HighLAND
MomRangeCorrection.cxx
1 #include "MomRangeCorrection.hxx"
2 #include "CutUtils.hxx"
3 
4 
5 //#define UseRecPack
6 #ifdef UseRecPack
7 #include "AnaRecPackManager.hxx"
8 #endif
9 
10 
11 //********************************************************************
12 MomRangeCorrection::MomRangeCorrection(SubDetId::SubDetEnum det) : CorrectionBase(){
13  //********************************************************************
14  _det = det;
15 }
16 
17 //********************************************************************
19  //********************************************************************
20 
21  AnaSpill& spill = *static_cast<AnaSpill*>(&spillBB);
22 
23  for (UInt_t i = 0; i < spill.Bunches.size(); i++) {
24  AnaBunch* bunch = static_cast<AnaBunch*>(spill.Bunches[i]);
25  for (UInt_t j = 0; j < bunch->Particles.size(); j++) {
26 
27  AnaTrackB* track = static_cast<AnaTrackB*>(bunch->Particles[j]);
28  if (!track) continue;
29 
30  // Check whether a track is relevant to apply the correction
31  if (!IsRelevantTrack(*track)) continue;
32 
33 #ifdef UseRecPack
34  double mom_range;
35  track->RangeMomentumMuon = -999.;
36  if (ND::tman().GetMomentumFromRangeLinear(*track, mom_range, ParticleId::kMuon))
37  track->RangeMomentumMuon = (Float_t)mom_range;
38 #endif
39 
40  }
41  }
42 }
43 
44 //********************************************************************
45 bool MomRangeCorrection::IsRelevantTrack(const AnaTrackB& track) const{
46  //********************************************************************
47 
48  if (!SubDetId::GetDetectorUsed(track.Detector, _det)) return false;
49 
50  // Should fail TPC track quality cut
51  if (cutUtils::TrackQualityCut(track)) return false;
52 
53  // Should start or stop in the volume of interest
54  if (!anaUtils::InDetVolume(_det, track.PositionStart) &&
55  !anaUtils::InDetVolume(_det, track.PositionEnd)) return false;
56 
57  return true;
58 }
59 
Float_t PositionStart[4]
The reconstructed start position of the particle.
unsigned long Detector
std::vector< AnaBunchC * > Bunches
The reconstructed objects, split into timing bunches.
static bool GetDetectorUsed(unsigned long BitField, SubDetId::SubDetEnum det)
Method to see if a certain subdetector or subdetector system is used.
Definition: SubDetId.cxx:40
All corrections should be registered with the CorrectionManager.
Float_t RangeMomentumMuon
Momentum by range calculated with muon hypothesis.
void Apply(AnaSpillC &spill)
SubDetEnum
Enumeration of all detector systems and subdetectors.
Definition: SubDetId.hxx:25
Representation of a global track.
bool InDetVolume(SubDetId::SubDetEnum det, const Float_t *pos)
std::vector< AnaParticleB * > Particles
Float_t PositionEnd[4]
The reconstructed end position of the particle.