ATLAS Offline Software
Loading...
Searching...
No Matches
Calibrator Class Reference

An instance of this class is created for each sub-level of the TRT by the TRTCalibrator. More...

#include <Calibrator.h>

Collaboration diagram for Calibrator:

Public Member Functions

 Calibrator ()
 Calibrator (int, const std::string &, int, int, const std::string &, const std::string &, float)
 Constructor.
 Calibrator (const Calibrator &)=delete
Calibratoroperator= (const Calibrator &)=delete
 ~Calibrator ()
 Destructor.
int Simple1dHist (float, float, int, float)
 A 1D histograming function.
int Simple2dHist (float, float, int, float, float, int, float, float)
 A 2D histograming function.
float AccumulativeMean (float, float, float)
 Increments a single bin in all three histograms in a sub-module.
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 hits in a single straw.
TDirectory *Calibrate ATLAS_NOT_THREAD_SAFE (TDirectory *, const std::string &, const std::string &, caldata *)
 Creates root histograms, performs the t0 and R-t calibration for a given sub-module and writes the resulting histograms to a root directory tree (if not told otherwise).
float FitRt ATLAS_NOT_THREAD_SAFE (const std::string &, const std::string &, TH2F *, TDirectory *)
 Makes the R-t fit.
float FitTimeResidual ATLAS_NOT_THREAD_SAFE (const std::string &, TH1F *)
 Makes the time residual fit.
float FitResidual ATLAS_NOT_THREAD_SAFE (const std::string &, TH1F *)
 Makes the residual fit.
void WriteStat (TDirectory *)
 Creates an ntuple with entries containing data associated with the sub-modules in a sub level.
void DumpConstants ()
std::string GetBinnedRt (const std::string &)
std::string PrintStat ()
 Prints some sub-level statistics.
std::string PrintInfo ()
bool HasKey (const std::string &) const
 ...
int UpdateOldConstants ()
 ...
bool CheckSelection (int)
 Checks if a given sub-module is selected for calibration.
bool Skip ()
 ...
std::string GetOptString () const
 Creates a string summarizing what is being done at this sub-level.
int GetNDirs ()
 ...
std::string GetSelString ()
 Creates a string summarizing which modules are being calibrated at this sub-level.
float oldt0 (const std::string &key)
float xmean (const std::string &key)
float ymean (const std::string &key)
float zmean (const std::string &key)

Public Attributes

std::map< std::string, caldatadata
 A map between the sub-module identifier string and the calibration data structure (caldata).
bool dort {}
 if true an rt fit is made, if false the value from the level above is used
bool dot0 {}
 if true a time residual fit is made, if false the value from the level above is used
bool dores {}
 if true a residual fit is made
bool nort {}
 if true the old rt parameters are copied to the new ones
bool not0 {}
 if true the old t0 valus is copied to the new one
bool usebref {}
 if true chip reference t0 values (offset from board mean) are used
bool bequiet {}
 if true no histograms are written to the root file
bool printlog {}
 if true a log entry is prined for each sub-modile in this sub-level
bool printt0 {}
 if true a t0 entry in the calibration output file is prined for each sub-module in this sub-level
bool printrt {}
 if true an rt entry in the calibration output file is prined for each sub-module in this sub-level
bool usep0 {}
 if true the 0th order coeficcient of the rt fit function is not set to 0 in the calibration output file
bool floatp3 {}
 if true the 3rd order coeficcient of the rt fit function is not fixed to 0
bool useshortstraws {}
 if true a shift of -0.75 ns is applied for straws in layer ==0, strawlayer < 9, and when doing calibration in a granuralyty different from chip or straw
std::set< int > selection
 a set containing the sub-modules to be calibrated
int level {}
 the sub-level of the Calibrator instance

Private Attributes

std::string m_name
 The name of the Calibrator instance.
std::string m_rtbinning
 The direction to do the R-t binning.
int m_minrtstat {}
 minimum number of hits in a sub-module required to do an R-t calibration
int m_mint0stat {}
 minimum number of hits in a sub-module required to do a t0 calibration
float m_t0shift {}
 the t0 shift
int m_nbinsr {}
 number of r-bins in the 2D rt histogram
int m_nbinst {}
 number of t-bins in the 2D rt histogram
int m_nbinstres {}
 number of bins in the 1D time residual histogram
int m_nbinsres {}
 number of bins in the 1D residual histogram
float m_minr {}
 lower limit of r in 2D rt histogram
float m_maxr {}
 upper limit of r in 2D rt histogram
float m_mint {}
 lower limit of t in 2D rt histogram
float m_maxt {}
 upper limit of t in 2D rt histogram
float m_mintres {}
 lower limit of 1D time residual histogram
float m_maxtres {}
 upper limit of 1D time residual histogram
float m_minres {}
 lower limit of 1D residual histogram
float m_maxres {}
 upper limit of 1D residual histogram
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
 ...
std::map< std::string, RtGraph * > m_rtgraphs {}
 ...
int m_ntreshits {}
 ...
int m_nreshits {}
 ...
int m_nrthits {}
 ...
int m_nhits {}
 ...
