ATLAS Offline Software
Loading...
Searching...
No Matches
ZDCTreeAnalysis.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
6// This class has been automatically generated on
7// Wed Dec 16 10:23:25 2015 by ROOT version 6.04/12
8// from TTree zdcTree/ZDC Tree
9// found on file: data15_hi.00287259.calibration_zdcCalib.recon.AOD.c931.root
11
12#ifndef ZDCTreeAnalysis_h
13#define ZDCTreeAnalysis_h
14
15#include <TROOT.h>
16#include <TChain.h>
17#include <TFile.h>
18#include <TH1.h>
19#include <TF1.h>
20#include <TSpline.h>
21
22// Header file for the classes stored in the TTree if any.
23#include <vector>
24#include <iostream>
25#include <sstream>
26
27#include "ZDCDataAnalyzer.h"
28
30public :
31 TTree *fChain;
32 Int_t fCurrent;
33
34 TFile* _outTFile;
35 TTree* _outTree;
37
38// Fixed size dimensions of array or collections stored in the TTree if any.
39
40 // Declaration of leaf types
41 UInt_t runNumber;
43 UInt_t lumiBlock;
44 UInt_t bcid;
45 ULong64_t trigger;
47 UInt_t tbp[16];
48 UInt_t tav[16];
49
50 UInt_t passBits;
51 UShort_t zdc_raw[2][4][2][2][7];
52
53 Float_t fcalEt;
54 Int_t ntrk;
55 Int_t nvx;
56 Float_t vx[3];
57 Int_t vxntrk;
58 Float_t vxcov[6];
59 UShort_t mbts_countA;
60 UShort_t mbts_countC;
61 Float_t mbts_timeA;
62 Float_t mbts_timeC;
64
65 Bool_t L1_ZDC_A;
66 Float_t ps_L1_ZDC_A;
67 Bool_t L1_ZDC_C;
68 Float_t ps_L1_ZDC_C;
69 Bool_t L1_ZDC_AND;
71 Bool_t L1_ZDC_A_C;
73
74 // Data for branches that are to be added to the tree
75 //
78
79 // Data obtained from the analysis
80 //
81 // Summary data
82 //
84 float zdc_SumAmp[2];
86 float zdc_AvgTime[2];
88
89 // Per-module data
90 //
91 std::vector<float>* zdc_samplesSub;
92 std::vector<float>* zdc_samplesDeriv;
93 std::vector<float>* zdc_samplesDeriv2nd;
94
95 float zdc_Presample[2][4];
96
97 float zdc_MaxADC[2][4];
99
100 float zdc_MinADC[2][4];
102
103 float zdc_Min2ndDeriv[2][4];
105
106 int zdc_Status[2][4];
107 float zdc_Amp[2][4];
108 float zdc_FitT0[2][4];
109 float zdc_FitChisq[2][4];
110 float zdc_T0Corr[2][4];
111
112 float zdc_CalibAmp[2][4];
113 float zdc_CalibTime[2][4];
114
115 // The object responsible for the actual analysis
116 //
118
119private:
120 // Critical construction parameters
121 //
125 std::string _fitFunction;
126
129
130 // Cut quantities
131 //
132 float _HGOverFlowADC[2][4];
133 float _HGUnderFlowADC[2][4];
134 float _DeltaT0CutLow[2][4];
135 float _DeltaT0CutHigh[2][4];
136 float _chisqDivAmpCutHG[2][4];
137 float _chisqDivAmpCutLG[2][4];
138
139 // Per-module calibration factors
140 //
141 // Time-dependent
142 //
143 bool _haveLBDepT0[2][4];
144 TSpline* _moduleT0HGLB[2][4];
145 TSpline* _moduleT0LGLB[2][4];
146
148 float _modECalib[2][4];
149
151 TSpline* _modECalibLB[2][4];
152
153 // Allow per-module Tau1, tau2 settings
154 //
156 bool _fixTau1[2][4];
157 bool _fixTau2[2][4];
158 float _moduleTau1[2][4];
159 float _moduleTau2[2][4];
160 float _moduleT0LG[2][4];
161 float _moduleT0HG[2][4];
162
163 std::array<std::array<float, 4>, 2> _moduleHGGains;
164
165 // Time slewing corrections
166 //
167 float _T0SlewCoeffHG[2][4][3];
168 float _T0SlewCoeffLG[2][4][3];
169
170 // Bunch information
171 //
172 std::vector<std::set<int> > _trains;
173 std::vector<int> _BCIDGap;
174 std::vector<int> _BCIDPosInTrain;
175
176 // Which entry we're reading
177 //
180 unsigned int _runNumber;
181
182private:
183 // List of branches
184 TBranch *b_runNumber;
185 TBranch *b_eventNumber;
186 TBranch *b_lumiBlock;
187 TBranch *b_bcid;
188 TBranch *b_trigger;
189 TBranch *b_trigger_TBP;
190 TBranch *b_tbp;
191 TBranch *b_tav;
192 TBranch *b_decisions;
193 TBranch *b_prescales;
194 TBranch *b_passBits;
195
196 TBranch *b_zdc_raw;
197 // TBranch *b_fcalEt; //!
198 // TBranch *b_ntrk; //!
199 // TBranch *b_nvx; //!
200 // TBranch *b_vx; //!
201 // TBranch *b_vxntrk; //!
202 // TBranch *b_vxcov; //!
203 // TBranch *b_mbts_countA; //!
204 // TBranch *b_mbts_countC; //!
205 // TBranch *b_mbts_timeA; //!
206 // TBranch *b_mbts_timeC; //!
207 // TBranch *b_mbts_timeDiff; //!
208
209 TBranch *b_L1_ZDC_A;
210 TBranch *b_ps_L1_ZDC_A;
211 TBranch *b_L1_ZDC_C;
212 TBranch *b_ps_L1_ZDC_C;
213 TBranch *b_L1_ZDC_AND;
215 TBranch *b_L1_ZDC_A_C;
217
220
221public:
222
223 ZDCTreeAnalysis(std::string filename, int nSample = 7, double deltaT = 12.5, int preSamplIdx = 1, std::string fitFunction = "FermiExp");
224
226 const ZDCDataAnalyzer::ZDCModuleFloatArray& HGUnderFlowADC,
227 const ZDCDataAnalyzer::ZDCModuleFloatArray& LGOverFlowADC)
228 {
229 _dataAnalyzer_p->SetADCOverUnderflowValues(HGOverFlowADC, HGUnderFlowADC, LGOverFlowADC);
230 }
231
233 const ZDCDataAnalyzer::ZDCModuleFloatArray& chisqDivAmpCutLG,
234 const ZDCDataAnalyzer::ZDCModuleFloatArray& DeltaT0CutLowHG,
235 const ZDCDataAnalyzer::ZDCModuleFloatArray& DeltaT0CutHighHG,
236 const ZDCDataAnalyzer::ZDCModuleFloatArray& DeltaT0CutLowLG,
237 const ZDCDataAnalyzer::ZDCModuleFloatArray& DeltaT0CutHighLG)
238
239 {
240 _dataAnalyzer_p->SetCutValues(chisqDivAmpCutHG, chisqDivAmpCutLG,
241 DeltaT0CutLowHG, DeltaT0CutHighHG,
242 DeltaT0CutLowLG, DeltaT0CutHighLG);
243 }
244
251 {
252 _dataAnalyzer_p->SetTauT0Values(fixTau1, fixTau2, tau1, tau2, t0HG, t0LG);
253 }
254
255
256 void SetDebugLevel(int debugLevel = 0)
257 {
258 _dataAnalyzer_p->SetDebugLevel(debugLevel);
259 }
260
261 void LoadEnergyCalibrations(std::array<std::array<TSpline*, 4>, 2>&& calibSplines)
262 {
263 _dataAnalyzer_p->LoadEnergyCalibrations(std::move(calibSplines));
264 }
265
266 void LoadT0Calibrations(std::array<std::array<TSpline*, 4>, 2>&& calibSplinesHG,
267 std::array<std::array<TSpline*, 4>, 2>&& calibSplinesLG)
268 {
269 _dataAnalyzer_p->LoadtT0Calibrations(std::move(calibSplinesHG), std::move(calibSplinesLG));
270 }
271
272 void SetLBDepT0(int iside, int imod, TSpline* t0SplineLG, TSpline* t0SplineHG);
273
274 void SetSlewingCoeff(const std::array<std::array<std::vector<float>, 4>, 2>& HGParamArr,
275 const std::array<std::array<std::vector<float>, 4>, 2>& LGParamArr)
276 {
277 _dataAnalyzer_p->SetTimingCorrParams(HGParamArr, LGParamArr);
278 }
279
280 void OpenOutputTree(const std::string & file);
282
283 void PlotFits(const std::string & canvasSavePath = "");
284
286 virtual Int_t Cut(Long64_t entry);
287 virtual Int_t GetEntry(Long64_t entry);
288 virtual Long64_t LoadTree(Long64_t entry);
289 virtual void Init(TTree *tree);
290 virtual void Loop(int numEntries = -1, int startEntry = 0);
291 virtual Bool_t Notify();
292 virtual void Show(Long64_t entry = -1);
293
294 void LoadEntry(int entry)
295 {
296 GetEntry(entry);
297 DoAnalysis();
298 }
299
301 {
303 DoAnalysis();
304 }
305
306 unsigned int GetRunNumber() const {return _runNumber;}
307
309};
310
311
312#endif
313
314#ifdef ZDCTreeAnalysis_cxx
315
316ZDCTreeAnalysis::ZDCTreeAnalysis(const std::string & filename, int nSample, double deltaT, int preSamplIdx, const std::string & fitFunction) :
317 fChain(0), _outTFile(0), _outTree(0),
318 _nSample(nSample), _deltaTSample(deltaT), _preSampleIdx(preSamplIdx),
319 _doOutput(false), _currentEntry(-1), _inLoop(false),
320 _haveCalibrations(false)
321{
322
323 // Open the fiel, extract and initialize the tree
324 //
325 TTree* tree;
326 TFile* f = new TFile(filename.c_str());
327 f->GetObject("zdcTree",tree);
328 Init(tree);
329
330 // Capture the run number
331 //
332 GetEntry(1);
334
335 InitInternal();
336
337 // Figure out the bunch spacing
338 //
340
341 // Set the HV gains
342 //
343 _moduleHGGains = {9.51122, 9.51980, 9.51122, 9.51122,
344 9.51415, 9.5049, 9.51659, 9.51415};
345
346 _peak2ndDerivMinSamples = {3, 3, 3, 2,
347 2, 2, 2, 2};
348
349 _peak2ndDerivMinThresholds = {-7, -7, -7, -7,
350 -7, -7, -7, -7};
351
352 _dataAnalyzer_p = new ZDCDataAnalyzer(_nSample, _deltaTSample, _preSampleIdx, fitFunction,
354
355/* 81Undelayed */
356/* 81H1: 9.5049 */
357/* 81H2: 9.51659 */
358/* 81H3: 9.50119 */
359/* 81EM: 9.51415 */
360/* 81Delayed */
361/* 81H1: 9.52632 */
362/* 81H2: 9.49662 */
363/* 81H3: 9.50853 */
364/* 81EM: 9.50842 */
365/* 12Undelayed */
366/* 12H1: 9.5198 */
367/* 12H2: 9.51122 */
368/* 12H3: 9.51122 */
369/* 12EM: 9.51122 */
370/* 12Delayed */
371/* 12H1: 9.51237 */
372/* 12H2: 9.50178 */
373/* 12H3: 9.50178 */
374/* 12EM: 9.50178 */
375}
376
378{
379 if (!fChain) return;
380 delete fChain->GetCurrentFile();
381}
382
383Int_t ZDCTreeAnalysis::GetEntry(Long64_t entry)
384{
385// Read contents of entry.
386 if (!fChain) return 0;
387 int result = fChain->GetEntry(entry);
388 if (result > 0) _currentEntry = entry;
389 return result;
390}
391Long64_t ZDCTreeAnalysis::LoadTree(Long64_t entry)
392{
393// Set the environment to read one entry
394 if (!fChain) return -5;
395 Long64_t centry = fChain->LoadTree(entry);
396 if (centry < 0) return centry;
397 if (fChain->GetTreeNumber() != fCurrent) {
398 fCurrent = fChain->GetTreeNumber();
399 Notify();
400 }
401 return centry;
402}
403
404void ZDCTreeAnalysis::Init(TTree *tree)
405{
406 // The Init() function is called when the selector needs to initialize
407 // a new tree or chain. Typically here the branch addresses and branch
408 // pointers of the tree will be set.
409 // It is normally not necessary to make changes to the generated
410 // code, but the routine can be extended by the user if needed.
411 // Init() will be called many times when running on PROOF
412 // (once per file to be processed).
413
414 // Set object pointer
415 // decisions = 0;
416 // prescales = 0;
417 // Set branch addresses and branch pointers
418 if (!tree) return;
419 fChain = tree;
420 fCurrent = -1;
421 // fChain->SetMakeClass(1);
422
423 fChain->SetBranchAddress("runNumber", &runNumber, &b_runNumber);
424 fChain->SetBranchAddress("eventNumber", &eventNumber, &b_eventNumber);
425 fChain->SetBranchAddress("lumiBlock", &lumiBlock, &b_lumiBlock);
426 fChain->SetBranchAddress("bcid", &bcid, &b_bcid);
427 // fChain->SetBranchAddress("trigger", &trigger, &b_trigger);
428 // fChain->SetBranchAddress("trigger_TBP", &trigger_TBP, &b_trigger_TBP);
429 fChain->SetBranchAddress("tbp", tbp, &b_tbp);
430
431 // fChain->SetBranchAddress("tav", tav, &b_tav);
432 // // fChain->SetBranchAddress("decisions", &decisions, &b_decisions);
433 // // fChain->SetBranchAddress("prescales", &prescales, &b_prescales);
434 fChain->SetBranchAddress("passBits", &passBits, &b_passBits);
435
436 // fChain->SetBranchAddress("zdc_amp", zdc_amp, &b_zdc_amp);
437 // fChain->SetBranchAddress("zdc_amp_rp", zdc_amp_rp, &b_zdc_amp_rp);
438 // fChain->SetBranchAddress("zdc_time", zdc_time, &b_zdc_time);
439 fChain->SetBranchAddress("zdc_raw", zdc_raw, &b_zdc_raw);
440 // fChain->SetBranchAddress("zdc_ampHG", zdc_ampHG, &b_zdc_ampHG);
441 // fChain->SetBranchAddress("zdc_ampLG", zdc_ampLG, &b_zdc_ampLG);
442 // fChain->SetBranchAddress("zdc_sumHG", zdc_sumHG, &b_zdc_sumHG);
443 // fChain->SetBranchAddress("zdc_sumLG", zdc_sumLG, &b_zdc_sumLG);
444 // fChain->SetBranchAddress("zdc_ampHG_rp", zdc_ampHG_rp, &b_zdc_ampHG_rp);
445 // fChain->SetBranchAddress("zdc_ampLG_rp", zdc_ampLG_rp, &b_zdc_ampLG_rp);
446 // fChain->SetBranchAddress("zdc_sumHG_rp", zdc_sumHG_rp, &b_zdc_sumHG_rp);
447 // fChain->SetBranchAddress("zdc_sumLG_rp", zdc_sumLG_rp, &b_zdc_sumLG_rp);
448 // fChain->SetBranchAddress("fcalEt", &fcalEt, &b_fcalEt);
449 // fChain->SetBranchAddress("ntrk", &ntrk, &b_ntrk);
450 // fChain->SetBranchAddress("nvx", &nvx, &b_nvx);
451 // fChain->SetBranchAddress("vx", vx, &b_vx);
452 // fChain->SetBranchAddress("vxntrk", &vxntrk, &b_vxntrk);
453 // fChain->SetBranchAddress("vxcov", vxcov, &b_vxcov);
454 // fChain->SetBranchAddress("mbts_countA", &mbts_countA, &b_mbts_countA);
455 // fChain->SetBranchAddress("mbts_countC", &mbts_countC, &b_mbts_countC);
456 // fChain->SetBranchAddress("mbts_timeA", &mbts_timeA, &b_mbts_timeA);
457 // fChain->SetBranchAddress("mbts_timeC", &mbts_timeC, &b_mbts_timeC);
458 // fChain->SetBranchAddress("mbts_timeDiff", &mbts_timeDiff, &b_mbts_timeDiff);
459
460 fChain->SetBranchAddress("L1_ZDC_A", &L1_ZDC_A, &b_L1_ZDC_A);
461 // fChain->SetBranchAddress("ps_L1_ZDC_A", &ps_L1_ZDC_A, &b_ps_L1_ZDC_A);
462 fChain->SetBranchAddress("L1_ZDC_C", &L1_ZDC_C, &b_L1_ZDC_C);
463 // fChain->SetBranchAddress("ps_L1_ZDC_C", &ps_L1_ZDC_C, &b_ps_L1_ZDC_C);
464 fChain->SetBranchAddress("L1_ZDC_AND", &L1_ZDC_AND, &b_L1_ZDC_AND);
465 // fChain->SetBranchAddress("ps_L1_ZDC_AND", &ps_L1_ZDC_AND, &b_ps_L1_ZDC_AND);
466 fChain->SetBranchAddress("L1_ZDC_A_C", &L1_ZDC_A_C, &b_L1_ZDC_A_C);
467 // fChain->SetBranchAddress("ps_L1_ZDC_A_C", &ps_L1_ZDC_A_C, &b_ps_L1_ZDC_A_C);
468
469 fChain->SetBranchStatus("*", 0);
470 fChain->SetBranchStatus("runNumber", 1);
471 fChain->SetBranchStatus("eventNumber", 1);
472 fChain->SetBranchStatus("lumiBlock", 1);
473 fChain->SetBranchStatus("bcid", 1);
474 fChain->SetBranchStatus("zdc_raw", 1);
475 fChain->SetBranchStatus("tbp", 1);
476
477 fChain->SetBranchStatus("passBits", 1);
478
479 fChain->SetBranchStatus("L1_ZDC_A", 1);
480 fChain->SetBranchStatus("L1_ZDC_C", 1);
481 fChain->SetBranchStatus("L1_ZDC_AND", 1);
482 fChain->SetBranchStatus("L1_ZDC_A_C", 1);
483
484 Notify();
485}
486
488{
489 // The Notify() function is called when a new file is opened. This
490 // can be either for a new TTree in a TChain or when when a new TTree
491 // is started when using PROOF. It is normally not necessary to make changes
492 // to the generated code, but the routine can be extended by the
493 // user if needed. The return value is currently not used.
494
495 return kTRUE;
496}
497
498void ZDCTreeAnalysis::Show(Long64_t entry)
499{
500// Print contents of entry.
501// If entry is not specified, print current entry
502 if (!fChain) return;
503 fChain->Show(entry);
504}
505Int_t ZDCTreeAnalysis::Cut(Long64_t entry)
506{
507// This function may be called from Loop.
508// returns 1 if entry is accepted.
509// returns -1 otherwise.
510 return 1;
511}
512#endif // #ifdef ZDCTreeAnalysis_cxx
std::array< std::array< bool, 4 >, 2 > ZDCModuleBoolArray
std::array< std::array< float, 4 >, 2 > ZDCModuleFloatArray
float zdc_Presample[2][4]
float _modECalib[2][4]
ZDCTreeAnalysis(std::string filename, int nSample=7, double deltaT=12.5, int preSamplIdx=1, std::string fitFunction="FermiExp")
float _DeltaT0CutLow[2][4]
virtual Long64_t LoadTree(Long64_t entry)
void SetTauT0Values(const ZDCDataAnalyzer::ZDCModuleBoolArray &fixTau1, const ZDCDataAnalyzer::ZDCModuleBoolArray &fixTau2, const ZDCDataAnalyzer::ZDCModuleFloatArray &tau1, const ZDCDataAnalyzer::ZDCModuleFloatArray &tau2, const ZDCDataAnalyzer::ZDCModuleFloatArray &t0HG, const ZDCDataAnalyzer::ZDCModuleFloatArray &t0LG)
void SetDebugLevel(int debugLevel=0)
TSpline * _moduleT0LGLB[2][4]
float zdc_FitT0[2][4]
float _moduleT0HG[2][4]
virtual Bool_t Notify()
unsigned int _runNumber
float _HGOverFlowADC[2][4]
TBranch * b_eventNumber
float _DeltaT0CutHigh[2][4]
float _T0SlewCoeffLG[2][4][3]
TBranch * b_ps_L1_ZDC_A
virtual Int_t GetEntry(Long64_t entry)
TSpline * _modECalibLB[2][4]
Int_t fCurrent
pointer to the analyzed TTree or TChain
int zdc_Min2ndDerivSample[2][4]
std::vector< float > * zdc_samplesDeriv2nd
void SetCutValues(const ZDCDataAnalyzer::ZDCModuleFloatArray &chisqDivAmpCutHG, const ZDCDataAnalyzer::ZDCModuleFloatArray &chisqDivAmpCutLG, const ZDCDataAnalyzer::ZDCModuleFloatArray &DeltaT0CutLowHG, const ZDCDataAnalyzer::ZDCModuleFloatArray &DeltaT0CutHighHG, const ZDCDataAnalyzer::ZDCModuleFloatArray &DeltaT0CutLowLG, const ZDCDataAnalyzer::ZDCModuleFloatArray &DeltaT0CutHighLG)
TSpline * _moduleT0HGLB[2][4]
float _chisqDivAmpCutHG[2][4]
void PlotFits(const std::string &canvasSavePath="")
ZDCDataAnalyzer::ZDCModuleFloatArray _peak2ndDerivMinSamples
virtual void Show(Long64_t entry=-1)
TBranch * b_ps_L1_ZDC_C
void SetADCOverUnderflowValues(const ZDCDataAnalyzer::ZDCModuleFloatArray &HGOverFlowADC, const ZDCDataAnalyzer::ZDCModuleFloatArray &HGUnderFlowADC, const ZDCDataAnalyzer::ZDCModuleFloatArray &LGOverFlowADC)
std::string _fitFunction
void SetLBDepT0(int iside, int imod, TSpline *t0SplineLG, TSpline *t0SplineHG)
float _moduleTau2[2][4]
TBranch * b_ps_L1_ZDC_AND
float zdc_Amp[2][4]
void SetupBunchTrains()
std::array< std::array< float, 4 >, 2 > _moduleHGGains
float zdc_MaxADC[2][4]
float _HGUnderFlowADC[2][4]
float _moduleT0LG[2][4]
float zdc_CalibAmp[2][4]
TBranch * b_ps_L1_ZDC_A_C
float _chisqDivAmpCutLG[2][4]
float zdc_SumCalibAmp[2]
std::vector< std::set< int > > _trains
std::vector< float > * zdc_samplesSub
bool _haveLBDepT0[2][4]
float zdc_FitChisq[2][4]
void SetSlewingCoeff(const std::array< std::array< std::vector< float >, 4 >, 2 > &HGParamArr, const std::array< std::array< std::vector< float >, 4 >, 2 > &LGParamArr)
float zdc_MinADC[2][4]
virtual ~ZDCTreeAnalysis()
void LoadEnergyCalibrations(std::array< std::array< TSpline *, 4 >, 2 > &&calibSplines)
void CloseOutputTree()
TFile * _outTFile
current Tree number in a TChain
virtual Int_t Cut(Long64_t entry)
std::vector< int > _BCIDGap
UShort_t zdc_raw[2][4][2][2][7]
float zdc_T0Corr[2][4]
float _T0SlewCoeffHG[2][4][3]
float zdc_CalibTime[2][4]
int zdc_MaxADCSample[2][4]
float _moduleTau1[2][4]
bool _haveLBDepECalib[2][4]
void OpenOutputTree(const std::string &file)
void LoadT0Calibrations(std::array< std::array< TSpline *, 4 >, 2 > &&calibSplinesHG, std::array< std::array< TSpline *, 4 >, 2 > &&calibSplinesLG)
int zdc_MinADCSample[2][4]
float zdc_Min2ndDeriv[2][4]
TBranch * b_trigger_TBP
ZDCDataAnalyzer::ZDCModuleFloatArray _peak2ndDerivMinThresholds
unsigned int GetRunNumber() const
void LoadEntry(int entry)
bool _haveModuleSettings[2][4]
std::vector< float > * zdc_samplesDeriv
virtual void Loop(int numEntries=-1, int startEntry=0)
std::vector< int > _BCIDPosInTrain
virtual void Init(TTree *tree)
ZDCDataAnalyzer * _dataAnalyzer_p
TChain * tree
TFile * file