HighLAND
ToFResolSystematics.cxx
1 #include "ToFResolSystematics.hxx"
2 #include "EventBoxTracker.hxx"
3 #include "Parameters.hxx"
4 
5 //********************************************************************
6 ToFResolSystematics::ToFResolSystematics():EventVariationBase(1), BinnedParams("ToFResolution", k1D_SYMMETRIC_NOMEAN){
7 //********************************************************************
8 
10 
11  // Get the systematic source values
12  GetSigmaValueForBin(0, _sigma_FGD1FGD2 );
13  GetSigmaValueForBin(1, _sigma_FGD1P0D_Track );
14  GetSigmaValueForBin(2, _sigma_FGD1ECAL_LAStartFgd_Track );
15  GetSigmaValueForBin(3, _sigma_FGD1ECAL_LAStartFgd_Shower );
16  GetSigmaValueForBin(4, _sigma_FGD1ECAL_LAEndFgd_Track );
17  GetSigmaValueForBin(5, _sigma_FGD1ECAL_LAEndFgd_Shower );
18  GetSigmaValueForBin(6, _sigma_FGD1ECAL_HAStartFgd_Track );
19  GetSigmaValueForBin(7, _sigma_FGD1ECAL_HAStartFgd_Shower );
20  GetSigmaValueForBin(8, _sigma_FGD1ECAL_HAEndFgd_Track );
21  GetSigmaValueForBin(9, _sigma_FGD1ECAL_HAEndFgd_Shower );
22 
23  _apply_ToF_based_Flip = (bool)ND::params().GetParameterI("psycheSystematics.ToF.ApplyToFFlip");
24 
25 }
26 
27 //********************************************************************
29 //********************************************************************
30 
31  // Get the SystBox for this event
32  SystBoxB* box = GetSystBox(event);
33  if (!box) return;
34 
35  // Loop though the tracks and apply the smearing
36  for (int i = 0; i<box->nRelevantRecObjects; i++){
37  AnaTrackB* track = static_cast<AnaTrackB*>(box->RelevantRecObjects[i]);
38 
40 
41  if(topo == ToFSenseCorrector::kToFTopo_FGD1FGD2)
42  track->ToF.FGD1_FGD2 += _sigma_FGD1FGD2 * toy.GetToyVariations(_index)->Variations[0];
43 
44  if(topo == ToFSenseCorrector::kToFTopo_FGD1P0D_Track)
45  track->ToF.P0D_FGD1 += _sigma_FGD1P0D_Track * toy.GetToyVariations(_index)->Variations[1];
46 
47  if(topo == ToFSenseCorrector::kToFTopo_FGD1ECAL_LAStartFgd_Track)
48  track->ToF.ECal_FGD1 += _sigma_FGD1ECAL_LAStartFgd_Track*toy.GetToyVariations(_index)->Variations[2];
49  if(topo == ToFSenseCorrector::kToFTopo_FGD1ECAL_LAStartFgd_Shower)
50  track->ToF.ECal_FGD1 += _sigma_FGD1ECAL_LAStartFgd_Shower*toy.GetToyVariations(_index)->Variations[3];
51  if(topo == ToFSenseCorrector::kToFTopo_FGD1ECAL_LAEndFgd_Track)
52  track->ToF.ECal_FGD1 += _sigma_FGD1ECAL_LAEndFgd_Track*toy.GetToyVariations(_index)->Variations[4];
53  if(topo == ToFSenseCorrector::kToFTopo_FGD1ECAL_LAEndFgd_Shower)
54  track->ToF.ECal_FGD1 += _sigma_FGD1ECAL_LAEndFgd_Shower*toy.GetToyVariations(_index)->Variations[5];
55  if(topo == ToFSenseCorrector::kToFTopo_FGD1ECAL_HAStartFgd_Track)
56  track->ToF.ECal_FGD1 += _sigma_FGD1ECAL_HAStartFgd_Track*toy.GetToyVariations(_index)->Variations[6];
57  if(topo == ToFSenseCorrector::kToFTopo_FGD1ECAL_HAStartFgd_Shower)
58  track->ToF.ECal_FGD1 += _sigma_FGD1ECAL_HAStartFgd_Shower*toy.GetToyVariations(_index)->Variations[7];
59  if(topo == ToFSenseCorrector::kToFTopo_FGD1ECAL_HAEndFgd_Track)
60  track->ToF.ECal_FGD1 += _sigma_FGD1ECAL_HAEndFgd_Track*toy.GetToyVariations(_index)->Variations[8];
61  if(topo == ToFSenseCorrector::kToFTopo_FGD1ECAL_HAEndFgd_Shower)
62  track->ToF.ECal_FGD1 += _sigma_FGD1ECAL_HAEndFgd_Shower*toy.GetToyVariations(_index)->Variations[9];
63 
64  // Then check whether a flipping is needed (since the ToF may have just changed), if the case then flip
65  if (_apply_ToF_based_Flip && _tofCorrector.CheckNeedApplyToFBasedFlip(*track, topo) ) ToFSenseCorrector::FlipTrack(*track);
66 
67  }
68 
69 }
70 
71 //********************************************************************
73 //********************************************************************
74 
75  // Get the SystBox for this event
76  SystBoxB* box = GetSystBox(event);
77 
78  for (int i = 0; i < box->nRelevantRecObjects; i++){
79  AnaTrackB* track = static_cast<AnaTrackB*>(box->RelevantRecObjects[i]);
80  if(!track->Original){ std::cout<<"ToFResolSystematics::UndoSystematic:: No original object , not able to undo variation"<<std::endl; continue; }
81  const AnaTrackB* orig = static_cast<const AnaTrackB*>(track->Original);
82 
83  if(track->ToF.Flag_FGD1_FGD2)
84  track->ToF.FGD1_FGD2 = orig->ToF.FGD1_FGD2;
85 
86  if(track->ToF.Flag_P0D_FGD1)
87  track->ToF.P0D_FGD1 = orig->ToF.P0D_FGD1;
88 
89  if(track->ToF.Flag_ECal_FGD1)
90  track->ToF.ECal_FGD1 = orig->ToF.ECal_FGD1;
91 
92  if(track->ToF.Flag_ECal_FGD2)
93  track->ToF.ECal_FGD2 = orig->ToF.ECal_FGD2;
94 
95  // Flip back if needed
97  if (_apply_ToF_based_Flip && _tofCorrector.CheckNeedApplyToFBasedFlip(*track, topo) ) ToFSenseCorrector::FlipTrack(*track);
98 
99  }
100 
101  return false;
102 }
103 
104 //********************************************************************
106 //********************************************************************
107 
108  // Consider all tracks that can be potentially useful for analysis: this also includes veto tracks
109  // so no need to stick to a particular FGD (and yep, not then considering P0D-ECal objects)
110  (void)sel;
111  IDs[0] = EventBoxTracker::kTracksWithTPCorFGD1;
112  IDs[1] = EventBoxTracker::kTracksWithTPCorFGD2;
113 
114  return 2;
115 
116 }
Int_t _index
The index of this systematic (needed by SystematicsManager);.
Float_t * Variations
the vector of Variations, one for each of the systematic parameters
Int_t GetRelevantRecObjectGroups(const SelectionBase &sel, Int_t *IDs) const
Get the TrackGroup IDs array for this systematic.
SystBoxB * GetSystBox(const AnaEventC &event, Int_t isel=0, Int_t ibranch=0) const
Get the SystBox corresponding to a selection, branch and event.
void SetNParameters(int N)
Set the number of systematic parameters associated to this systematic.
AnaToF ToF
Times of flight between pairs of detectors.
static void FlipTrack(AnaTrackB &track)
Flip a track.
static ToFTopology GetToFTopology(const AnaTrackB &track)
const AnaParticleB * Original
Representation of a global track.
ToyVariations * GetToyVariations(UInt_t index) const
returns the variations for a given systematic (index)
Int_t nRelevantRecObjects
----—— Relevant rec objects and true objects for each systematic ------------—— ...
Definition: SystBoxB.hxx:20
Int_t GetNBins()
Get the number of bins.
virtual void Apply(const ToyExperiment &toy, AnaEventC &event)
Apply the systematic.
bool GetSigmaValueForBin(Int_t index, Float_t &sigma)
Get only mean or sigma.
virtual bool UndoSystematic(AnaEventC &event)
Undo the systematic variations done by ApplyVariation. This is faster tha reseting the full Spill...