bool m_isdines
 true if the rt relation is Dines'

Detailed Description

An instance of this class is created for each sub-level of the TRT by the TRTCalibrator.

It contains three histograms for each sub-module in the level:

The histograms are inside a caldata structure which also contains other variables with information about the calibration of a sub-module. There is one caldata instance for each sub-module in the level. They are contained in a map (Calibrator::data) with a key string which identifies the sub-module.

Methods exists for adding hits to the histograms (Calibrator::AddHits) and for fitting them (Calibrator::Calibrate).

Definition at line 178 of file Calibrator.h.

Constructor & Destructor Documentation

◆ Calibrator() [1/3]

Calibrator::Calibrator ( )

Definition at line 339 of file Calibrator.cxx.

340 : dort(false),
341 dot0(false),
342 dores(false),
343 nort(false),
344 not0(false),
345 usebref(false),
346 bequiet(false),
347 printlog(false),
348 printt0(false),
349 printrt(false),
350 usep0(false),
351 floatp3(false),
352 useshortstraws(true),
353
354 m_name ("None"),
355 m_rtbinning ("None"),
356 m_minrtstat (-10),
357 m_mint0stat (-10),
358 m_t0shift (-100.),
359
360 m_nbinsr(100),
361 m_nbinst(55),
362 m_nbinstres(100),
363 m_nbinsres(100),
364 m_minr(0),
365 m_maxr(2),
366 m_mint(-5),
367 m_maxt(50),
368 m_mintres(-10),
369 m_maxtres(10),
370 m_minres(-0.6),
371 m_maxres(0.6),
372
373 m_ntreshits(0),
374 m_nreshits(0),
375 m_nrthits(0),
376 m_nhits(0),
377
378 m_isdines ( false)
379{
380 selection.insert(-3);
381 level =-10;
382}
bool not0
if true the old t0 valus is copied to the new one
Definition Calibrator.h:345
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
std::set< int > selection
a set containing the sub-modules to be calibrated
Definition Calibrator.h:354
int m_nbinsres
number of bins in the 1D residual histogram
Definition Calibrator.h:367
bool nort
if true the old rt parameters are copied to the new ones
Definition Calibrator.h:344
bool dort
if true an rt fit is made, if false the value from the level above is used
Definition Calibrator.h:341
int m_nbinstres
number of bins in the 1D time residual histogram
Definition Calibrator.h:366
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
float m_mint
lower limit of t in 2D rt histogram
Definition Calibrator.h:370
float m_maxt
upper limit of t in 2D rt histogram
Definition Calibrator.h:371
bool floatp3
if true the 3rd order coeficcient of the rt fit function is not fixed to 0
Definition Calibrator.h:352
int m_nhits
...
Definition Calibrator.h:384
bool printlog
if true a log entry is prined for each sub-modile in this sub-level
Definition Calibrator.h:348
int m_nrthits
...
Definition Calibrator.h:383
int level
the sub-level of the Calibrator instance
Definition Calibrator.h:355
float m_maxres
upper limit of 1D residual histogram
Definition Calibrator.h:375
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
int m_nbinsr
number of r-bins in the 2D rt histogram
Definition Calibrator.h:364
int m_ntreshits
...
Definition Calibrator.h:381
int m_nreshits
...
Definition Calibrator.h:382
int m_minrtstat
minimum number of hits in a sub-module required to do an R-t calibration
Definition Calibrator.h:361
float m_maxtres
upper limit of 1D time residual histogram
Definition Calibrator.h:373
bool dot0
if true a time residual fit is made, if false the value from the level above is used
Definition Calibrator.h:342
float m_t0shift
the t0 shift
Definition Calibrator.h:363
float m_maxr
upper limit of r in 2D rt histogram
Definition Calibrator.h:369
float m_mintres
lower limit of 1D time residual histogram
Definition Calibrator.h:372
std::string m_name
The name of the Calibrator instance.
Definition Calibrator.h:359
int m_nbinst
number of t-bins in the 2D rt histogram
Definition Calibrator.h:365
std::string m_rtbinning
The direction to do the R-t binning.
Definition Calibrator.h:360
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
bool bequiet
if true no histograms are written to the root file
Definition Calibrator.h:347
float m_minr
lower limit of r in 2D rt histogram
Definition Calibrator.h:368
bool dores
if true a residual fit is made
Definition Calibrator.h:343
float m_minres
lower limit of 1D residual histogram
Definition Calibrator.h:374
bool usebref
if true chip reference t0 values (offset from board mean) are used
Definition Calibrator.h:346
bool m_isdines
true if the rt relation is Dines'
Definition Calibrator.h:388
int m_mint0stat
minimum number of hits in a sub-module required to do a t0 calibration
Definition Calibrator.h:362

◆ Calibrator() [2/3]

Calibrator::Calibrator ( int lev,
const std::string & nme,
int mint0,
int minrt,
const std::string & rtr,
const std::string & rtb,
float t0sft )

Constructor.

