Run algorithm on data.
913{
914 int channelId;
915 gROOT->SetBatch(kTRUE);
920
921 fcn_gaus =
new TF1(
"fcn_gaus",
"gaus");
922 fcn_land =
new TF1(
"fcn_land",
"landau");
923 fcn_pol1 =
new TF1(
"fcn_pol1",
"pol1");
924 fcn_const =
new TF1(
"fcn_const",
"pol0");
925
926
929 return result;
930
931
932 std::string name = "time_calibration.root";
933 int i = 1;
934 while (1) {
935 struct stat buffer;
936 if (stat(name.c_str(), &buffer) != 0)
937 break;
938 name = "time_calibration_" + std::to_string(i) + ".root";
939 i = i + 1;
940 if (i < 0)
941 break;
942 }
943 m_outFile =
new TFile(name.c_str(),
"recreate");
945
946 std::vector<struct Event> eventsChannel;
947 eventsChannel.clear();
950
951
952
953
954 B2INFO("Counting events per channel...");
955 std::map<KLMChannelNumber, unsigned int> eventCounts;
957
958
959 std::vector< std::pair<KLMChannelNumber, unsigned int> > channelsBKLM;
960 std::vector< std::pair<KLMChannelNumber, unsigned int> > channelsEKLM;
961 KLMChannelIndex klmChannels;
962
963 for (KLMChannelIndex& klmChannel : klmChannels) {
965 m_cFlag[channel] = ChannelCalibrationStatus::c_NotEnoughData;
966
967 if (eventCounts.find(channel) == eventCounts.end())
968 continue;
969
970 int nEvents = eventCounts[channel];
972 B2WARNING("Not enough calibration data collected."
973 << LogVar("channel", channel)
974 << LogVar("number of digit", nEvents));
975 continue;
976 }
977
978 m_cFlag[channel] = ChannelCalibrationStatus::c_FailedFit;
979
982 channelsBKLM.push_back(std::pair<KLMChannelNumber, unsigned int>(channel, nEvents));
983 }
985 channelsEKLM.push_back(std::pair<KLMChannelNumber, unsigned int>(channel, nEvents));
986 }
987 }
988
989 std::sort(channelsBKLM.begin(), channelsBKLM.end(), compareEventNumber);
990 std::sort(channelsEKLM.begin(), channelsEKLM.end(), compareEventNumber);
991
992
993
994
995 double delayBKLM, delayBKLMError;
996 double delayEKLM, delayEKLMError;
997
998
1003
1004 B2INFO("2D fits complete, data cleared.");
1005
1006
1007
1008
1009 auto isRPCBackward = [](const KLMChannelIndex & ch) {
1013 };
1014
1015 auto isRPCForward = [](const KLMChannelIndex & ch) {
1019 };
1020
1021 auto isBKLMScintillatorBackward = [](const KLMChannelIndex & ch) {
1025 };
1026
1027 auto isBKLMScintillatorForward = [](const KLMChannelIndex & ch) {
1031 };
1032
1033 auto isEKLMScintillatorBackward = [](const KLMChannelIndex & ch) {
1036 };
1037
1038 auto isEKLMScintillatorForward = [](const KLMChannelIndex & ch) {
1041 };
1042
1043 std::vector<std::pair<std::string, std::function<bool(const KLMChannelIndex&)>>> batches = {
1044 {"RPC Backward", isRPCBackward},
1045 {"RPC Forward", isRPCForward},
1046 {"BKLM Scintillator Backward", isBKLMScintillatorBackward},
1047 {"BKLM Scintillator Forward", isBKLMScintillatorForward},
1048 {"EKLM Scintillator Backward", isEKLMScintillatorBackward},
1049 {"EKLM Scintillator Forward", isEKLMScintillatorForward}
1050 };
1051
1052
1053
1054
1055
1056 B2INFO("First loop: Computing global statistics (batched processing)...");
1057
1058 TString iFstring[2] = {"Backward", "Forward"};
1059 TString iPstring[2] = {"ZReadout", "PhiReadout"};
1060 int nBin = 80;
1061 int nBin_scint = 80;
1062
1063 for (const auto& batch : batches) {
1064 B2INFO("Processing batch for global stats: " << batch.first);
1066
1068 channelId = klmChannel.getKLMChannelNumber();
1069
1070 if (!batch.second(klmChannel))
1071 continue;
1072
1073 if (
m_cFlag[channelId] == ChannelCalibrationStatus::c_NotEnoughData)
1074 continue;
1075
1077 continue;
1078
1079 eventsChannel =
m_evts[channelId];
1080 int iSub = klmChannel.getSubdetector();
1082
1083
1084 for (
const Event& event : eventsChannel) {
1085 XYZVector diffD = XYZVector(event.diffDistX, event.diffDistY, event.diffDistZ);
1087
1088 double timeHit = event.time();
1090 timeHit = timeHit - event.t0;
1091
1092 if (timeHit <= -400e3)
1093 continue;
1094
1096 if (iL > 1) {
1098 } else {
1100 }
1101 } else {
1103 }
1104 }
1105 }
1106
1108 B2INFO("Batch processed and cleared: " << batch.first);
1109 }
1110
1111
1116
1117 B2INFO("Global Mean for Raw." << LogVar("RPC", tmpMean_rpc_global)
1118 << LogVar("Scint BKLM", tmpMean_scint_global)
1119 << LogVar("Scint EKLM", tmpMean_scint_global_end));
1120
1121
1122
1123
1124
1125 B2INFO("Second pass: Computing per-channel time shifts (batched processing)...");
1126
1127 for (const auto& batch : batches) {
1128 B2INFO("Processing batch for time shifts: " << batch.first);
1130
1132 channelId = klmChannel.getKLMChannelNumber();
1133
1134 if (!batch.second(klmChannel))
1135 continue;
1136
1137 if (
m_cFlag[channelId] == ChannelCalibrationStatus::c_NotEnoughData)
1138 continue;
1139
1141 continue;
1142
1143 eventsChannel =
m_evts[channelId];
1144 int iSub = klmChannel.getSubdetector();
1145 int iF, iS, iL, iP, iC;
1146
1148 iF = klmChannel.getSection();
1149 iS = klmChannel.getSector() - 1;
1150 iL = klmChannel.getLayer() - 1;
1151 iP = klmChannel.getPlane();
1152 iC = klmChannel.getStrip() - 1;
1153 } else {
1154 iF = klmChannel.getSection() - 1;
1155 iS = klmChannel.getSector() - 1;
1156 iL = klmChannel.getLayer() - 1;
1157 iP = klmChannel.getPlane() - 1;
1158 iC = klmChannel.getStrip() - 1;
1159 }
1160
1161
1162 TString hn, ht;
1163 TH1F* h_temp_tc = nullptr;
1164
1166 if (iL > 1) {
1167 hn = Form("h_timeF%d_S%d_L%d_P%d_C%d_tc", iF, iS, iL, iP, iC);
1168 ht = Form("Time distribution for RPC of Channel%d, %s, Layer%d, Sector%d, %s",
1169 iC, iPstring[iP].Data(), iL, iS, iFstring[iF].Data());
1171 } else {
1172 hn = Form("h_timeF%d_S%d_L%d_P%d_C%d_tc", iF, iS, iL, iP, iC);
1173 ht = Form("time distribution for Scintillator of Channel%d, %s, Layer%d, Sector%d, %s",
1174 iC, iPstring[iP].Data(), iL, iS, iFstring[iF].Data());
1177 }
1178 } else {
1179 hn = Form("h_timeF%d_S%d_L%d_P%d_C%d_tc_end", iF, iS, iL, iP, iC);
1180 ht = Form("Time distribution for Scintillator of Channel%d, %s, Layer%d, Sector%d, %s (Endcap)",
1181 iC, iPstring[iP].Data(), iL, iS, iFstring[iF].Data());
1184 }
1185
1186 for (
const Event& event : eventsChannel) {
1187 double timeHit = event.time();
1189 timeHit = timeHit - event.t0;
1190 if (timeHit <= -400e3)
1191 continue;
1192 h_temp_tc->Fill(timeHit);
1193 }
1194
1196 double tmpMean_channel =
fcn_gaus->GetParameter(1);
1197
1199 if (iL > 1) {
1200 m_timeShift[channelId] = tmpMean_channel - tmpMean_rpc_global;
1201 } else {
1202 m_timeShift[channelId] = tmpMean_channel - tmpMean_scint_global;
1203 }
1204 } else {
1205 m_timeShift[channelId] = tmpMean_channel - tmpMean_scint_global_end;
1206 }
1207
1208 delete h_temp_tc;
1209 }
1210
1212 B2INFO("Batch processed and cleared: " << batch.first);
1213 }
1214
1218 B2INFO("Effective Light m_timeShift obtained.");
1219
1220
1225
1226 B2INFO("Effective light speed fitting.");
1228 double delayRPCPhi =
fcn_pol1->GetParameter(1);
1229 double e_slope_rpc_phi =
fcn_pol1->GetParError(1);
1230
1232 double delayRPCZ =
fcn_pol1->GetParameter(1);
1233 double e_slope_rpc_z =
fcn_pol1->GetParError(1);
1234
1236 double slope_scint_phi =
fcn_pol1->GetParameter(1);
1237 double e_slope_scint_phi =
fcn_pol1->GetParError(1);
1238
1240 double slope_scint_z =
fcn_pol1->GetParameter(1);
1241 double e_slope_scint_z =
fcn_pol1->GetParError(1);
1242
1244 double slope_scint_plane1_end =
fcn_pol1->GetParameter(1);
1245 double e_slope_scint_plane1_end =
fcn_pol1->GetParError(1);
1246
1248 double slope_scint_plane2_end =
fcn_pol1->GetParameter(1);
1249 double e_slope_scint_plane2_end =
fcn_pol1->GetParError(1);
1250
1251 TString logStr_phi, logStr_z;
1252 logStr_phi = Form("%.4f +/- %.4f ns/cm", delayRPCPhi, e_slope_rpc_phi);
1253 logStr_z = Form("%.4f +/- %.4f ns/cm", delayRPCZ, e_slope_rpc_z);
1254 B2INFO("Delay in RPCs:"
1255 << LogVar("Fitted Value (phi readout) ", logStr_phi.Data())
1256 << LogVar("Fitted Value (z readout) ", logStr_z.Data()));
1257 logStr_phi = Form("%.4f +/- %.4f ns/cm", slope_scint_phi, e_slope_scint_phi);
1258 logStr_z = Form("%.4f +/- %.4f ns/cm", slope_scint_z, e_slope_scint_z);
1259 B2INFO("Delay in BKLM scintillators:"
1260 << LogVar("Fitted Value (phi readout) ", logStr_phi.Data())
1261 << LogVar("Fitted Value (z readout) ", logStr_z.Data()));
1262 logStr_phi = Form("%.4f +/- %.4f ns/cm", slope_scint_plane1_end,
1263 e_slope_scint_plane1_end);
1264 logStr_z = Form("%.4f +/- %.4f ns/cm", slope_scint_plane2_end,
1265 e_slope_scint_plane2_end);
1266 B2INFO("Delay in EKLM scintillators:"
1267 << LogVar("Fitted Value (plane1 readout) ", logStr_phi.Data())
1268 << LogVar("Fitted Value (plane2 readout) ", logStr_z.Data()));
1269
1270 logStr_z = Form("%.4f +/- %.4f ns/cm", delayBKLM, delayBKLMError);
1271 B2INFO("Delay in BKLM scintillators:"
1272 << LogVar("Fitted Value (2d fit) ", logStr_z.Data()));
1273 logStr_z = Form("%.4f +/- %.4f ns/cm", delayEKLM, delayEKLMError);
1274 B2INFO("Delay in EKLM scintillators:"
1275 << LogVar("Fitted Value (2d fit) ", logStr_z.Data()));
1276
1281
1282
1283
1284
1285
1286 B2INFO("Third loop: Time distribution filling (batched processing)...");
1287
1288 for (const auto& batch : batches) {
1289 B2INFO("Processing batch: " << batch.first);
1291
1293 channelId = klmChannel.getKLMChannelNumber();
1294
1295 if (!batch.second(klmChannel))
1296 continue;
1297
1298 if (
m_cFlag[channelId] == ChannelCalibrationStatus::c_NotEnoughData)
1299 continue;
1300
1302 continue;
1303
1304 eventsChannel =
m_evts[channelId];
1305 int iSub = klmChannel.getSubdetector();
1306 int iF, iS, iL, iP, iC;
1307
1309 iF = klmChannel.getSection();
1310 iS = klmChannel.getSector() - 1;
1311 iL = klmChannel.getLayer() - 1;
1312 iP = klmChannel.getPlane();
1313 iC = klmChannel.getStrip() - 1;
1314 } else {
1315 iF = klmChannel.getSection() - 1;
1316 iS = klmChannel.getSector() - 1;
1317 iL = klmChannel.getLayer() - 1;
1318 iP = klmChannel.getPlane() - 1;
1319 iC = klmChannel.getStrip() - 1;
1320 }
1321
1322
1323 TString hn, ht;
1324 TH1F* h_temp = nullptr;
1325
1327 if (iL > 1) {
1328 hn = Form("h_timeF%d_S%d_L%d_P%d_C%d", iF, iS, iL, iP, iC);
1329 ht = Form("Time distribution for RPC of Channel%d, %s, Layer%d, Sector%d, %s",
1330 iC, iPstring[iP].Data(), iL, iS, iFstring[iF].Data());
1332 } else {
1333 hn = Form("h_timeF%d_S%d_L%d_P%d_C%d", iF, iS, iL, iP, iC);
1334 ht = Form("time distribution for Scintillator of Channel%d, %s, Layer%d, Sector%d, %s",
1335 iC, iPstring[iP].Data(), iL, iS, iFstring[iF].Data());
1338 }
1339 } else {
1340 hn = Form("h_timeF%d_S%d_L%d_P%d_C%d_end", iF, iS, iL, iP, iC);
1341 ht = Form("Time distribution for Scintillator of Channel%d, %s, Layer%d, Sector%d, %s (Endcap)",
1342 iC, iPstring[iP].Data(), iL, iS, iFstring[iF].Data());
1345 }
1346
1347
1348 for (
const Event& event : eventsChannel) {
1349 double timeHit = event.time();
1351 timeHit = timeHit - event.t0;
1352 if (timeHit <= -400e3)
1353 continue;
1354
1356 if (iL > 1) {
1357 double propgationT;
1359 propgationT = event.dist * delayRPCZ;
1360 else
1361 propgationT = event.dist * delayRPCPhi;
1362 double time = timeHit - propgationT;
1363
1365 h_temp->Fill(time);
1366
1375 }
1376 } else {
1377 double propgationT = event.dist * delayBKLM;
1378 double time = timeHit - propgationT;
1379
1381 h_temp->Fill(time);
1382
1391 }
1392 }
1393 } else {
1394 double propgationT = event.dist * delayEKLM;
1395 double time = timeHit - propgationT;
1396
1398 h_temp->Fill(time);
1399
1408 }
1409 }
1410 }
1411
1412 TFitResultPtr r = h_temp->Fit(
fcn_gaus,
"LESQ");
1413 if (int(r) == 0) {
1414 m_cFlag[channelId] = ChannelCalibrationStatus::c_SuccessfulCalibration;
1417 }
1418
1420 }
1421
1423 B2INFO("Batch processed and cleared: " << batch.first);
1424 }
1425
1426 B2INFO("Original filling done.");
1427
1428
1429 int iChannel_rpc = 0;
1430 int iChannel = 0;
1431 int iChannel_end = 0;
1433 channelId = klmChannel.getKLMChannelNumber();
1434 if (
m_cFlag[channelId] != ChannelCalibrationStatus::c_SuccessfulCalibration)
1435 continue;
1436
1437 int iSub = klmChannel.getSubdetector();
1439 int iL = klmChannel.getLayer() - 1;
1440 if (iL > 1) {
1443 iChannel_rpc++;
1444 } else {
1447 iChannel++;
1448 }
1449 } else {
1452 iChannel_end++;
1453 }
1454 }
1455
1459
1463
1467
1468 B2INFO("Channel's time distribution fitting done.");
1472
1473 B2INFO("Calibrated channel's time distribution filling begins.");
1474
1477 channelId = klmChannel.getKLMChannelNumber();
1480 continue;
1484 }
1485
1487 channelId = klmChannel.getKLMChannelNumber();
1489 continue;
1492 B2DEBUG(20,
"Uncalibrated Estimation " << LogVar(
"Channel", channelId) << LogVar(
"Estimated value",
m_timeShift[channelId]));
1493 }
1494
1495 iChannel_rpc = 0;
1496 iChannel = 0;
1497 iChannel_end = 0;
1499 channelId = klmChannel.getKLMChannelNumber();
1501 B2ERROR("!!! Not All Channels Calibration Constant Set. Error Happened on " << LogVar("Channel", channelId));
1502 continue;
1503 }
1504 int iSub = klmChannel.getSubdetector();
1506 int iL = klmChannel.getLayer();
1507 if (iL > 2) {
1509 iChannel_rpc++;
1510 } else {
1512 iChannel++;
1513 }
1514 } else {
1516 iChannel_end++;
1517 }
1518 }
1519
1520
1525
1526
1527
1528
1529
1530 B2INFO("Fourth loop: Calibrated time distribution filling (batched processing)...");
1531
1532 for (const auto& batch : batches) {
1533 B2INFO("Processing batch: " << batch.first);
1535
1537 channelId = klmChannel.getKLMChannelNumber();
1538
1539 if (!batch.second(klmChannel))
1540 continue;
1541
1543 continue;
1544
1545 eventsChannel =
m_evts[channelId];
1546 int iSub = klmChannel.getSubdetector();
1547 int iF, iS, iL, iP, iC;
1548
1550 iF = klmChannel.getSection();
1551 iS = klmChannel.getSector() - 1;
1552 iL = klmChannel.getLayer() - 1;
1553 iP = klmChannel.getPlane();
1554 iC = klmChannel.getStrip() - 1;
1555 } else {
1556 iF = klmChannel.getSection() - 1;
1557 iS = klmChannel.getSector() - 1;
1558 iL = klmChannel.getLayer() - 1;
1559 iP = klmChannel.getPlane() - 1;
1560 iC = klmChannel.getStrip() - 1;
1561 }
1562
1563 TString hn, ht;
1564 TH1F* hc_temp = nullptr;
1565
1567 if (iL > 1) {
1568 hn = Form("hc_timeF%d_S%d_L%d_P%d_C%d", iF, iS, iL, iP, iC);
1569 ht = Form("Calibrated time distribution for RPC of Channel%d, %s, Layer%d, Sector%d, %s",
1570 iC, iPstring[iP].Data(), iL, iS, iFstring[iF].Data());
1573 } else {
1574 hn = Form("hc_timeF%d_S%d_L%d_P%d_C%d", iF, iS, iL, iP, iC);
1575 ht = Form("Calibrated time distribution for Scintillator of Channel%d, %s, Layer%d, Sector%d, %s",
1576 iC, iPstring[iP].Data(), iL, iS, iFstring[iF].Data());
1579 }
1580 } else {
1581 hn = Form("hc_timeF%d_S%d_L%d_P%d_C%d_end", iF, iS, iL, iP, iC);
1582 ht = Form("Calibrated time distribution for Scintillator of Channel%d, %s, Layer%d, Sector%d, %s (Endcap)",
1583 iC, iPstring[iP].Data(), iL, iS, iFstring[iF].Data());
1586 }
1587
1588 for (
const Event& event : eventsChannel) {
1589 double timeHit = event.time();
1591 timeHit = timeHit - event.t0;
1592 if (timeHit <= -400e3)
1593 continue;
1594
1596 if (iL > 1) {
1597 double propgationT;
1599 propgationT = event.dist * delayRPCZ;
1600 else
1601 propgationT = event.dist * delayRPCPhi;
1602 double time = timeHit - propgationT -
m_timeShift[channelId];
1603
1605 hc_temp->Fill(time);
1606
1615 }
1616 } else {
1617 double propgationT = event.dist * delayBKLM;
1618 double time = timeHit - propgationT -
m_timeShift[channelId];
1619
1621 hc_temp->Fill(time);
1622
1631 }
1632 }
1633 } else {
1634 double propgationT = event.dist * delayEKLM;
1635 double time = timeHit - propgationT -
m_timeShift[channelId];
1636
1638 hc_temp->Fill(time);
1639
1648 }
1649 }
1650 }
1651
1652 if (
m_cFlag[channelId] == ChannelCalibrationStatus::c_NotEnoughData) {
1653 delete hc_temp;
1654 continue;
1655 }
1656
1657 TFitResultPtr rc = hc_temp->Fit(
fcn_gaus,
"LESQ");
1658 if (int(rc) == 0) {
1659 m_cFlag[channelId] = ChannelCalibrationStatus::c_SuccessfulCalibration;
1662 }
1663
1665 }
1666
1668 B2INFO("Batch processed and cleared: " << batch.first);
1669 }
1670
1671
1672 int icChannel_rpc = 0;
1673 int icChannel = 0;
1674 int icChannel_end = 0;
1676 channelId = klmChannel.getKLMChannelNumber();
1677 if (
m_cFlag[channelId] != ChannelCalibrationStatus::c_SuccessfulCalibration)
1678 continue;
1679
1680 int iSub = klmChannel.getSubdetector();
1682 int iL = klmChannel.getLayer() - 1;
1683 if (iL > 1) {
1686 icChannel_rpc++;
1687 } else {
1690 icChannel++;
1691 }
1692 } else {
1695 icChannel_end++;
1696 }
1697 }
1698
1702
1706
1710
1711 B2INFO("Channel's time distribution fitting done.");
1715
1716 B2INFO("Calibrated channel's time distribution filling begins.");
1717
1720 channelId = klmChannel.getKLMChannelNumber();
1723 continue;
1727 }
1728
1730 channelId = klmChannel.getKLMChannelNumber();
1732 continue;
1735 B2DEBUG(20,
"Calibrated Estimation " << LogVar(
"Channel", channelId) << LogVar(
"Estimated value",
m_timeRes[channelId]));
1736 }
1737
1738 icChannel_rpc = 0;
1739 icChannel = 0;
1740 icChannel_end = 0;
1742 channelId = klmChannel.getKLMChannelNumber();
1744 B2ERROR("!!! Not All Channels Calibration Constant Set. Error Happened on " << LogVar("Channel", channelId));
1745 continue;
1746 }
1747 int iSub = klmChannel.getSubdetector();
1749 int iL = klmChannel.getLayer();
1750 if (iL > 2) {
1752 icChannel_rpc++;
1753 } else {
1755 icChannel++;
1756 }
1757 } else {
1759 icChannel_end++;
1760 }
1761 }
1762
1768
1770
1775}
@ c_FirstRPCLayer
First RPC layer.
@ c_ForwardSection
Forward.
@ c_BackwardSection
Backward.
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 successfully =0 in Python.
@ c_ForwardSection
Forward.
@ c_BackwardSection
Backward.
TProfile * m_Profile2EKLMScintillatorPlane2
For EKLM scintillator plane2.
double mc_etime_channelAvg_rpc
Calibrated central value error of the global time distribution (BKLM RPC part).
TH2F * h2c_timeF_scint_end[2]
EKLM part.
KLMTimeResolution * m_timeResolution
DBObject of time resolution.
TH1F * h_time_scint_tc_end
EKLM part.
void createHistograms()
Create histograms.
TGraphErrors * gre_time_channel_scint
BKLM Scintillator.
TH1F * h_timeFSL[2][8][15]
BKLM part.
TH1F * hc_timeFSL_end[2][4][14]
EKLM part.
TH1F * h_timeFSLP_end[2][4][14][2]
EKLM part.
TGraph * gr_timeRes_channel_rpc
BKLM RPC.
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 each 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 esti_timeRes(const KLMChannelIndex &klmChannel)
Estimate value of calibration constant for calibrated channels.
double m_UpperTimeBoundaryCalibratedRPC
Upper time boundary for RPC (calibrated data).
double m_ctime_channelAvg_rpc
Calibrated central value of the global time distribution (BKLM RPC part).
KLMTimeConstants * m_timeConstants
DBObject of time cost on some parts of the detector.
void setupDatabase()
Setup the database.
TH1F * hc_timeFS_scint[2][8]
BKLM scintillator part.
std::map< KLMChannelNumber, double > m_time_channel
Time distribution central value of each channel.
double m_ctime_channelAvg_scint_end
Calibrated central value of the global time distribution (EKLM scintillator part).
CalibrationAlgorithm::EResult readCalibrationData()
Read calibration data.
TGraph * gr_timeShift_channel_scint_end
EKLM.
TGraph * gr_timeRes_channel_scint
BKLM scintillator.
TH1F * hc_timeF_scint[2]
BKLM scintillator part.
TH1F * h_timeFS_scint[2][8]
BKLM scintillator part.
bool m_saveChannelHists
Write per-channel temporary histograms (tc/raw/hc) in minimal mode.
double m_UpperTimeBoundaryScintillatorsBKLM
Upper time boundary for BKLM scintillators.
TH1F * hc_timeF_rpc[2]
BKLM RPC part.
TH2F * h2c_timeFS_end[2][4]
EKLM part.
TGraphErrors * gre_ctime_channel_scint_end
EKLM.
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.
double m_UpperTimeBoundaryCalibratedScintillatorsEKLM
Upper time boundary for BKLM scintillators (calibrated data).
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.
double m_UpperTimeBoundaryScintillatorsEKLM
Upper time boundary for BKLM scintillators.
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.
double m_LowerTimeBoundaryCalibratedScintillatorsEKLM
Lower time boundary for EKLM scintillators (calibrated data).
TH1F * hc_timeFSLP[2][8][15][2]
BKLM part.
TGraphErrors * gre_ctime_channel_rpc
BKLM RPC.
void saveHist()
Save histograms to file.
bool m_saveAllPlots
Default minimal unless you set true in your header script.
TH2F * h2c_timeFSLP[2][8][15][2]
BKLM part.
double m_ctime_channelAvg_scint
Calibrated central value of the global time distribution (BKLM scintillator part).
TF1 * fcn_const
Const function.
double m_UpperTimeBoundaryCalibratedScintillatorsBKLM
Upper time boundary for BKLM scintillators (calibrated data).
TProfile * m_Profile2RpcZ
For BKLM RPC z plane.
TH2F * h2_timeFSLP_end[2][4][14][2]
EKLM part.
TH1I * hc_calibrated
Calibration statistics for each channel.
void timeDistance2dFit(const std::vector< std::pair< KLMChannelNumber, unsigned int > > &channels, double &delay, double &delayError)
Two-dimensional fit for individual channels.
TGraph * gr_timeRes_channel_scint_end
EKLM.
TH1I * h_calibrated
Calibration statistics for each channel.
TProfile * m_ProfileBKLMScintillatorZ
For BKLM scintillator z plane.
double m_LowerTimeBoundaryScintillatorsBKLM
Lower time boundary for BKLM scintillators.
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.
double mc_etime_channelAvg_scint
Calibrated central value error of the global time distribution (BKLM scintillator part).
TH2F * h2c_timeFSLP_end[2][4][14][2]
EKLM part.
double mc_etime_channelAvg_scint_end
Calibrated central value error of the global time distribution (EKLM scintillator part).
void writeThenDelete_(TH1 *h, bool write)
Optionally write a histogram, then delete it to free memory.
TH2F * h2_timeF_scint_end[2]
EKLM part.
TF1 * fcn_gaus
Gaussian function.
double m_LowerTimeBoundaryCalibratedScintillatorsBKLM
Lower time boundary for BKLM scintillators (calibrated data).
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).
TH1F * h_timeF_scint_end[2]
EKLM part.
TProfile * m_ProfileRpcPhi
For BKLM RPC phi plane.
TGraphErrors * gre_ctime_channel_scint
BKLM Scintillator.
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.
std::map< KLMChannelNumber, double > m_timeRes
Resolution values of each channel.
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.
std::map< KLMChannelNumber, double > m_ctime_channel
Calibrated time distribution central value of each channel.
double m_LowerTimeBoundaryCalibratedRPC
Lower time boundary for RPC (calibrated data).
bool m_useEventT0
Whether to use event T0 from CDC.
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.
TProfile * m_ProfileRpcZ
For BKLM RPC z plane.
std::map< KLMChannelNumber, double > mc_etime_channel
Calibrated time distribution central value Error of each channel.
void readCalibrationDataBatch(std::function< bool(const KLMChannelIndex &)> channelFilter)
Load calibration data for a specific batch of channels.
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).
double m_LowerTimeBoundaryScintillatorsEKLM
Lower time boundary for EKLM scintillators.
void readCalibrationDataCounts(std::map< KLMChannelNumber, unsigned int > &eventCounts)
Count events per channel (lightweight scan without loading full data).
std::map< KLMChannelNumber, double > m_etime_channel
Time distribution central value Error of each channel.
int m_lower_limit_counts
Lower limit of hits collected for on single channel.
void readCalibrationDataFor2DFit(const std::vector< std::pair< KLMChannelNumber, unsigned int > > &channelsBKLM, const std::vector< std::pair< KLMChannelNumber, unsigned int > > &channelsEKLM)
Load calibration data only for channels needed for 2D fit.
@ c_BKLM
BKLM scintillator.
@ c_EKLM
EKLM scintillator.
uint16_t KLMChannelNumber
Channel number.