9 #include <top/modules/TOPChannelMasker/TOPChannelMaskerModule.h>
10 #include <top/reconstruction_cpp/TOPRecoManager.h>
11 #include <top/geometry/TOPGeometryPar.h>
35 setDescription(
"Masks dead, hot and uncalibrated channels from the reconstruction");
38 setPropertyFlags(c_ParallelProcessingCertified);
41 addParam(
"maskUncalibratedChannelT0", m_maskUncalibratedChannelT0,
42 "if true, mask channelT0-uncalibrated channels",
true);
43 addParam(
"maskUncalibratedTimebase", m_maskUncalibratedTimebase,
44 "if true, mask timebase-uncalibrated channels ",
true);
47 void TOPChannelMaskerModule::initialize()
50 m_digits.isRequired();
51 m_eventAsicMask.isOptional();
54 void TOPChannelMaskerModule::beginRun()
57 if (not m_channelMask.isValid()) {
58 B2FATAL(
"channel mask not available");
60 if (not m_channelT0.isValid()) {
61 B2FATAL(
"channel T0 calibration not available");
63 if (not m_timebase.isValid()) {
64 B2FATAL(
"timebase calibration not available");
69 void TOPChannelMaskerModule::event()
74 bool pmtInstalled = m_pmtInstalled.hasChanged();
75 bool pmtQEData = m_pmtQEData.hasChanged();
76 bool channelRQE = m_channelRQE.hasChanged();
77 bool thresholdEff = m_thresholdEff.hasChanged();
81 if (pmtInstalled or pmtQEData or channelRQE or thresholdEff) {
82 TOPRecoManager::setChannelEffi();
87 bool asicMasksChanged =
false;
88 if (m_eventAsicMask.isValid()) {
89 if (m_eventAsicMask->get() != m_savedAsicMask.get()) {
90 m_savedAsicMask.set(m_eventAsicMask->get());
91 asicMasksChanged =
true;
97 bool channelMaskChanged = m_channelMask.hasChanged();
98 bool channelT0Changed = m_channelT0.hasChanged();
99 bool timebaseChanged = m_timebase.hasChanged();
103 if (channelMaskChanged or asicMasksChanged or
104 (m_maskUncalibratedChannelT0 and channelT0Changed) or
105 (m_maskUncalibratedTimebase and timebaseChanged)) {
107 TOPRecoManager::setChannelMask(m_channelMask, m_savedAsicMask);
108 if (m_maskUncalibratedChannelT0) {
109 TOPRecoManager::setUncalibratedChannelsOff(m_channelT0);
111 if (m_maskUncalibratedTimebase) {
112 TOPRecoManager::setUncalibratedChannelsOff(m_timebase);
118 for (
auto& digit : m_digits) {
120 if (digit.getHitQuality() == TOPDigit::c_Masked or
121 digit.getHitQuality() == TOPDigit::c_Uncalibrated) {
122 digit.setHitQuality(TOPDigit::c_Good);
124 if (digit.getHitQuality() != TOPDigit::c_Good)
continue;
127 auto slotID = digit.getModuleID();
128 auto channel = digit.getChannel();
129 if (not m_channelMask->isActive(slotID, channel)) {
130 digit.setHitQuality(TOPDigit::c_Masked);
133 if (m_maskUncalibratedChannelT0 and not m_channelT0->isCalibrated(slotID, channel)) {
134 digit.setHitQuality(TOPDigit::c_Uncalibrated);
137 if (m_maskUncalibratedTimebase) {
138 const auto& fe_mapper = TOPGeometryPar::Instance()->getFrontEndMapper();
139 const auto* fe = fe_mapper.getMap(slotID, channel / 128);
141 B2ERROR(
"No front-end map found" <<
LogVar(
"slotID", slotID) <<
LogVar(
"channel", channel));
142 digit.setHitQuality(TOPDigit::c_Uncalibrated);
145 auto scrodID = fe->getScrodID();
146 const auto* sampleTimes = m_timebase->getSampleTimes(scrodID, channel);
147 if (not sampleTimes->isCalibrated()) {
148 digit.setHitQuality(TOPDigit::c_Uncalibrated);
Masks dead PMs from the reconstruction.
Class to store variables with their name which were sent to the logging service.
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Abstract base class for different kinds of events.