Parameters
[in]levsub level number 0=TRT 1=barrel/ec 2=layer 3=phi-module 4=board 5=chip 6=straw
[in]nmethe name of the calibrator
[in]mint0minimum number of hits in a sub-module required to do a t0 calibration
[in]minrtminimum number of hits in a sub-module required to do an rt calibration
[in]rtrwhich rt-relation to use
[in]rtbwhich rt binning to use

Definition at line 384 of file Calibrator.cxx.

385 : dort(false),
386 dot0(false),
387 dores(false),
388 nort(false),
389 not0(false),
390 usebref(false),
391 bequiet(false),
392 printlog(false),
393 printt0(false),
394 printrt(false),
395 usep0(false),
396 floatp3(false),
397 useshortstraws(true),
398
399 m_name(nme),
400 m_rtbinning(rtb),
401 m_minrtstat(minrt),
402 m_mint0stat(mint0),
403 m_t0shift(t0sft),
404
405 m_nbinsr(100),
406 m_nbinst(55),
407 m_nbinstres(100),
408 m_nbinsres(100),
409 m_minr(0),
410 m_maxr(2),
411 m_mint(-5),
412 m_maxt(50),
413 m_mintres(-10),
414 m_maxtres(10),
415 m_minres(-0.6),
416 m_maxres(0.6),
417
418 m_ntreshits(0),
419 m_nreshits(0),
420 m_nrthits(0),
421 m_nhits(0),
422
423 m_isdines ( rtr.find("dines")!=std::string::npos)
424{
425 level=lev;
426 selection.insert(-3);
427}

◆ Calibrator() [3/3]

Calibrator::Calibrator ( const Calibrator & )
delete

◆ ~Calibrator()

Calibrator::~Calibrator ( )

Destructor.

Definition at line 429 of file Calibrator.cxx.

429 {
430}

Member Function Documentation

◆ AccumulativeMean()

float Calibrator::AccumulativeMean ( float n,
float oldmean,
float newvalue )

Increments a single bin in all three histograms in a sub-module.

Parameters
[in]keythe identifier of the histogram
[in]dthe databundle containing single straw hit data
Returns
1

Definition at line 447 of file Calibrator.cxx.

447 {
448 if((int)n==0) return oldmean;
449 return oldmean*((n-1)/n)+newvalue/n;
450}

◆ AddHit()

int Calibrator::AddHit ( const std::string & key,
const databundle & d,
int * binhist,
bool makehist )

Adds hits to a sub-module either in the form of a single straw hit or a histogram containing all the hits in a single straw.

Parameters
[in]keythe identifier of the sub-module
[in]dthe databundle containing single straw hit data
[in]binhistan integer arry containing the histogram data for a single straw
Returns
1 if the sub-module is seen for the first time and 0 if it has been seen before

Definition at line 962 of file Calibrator.cxx.

