ATLAS Offline Software
Calibrator.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 /********************************************************************
6 
7  NAME: Calibrator.h
8 PACKAGE: TRTCalibTools
9 
10 AUTHORS: Johan Lundquist
11 CREATED: 27-03-2009
12 
13 PURPOSE: Class for calibrating a TRT sub-level
14 
15 ********************************************************************/
16 
18 #include <vector>
19 #include <map>
20 #include <set>
21 #include <string>
22 #include <array>
23 
24 class TH1F;
25 class TH2F;
26 class TF1;
27 class TH1D;
28 class TDirectory;
29 class TGraphErrors;
30 
34 class RtGraph{
35 public: RtGraph(TH2F*, int, const char*, bool, TDirectory*); ~RtGraph();
38  //explicitly delete these, code to implement them would be horrible due to use of raw arrays RtGraph(const RtGraph & other) = delete; RtGraph & operator=(const RtGraph & other) = delete; //TH1D** hslizes; std::vector<double> rval; std::vector<double> tval; TGraphErrors* trgr; TGraphErrors* rtgr; int npoints; float mintime;
48 private: std::string m_chname; std::string m_chtit;
51  /***/ enum bintype {LOW, GOOD, HIGH, EMPTY};
52  /***/ bintype* m_btype;
53  /***/ float *m_rightsig;
54  /***/ float *m_leftsig;
55  /***/ float *m_maxval;
56  /***/ float *m_leftval;
57  /***/ float *m_rightval;
58  /***/ float m_mean;
59  /***/ float m_mindistance;
60  /***/ int *m_maxbin;
61  /***/ int m_ipoint;
62  /***/ float m_t;
63  /***/ float m_d;
64  /***/ float m_et;
65  /***/ float m_ed;
66  /***/ float *m_tv;
67  /***/ float *m_dv;
68  /***/ float *m_etv;
69  /***/ float *m_edv;
70 // /***/ float width;
71 // /***/ TF1* m_ff;
72 };
73 
77 class databundle{
78  public: int det; int lay; int mod; int brd; int chp; int stl; int stw; int sid; int ievt; float tres; float weight; float res; float t; float r; float t0; float rt0; std::array<float, 4> rtpar{}; float x; float y; float z;
99 };
100 
104 class caldata{
105  public:
106  caldata();
107  caldata(bool,int,int);
108  ~caldata(); int det; int lay; int mod; int brd; int chp; int stl; int stw; int sid; int ntres; int nrt; int nres; int t0fittype; float res; float resMean; float reserr; float tres; float tresMean; float t0; float t0err; float reft0; float t0off; float rtt0; std::array<float, 4> oldrtpar{}; std::array<float, 4> rtpar{}; float nhits; float x; float y; float z; double oldt02; double sumt0; double sumx; double sumy; double sumz; bool calflag; bool rtflag; bool t0flag; std::vector<float> m_treshist; std::vector<float> reshist; std::vector<float> rthist; RtGraph* rtgraph;
149 };
150 
154 //class caldata : public caldata{
155 // public:
156 // /**the 1D time residual histogram (100 bins)*/ float treshist[100];
157 // /**the 1D residual histogram (100 bins)*/ float reshist[100];
158 // /**the 2D rt histogram (20x32 bins)*/ float rthist[640];
159 //};
160 
179 public:
180  Calibrator();
181 
191  Calibrator(int,const std::string&,int,int,const std::string&,const std::string&,float);
192 
193  Calibrator (const Calibrator&) = delete;
194  Calibrator& operator= (const Calibrator&) = delete;
195 
199  ~Calibrator();
200 
209  int Simple1dHist(float, float, int, float);
210 
223  int Simple2dHist(float, float, int, float, float, int, float, float);
224 
231  float AccumulativeMean(float, float, float);
232 
240  int AddHit(const std::string&, const databundle &,int*,bool);
241 
249  TDirectory* Calibrate ATLAS_NOT_THREAD_SAFE (TDirectory*, std::string, const std::string&, caldata*);
250 
257  float FitRt ATLAS_NOT_THREAD_SAFE (const std::string&,const std::string&,TH2F*,TDirectory*);
258 
265  float FitTimeResidual ATLAS_NOT_THREAD_SAFE (const std::string&,TH1F*);
266 
273  float FitResidual ATLAS_NOT_THREAD_SAFE (const std::string&,TH1F*);
274 
279  void WriteStat(TDirectory*);
280 
281  void DumpConstants();
282 
285  std::string GetBinnedRt(const std::string&);
286 
290  std::string PrintStat();
291 
292  std::string PrintInfo();
293 
297  bool HasKey(const std::string&) const;
298 
302  int UpdateOldConstants();
303 
309  bool CheckSelection(int);
310 
314  bool Skip();
315 
320  std::string GetOptString() const;
321 
325  int GetNDirs();
326 
331  std::string GetSelString();
332 
333  float oldt0(const std::string& key) {return data[key].sumt0/float(data[key].ntres);}
334  float xmean(const std::string& key) {return data[key].sumx/float(data.size());}
335  float ymean(const std::string& key) {return data[key].sumy/float(data.size());}
336  float zmean(const std::string& key) {return data[key].sumz/float(data.size());}
337 
339  std::map<std::string,caldata> data;
340  bool dort; bool dot0; bool dores; bool nort; bool not0; bool usebref; bool bequiet; bool printlog; bool printt0; bool printrt; bool usep0; bool floatp3; bool useshortstraws; std::set<int> selection; int level;
356 
357 private:
358  std::string m_name; std::string m_rtbinning; int m_minrtstat; int m_mint0stat; float m_t0shift; int m_nbinsr; int m_nbinst; int m_nbinstres; int m_nbinsres; float m_minr; float m_maxr; float m_mint; float m_maxt; float m_mintres; float m_maxtres; float m_minres; float m_maxres; std::map<std::string,TDirectory*> m_hdirs; std::map<std::string,TH1F*> m_resHists; std::map<std::string,TH1F*> m_tresHists; std::map<std::string,TH2F*> m_rtHists;
380  // /**...*/ std::map<std::string,RtGraph*> m_rtgraphs; int m_ntreshits; int m_nreshits; int m_nrthits; int m_nhits;
385 
386 
387  bool m_isdines;
389 
390 };
391 
392 
Calibrator::m_name
std::string m_name
The name of the Calibrator instance.
Definition: Calibrator.h:359
Calibrator::ymean
float ymean(const std::string &key)
Definition: Calibrator.h:335
Calibrator::printt0
bool printt0
if true a t0 entry in the calibration output file is prined for each sub-module in this sub-level
Definition: Calibrator.h:349
databundle::det
int det
detector (barrel -1 or 1, or end-cap -2 or 2)
Definition: Calibrator.h:79
Calibrator::dort
bool dort
if true an rt fit is made, if false the value from the level above is used
Definition: Calibrator.h:341
Calibrator::m_maxres
float m_maxres
upper limit of 1D residual histogram
Definition: Calibrator.h:375
Calibrator::nort
bool nort
if true the old rt parameters are copied to the new ones
Definition: Calibrator.h:344
Calibrator::m_nbinsr
int m_nbinsr
number of r-bins in the 2D rt histogram
Definition: Calibrator.h:364
caldata::rthist
std::vector< float > rthist
the 2D rt histogram (20x32 bins)
Definition: Calibrator.h:147
caldata::t0fittype
int t0fittype
the type of time residual fit that was made
Definition: Calibrator.h:120
Calibrator::printlog
bool printlog
if true a log entry is prined for each sub-modile in this sub-level
Definition: Calibrator.h:348
caldata::nhits
float nhits
the number of straws in the sub-module
Definition: Calibrator.h:133
Calibrator::oldt0
float oldt0(const std::string &key)
Definition: Calibrator.h:333
caldata::ntres
int ntres
number of time residual histogram entries
Definition: Calibrator.h:117
caldata::brd
int brd
board
Definition: Calibrator.h:112
caldata::sid
int sid
straw ID
Definition: Calibrator.h:116
TH2F
Definition: rootspy.cxx:420
Calibrator::m_maxtres
float m_maxtres
upper limit of 1D time residual histogram
Definition: Calibrator.h:373
Calibrator::m_mintres
float m_mintres
lower limit of 1D time residual histogram
Definition: Calibrator.h:372
RtGraph::~RtGraph
~RtGraph()
the destructor
Definition: Calibrator.cxx:287
Calibrator::UpdateOldConstants
int UpdateOldConstants()
...
Definition: Calibrator.cxx:529
Calibrator
A structure to contain data associated with the calibration of a certain sub-module.
Definition: Calibrator.h:178
Calibrator::HasKey
bool HasKey(const std::string &) const
...
Definition: Calibrator.cxx:452
Calibrator::m_hdirs
std::map< std::string, TDirectory * > m_hdirs
...
Definition: Calibrator.h:376
RtGraph::HIGH
@ HIGH
Definition: Calibrator.h:51
Calibrator::m_t0shift
float m_t0shift
the t0 shift
Definition: Calibrator.h:363
Calibrator::zmean
float zmean(const std::string &key)
Definition: Calibrator.h:336
Calibrator::m_maxt
float m_maxt
upper limit of t in 2D rt histogram
Definition: Calibrator.h:371
TH1D
Definition: rootspy.cxx:342
caldata
A structure to contain data associated with the calibration of a certain sub-module.
Definition: Calibrator.h:104
databundle::lay
int lay
layer
Definition: Calibrator.h:80
Calibrator::CheckSelection
bool CheckSelection(int)
Checks if a given sub-module is selected for calibration.
Definition: Calibrator.cxx:457
Calibrator::printrt
bool printrt
if true an rt entry in the calibration output file is prined for each sub-module in this sub-level
Definition: Calibrator.h:350
caldata::x
float x
sub-module x position (average of all straws in the module)
Definition: Calibrator.h:134
RtGraph::GOOD
@ GOOD
Definition: Calibrator.h:51
caldata::det
int det
detector (barrel or end-cap)
Definition: Calibrator.h:109
Calibrator::ATLAS_NOT_THREAD_SAFE
float FitResidual ATLAS_NOT_THREAD_SAFE(const std::string &, TH1F *)
Makes the residual fit.
Calibrator::ATLAS_NOT_THREAD_SAFE
TDirectory *Calibrate ATLAS_NOT_THREAD_SAFE(TDirectory *, std::string, const std::string &, caldata *)
Creates root histograms, performs the t0 and R-t calibration for a given sub-module and writes the re...
Calibrator::dot0
bool dot0
if true a time residual fit is made, if false the value from the level above is used
Definition: Calibrator.h:342
RtGraph::m_tv
float * m_tv
Definition: Calibrator.h:66
caldata::resMean
float resMean
the residual mean
Definition: Calibrator.h:122
caldata::oldt02
double oldt02
the old sub-module t0 (average of t0 for all straws in the module)
Definition: Calibrator.h:137
databundle::brd
int brd
board
Definition: Calibrator.h:82
caldata::sumt0
double sumt0
...
Definition: Calibrator.h:138
caldata::lay
int lay
layer
Definition: Calibrator.h:110
Calibrator::m_nbinst
int m_nbinst
number of t-bins in the 2D rt histogram
Definition: Calibrator.h:365
Calibrator::ATLAS_NOT_THREAD_SAFE
float FitTimeResidual ATLAS_NOT_THREAD_SAFE(const std::string &, TH1F *)
Makes the time residual fit.
Calibrator::usebref
bool usebref
if true chip reference t0 values (offset from board mean) are used
Definition: Calibrator.h:346
Calibrator::floatp3
bool floatp3
if true the 3rd order coeficcient of the rt fit function is not fixed to 0
Definition: Calibrator.h:352
caldata::y
float y
sub-module y position (average of all straws in the module)
Definition: Calibrator.h:135
caldata::rtflag
bool rtflag
flag indicating if an R-t calibration has been made
Definition: Calibrator.h:143
Calibrator::Skip
bool Skip()
...
Definition: Calibrator.cxx:462
databundle::stw
int stw
straw number (within the strawlayer)
Definition: Calibrator.h:85
Calibrator::PrintInfo
std::string PrintInfo()
Definition: Calibrator.cxx:467
caldata::res
float res
the residual
Definition: Calibrator.h:121
Calibrator::dores
bool dores
if true a residual fit is made
Definition: Calibrator.h:343
Calibrator::m_tresHists
std::map< std::string, TH1F * > m_tresHists
...
Definition: Calibrator.h:378
databundle::mod
int mod
phi module
Definition: Calibrator.h:81
caldata::sumz
double sumz
...
Definition: Calibrator.h:141
Calibrator::usep0
bool usep0
if true the 0th order coeficcient of the rt fit function is not set to 0 in the calibration output fi...
Definition: Calibrator.h:351
caldata::t0off
float t0off
the t0 offset from the level below
Definition: Calibrator.h:129
RtGraph::EMPTY
@ EMPTY
Definition: Calibrator.h:51
Calibrator::m_rtbinning
std::string m_rtbinning
The direction to do the R-t binning.
Definition: Calibrator.h:360
caldata::stl
int stl
straw-layer
Definition: Calibrator.h:114
caldata::caldata
caldata()
Definition: Calibrator.cxx:33
caldata::t0flag
bool t0flag
flag indicating if a t0 calibration has been made
Definition: Calibrator.h:144
Calibrator::m_minr
float m_minr
lower limit of r in 2D rt histogram
Definition: Calibrator.h:368
RtGraph::m_rightval
float * m_rightval
Definition: Calibrator.h:57
Calibrator::GetOptString
std::string GetOptString() const
Creates a string summarizing what is being done at this sub-level.
Definition: Calibrator.cxx:485
Calibrator::ATLAS_NOT_THREAD_SAFE
float FitRt ATLAS_NOT_THREAD_SAFE(const std::string &, const std::string &, TH2F *, TDirectory *)
Makes the R-t fit.
Calibrator::m_rtHists
std::map< std::string, TH2F * > m_rtHists
...
Definition: Calibrator.h:379
databundle::x
float x
straw x position
Definition: Calibrator.h:96
caldata::mod
int mod
phi module
Definition: Calibrator.h:111
caldata::t0
float t0
the new t0
Definition: Calibrator.h:126
caldata::rtgraph
RtGraph * rtgraph
the rt graph
Definition: Calibrator.h:148
caldata::rtpar
std::array< float, 4 > rtpar
the new rt-parameters
Definition: Calibrator.h:132
caldata::nrt
int nrt
number of rt histogram entries
Definition: Calibrator.h:118
databundle::res
float res
space residual
Definition: Calibrator.h:90
Calibrator::DumpConstants
void DumpConstants()
Definition: Calibrator.cxx:1225
RtGraph::m_btype
bintype * m_btype
Definition: Calibrator.h:52
RtGraph::m_mindistance
float m_mindistance
Definition: Calibrator.h:59
Calibrator::Calibrator
Calibrator()
Definition: Calibrator.cxx:339
RtGraph::m_leftval
float * m_leftval
Definition: Calibrator.h:56
RtGraph::m_chname
std::string m_chname
the histogram name
Definition: Calibrator.h:49
Calibrator::operator=
Calibrator & operator=(const Calibrator &)=delete
Calibrator::m_mint
float m_mint
lower limit of t in 2D rt histogram
Definition: Calibrator.h:370
databundle::ievt
int ievt
event number
Definition: Calibrator.h:87
RtGraph::m_d
float m_d
Definition: Calibrator.h:63
RtGraph::m_rightsig
float * m_rightsig
Definition: Calibrator.h:53
RtGraph::m_leftsig
float * m_leftsig
Definition: Calibrator.h:54
caldata::sumx
double sumx
...
Definition: Calibrator.h:139
Calibrator::Simple2dHist
int Simple2dHist(float, float, int, float, float, int, float, float)
A 2D histograming function.
Definition: Calibrator.cxx:439
databundle::weight
float weight
histogram weight (currently set to 1)
Definition: Calibrator.h:89
Calibrator::selection
std::set< int > selection
a set containing the sub-modules to be calibrated
Definition: Calibrator.h:354
RtGraph::m_et
float m_et
Definition: Calibrator.h:64
caldata::t0err
float t0err
the new to error
Definition: Calibrator.h:127
caldata::tres
float tres
the time residual
Definition: Calibrator.h:124
caldata::tresMean
float tresMean
the time residual mean
Definition: Calibrator.h:125
RtGraph::m_etv
float * m_etv
Definition: Calibrator.h:68
Calibrator::WriteStat
void WriteStat(TDirectory *)
Creates an ntuple with entries containing data associated with the sub-modules in a sub level.
Definition: Calibrator.cxx:1180
Calibrator::Simple1dHist
int Simple1dHist(float, float, int, float)
A 1D histograming function.
Definition: Calibrator.cxx:432
caldata::chp
int chp
chip
Definition: Calibrator.h:113
Calibrator::m_mint0stat
int m_mint0stat
minimum number of hits in a sub-module required to do a t0 calibration
Definition: Calibrator.h:362
caldata::sumy
double sumy
...
Definition: Calibrator.h:140
databundle::rtpar
std::array< float, 4 > rtpar
rt-parameters used in the reconstruction
Definition: Calibrator.h:95
Calibrator::useshortstraws
bool useshortstraws
if true a shift of -0.75 ns is applied for straws in layer ==0, strawlayer < 9, and when doing calibr...
Definition: Calibrator.h:353
Calibrator::m_maxr
float m_maxr
upper limit of r in 2D rt histogram
Definition: Calibrator.h:369
caldata::reserr
float reserr
the residual error
Definition: Calibrator.h:123
Calibrator::PrintStat
std::string PrintStat()
Prints some sub-level statistics.
Definition: Calibrator.cxx:478
Calibrator::not0
bool not0
if true the old t0 valus is copied to the new one
Definition: Calibrator.h:345
Calibrator::m_resHists
std::map< std::string, TH1F * > m_resHists
...
Definition: Calibrator.h:377
databundle
A structure to contain hit data.
Definition: Calibrator.h:77
RtGraph::RtGraph
RtGraph(TH2F *, int, const char *, bool, TDirectory *)
the constructor
Definition: Calibrator.cxx:118
RtGraph::m_chtit
std::string m_chtit
the histogram title
Definition: Calibrator.h:50
RtGraph::m_mean
float m_mean
Definition: Calibrator.h:58
databundle::chp
int chp
chip
Definition: Calibrator.h:83
caldata::calflag
bool calflag
flag indicating if any calibration has been made
Definition: Calibrator.h:142
Calibrator::AccumulativeMean
float AccumulativeMean(float, float, float)
Increments a single bin in all three histograms in a sub-module.
Definition: Calibrator.cxx:447
RtGraph::LOW
@ LOW
Definition: Calibrator.h:51
databundle::z
float z
straw z position
Definition: Calibrator.h:98
Calibrator::AddHit
int AddHit(const std::string &, const databundle &, int *, bool)
Adds hits to a sub-module either in the form of a single straw hit or a histogram containing all the ...
Definition: Calibrator.cxx:962
RtGraph::m_maxval
float * m_maxval
Definition: Calibrator.h:55
Calibrator::GetSelString
std::string GetSelString()
Creates a string summarizing which modules are being calibrated at this sub-level.
Definition: Calibrator.cxx:506
databundle::rt0
float rt0
reference t0 (offset from board mean)
Definition: Calibrator.h:94
Calibrator::m_minres
float m_minres
lower limit of 1D residual histogram
Definition: Calibrator.h:374
TH1F
Definition: rootspy.cxx:320
RtGraph::m_dv
float * m_dv
Definition: Calibrator.h:67
caldata::m_treshist
std::vector< float > m_treshist
the 1D time residual histogram (100 bins)
Definition: Calibrator.h:145
caldata::nres
int nres
number of residual histogram entries
Definition: Calibrator.h:119
RtGraph::m_edv
float * m_edv
Definition: Calibrator.h:69
caldata::stw
int stw
straw number (within the strawlayer)
Definition: Calibrator.h:115
Calibrator::~Calibrator
~Calibrator()
Destructor.
Definition: Calibrator.cxx:429
caldata::reshist
std::vector< float > reshist
the 1D residual histogram (100 bins)
Definition: Calibrator.h:146
Calibrator::m_nbinsres
int m_nbinsres
number of bins in the 1D residual histogram
Definition: Calibrator.h:367
databundle::stl
int stl
straw-layer
Definition: Calibrator.h:84
Calibrator::Calibrator
Calibrator(const Calibrator &)=delete
databundle::r
float r
drift radius from r(t) relation
Definition: Calibrator.h:92
caldata::rtt0
float rtt0
the t0 fron the R-t fit
Definition: Calibrator.h:130
databundle::sid
int sid
straw ID
Definition: Calibrator.h:86
RtGraph::m_ipoint
int m_ipoint
Definition: Calibrator.h:61
Calibrator::xmean
float xmean(const std::string &key)
Definition: Calibrator.h:334
caldata::~caldata
~caldata()
Definition: Calibrator.cxx:71
caldata::reft0
float reft0
the reference t0 (offset from board mean)
Definition: Calibrator.h:128
RtGraph
A class for generating a r-t and t-r graphs by binning the 2D histograms in Calibrator::rtHists in r ...
Definition: Calibrator.h:34
Calibrator::m_isdines
bool m_isdines
true if the rt relation is Dines'
Definition: Calibrator.h:388
RtGraph::m_ed
float m_ed
Definition: Calibrator.h:65
Calibrator::bequiet
bool bequiet
if true no histograms are written to the root file
Definition: Calibrator.h:347
databundle::tres
float tres
time residual
Definition: Calibrator.h:88
databundle::t0
float t0
t0 value used in reconstruction
Definition: Calibrator.h:93
Calibrator::m_nbinstres
int m_nbinstres
number of bins in the 1D time residual histogram
Definition: Calibrator.h:366
checker_macros.h
Define macros for attributes used to control the static checker.
Calibrator::level
int level
the sub-level of the Calibrator instance
Definition: Calibrator.h:355
RtGraph::m_maxbin
int * m_maxbin
Definition: Calibrator.h:60
Calibrator::m_minrtstat
int m_minrtstat
minimum number of hits in a sub-module required to do an R-t calibration
Definition: Calibrator.h:361
caldata::oldrtpar
std::array< float, 4 > oldrtpar
the rt-parameters used in the track reconstruction
Definition: Calibrator.h:131
caldata::z
float z
sub-module z position (average of all straws in the module)
Definition: Calibrator.h:136
readCCLHist.float
float
Definition: readCCLHist.py:83
databundle::y
float y
straw y position
Definition: Calibrator.h:97
Calibrator::GetBinnedRt
std::string GetBinnedRt(const std::string &)
Definition: Calibrator.cxx:514
RtGraph::bintype
bintype
Definition: Calibrator.h:51
Calibrator::data
std::map< std::string, caldata > data
A map between the sub-module identifier string and the calibration data structure (caldata)
Definition: Calibrator.h:339
RtGraph::m_t
float m_t
Definition: Calibrator.h:62
Calibrator::GetNDirs
int GetNDirs()
...
Definition: Calibrator.cxx:502
databundle::t
float t
raw time
Definition: Calibrator.h:91
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37