50 declareInterface<ITRTCalibrator>(
this);
62 return StatusCode::FAILURE;
66 return StatusCode::FAILURE;
70 return StatusCode::FAILURE;
74 return StatusCode::FAILURE;
78 return StatusCode::FAILURE;
86 return StatusCode::FAILURE;
119 m_config[
"all"].CalibrateRt.emplace_back(
"TRT") ;
120 m_config[
"all"].CalibrateT0.emplace_back(
"TRT") ;
121 m_config[
"all"].PrintLog.emplace_back(
"TRT") ;
122 m_config[
"all"].PrintT0Out.emplace_back(
"TRT") ;
123 m_config[
"all"].PrintRtOut.emplace_back(
"TRT") ;
126 m_config[
"subdet"].CalibrateRt.emplace_back(
"TRT") ;
127 m_config[
"subdet"].CalibrateRt.emplace_back(
"Detector") ;
129 m_config[
"subdet"].NoHistograms.emplace_back(
"TRT") ;
131 m_config[
"subdet"].PrintT0Out.emplace_back(
"Detector") ;
132 m_config[
"subdet"].PrintRtOut.emplace_back(
"Detector") ;
136 m_config[
"1"].selections[
"Detector"].insert(1);
143 m_config[
"-1"].selections[
"Detector"].insert(-1);
151 m_config[
"layer"].CalibrateRt.emplace_back(
"TRT") ;
152 m_config[
"layer"].CalibrateRt.emplace_back(
"Detector") ;
153 m_config[
"layer"].CalibrateRt.emplace_back(
"Layer") ;
154 m_config[
"layer"].CalibrateRt.emplace_back(
"Module") ;
155 m_config[
"layer"].CalibrateRt.emplace_back(
"Board") ;
156 m_config[
"layer"].CalibrateRt.emplace_back(
"Chip") ;
158 m_config[
"layer"].NoHistograms.emplace_back(
"TRT") ;
159 m_config[
"layer"].NoHistograms.emplace_back(
"Detector") ;
160 m_config[
"layer"].NoHistograms.emplace_back(
"Straw") ;
162 m_config[
"layer"].PrintT0Out.emplace_back(
"Layer") ;
163 m_config[
"layer"].PrintT0Out.emplace_back(
"Module") ;
164 m_config[
"layer"].PrintT0Out.emplace_back(
"Board") ;
165 m_config[
"layer"].PrintT0Out.emplace_back(
"Chip") ;
166 m_config[
"layer"].PrintT0Out.emplace_back(
"Straw") ;
167 m_config[
"layer"].PrintRtOut.emplace_back(
"Layer") ;
168 m_config[
"layer"].PrintRtOut.emplace_back(
"Module") ;
169 m_config[
"layer"].PrintRtOut.emplace_back(
"Board") ;
170 m_config[
"layer"].PrintRtOut.emplace_back(
"Chip") ;
171 m_config[
"layer"].PrintRtOut.emplace_back(
"Straw") ;
175 m_config[
"1_0"].selections[
"Detector"].insert(1);
176 m_config[
"1_0"].selections[
"Layer"].insert(0);
178 m_config[
"1_1"].selections[
"Detector"].insert(1);
179 m_config[
"1_1"].selections[
"Layer"].insert(1);
181 m_config[
"1_2"].selections[
"Detector"].insert(1);
182 m_config[
"1_2"].selections[
"Layer"].insert(2);
184 m_config[
"-1_0"].selections[
"Detector"].insert(-1);
185 m_config[
"-1_0"].selections[
"Layer"].insert(0);
187 m_config[
"-1_1"].selections[
"Detector"].insert(-1);
188 m_config[
"-1_1"].selections[
"Layer"].insert(1);
190 m_config[
"-1_2"].selections[
"Detector"].insert(-1);
191 m_config[
"-1_2"].selections[
"Layer"].insert(2);
193 return StatusCode::SUCCESS;
199 return StatusCode::SUCCESS;
207 for (
int i=0;
i<lev;
i++){
208 pat.replace(
pat.find(
'_'),1,
"");
209 sublev =
pat.substr(0,
pat.find(
'_'));
210 pat.replace(0,
pat.find(
'_'),
"");
217 std::map<std::string,int> strawmap;
222 std::string strawkey=std::string(Form(
"%i %i %i %i %i",
228 strawmap[strawkey]=isid;
234 std::string sl=sublev;
236 if (sl.compare(
SubLev(
key,lev))==0)
return true;
238 while(sl.compare(sl.substr(sl.find(
',')+1))!=0){
240 sl=sl.substr(sl.find(
',')+1);
251 if (sl.compare(
"-")==0) {
255 if (sl.compare(
"*")==0) {
260 if(sl.find(
',')!=std::string::npos){
262 while(sl.find(
',')!=std::string::npos){
263 sscanf(sl.substr(0,sl.find(
',')).data(),
"%i",&
value);
264 levels->insert(
value);
265 sl=sl.substr(sl.find(
',')+1);
267 sscanf(sl.data(),
"%i",&
value);
268 levels->insert(
value);
269 return levels->size();
272 if(sl.find(
't')!=std::string::npos){
274 sscanf(sl.substr(0,sl.find(
't')).data(),
"%i",&
min);
276 sl=sl.substr(sl.find(
't')+1);
277 sscanf(sl.data(),
"%i",&
max);
279 for (
int imod=
min; imod<=
max; imod++){
280 levels->insert(imod);
282 return levels->size();
286 sscanf(sl.data(),
"%i",&
value);
287 levels->insert(
value);
288 return levels->size();
316 int nTRThist=0, ndethist=0, nlayhist=0, nmodhist=0, nbrdhist=0, nchphist=0, nstwhist=0;
317 int nTRThistAr=0, ndethistAr=0, nlayhistAr=0, nmodhistAr=0, nbrdhistAr=0, nchphistAr=0, nstwhistAr=0;
320 std::string
infile=m_hittuple;
321 std::string
outfile=
"calibout";
323 std::string detname=
"Detector";
324 std::string layname=
"Layer";
325 if (!m_SplitBarrel) {
326 detname=
"WholeBarrel";
327 layname=
"WholeBarrelLayer";
331 Calibrator TRT(0,
"TRT",m_mint0,m_minrt,m_rtrel,m_rtbinning,m_t0offset);
333 Calibrator Layer(2,layname.data(),m_mint0,m_minrt,m_rtrel,m_rtbinning,m_t0offset);
334 Calibrator Module(3,
"Module",m_mint0,m_minrt,m_rtrel,m_rtbinning,m_t0offset);
335 Calibrator Board(4,
"Board",m_mint0,m_minrt,m_rtrel,m_rtbinning,m_t0offset);
336 Calibrator Chip(5,
"Chip",m_mint0,m_minrt,m_rtrel,m_rtbinning,m_t0offset);
337 Calibrator Straw(6,
"Straw",m_mint0,m_minrt,m_rtrel,m_rtbinning,m_t0offset);
341 std::map<std::string,Calibrator*> calibrators;
342 calibrators[
"TRT"]=&
TRT;
344 calibrators[
"Layer"]=&
Layer;
345 calibrators[
"Module"]=&Module;
346 calibrators[
"Board"]=&Board;
347 calibrators[
"Chip"]=&Chip;
348 calibrators[
"Straw"]=&
Straw;
351 if(m_calsub!=
"user"){
352 m_doRt=m_config[m_calsub].CalibrateRt;
353 m_doT0=m_config[m_calsub].CalibrateT0;
354 m_doRes=m_config[m_calsub].FitResidual;
355 m_beQuiet=m_config[m_calsub].NoHistograms;
356 m_doOutPrint=m_config[m_calsub].PrintT0Out;
357 m_doRtPrint=m_config[m_calsub].PrintRtOut;
358 m_doLogPrint=m_config[m_calsub].PrintLog;
362 for (
const std::string&
s : m_doRt) calibrators[
s]->dort=
true;
363 for (
const std::string&
s : m_doT0) calibrators[
s]->dot0=
true;
364 for (
const std::string&
s : m_doRes) calibrators[
s]->dores=
true;
365 for (
const std::string&
s : m_beQuiet) calibrators[
s]->bequiet=
true;
366 for (
const std::string&
s : m_doOutPrint) calibrators[
s]->printt0=
true;
367 for (
const std::string&
s : m_doRtPrint) calibrators[
s]->printrt=
true;
368 for (
const std::string&
s : m_doLogPrint) calibrators[
s]->printlog=
true;
369 for (
const std::string&
s : m_useBoardRef) calibrators[
s]->usebref=
true;
370 for (std::pair<const std::string, Calibrator*>&
p : calibrators) {
372 calib->usep0=m_useP0;
373 calib->floatp3=m_floatP3;
374 calib->useshortstraws=m_DoShortStrawCorrection;
376 if (m_doRt.size()==0)
calib->nort=
true;
377 if (m_doT0.size()==0)
calib->not0=
true;
379 std::set<int> selset;
380 GetSubLevels(m_selstring,
calib->level+1,&selset);
382 calib->selection = selset;
387 Calibrator TRT_Ar (0,
"TRT_Ar" ,m_mint0,m_minrt,m_rtrel,m_rtbinning,m_t0offset);
388 Calibrator Detector_Ar(1,
"Detector_Ar",m_mint0,m_minrt,m_rtrel,m_rtbinning,m_t0offset);
389 Calibrator Layer_Ar (2,
"Layer_Ar" ,m_mint0,m_minrt,m_rtrel,m_rtbinning,m_t0offset);
390 Calibrator Module_Ar (3,
"Module_Ar" ,m_mint0,m_minrt,m_rtrel,m_rtbinning,m_t0offset);
391 Calibrator Board_Ar (4,
"Board_Ar" ,m_mint0,m_minrt,m_rtrel,m_rtbinning,m_t0offset);
392 Calibrator Chip_Ar (5,
"Chip_Ar" ,m_mint0,m_minrt,m_rtrel,m_rtbinning,m_t0offset);
393 Calibrator Straw_Ar (6,
"Straw_Ar" ,m_mint0,m_minrt,m_rtrel,m_rtbinning,m_t0offset);
396 std::map<std::string,Calibrator*> calibratorsAr;
397 calibratorsAr[
"TRT"] =&TRT_Ar;
398 calibratorsAr[
"Detector"] =&Detector_Ar;
399 calibratorsAr[
"Layer"] =&Layer_Ar;
400 calibratorsAr[
"Module"] =&Module_Ar;
401 calibratorsAr[
"Board"] =&Board_Ar;
402 calibratorsAr[
"Chip"] =&Chip_Ar;
403 calibratorsAr[
"Straw"] =&Straw_Ar;
406 for (
const std::string&
s : m_doRt) calibratorsAr[
s]->dort=
true;
407 for (
const std::string&
s : m_doT0) calibratorsAr[
s]->dot0=
true;
408 for (
const std::string&
s : m_doRes) calibratorsAr[
s]->dores=
true;
409 for (
const std::string&
s : m_beQuiet) calibratorsAr[
s]->bequiet=
true;
410 for (
const std::string&
s : m_doOutPrint) calibratorsAr[
s]->printt0=
true;
411 for (
const std::string&
s : m_doRtPrint) calibratorsAr[
s]->printrt=
true;
412 for (
const std::string&
s : m_doLogPrint) calibratorsAr[
s]->printlog=
true;
413 for (
const std::string&
s : m_useBoardRef) calibratorsAr[
s]->usebref=
true;
414 for (std::pair<const std::string, Calibrator*>&
p : calibratorsAr) {
416 calib->usep0=m_useP0;
417 calib->floatp3=m_floatP3;
418 calib->useshortstraws=m_DoShortStrawCorrection;
420 if (m_doRt.size()==0)
calib->nort=
true;
421 if (m_doT0.size()==0)
calib->not0=
true;
423 std::set<int> selset;
424 GetSubLevels(m_selstring,
calib->level+1,&selset);
426 calib->selection = selset;
442 ATH_MSG_INFO(
"MIN STATISTICS : RT=" << m_minrt <<
", T0=" << m_mint0 );
463 ATH_MSG_INFO(
"MIN STATISTICS : RT=" << m_minrt <<
", T0=" << m_mint0 );
476 int rbrd, rchp, rdet, dum;
478 std::map<std::string,float> reft0map;
479 std::ifstream t0ref(
"finedelays.txt",std::ios::in);
480 if(t0ref.is_open())
ATH_MSG_INFO(
" Opened finedelays.txt ");
481 for(
int iref=0;iref<208;iref++){
482 t0ref >> rbrd >> rchp >> rdet >> dum >> rt0;
483 reft0map[std::string(Form(
"_%i_%i_%i",rdet,rbrd,rchp))]=rt0;
490 bool isdines = (m_rtrel.value()).
find(
"dines")!=std::string::npos;
491 bool isbinned = (m_rtrel.value()).
find(
"binned")!=std::string::npos;
493 if (isdines) rtint=2;
494 else if (isbinned) rtint=1;
499 std::map<std::string,epdata> ephasemap;
502 std::unique_ptr<TFile>
histfile(TFile::Open(
"calibout.root",
"RECREATE"));
511 std::ifstream
myFile (
infile.data(), std::ios::in | std::ios::binary);
519 myFile.read ((
char*)&npop,
sizeof(
int));
521 int* chist=
new int[2*npop+2];
522 if (npop>0)
myFile.read ((
char*)(chist+2),
sizeof(
int)*2*npop);
523 myFile.read ((
char*)&isid,
sizeof(
int));
532 m_neighbourSvc->getChip(
ident,chip);
533 if(abs(m_TRTID->barrel_ec(
ident))<2){
534 board=m_neighbourSvc->chipToBoardBarrel(chip,m_TRTID->layer_or_wheel(
ident));
543 if (m_SplitBarrel) hitdata.
det=(
int)m_TRTID->barrel_ec(
ident);
544 else hitdata.
det=abs((
int)m_TRTID->barrel_ec(
ident));
545 if(hitdata.
det!=1 && hitdata.
det!=-1 && hitdata.
det!=2 && hitdata.
det!=-2) {
550 if( (hitdata.
det==1 || hitdata.
det==-1) && (hitdata.
lay<0 || hitdata.
lay>2) ) {
553 }
else if( (hitdata.
det==2 || hitdata.
det==-2) && (hitdata.
lay<0 || hitdata.
lay>13) ) {
558 if( hitdata.
mod < 0 || hitdata.
mod > 31 ) {
566 if( hitdata.
stl < 0 || hitdata.
stl > m_TRTID->straw_layer_max(
ident) ) {
572 if( hitdata.
stw < 0 || hitdata.
stw > m_TRTID->straw_max(
ident) ) {
581 std::vector<float> rvalues ;
582 const float defaultpcal[] = {0,0,0,0} ;
585 pcal = rtr ? rtr->
cal() : defaultpcal ;
590 pcal = rtr ? rtr->
cal() : defaultpcal ;
592 hitdata.
rtpar[0]=pcal[0];
593 hitdata.
rtpar[1]=pcal[1];
594 hitdata.
rtpar[2]=pcal[2];
595 hitdata.
rtpar[3]=pcal[3];
599 MakeBDKeys(hitdata.
det, hitdata.
lay, hitdata.
mod, hitdata.
brd, hitdata.
chp, hitdata.
sid);
602 m_trt.t[m_Tkey].d[m_Dkey].l[m_Lkey].m[m_Mkey].b[m_Bkey].c[m_Ckey].s[m_Skey].z=0;
603 m_trt_acc.t[m_Tkey].d[m_Dkey_acc].l[m_Lkey_acc].m[m_Mkey].b[m_Bkey].c[m_Ckey].s[m_Skey].z=0;
614 hitdata.
t0=m_trtcaldbTool->getT0(
ident);
616 strawelement = m_trtmanager->getElement(
ident);
617 if(hitdata.
det==1 || hitdata.
det==-1) {
630 if ( m_DoShortStrawCorrection && hitdata.
lay==0 && hitdata.
stl<9){
632 double t0test1=m_trtcaldbTool->getT0((
Identifier)301998432);
633 double t0test2=m_trtcaldbTool->getT0((
Identifier)302001504);
634 if (t0test1 != t0test2) hitdata.
t0+=0.75;
638 hitdata.
rt0=reft0map[std::string(Form(
"_%i_%i_%i",hitdata.
det,hitdata.
brd,hitdata.
chp))];
641 int isArgonStraw = 0;
650 nTRThist +=
TRT.AddHit(m_Tkey,hitdata,chist,
true);
652 if (m_SplitBarrel) ndethist +=
Detector.AddHit(m_Dkey,hitdata,chist,
true);
653 else ndethist +=
Detector.AddHit(m_Dkey_acc,hitdata,chist,
true);
654 if (
Layer.CheckSelection(hitdata.
lay)) {
655 if (m_SplitBarrel) nlayhist +=
Layer.AddHit(m_Lkey,hitdata,chist,
true);
656 else { nlayhist +=
Layer.AddHit(m_Lkey_acc,hitdata,chist,
true);
continue;}
658 nmodhist += Module.
AddHit(m_Mkey,hitdata,chist,
true);
660 nbrdhist += Board.
AddHit(m_Bkey,hitdata,chist,
true);
662 nchphist += Chip.
AddHit(m_Ckey,hitdata,chist,
true);
663 if (
Straw.CheckSelection(hitdata.
stw))
664 nstwhist +=
Straw.AddHit(m_Skey,hitdata,chist,
true);
673 nTRThist +=
TRT.AddHit(m_Tkey,hitdata,chist,
true);
675 if (m_SplitBarrel) ndethist +=
Detector.AddHit(m_Dkey,hitdata,chist,
true);
676 else ndethist +=
Detector.AddHit(m_Dkey_acc,hitdata,chist,
true);
677 if (
Layer.CheckSelection(hitdata.
lay)) {
678 if (m_SplitBarrel) nlayhist +=
Layer.AddHit(m_Lkey,hitdata,chist,
true);
679 else { nlayhist +=
Layer.AddHit(m_Lkey_acc,hitdata,chist,
true);
continue;}
681 nmodhist += Module.
AddHit(m_Mkey,hitdata,chist,
true);
683 nbrdhist += Board.
AddHit(m_Bkey,hitdata,chist,
true);
685 nchphist += Chip.
AddHit(m_Ckey,hitdata,chist,
true);
686 if (
Straw.CheckSelection(hitdata.
stw)) {
687 nstwhist +=
Straw.AddHit(m_Skey,hitdata,chist,
true);
696 nTRThistAr += TRT_Ar.
AddHit(m_Tkey,hitdata,chist,
true);
698 if (m_SplitBarrel) ndethistAr += Detector_Ar.
AddHit(m_Dkey,hitdata,chist,
true);
699 else ndethistAr += Detector_Ar.
AddHit(m_Dkey_acc,hitdata,chist,
true);
701 if (m_SplitBarrel) nlayhistAr += Layer_Ar.
AddHit(m_Lkey,hitdata,chist,
true);
702 else { nlayhistAr += Layer_Ar.
AddHit(m_Lkey_acc,hitdata,chist,
true);
continue;}
704 nmodhistAr += Module_Ar.
AddHit(m_Mkey,hitdata,chist,
true);
706 nbrdhistAr += Board_Ar.
AddHit(m_Bkey,hitdata,chist,
true);
708 nchphistAr += Chip_Ar.
AddHit(m_Ckey,hitdata,chist,
true);
710 nstwhistAr += Straw_Ar.
AddHit(m_Skey,hitdata,chist,
true);
721 if ((ihist%10000==9999) | (ihist==m_nevents-1)){
722 ATH_MSG_INFO( Form(
"%7i HISTOGRAMS READ, UNITS ADDED: %i %i %2i %3i %3i %4i %6i",ihist+1,nTRThist, ndethist, nlayhist, nmodhist, nbrdhist, nchphist, nstwhist) );
723 if(m_DoArXenonSep)
ATH_MSG_INFO( Form(
"%7i Ar HISTOGRAMS READ, UNITS ADDED: %i %i %2i %3i %3i %4i %6i",ihistAr+1,nTRThistAr, ndethistAr, nlayhistAr, nmodhistAr, nbrdhistAr, nchphistAr, nstwhistAr) );
730 ATH_MSG_INFO( Form(
"%7i HISTOGRAMS READ, UNITS ADDED: %i %i %2i %3i %3i %4i %6i",ihist+1,nTRThist, ndethist, nlayhist, nmodhist, nbrdhist, nchphist, nstwhist) );
731 if(m_DoArXenonSep)
ATH_MSG_INFO( Form(
"%7i Ar HISTOGRAMS READ, UNITS ADDED: %i %i %2i %3i %3i %4i %6i",ihistAr+1,nTRThistAr, ndethistAr, nlayhistAr, nmodhistAr, nbrdhistAr, nchphistAr, nstwhistAr) );
733 TRT.UpdateOldConstants();
735 Layer.UpdateOldConstants();
778 caldata startdata(
true,55,100);
781 std::map<std::string,TDirectory*> dirmap;
796 for (std::pair<const std::string, BDdetector>&
pt : m_trt.t) {
798 if (
TRT.Skip())
break;
799 if (
TRT.HasKey(
pt.first)) {
800 trtdir =
TRT.Calibrate(
histfile.get(),
pt.first,SubLev(m_options,1),&startdata);
801 if (
TRT.printt0) t0calfile << Form(
"-3 -1 -1 -1 -1 : %e %e",
TRT.data[
pt.first].t0,
TRT.data[
pt.first].t0err) << std::endl;
802 if (
TRT.printrt) rtcalfile << Form(
"-3 -1 -1 -1 -1 : %i %e %e %e %e",rtint,
TRT.data[
pt.first].rtpar[0],
TRT.data[
pt.first].rtpar[1],
TRT.data[
pt.first].rtpar[2],
TRT.data[
pt.first].rtpar[3]) << std::endl;
804 for (std::pair<const std::string, BDlayer>&
pd :
pt.second.d) {
808 detdir =
Detector.Calibrate(trtdir,
pd.first,SubLev(m_options,2),&
TRT.data[
pt.first]);
810 for (std::pair<const std::string, BDmodule>& pl :
pd.second.l) {
812 if(
Layer.Skip())
break;
813 if(
Layer.HasKey(pl.first)){
814 laydir =
Layer.Calibrate(detdir,pl.first,SubLev(m_options,3),&
Detector.data[
pd.first]);
815 if (
Layer.printt0) t0calfile << Form(
"%i %i -1 -1 -1 : %e %e",
Layer.data[pl.first].det,
Layer.data[pl.first].lay,
Layer.data[pl.first].t0,
Layer.data[pl.first].t0err) << std::endl;
816 if (
Layer.printrt) rtcalfile << Form(
"%i %i -1 -1 -1 : %i %e %e %e %e",
Layer.data[pl.first].det,
Layer.data[pl.first].lay,rtint,
Layer.data[pl.first].rtpar[0],
Layer.data[pl.first].rtpar[1],
Layer.data[pl.first].rtpar[2],
Layer.data[pl.first].rtpar[3]) << std::endl;
817 if (!m_SplitBarrel) {
818 if (
Layer.printt0) t0calfile << Form(
"%i %i -1 -1 -1 : %e %e",-
Layer.data[pl.first].det,
Layer.data[pl.first].lay,
Layer.data[pl.first].t0,
Layer.data[pl.first].t0err) << std::endl;
819 if (
Layer.printrt) rtcalfile << Form(
"%i %i -1 -1 -1 : %i %e %e %e %e",-
Layer.data[pl.first].det,
Layer.data[pl.first].lay,rtint,
Layer.data[pl.first].rtpar[0],
Layer.data[pl.first].rtpar[1],
Layer.data[pl.first].rtpar[2],
Layer.data[pl.first].rtpar[3]) << std::endl;
822 for (std::pair<const std::string, BDboard>& pm : pl.second.m) {
824 if(Module.
Skip())
break;
825 if(Module.
HasKey(pm.first)){
826 moddir = Module.Calibrate(laydir,pm.first,SubLev(m_options,4),&
Layer.data[pl.first]);
827 if (Module.
printt0) t0calfile << Form(
"%i %i %i -1 -1 : %e %e",Module.
data[pm.first].det,Module.
data[pm.first].lay,Module.
data[pm.first].mod,Module.
data[pm.first].t0,Module.
data[pm.first].t0err) << std::endl;
828 if (Module.
printrt) rtcalfile << Form(
"%i %i %i -1 -1 : %i %e %e %e %e",Module.
data[pm.first].det,Module.
data[pm.first].lay,Module.
data[pm.first].mod,rtint,Module.
data[pm.first].rtpar[0],Module.
data[pm.first].rtpar[1],Module.
data[pm.first].rtpar[2],Module.
data[pm.first].rtpar[3]) << std::endl;
830 for (std::pair<const std::string, BDchip>&
pb : pm.second.b) {
832 if(Board.
Skip())
break;
834 brddir = Board.Calibrate(moddir,
pb.first,SubLev(m_options,5),&Module.
data[pm.first]);
836 for (std::pair<const std::string, BDstraw>&
pc :
pb.second.c) {
838 if(Chip.
Skip())
break;
840 chpdir = Chip.Calibrate(brddir,
pc.first,SubLev(m_options,6),&Board.
data[
pb.first]);
842 for (std::pair<const std::string, BDzero>& ps :
pc.second.s) {
844 if(
Straw.Skip())
break;
845 if(
Straw.HasKey(ps.first)){
846 Straw.Calibrate(chpdir,ps.first,SubLev(m_options,7),&Chip.
data[
pc.first]);
847 if (
Straw.printt0) t0calfile << Form(
"%i %i %i %i %i : %e %e",
Straw.data[ps.first].det,
Straw.data[ps.first].lay,
Straw.data[ps.first].mod,
Straw.data[ps.first].stl,
Straw.data[ps.first].stw,
Straw.data[ps.first].t0,
Straw.data[ps.first].t0err) << std::endl;
848 if (
Straw.printrt) rtcalfile << Form(
"%i %i %i %i %i : %i %e %e %e %e",
Straw.data[ps.first].det,
Straw.data[ps.first].lay,
Straw.data[ps.first].mod,
Straw.data[ps.first].stl,
Straw.data[ps.first].stw,rtint,
Straw.data[ps.first].rtpar[0],
Straw.data[ps.first].rtpar[1],
Straw.data[ps.first].rtpar[2],
Straw.data[ps.first].rtpar[3]) << std::endl;
860 std::map<std::string,TDirectory*> dirArmap;
870 for (std::pair<const std::string, BDdetector>&
pt : m_trt.t) {
872 if (TRT_Ar.
Skip())
break;
874 trtdirAr = TRT_Ar.Calibrate(
histfile.get(),
pt.first,SubLev(m_options,1),&startdata);
876 for (std::pair<const std::string, BDlayer>&
pd :
pt.second.d) {
878 if(Detector_Ar.
Skip())
break;
880 detdirAr = Detector_Ar.Calibrate(trtdirAr,
pd.first,SubLev(m_options,2),&TRT_Ar.
data[
pt.first]);
882 for (std::pair<const std::string, BDmodule>& pl :
pd.second.l) {
884 if(Layer_Ar.
Skip())
break;
885 if(Layer_Ar.
HasKey(pl.first)){
886 laydirAr = Layer_Ar.Calibrate(detdirAr,pl.first,SubLev(m_options,3),&Detector_Ar.
data[
pd.first]);
889 for (std::pair<const std::string, BDboard>& pm : pl.second.m) {
891 if(Module_Ar.
Skip())
break;
892 if(Module_Ar.
HasKey(pm.first)){
893 moddirAr = Module_Ar.Calibrate(laydirAr,pm.first,SubLev(m_options,4),&Layer_Ar.
data[pl.first]);
894 if (Module_Ar.
printt0) t0calfile << Form(
"%i %i %i -1 -1 : %e %e",Module_Ar.
data[pm.first].det,Module_Ar.
data[pm.first].lay,Module_Ar.
data[pm.first].mod,Module_Ar.
data[pm.first].t0,Module_Ar.
data[pm.first].t0err) << std::endl;
895 if (Layer_Ar.
printrt) rtcalfile << Form(
"%i %i %i -1 -1 : %i %e %e %e %e",Module_Ar.
data[pm.first].det,Module_Ar.
data[pm.first].lay,Module_Ar.
data[pm.first].mod,rtint,Module_Ar.
data[pm.first].rtpar[0],Module_Ar.
data[pm.first].rtpar[1],Module_Ar.
data[pm.first].rtpar[2],Module_Ar.
data[pm.first].rtpar[3]) << std::endl;
897 for (std::pair<const std::string, BDchip>&
pb : pm.second.b) {
898 if(Board_Ar.
Skip())
break;
900 brddirAr = Board_Ar.Calibrate(moddirAr,
pb.first,SubLev(m_options,5),&Module_Ar.
data[pm.first]);
902 for (std::pair<const std::string, BDstraw>&
pc :
pb.second.c) {
904 if(Chip_Ar.
Skip())
break;
906 chpdirAr = Chip_Ar.Calibrate(brddirAr,
pc.first,SubLev(m_options,6),&Board_Ar.
data[
pb.first]);
908 for (std::pair<const std::string, BDzero>& ps :
pc.second.s) {
910 if(Straw_Ar.
Skip())
break;
911 if(Straw_Ar.
HasKey(ps.first)){
912 Straw_Ar.Calibrate(chpdirAr,ps.first,SubLev(m_options,7),&Chip_Ar.
data[
pc.first]);
913 if (Straw_Ar.
printt0) t0calfile << Form(
"%i %i %i %i %i : %e %e",Straw_Ar.
data[ps.first].det,Straw_Ar.
data[ps.first].lay,Straw_Ar.
data[ps.first].mod,Straw_Ar.
data[ps.first].stl,Straw_Ar.
data[ps.first].stw,Straw_Ar.
data[ps.first].t0,Straw_Ar.
data[ps.first].t0err) << std::endl;
914 if (Straw_Ar.
printrt) rtcalfile << Form(
"%i %i %i %i %i : %i %e %e %e %e",Straw_Ar.
data[ps.first].det,Straw_Ar.
data[ps.first].lay,Straw_Ar.
data[ps.first].mod,Straw_Ar.
data[ps.first].stl,Straw_Ar.
data[ps.first].stw,rtint,Straw_Ar.
data[ps.first].rtpar[0],Straw_Ar.
data[ps.first].rtpar[1],Straw_Ar.
data[ps.first].rtpar[2],Straw_Ar.
data[ps.first].rtpar[3]) << std::endl;
940 Layer.DumpConstants();
944 Straw.DumpConstants();
947 binrtcalfile.close();
979 if (aTrack==
nullptr) {};