962 {
963
964 int tresbin=Simple1dHist(m_mintres,m_maxtres,m_nbinstres,d.tres);
965 int resbin=Simple1dHist(m_minres,m_maxres,m_nbinsres,d.res);
967 int npop;
968 int ibin;
969 int value;
970
971 //if the it is the first hit or histogram
972 if (data.find(key) == data.end()){
973
974 //create a new histogram object
975 caldata* hist=new caldata(makehist,m_nbinst,m_nbinsr);
976
977 //out of memory?
978 if (hist == nullptr){
979 std::cout << "OUT OF MEMORY!" << std::endl;
980 return -1;
981 }
982
983 hist->ntres=0;
984 hist->nres=0;
985 hist->nrt=0;
986 hist->sumt0=0;
987
988 //zero histogram bins
989 for (int i=0;i<m_nbinsr*m_nbinst+200;i++) {
990 if (makehist) hist->rthist[i]=0;
991 if (i<100) {
992 if (makehist) hist->m_treshist[i]=0;
993 if (makehist) hist->reshist[i]=0;
994 }
995 }
996
997 if (binhist==nullptr){ //if it is a hit
998
999 if (tresbin>=0){
1000 if (makehist) hist->m_treshist[tresbin]=d.weight; //add value to bin
1001 hist->ntres=1; //set bin content to 1
1002 m_nhits=1;
1003 }
1004 if (resbin>=0){
1005 if (makehist) hist->reshist[resbin]=1;
1006 hist->nres=1;
1007 }
1008 if (rtbin>=0){
1009 if (makehist) hist->rthist[rtbin]=1;
1010 hist->nrt=1;
1011 }
1012
1013 hist->sumt0=d.t0;
1014 }
1015 else { //if it is a histogram
1016
1017 npop=binhist[0]; //the number of populated (non-zero) bins
1018 if(level<2) std::cout << " Calibrator::AddHit called for key " << key << " add histogram with "<< npop << " non-zero bins " << std::endl;
1019
1020 for(int ipop=2;ipop<2*npop+2;ipop=ipop+2) { //loop over the data
1021
1022 ibin=binhist[ipop]; //bin number
1023 value=binhist[ipop+1]; //value
1024
1025 if (ibin<100) { //timeresidual histogram
1027 hist->ntres+=value;
1028 m_nhits+=value;
1029 if (makehist) hist->m_treshist[ibin]=(float)value;
1030 hist->sumt0+=d.t0*value;
1031 }
1032 else if (ibin>=100 && ibin<200) { //residual histogram
1034 hist->nres+=value;
1035 if (makehist) hist->reshist[ibin-100]=(float)value;
1036 }
1037 else { //rt histogram
1039 hist->nrt+=value;
1040 if (makehist) hist->rthist[ibin-200]=(float)value;
1041 }
1042
1043 }
1044 }
1045
1046 //initialize parameters
1047 if (level>0) hist->det=d.det; else hist->det=-3; //
1048 if (level>1) hist->lay=d.lay; else hist->lay=-3;
1049 if (level>2) hist->mod=d.mod; else hist->mod=-3;
1050 if (level>3) hist->brd=d.brd; else hist->brd=-3;
1051 if (level>4) hist->chp=d.chp; else hist->chp=-3;
1052 if (level>5) hist->stw=d.stw; else hist->stw=-3;
1053 if (level>2) hist->stl=d.stl; else hist->stl=-3;
1054 if (level>5) hist->sid=d.sid; else hist->sid=-3;
1055 hist->res=0;
1056 hist->resMean=0;
1057 hist->reserr=0;
1058 hist->tres=0;
1059 hist->tresMean=0;
1060 hist->t0=0;
1061 if (level==5) hist->reft0=d.rt0; else hist->reft0=0;
1062 hist->t0off=0;
1063 hist->t0err=0;
1064 hist->nhits=1;
1065 hist->t0fittype=0;
1066
1067 hist->x=d.x; //straw x coordinate
1068 hist->y=d.y; //straw y coordinate
1069 hist->z=d.z; //straw z coordinate
1070
1071 hist->oldt02=d.t0; //straw old t0 value
1072 hist->oldrtpar[0]=d.rtpar[0];
1073 hist->oldrtpar[1]=d.rtpar[1];
1074 hist->oldrtpar[2]=d.rtpar[2];
1075 hist->oldrtpar[3]=d.rtpar[3];
1076
1077 hist->sumx=0;
1078 hist->sumy=0;
1079 hist->sumz=0;
1080
1081 hist->rtflag=false;
1082 hist->t0flag=false;
1083 hist->calflag=false;
1084
1085
1086
1087 for (unsigned int i =0; i < 4; i++){
1088 hist->rtpar[i]=-10.0;
1089 }
1090
1091 data[key]=*hist; //save the histogram in the map
1092
1093
1094
1095 data[key].oldt02 = AccumulativeMean(data[key].nhits, data[key].oldt02, d.t0); //update old t0 m_mean value
1096
1097 data[key].nhits++; // increment m_nhits
1098
1099 if(level<2) std::cout << " First hit for det " << data[key].det << " lay " << data[key].lay << " t0 " << data[key].t0 << " upd t0 " << data[key].oldt02 << " nhits: " << data[key].nhits << std::endl;
1100
1101 delete hist;
1102
1103 return 1;
1104}
1105 else { //if not the first hit or histogram
1106
1107 //increment histogram bins
1108 if (binhist==nullptr){
1109
1110 if (tresbin>=0){
1111 if (makehist) data[key].m_treshist[tresbin]=data[key].m_treshist[tresbin]+d.weight;
1112 data[key].ntres++;
1113 m_nhits=1;
1114 }
1115 if (resbin>=0){
1116 if (makehist) data[key].reshist[resbin]++;
1117 data[key].nres++;
1118 }
1119 if (rtbin>=0){
1120 if (makehist) data[key].rthist[rtbin]++;
1121 data[key].nrt++;
1122 }
1123
1124 data[key].sumt0+=d.t0;
1125
1126 }
1127
1128 else {
1129
1130 npop=binhist[0];
1131
1132 for(int ipop=2;ipop<2*npop+2;ipop=ipop+2) {
1133
1134 ibin=binhist[ipop];
1135 value=binhist[ipop+1];
1136
1137 if (ibin<100) {
1139 m_nhits+=value;
1140 data[key].ntres+=value;
1141 if (makehist) data[key].m_treshist[ibin]+=(float)value;
1142 data[key].sumt0+=d.t0*value;
1143 }
1144 else if (ibin>=100 && ibin<200) {
1146 data[key].nres+=value;
1147 if (makehist) data[key].reshist[ibin-100]+=(float)value;
1148 }
1149 else {
1151 data[key].nrt+=value;
1152 if (makehist) data[key].rthist[ibin-200]+=(float)value;
1153 }
1154
1155 }
1156
1157 }
1158
1159
1160 data[key].sumx+=d.x;
1161 data[key].sumy+=d.y;
1162 data[key].sumz+=d.z;
1163 data[key].oldt02 = AccumulativeMean(data[key].nhits, data[key].oldt02, d.t0);
1164 data[key].oldrtpar[0] = AccumulativeMean(data[key].nhits, data[key].oldrtpar[0], d.rtpar[0]);
1165 data[key].oldrtpar[1] = AccumulativeMean(data[key].nhits, data[key].oldrtpar[1], d.rtpar[1]);
1166 data[key].oldrtpar[2] = AccumulativeMean(data[key].nhits, data[key].oldrtpar[2], d.rtpar[2]);
1167 data[key].oldrtpar[3] = AccumulativeMean(data[key].nhits, data[key].oldrtpar[3], d.rtpar[3]);
1168 data[key].x = AccumulativeMean(data[key].nhits, data[key].x, d.x);
1169 data[key].y = AccumulativeMean(data[key].nhits, data[key].y, d.y);
1170 data[key].z = AccumulativeMean(data[key].nhits, data[key].z, d.z);
1171
1172 data[key].nhits++; //increment hit counts
1173
1174 return 0;
1175 }
1176
1177
1178}
#define y
#define x
#define z
int Simple1dHist(float, float, int, float)
A 1D histograming function.
std::map< std::string, caldata > data
A map between the sub-module identifier string and the calibration data structure (caldata).
Definition Calibrator.h:339
float AccumulativeMean(float, float, float)
Increments a single bin in all three histograms in a sub-module.
int Simple2dHist(float, float, int, float, float, int, float, float)
A 2D histograming function.

