HighLAND
MomentumScaleSystematics.cxx
1 #include "MomentumScaleSystematics.hxx"
2 #include "ND280AnalysisUtils.hxx"
3 #include "EventBoxTracker.hxx"
4 #include "Parameters.hxx"
5 
6 //#define DEBUG
7 
8 
9 //********************************************************************
11 //********************************************************************
12 
13  _useP0DFV = (bool) ND::params().GetParameterI("psycheSystematics.Tracker.UseP0DFV");
14 
15  // Get the systematic source values
17 }
18 
19 //********************************************************************
21 //********************************************************************
22 
23  // Get the SystBox for this event
24  SystBoxB* box = GetSystBox(event);
25 
26 #ifdef DEBUG
27  std::cout << "MomentumScaleSystematics::ApplyVariation(): " << box->nRelevantRecObjects <<" and? "<<box->nRelevantRecObjects<< std::endl;
28 #endif
29  if (_useP0DFV) {
30  ApplyP0DTPC(toy,event);
31  return;
32  }
33 
34  // loop over the relevant tracks for this systematic
35  for (Int_t itrk=0;itrk<box->nRelevantRecObjects;itrk++){
36  AnaTrackB* track = static_cast<AnaTrackB*>(box->RelevantRecObjects[itrk]);
37 
38 #ifdef DEBUG
39  std::cout << itrk << " --> p0 = " << track->Momentum << std::endl;
40 #endif
41 
42  // Apply the momentum scale factor
43  track->Momentum *=(1 + _scaleError * toy.GetToyVariations(_index)->Variations[0]);
44 
45 #ifdef DEBUG
46  std::cout << "p = " << p << std::endl;
47 #endif
48  }
49 }
50 
51 //********************************************************************
52 void MomentumScaleSystematics::ApplyP0DTPC(const ToyExperiment& toy, AnaEventC& event)
53 //********************************************************************
54 {
55  SystBoxB* box = GetSystBox(event);
56 
57 #ifdef DEBUG
58  std::cout << "MomentumScaleSystematics::ApplyVariation(): " << box->nRelevantRecObjects <<" and? "<<toy.Variations[0]<< std::endl;
59 #endif
60 
61  // loop over the relevant tracks for this systematic
62  for (Int_t itrk=0;itrk<box->nRelevantRecObjects;itrk++){
63  AnaTrackB* track = static_cast<AnaTrackB*>(box->RelevantRecObjects[itrk]);
64  AnaP0DParticleB* p0dTrack = track->P0DSegments[0];
65  if (!p0dTrack || p0dTrack->ELoss < 0) continue;
66 
67  double trackerMomentum = track->Momentum - p0dTrack->ELoss;
68 
69 #ifdef DEBUG
70  std::cout << itrk << " --> p0 = " << track->Momentum << std::endl;
71 #endif
72 
73  // Apply the momentum scale factor. This is modified from the
74  // default MomentumScaleSystematics to scale only the
75  // TrackerMomentum component.
76  track->Momentum = track->Momentum + trackerMomentum * (_scaleError*toy.GetToyVariations(_index)->Variations[0]);
77 
78 #ifdef DEBUG
79  std::cout << "p = " << track->Momentum << std::endl;
80 #endif
81  }
82 
83 
84 }
85 
86 
87 
88 //********************************************************************
90 //********************************************************************
91 
92  // Get the SystBox for this event
93  SystBoxB* box = GetSystBox(event);
94 
95  for (Int_t itrk=0;itrk<box->nRelevantRecObjects;itrk++){
96  AnaTrackB* track = static_cast<AnaTrackB*>(box->RelevantRecObjects[itrk]);
97  // Go back to the corrected momentum
98  track->Momentum = track->GetOriginalTrack()->Momentum;
99  }
100 
101  // Don't reset the spill to corrected
102  return false;
103 }
104 
105 //********************************************************************
107 //********************************************************************
108 
109  Int_t ngroups=0;
110  for (UInt_t b=0; b<sel.GetNBranches(); b++){
111  SubDetId_h det = sel.GetDetectorFV(b);
112  if (det == SubDetId::kFGD1 || det == SubDetId::kFGD){
113  IDs[ngroups++] = EventBoxTracker::kTracksWithTPCInFGD1FV;
114  }
115  if (det == SubDetId::kFGD2 || det == SubDetId::kFGD){
116  IDs[ngroups++] = EventBoxTracker::kTracksWithTPCInFGD2FV;
117  }
118  if (det == SubDetId::kP0D){
119  IDs[ngroups++] = EventBoxTracker::kTracksWithTPCInP0DFV;
120  }
121  }
122 
123  return ngroups;
124 }
Int_t _index
The index of this systematic (needed by SystematicsManager);.
const AnaTrackB * GetOriginalTrack() const
Return a casted version of the original AnaParticleB associated.
AnaP0DParticleB * P0DSegments[NMAXP0DS]
The P0D segments that contributed to this global track.
Float_t * Variations
the vector of Variations, one for each of the systematic parameters
int GetParameterI(std::string)
Get parameter. Value is returned as integer.
Definition: Parameters.cxx:217
SystBoxB * GetSystBox(const AnaEventC &event, Int_t isel=0, Int_t ibranch=0) const
Get the SystBox corresponding to a selection, branch and event.
bool UndoSystematic(AnaEventC &event)
Undo the systematic variations done by ApplyVariation. This is faster tha reseting the full Spill...
Float_t Momentum
The reconstructed momentum of the particle, at the start position.
void Apply(const ToyExperiment &toy, AnaEventC &event)
Apply the systematic.
Int_t GetRelevantRecObjectGroups(const SelectionBase &sel, Int_t *IDs) const
Get the TrackGroup IDs array for this systematic.
Float_t _scaleError
Width of the scale distribution.
Representation of a global track.
ToyVariations * GetToyVariations(UInt_t index) const
returns the variations for a given systematic (index)
UInt_t GetNBranches() const
Return the number of branches.
Int_t nRelevantRecObjects
----—— Relevant rec objects and true objects for each systematic ------------—— ...
Definition: SystBoxB.hxx:20
Representation of a P0D segment of a global track.
SubDetId_h GetDetectorFV(Int_t ibranch=0) const
Get the detector in which the Fiducial Volume is defined.
bool GetSigmaValueForBin(Int_t index, Float_t &sigma)
Get only mean or sigma.