HighLAND
baseTrackerAnalysis.cxx
1 #include "baseTrackerAnalysis.hxx"
2 
3 #include "BFieldDistortionSystematics.hxx"
4 #include "MomentumScaleSystematics.hxx"
5 #include "MomentumResolSystematics.hxx"
6 #include "MomRangeResolSystematics.hxx"
7 #include "TPCPIDSystematics.hxx"
8 #include "TPCClusterEffSystematics.hxx"
9 #include "FGDPIDSystematics.hxx"
10 
11 #include "PileUpSystematics.hxx"
12 #include "FGDMassSystematics.hxx"
13 #include "OOFVSystematics.hxx"
14 #include "SandMuonsSystematics.hxx"
15 
16 // ECal EM
17 #include "ECalEMEnergyResolSystematics.hxx"
18 #include "ECalEMEnergyScaleSystematics.hxx"
19 
20 // ToF
21 #include "ToFResolSystematics.hxx"
22 
23 // nue Pile-up systematics
24 #include "nueP0DPileUpSystematics.hxx"
25 #include "nueTPCPileUpSystematics.hxx"
26 #include "nueECalPileUpSystematics.hxx"
27 #include "nueOOFVSystematics.hxx"
28 
29 //P0D Systematics stuff
30 #include "P0DVetoSystematics.hxx"
31 #include "P0DELossScaleSystematics.hxx"
32 #include "P0DELossResolSystematics.hxx"
33 
34 // TPC PID Corrections
35 #include "TPCdEdxDataCorrection.hxx"
36 #include "TPCdEdxMCCorrection.hxx"
37 #include "TPCExpecteddEdxCorrection.hxx"
38 #include "TPCPIDPullMCCorrection.hxx"
39 
40 #include "PileUpCorrection.hxx"
41 #include "MomResolMCCorrection.hxx"
42 
43 #include "FlipKinematicsCorrection.hxx"
44 #include "ToFCorrection.hxx"
45 #include "MomRangeCorrection.hxx"
46 
47 #include "baseToyMaker.hxx"
48 
49 //********************************************************************
51 //********************************************************************
52 
53  _chargeid = NULL;
54  _tpcfgdmatch = NULL;
55  _tpctr = NULL;
56  _fgdtr = NULL;
57  _fgdhybtr = NULL;
58  _me = NULL;
59  _tpc_ecal_matcheff = NULL;
60  _tpc_p0d_matcheff = NULL;
61  _fgd_ecal_matcheff = NULL;
62  _fgd_ecal_smrd_matcheff = NULL;
63  _ecal_trackeff = NULL;
64  _ecal_pid = NULL;
65  _fgd2shower = NULL;
66 
67  // Add the package version
68  ND::versioning().AddPackage("baseTrackerAnalysis", anaUtils::GetSoftwareVersionFromPath((std::string)getenv("BASETRACKERANALYSISROOT")));
69 
70  // Don't compute efficiencies by default
71  _computeEfficiency = false;
72 }
73 
74 //********************************************************************
76 //********************************************************************
77 
78  //------------ Add Variation systematics ------------
79  //! [baseTrackerAnalysis_varsyst]
80  evar().AddEventVariation(SystId::kBFieldDist, "BFieldDist", new BFieldDistortionSystematics());
81  evar().AddEventVariation(SystId::kMomScale, "MomScale", new MomentumScaleSystematics());
82  evar().AddEventVariation(SystId::kMomResol, "MomResol", new MomentumResolSystematics());
83  evar().AddEventVariation(SystId::kMomRangeResol, "MomRangeResol", new MomRangeResolSystematics());
84  evar().AddEventVariation(SystId::kTpcPid, "TpcPid", new TPCPIDSystematics());
85  evar().AddEventVariation(SystId::kFgdPid, "FgdPid", new FGDPIDSystematics());
86  //! [baseTrackerAnalysis_varsyst]
87 
88  evar().AddEventVariation(SystId::kECalEMResol, "ECalEMResol", new ECalEMEnergyResolSystematics());
89  evar().AddEventVariation(SystId::kECalEMScale, "ECalEMScale", new ECalEMEnergyScaleSystematics());
90 
91  evar().AddEventVariation(SystId::kToFResol, "ToFResol", new ToFResolSystematics());
92  evar().AddEventVariation(SystId::kP0DELossScale, "P0DELossScale", new P0DELossScaleSystematics());
93  evar().AddEventVariation(SystId::kP0DELossResol, "P0DELossResol", new P0DELossResolSystematics());
94 
95 
96  //-------------- Add Event Weights ------------------
97 
98  // compute efficiency using truth for eff-like systematics
99  _computeEfficiency = (bool)ND::params().GetParameterI("baseTrackerAnalysis.Systematics.ComputeEfficiency");
100 
101  _chargeid = new ChargeIDEffSystematics( _computeEfficiency);
102  _tpcfgdmatch = new TPCFGDMatchEffSystematics( _computeEfficiency);
107  _tpc_ecal_matcheff = new TPCECalMatchEffSystematics( _computeEfficiency);
108  _tpc_p0d_matcheff = new TPCP0DMatchEffSystematics( _computeEfficiency);
109  _fgd_ecal_matcheff = new FGDECalMatchEffSystematics( _computeEfficiency);
110  _fgd_ecal_smrd_matcheff = new FGDECalSMRDMatchEffSystematics( _computeEfficiency);
111  _ecal_trackeff = new ECalTrackEffSystematics( _computeEfficiency);
112  _ecal_pid = new ECalPIDSystematics( _computeEfficiency);
113  _ecal_emhippid = new ECalEmHipPIDSystematics( _computeEfficiency);
114  _fgd2shower = new FGD2ShowerSystematics( _computeEfficiency);
115 
116  //BELOW the order is the same as in psyche, so that each throws can be exactly the same as in psyche.
117  eweight().AddEventWeight(SystId::kChargeIDEff, "ChargeIDEff", _chargeid);
118  eweight().AddEventWeight(SystId::kTpcClusterEff, "TpcClusterEff", new TPCClusterEffSystematics());
119  eweight().AddEventWeight(SystId::kTpcTrackEff, "TpcTrackEff", _tpctr);
120  eweight().AddEventWeight(SystId::kTpcFgdMatchEff, "TpcFgdMatchEff", _tpcfgdmatch);
121  eweight().AddEventWeight(SystId::kFgdTrackEff, "FgdTrackEff", _fgdtr);
122  eweight().AddEventWeight(SystId::kFgdHybridTrackEff, "FgdHybridTrackEff", _fgdhybtr);
123  eweight().AddEventWeight(SystId::kMichelEleEff, "MichelEleEff", _me);
124  //! [baseTrackerAnalysis_weightsyst]
125  eweight().AddEventWeight(SystId::kPileUp, "PileUp", new PileUpSystematics());
126  eweight().AddEventWeight(SystId::kFgdMass, "FgdMass", new FGDMassSystematics());
127  eweight().AddEventWeight(SystId::kOOFV, "OOFV", new OOFVSystematics());
128  eweight().AddEventWeight(SystId::kSandMu, "SandMu", new SandMuonsSystematics());
129  //! [baseTrackerAnalysis_weightsyst]
130  eweight().AddEventWeight(SystId::kTpcECalMatchEff, "TpcECalMatchEff", _tpc_ecal_matcheff);
131  eweight().AddEventWeight(SystId::kTpcP0dMatchEff, "TpcP0dMatchEff", _tpc_p0d_matcheff);
132  eweight().AddEventWeight(SystId::kFgdECalMatchEff, "FgdECalMatchEff", _fgd_ecal_matcheff);
133  eweight().AddEventWeight(SystId::kFgdECalSmrdMatchEff, "FgdECalSMRDMatchEff", _fgd_ecal_smrd_matcheff);
134  eweight().AddEventWeight(SystId::kECalTrackEff, "ECalTrackEff", _ecal_trackeff);
135  eweight().AddEventWeight(SystId::kECalPID, "ECalPID", _ecal_pid);
136  eweight().AddEventWeight(SystId::kECalEmHipPID, "ECalEmHipPID", _ecal_emhippid);
137  eweight().AddEventWeight(SystId::kFGD2Shower, "Fgd2Shower", _fgd2shower);
138  eweight().AddEventWeight(SystId::kNuETPCPileUp, "nueTPCPileup", new nueTPCPileUpSystematics());
139  eweight().AddEventWeight(SystId::kNuEP0DPileUp, "nueP0DPileup", new nueP0DPileUpSystematics());
140  eweight().AddEventWeight(SystId::kNuEECalPileUp, "nueEcalPileup", new nueECalPileUpSystematics());
141  eweight().AddEventWeight(SystId::kNuEOOFV, "nueOOFV", new nueOOFVSystematics());
142  eweight().AddEventWeight(SystId::kP0DVeto, "P0DVeto", new P0DVetoSystematics());
143 
144  // This must be called here (after adding all other systematics) such that the order in which they are added is the same as before (in baseAnalysis).
145  // Otherwise the random throws will be different. TODO. Is this still true ?
146  baseAnalysis::DefineSystematics();
147 }
148 
149 //********************************************************************
150 void baseTrackerAnalysis::DefineCorrections(){
151 //********************************************************************
152 
153  baseAnalysis::DefineCorrections();
154 
155  //----------- Define all corrections ----------------
156  if (ND::params().GetParameterI("baseTrackerAnalysis.Corrections.DisableAllCorrections")){
157  // Should not be needed, but just in case !!!
158  corr().DisableAllCorrections();
159  }
160  else{
161  // Add corrections only when they are enabled. In that way the CorrectionManager does not have to loop over unused corrections
162  if ((bool)ND::params().GetParameterI("baseTrackerAnalysis.Corrections.EnablePileUp")) corr().AddCorrection("pileup_corr", new PileUpCorrection());
163  if ((bool)ND::params().GetParameterI("baseTrackerAnalysis.Corrections.EnableTPCdEdxData")) corr().AddCorrection("tpcdedx_data_corr", new TPCdEdxDataCorrection());
164  if ((bool)ND::params().GetParameterI("baseTrackerAnalysis.Corrections.EnableTPCdEdxMC")) corr().AddCorrection("tpcdedx_mc_corr", new TPCdEdxMCCorrection());
165  if ((bool)ND::params().GetParameterI("baseTrackerAnalysis.Corrections.EnableTPCExpecteddEdx")) corr().AddCorrection("tpcexpecteddedx_corr", new TPCExpecteddEdxCorrection());
166 
167  // TPC PID correction based on pull params smearing
168  if ((bool)ND::params().GetParameterI("baseTrackerAnalysis.Corrections.EnableTPCPIDPullMC")) corr().AddCorrection("tpc_pid_pull_mc_corr", new TPCPIDPullMCCorrection());
169 
170  // Smear MC momentum to match resolution in data
171  if ((bool)ND::params().GetParameterI("baseTrackerAnalysis.Corrections.EnableMomResolMC")) corr().AddCorrection("mom_resol_mc_corr", new MomResolMCCorrection());
172 
173  // Need to be called before the ToF in order to correctly flip a track if required
174  if ((bool)ND::params().GetParameterI("baseTrackerAnalysis.Corrections.EnableFlipKinematicsCorrection"))
175  corr().AddCorrection("flipkinematics_corr", new FlipKinematicsCorrection());
176 
177  if ((bool)ND::params().GetParameterI("baseTrackerAnalysis.Corrections.EnableToFCorrection"))
178  // need to make sure that the kinematics is ready for flip, i.e. alternate reverse momentum was fixed
179  corr().AddCorrection("tof_corr", new ToFCorrection());
180 
181  if ((bool)ND::params().GetParameterI("baseTrackerAnalysis.Corrections.EnableMomRangeCorrection"))
182  corr().AddCorrection("momrange_corr", new MomRangeCorrection());
183 
184 
185  }
186 }
187 
188 //********************************************************************
190 //********************************************************************
191 
192  // Define all configuration of the base package
193  baseAnalysis::DefineConfigurations();
194 
195  //------- Add and define individual configurations with one systematic only ------------------
196 
197  if (_enableSingleVariationSystConf){
198  if (ND::params().GetParameterI("baseTrackerAnalysis.Variations.EnableBFieldDist")){
199  AddConfiguration(conf(), bfield_syst, _ntoys, _randomSeed, new baseToyMaker(_randomSeed));
200  conf().EnableEventVariation(SystId::kBFieldDist,bfield_syst);
201  }
202  if (ND::params().GetParameterI("baseTrackerAnalysis.Variations.EnableMomScale")){
203  AddConfiguration(conf(), momscale_syst, _ntoys, _randomSeed, new baseToyMaker(_randomSeed));
204  conf().EnableEventVariation(SystId::kMomScale,momscale_syst);
205  }
206  if (ND::params().GetParameterI("baseTrackerAnalysis.Variations.EnableMomRes")){
207  AddConfiguration(conf(), momresol_syst, _ntoys, _randomSeed, new baseToyMaker(_randomSeed));
208  conf().EnableEventVariation(SystId::kMomResol,momresol_syst);
209  }
210  if (ND::params().GetParameterI("baseTrackerAnalysis.Variations.EnableMomRangeRes")){
211  AddConfiguration(conf(), momrange_resol_syst, _ntoys, _randomSeed, new baseToyMaker(_randomSeed));
212  conf().EnableEventVariation(SystId::kMomRangeResol,momrange_resol_syst);
213  }
214  if (ND::params().GetParameterI("baseTrackerAnalysis.Variations.EnableTPCPID")){
215  AddConfiguration(conf(), tpcpid_syst, _ntoys, _randomSeed, new baseToyMaker(_randomSeed));
216  conf().EnableEventVariation(SystId::kTpcPid,tpcpid_syst);
217  }
218  if (ND::params().GetParameterI("baseTrackerAnalysis.Variations.EnableFGDPID")){
219  AddConfiguration(conf(), fgdpid_syst, _ntoys, _randomSeed, new baseToyMaker(_randomSeed));
220  conf().EnableEventVariation(SystId::kFgdPid, fgdpid_syst);
221  }
222  if (ND::params().GetParameterI("baseTrackerAnalysis.Variations.EnableECalEMResol")){
223  AddConfiguration(conf(), ecal_emresol_syst, _ntoys, _randomSeed, new baseToyMaker(_randomSeed));
224  conf().EnableEventVariation(SystId::kECalEMResol, ecal_emresol_syst);
225  }
226  if (ND::params().GetParameterI("baseTrackerAnalysis.Variations.EnableECalEMScale")){
227  AddConfiguration(conf(), ecal_emscale_syst, _ntoys, _randomSeed, new baseToyMaker(_randomSeed));
228  conf().EnableEventVariation(SystId::kECalEMScale, ecal_emscale_syst);
229  }
230  if (ND::params().GetParameterI("baseTrackerAnalysis.Variations.EnableToFResol")){
231  AddConfiguration(conf(), tof_resol_syst, _ntoys, _randomSeed, new baseToyMaker(_randomSeed));
232  conf().EnableEventVariation(SystId::kToFResol, tof_resol_syst);
233  }
234  if (ND::params().GetParameterI("baseTrackerAnalysis.Variations.EnableP0DELossScale")){
235  AddConfiguration(conf(), p0d_elossscale_syst, _ntoys, _randomSeed, new baseToyMaker(_randomSeed));
236  conf().EnableEventVariation(SystId::kP0DELossScale, p0d_elossscale_syst);
237  }
238  if (ND::params().GetParameterI("baseTrackerAnalysis.Variations.EnableP0DELossResol")){
239  AddConfiguration(conf(), p0d_elossresol_syst, _ntoys, _randomSeed, new baseToyMaker(_randomSeed));
240  conf().EnableEventVariation(SystId::kP0DELossResol, p0d_elossresol_syst);
241  }
242  }
243 
244  if (_enableSingleWeightSystConf){
245  if (ND::params().GetParameterI("baseTrackerAnalysis.Weights.EnableChargeConf")){
246  AddConfiguration(conf(), chargeideff_syst, _ntoys, _randomSeed, new baseToyMaker(_randomSeed));
247  conf().EnableEventWeight(SystId::kChargeIDEff, chargeideff_syst);
248  }
249  if (ND::params().GetParameterI("baseTrackerAnalysis.Weights.EnableTPCTrackEff")){
250  AddConfiguration(conf(), tpctrackeff_syst, _ntoys, _randomSeed, new baseToyMaker(_randomSeed));
251  conf().EnableEventWeight(SystId::kTpcTrackEff,tpctrackeff_syst);
252  }
253  if (ND::params().GetParameterI("baseTrackerAnalysis.Weights.EnableFGDTrackEff")){
254  AddConfiguration(conf(), fgdtrackeff_syst, _ntoys, _randomSeed, new baseToyMaker(_randomSeed));
255  conf().EnableEventWeight(SystId::kFgdTrackEff,fgdtrackeff_syst);
256  }
257  if (ND::params().GetParameterI("baseTrackerAnalysis.Weights.EnableFGDHybridTrackEff")){
258  AddConfiguration(conf(), fgdhybridtrackeff_syst, _ntoys, _randomSeed, new baseToyMaker(_randomSeed));
259  conf().EnableEventWeight(SystId::kFgdHybridTrackEff,fgdhybridtrackeff_syst);
260  }
261  if (ND::params().GetParameterI("baseTrackerAnalysis.Weights.EnableTPCFGDMatchEff")){
262  AddConfiguration(conf(), tpcfgdmatcheff_syst, _ntoys, _randomSeed, new baseToyMaker(_randomSeed));
263  conf().EnableEventWeight(SystId::kTpcFgdMatchEff,tpcfgdmatcheff_syst);
264  }
265  if (ND::params().GetParameterI("baseTrackerAnalysis.Weights.EnableOOFV")){
266  AddConfiguration(conf(), oofv_syst, _ntoys, _randomSeed, new baseToyMaker(_randomSeed));
267  conf().EnableEventWeight(SystId::kOOFV,oofv_syst);
268  }
269  if (ND::params().GetParameterI("baseTrackerAnalysis.Weights.EnablePileUp")){
270  AddConfiguration(conf(), pileup_syst, _ntoys, _randomSeed, new baseToyMaker(_randomSeed));
271  conf().EnableEventWeight(SystId::kPileUp,pileup_syst);
272  }
273  if (ND::params().GetParameterI("baseTrackerAnalysis.Weights.EnableFGDMass")){
274  AddConfiguration(conf(), fgdmass_syst, _ntoys, _randomSeed, new baseToyMaker(_randomSeed));
275  conf().EnableEventWeight(SystId::kFgdMass,fgdmass_syst);
276  }
277  if (ND::params().GetParameterI("baseTrackerAnalysis.Weights.EnableMichelEleEff")){
278  AddConfiguration(conf(), michel_syst, _ntoys, _randomSeed, new baseToyMaker(_randomSeed));
279  conf().EnableEventWeight(SystId::kMichelEleEff,michel_syst);
280  }
281  if (ND::params().GetParameterI("baseTrackerAnalysis.Weights.EnableSandMu")){
282  AddConfiguration(conf(), sandmu_syst, _ntoys, _randomSeed, new baseToyMaker(_randomSeed));
283  conf().EnableEventWeight(SystId::kSandMu,sandmu_syst);
284  }
285  if (ND::params().GetParameterI("baseTrackerAnalysis.Weights.EnableTPCClusterEff")){
286  AddConfiguration(conf(), tpcclustereff_syst, _ntoys, _randomSeed, new baseToyMaker(_randomSeed));
287  conf().EnableEventWeight(SystId::kTpcClusterEff,tpcclustereff_syst);
288  }
289  if (ND::params().GetParameterI("baseTrackerAnalysis.Weights.EnableTPCECalMatchEff")){
290  AddConfiguration(conf(), tpc_ecal_matcheff_syst, _ntoys, _randomSeed, new baseToyMaker(_randomSeed));
291  conf().EnableEventWeight(SystId::kTpcECalMatchEff, tpc_ecal_matcheff_syst);
292  }
293  if (ND::params().GetParameterI("baseTrackerAnalysis.Weights.EnableTPCP0DMatchEff")){
294  AddConfiguration(conf(), tpc_p0d_matcheff_syst, _ntoys, _randomSeed, new baseToyMaker(_randomSeed));
295  conf().EnableEventWeight(SystId::kTpcP0dMatchEff, tpc_p0d_matcheff_syst);
296  }
297  if (ND::params().GetParameterI("baseTrackerAnalysis.Weights.EnableFGDECalMatchEff")){
298  AddConfiguration(conf(), fgd_ecal_matcheff_syst, _ntoys, _randomSeed, new baseToyMaker(_randomSeed));
299  conf().EnableEventWeight(SystId::kFgdECalMatchEff, fgd_ecal_matcheff_syst);
300  }
301  if (ND::params().GetParameterI("baseTrackerAnalysis.Weights.EnableFGDECalSMRDMatchEff")){
302  AddConfiguration(conf(), fgd_ecal_smrd_matcheff_syst, _ntoys, _randomSeed, new baseToyMaker(_randomSeed));
303  conf().EnableEventWeight(SystId::kFgdECalSmrdMatchEff, fgd_ecal_smrd_matcheff_syst);
304  }
305  if (ND::params().GetParameterI("baseTrackerAnalysis.Weights.EnableECalTrackEff")){
306  AddConfiguration(conf(), ecal_trackeff_syst, _ntoys, _randomSeed, new baseToyMaker(_randomSeed));
307  conf().EnableEventWeight(SystId::kECalTrackEff, ecal_trackeff_syst);
308  }
309  if (ND::params().GetParameterI("baseTrackerAnalysis.Weights.EnableECalPID")){
310  AddConfiguration(conf(), ecal_pid_syst, _ntoys, _randomSeed, new baseToyMaker(_randomSeed));
311  conf().EnableEventWeight(SystId::kECalPID, ecal_pid_syst);
312  }
313  if (ND::params().GetParameterI("baseTrackerAnalysis.Weights.EnableECalEmHipPID")){
314  AddConfiguration(conf(), ecal_emhippid_syst, _ntoys, _randomSeed, new baseToyMaker(_randomSeed));
315  conf().EnableEventWeight(SystId::kECalEmHipPID, ecal_emhippid_syst);
316  }
317  if (ND::params().GetParameterI("baseTrackerAnalysis.Weights.EnableFGD2Shower")){
318  AddConfiguration(conf(), fgd2shower_syst, _ntoys, _randomSeed, new baseToyMaker(_randomSeed));
319  conf().EnableEventWeight(SystId::kFGD2Shower, fgd2shower_syst);
320  }
321  if (ND::params().GetParameterI("baseTrackerAnalysis.Weights.EnableNuETPCPileUp")){
322  AddConfiguration(conf(), nuetpcpileup_syst, _ntoys, _randomSeed, new baseToyMaker(_randomSeed));
323  conf().EnableEventWeight(SystId::kNuETPCPileUp, nuetpcpileup_syst);
324  }
325  if (ND::params().GetParameterI("baseTrackerAnalysis.Weights.EnableNuEP0DPileUp")){
326  AddConfiguration(conf(), nuep0dpileup_syst, _ntoys, _randomSeed, new baseToyMaker(_randomSeed));
327  conf().EnableEventWeight(SystId::kNuEP0DPileUp, nuep0dpileup_syst);
328  }
329  if (ND::params().GetParameterI("baseTrackerAnalysis.Weights.EnableNuEECalPileUp")){
330  AddConfiguration(conf(), nueecalpileup_syst, _ntoys, _randomSeed, new baseToyMaker(_randomSeed));
331  conf().EnableEventWeight(SystId::kNuEECalPileUp, nueecalpileup_syst);
332  }
333  if (ND::params().GetParameterI("baseTrackerAnalysis.Weights.EnableNuEOOFV")){
334  AddConfiguration(conf(), nueoofv_syst, _ntoys, _randomSeed, new baseToyMaker(_randomSeed));
335  conf().EnableEventWeight(SystId::kNuEOOFV,nueoofv_syst);
336  }
337  if (ND::params().GetParameterI("baseTrackerAnalysis.Weights.EnableP0DVeto")){
338  AddConfiguration(conf(), p0d_veto_syst, _ntoys, _randomSeed, new baseToyMaker(_randomSeed));
339  conf().EnableEventWeight(SystId::kP0DVeto,nueoofv_syst);
340  }
341  }
342 
343  //! [baseTrackerAnalysis_all_syst]
344  // Enable all variation systematics in the all_syst configuration (created in baseAnalysis)
345  if ( _enableAllSystConfig){
346  if (ND::params().GetParameterI("baseTrackerAnalysis.Variations.EnableBFieldDist")) conf().EnableEventVariation(SystId::kBFieldDist , all_syst);
347  if (ND::params().GetParameterI("baseTrackerAnalysis.Variations.EnableMomRes")) conf().EnableEventVariation(SystId::kMomResol , all_syst);
348  if (ND::params().GetParameterI("baseTrackerAnalysis.Variations.EnableMomRangeRes")) conf().EnableEventVariation(SystId::kMomRangeResol , all_syst);
349  if (ND::params().GetParameterI("baseTrackerAnalysis.Variations.EnableMomScale")) conf().EnableEventVariation(SystId::kMomScale , all_syst);
350  if (ND::params().GetParameterI("baseTrackerAnalysis.Variations.EnableTPCPID")) conf().EnableEventVariation(SystId::kTpcPid , all_syst);
351  if (ND::params().GetParameterI("baseTrackerAnalysis.Variations.EnableFGDPID")) conf().EnableEventVariation(SystId::kFgdPid , all_syst);
352  if (ND::params().GetParameterI("baseTrackerAnalysis.Variations.EnableECalEMResol")) conf().EnableEventVariation(SystId::kECalEMResol , all_syst);
353  if (ND::params().GetParameterI("baseTrackerAnalysis.Variations.EnableECalEMScale")) conf().EnableEventVariation(SystId::kECalEMScale , all_syst);
354  if (ND::params().GetParameterI("baseTrackerAnalysis.Variations.EnableToFResol")) conf().EnableEventVariation(SystId::kToFResol , all_syst);
355  if (ND::params().GetParameterI("baseTrackerAnalysis.Variations.EnableP0DELossScale")) conf().EnableEventVariation(SystId::kP0DELossScale , all_syst);
356  if (ND::params().GetParameterI("baseTrackerAnalysis.Variations.EnableP0DELossResol")) conf().EnableEventVariation(SystId::kP0DELossResol , all_syst);
357  }
358 
359  // Enable all Event Weights in the default and all_syst configurations
360  for (std::vector<ConfigurationBase* >::iterator it= conf().GetConfigurations().begin();it!=conf().GetConfigurations().end();it++){
361  Int_t index = (*it)->GetIndex();
362  if (index != ConfigurationManager::default_conf && (index != all_syst || !_enableAllSystConfig)) continue;
363 
364  if (ND::params().GetParameterI("baseTrackerAnalysis.Weights.EnableChargeConf")) conf().EnableEventWeight(SystId::kChargeIDEff , index);
365  if (ND::params().GetParameterI("baseTrackerAnalysis.Weights.EnablePileUp")) conf().EnableEventWeight(SystId::kPileUp , index);
366  if (ND::params().GetParameterI("baseTrackerAnalysis.Weights.EnableMichelEleEff")) conf().EnableEventWeight(SystId::kMichelEleEff , index);
367  if (ND::params().GetParameterI("baseTrackerAnalysis.Weights.EnableTPCTrackEff")) conf().EnableEventWeight(SystId::kTpcTrackEff , index);
368  if (ND::params().GetParameterI("baseTrackerAnalysis.Weights.EnableFGDTrackEff")) conf().EnableEventWeight(SystId::kFgdTrackEff , index);
369  if (ND::params().GetParameterI("baseTrackerAnalysis.Weights.EnableFGDHybridTrackEff")) conf().EnableEventWeight(SystId::kFgdHybridTrackEff , index);
370  if (ND::params().GetParameterI("baseTrackerAnalysis.Weights.EnableTPCFGDMatchEff")) conf().EnableEventWeight(SystId::kTpcFgdMatchEff , index);
371  if (ND::params().GetParameterI("baseTrackerAnalysis.Weights.EnableOOFV")) conf().EnableEventWeight(SystId::kOOFV , index);
372  if (ND::params().GetParameterI("baseTrackerAnalysis.Weights.EnableTPCClusterEff")) conf().EnableEventWeight(SystId::kTpcClusterEff , index);
373  if (ND::params().GetParameterI("baseTrackerAnalysis.Weights.EnableFGDMass")) conf().EnableEventWeight(SystId::kFgdMass , index);
374  if (ND::params().GetParameterI("baseTrackerAnalysis.Weights.EnableSandMu")) conf().EnableEventWeight(SystId::kSandMu , index);
375  if (ND::params().GetParameterI("baseTrackerAnalysis.Weights.EnableTPCECalMatchEff")) conf().EnableEventWeight(SystId::kTpcECalMatchEff , index);
376  if (ND::params().GetParameterI("baseTrackerAnalysis.Weights.EnableTPCP0DMatchEff")) conf().EnableEventWeight(SystId::kTpcP0dMatchEff , index);
377  if (ND::params().GetParameterI("baseTrackerAnalysis.Weights.EnableFGDECalMatchEff")) conf().EnableEventWeight(SystId::kFgdECalMatchEff , index);
378  if (ND::params().GetParameterI("baseTrackerAnalysis.Weights.EnableFGDECalSMRDMatchEff")) conf().EnableEventWeight(SystId::kFgdECalSmrdMatchEff , index);
379  if (ND::params().GetParameterI("baseTrackerAnalysis.Weights.EnableECalTrackEff")) conf().EnableEventWeight(SystId::kECalTrackEff , index);
380  if (ND::params().GetParameterI("baseTrackerAnalysis.Weights.EnableECalPID")) conf().EnableEventWeight(SystId::kECalPID , index);
381  if (ND::params().GetParameterI("baseTrackerAnalysis.Weights.EnableECalEmHipPID")) conf().EnableEventWeight(SystId::kECalEmHipPID , index);
382  if (ND::params().GetParameterI("baseTrackerAnalysis.Weights.EnableFGD2Shower")) conf().EnableEventWeight(SystId::kFGD2Shower , index);
383  if (ND::params().GetParameterI("baseTrackerAnalysis.Weights.EnableNuETPCPileUp")) conf().EnableEventWeight(SystId::kNuETPCPileUp , index);
384  if (ND::params().GetParameterI("baseTrackerAnalysis.Weights.EnableNuEP0DPileUp")) conf().EnableEventWeight(SystId::kNuEP0DPileUp , index);
385  if (ND::params().GetParameterI("baseTrackerAnalysis.Weights.EnableNuEECalPileUp")) conf().EnableEventWeight(SystId::kNuEECalPileUp , index);
386  if (ND::params().GetParameterI("baseTrackerAnalysis.Weights.EnableNuEOOFV")) conf().EnableEventWeight(SystId::kNuEOOFV , index);
387  if (ND::params().GetParameterI("baseTrackerAnalysis.Weights.EnableP0DVeto")) conf().EnableEventWeight(SystId::kP0DVeto , index);
388  }
389  //! [baseTrackerAnalysis_all_syst]
390 
391  // A configuration with all syst but zero variation applied
393  AddZeroVarConfiguration();
394 
395 }
396 
397 //********************************************************************
398 void baseTrackerAnalysis::DefineMicroTrees(bool addBase){
399 //********************************************************************
400 
401  if (addBase) baseAnalysis::DefineMicroTrees(addBase);
402 
403  // -------- Add variables to the analysis tree ----------------------
404 
405  AddVarI(output(), ntpctracks, "number of tracks containing TPC");
406  AddVarI(output(), ntpcposQualityFV,"number of positive tracks containing TPC, with good quality and in FV");
407  AddVarI(output(), ntpcnegQualityFV,"number of negative tracks containing TPC, with good quality and in FV");
408  AddVarI(output(), nfgdtracks, "number of tracks contining FGD and no TPC");
409  AddVarI(output(), nfgdonlytracks, "number of tracks in FGD only");
410 
411  //--- add nb of efficiant/inefficiant tracks that pass systematics cut for each event
412  if (_computeEfficiency){
413  AddVarFixVI(output(), chargeid_nwrong, "number of tracks with wrong charge for each systematic bin", NMAXSYSTSOURCEBINS);
414  AddVarFixVI(output(), chargeid_ncorrect, "number of tracks with correct charge for each systematic bin", NMAXSYSTSOURCEBINS);
415  AddVarFixVI(output(), tpcfgdmatch_nwrong, "number of tracks with wrong tpcfgd match for each systematic bin", NMAXSYSTSOURCEBINS);
416  AddVarFixVI(output(), tpcfgdmatch_ncorrect, "number of tracks with correct tpcfgd match for each systematic bin", NMAXSYSTSOURCEBINS);
417  AddVarFixVI(output(), tpctr_nwrong, "number of tracks with wrong tpc tracking for each systematic bin", NMAXSYSTSOURCEBINS);
418  AddVarFixVI(output(), tpctr_ncorrect, "number of tracks with correct tpc tracking for each systematic bin", NMAXSYSTSOURCEBINS);
419  AddVarFixVI(output(), fgdtr_nwrong, "number of tracks with wrong fgd tracking for each systematic bin", NMAXSYSTSOURCEBINS);
420  AddVarFixVI(output(), fgdtr_ncorrect, "number of tracks with correct fgd tracking for each systematic bin", NMAXSYSTSOURCEBINS);
421  AddVarFixVI(output(), fgdhybtr_nwrong, "number of tracks with wrong fgdhyb tracking for each systematic bin", NMAXSYSTSOURCEBINS);
422  AddVarFixVI(output(), fgdhybtr_ncorrect, "number of tracks with correct fgdhyb tracking for each systematic bin", NMAXSYSTSOURCEBINS);
423  AddVarFixVI(output(), meeff_nwrong, "number of events with true me but no selected me for each systematic bin", NMAXSYSTSOURCEBINS);
424  AddVarFixVI(output(), meeff_ncorrect, "number of events with true me and selected me for each systematic bin", NMAXSYSTSOURCEBINS);
425  AddVarFixVI(output(), mepur_nwrong, "number of events with me found selected when no true me for each systematic bin", NMAXSYSTSOURCEBINS);
426  AddVarFixVI(output(), mepur_ncorrect, "number of events with me found selected when true me exists for each systematic bin", NMAXSYSTSOURCEBINS);
427 
428  AddVarFixVI(output(), tpc_ecal_match_ncorrect, "number of events with correct tpc-ecal match for each systematic bin", NMAXSYSTSOURCEBINS);
429  AddVarFixVI(output(), tpc_ecal_match_nwrong, "number of events with wrong tpc-ecal match for each systematic bin", NMAXSYSTSOURCEBINS);
430 
431  AddVarFixVI(output(), tpc_p0d_match_ncorrect, "number of events with correct tpc-p0d match for each systematic bin", NMAXSYSTSOURCEBINS);
432  AddVarFixVI(output(), tpc_p0d_match_nwrong, "number of events with wrong tpc-p0d match for each systematic bin", NMAXSYSTSOURCEBINS);
433 
434  AddVarFixVI(output(), fgd_ecal_match_ncorrect, "number of events with correct fgd-ecal match for each systematic bin", NMAXSYSTSOURCEBINS);
435  AddVarFixVI(output(), fgd_ecal_match_nwrong, "number of events with wrong fgd-ecal match for each systematic bin", NMAXSYSTSOURCEBINS);
436 
437  AddVarFixVI(output(), fgd_ecal_smrd_match_ncorrect, "number of events with correct fgd-ecal-smrd match for each systematic bin", NMAXSYSTSOURCEBINS);
438  AddVarFixVI(output(), fgd_ecal_smrd_match_nwrong, "number of events with wrong fgd-ecal-srmd match for each systematic bin", NMAXSYSTSOURCEBINS);
439 
440  AddVarFixVI(output(), ecal_tr_ncorrect, "number of tracks with correct ecal tracking for each systematic bin", NMAXSYSTSOURCEBINS);
441  AddVarFixVI(output(), ecal_tr_nwrong, "number of tracks with wrong ecal tracking for each systematic bin", NMAXSYSTSOURCEBINS);
442 
443  AddVarFixVI(output(), ecal_pid_ncorrect, "number of tracks with correct ecal PID for each systematic bin", NMAXSYSTSOURCEBINS);
444  AddVarFixVI(output(), ecal_pid_nwrong, "number of tracks with wrong ecal PID for each systematic bin", NMAXSYSTSOURCEBINS);
445 
446  AddVarFixVI(output(), ecal_emhippid_ncorrect, "number of tracks with correct ecal EmHip PID for each systematic bin", NMAXSYSTSOURCEBINS);
447  AddVarFixVI(output(), ecal_emhippid_nwrong, "number of tracks with wrong ecal EmHip PID for each systematic bin", NMAXSYSTSOURCEBINS);
448 
449  AddVarFixVI(output(), fgd2shower_ncorrect, "number of FGD1 tracks that do shower in FGD2 for each systematic bin", NMAXSYSTSOURCEBINS);
450  AddVarFixVI(output(), fgd2shower_nwrong, "number of FGD1 tracks that do not shower in FGD2 for each systematic bin", NMAXSYSTSOURCEBINS);
451 
452  }
453 }
454 
455 //********************************************************************
456 void baseTrackerAnalysis::DefineTruthTree(){
457 //********************************************************************
458 
459  baseAnalysis::DefineTruthTree();
460 }
461 
462 //********************************************************************
463 void baseTrackerAnalysis::FillMicroTrees(bool addBase){
464 //********************************************************************
465 
466  if (addBase) baseAnalysis::FillMicroTreesBase(addBase);
467 
468  // Track counters
469  AnaTrackB* dummy[NMAXPARTICLES];
470  int nTPC = anaUtils::GetAllTracksUsingDet(GetBunch(), SubDetId::kTPC, dummy);
472  int nFGDonly = anaUtils::GetAllTracksUsingOnlyDet(GetBunch(), SubDetId::kFGD, dummy);
473 
474  output().FillVar(ntpctracks,nTPC);
475  output().FillVar(nfgdtracks,nFGD); // tracks with no TPC
476  output().FillVar(nfgdonlytracks,nFGDonly); // tracks with only FGD
477  output().FillVar(ntpcnegQualityFV,(Int_t)box().nNegativeTPCtracks); // Tracks containing TPC, with good quality and in FV
478  output().FillVar(ntpcposQualityFV,(Int_t)box().nPositiveTPCtracks); // Tracks containing TPC, with good quality and in FV
479 
480  // Counters needed to compute efficiencies elated with systematics
481  if (_computeEfficiency){
482  for (UInt_t i=0;i<NMAXSYSTSOURCEBINS;i++){
483  output().FillVectorVar(chargeid_ncorrect, _chargeid->_globalCharge->GetNCorrectAssoc(i), i);
484  output().FillVectorVar(chargeid_nwrong, _chargeid->_globalCharge->GetNWrongAssoc(i), i);
485  output().FillVectorVar(tpcfgdmatch_ncorrect, _tpcfgdmatch->GetNCorrectAssoc(i), i);
486  output().FillVectorVar(tpcfgdmatch_nwrong, _tpcfgdmatch->GetNWrongAssoc(i), i);
487  output().FillVectorVar(tpctr_ncorrect, _tpctr->GetNCorrectAssoc(i), i);
488  output().FillVectorVar(tpctr_nwrong, _tpctr->GetNWrongAssoc(i), i);
489  output().FillVectorVar(fgdtr_ncorrect, _fgdtr->_fgd1->GetNCorrectAssoc(i), i);
490  output().FillVectorVar(fgdtr_nwrong, _fgdtr->_fgd1->GetNWrongAssoc(i), i);
491  output().FillVectorVar(fgdhybtr_ncorrect, _fgdhybtr->_fgd1->GetNCorrectAssoc(i), i);
492  output().FillVectorVar(fgdhybtr_nwrong, _fgdhybtr->_fgd1->GetNWrongAssoc(i), i);
493  output().FillVectorVar(meeff_ncorrect, _me->_fgd1eff->GetNCorrectAssoc(i), i);
494  output().FillVectorVar(meeff_nwrong, _me->_fgd1eff->GetNWrongAssoc(i), i);
495  output().FillVectorVar(mepur_ncorrect, _me->_fgd1pur->GetNCorrectAssoc(i), i);
496  output().FillVectorVar(mepur_nwrong, _me->_fgd1pur->GetNWrongAssoc(i), i);
497 
498  output().FillVectorVar(tpc_ecal_match_ncorrect, _tpc_ecal_matcheff->GetNCorrectAssoc(i), i);
499  output().FillVectorVar(tpc_ecal_match_nwrong, _tpc_ecal_matcheff->GetNWrongAssoc(i), i);
500 
501  output().FillVectorVar(tpc_p0d_match_ncorrect, _tpc_p0d_matcheff->GetNCorrectAssoc(i), i);
502  output().FillVectorVar(tpc_p0d_match_nwrong, _tpc_p0d_matcheff->GetNWrongAssoc(i), i);
503 
504  output().FillVectorVar(fgd_ecal_match_ncorrect, _fgd_ecal_matcheff->GetNCorrectAssoc(i), i);
505  output().FillVectorVar(fgd_ecal_match_nwrong, _fgd_ecal_matcheff->GetNWrongAssoc(i), i);
506 
507  output().FillVectorVar(fgd_ecal_smrd_match_ncorrect, _fgd_ecal_smrd_matcheff->GetNCorrectAssoc(i), i);
508  output().FillVectorVar(fgd_ecal_smrd_match_nwrong, _fgd_ecal_smrd_matcheff->GetNWrongAssoc(i), i);
509 
510  output().FillVectorVar(ecal_tr_ncorrect, _ecal_trackeff->GetNCorrectAssoc(i), i);
511  output().FillVectorVar(ecal_tr_nwrong, _ecal_trackeff->GetNWrongAssoc(i), i);
512 
513  output().FillVectorVar(ecal_pid_ncorrect, _ecal_pid->GetNCorrectAssoc(i), i);
514  output().FillVectorVar(ecal_pid_nwrong, _ecal_pid->GetNWrongAssoc(i), i);
515 
516  output().FillVectorVar(ecal_emhippid_ncorrect, _ecal_emhippid->GetNCorrectAssoc(i), i);
517  output().FillVectorVar(ecal_emhippid_nwrong, _ecal_emhippid->GetNWrongAssoc(i), i);
518 
519  output().FillVectorVar(fgd2shower_ncorrect, _fgd2shower->GetNCorrectAssoc(i), i);
520  output().FillVectorVar(fgd2shower_nwrong, _fgd2shower->GetNWrongAssoc(i), i);
521 
522  }
523  }
524 
525 }
526 
527 //********************************************************************
528 void baseTrackerAnalysis::FillToyVarsInMicroTrees(bool addBase){
529 //********************************************************************
530 
531  if (addBase) baseAnalysis::FillToyVarsInMicroTreesBase(addBase);
532 }
533 
534 //********************************************************************
535 void baseTrackerAnalysis::FillTruthTreeBase(const AnaTrueVertex& vtx, const SubDetId::SubDetEnum det, bool IsAntinu){
536 //********************************************************************
537 
538  // Fill the common variables
539  baseAnalysis::FillTruthTreeBase(vtx, det, IsAntinu);
540 }
void DisableAllCorrections()
Disable all corrections in a given configuration (if conf=="" for all confs)
int GetAllTracksUsingOnlyDet(const AnaBunchB &bunch, SubDetId::SubDetEnum det, AnaTrackB *selTracks[])
int GetParameterI(std::string)
Get parameter. Value is returned as integer.
Definition: Parameters.cxx:217
TN-152 for a longer explanaition.
void AddCorrection(Int_t index, const std::string &name, CorrectionBase *corr)
void AddPackage(const std::string &name, const std::string &version)
Add a package.
void FillVectorVar(Int_t index, Float_t var, Int_t indx=-1)
Fill a vector variable.
bool _enableZeroVarConfig
bool _computeEfficiency
Compute analysis sample efficiency.
AnaBunch & GetBunch()
Get a casted AnaBunchBB to AnaBunch from the InputManager (TODO the protection)
virtual void DefineSystematics()
std::string GetSoftwareVersionFromPath(const std::string &path)
Get The software version from the path of the package.
Representation of a true Monte Carlo vertex.
Definition: DataClasses.hxx:50
virtual const ToyBoxTracker & box(Int_t isel=-1) const
Returns the ToyBoxTracker.
This class defines a correction that affects the reconstructed TPC Momentum of an.
SubDetEnum
Enumeration of all detector systems and subdetectors.
Definition: SubDetId.hxx:25
int GetAllTracksUsingFGDAndNoTPC(const AnaBunchB &bunch, AnaTrackB *selTracks[])
This is a normalization systematic. It takes into account the uncertainty on the FGD mass introduced ...
Representation of a global track.
This systematic evaluates the oofv systematic for nue analysis. At the moment a 30% rate unceratinty ...
void AddEventVariation(Int_t index, EventVariationBase *sys)
Add a new Event Variation provided its index in the manager and a pointer to it.
std::vector< ConfigurationBase * > & GetConfigurations()
return the vector of configurations
Creates ToyExperiments.
void AddEventWeight(Int_t index, EventWeightBase *sys)
Add a new Event Weight provided its index in the manager and a pointer to it.
void EnableEventWeight(Int_t syst, Int_t conf=-1)
Enable the systematic registered with the given index.
baseTrackerAnalysis(AnalysisAlgorithm *ana=NULL)
void EnableEventVariation(Int_t syst, Int_t conf=-1)
Enable the systematic registered with the given index.
void FillVar(Int_t index, Float_t var)
Fill a single variable.
TN-152 for a longer explanaition.
Charge confusion systematic. This is treated as an efficiency systematic, applying a weight to the ev...
This systematic smears the pull of each FGD track segment.
int GetAllTracksUsingDet(const AnaBunchB &bunch, SubDetId::SubDetEnum det, AnaTrackB *selTracks[])
This systematic smears the CT of each TPC track segment.
Michel electron effciency systematic.
virtual void DefineConfigurations()