◆ ATLAS_NOT_THREAD_SAFE() [1/4]

float FitRt Calibrator::ATLAS_NOT_THREAD_SAFE ( const std::string & ,
const std::string & ,
TH2F * ,
TDirectory *  )

Makes the R-t fit.

Parameters
[in]keythe identifier of the sub-module to calibrate
[in]rtHistthe 2D root histogram with the R-t data
Returns
the t0 from the R-t fit

◆ ATLAS_NOT_THREAD_SAFE() [2/4]

float FitResidual Calibrator::ATLAS_NOT_THREAD_SAFE ( const std::string & ,
TH1F *  )

Makes the residual fit.

Parameters
[in]keythe identifier of the sub-module to calibrate
[in]resHistthe 1D root histogram with the residuals
Returns
the mean value of the residual fit

◆ ATLAS_NOT_THREAD_SAFE() [3/4]

float FitTimeResidual Calibrator::ATLAS_NOT_THREAD_SAFE ( const std::string & ,
TH1F *  )

Makes the time residual fit.

Parameters
[in]keythe identifier of the sub-module to calibrate
[in]tresHistthe 1D root histogram with the time residuals
Returns
the mean value of the time residual fit

◆ ATLAS_NOT_THREAD_SAFE() [4/4]

TDirectory *Calibrate Calibrator::ATLAS_NOT_THREAD_SAFE ( TDirectory * ,
const std::string & ,
const std::string & ,
caldata *  )

Creates root histograms, performs the t0 and R-t calibration for a given sub-module and writes the resulting histograms to a root directory tree (if not told otherwise).

The new t0 values are calculated here.

Parameters
[in]dirthe root directory of the sub level above
[in]keythe identifier of the sub-module to calibrate
[in]caldata_abovethe caldata object from the sub-module above the one to be calibrated
Returns
the root directory where the histgrams were written

◆ CheckSelection()

bool Calibrator::CheckSelection ( int level)

Checks if a given sub-module is selected for calibration.

Parameters
[in]levelthe number of the sub-module to check
Returns
returns true if the module is found

Definition at line 457 of file Calibrator.cxx.

457 {
458 if (selection.find(level)!=selection.end() || selection.find(-3)!=selection.end()) return true;
459 else return false;
460}

◆ DumpConstants()

void Calibrator::DumpConstants ( )

Definition at line 1225 of file Calibrator.cxx.

1225 {
1226
1227 std::ofstream dumpfile( "calib_constants_out.txt", std::ios::out | std::ios::app);
1228
1229 for (const std::pair<const std::string, caldata>& p : data) {
1230 dumpfile << p.first << " " << p.second.t0 << " " << std::endl;
1231
1232 }
1233
1234 dumpfile.close();
1235
1236}
std::ofstream dumpfile("dumpfile.log")

◆ GetBinnedRt()

std::string Calibrator::GetBinnedRt ( const std::string & key)

Definition at line 514 of file Calibrator.cxx.

514 {
515
516 int nbins=data[key].rtgraph->tval.size();
517 double maxt=data[key].rtgraph->tval[nbins-1];
518 double mint=data[key].rtgraph->tval[0];
519
520 std::string brt = "";
521 brt += Form("%f %f %i ",mint,maxt,nbins);
522
523 for (int ip=0; ip<nbins;ip++){
524 brt += Form("%f ",data[key].rtgraph->rval[ip]);
525 }
526 return brt;
527}

◆ GetNDirs()

int Calibrator::GetNDirs ( )

...

Definition at line 502 of file Calibrator.cxx.

502 {
503 return data.size();
504}

◆ GetOptString()

std::string Calibrator::GetOptString ( ) const

Creates a string summarizing what is being done at this sub-level.

Returns
the string

Definition at line 485 of file Calibrator.cxx.

