12 ATH_MSG_DEBUG(
"calling the constructor of ZdcMonitorAlgorithm");
24 float log_min = std::log10(min_value);
25 float log_max = std::log10(max_value);
28 float step = (log_max - log_min) / num_bins;
31 for (
int i = 0;
i <= num_bins; ++
i) {
32 float edge = log_min +
i *
step;
33 bin_edges.push_back(
std::pow(10, edge));
40 if (event_value < bin_edges.front() || event_value > bin_edges.back()) {
41 ATH_MSG_DEBUG(
"In calculation of inverse-bin-width event weight for the variable " << variable_name <<
", the current event value " << event_value <<
" is out of the bin range.");
42 ATH_MSG_DEBUG(
"Assign zero weight for the current event (event not filled).");
47 for (
size_t i = 0;
i < bin_edges.size() - 1; ++
i) {
48 if (event_value >= bin_edges[
i] && event_value < bin_edges[
i + 1]) {
53 ATH_MSG_WARNING(
"Warning: in calculation of inverse-bin-width event weight for the variable " << variable_name <<
", bin width containing the event value " << event_value <<
" is zero.");
54 ATH_MSG_WARNING(
"Assign zero weight for the current event (event not filled).");
61 if (event_value == bin_edges.back()) {
62 size_t last_bin_index = bin_edges.size() - 2;
63 float bin_width = bin_edges[last_bin_index + 1] - bin_edges[last_bin_index];
68 ATH_MSG_WARNING(
"Warning: in calculation of inverse-bin-width event weight for the variable " << variable_name <<
", no valid bin found for the event value " << event_value <<
".");
69 ATH_MSG_WARNING(
"Assign zero weight for the current event (event not filled).");
142 std::vector<std::string>
sides = {
"C",
"A"};
143 std::vector<std::string> modules = {
"0",
"1",
"2",
"3"};
144 std::vector<std::string>
channels = {
"0",
"1",
"2",
"3",
"4",
"5",
"6",
"7",
"8",
"9",
"10",
"11",
"12",
"13",
"14",
"15"};
163 ATH_MSG_DEBUG(
"calling the fillPhysicsDataHistograms function");
168 bool cur_event_ZDC_available =
true;
169 bool cur_event_RPD_available =
true;
170 bool cur_event_RPDCentroid_available =
true;
187 std::array<float, m_nDecodingErrorBits> decodingErrorBitsArr = {0, 0, 0};
189 cur_event_ZDC_available &= !zdcDecodingError;
190 cur_event_RPD_available &= !rpdDecodingError;
192 if (!zdcDecodingError && !rpdDecodingError){
193 decodingErrorBitsArr[0] += 1;
194 }
else if (zdcDecodingError){
196 decodingErrorBitsArr[1] += 1;
199 decodingErrorBitsArr[2] += 1;
202 auto zdcTool =
getGroup(
"genZdcMonTool");
216 passTrigSideA = trigDecTool->isPassed(
m_triggerSideA, TrigDefs::Physics);
217 passTrigSideC = trigDecTool->isPassed(
m_triggerSideC, TrigDefs::Physics);
237 std::array<bool, 2> centroidSideValidArr;
238 std::array<bool, 2> rpdSideValidArr = {
false,
false};
239 std::array<std::vector<float>,2> rpdSubAmpVecs;
246 auto passMinZDCEnergyCutForCentroidValidEvaluation =
Monitored::Scalar<bool>(
"passMinZDCEnergyCutForCentroidValidEvaluation",
false);
251 std::array<float, 2> zdcEMModuleEnergyArr = {-1000.,-1000.};
252 std::array<float, 2> zdcEnergySumArr = {-1000,-1000.};
253 std::array<float, 2> zdcUncalibSumArr = {-1000.,-1000.};
254 std::array<float, 2> zdcAvgTimeArr = {-1000.,-1000.};
255 std::array<bool, 2> zdcModuleMaskArr = {
false,
false};
256 std::array<bool, 2> passTrigOppSideArr = {
false,
false};
257 std::array<float, 2> rpdAmplitudeCalibSum = {-1000.,-1000.};
258 std::array<float, 2> rpdMaxADCSum = {-1000.,-1000.};
260 std::array<float, m_nRpdCentroidStatusBits> centroidStatusBitsCountCurSide;
264 return StatusCode::SUCCESS;
274 cur_event_ZDC_available &= ZdcSumCalibEnergyHandle.
isAvailable();
275 if (cur_event_ZDC_available){
276 for (
const auto& zdcSum : *zdcSums) {
277 if (zdcSum->zdcSide() != 0){
278 int iside = (zdcSum->zdcSide() > 0)? 1 : 0;
280 zdcEnergySumArr[iside] = ZdcSumCalibEnergyHandle(*zdcSum);
281 zdcUncalibSumArr[iside] = ZdcSumUncalibSumHandle(*zdcSum);
282 zdcAvgTimeArr[iside] = ZdcSumAverageTimeHandle(*zdcSum);
283 zdcModuleMaskArr[iside] = ZdcSumModuleMaskHandle(*zdcSum);
285 passTrigOppSideArr[iside] = (iside == 0)? passTrigSideA : passTrigSideC;
287 if (zdcSum->zdcSide() == 1){
288 zdcEnergySumA = ZdcSumCalibEnergyHandle(*zdcSum);
289 zdcUncalibSumA = ZdcSumUncalibSumHandle(*zdcSum);
292 zdcEnergySumC = ZdcSumCalibEnergyHandle(*zdcSum);
293 zdcUncalibSumC = ZdcSumUncalibSumHandle(*zdcSum);
299 cur_event_ZDC_available &= ZdcSumUncalibSumHandle.
isAvailable();
300 if (cur_event_ZDC_available){
301 for (
const auto& zdcSum : *zdcSums) {
302 if (zdcSum->zdcSide() != 0){
303 int iside = (zdcSum->zdcSide() > 0)? 1 : 0;
304 zdcUncalibSumArr[iside] = ZdcSumUncalibSumHandle(*zdcSum);
313 cur_event_RPD_available &= RPDsideStatusHandle.
isAvailable();
314 if (cur_event_RPD_available){
315 for (
const auto& zdcSum : *zdcSums) {
316 if (zdcSum->zdcSide() != 0){
317 int iside = (zdcSum->zdcSide() > 0)? 1 : 0;
318 unsigned int rpdStatusCurSide = RPDsideStatusHandle(*zdcSum);
335 cur_event_RPDCentroid_available &= RPDcentroidStatusHandle.
isAvailable();
336 if (cur_event_RPDCentroid_available){
337 for (
const auto& zdcSum : *zdcSums) {
339 if (zdcSum->zdcSide() == 0){
340 rpdCosDeltaReactionPlaneAngle = RPDcosDeltaReactionPlaneAngleHandle(*zdcSum);
342 int iside = (zdcSum->zdcSide() > 0)? 1 : 0;
343 std::string side_str = (iside == 0)?
"C" :
"A";
345 rpdSubAmpVecs[iside] = RPDsubAmpHandle(*zdcSum);
346 rpdSubAmpSumCurSide = RPDsubAmpSumHandle(*zdcSum);
347 rpdXCentroidCurSide = RPDxCentroidHandle(*zdcSum);
348 rpdYCentroidCurSide = RPDyCentroidHandle(*zdcSum);
349 rpdReactionPlaneAngleCurSide = RPDreactionPlaneAngleHandle(*zdcSum);
351 unsigned int rpdCentroidStatusCurSide = RPDcentroidStatusHandle(*zdcSum);
364 centroidValidBitFloat = (centroidValid)? 0.5 : 1.5;
369 bothReactionPlaneAngleValid &= centroidValid;
370 bothHasCentroid &= curSideHasCentroid;
374 if (rpdCentroidStatusCurSide & 1 << bit){
375 centroidStatusBitsCountCurSide[bit] += 1;
378 auto centroidStatusBits =
Monitored::Collection(
"centroidStatusBits", centroidStatusBitsCountCurSide);
380 if (curSideHasCentroid){
384 fill(
m_tools[
m_ZDCSideToolIndices.at(side_str)], rpdSubAmpSumCurSide, centroidValid, passMinZDCEnergyCutForCentroidValidEvaluation, centroidValidBitFloat, rpdXCentroidCurSide, rpdYCentroidCurSide, rpdReactionPlaneAngleCurSide, centroidStatusBits,
lumiBlock,
bcid);
459 std::array<float, m_nZdcStatusBits> zdcStatusBitsCount;
460 std::array<float, m_nRpdStatusBits> rpdStatusBitsCount;
464 return StatusCode::SUCCESS;
469 injectedPulseInputVoltage = zdcModuleAmp * 1. / 25000.;
472 if (injectedPulseInputVoltage > 0){
483 cur_event_ZDC_available &= zdcModuleStatusHandle.
isAvailable();
484 if (cur_event_ZDC_available){
485 for (
const auto zdcMod : *zdcModules){
486 int iside = (zdcMod->zdcSide() > 0)? 1 : 0;
487 std::string side_str = (iside == 0)?
"C" :
"A";
489 if (zdcMod->zdcType() == 0){
490 int imod = zdcMod->zdcModule();
493 int status = zdcModuleStatusHandle(*zdcMod);
495 for (
int bit = 0; bit <
m_nZdcStatusBits; bit++) zdcStatusBitsCount[bit] = 0;
498 zdcStatusBitsCount[bit] += 1;
506 zdcModuleAmp = zdcModuleAmplitudeHandle(*zdcMod);
507 zdcModuleMaxADC = zdcModuleMaxADCHandle(*zdcMod);
508 zdcModuleAmpToMaxADCRatio = (zdcModuleMaxADC == 0)? -1000. : zdcModuleAmp / zdcModuleMaxADC;
509 zdcModuleTime = zdcModuleTimeHandle(*zdcMod);
510 zdcModuleFitT0 = zdcModuleFitT0Handle(*zdcMod);
511 zdcModuleChisq = zdcModuleChisqHandle(*zdcMod);
512 zdcModuleCalibAmp = zdcModuleCalibEnergyHandle(*zdcMod);
513 zdcModuleCalibTime = zdcModuleCalibTimeHandle(*zdcMod);
514 zdcUncalibSumCurrentSide = zdcUncalibSumArr[iside];
515 zdcEnergySumCurrentSide = zdcEnergySumArr[iside];
516 zdcAbove20NCurrentSide = (zdcUncalibSumCurrentSide > 20 *
m_expected1N);
520 zdcModuleFract = (zdcEnergySumCurrentSide == 0)? -1000. : zdcModuleCalibAmp / zdcEnergySumCurrentSide;
522 zdcModuleFract = (zdcUncalibSumCurrentSide == 0)? -1000. : zdcModuleAmp / zdcUncalibSumCurrentSide;
524 zdcModuleChisqOverAmp = (zdcModuleAmp == 0)? -1000. : zdcModuleChisq / zdcModuleAmp;
526 zdcModuleHG = !(zdcModuleLG);
529 zdcModuleAmpLGRefit = zdcModuleAmpLGRefitHandle(*zdcMod);
530 zdcModuleT0LGRefit = zdcModuleT0LGRefitHandle(*zdcMod);
531 zdcModuleT0SubLGRefit = zdcModuleT0SubLGRefitHandle(*zdcMod);
532 zdcModuleChisqLGRefit = zdcModuleChisqLGRefitHandle(*zdcMod);
534 zdcModuleHGtoLGAmpRatio = (!zdcModuleHGValid || zdcModuleAmpLGRefit == 0)? -1000. : zdcModuleAmp * 1. / zdcModuleAmpLGRefit;
535 zdcModuleHGtoLGT0Diff = (!zdcModuleHGValid)? -1000. : zdcModuleFitT0 - zdcModuleT0LGRefit;
540 if (imod == 0) zdcEMModuleEnergyArr[iside] = zdcModuleCalibAmp;
543 fill(
m_tools[
m_ZDCModuleToolIndices.at(side_str).at(module_str)], zdcModuleAmp, zdcModuleMaxADC, zdcModuleAmpToMaxADCRatio, zdcModuleFract, zdcUncalibSumCurrentSide, zdcEnergySumCurrentSide, zdcModuleTime, zdcModuleFitT0, zdcModuleChisq, zdcModuleChisqOverAmp, zdcModuleChisqEventWeight, zdcModuleChisqOverAmpEventWeight, zdcModuleCalibAmp, zdcModuleCalibTime, zdcModuleLG, zdcModuleHG, zdcModuleHGValid, zdcModuleAmpLGRefit, zdcModuleT0LGRefit, zdcModuleT0SubLGRefit, zdcModuleChisqLGRefit, zdcModuleHGtoLGAmpRatio, zdcModuleHGtoLGT0Diff, injectedPulseInputVoltage,
lumiBlock,
bcid);
545 fill(
m_tools[
m_ZDCModuleToolIndices.at(side_str).at(module_str)], zdcModuleAmp, zdcModuleMaxADC, zdcModuleAmpToMaxADCRatio, zdcModuleFract, zdcUncalibSumCurrentSide, zdcEnergySumCurrentSide, zdcAbove20NCurrentSide, zdcEnergyAboveModuleFractCut, zdcModuleTime, zdcModuleFitT0, zdcModuleChisq, zdcModuleChisqOverAmp, zdcModuleChisqEventWeight, zdcModuleChisqOverAmpEventWeight, zdcModuleCalibAmp, zdcModuleCalibTime, zdcModuleLG, zdcModuleHG, zdcModuleHGValid, zdcModuleAmpLGRefit, zdcModuleT0LGRefit, zdcModuleT0SubLGRefit, zdcModuleChisqLGRefit, zdcModuleHGtoLGAmpRatio, zdcModuleHGtoLGT0Diff,
lumiBlock,
bcid);
565 cur_event_RPD_available &= RPDChannelStatusHandle.
isAvailable();
566 if (cur_event_RPD_available){
567 for (
const auto zdcMod : *zdcModules){
568 int iside = (zdcMod->zdcSide() > 0)? 1 : 0;
569 std::string side_str = (iside == 0)?
"C" :
"A";
571 if (zdcMod->zdcType() == 1) {
574 int ichannel = zdcMod->zdcChannel();
577 int status = RPDChannelStatusHandle(*zdcMod);
579 for (
int bit = 0; bit <
m_nRpdStatusBits; bit++) rpdStatusBitsCount[bit] = 0;
582 rpdStatusBitsCount[bit] += 1;
588 rpdChannelSubAmp = rpdSubAmpVecs[iside][ichannel];
589 rpdChannelAmplitude = RPDChannelAmplitudeHandle(*zdcMod);
590 rpdChannelMaxADC = RPDChannelMaxADCHandle(*zdcMod);
591 rpdChannelMaxSample = RPDChannelMaxSampleHandle(*zdcMod);
592 rpdChannelAmplitudeCalib = RPDChannelAmplitudeCalibHandle(*zdcMod);
593 std::vector<float> rpdChannelPileupFitParams = RPDChannelPileupExpFitParamsHandle(*zdcMod);
594 rpdChannelPileupFitSlope = rpdChannelPileupFitParams[1];
595 rpdChannelPileupFrac = RPDChannelPileupFracHandle(*zdcMod);
597 absRpdChannelAmplitude = abs(rpdChannelAmplitude);
598 zdcEMModuleEnergySameSide = zdcEMModuleEnergyArr[iside];
599 zdcEnergySumSameSide = zdcEnergySumArr[iside];
601 rpdChannelValid = curRpdChannelValid;
602 rpdChannelValidBitFloat = (curRpdChannelValid)? 0.5 : 1.5;
603 rpdChannelCentroidValid = centroidSideValidArr.at(iside);
605 rpdAmplitudeCalibSum[iside] += rpdChannelAmplitudeCalib;
606 rpdMaxADCSum[iside] += rpdChannelMaxADC;
608 fill(
m_tools[
m_RPDChannelToolIndices.at(side_str).at(channel_str)], rpdChannelSubAmp, rpdChannelAmplitude, rpdChannelAmplitudeCalib, rpdChannelMaxADC, rpdChannelMaxSample, rpdStatusBits, rpdChannelPileupFitSlope, absRpdChannelAmplitude, rpdChannelPileupFrac, zdcEMModuleEnergySameSide, zdcEnergySumSameSide, rpdChannelValid, rpdChannelValidBitFloat, rpdChannelCentroidValid,
lumiBlock,
bcid);
621 std::array<float,2> fcalEtArr = {0.,0.};
631 for (
const auto eventShape : *eventShapes){
632 int layer = eventShape->layer();
633 float eta = eventShape->etaMin();
634 float et = eventShape->et();
652 if (!cur_event_ZDC_available && !zdcDecodingError){
653 ATH_MSG_WARNING(
"Current event has no ZDC decoding error but ZDC aux data is not available!");
655 if (!cur_event_RPD_available && !rpdDecodingError){
656 ATH_MSG_WARNING(
"Current event has no RPD decoding error but RPD aux data is not available!");
661 if (!cur_event_ZDC_available && !cur_event_RPD_available){
662 ATH_MSG_WARNING(
"For current event, neither ZDC nor RPD data are available!");
663 return StatusCode::SUCCESS;
674 fill(zdcTool,
lumiBlock,
bcid, passTrigSideA, passTrigSideC, zdcEnergySumA, zdcEnergySumC, zdcUncalibSumA, zdcUncalibSumC, fcalEtA, fcalEtC);
676 fill(zdcTool,
lumiBlock,
bcid, passTrigSideA, passTrigSideC, zdcEnergySumA, zdcEnergySumC, zdcUncalibSumA, zdcUncalibSumC);
681 fill(zdcTool, rpdCosDeltaReactionPlaneAngle, bothReactionPlaneAngleValid, bothHasCentroid);
691 for (
int iside = 0; iside <
m_nSides; iside++){
692 std::string side_str = (iside == 0)?
"C" :
"A";
707 fill(
m_tools[
m_ZDCSideToolIndices.at(side_str)], passTrigOppSide, zdcEnergySumCurSide, zdcUncalibSumCurSide, zdcEMModuleEnergyCurSide, zdcAvgTimeCurSide, zdcModuleMaskCurSide, rpdAmplitudeCalibSumCurSide, rpdMaxADCSumCurSide, rpdCurSideValid, fcalEtCurSide,
lumiBlock,
bcid);
710 for (
int iside = 0; iside <
m_nSides; iside++){
711 std::string side_str = (iside == 0)?
"C" :
"A";
724 for (
int iside = 0; iside <
m_nSides; iside++){
725 std::string side_str = (iside == 0)?
"C" :
"A";
735 return StatusCode::SUCCESS;
746 return StatusCode::SUCCESS;
759 return StatusCode::SUCCESS;
761 for (
const auto& zdcSum : *zdcSums) {
762 if (zdcSum->zdcSide() == 0){
764 ATH_MSG_WARNING(
"The global sum entry in zdc sum container can be retrieved; but it does NOT have the variable eventType written as a decoration!");
765 return StatusCode::SUCCESS;
769 ATH_MSG_WARNING(
"The global sum entry in zdc sum container can be retrieved; but it does NOT have the variable DAQMode written as a decoration!");
770 return StatusCode::SUCCESS;
773 eventType = eventTypeHandle(*zdcSum);
774 DAQMode = DAQModeHandle(*zdcSum);
781 ATH_MSG_WARNING(
"The zdc sum container can be retrieved from the evtStore() but");
782 ATH_MSG_WARNING(
"Either the event type or the DAQ mode is the default unknown value");
783 ATH_MSG_WARNING(
"Most likely, there is no global sum (side == 0) entry in the zdc sum container");
784 return StatusCode::SUCCESS;
791 ATH_MSG_WARNING(
"Event type should be PhysicsData/Simulation but it is NOT");
792 return StatusCode::SUCCESS;