13 #include <top/modules/TOPChannelMasker/TOPChannelMaskerModule.h>
14 #include <top/reconstruction/TOPreco.h>
15 #include <top/reconstruction/TOPconfigure.h>
39 setDescription(
"Masks dead PMs from the reconstruction");
42 setPropertyFlags(c_ParallelProcessingCertified);
45 addParam(
"printMask", m_printMask,
46 "if true, print channel mask as set in reconstruction",
false);
47 addParam(
"maskUncalibratedChannelT0", m_maskUncalibratedChannelT0,
48 "if true, mask channelT0-uncalibrated channels",
true);
49 addParam(
"maskUncalibratedTimebase", m_maskUncalibratedTimebase,
50 "if true, mask timebase-uncalibrated channels ",
true);
53 void TOPChannelMaskerModule::initialize()
56 m_digits.isRequired();
57 m_eventAsicMask.isOptional();
63 void TOPChannelMaskerModule::beginRun()
66 if (not m_channelMask.isValid()) {
67 B2FATAL(
"channel mask not available");
69 if (not m_channelT0.isValid()) {
70 B2FATAL(
"channel T0 calibration not available");
72 if (not m_timebase.isValid()) {
73 B2FATAL(
"timebase calibration not available");
78 void TOPChannelMaskerModule::event()
83 bool pmtInstalled = m_pmtInstalled.hasChanged();
84 bool pmtQEData = m_pmtQEData.hasChanged();
85 bool channelRQE = m_channelRQE.hasChanged();
86 bool thresholdEff = m_thresholdEff.hasChanged();
90 if (pmtInstalled or pmtQEData or channelRQE or thresholdEff) {
91 TOPreco::setChannelEffi();
96 bool asicMasksChanged =
false;
97 if (m_eventAsicMask.isValid()) {
98 if (m_eventAsicMask->get() != m_savedAsicMask.get()) {
99 m_savedAsicMask.set(m_eventAsicMask->get());
100 asicMasksChanged =
true;
106 bool channelMaskChanged = m_channelMask.hasChanged();
107 bool channelT0Changed = m_channelT0.hasChanged();
108 bool timebaseChanged = m_timebase.hasChanged();
112 if (channelMaskChanged or asicMasksChanged or
113 (m_maskUncalibratedChannelT0 and channelT0Changed) or
114 (m_maskUncalibratedTimebase and timebaseChanged)) {
116 TOPreco::setChannelMask(m_channelMask, m_savedAsicMask);
117 if (m_maskUncalibratedChannelT0) TOPreco::setUncalibratedChannelsOff(m_channelT0);
118 if (m_maskUncalibratedTimebase) TOPreco::setUncalibratedChannelsOff(m_timebase);
119 if (m_printMask) TOPreco::printChannelMask();
124 for (
auto& digit : m_digits) {
126 if (digit.getHitQuality() == TOPDigit::c_Masked or
127 digit.getHitQuality() == TOPDigit::c_Uncalibrated) {
128 digit.setHitQuality(TOPDigit::c_Good);
131 if (digit.getHitQuality() != TOPDigit::c_Good)
continue;
133 if (not m_channelMask->isActive(digit.getModuleID(), digit.getChannel())) {
134 digit.setHitQuality(TOPDigit::c_Masked);
136 if (m_maskUncalibratedChannelT0 and not digit.isChannelT0Calibrated()) {
137 digit.setHitQuality(TOPDigit::c_Uncalibrated);
139 if (m_maskUncalibratedTimebase and not digit.isTimeBaseCalibrated()) {
140 digit.setHitQuality(TOPDigit::c_Uncalibrated);