485 {
486 std::string optstr="";
487 if (dort) optstr += 'R';
488 if (dot0) optstr += 'T';
489 if (printlog) optstr +='P';
490 if (printt0) optstr += 'F';
491 if (printrt) optstr += 'G';
492 if (bequiet) optstr += 'Q';
493 if (usebref) optstr += 'B';
494 if (useshortstraws) optstr += 'S';
495 if (usep0 && dort) optstr += '0';
496 if (floatp3 && dort) optstr += '3';
497 if (!(dort || dot0 || usebref || bequiet || printlog || printt0 || printrt)) optstr += 'N';
498
499 return optstr;
500}

◆ GetSelString()

std::string Calibrator::GetSelString ( )

Creates a string summarizing which modules are being calibrated at this sub-level.

Returns
the string

Definition at line 506 of file Calibrator.cxx.

506 {
507 std::string selstr="";
508 if (selection.find(-3)!=selection.end()) selstr="*";
509 else if (selection.find(-4)!=selection.end()) selstr="-";
510 else for (int isel : selection) selstr += std::string(Form("%i",isel));
511 return selstr;
512}

◆ HasKey()

bool Calibrator::HasKey ( const std::string & key) const

...

Definition at line 452 of file Calibrator.cxx.

452 {
453
454 return data.find(key) != data.end();
455}

◆ oldt0()

float Calibrator::oldt0 ( const std::string & key)
inline

Definition at line 333 of file Calibrator.h.

333{return data[key].sumt0/float(data[key].ntres);}

◆ operator=()

Calibrator & Calibrator::operator= ( const Calibrator & )
delete

◆ PrintInfo()

std::string Calibrator::PrintInfo ( )

Definition at line 467 of file Calibrator.cxx.

467 {
468 std::string yn[2]={"NO","YES"};
469 std::string info = std::string(Form("CONFIGURATION %-16s: dort=%-3s, dot0=%-3s, dores=%-3s, selection=",m_name.data(),yn[dort].data(),yn[dot0].data(),yn[dores].data()));
470 for (int isel : selection) {
471 if (isel==-3) info += std::string("all");
472 else if (isel==-4) info += std::string("none");
473 else info += std::string(Form("%2i,",isel));
474 }
475 return info;
476}

◆ PrintStat()

std::string Calibrator::PrintStat ( )

Prints some sub-level statistics.

Definition at line 478 of file Calibrator.cxx.

478 {
479 int units = (int)data.size();
480 if(units==0) units++;
481 std::string info = std::string(Form("STATISTICS %16s: nunits=%8i, nhits=%9i, hits/unit=%11.1f", m_name.data(), units, m_nhits, (float)m_nhits/(float)units ));
482 return info;
483}

◆ Simple1dHist()

int Calibrator::Simple1dHist ( float min,
float max,
int nbins,
float value )

A 1D histograming function.

Parameters
[in]minhistogram lower limit
[in]maxhistogram upper limit
[in]nbinsnymber of bins
[in]valuethe value
Returns
the histogram bin

Definition at line 432 of file Calibrator.cxx.

432 {
433 if ( (value<min) || (value>max) ) return -1;
434 if ( max-min == 0 ) return -1;
435 int binno=(int)(nbins*((value-min)/(max-min)));
436 return binno;
437}
#define min(a, b)
Definition cfImp.cxx:40
#define max(a, b)
Definition cfImp.cxx:41

◆ Simple2dHist()

int Calibrator::Simple2dHist ( float minx,
float maxx,
int nbinsx,
float miny,
float maxy,
int nbinsy,
float valuex,
float valuey )

A 2D histograming function.

Parameters
[in]minxhistogram lower x-limit
[in]maxxhistogram upper x-limit
[in]nbinsxnymber of x bins
[in]valuexthe x value
[in]minyhistogram lower y-limit
[in]maxyhistogram upper y-limit
[in]nbinsynymber of y bins
[in]valueythe y value
Returns
the histogram bin in the form (biny*nbinsx+binx)

Definition at line 439 of file Calibrator.cxx.

439 {
440 if ( (valuex<minx) || (valuex>maxx) || (valuey<miny) || (valuey>maxy) ) return -1;
441 if(maxx-minx == 0 || maxy-miny==0) return -1;
442 int binnox=(int)(nbinsx*((valuex-minx)/(maxx-minx)));
443 int binnoy=(int)(nbinsy*((valuey-miny)/(maxy-miny)));
444 return binnoy*nbinsx+binnox;
445}

◆ Skip()

bool Calibrator::Skip ( )

...

Definition at line 462 of file Calibrator.cxx.

462 {
463 if (selection.find(-4)!=selection.end()) return true;
464 else return false;
465}

◆ UpdateOldConstants()

int Calibrator::UpdateOldConstants ( )

...

Definition at line 529 of file Calibrator.cxx.

529 {
530
531 std::string line;
532 std::ifstream oldconstfile("calib_constants_in.txt");
533 std::string key;
534 float t0;
535
536 if (oldconstfile.is_open())
537 {
538 while (!oldconstfile.eof() )
539 {
540 oldconstfile >> key >> t0;
541 if (data.find(key) != data.end()){
542 std::cout << "UPDATED OLD T0: " << key << " " << data[key].oldt02 << " -> " << t0 << std::endl;
543 data[key].oldt02=t0;
544 }
545 }
546 oldconstfile.close();
547 return 0;
548 }
549 else {
550 std::cout << "NO OLD T0S FILE FOUND. USING AVERAGE VALUES!" << std::endl;
551 return -1;
552 }
553}
static Double_t t0

