HighLAND
UseGlobalAltMomCorrection.cxx
1 #include "UseGlobalAltMomCorrection.hxx"
2 #include "DataClasses.hxx"
3 #include "HighlandAnalysisUtils.hxx"
4 
5 //********************************************************************
7 //********************************************************************
8  _hyp = hypothesis;
9 }
10 
11 //********************************************************************
13 //********************************************************************
14 
15  AnaSpill& spill = *static_cast<AnaSpill*>(&spillBB);
16 
17  for (unsigned int i = 0; i < spill.Bunches.size(); i++) {
18  AnaTrackB* tracks[100];
19  AnaBunch* bunch = static_cast<AnaBunch*>(spill.Bunches[i]);
20  int nTPC = anaUtils::GetAllTracksUsingDet(*bunch, SubDetId::kTPC, tracks);
21  for (Int_t j = 0; j < nTPC; j++) {
22  AnaTrack* track = static_cast<AnaTrack*>(tracks[j]);
23 
24  if (_hyp == kMuon) {
25  track->Momentum = track->MomentumMuon;
26  track->MomentumError = track->MomentumErrorMuon;
27  } else if (_hyp == kElectron) {
28  track->Momentum = track->MomentumEle;
29  track->MomentumError = track->MomentumErrorEle;
30  } else if (_hyp == kProton) {
31  track->Momentum = track->MomentumProton;
32  track->MomentumError = track->MomentumErrorProton;
33  }
34  }
35 
36  // TODO. Removed because AnaParticle does not have momentum now
37  // Sort all particles by momentum after correction (using GetAllTracks the sorting doesn't work!)
38  // std::sort(spill.Bunches.at(i)->Particles.begin(), spill.Bunches.at(i)->Particles.end(), AnaTrack::CompareMomentum);
39 
40  }
41  /*
42 
43  // Sort all particles constituents of each global vertex by momentum after correction
44  // to be done after filling all bunches (because there might be associated particles from other bunches)
45  for (unsigned int i = 0; i < spill.Bunches.size(); i++) {
46  std::vector<AnaVertexB*> allVertices = (*(static_cast<AnaBunch*>(spill.Bunches.at(i)))).Vertices;
47  for (unsigned int j = 0; j < allVertices.size(); j++)
48  std::sort(allVertices.at(j)->Particles, allVertices.at(j)->Particles+allVertices.at(j)->nParticles, AnaTrack::CompareMomentum);
49  }
50 
51  // Sort all particles associated to each true vertex by momentum after correction
52  std::vector<AnaTrueVertexB*> allTrueVertices = spill.TrueVertices;
53  for (unsigned int j = 0; j < allTrueVertices.size(); j++){
54  AnaTrueVertex * tvertex = static_cast<AnaTrueVertex*>(allTrueVertices.at(j));
55  std::sort(tvertex->ReconParticles.begin(), tvertex->ReconParticles.end(), AnaTrack::CompareMomentum);
56  }
57 
58  // Sort all particles associated to each true particle by momentum after correction
59  std::vector<AnaTrueParticleB*> allTrueParticles = spill.TrueParticles;
60  for (unsigned int j = 0; j < allTrueParticles.size(); j++){
61  AnaTrueParticle * tparticle = static_cast<AnaTrueParticle*>(allTrueParticles.at(j));
62  std::sort(tparticle->ReconParticles.begin(), tparticle->ReconParticles.end(), AnaTrack::CompareMomentum);
63  }
64  */
65 }
66 
Representation of a global track.
Float_t MomentumEle
Momentum from refitting the track assuming the electron hypothesis.
std::vector< AnaBunchC * > Bunches
The reconstructed objects, split into timing bunches.
Float_t MomentumErrorProton
Error on momentum from refitting the track assuming the proton hypothesis.
All corrections should be registered with the CorrectionManager.
Float_t Momentum
The reconstructed momentum of the particle, at the start position.
Float_t MomentumErrorMuon
Error on momentum from refitting the track assuming the muon hypothesis.
Hypothesis
Enumerator describing the refits that are available.
Float_t MomentumErrorEle
Error on momentum from refitting the track assuming the electron hypothesis.
Representation of a global track.
Float_t MomentumError
The error on the reconstructed momentum.
int GetAllTracksUsingDet(const AnaBunchB &bunch, SubDetId::SubDetEnum det, AnaTrackB *selTracks[])
void Apply(AnaSpillC &spill)
Apply the variation to all tracks with TPC info.
Float_t MomentumMuon
Momentum from refitting the track assuming the muon hypothesis.
Float_t MomentumProton
Momentum from refitting the track assuming the proton hypothesis.