15 #include "CaloDetDescr/CaloDetDescrElement.h"
17 #include "Identifier/Identifier.h"
34 m_LArOnlineIDHelper(nullptr)
91 ATH_MSG_WARNING(
"UseTrigger set to true but no trigger names given! Forcing useTrigger to false");
99 ATH_MSG_ERROR(
"LayerNames and LayerNcells not of the same length, aborting.....");
100 return StatusCode::FAILURE;
114 return StatusCode::SUCCESS;
127 std::set<std::string> uniqunesCheck;
129 auto r=uniqunesCheck.insert(
s);
131 ATH_MSG_ERROR(
"Configuration error: Threshold type " <<
s <<
" appears more than once" );
132 return StatusCode::FAILURE;
135 uniqunesCheck.clear();
138 const std::map<const std::string, const Direction> stringToDirection {{
"over",
OVER},{
"under",
UNDER},{
"both",
BOTH},{
"none",
NONE}};
139 const std::map<const std::string, const TriggerType> stringToTrigType {{
"nota",
NOTA},{
"rndm",
RNDM},{
"calo",
CALO},{
"minbias",
MINBIAS},
143 for (
size_t iThr=0;iThr<nThr;++iThr) {
152 if (itD!=stringToDirection.end()) {
156 ATH_MSG_ERROR(
"Configuration problem. Unknown threshold direction '"
159 return StatusCode::FAILURE;
163 if (itT!=stringToTrigType.end()) {
164 threshold.m_triggersToExclude.set(itT->second);
165 if (itT->first==
"all") {
ATH_MSG_WARNING(
"Setting TriggersToExclude to 'all' has no effect!" );}
168 ATH_MSG_ERROR(
"Configuration problem. Unknown trigger type '"
170 <<
"' given in propety 'TriggersToExlude'" );
171 return StatusCode::FAILURE;
175 if (itT!=stringToTrigType.end()) {
176 threshold.m_triggersToInclude.set(itT->second);
177 if (itT->first==
"none") {
ATH_MSG_WARNING(
"Setting TriggersToInclude to 'none' has no effect!" );}
180 ATH_MSG_ERROR(
"Configuration problem. Unknown trigger type '"
182 <<
"' given in propety 'TriggersToInclude'" );
183 return StatusCode::FAILURE;
205 [&](
const threshold_t&
x) {return (x.m_threshName==nameToOverwrite);}
209 ATH_MSG_ERROR(
"Configuration error reading 'ThresholdColumnType': Threshold type '" << nameToOverwrite <<
"' is not defined in 'ThresholdType'" );
210 return StatusCode::FAILURE;
213 for (
unsigned iLyr=0;iLyr<
MAXLYRNS;++iLyr) {
215 ATH_MSG_ERROR(
"Configuration error: Not enough values in threshold vector for layer " << iLyr );
216 return StatusCode::FAILURE;
230 ATH_MSG_INFO(
"Config issue: Threshold type '" << thr.
m_threshName <<
"' defined but no histograms requested. Deleting." );
234 ATH_MSG_INFO(
"Threshold histograms requested for threshold '" << thrIt->m_threshName <<
"'");
242 if (thr.m_threshDirection!=
NONE &&
243 std::count(thr.m_threshTitleTemplate.begin(),thr.m_threshTitleTemplate.end(),
'%')==1) {
244 const size_t maxTitleLenght=thr.m_threshTitleTemplate.size()+32;
245 std::unique_ptr<char[]> toBeFilled(
new char[maxTitleLenght]);
247 for (
unsigned iLyrns=0;iLyrns<
MAXLYRNS;++iLyrns) {
249 snprintf(toBeFilled.get(),maxTitleLenght,thr.m_threshTitleTemplate.c_str(),thr.m_threshValue[iLyrns]);
250 toBeFilled[maxTitleLenght-1]=
'\0';
251 thr.m_threshTitles[iLyrns]=toBeFilled.get();
257 for (
unsigned iLyrns=0;iLyrns<
MAXLYRNS;++iLyrns) {
258 thr.m_threshTitles[iLyrns]=thr.m_threshTitleTemplate;
263 return StatusCode::SUCCESS;
297 std::bitset<MAXTRIGTYPE> triggersPassed(0
x1<<
NOTA);
298 constexpr std::bitset<MAXTRIGTYPE> NOTAmask=~(0x1<<
NOTA);
300 for (
unsigned i=0;
i<
NOTA;++
i) {
305 triggersPassed.set(
i);
313 thr.m_threshTriggerDecision=(thr.m_triggersToInclude & triggersPassed).any() && (thr.m_triggersToExclude & triggersPassed & NOTAmask).
none();
325 if (thr.m_threshTriggerDecision && (passBeamBackgroundRemoval || !thr.m_doBeamBackgroundRemoval)) {
438 return StatusCode::FAILURE;
458 bool passBeamBackgroundRemoval =
true;
460 if(!ifPass)
return StatusCode::SUCCESS;
474 std::vector<std::vector<std::vector<LArMonValues>>> monValueVec;
476 for (
size_t ilayer = 0; ilayer <
m_layerNames.size(); ++ilayer) {
477 monValueVec.emplace_back();
478 monValueVec[ilayer].reserve(thresholds.size());
479 for (
size_t ithreshold = 0; ithreshold < thresholds.size(); ++ithreshold) {
480 monValueVec[ilayer].emplace_back();
482 monValueVec[ilayer][ithreshold].reserve(
m_layerNcells[ilayer]);
486 std::vector<std::vector<float>> energies_nocut;
488 for (
size_t ilayer = 0; ilayer <
m_layerNames.size(); ++ilayer) {
489 energies_nocut.emplace_back();
493 for ( ;
it!=it_e;++
it) {
498 const ULong64_t monCellID =
id.get_compact();
500 if(!is_lar)
continue;
506 const float cellen =
cell->energy();
507 const float celltime =
cell->time();
510 const bool celltqavailable = ( cellprovenance & 0x2000 );
518 float celleta,cellphi;
519 unsigned iLyr, iLyrNS;
523 auto& lvaluemap = monValueVec[iLyr];
524 for (
size_t ithr = 0; ithr < thresholds.size(); ++ithr) {
525 const auto& thr = thresholds[ithr];
531 if (
m_useTrigger && !thr.m_threshTriggerDecision)
continue;
535 if (thr.m_doBeamBackgroundRemoval && !passBeamBackgroundRemoval)
continue;
539 float thresholdVal=thr.m_threshValue[iLyrNS];
540 if (thresholdVal==0) {
547 bool passThrCut(
true);
548 if (thr.m_threshDirection==
OVER && cellen <= thresholdVal) passThrCut=
false;
549 if (thr.m_threshDirection==
UNDER && cellen > thresholdVal) passThrCut=
false;
550 if (thr.m_threshDirection==
BOTH && (cellen > -thresholdVal && cellen <= thresholdVal)) passThrCut=
false;
553 bool pass_qual = (cellquality > thr.m_qualityFactorThreshold);
554 bool pass_time = (fabs(celltime) > thr.m_timeThreshold);
556 lvaluemap[ithr].push_back({celleta, cellphi, cellen, celltime, cellquality, pass_qual, pass_time, passThrCut});
558 if(!passThrCut)
continue;
565 if(passBeamBackgroundRemoval) {
567 energies_nocut[iLyr].push_back(cellen);
580 float energyThreshold;
588 if (cellen > energyThreshold) {
600 for (
size_t ilayer = 0; ilayer < energies_nocut.size(); ++ilayer) {
602 energies_nocut[ilayer]);
607 for (
size_t ilayer = 0; ilayer < monValueVec.size(); ++ilayer) {
608 for (
size_t ithreshold = 0; ithreshold < monValueVec[ilayer].size(); ++ithreshold) {
609 const auto&
tool = monValueVec[ilayer][ithreshold];
619 passThrCut, mon_eta, mon_phi,
en, mon_qual,
620 pass_qual, tim, pass_time);
625 return StatusCode::SUCCESS;
644 return StatusCode::SUCCESS;
651 return StatusCode::FAILURE;
658 for ( ;
it!=it_e;++
it) {
662 if(!is_lar)
continue;
664 float celleta, cellphi;
665 unsigned iLyr, iLyrNS;
671 const LArBadChannel larBadChannel = bcCont->offlineStatus(
id);
677 fill(
m_MonGroupNamePerJob,badCellWord,cellnoisedb,mon_eta,mon_phi,fillBadChannelPlot,doDatabaseNoisePlot,doCellsActiveEtaPlot,doCellsActivePhiPlot);
680 return StatusCode::SUCCESS;
687 for (
const auto&
c :
input) {