HighLAND
FlipKinematicsCorrection.cxx
1 #include "FlipKinematicsCorrection.hxx"
2 #include "ToFSenseCorrector.hxx"
3 #include "CutUtils.hxx"
4 
5 //#define UseRecPack
6 #ifdef UseRecPack
7 #include "AnaRecPackManager.hxx"
8 #endif
9 
10 
11 
12 //********************************************************************
13 FlipKinematicsCorrection::FlipKinematicsCorrection(SubDetId::SubDetEnum det) : CorrectionBase(){
14  //********************************************************************
15  _det = det;
16 }
17 
18 //********************************************************************
20 //********************************************************************
21 
22 
23  AnaSpill& spill = *static_cast<AnaSpill*>(&spillC);
24 
25  for (UInt_t i = 0; i < spill.Bunches.size(); i++) {
26  AnaBunch* bunch = static_cast<AnaBunch*>(spill.Bunches[i]);
27  for (UInt_t j = 0; j < bunch->Particles.size(); j++) {
28 
29  AnaTrack* track = static_cast<AnaTrack*>(bunch->Particles[j]);
30 
31  if (!track) continue;
32 
33  // Check whether a track is relevant to apply the correction
34  if (!IsRelevantTrack(*track)) continue;
35 
37 
38  if (!tpcTrack) continue;
39 
40  if (!cutUtils::TPCTrackQualityCut(*tpcTrack)) continue;
41 
42 #ifdef UseRecPack
43  track->MomentumFlip = -999.;
44  double momentum_tmp = tpcTrack->MomentumEnd;
45  if (ND::tman().CorrectEnergyLossLinear(tpcTrack->PositionEnd, track->PositionEnd, momentum_tmp,
46  ParticleId::GetParticle(track->ReconPDG), AnaRecPackManager::kBwd)) // from closest TPC endpoint and to track end backwards
47  track->MomentumFlip = momentum_tmp;
48 
49 
50 #else
51  std::cout << " WARNING! FlipKinematicsCorrection is run w/o highlandRecPack usage. \n"
52  " It is highly recommended to use RecPack to restore possible fit failures of the \n"
53  " global recon re-fits with opposite track sense hypotheis assumes (end to start) " << std::endl;
54 
55 #endif
56 
57  }
58  }
59 }
60 
61 //********************************************************************
63  //********************************************************************
64 
65  if (!SubDetId::GetDetectorUsed(track.Detector, _det)) return false;
66 
67  if (!SubDetId::GetDetectorUsed(track.Detector, SubDetId::kTPC)) return false;
68 
69 
70  if (ToFSenseCorrector::GetToFTopology(track) == ToFSenseCorrector::kToFInvalid) return false;
71 
72  return true;
73 
74 }
75 
Representation of a global track.
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 MomentumFlip
Momentum for the main PID hypothesis and reverse sense.
static ToFTopology GetToFTopology(const AnaTrackB &track)
SubDetEnum
Enumeration of all detector systems and subdetectors.
Definition: SubDetId.hxx:25
Representation of a global track.
Float_t MomentumEnd
The reconstructed momentum of the particle, at the end position.
std::vector< AnaParticleB * > Particles
Representation of a TPC segment of a global track.
AnaParticleB * GetSegmentWithMostNodesInClosestTpc(const AnaTrackB &track)
Combined function to address NuMu selection needs as efficiently as possible - gets the TPC segment w...
Int_t ReconPDG
PDG of the most probable particle hypothesis used at reconstruction level.
Float_t PositionEnd[4]
The reconstructed end position of the particle.
bool IsRelevantTrack(const AnaTrackB &track) const