◆ WriteStat()

void Calibrator::WriteStat ( TDirectory * dir)

Creates an ntuple with entries containing data associated with the sub-modules in a sub level.

Parameters
[in]dirthe root directory where to write the ntuple

Definition at line 1180 of file Calibrator.cxx.

1180 {
1181 dir->cd();
1182 TNtuple* stattup = new TNtuple(Form("%stuple",m_name.data()),"statistics","det:lay:mod:brd:chp:sid:stl:stw:rtflag:t0flag:t0:oldt0:rt0:dt0:t0offset:ftype:nhits:nt0:nrt:res:resMean:dres:tres:tresMean:x:y:z");
1183 for(std::map<std::string,caldata>::iterator ihist=data.begin(); ihist!=data.end(); ++ihist){
1184 if ((ihist->second).calflag) {
1185 //std::cout << " Writing TNtuple for name: " << m_name << " det: " << (ihist->second).det << " lay " << (ihist->second).lay << " mod: " << (ihist->second).mod << " brd " << (ihist->second).brd << " res width " << (ihist->second).res << " tres mean " << (ihist->second).tresMean << std::endl;
1186 float const ntvar[27]={
1187 float((ihist->second).det),
1188 float((ihist->second).lay),
1189 float((ihist->second).mod),
1190 float((ihist->second).brd),
1191 float((ihist->second).chp),
1192 float((ihist->second).sid),
1193 float((ihist->second).stl),
1194 float((ihist->second).stw),
1195 float((int)(ihist->second).rtflag),
1196 float((int)(ihist->second).t0flag),
1197 (ihist->second).t0,
1198 float((ihist->second).oldt02),
1199 //oldt0(ihist->first),
1200 (ihist->second).reft0,
1201 (ihist->second).t0err,
1202 (ihist->second).t0off,
1203 float((ihist->second).t0fittype),
1204 (ihist->second).nhits,
1205 (float)(ihist->second).ntres,
1206 (float)(ihist->second).nrt,
1207 (float)(ihist->second).res,
1208 (float)(ihist->second).resMean,
1209 (ihist->second).reserr,
1210 (ihist->second).tres,
1211 (ihist->second).tresMean,
1212 (ihist->second).x,
1213 (ihist->second).y,
1214 (ihist->second).z
1215 };
1216 stattup->Fill(ntvar);
1217 }
1218
1219 }
1220
1221 stattup->Write();
1222
1223}
std::pair< std::vector< unsigned int >, bool > res

◆ xmean()

float Calibrator::xmean ( const std::string & key)
inline

Definition at line 334 of file Calibrator.h.

334{return data[key].sumx/float(data.size());}

◆ ymean()

float Calibrator::ymean ( const std::string & key)
inline

Definition at line 335 of file Calibrator.h.

335{return data[key].sumy/float(data.size());}

◆ zmean()

float Calibrator::zmean ( const std::string & key)
inline

Definition at line 336 of file Calibrator.h.

336{return data[key].sumz/float(data.size());}

Member Data Documentation

◆ bequiet

bool Calibrator::bequiet {}

if true no histograms are written to the root file

Definition at line 347 of file Calibrator.h.

347{};

◆ data

std::map<std::string,caldata> Calibrator::data

A map between the sub-module identifier string and the calibration data structure (caldata).

Definition at line 339 of file Calibrator.h.

◆ dores

bool Calibrator::dores {}

if true a residual fit is made

Definition at line 343 of file Calibrator.h.

343{};

◆ dort

bool Calibrator::dort {}

if true an rt fit is made, if false the value from the level above is used

Definition at line 341 of file Calibrator.h.

341{};

◆ dot0

bool Calibrator::dot0 {}

if true a time residual fit is made, if false the value from the level above is used

Definition at line 342 of file Calibrator.h.

342{};

◆ floatp3

bool Calibrator::floatp3 {}

if true the 3rd order coeficcient of the rt fit function is not fixed to 0

Definition at line 352 of file Calibrator.h.

352{};

◆ level

int Calibrator::level {}

the sub-level of the Calibrator instance

Definition at line 355 of file Calibrator.h.

355{};

◆ m_hdirs

std::map<std::string,TDirectory*> Calibrator::m_hdirs
private

...

Definition at line 376 of file Calibrator.h.

◆ m_isdines

bool Calibrator::m_isdines
private

true if the rt relation is Dines'

Definition at line 388 of file Calibrator.h.

◆ m_maxr

float Calibrator::m_maxr {}
private

upper limit of r in 2D rt histogram

Definition at line 369 of file Calibrator.h.

369{};

◆ m_maxres

float Calibrator::m_maxres {}
private

upper limit of 1D residual histogram

Definition at line 375 of file Calibrator.h.

375{};

◆ m_maxt

float Calibrator::m_maxt {}
private

upper limit of t in 2D rt histogram

Definition at line 371 of file Calibrator.h.

371{};

