3 #include <fwk/CentralConfig.h>
4 #include <det/VManager.h>
5 #include <utl/Branch.h>
7 #include <sevt/SEvent.h>
8 #include <sevt/Station.h>
9 #include <utl/TimeStamp.h>
11 #include <sevt/PMTQuality.h>
12 #include <sdet/PMTConstants.h>
23 namespace SdPMTQualityCheckerKG {
27 IsInRange(
const double x,
const pair<double, double>& r)
29 return r.first <= x && x <= r.second;
37 return r.first >= 0 && r.second >= 0 && r.first < r.second;
44 const auto topB = CentralConfig::GetInstance()->GetTopBranch(
"SdPMTQualityChecker");
46 topB.GetChild(
"verbose").GetData(fVerbose);
48 const auto calibratorBranch = topB.GetChild(
"calibratorBranch").Get<
string>();
49 const auto calibTopB = CentralConfig::GetInstance()->GetTopBranch(calibratorBranch);
50 calibTopB.GetChild(
"peakOnlineToVEMFactor").GetData(fPeakOnlineToVEMFactor);
52 topB.GetChild(
"validGainRatioRange").GetData(fValidGainRatioRange);
53 topB.GetChild(
"validVEMPeakRange").GetData(fValidVEMPeakRange);
54 topB.GetChild(
"maxSigmaBaseline").GetData(fMaxSigmaBaseline);
57 ERROR(
"error in <validGainRatioRange>");
62 ERROR(
"error in <validVEMPeakRange>");
66 if (fMaxSigmaBaseline < 0) {
67 ERROR(
"error in <maxSigmaBaseline>");
76 SdPMTQualityChecker::Run(
Event& event)
90 auto& sEvent =
event.GetSEvent();
94 for (
auto& station : sEvent.StationsRange()) {
102 const unsigned int sId = station.GetId();
106 for (
auto& pmt : station.PMTsRange()) {
108 if (!pmt.HasCalibData())
110 auto& pmtCalib = pmt.GetCalibData();
114 const unsigned int pmtId = pmt.GetId();
117 if (pmt.HasQuality()) {
118 const auto& pmtQuality = pmt.GetQuality();
119 if (!pmtQuality.IsTubeOk()) {
120 pmtCalib.SetIsTubeOk(
false);
121 info <<
"\nFlagging whole PMT " << pmtId <<
" of station " << sId
122 <<
" as bad (reason: Auger event PMT quality flag).";
124 if (!pmtQuality.HasAnode()) {
125 pmtCalib.SetIsLowGainOk(
false);
126 info <<
"\nFlagging anode (LG) of PMT " << pmtId <<
" of station " << sId
127 <<
" as bad (reason: Auger event PMT quality flag).";
132 if (pmt.HasRecData())
133 daRatio = pmt.GetRecData().GetGainRatio();
135 const int calibVersion = station.GetCalibData().GetVersion();
138 daRatio = pmtCalib.GetGainRatio() / (calibVersion == 12 ? 1.07 : 1);
141 if (!
IsInRange(daRatio, fValidGainRatioRange)) {
142 info <<
"\nFlagging anode (LG) of PMT " << pmtId <<
" of station " << sId
143 <<
" as bad (reason: D/A out of allowed range).";
144 pmtCalib.SetIsLowGainOk(
false);
147 const double vemPeak = pmtCalib.GetOnlinePeak() * fPeakOnlineToVEMFactor;
149 if (!
IsInRange(vemPeak, fValidVEMPeakRange)) {
150 info <<
"\nFlagging whole PMT " << pmtId <<
" of station " << sId
151 <<
" as bad (reason: vemPeak out of allowed range).";
152 pmtCalib.SetIsTubeOk(
false);
155 if (pmtCalib.GetBaselineRMS() > fMaxSigmaBaseline) {
156 info <<
"\nFlagging whole PMT " << pmtId <<
" of station " << sId
157 <<
" as bad (reason: sigma baseline above allowed limit).";
158 pmtCalib.SetIsTubeOk(
false);
161 if (pmtCalib.IsTubeOk())
165 if (allbad && hasCalib > 0) {
166 info <<
"\nRejecting station " << sId <<
" because all PMTs are flagged as bad.";
173 const string mess = info.str();
175 INFO(
"Applying PMT quality flags according to information in the raw event:" + mess);
#define INFO(message)
Macro for logging informational messages.
void Init()
Initialise the registry.
bool IsValidPositiveRange(const pair< double, double > &r)
ResultFlag
Flag returned by module methods to the RunController.
bool IsInRange(const double x, const vector< double > &r)
#define ERROR(message)
Macro for logging error messages.