10 #include <klm/calibration/KLMTimeAlgorithm.h>
13 #include <klm/dataobjects/bklm/BKLMElementNumbers.h>
16 #include <framework/database/Database.h>
17 #include <framework/database/DBObjPtr.h>
18 #include <framework/database/DBStore.h>
19 #include <framework/dataobjects/EventMetaData.h>
20 #include <framework/gearbox/Const.h>
21 #include <framework/logging/Logger.h>
24 #include <Math/MinimizerOptions.h>
26 #include <TFitResult.h>
34 using namespace ROOT::Math;
37 const int c_NBinsTime = 100;
40 const int c_NBinsDistance = 100;
43 static double s_BinnedData[c_NBinsTime][c_NBinsDistance];
46 static double s_LowerTimeBoundary = 0;
49 static double s_UpperTimeBoundary = 0;
52 static double s_StripLength = 0;
54 static bool compareEventNumber(
const std::pair<KLMChannelNumber, unsigned int>& pair1,
55 const std::pair<KLMChannelNumber, unsigned int>& pair2)
57 return pair1.second < pair2.second;
60 static double timeDensity(
double x[2],
double* par)
62 double polynomial, t0, gauss;
64 t0 = par[2] + par[4] * x[1];
65 gauss = par[1] / (sqrt(2.0 * M_PI) * par[3]) *
66 exp(-0.5 * pow((x[0] - t0) / par[3], 2));
67 return fabs(polynomial + gauss);
70 static void fcn(
int& npar,
double* grad,
double& fval,
double* par,
int iflag)
77 for (
int i = 0; i < c_NBinsTime; ++i) {
78 x[0] = s_LowerTimeBoundary +
79 (s_UpperTimeBoundary - s_LowerTimeBoundary) *
80 (
double(i) + 0.5) / c_NBinsTime;
81 for (
int j = 0; j < c_NBinsDistance; ++j) {
82 x[1] = s_StripLength * (double(j) + 0.5) / c_NBinsDistance;
83 double f = timeDensity(x, par);
84 if (s_BinnedData[i][j] == 0)
85 fval = fval + 2.0 * f;
87 fval = fval + 2.0 * (f - s_BinnedData[i][j] *
88 (1.0 - log(s_BinnedData[i][j] / f)));
106 const std::vector<Calibration::ExpRun>& runs =
getRunList();
107 int firstExperiment = runs[0].first;
108 int lastExperiment = runs[runs.size() - 1].first;
109 if (firstExperiment != lastExperiment) {
110 B2FATAL(
"Runs from different experiments are used "
111 "for KLM time calibration (single algorithm run).");
120 if (eventMetaData->getExperiment() != firstExperiment) {
121 B2FATAL(
"Runs from different experiments are used "
122 "for KLM time calibration (consecutive algorithm runs).");
124 eventMetaData->setExperiment(firstExperiment);
125 eventMetaData->setRun(runs[0].second);
127 eventMetaData.
construct(1, runs[0].second, firstExperiment);
143 B2INFO(
"Read tree entries and seprate events by module id.");
145 std::shared_ptr<TTree> timeCalibrationData;
146 timeCalibrationData = getObjectPtr<TTree>(
"time_calibration_data");
147 timeCalibrationData->SetBranchAddress(
"t0", &event.t0);
148 timeCalibrationData->SetBranchAddress(
"flyTime", &event.flyTime);
149 timeCalibrationData->SetBranchAddress(
"recTime", &event.recTime);
150 timeCalibrationData->SetBranchAddress(
"dist", &event.dist);
151 timeCalibrationData->SetBranchAddress(
"diffDistX", &event.diffDistX);
152 timeCalibrationData->SetBranchAddress(
"diffDistY", &event.diffDistY);
153 timeCalibrationData->SetBranchAddress(
"diffDistZ", &event.diffDistZ);
154 timeCalibrationData->SetBranchAddress(
"eDep", &event.eDep);
155 timeCalibrationData->SetBranchAddress(
"nPE", &event.nPE);
156 timeCalibrationData->SetBranchAddress(
"channelId", &event.channelId);
157 timeCalibrationData->SetBranchAddress(
"inRPC", &event.inRPC);
158 timeCalibrationData->SetBranchAddress(
"isFlipped", &event.isFlipped);
160 B2INFO(
LogVar(
"Total number of digits:", timeCalibrationData->GetEntries()));
163 int n = timeCalibrationData->GetEntries();
166 for (
int i = 0; i < n; ++i) {
167 timeCalibrationData->GetEntry(i);
168 m_evts[
event.channelId].push_back(event);
170 B2INFO(
"Events packing finish.");
192 int nBin_scint = 400;
194 TString iFstring[2] = {
"Backward",
"Forward"};
195 TString iPstring[2] = {
"ZReadout",
"PhiReadout"};
198 h_diff =
new TH1F(
"h_diff",
"Position difference between bklmHit2d and extHit;position difference", 100, 0, 10);
199 h_calibrated =
new TH1I(
"h_calibrated_summary",
"h_calibrated_summary;calibrated or not", 3, 0, 3);
209 double maximalPhiStripLengthBKLM =
211 double maximalZStripLengthBKLM =
213 double maximalStripLengthEKLM =
217 "Time over propagation length for RPCs (Phi_Readout); propagation distance[cm]; T_rec-T_0-T_fly-'T_calibration'[ns]", 400, 0.0,
220 "Time over propagation length for RPCs (Z_Readout); propagation distance[cm]; T_rec-T_0-T_fly-'T_calibration'[ns]", 400, 0.0,
223 "Time over propagation length for scintillators (Phi_Readout); propagation distance[cm]; T_rec-T_0-T_fly-'T_calibration'[ns]",
224 200, 0.0, maximalPhiStripLengthBKLM);
226 "Time over propagation length for scintillators (Z_Readout); propagation distance[cm]; T_rec-T_0-T_fly-'T_calibration'[ns]",
227 200, 0.0, maximalZStripLengthBKLM);
229 "Time over propagation length for scintillators (plane1, Endcap); propagation distance[cm]; T_rec-T_0-T_fly-'T_calibration'[ns]",
230 200, 0.0, maximalStripLengthEKLM);
232 "Time over propagation length for scintillators (plane2, Endcap); propagation distance[cm]; T_rec-T_0-T_fly-'T_calibration'[ns]",
233 200, 0.0, maximalStripLengthEKLM);
236 "Time over propagation length for RPCs (Phi_Readout); propagation distance[cm]; T_rec-T_0-T_fly-'T_calibration'[ns]", 400, 0.0,
239 "Time over propagation length for RPCs (Z_Readout); propagation distance[cm]; T_rec-T_0-T_fly-'T_calibration'[ns]", 400, 0.0,
242 "Time over propagation length for scintillators (Phi_Readout); propagation distance[cm]; T_rec-T_0-T_fly-'T_calibration'[ns]",
243 200, 0.0, maximalPhiStripLengthBKLM);
245 "Time over propagation length for scintillators (Z_Readout); propagation distance[cm]; T_rec-T_0-T_fly-'T_calibration'[ns]",
246 200, 0.0, maximalZStripLengthBKLM);
248 "Time over propagation length for scintillators (plane1, Endcap); propagation distance[cm]; T_rec-T_0-T_fly-'T_calibration'[ns]",
249 200, 0.0, maximalStripLengthEKLM);
251 "Time over propagation length for scintillators (plane2, Endcap); propagation distance[cm]; T_rec-T_0-T_fly-'T_calibration'[ns]",
252 200, 0.0, maximalStripLengthEKLM);
255 h_time_scint_tc =
new TH1F(
"h_time_scint_tc",
"time distribtution for Scintillator", nBin_scint,
257 h_time_scint_tc_end =
new TH1F(
"h_time_scint_tc_end",
"time distribtution for Scintillator (Endcap)", nBin_scint,
264 h_time_scint =
new TH1F(
"h_time_scint",
"time distribtution for Scintillator; T_rec-T_0-T_fly-T_propagation[ns]", nBin_scint,
266 h_time_scint_end =
new TH1F(
"h_time_scint_end",
"time distribtution for Scintillator (Endcap); T_rec-T_0-T_fly-T_propagation[ns]",
269 hc_time_rpc =
new TH1F(
"hc_time_rpc",
"Calibrated time distribtution for RPC; T_rec-T_0-T_fly-T_propagation-T_calibration[ns]",
272 "Calibrated time distribtution for Scintillator; T_rec-T_0-T_fly-T_propagation-T_calibration[ns]", nBin_scint,
276 "Calibrated time distribtution for Scintillator (Endcap); T_rec-T_0-T_fly-T_propagation-T_calibration[ns]", nBin_scint,
279 for (
int iF = 0; iF < 2; ++iF) {
280 hn = Form(
"h_timeF%d_rpc", iF);
281 ht = Form(
"Time distribtution for RPC of %s; T_rec-T_0-T_fly-T_propagation[ns]", iFstring[iF].Data());
283 hn = Form(
"h_timeF%d_scint", iF);
284 ht = Form(
"Time distribtution for Scintillator of %s; T_rec-T_0-T_fly-T_propagation[ns]", iFstring[iF].Data());
287 hn = Form(
"h_timeF%d_scint_end", iF);
288 ht = Form(
"Time distribtution for Scintillator of %s (Endcap); T_rec-T_0-T_fly-T_propagation[ns]", iFstring[iF].Data());
292 hn = Form(
"h2_timeF%d_rpc", iF);
293 ht = Form(
"Time distribtution for RPC of %s; Sector Index; T_rec-T_0-T_fly-T_propagation[ns]", iFstring[iF].Data());
295 hn = Form(
"h2_timeF%d_scint", iF);
296 ht = Form(
"Time distribtution for Scintillator of %s; Sector Index; T_rec-T_0-T_fly-T_propagation[ns]", iFstring[iF].Data());
299 hn = Form(
"h2_timeF%d_scint_end", iF);
300 ht = Form(
"Time distribtution for Scintillator of %s (Endcap); Sector Index; T_rec-T_0-T_fly-T_propagation[ns]",
301 iFstring[iF].Data());
305 hn = Form(
"hc_timeF%d_rpc", iF);
306 ht = Form(
"Calibrated time distribtution for RPC of %s; T_rec-T_0-T_fly-T_propagation-T_calibration[ns]", iFstring[iF].Data());
308 hn = Form(
"hc_timeF%d_scint", iF);
309 ht = Form(
"Calibrated time distribtution for Scintillator of %s; T_rec-T_0-T_fly-T_propagation-T_calibration[ns]",
310 iFstring[iF].Data());
313 hn = Form(
"hc_timeF%d_scint_end", iF);
314 ht = Form(
"Calibrated time distribtution for Scintillator of %s (Endcap); T_rec-T_0-T_fly-T_propagation-T_calibration[ns]",
315 iFstring[iF].Data());
319 hn = Form(
"h2c_timeF%d_rpc", iF);
320 ht = Form(
"Calibrated time distribtution for RPC of %s; Sector Index; T_rec-T_0-T_fly-T_propagation-T_calibration[ns]",
321 iFstring[iF].Data());
324 hn = Form(
"h2c_timeF%d_scint", iF);
325 ht = Form(
"Calibrated time distribtution for Scintillator of %s; Sector Index; T_rec-T_0-T_fly-T_propagation-T_calibration[ns]",
326 iFstring[iF].Data());
329 hn = Form(
"h2c_timeF%d_scint_end", iF);
330 ht = Form(
"Calibrated time distribtution for Scintillator of %s (Endcap) ; Sector Index; T_rec-T_0-T_fly-T_propagation-T_calibration[ns]",
331 iFstring[iF].Data());
335 for (
int iS = 0; iS < 8; ++iS) {
337 hn = Form(
"h_timeF%d_S%d_scint", iF, iS);
338 ht = Form(
"Time distribtution for Scintillator of Sector%d, %s; T_rec-T_0-T_fly-T_propagation[ns]", iS, iFstring[iF].Data());
341 hn = Form(
"h_timeF%d_S%d_rpc", iF, iS);
342 ht = Form(
"Time distribtution for RPC of Sector%d, %s; T_rec-T_0-T_fly-T_propagation[ns]", iS, iFstring[iF].Data());
344 hn = Form(
"h2_timeF%d_S%d", iF, iS);
345 ht = Form(
"Time distribtution of Sector%d, %s; Layer Index; T_rec-T_0-T_fly-T_propagation[ns]", iS, iFstring[iF].Data());
349 hn = Form(
"hc_timeF%d_S%d_scint", iF, iS);
350 ht = Form(
"Calibrated time distribtution for Scintillator of Sector%d, %s; T_rec-T_0-T_fly-T_propagation-T_calibration[ns]", iS,
351 iFstring[iF].Data());
354 hn = Form(
"hc_timeF%d_S%d_rpc", iF, iS);
355 ht = Form(
"Calibrated time distribtution for RPC of Sector%d, %s; T_rec-T_0-T_fly-T_propagation-T_calibration[ns]", iS,
356 iFstring[iF].Data());
359 hn = Form(
"h2c_timeF%d_S%d", iF, iS);
360 ht = Form(
"Calibrated time distribtution of Sector%d, %s; Layer Index; T_rec-T_0-T_fly-T_propagation-T_calibration[ns]", iS,
361 iFstring[iF].Data());
366 for (
int iL = 0; iL < 2; ++iL) {
367 hn = Form(
"h_timeF%d_S%d_L%d", iF, iS, iL);
368 ht = Form(
"Time distribtution for Scintillator of Layer%d, Sector%d, %s; T_rec-T_0-T_fly-T_propagation[ns]", iL, iS,
369 iFstring[iF].Data());
372 hn = Form(
"hc_timeF%d_S%d_L%d", iF, iS, iL);
373 ht = Form(
"Calibrated time distribtution for Scintillator of Layer%d, Sector%d, %s; T_rec-T_0-T_fly-T_propagation-T_calibration[ns]",
374 iL, iS, iFstring[iF].Data());
378 for (
int iP = 0; iP < 2; ++iP) {
379 hn = Form(
"h_timeF%d_S%d_L%d_P%d", iF, iS, iL, iP);
380 ht = Form(
"Time distribtution for Scintillator of %s, Layer%d, Sector%d, %s; T_rec-T_0-T_fly-T_propagation[ns]",
381 iPstring[iP].Data(), iL, iS, iFstring[iF].Data());
384 hn = Form(
"h2_timeF%d_S%d_L%d_P%d", iF, iS, iL, iP);
385 ht = Form(
"Time distribtution for Scintillator of %s, Layer%d, Sector%d, %s; Channel Index; T_rec-T_0-T_fly-T_propagation[ns]",
386 iPstring[iP].Data(), iL, iS, iFstring[iF].Data());
390 hn = Form(
"hc_timeF%d_S%d_L%d_P%d", iF, iS, iL, iP);
391 ht = Form(
"Calibrated time distribtution for Scintillator of %s, Layer%d, Sector%d, %s; T_rec-T_0-T_fly-T_propagation-T_calibration[ns]",
392 iPstring[iP].Data(), iL, iS, iFstring[iF].Data());
395 hn = Form(
"h2c_timeF%d_S%d_L%d_P%d", iF, iS, iL, iP);
396 ht = Form(
"Calibrated time distribtution for Scintillator of %s, Layer%d, Sector%d, %s; Channel Index; T_rec-T_0-T_fly-T_propagation-T_calibration[ns]",
397 iPstring[iP].Data(), iL, iS, iFstring[iF].Data());
402 for (
int iC = 0; iC < nchannel_max; ++iC) {
403 hn = Form(
"h_timeF%d_S%d_L%d_P%d_C%d_tc", iF, iS, iL, iP, iC);
404 ht = Form(
"time distribtution for Scintillator of Channel%d, %s, Layer%d, Sector%d, %s; T_rec-T_0-T_fly-T_propagation[ns]", iC,
405 iPstring[iP].Data(), iL, iS, iFstring[iF].Data());
409 hn = Form(
"h_timeF%d_S%d_L%d_P%d_C%d", iF, iS, iL, iP, iC);
410 ht = Form(
"time distribtution for Scintillator of Channel%d, %s, Layer%d, Sector%d, %s; T_rec-T_0-T_fly-T_propagation[ns]", iC,
411 iPstring[iP].Data(), iL, iS, iFstring[iF].Data());
415 hn = Form(
"hc_timeF%d_S%d_L%d_P%d_C%d", iF, iS, iL, iP, iC);
416 ht = Form(
"Calibrated time distribtution for Scintillator of Channel%d, %s, Layer%d, Sector%d, %s; T_rec-T_0-T_fly-T_propagation-T_calibration[ns]",
417 iC, iPstring[iP].Data(), iL, iS, iFstring[iF].Data());
420 hn = Form(
"time_length_bklm_F%d_S%d_L%d_P%d_C%d", iF, iS, iL, iP, iC);
421 double stripLength = 200;
424 "Time versus propagation length; "
425 "propagation distance[cm]; "
426 "T_rec-T_0-T_fly-'T_calibration'[ns]",
427 200, 0.0, stripLength,
434 for (
int iL = 2; iL < 15; ++iL) {
435 hn = Form(
"h_timeF%d_S%d_L%d", iF, iS, iL);
436 ht = Form(
"time distribtution for RPC of Layer%d, Sector%d, %s; T_rec-T_0-T_fly-T_propagation[ns]", iL, iS, iFstring[iF].Data());
439 hn = Form(
"hc_timeF%d_S%d_L%d", iF, iS, iL);
440 ht = Form(
"Calibrated time distribtution for RPC of Layer%d, Sector%d, %s; T_rec-T_0-T_fly-T_propagation-T_calibration[ns]", iL, iS,
441 iFstring[iF].Data());
444 for (
int iP = 0; iP < 2; ++iP) {
445 hn = Form(
"h_timeF%d_S%d_L%d_P%d", iF, iS, iL, iP);
446 ht = Form(
"time distribtution for RPC of %s, Layer%d, Sector%d, %s; T_rec-T_0-T_fly-T_propagation[ns]", iPstring[iP].Data(), iL, iS,
447 iFstring[iF].Data());
450 hn = Form(
"h2_timeF%d_S%d_L%d_P%d", iF, iS, iL, iP);
451 ht = Form(
"time distribtution for RPC of %s, Layer%d, Sector%d, %s; Channel Index; T_rec-T_0-T_fly-T_propagation[ns]",
452 iPstring[iP].Data(), iL, iS, iFstring[iF].Data());
455 hn = Form(
"hc_timeF%d_S%d_L%d_P%d", iF, iS, iL, iP);
456 ht = Form(
"Calibrated time distribtution for RPC of %s, Layer%d, Sector%d, %s; T_rec-T_0-T_fly-T_propagation-T_calibration[ns]",
457 iPstring[iP].Data(), iL, iS, iFstring[iF].Data());
461 hn = Form(
"h2c_timeF%d_S%d_L%d_P%d", iF, iS, iL, iP);
462 ht = Form(
"Calibrated time distribtution for RPC of %s, Layer%d, Sector%d, %s; Channel Index; T_rec-T_0-T_fly-T_propagation-T_calibration[ns]",
463 iPstring[iP].Data(), iL, iS, iFstring[iF].Data());
468 for (
int iC = 0; iC < nchannel_max; ++iC) {
469 hn = Form(
"h_timeF%d_S%d_L%d_P%d_C%d_tc", iF, iS, iL, iP, iC);
470 ht = Form(
"Time distribtution for RPC of Channel%d, %s, Layer%d, Sector%d, %s; T_rec-T_0-T_fly-T_propagation[ns]", iC,
471 iPstring[iP].Data(), iL, iS, iFstring[iF].Data());
474 hn = Form(
"h_timeF%d_S%d_L%d_P%d_C%d", iF, iS, iL, iP, iC);
475 ht = Form(
"Time distribtution for RPC of Channel%d, %s, Layer%d, Sector%d, %s; T_rec-T_0-T_fly-T_propagation[ns]", iC,
476 iPstring[iP].Data(), iL, iS, iFstring[iF].Data());
479 hn = Form(
"hc_timeF%d_S%d_L%d_P%d_C%d", iF, iS, iL, iP, iC);
480 ht = Form(
"Calibrated time distribtution for RPC of Channel%d, %s, Layer%d, Sector%d, %s; T_rec-T_0-T_fly-T_propagation-T_calibration[ns]",
481 iC, iPstring[iP].Data(), iL, iS, iFstring[iF].Data());
489 int maxLay = 12 + 2 * iF;
490 for (
int iS = 0; iS < 4; ++iS) {
491 hn = Form(
"h_timeF%d_S%d_scint_end", iF, iS);
492 ht = Form(
"Time distribtution for Scintillator of Sector%d, %s (Endcap); T_rec-T_0-T_fly-T_propagation[ns]", iS,
493 iFstring[iF].Data());
496 hn = Form(
"h2_timeF%d_S%d_end", iF, iS);
497 ht = Form(
"Time distribtution of Sector%d, %s (Endcap); Layer Index; T_rec-T_0-T_fly-T_propagation[ns]", iS, iFstring[iF].Data());
500 hn = Form(
"hc_timeF%d_S%d_scint_end", iF, iS);
501 ht = Form(
"Calibrated time distribtution for Scintillator of Sector%d (Endcap), %s; T_rec-T_0-T_fly-T_propagation-T_calibration[ns]",
502 iS, iFstring[iF].Data());
505 hn = Form(
"h2c_timeF%d_S%d_end", iF, iS);
506 ht = Form(
"Calibrated time distribtution of Sector%d, %s (Endcap); Layer Index; T_rec-T_0-T_fly-T_propagation-T_calibration[ns]",
507 iS, iFstring[iF].Data());
508 h2c_timeFS_end[iF][iS] =
new TH2F(hn.Data(), ht.Data(), maxLay, 0, maxLay, nBin_scint,
512 for (
int iL = 0; iL < maxLay; ++iL) {
513 hn = Form(
"h_timeF%d_S%d_L%d_end", iF, iS, iL);
514 ht = Form(
"Time distribtution for Scintillator of Layer%d, Sector%d, %s (Endcap); T_rec-T_0-T_fly-T_propagation[ns]", iL, iS,
515 iFstring[iF].Data());
518 hn = Form(
"hc_timeF%d_S%d_L%d_end", iF, iS, iL);
519 ht = Form(
"Calibrated time distribtution for Scintillator of Layer%d, Sector%d, %s (Endcap); T_rec-T_0-T_fly-T_propagation-T_calibration[ns]",
520 iL, iS, iFstring[iF].Data());
524 for (
int iP = 0; iP < 2; ++iP) {
525 hn = Form(
"h_timeF%d_S%d_L%d_P%d_end", iF, iS, iL, iP);
526 ht = Form(
"Time distribtution for Scintillator of %s, Layer%d, Sector%d, %s (Endcap); T_rec-T_0-T_fly-T_propagation[ns]",
527 iPstring[iP].Data(), iL, iS, iFstring[iF].Data());
531 hn = Form(
"h2_timeF%d_S%d_L%d_P%d_end", iF, iS, iL, iP);
532 ht = Form(
"Time distribtution for Scintillator of %s, Layer%d, Sector%d, %s (Endcap); Channel Index; T_rec-T_0-T_fly-T_propagation[ns]",
533 iPstring[iP].Data(), iL, iS, iFstring[iF].Data());
537 hn = Form(
"hc_timeF%d_S%d_L%d_P%d_end", iF, iS, iL, iP);
538 ht = Form(
"Calibrated time distribtution for Scintillator of %s, Layer%d, Sector%d, %s (Endcap); T_rec-T_0-T_fly-T_propagation-T_calibration[ns]",
539 iPstring[iP].Data(), iL, iS, iFstring[iF].Data());
543 hn = Form(
"h2c_timeF%d_S%d_L%d_P%d_end", iF, iS, iL, iP);
544 ht = Form(
"Calibrated time distribtution for Scintillator of %s, Layer%d, Sector%d, %s (Endcap); Channel Index; T_rec-T_0-T_fly-T_propagation-T_calibration[ns]",
545 iPstring[iP].Data(), iL, iS, iFstring[iF].Data());
546 h2c_timeFSLP_end[iF][iS][iL][iP] =
new TH2F(hn.Data(), ht.Data(), 75, 0, 75, nBin_scint,
550 for (
int iC = 0; iC < 75; ++iC) {
551 hn = Form(
"h_timeF%d_S%d_L%d_P%d_C%d_tc_end", iF, iS, iL, iP, iC);
552 ht = Form(
"Time distribtution for Scintillator of Channel%d, %s, Layer%d, Sector%d, %s (Endcap); T_rec-T_0-T_fly-T_propagation[ns]",
553 iC, iPstring[iP].Data(), iL, iS, iFstring[iF].Data());
557 hn = Form(
"h_timeF%d_S%d_L%d_P%d_C%d_end", iF, iS, iL, iP, iC);
558 ht = Form(
"Time distribtution for Scintillator of Channel%d, %s, Layer%d, Sector%d, %s (Endcap); T_rec-T_0-T_fly-T_propagation[ns]",
559 iC, iPstring[iP].Data(), iL, iS, iFstring[iF].Data());
563 hn = Form(
"hc_timeF%d_S%d_L%d_P%d_C%d_end", iF, iS, iL, iP, iC);
564 ht = Form(
"Calibrated time distribtution for Scintillator of Channel%d, %s, Layer%d, Sector%d, %s (Endcap); T_rec-T_0-T_fly-T_propagation-T_calibration[ns]",
565 iC, iPstring[iP].Data(), iL, iS, iFstring[iF].Data());
568 hn = Form(
"time_length_eklm_F%d_S%d_L%d_P%d_C%d", iF, iS, iL, iP, iC);
573 "Time versus propagation length; "
574 "propagation distance[cm]; "
575 "T_rec-T_0-T_fly-'T_calibration'[ns]",
576 200, 0.0, stripLength,
587 TProfile* profileRpcPhi, TProfile* profileRpcZ,
588 TProfile* profileBKLMScintillatorPhi, TProfile* profileBKLMScintillatorZ,
589 TProfile* profileEKLMScintillatorPlane1,
590 TProfile* profileEKLMScintillatorPlane2,
bool fill2dHistograms)
594 if (
m_cFlag[channel] == ChannelCalibrationStatus::c_NotEnoughData)
597 std::vector<struct Event>::iterator it;
598 std::vector<struct Event> eventsChannel;
599 eventsChannel =
m_evts[channel];
600 int iSub = klmChannel.getSubdetector();
602 for (it = eventsChannel.begin(); it != eventsChannel.end(); ++it) {
603 double timeHit = it->time() -
m_timeShift[channel];
605 timeHit = timeHit - it->t0;
606 double distHit = it->dist;
609 int iF = klmChannel.getSection();
610 int iS = klmChannel.getSector() - 1;
611 int iL = klmChannel.getLayer() - 1;
612 int iP = klmChannel.getPlane();
613 int iC = klmChannel.getStrip() - 1;
616 profileRpcPhi->Fill(distHit, timeHit);
618 profileRpcZ->Fill(distHit, timeHit);
621 if (fill2dHistograms)
624 profileBKLMScintillatorPhi->Fill(distHit, timeHit);
626 profileBKLMScintillatorZ->Fill(distHit, timeHit);
630 int iF = klmChannel.getSection() - 1;
631 int iS = klmChannel.getSector() - 1;
632 int iL = klmChannel.getLayer() - 1;
633 int iP = klmChannel.getPlane() - 1;
634 int iC = klmChannel.getStrip() - 1;
635 if (fill2dHistograms)
638 profileEKLMScintillatorPlane1->Fill(distHit, timeHit);
640 profileEKLMScintillatorPlane2->Fill(distHit, timeHit);
648 const std::vector< std::pair<KLMChannelNumber, unsigned int> >& channels,
649 double& delay,
double& delayError)
651 std::vector<struct Event>::iterator it;
652 std::vector<struct Event> eventsChannel;
654 int nConvergedFits = 0;
657 if (nFits > (
int)channels.size())
658 nFits = channels.size();
659 for (
int i = 0; i < nFits; ++i) {
660 int subdetector, section, sector, layer, plane, strip;
662 channels[i].first, &subdetector, §ion, §or, &layer, &plane,
669 s_StripLength = module->getStripLength(plane, strip);
676 for (
int j = 0; j < c_NBinsTime; ++j) {
677 for (
int k = 0; k < c_NBinsDistance; ++k)
678 s_BinnedData[j][k] = 0;
680 eventsChannel =
m_evts[channels[i].first];
681 double averageTime = 0;
682 for (it = eventsChannel.begin(); it != eventsChannel.end(); ++it) {
683 double timeHit = it->time();
685 timeHit = timeHit - it->t0;
686 averageTime = averageTime + timeHit;
687 int timeBin = std::floor((timeHit - s_LowerTimeBoundary) * c_NBinsTime /
688 (s_UpperTimeBoundary - s_LowerTimeBoundary));
689 if (timeBin < 0 || timeBin >= c_NBinsTime)
691 int distanceBin = std::floor(it->dist * c_NBinsDistance / s_StripLength);
692 if (distanceBin < 0 || distanceBin >= c_NBinsDistance) {
693 B2ERROR(
"The distance to SiPM is greater than the strip length.");
696 s_BinnedData[timeBin][distanceBin] += 1;
698 averageTime = averageTime / eventsChannel.size();
700 minuit.SetPrintLevel(-1);
702 minuit.mnparm(0,
"P0", 1, 0.001, 0, 0, minuitResult);
703 minuit.mnparm(1,
"N", 10, 0.001, 0, 0, minuitResult);
704 minuit.mnparm(2,
"T0", averageTime, 0.001, 0, 0, minuitResult);
705 minuit.mnparm(3,
"SIGMA", 10, 0.001, 0, 0, minuitResult);
706 minuit.mnparm(4,
"DELAY", 0.0, 0.001, 0, 0, minuitResult);
708 minuit.mncomd(
"FIX 2 3 4 5", minuitResult);
709 minuit.mncomd(
"MIGRAD 10000", minuitResult);
710 minuit.mncomd(
"RELEASE 2", minuitResult);
711 minuit.mncomd(
"MIGRAD 10000", minuitResult);
712 minuit.mncomd(
"RELEASE 3", minuitResult);
713 minuit.mncomd(
"MIGRAD 10000", minuitResult);
714 minuit.mncomd(
"RELEASE 4", minuitResult);
715 minuit.mncomd(
"MIGRAD 10000", minuitResult);
716 minuit.mncomd(
"RELEASE 5", minuitResult);
717 minuit.mncomd(
"MIGRAD 10000", minuitResult);
719 if (minuit.fISW[1] != 3)
722 double channelDelay, channelDelayError;
723 minuit.GetParameter(4, channelDelay, channelDelayError);
724 delay = delay + channelDelay;
725 delayError = delayError + channelDelayError * channelDelayError;
727 delay = delay / nConvergedFits;
728 delayError = sqrt(delayError) / (nConvergedFits - 1);
734 gROOT->SetBatch(kTRUE);
739 fcn_gaus =
new TF1(
"fcn_gaus",
"gaus");
740 fcn_land =
new TF1(
"fcn_land",
"landau");
741 fcn_pol1 =
new TF1(
"fcn_pol1",
"pol1");
742 fcn_const =
new TF1(
"fcn_const",
"pol0");
749 std::string name =
"time_calibration.root";
753 if (stat(name.c_str(), &buffer) != 0)
755 name =
"time_calibration_" + std::to_string(i) +
".root";
761 m_outFile =
new TFile(name.c_str(),
"recreate");
764 std::vector<struct Event>::iterator it;
765 std::vector<struct Event> eventsChannel;
767 eventsChannel.clear();
772 std::vector< std::pair<KLMChannelNumber, unsigned int> > channelsBKLM;
773 std::vector< std::pair<KLMChannelNumber, unsigned int> > channelsEKLM;
777 m_cFlag[channel] = ChannelCalibrationStatus::c_NotEnoughData;
780 int nEvents =
m_evts[channel].size();
782 B2WARNING(
"Not enough calibration data collected."
783 <<
LogVar(
"channel", channel)
784 <<
LogVar(
"number of digit", nEvents));
787 m_cFlag[channel] = ChannelCalibrationStatus::c_FailedFit;
790 channelsBKLM.push_back(
791 std::pair<KLMChannelNumber, unsigned int>(channel, nEvents));
794 channelsEKLM.push_back(
795 std::pair<KLMChannelNumber, unsigned int>(channel, nEvents));
798 std::sort(channelsBKLM.begin(), channelsBKLM.end(), compareEventNumber);
799 std::sort(channelsEKLM.begin(), channelsEKLM.end(), compareEventNumber);
802 double delayBKLM, delayBKLMError;
803 double delayEKLM, delayEKLMError;
811 B2INFO(
"Effective light speed Estimation.");
813 channelId = klmChannel.getKLMChannelNumber();
814 if (
m_cFlag[channelId] == ChannelCalibrationStatus::c_NotEnoughData)
817 eventsChannel =
m_evts[channelId];
818 int iSub = klmChannel.getSubdetector();
820 for (it = eventsChannel.begin(); it != eventsChannel.end(); ++it) {
821 TVector3 diffD = TVector3(it->diffDistX, it->diffDistY, it->diffDistZ);
822 h_diff->Fill(diffD.Mag());
823 double timeHit = it->time();
825 timeHit = timeHit - it->t0;
827 int iF = klmChannel.getSection();
828 int iS = klmChannel.getSector() - 1;
829 int iL = klmChannel.getLayer() - 1;
830 int iP = klmChannel.getPlane();
831 int iC = klmChannel.getStrip() - 1;
839 int iF = klmChannel.getSection() - 1;
840 int iS = klmChannel.getSector() - 1;
841 int iL = klmChannel.getLayer() - 1;
842 int iP = klmChannel.getPlane() - 1;
843 int iC = klmChannel.getStrip() - 1;
849 B2INFO(
"Effective light speed Estimation! Hists and Graph filling done.");
857 B2INFO(
"Global Mean for Raw." <<
LogVar(
"RPC", tmpMean_rpc_global) <<
LogVar(
"Scint BKLM",
858 tmpMean_scint_global) <<
LogVar(
"Scint EKLM", tmpMean_scint_global_end));
861 channelId = klmChannel.getKLMChannelNumber();
862 if (
m_cFlag[channelId] == ChannelCalibrationStatus::c_NotEnoughData)
865 int iSub = klmChannel.getSubdetector();
867 int iF = klmChannel.getSection();
868 int iS = klmChannel.getSector() - 1;
869 int iL = klmChannel.getLayer() - 1;
870 int iP = klmChannel.getPlane();
871 int iC = klmChannel.getStrip() - 1;
873 double tmpMean_channel =
fcn_gaus->GetParameter(1);
875 m_timeShift[channelId] = tmpMean_channel - tmpMean_rpc_global;
877 m_timeShift[channelId] = tmpMean_channel - tmpMean_scint_global;
880 int iF = klmChannel.getSection() - 1;
881 int iS = klmChannel.getSector() - 1;
882 int iL = klmChannel.getLayer() - 1;
883 int iP = klmChannel.getPlane() - 1;
884 int iC = klmChannel.getStrip() - 1;
886 double tmpMean_channel =
fcn_gaus->GetParameter(1);
887 m_timeShift[channelId] = tmpMean_channel - tmpMean_scint_global_end;
894 B2INFO(
"Effective Light m_timeShift obtained. done.");
901 B2INFO(
"Effective light speed fitting.");
903 double delayRPCPhi =
fcn_pol1->GetParameter(1);
904 double e_slope_rpc_phi =
fcn_pol1->GetParError(1);
907 double delayRPCZ =
fcn_pol1->GetParameter(1);
908 double e_slope_rpc_z =
fcn_pol1->GetParError(1);
911 double slope_scint_phi =
fcn_pol1->GetParameter(1);
912 double e_slope_scint_phi =
fcn_pol1->GetParError(1);
915 double slope_scint_z =
fcn_pol1->GetParameter(1);
916 double e_slope_scint_z =
fcn_pol1->GetParError(1);
919 double slope_scint_plane1_end =
fcn_pol1->GetParameter(1);
920 double e_slope_scint_plane1_end =
fcn_pol1->GetParError(1);
923 double slope_scint_plane2_end =
fcn_pol1->GetParameter(1);
924 double e_slope_scint_plane2_end =
fcn_pol1->GetParError(1);
926 TString logStr_phi, logStr_z;
927 logStr_phi = Form(
"%.4f +/- %.4f ns/cm", delayRPCPhi, e_slope_rpc_phi);
928 logStr_z = Form(
"%.4f +/- %.4f ns/cm", delayRPCZ, e_slope_rpc_z);
929 B2INFO(
"Delay in RPCs:"
930 <<
LogVar(
"Fitted Value (phi readout) ", logStr_phi.Data())
931 <<
LogVar(
"Fitted Value (z readout) ", logStr_z.Data()));
932 logStr_phi = Form(
"%.4f +/- %.4f ns/cm", slope_scint_phi, e_slope_scint_phi);
933 logStr_z = Form(
"%.4f +/- %.4f ns/cm", slope_scint_z, e_slope_scint_z);
934 B2INFO(
"Delay in BKLM scintillators:"
935 <<
LogVar(
"Fitted Value (phi readout) ", logStr_phi.Data())
936 <<
LogVar(
"Fitted Value (z readout) ", logStr_z.Data()));
937 logStr_phi = Form(
"%.4f +/- %.4f ns/cm", slope_scint_plane1_end,
938 e_slope_scint_plane1_end);
939 logStr_z = Form(
"%.4f +/- %.4f ns/cm", slope_scint_plane2_end,
940 e_slope_scint_plane2_end);
941 B2INFO(
"Delay in EKLM scintillators:"
942 <<
LogVar(
"Fitted Value (plane1 readout) ", logStr_phi.Data())
943 <<
LogVar(
"Fitted Value (plane2 readout) ", logStr_z.Data()));
945 logStr_z = Form(
"%.4f +/- %.4f ns/cm", delayBKLM, delayBKLMError);
946 B2INFO(
"Delay in BKLM scintillators:"
947 <<
LogVar(
"Fitted Value (2d fit) ", logStr_z.Data()));
948 logStr_z = Form(
"%.4f +/- %.4f ns/cm", delayEKLM, delayEKLMError);
949 B2INFO(
"Delay in EKLM scintillators:"
950 <<
LogVar(
"Fitted Value (2d fit) ", logStr_z.Data()));
962 B2INFO(
"Time distribution filling begins.");
964 channelId = klmChannel.getKLMChannelNumber();
965 int iSub = klmChannel.getSubdetector();
967 if (
m_cFlag[channelId] == ChannelCalibrationStatus::c_NotEnoughData)
969 eventsChannel =
m_evts[channelId];
971 for (it = eventsChannel.begin(); it != eventsChannel.end(); ++it) {
972 double timeHit = it->time();
974 timeHit = timeHit - it->t0;
976 int iF = klmChannel.getSection();
977 int iS = klmChannel.getSector() - 1;
978 int iL = klmChannel.getLayer() - 1;
979 int iP = klmChannel.getPlane();
980 int iC = klmChannel.getStrip() - 1;
984 propgationT = it->dist * delayRPCZ;
986 propgationT = it->dist * delayRPCPhi;
987 double time = timeHit - propgationT;
998 double propgationT = it->dist * delayBKLM;
999 double time = timeHit - propgationT;
1011 int iF = klmChannel.getSection() - 1;
1012 int iS = klmChannel.getSector() - 1;
1013 int iL = klmChannel.getLayer() - 1;
1014 int iP = klmChannel.getPlane() - 1;
1015 int iC = klmChannel.getStrip() - 1;
1016 double propgationT = it->dist * delayEKLM;
1017 double time = timeHit - propgationT;
1031 B2INFO(
"Orignal filling done.");
1033 int iChannel_rpc = 0;
1035 int iChannel_end = 0;
1037 channelId = klmChannel.getKLMChannelNumber();
1038 if (
m_cFlag[channelId] == ChannelCalibrationStatus::c_NotEnoughData)
1040 int iSub = klmChannel.getSubdetector();
1043 int iF = klmChannel.getSection();
1044 int iS = klmChannel.getSector() - 1;
1045 int iL = klmChannel.getLayer() - 1;
1046 int iP = klmChannel.getPlane();
1047 int iC = klmChannel.getStrip() - 1;
1053 m_cFlag[channelId] = ChannelCalibrationStatus::c_SuccessfulCalibration;
1066 int iF = klmChannel.getSection() - 1;
1067 int iS = klmChannel.getSector() - 1;
1068 int iL = klmChannel.getLayer() - 1;
1069 int iP = klmChannel.getPlane() - 1;
1070 int iC = klmChannel.getStrip() - 1;
1076 m_cFlag[channelId] = ChannelCalibrationStatus::c_SuccessfulCalibration;
1097 B2INFO(
"Channel's time distribution fitting done.");
1102 B2INFO(
"Calibrated channel's time distribution filling begins.");
1106 channelId = klmChannel.getKLMChannelNumber();
1111 int iSub = klmChannel.getSubdetector();
1113 int iL = klmChannel.getLayer() - 1;
1125 channelId = klmChannel.getKLMChannelNumber();
1130 B2DEBUG(20,
"Uncalibrated Estimation " <<
LogVar(
"Channel", channelId) <<
LogVar(
"Estimated value",
m_timeShift[channelId]));
1137 channelId = klmChannel.getKLMChannelNumber();
1139 B2ERROR(
"!!! Not All Channels Calibration Constant Set. Error Happended on " <<
LogVar(
"Channel", channelId));
1142 int iSub = klmChannel.getSubdetector();
1144 int iL = klmChannel.getLayer();
1163 channelId = klmChannel.getKLMChannelNumber();
1164 int iSub = klmChannel.getSubdetector();
1165 eventsChannel =
m_evts[channelId];
1166 for (it = eventsChannel.begin(); it != eventsChannel.end(); ++it) {
1167 double timeHit = it->time();
1169 timeHit = timeHit - it->t0;
1171 int iF = klmChannel.getSection();
1172 int iS = klmChannel.getSector() - 1;
1173 int iL = klmChannel.getLayer() - 1;
1174 int iP = klmChannel.getPlane();
1175 int iC = klmChannel.getStrip() - 1;
1179 propgationT = it->dist * delayRPCZ;
1181 propgationT = it->dist * delayRPCPhi;
1182 double time = timeHit - propgationT -
m_timeShift[channelId];
1193 double propgationT = it->dist * delayBKLM;
1194 double time = timeHit - propgationT -
m_timeShift[channelId];
1206 int iF = klmChannel.getSection() - 1;
1207 int iS = klmChannel.getSector() - 1;
1208 int iL = klmChannel.getLayer() - 1;
1209 int iP = klmChannel.getPlane() - 1;
1210 int iC = klmChannel.getStrip() - 1;
1211 double propgationT = it->dist * delayEKLM;
1212 double time = timeHit - propgationT -
m_timeShift[channelId];
1242 B2INFO(
"Save Histograms into Files.");
1243 TDirectory* dir_monitor =
m_outFile->mkdir(
"monitor_Hists");
1246 h_diff->SetDirectory(dir_monitor);
1249 TDirectory* dir_effC =
m_outFile->mkdir(
"effC_Hists");
1265 TDirectory* dir_time =
m_outFile->mkdir(
"time");
1284 B2INFO(
"Top file setup Done.");
1286 TDirectory* dir_time_F[2];
1287 TDirectory* dir_time_FS[2][8];
1288 TDirectory* dir_time_FSL[2][8][15];
1289 TDirectory* dir_time_FSLP[2][8][15][2];
1290 TDirectory* dir_time_F_end[2];
1291 TDirectory* dir_time_FS_end[2][4];
1292 TDirectory* dir_time_FSL_end[2][4][14];
1293 TDirectory* dir_time_FSLP_end[2][4][14][2];
1295 B2INFO(
"Sub files declare Done.");
1296 for (
int iF = 0; iF < 2; ++iF) {
1315 sprintf(dirname,
"isForward_%d", iF);
1316 dir_time_F[iF] = dir_time->mkdir(dirname);
1317 dir_time_F[iF]->cd();
1319 for (
int iS = 0; iS < 8; ++iS) {
1326 h2_timeFS[iF][iS]->SetDirectory(dir_time_F[iF]);
1327 h2c_timeFS[iF][iS]->SetDirectory(dir_time_F[iF]);
1329 sprintf(dirname,
"Sector_%d", iS + 1);
1330 dir_time_FS[iF][iS] = dir_time_F[iF]->mkdir(dirname);
1331 dir_time_FS[iF][iS]->cd();
1333 for (
int iL = 0; iL < 15; ++iL) {
1334 h_timeFSL[iF][iS][iL]->SetDirectory(dir_time_FS[iF][iS]);
1335 hc_timeFSL[iF][iS][iL]->SetDirectory(dir_time_FS[iF][iS]);
1337 sprintf(dirname,
"Layer_%d", iL + 1);
1338 dir_time_FSL[iF][iS][iL] = dir_time_FS[iF][iS]->mkdir(dirname);
1339 dir_time_FSL[iF][iS][iL]->cd();
1340 for (
int iP = 0; iP < 2; ++iP) {
1341 h_timeFSLP[iF][iS][iL][iP]->SetDirectory(dir_time_FSL[iF][iS][iL]);
1342 hc_timeFSLP[iF][iS][iL][iP]->SetDirectory(dir_time_FSL[iF][iS][iL]);
1343 h2_timeFSLP[iF][iS][iL][iP]->SetDirectory(dir_time_FSL[iF][iS][iL]);
1344 h2c_timeFSLP[iF][iS][iL][iP]->SetDirectory(dir_time_FSL[iF][iS][iL]);
1346 sprintf(dirname,
"Plane_%d", iP);
1347 dir_time_FSLP[iF][iS][iL][iP] = dir_time_FSL[iF][iS][iL]->mkdir(dirname);
1348 dir_time_FSLP[iF][iS][iL][iP]->cd();
1351 for (
int iC = 0; iC < nchannel_max; ++iC) {
1354 h_timeFSLPC[iF][iS][iL][iP][iC]->SetDirectory(dir_time_FSLP[iF][iS][iL][iP]);
1355 hc_timeFSLPC[iF][iS][iL][iP][iC]->SetDirectory(dir_time_FSLP[iF][iS][iL][iP]);
1362 sprintf(dirname,
"isForward_%d_end", iF + 1);
1363 dir_time_F_end[iF] = dir_time->mkdir(dirname);
1364 dir_time_F_end[iF]->cd();
1365 int maxLayer = 12 + 2 * iF;
1366 for (
int iS = 0; iS < 4; ++iS) {
1373 sprintf(dirname,
"Sector_%d_end", iS + 1);
1374 dir_time_FS_end[iF][iS] = dir_time_F_end[iF]->mkdir(dirname);
1375 dir_time_FS_end[iF][iS]->cd();
1376 for (
int iL = 0; iL < maxLayer; ++iL) {
1377 h_timeFSL_end[iF][iS][iL]->SetDirectory(dir_time_FS_end[iF][iS]);
1378 hc_timeFSL_end[iF][iS][iL]->SetDirectory(dir_time_FS_end[iF][iS]);
1380 sprintf(dirname,
"Layer_%d_end", iL + 1);
1381 dir_time_FSL_end[iF][iS][iL] = dir_time_FS_end[iF][iS]->mkdir(dirname);
1382 dir_time_FSL_end[iF][iS][iL]->cd();
1383 for (
int iP = 0; iP < 2; ++iP) {
1384 h_timeFSLP_end[iF][iS][iL][iP]->SetDirectory(dir_time_FSL_end[iF][iS][iL]);
1385 hc_timeFSLP_end[iF][iS][iL][iP]->SetDirectory(dir_time_FSL_end[iF][iS][iL]);
1386 h2_timeFSLP_end[iF][iS][iL][iP]->SetDirectory(dir_time_FSL_end[iF][iS][iL]);
1387 h2c_timeFSLP_end[iF][iS][iL][iP]->SetDirectory(dir_time_FSL_end[iF][iS][iL]);
1389 sprintf(dirname,
"plane_%d_end", iP);
1390 dir_time_FSLP_end[iF][iS][iL][iP] = dir_time_FSL_end[iF][iS][iL]->mkdir(dirname);
1391 dir_time_FSLP_end[iF][iS][iL][iP]->cd();
1393 for (
int iC = 0; iC < 75; ++iC) {
1394 h_timeFSLPC_end[iF][iS][iL][iP][iC]->SetDirectory(dir_time_FSLP_end[iF][iS][iL][iP]);
1395 hc_timeFSLPC_end[iF][iS][iL][iP][iC]->SetDirectory(dir_time_FSLP_end[iF][iS][iL][iP]);
1406 B2INFO(
"File Write and Close. Done.");
1424 }
else if (iC == totNStrips) {
1430 std::pair<int, double> tS_upper =
tS_upperStrip(kCIndex_upper);
1431 std::pair<int, double> tS_lower =
tS_lowerStrip(kCIndex_lower);
1432 unsigned int td_upper = tS_upper.first - iC;
1433 unsigned int td_lower = iC - tS_lower.first;
1434 unsigned int td = tS_upper.first - tS_lower.first;
1435 tS = (double(td_upper) * tS_lower.second + double(td_lower) * tS_upper.second) /
double(td);
1442 std::pair<int, double> tS;
1456 }
else if (iC == totNStrips) {
1468 std::pair<int, double> tS;
1479 }
else if (iC == 1) {
@ c_FirstRPCLayer
First RPC layer.
static int getNStrips(int section, int sector, int layer, int plane)
Get number of strips.
Base class for calibration algorithms.
void saveCalibration(TClonesArray *data, const std::string &name)
Store DBArray payload with given name with default IOV.
EResult
The result of calibration.
@ c_OK
Finished successfuly =0 in Python.
@ c_NotEnoughData
Needs more data =2 in Python.
const std::vector< Calibration::ExpRun > & getRunList() const
Get the list of runs for which calibration is called.
Class for accessing objects in the database.
Singleton class to cache database objects.
static DataStore & Instance()
Instance of singleton Store.
void setInitializeActive(bool active)
Setter for m_initializeActive.
static constexpr int getMaximalStripNumber()
Get maximal strip number.
static const GeometryData & Instance(enum DataSource dataSource=c_Database, const GearDir *gearDir=nullptr)
Instantiation.
double getStripLength(int strip) const
Get strip length.
double getMaximalStripLength() const
Get maximal strip length.
int getSubdetector() const
Get subdetector.
int getLayer() const
Get layer.
KLMChannelIndex begin()
First channel.
KLMChannelIndex & end()
Last channel.
int getSection() const
Get section.
int getPlane() const
Get plane.
int getStrip() const
Get strip.
int getSector() const
Get sector.
KLMChannelNumber getKLMChannelNumber() const
Get KLM channel number.
static const KLMElementNumbers & Instance()
Instantiation.
void channelNumberToElementNumbers(KLMChannelNumber channel, int *subdetector, int *section, int *sector, int *layer, int *plane, int *strip) const
Get element numbers by channel number.
TProfile * m_Profile2EKLMScintillatorPlane2
For EKLM scintillator plane2.
TH2F * m_HistTimeLengthEKLM[2][4][14][2][75]
Two-dimensional distributions of time versus propagation length.
TH1F * h_timeFSLPC_tc[2][8][15][2][54]
BKLM part, used for effective light speed estimation.
TH2F * h2c_timeF_scint_end[2]
EKLM part.
TH1F * h_timeFSLPC_tc_end[2][4][14][2][75]
EKLM part, used for effective light speed estimation.
TH1F * h_time_scint_tc_end
EKLM part.
void createHistograms()
Create histograms.
TGraphErrors * gre_time_channel_scint
BKLM Scintillator.
double m_LowerTimeBoundaryCalibratedScintilltorsEKLM
Lower time boundary for EKLM scintillators (calibrated data).
double m_LowerTimeBoundaryScintilltorsEKLM
Lower time boundary for EKLM scintillators.
TH1F * h_timeFSL[2][8][15]
BKLM part.
TH1F * hc_timeFSLPC_end[2][4][14][2][75]
EKLM part.
TH1F * hc_timeFSL_end[2][4][14]
EKLM part.
TH1F * h_timeFSLP_end[2][4][14][2]
EKLM part.
TH1F * hc_timeFSLP_end[2][4][14][2]
EKLM part.
TH1F * h_timeFSLP[2][8][15][2]
BKLM part.
TH1F * hc_timeF_scint_end[2]
EKLM part.
std::map< KLMChannelNumber, double > m_timeShift
Shift values of ecah channel.
TH1F * h_time_scint
BKLM scintillator part.
double m_time_channelAvg_scint
Central value of the global time distribution (BKLM scintillator part).
TH1F * hc_timeFS_scint_end[2][4]
EKLM part.
double m_UpperTimeBoundaryCalibratedRPC
Upper time boundary for RPC (calibrated data).
KLMTimeConstants * m_timeConstants
DBObject of time cost on some parts of the detector.
void setupDatabase()
Setup the database.
double m_LowerTimeBoundaryCalibratedScintilltorsBKLM
Lower time boundary for BKLM scintillators (calibrated data).
double m_UpperTimeBoundaryCalibratedScintilltorsBKLM
Upper time boundary for BKLM scintillators (calibrated data).
TH1F * hc_timeFS_scint[2][8]
BKLM scintillator part.
std::map< KLMChannelNumber, double > m_time_channel
Time distribution central value of each channel.
CalibrationAlgorithm::EResult readCalibrationData()
Read calibration data.
TGraph * gr_timeShift_channel_scint_end
EKLM.
TH1F * hc_timeF_scint[2]
BKLM scintillator part.
TH1F * h_timeFS_scint[2][8]
BKLM scintillator part.
const KLMElementNumbers * m_ElementNumbers
Element numbers.
TH1F * hc_timeF_rpc[2]
BKLM RPC part.
TH2F * h2c_timeFS_end[2][4]
EKLM part.
TH1F * h_timeFSLPC_end[2][4][14][2][75]
EKLM part.
const EKLM::GeometryData * m_EKLMGeometry
EKLM geometry data.
TProfile * m_Profile2BKLMScintillatorPhi
For BKLM scintillator phi plane.
TH1F * hc_time_scint_end
EKLM part.
TGraphErrors * gre_time_channel_scint_end
EKLM.
TH2F * h2_timeFSLP[2][8][15][2]
BKLM part.
TGraph * gr_timeShift_channel_scint
BKLM scintillator.
double m_time_channelAvg_scint_end
Central value of the global time distribution (EKLM scintillator part).
TProfile * m_Profile2EKLMScintillatorPlane1
For EKLM scintillator plane1.
TH1F * hc_timeFS_rpc[2][8]
BKLM RPC part.
void fillTimeDistanceProfiles(TProfile *profileRpcPhi, TProfile *profileRpcZ, TProfile *profileBKLMScintillatorPhi, TProfile *profileBKLMScintillatorZ, TProfile *profileEKLMScintillatorPlane1, TProfile *profileEKLMScintillatorPlane2, bool fill2dHistograms)
Fill profiles of time versus distance.
TFile * m_outFile
Output file.
double esti_timeShift(const KLMChannelIndex &klmChannel)
Estimate value of calibration constant for uncalibrated channels.
std::pair< int, double > tS_upperStrip(const KLMChannelIndex &klmChannel)
Tracing avaiable channels with increasing strip number.
TH1F * hc_timeFSLP[2][8][15][2]
BKLM part.
void saveHist()
Save histograms to file.
const bklm::GeometryPar * m_BKLMGeometry
BKLM geometry data.
TH2F * h2c_timeFSLP[2][8][15][2]
BKLM part.
TF1 * fcn_const
Const function.
TProfile * m_Profile2RpcZ
For BKLM RPC z plane.
TH1F * h_timeFSLPC[2][8][15][2][54]
BKLM part.
~KLMTimeAlgorithm()
Destructor.
TH2F * m_HistTimeLengthBKLM[2][8][15][2][54]
Two-dimensional distributions of time versus propagation length.
TH2F * h2_timeFSLP_end[2][4][14][2]
EKLM part.
void timeDistance2dFit(const std::vector< std::pair< KLMChannelNumber, unsigned int > > &channels, double &delay, double &delayError)
Two-dimensional fit for individual channels.
TH1I * h_calibrated
Calibration statistics for each channel.
TProfile * m_ProfileBKLMScintillatorZ
For BKLM scintillator z plane.
TH1F * h_time_rpc_tc
BKLM RPC part.
TH1F * h_time_scint_end
EKLM part.
TH2F * h2c_timeF_scint[2]
BKLM scintillator part.
TF1 * fcn_pol1
Pol1 function.
double m_etime_channelAvg_scint_end
Central value error of the global time distribution (EKLM scintillator part).
TH1F * hc_time_rpc
BKLM RPC part.
TH2F * h2c_timeFSLP_end[2][4][14][2]
EKLM part.
TH2F * h2_timeF_scint_end[2]
EKLM part.
double m_UpperTimeBoundaryScintilltorsBKLM
Upper time boundary for BKLM scintillators.
TF1 * fcn_gaus
Gaussian function.
TH1F * h_timeF_rpc[2]
BKLM RPC part.
TProfile * m_ProfileBKLMScintillatorPhi
For BKLM scintillator phi plane.
TH1F * hc_time_scint
BKLM scintillator part.
TH2F * h2_timeFS[2][8]
BKLM part.
double m_etime_channelAvg_scint
Central value error of the global time distribution (BKLM scintillator part).
double m_UpperTimeBoundaryCalibratedScintilltorsEKLM
Upper time boundary for BKLM scintillators (calibrated data).
TH1F * h_timeF_scint_end[2]
EKLM part.
TProfile * m_ProfileRpcPhi
For BKLM RPC phi plane.
TProfile * m_ProfileEKLMScintillatorPlane2
For EKLM scintillator plane2.
TH1F * h_time_rpc
BKLM RPC part.
TH1F * h_timeFSL_end[2][4][14]
EKLM part.
TProfile * m_Profile2RpcPhi
For BKLM RPC phi plane.
TH1F * h_timeF_scint[2]
BKLM scintillator part.
TH1F * hc_timeFSL[2][8][15]
BKLM part.
TProfile * m_Profile2BKLMScintillatorZ
For BKLM scintillator z plane.
TH1F * h_timeFS_rpc[2][8]
BKLM RPC part.
KLMChannelIndex m_klmChannels
KLM ChannelIndex object.
TGraph * gr_timeShift_channel_rpc
BKLM RPC.
TH1F * h_diff
Distance between global and local position.
TH2F * h2_timeF_scint[2]
BKLM scintillator part.
TH1F * h_time_scint_tc
BKLM scintillator part.
double m_LowerTimeBoundaryRPC
Lower time boundary for RPC.
virtual EResult calibrate() override
Run algorithm on data.
double m_LowerTimeBoundaryCalibratedRPC
Lower time boundary for RPC (calibrated data).
bool m_useEventT0
Whether to use event T0 from CDC.
int m_MinimalDigitNumber
Minimal digit number (total).
TProfile * m_ProfileEKLMScintillatorPlane1
For EKLM scintillator plane1.
double m_UpperTimeBoundaryRPC
Upper time boundary for RPC.
TH2F * h2c_timeF_rpc[2]
BKLM RPC part.
TF1 * fcn_land
Landau function.
KLMTimeCableDelay * m_timeCableDelay
DBObject of the calibration constant of each channel due to cable decay.
std::pair< int, double > tS_lowerStrip(const KLMChannelIndex &klmChannel)
Tracing avaiable channels with decreasing strip number.
TProfile * m_ProfileRpcZ
For BKLM RPC z plane.
double m_LowerTimeBoundaryScintilltorsBKLM
Lower time boundary for BKLM scintillators.
TH1F * hc_timeFSLPC[2][8][15][2][54]
BKLM part.
ROOT::Math::MinimizerOptions m_minimizerOptions
Minimization options.
std::map< KLMChannelNumber, int > m_cFlag
Calibration flag if the channel has enough hits collected and fitted OK.
TGraphErrors * gre_time_channel_rpc
BKLM RPC.
TH2F * h2_timeFS_end[2][4]
EKLM part.
TH2F * h2_timeF_rpc[2]
BKLM RPC part.
std::map< KLMChannelNumber, std::vector< struct Event > > m_evts
Container of hit information.
TH1F * h_timeFS_scint_end[2][4]
EKLM part.
double m_time_channelAvg_rpc
Central value of the global time distribution (BKLM RPC part).
TH2F * h2c_timeFS[2][8]
BKLM part.
double m_etime_channelAvg_rpc
Central value error of the global time distribution (BKLM RPC part).
KLMTimeAlgorithm()
Constructor.
std::map< KLMChannelNumber, double > m_etime_channel
Time distribution central value Error of each channel.
double m_UpperTimeBoundaryScintilltorsEKLM
Upper time boundary for BKLM scintillators.
int m_lower_limit_counts
Lower limit of hits collected for on single channel.
Class to store BKLM delay time coused by cable in the database.
void setTimeDelay(KLMChannelNumber channel, float timeDelay)
Set the time calibration constant.
Class to store KLM constants related to time.
@ c_BKLM
BKLM scintillator.
@ c_EKLM
EKLM scintillator.
void setDelay(float delay, int cType)
Set effective light speed of scintillators.
bool registerInDataStore(DataStore::EStoreFlags storeFlags=DataStore::c_WriteOut)
Register the object/array in the DataStore.
Type-safe access to single objects in the data store.
bool isValid() const
Check whether the object was created.
bool construct(Args &&... params)
Construct an object of type T in this StoreObjPtr, using the provided constructor arguments.
static const double cm
Standard units with the value = 1.
const Module * findModule(int section, int sector, int layer) const
Get the pointer to the definition of a module.
double getMaximalZStripLength() const
Get maximal Z strip length (for scintillators).
static GeometryPar * instance(void)
Static method to get a reference to the singleton GeometryPar instance.
double getMaximalPhiStripLength() const
Get maximal phi strip length (for scintillators).
Define the geometry of a BKLM module Each sector [octant] contains Modules.
Class to store variables with their name which were sent to the logging service.
static DBStore & Instance()
Instance of a singleton DBStore.
void updateEvent()
Updates all intra-run dependent objects.
void update()
Updates all objects that are outside their interval of validity.
uint16_t KLMChannelNumber
Channel number.
Abstract base class for different kinds of events.