◆ m_maxtres

float Calibrator::m_maxtres {}
private

upper limit of 1D time residual histogram

Definition at line 373 of file Calibrator.h.

373{};

◆ m_minr

float Calibrator::m_minr {}
private

lower limit of r in 2D rt histogram

Definition at line 368 of file Calibrator.h.

368{};

◆ m_minres

float Calibrator::m_minres {}
private

lower limit of 1D residual histogram

Definition at line 374 of file Calibrator.h.

374{};

◆ m_minrtstat

int Calibrator::m_minrtstat {}
private

minimum number of hits in a sub-module required to do an R-t calibration

Definition at line 361 of file Calibrator.h.

361{};

◆ m_mint

float Calibrator::m_mint {}
private

lower limit of t in 2D rt histogram

Definition at line 370 of file Calibrator.h.

370{};

◆ m_mint0stat

int Calibrator::m_mint0stat {}
private

minimum number of hits in a sub-module required to do a t0 calibration

Definition at line 362 of file Calibrator.h.

362{};

◆ m_mintres

float Calibrator::m_mintres {}
private

lower limit of 1D time residual histogram

Definition at line 372 of file Calibrator.h.

372{};

◆ m_name

std::string Calibrator::m_name
private

The name of the Calibrator instance.

Definition at line 359 of file Calibrator.h.

◆ m_nbinsr

int Calibrator::m_nbinsr {}
private

number of r-bins in the 2D rt histogram

Definition at line 364 of file Calibrator.h.

364{};

◆ m_nbinsres

int Calibrator::m_nbinsres {}
private

number of bins in the 1D residual histogram

Definition at line 367 of file Calibrator.h.

367{};

◆ m_nbinst

int Calibrator::m_nbinst {}
private

number of t-bins in the 2D rt histogram

Definition at line 365 of file Calibrator.h.

365{};

◆ m_nbinstres

int Calibrator::m_nbinstres {}
private

number of bins in the 1D time residual histogram

Definition at line 366 of file Calibrator.h.

366{};

◆ m_nhits

int Calibrator::m_nhits {}
private

...

Definition at line 384 of file Calibrator.h.

384{};

◆ m_nreshits

int Calibrator::m_nreshits {}
private

...

Definition at line 382 of file Calibrator.h.

382{};

◆ m_nrthits

int Calibrator::m_nrthits {}
private

...

Definition at line 383 of file Calibrator.h.

383{};

◆ m_ntreshits

int Calibrator::m_ntreshits {}
private

...

Definition at line 381 of file Calibrator.h.

381{};

◆ m_resHists

std::map<std::string,TH1F*> Calibrator::m_resHists
private

...

Definition at line 377 of file Calibrator.h.

◆ m_rtbinning

std::string Calibrator::m_rtbinning
private

The direction to do the R-t binning.

Definition at line 360 of file Calibrator.h.

◆ m_rtgraphs

std::map<std::string,RtGraph*> Calibrator::m_rtgraphs {}
private

...

Definition at line 380 of file Calibrator.h.

◆ m_rtHists

std::map<std::string,TH2F*> Calibrator::m_rtHists
private

...

Definition at line 379 of file Calibrator.h.

◆ m_t0shift

float Calibrator::m_t0shift {}
private

the t0 shift

Definition at line 363 of file Calibrator.h.

363{};

◆ m_tresHists

std::map<std::string,TH1F*> Calibrator::m_tresHists
private

...

Definition at line 378 of file Calibrator.h.

◆ nort

bool Calibrator::nort {}

if true the old rt parameters are copied to the new ones

Definition at line 344 of file Calibrator.h.

344{};

◆ not0

bool Calibrator::not0 {}

if true the old t0 valus is copied to the new one

Definition at line 345 of file Calibrator.h.

345{};

◆ printlog

bool Calibrator::printlog {}

if true a log entry is prined for each sub-modile in this sub-level

Definition at line 348 of file Calibrator.h.

348{};

◆ printrt

bool Calibrator::printrt {}

if true an rt entry in the calibration output file is prined for each sub-module in this sub-level

Definition at line 350 of file Calibrator.h.

350{};

◆ printt0

bool Calibrator::printt0 {}

if true a t0 entry in the calibration output file is prined for each sub-module in this sub-level

Definition at line 349 of file Calibrator.h.

349{};

◆ selection

std::set<int> Calibrator::selection

a set containing the sub-modules to be calibrated

Definition at line 354 of file Calibrator.h.

◆ usebref

bool Calibrator::usebref {}

if true chip reference t0 values (offset from board mean) are used

Definition at line 346 of file Calibrator.h.

346{};

◆ usep0

bool Calibrator::usep0 {}

if true the 0th order coeficcient of the rt fit function is not set to 0 in the calibration output file

Definition at line 351 of file Calibrator.h.

351{};

◆ useshortstraws

bool Calibrator::useshortstraws {}

if true a shift of -0.75 ns is applied for straws in layer ==0, strawlayer < 9, and when doing calibration in a granuralyty different from chip or straw

Definition at line 353 of file Calibrator.h.

353{};

The documentation for this class was generated from the following files: