20 : params_(
params), firstCallEB_(
true), firstCallEE_(
true), iEvent_(1) {
40 if (
params.getParameter<
bool>(
"configFromCondDB")) {
45 edm::LogWarning(
"EcalSelectiveReadout") <<
"Parameter configFromCondDB of EcalSelectiveReadout module not found. "
46 "Selective readout configuration will be read from python file.";
79 hSr_token_ = esConsumes<EcalSRSettings, EcalSRSettingsRcd>();
81 geom_token_ = esConsumes<CaloGeometry, CaloGeometryRecord>();
82 eTTmap_token_ = esConsumes<EcalTrigTowerConstituentsMap, IdealGeometryRecord>();
110 unique_ptr<EBDigiCollection> selectedEBDigis;
111 unique_ptr<EEDigiCollection> selectedEEDigis;
112 unique_ptr<EBSrFlagCollection> ebSrFlags;
113 unique_ptr<EESrFlagCollection> eeSrFlags;
116 selectedEBDigis = std::make_unique<EBDigiCollection>();
117 selectedEEDigis = std::make_unique<EEDigiCollection>();
121 ebSrFlags = std::make_unique<EBSrFlagCollection>();
122 eeSrFlags = std::make_unique<EESrFlagCollection>();
142 selectedEBDigis.get(),
143 selectedEEDigis.get(),
153 suppressor_->getEcalSelectiveReadout()->printHeader(srfFile);
155 srfFile <<
"# Event " <<
iEvent_ <<
"\n";
156 suppressor_->getEcalSelectiveReadout()->print(srfFile);
180 event.getByToken(
EB_token, hEBDigis);
193 event.getByToken(
EE_token, hEEDigis);
247 const char tccFlagMarker[] = {
'x',
'.',
'S',
'?',
'C',
'E',
'E',
'E',
'E'};
254 os <<
"# TCC flag map\n#\n"
257 <<
": 000 (low interest)\n"
260 <<
": 001 (mid interest)\n"
263 <<
": 010 (not valid)\n"
266 <<
": 011 (high interest)\n"
269 <<
": 1xx forced readout (Hw error)\n"
273 vector<vector<int> > ttf(
nEta, vector<int>(
nPhi, -1));
276 if (trigPrim.
size() > 0) {
279 int iPhi0 = trigPrim.
id().
iphi() - 1;
280 ttf[iEta0][iPhi0] = trigPrim.
ttFlag();
284 for (
int iPhi = 0; iPhi <
nPhi; ++iPhi) {
295 static std::atomic<bool> warnWeightCnt{
true};
296 bool expected =
true;
297 if ((
int)
weights.size() > nFIRTaps &&
298 warnWeightCnt.compare_exchange_strong(expected,
false, std::memory_order_acq_rel)) {
299 edm::LogWarning(
"Configuration") <<
"The list of DCC zero suppression FIR "
300 "weights given in parameter dccNormalizedWeights is longer "
301 "than the expected depth of the FIR filter :("
304 "The last weights will be discarded.";
309 double maxWeight =
weights[iMaxWeight];
311 for (
unsigned i = 0;
i <
weights.size(); ++
i) {
314 maxWeight =
weights[iMaxWeight];
326 if (rc && maxWeightBin != binOfMax) {
327 edm::LogWarning(
"Configuration") <<
"The maximum weight of DCC zero suppression FIR filter is not "
328 "applied to the expected maximum sample("
330 << (binOfMax == 1 ?
"st"
331 : (binOfMax == 2 ?
"nd" : (binOfMax == 3 ?
"rd" :
"th")))
332 <<
" time sample). This may indicate faulty 'dccNormalizedWeights' "
333 "or 'ecalDccZs1sSample' parameters.";
340 int& binOfMax)
const {
344 vector<string> ebDigiParamList =
result.getParameterNames();
345 string bofm(
"binOfMaximum");
346 if (
find(ebDigiParamList.begin(), ebDigiParamList.end(), bofm) != ebDigiParamList.end()) {
347 binOfMax =
result.getParameter<
int>(
"binOfMaximum");
360 const char srpFlagMarker[] = {
'.',
'z',
'Z',
'F',
'4',
'5',
'6',
'7'};
364 const char* date = ctime(&
t);
365 os <<
"#SRP flag map\n#\n"
380 <<
": full readout\n"
415 os <<
"# Event " <<
iEvent <<
"\n";
423 for (
size_t i = 0;
i <
sizeof(eeSrf) /
sizeof(
int); ((
int*)eeSrf)[
i++] = -1) {
427 int iZ0 =
flag.id().zside() > 0 ? 1 : 0;
428 int iX0 =
flag.id().ix() - 1;
429 int iY0 =
flag.id().iy() - 1;
431 assert(iX0 >= 0 && iX0 < nScX);
432 assert(iY0 >= 0 && iY0 < nScY);
433 eeSrf[iZ0][iX0][iY0] =
flag.value();
435 const int nEbTtEta = 34;
436 const int nEeTtEta = 11;
437 const int nTtEta = nEeTtEta * 2 + nEbTtEta;
438 const int nTtPhi = 72;
439 int ebSrf[nEbTtEta][nTtPhi];
440 for (
size_t i = 0;
i <
sizeof(ebSrf) /
sizeof(
int); ((
int*)ebSrf)[
i++] = -1) {
445 int iEta0 =
iEta + nTtEta / 2 - (
iEta >= 0 ? 1 : 0);
446 int iEbEta0 = iEta0 - nEeTtEta;
447 int iPhi0 =
flag.id().iphi() - 1;
448 assert(iEbEta0 >= 0 && iEbEta0 < nEbTtEta);
449 assert(iPhi0 >= 0 && iPhi0 < nTtPhi);
456 ebSrf[iEbEta0][iPhi0] =
flag.value();
462 for (
int iX0 = 0; iX0 < nScX; ++iX0) {
463 for (
int iY0 = 0; iY0 < nScY; ++iY0) {
464 int srFlag = eeSrf[0][iX0][iY0];
472 for (
int iEta0 = 0; iEta0 < nEbTtEta; ++iEta0) {
473 for (
int iPhi0 = 0; iPhi0 < nTtPhi; ++iPhi0) {
474 int srFlag = ebSrf[iEta0][iPhi0];
482 for (
int iX0 = 0; iX0 < nScX; ++iX0) {
483 for (
int iY0 = 0; iY0 < nScY; ++iY0) {
484 int srFlag = eeSrf[1][iX0][iY0];
498 <<
"Selective readout emulator, EcalSelectiveReadout, supports only single set of ZS weights. "
499 "while the configuration contains "
515 <<
"Inconsistency between number of weigth sets (" << settings.
dccNormalizedWeights_.size() <<
") and "