ATLAS Offline Software
Loading...
Searching...
No Matches
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
8PACKAGE: TRTCalibTools
9
10AUTHORS: Johan Lundquist
11CREATED: 27-03-2009
12
13PURPOSE: 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
24class TH1F;
25class TH2F;
26class TF1;
27class TH1D;
28class TDirectory;
29class TGraphErrors;
30
34class RtGraph{
35public: 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;
48private: std::string m_chname; std::string m_chtit;
51 /***/ enum bintype {LOW, GOOD, HIGH, EMPTY};
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
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
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
179public:
181
191 Calibrator(int,const std::string&,int,int,const std::string&,const std::string&,float);
192
193 Calibrator (const Calibrator&) = delete;
195
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
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
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
357private:
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
Define macros for attributes used to control the static checker.
bool Skip()
...
float FitResidual ATLAS_NOT_THREAD_SAFE(const std::string &, TH1F *)
Makes the residual fit.
void DumpConstants()
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...
std::string PrintInfo()
float ymean(const std::string &key)
Definition Calibrator.h:335
int Simple1dHist(float, float, int, float)
A 1D histograming function.
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 ...
std::string GetOptString() const
Creates a string summarizing what is being done at this sub-level.
~Calibrator()
Destructor.
float FitRt ATLAS_NOT_THREAD_SAFE(const std::string &, const std::string &, TH2F *, TDirectory *)
Makes the R-t fit.
Calibrator(const Calibrator &)=delete
std::string GetBinnedRt(const std::string &)
bool HasKey(const std::string &) const
...
int UpdateOldConstants()
...
Calibrator(int, const std::string &, int, int, const std::string &, const std::string &, float)
Constructor.
float AccumulativeMean(float, float, float)
Increments a single bin in all three histograms in a sub-module.
float zmean(const std::string &key)
Definition Calibrator.h:336
int Simple2dHist(float, float, int, float, float, int, float, float)
A 2D histograming function.
std::string GetSelString()
Creates a string summarizing which modules are being calibrated at this sub-level.
void WriteStat(TDirectory *)
Creates an ntuple with entries containing data associated with the sub-modules in a sub level.
Calibrator & operator=(const Calibrator &)=delete
float xmean(const std::string &key)
Definition Calibrator.h:334
int GetNDirs()
...
float FitTimeResidual ATLAS_NOT_THREAD_SAFE(const std::string &, TH1F *)
Makes the time residual fit.
float oldt0(const std::string &key)
Definition Calibrator.h:333
std::string PrintStat()
Prints some sub-level statistics.
bool CheckSelection(int)
Checks if a given sub-module is selected for calibration.
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
float * m_rightsig
Definition Calibrator.h:53
TGraphErrors * trgr
the t(r) graph
Definition Calibrator.h:44
bintype * m_btype
Definition Calibrator.h:52
float m_mindistance
Definition Calibrator.h:59
float * m_edv
Definition Calibrator.h:69
float * m_tv
Definition Calibrator.h:66
float * m_leftsig
Definition Calibrator.h:54
float m_et
Definition Calibrator.h:64
std::string m_chname
the histogram name
Definition Calibrator.h:49
float * m_etv
Definition Calibrator.h:68
float * m_rightval
Definition Calibrator.h:57
TGraphErrors * rtgr
the r(t) graph
Definition Calibrator.h:45
float m_d
Definition Calibrator.h:63
int m_ipoint
Definition Calibrator.h:61
std::string m_chtit
the histogram title
Definition Calibrator.h:50
float * m_leftval
Definition Calibrator.h:56
RtGraph & operator=(const RtGraph &other)=delete
assignment
float m_t
Definition Calibrator.h:62
std::vector< double > rval
array of the histograms for all bins
Definition Calibrator.h:42
float m_mean
Definition Calibrator.h:58
RtGraph(TH2F *, int, const char *, bool, TDirectory *)
the constructor
~RtGraph()
the destructor
RtGraph(const RtGraph &other)=delete
copy constructor
float m_ed
Definition Calibrator.h:65
int npoints
the number of graph points
Definition Calibrator.h:46
float * m_dv
Definition Calibrator.h:67
std::vector< double > tval
the r values
Definition Calibrator.h:43
float * m_maxval
Definition Calibrator.h:55
float mintime
the minimum t-value
Definition Calibrator.h:47
int * m_maxbin
Definition Calibrator.h:60
A structure to contain data associated with the calibration of a certain sub-module.
Definition Calibrator.h:104
int nrt
number of rt histogram entries
Definition Calibrator.h:118
int lay
layer
Definition Calibrator.h:110
int stw
straw number (within the strawlayer)
Definition Calibrator.h:115
int stl
straw-layer
Definition Calibrator.h:114
int brd
board
Definition Calibrator.h:112
std::vector< float > m_treshist
the 1D time residual histogram (100 bins)
Definition Calibrator.h:145
double sumt0
...
Definition Calibrator.h:138
float reft0
the reference t0 (offset from board mean)
Definition Calibrator.h:128
int det
detector (barrel or end-cap)
Definition Calibrator.h:109
int ntres
number of time residual histogram entries
Definition Calibrator.h:117
float t0
the new t0
Definition Calibrator.h:126
float t0err
the new to error
Definition Calibrator.h:127
float reserr
the residual error
Definition Calibrator.h:123
float y
sub-module y position (average of all straws in the module)
Definition Calibrator.h:135
float rtt0
the t0 fron the R-t fit
Definition Calibrator.h:130
float tres
the time residual
Definition Calibrator.h:124
double sumx
...
Definition Calibrator.h:139
float z
sub-module z position (average of all straws in the module)
Definition Calibrator.h:136
std::vector< float > reshist
the 1D residual histogram (100 bins)
Definition Calibrator.h:146
bool rtflag
flag indicating if an R-t calibration has been made
Definition Calibrator.h:143
bool calflag
flag indicating if any calibration has been made
Definition Calibrator.h:142
double sumy
...
Definition Calibrator.h:140
bool t0flag
flag indicating if a t0 calibration has been made
Definition Calibrator.h:144
int sid
straw ID
Definition Calibrator.h:116
float x
sub-module x position (average of all straws in the module)
Definition Calibrator.h:134
int nres
number of residual histogram entries
Definition Calibrator.h:119
float tresMean
the time residual mean
Definition Calibrator.h:125
RtGraph * rtgraph
the rt graph
Definition Calibrator.h:148
std::array< float, 4 > oldrtpar
the rt-parameters used in the track reconstruction
Definition Calibrator.h:131
float t0off
the t0 offset from the level below
Definition Calibrator.h:129
float resMean
the residual mean
Definition Calibrator.h:122
std::vector< float > rthist
the 2D rt histogram (20x32 bins)
Definition Calibrator.h:147
std::array< float, 4 > rtpar
the new rt-parameters
Definition Calibrator.h:132
int chp
chip
Definition Calibrator.h:113
int t0fittype
the type of time residual fit that was made
Definition Calibrator.h:120
double oldt02
the old sub-module t0 (average of t0 for all straws in the module)
Definition Calibrator.h:137
float nhits
the number of straws in the sub-module
Definition Calibrator.h:133
float res
the residual
Definition Calibrator.h:121
double sumz
...
Definition Calibrator.h:141
int mod
phi module
Definition Calibrator.h:111
A structure to contain hit data.
Definition Calibrator.h:77
float res
space residual
Definition Calibrator.h:90
int det
detector (barrel -1 or 1, or end-cap -2 or 2)
Definition Calibrator.h:79
float rt0
reference t0 (offset from board mean)
Definition Calibrator.h:94
int ievt
event number
Definition Calibrator.h:87
int chp
chip
Definition Calibrator.h:83
float t
raw time
Definition Calibrator.h:91
float r
drift radius from r(t) relation
Definition Calibrator.h:92
int brd
board
Definition Calibrator.h:82
float tres
time residual
Definition Calibrator.h:88
std::array< float, 4 > rtpar
rt-parameters used in the reconstruction
Definition Calibrator.h:95
float t0
t0 value used in reconstruction
Definition Calibrator.h:93
int stw
straw number (within the strawlayer)
Definition Calibrator.h:85
int stl
straw-layer
Definition Calibrator.h:84
float z
straw z position
Definition Calibrator.h:98
float x
straw x position
Definition Calibrator.h:96
int lay
layer
Definition Calibrator.h:80
float y
straw y position
Definition Calibrator.h:97
float weight
histogram weight (currently set to 1)
Definition Calibrator.h:89
int mod
phi module
Definition Calibrator.h:81
int sid
straw ID
Definition Calibrator.h:86
TH1F(name, title, nxbins, bins_par2, bins_par3=None, path='', **kwargs)