15#include "CaloDetDescr/CaloDetDescrElement.h"
17#include "Identifier/Identifier.h"
38LArCellMonAlg::~LArCellMonAlg() =
default;
61 ATH_MSG_WARNING(
"UseTrigger set to true but no trigger names given! Forcing useTrigger to false");
69 ATH_MSG_ERROR(
"LayerNames and LayerNcells not of the same length, aborting.....");
70 return StatusCode::FAILURE;
84 return StatusCode::SUCCESS;
97 std::set<std::string> uniqunesCheck;
99 auto r=uniqunesCheck.insert(s);
101 ATH_MSG_ERROR(
"Configuration error: Threshold type " << s <<
" appears more than once" );
102 return StatusCode::FAILURE;
105 uniqunesCheck.clear();
108 const std::map<const std::string, const Direction> stringToDirection {{
"over",
OVER},{
"under",
UNDER},{
"both",
BOTH},{
"none",
NONE}};
109 const std::map<const std::string, const TriggerType> stringToTrigType {{
"nota",
NOTA},{
"rndm",
RNDM},{
"calo",
CALO},{
"minbias",
MINBIAS},
113 for (
size_t iThr=0;iThr<nThr;++iThr) {
122 if (itD!=stringToDirection.end()) {
126 ATH_MSG_ERROR(
"Configuration problem. Unknown threshold direction '"
129 return StatusCode::FAILURE;
133 if (itT!=stringToTrigType.end()) {
134 threshold.m_triggersToExclude.set(itT->second);
135 if (itT->first==
"all") {
ATH_MSG_WARNING(
"Setting TriggersToExclude to 'all' has no effect!" );}
138 ATH_MSG_ERROR(
"Configuration problem. Unknown trigger type '"
140 <<
"' given in propety 'TriggersToExlude'" );
141 return StatusCode::FAILURE;
145 if (itT!=stringToTrigType.end()) {
146 threshold.m_triggersToInclude.set(itT->second);
147 if (itT->first==
"none") {
ATH_MSG_WARNING(
"Setting TriggersToInclude to 'none' has no effect!" );}
150 ATH_MSG_ERROR(
"Configuration problem. Unknown trigger type '"
152 <<
"' given in propety 'TriggersToInclude'" );
153 return StatusCode::FAILURE;
175 [&](
const threshold_t&
x) {return (x.m_threshName==nameToOverwrite);}
179 ATH_MSG_ERROR(
"Configuration error reading 'ThresholdColumnType': Threshold type '" << nameToOverwrite <<
"' is not defined in 'ThresholdType'" );
180 return StatusCode::FAILURE;
183 for (
unsigned iLyr=0;iLyr<
MAXLYRNS;++iLyr) {
185 ATH_MSG_ERROR(
"Configuration error: Not enough values in threshold vector for layer " << iLyr );
186 return StatusCode::FAILURE;
197 const threshold_t& thr=*thrIt;
198 if (!(thr.m_doEtaPhiOccupancy || thr.m_doPercentageOccupancy || thr.m_doEtaOccupancy || thr.m_doPhiOccupancy || thr.m_doEtaPhiTotalEnergy ||
199 thr.m_doEtaPhiAverageQuality || thr.m_doEtaPhiFractionOverQth || thr.m_doEtaPhiAverageTime || thr.m_doEtaPhiFractionPastTth)) {
200 ATH_MSG_INFO(
"Config issue: Threshold type '" << thr.m_threshName <<
"' defined but no histograms requested. Deleting." );
204 ATH_MSG_INFO(
"Threshold histograms requested for threshold '" << thrIt->m_threshName <<
"'");
212 if (thr.m_threshDirection!=
NONE &&
213 std::count(thr.m_threshTitleTemplate.begin(),thr.m_threshTitleTemplate.end(),
'%')==1) {
214 const size_t maxTitleLenght=thr.m_threshTitleTemplate.size()+32;
215 std::unique_ptr<char[]> toBeFilled(
new char[maxTitleLenght]);
217 for (
unsigned iLyrns=0;iLyrns<
MAXLYRNS;++iLyrns) {
219 snprintf(toBeFilled.get(),maxTitleLenght,thr.m_threshTitleTemplate.c_str(),thr.m_threshValue[iLyrns]);
220 toBeFilled[maxTitleLenght-1]=
'\0';
221 thr.m_threshTitles[iLyrns]=toBeFilled.get();
227 for (
unsigned iLyrns=0;iLyrns<
MAXLYRNS;++iLyrns) {
228 thr.m_threshTitles[iLyrns]=thr.m_threshTitleTemplate;
233 return StatusCode::SUCCESS;
267 std::bitset<MAXTRIGTYPE> triggersPassed(0x1<<
NOTA);
268 constexpr std::bitset<MAXTRIGTYPE> NOTAmask=~(0x1<<
NOTA);
270 for (
unsigned i=0;i<
NOTA;++i) {
272 if(!chainName.empty()) {
275 triggersPassed.set(i);
282 for (threshold_t& thr : thresholds) {
283 thr.m_threshTriggerDecision=(thr.m_triggersToInclude & triggersPassed).any() && (thr.m_triggersToExclude & triggersPassed & NOTAmask).none();
294 for (
const threshold_t& thr : thresholds) {
295 if (thr.m_threshTriggerDecision && (passBeamBackgroundRemoval || !thr.m_doBeamBackgroundRemoval)) {
408 return StatusCode::FAILURE;
428 bool passBeamBackgroundRemoval =
true;
431 if(!ifPass and not passBeamBackgroundRemoval==
false) {
433 return StatusCode::SUCCESS;
448 std::vector<std::vector<std::vector<LArMonValues>>> monValueVec;
450 for (
size_t ilayer = 0; ilayer <
m_layerNames.size(); ++ilayer) {
451 monValueVec.emplace_back();
452 monValueVec[ilayer].reserve(thresholds.size());
453 for (
size_t ithreshold = 0; ithreshold < thresholds.size(); ++ithreshold) {
454 monValueVec[ilayer].emplace_back();
456 monValueVec[ilayer][ithreshold].reserve(
m_layerNcells[ilayer]);
460 std::vector<std::vector<float>> energies_nocut;
462 for (
size_t ilayer = 0; ilayer <
m_layerNames.size(); ++ilayer) {
463 energies_nocut.emplace_back();
467 for ( ; it!=it_e;++it) {
472 const ULong64_t monCellID =
id.get_compact();
474 if(!is_lar)
continue;
480 const float cellen = cell->energy();
481 const float celltime = cell->time();
482 const uint16_t cellquality = cell->quality();
483 const uint16_t cellprovenance = cell->provenance();
484 const bool celltqavailable = ( cellprovenance & 0x2000 );
492 float celleta,cellphi;
493 unsigned iLyr, iLyrNS;
497 auto& lvaluemap = monValueVec[iLyr];
498 for (
size_t ithr = 0; ithr < thresholds.size(); ++ithr) {
499 const auto& thr = thresholds[ithr];
505 if (
m_useTrigger && !thr.m_threshTriggerDecision)
continue;
509 if (thr.m_doBeamBackgroundRemoval && !passBeamBackgroundRemoval)
continue;
513 float thresholdVal=thr.m_threshValue[iLyrNS];
514 if (thresholdVal==0) {
518 if (thr.m_inSigNoise) thresholdVal*=noisep->
getNoise(cellHash, gain);
521 bool passThrCut(
true);
522 if (thr.m_threshDirection==
OVER && cellen <= thresholdVal) passThrCut=
false;
523 if (thr.m_threshDirection==
UNDER && cellen > thresholdVal) passThrCut=
false;
524 if (thr.m_threshDirection==
BOTH && (cellen > -thresholdVal && cellen <= thresholdVal)) passThrCut=
false;
527 bool pass_qual = (cellquality > thr.m_qualityFactorThreshold);
528 bool pass_time = (fabs(celltime) > thr.m_timeThreshold);
530 lvaluemap[ithr].push_back({celleta, cellphi, cellen, celltime, cellquality, pass_qual, pass_time, passThrCut});
532 if(!passThrCut)
continue;
539 if(passBeamBackgroundRemoval) {
541 energies_nocut[iLyr].push_back(cellen);
554 float energyThreshold;
562 if (cellen > energyThreshold) {
568 fill(
m_MonGroupName,sporadicCellE,sporadicCellTime,sporadicCellQuality,sporadicCellID,lumiBlock);
574 for (
size_t ilayer = 0; ilayer < energies_nocut.size(); ++ilayer) {
576 energies_nocut[ilayer]);
581 for (
size_t ilayer = 0; ilayer < monValueVec.size(); ++ilayer) {
582 for (
size_t ithreshold = 0; ithreshold < monValueVec[ilayer].size(); ++ithreshold) {
583 const auto& tool = monValueVec[ilayer][ithreshold];
593 passThrCut, mon_eta, mon_phi, en, mon_qual,
594 pass_qual, tim, pass_time);
599 return StatusCode::SUCCESS;
618 return StatusCode::SUCCESS;
625 return StatusCode::FAILURE;
632 for ( ; it!=it_e;++it) {
636 if(!is_lar)
continue;
638 float celleta, cellphi;
639 unsigned iLyr, iLyrNS;
651 fill(
m_MonGroupNamePerJob,badCellWord,cellnoisedb,mon_eta,mon_phi,fillBadChannelPlot,doDatabaseNoisePlot,doCellsActiveEtaPlot,doCellsActivePhiPlot);
654 return StatusCode::SUCCESS;
661 for (
const auto& c : input) {
662 output.push_back(std::tolower(c));
668 return (std::find(
vec.begin(),
vec.end(),s)!=
vec.end());
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_WARNING(x)
Definition of CaloDetDescrManager.
std::vector< size_t > vec
LArBadXCont< LArBadChannel > LArBadChannelCont
size_t size() const
Number of registered mappings.
Wrapper to avoid constant divisions when using units.
const ServiceHandle< StoreGateSvc > & detStore() const
const ToolHandle< Trig::TrigDecisionTool > & getTrigDecisionTool() const
Get the trigger decision tool member.
SG::ReadHandle< xAOD::EventInfo > GetEventInfo(const EventContext &) const
Return a ReadHandle for an EventInfo object (get run/event numbers, etc.).
ToolHandleArray< GenericMonitoringTool > m_tools
Array of Generic Monitoring Tools.
Container class for CaloCell.
Data object for each calorimeter readout cell.
This class groups all DetDescr information related to a CaloCell.
IdentifierHash calo_hash() const
cell calo hash
StatusCode checkFilters(bool &ifPass, bool &passBeamBackgroundRemoval, const std::string &MonGroupName, const EventContext &ctx) const
void getHistoCoordinates(const CaloDetDescrElement *dde, float &celleta, float &cellphi, unsigned &iLyr, unsigned &iLyrNS) const
virtual StatusCode initialize() override
initialize
const CaloCell_ID * m_calo_id
float getNoise(const IdentifierHash h, const int gain) const
Accessor by IdentifierHash and gain.
DataModel_detail::const_iterator< DataVector > const_iterator
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
This is a "hash" representation of an Identifier.
BitWord packedData() const
bool good() const
Returns true if no problems at all (all bits at zero).
LArBC_t offlineStatus(const Identifier id) const
Query the status of a particular channel by offline ID This is the main client access method.
StatusCode createPerJobHistograms(const CaloCellContainer *cellcont, const CaloNoise *noisep) const
std::map< std::string, std::map< std::string, int > > m_toolmapAll
virtual StatusCode fillHistograms(const EventContext &ctx) const override final
adds event to the monitoring histograms
BooleanProperty m_doEnergyVsTime
StringArrayProperty m_thresholdNameProp
Gaudi::Property< std::vector< std::string > > m_problemsToMask
BooleanProperty m_useTrigger
const std::array< PartitionEnum, MAXLAYER > m_layerEnumtoPartitionEnum
FloatArrayProperty m_timeThresholdProp
BooleanProperty m_doDatabaseNoiseVsEtaPhi
StringArrayProperty m_doEtaOccupancyNames
std::vector< threshold_t > m_thresholds
std::array< FloatArrayProperty, MAXLYRNS > m_thresholdsProp
StringArrayProperty m_doEtaPhiAvgTimeNames
BooleanProperty m_ignoreKnownBadChannels
StringArrayProperty m_doEtaPhiTotalOccupancyNames
BooleanProperty m_doKnownBadChannelsVsEtaPhi
FloatArrayProperty m_eCutForTiming
SG::ReadCondHandleKey< LArOnOffIdMapping > m_cablingKey
Gaudi::Property< std::string > m_MonGroupNamePerJob
FloatProperty m_threshold_em_S0S1
BooleanArrayProperty m_inSigNoise
StringArrayProperty m_thresholdColumnType
StringArrayProperty m_doEtaPhiAvgQualityNames
virtual StatusCode initialize() override final
initialize
BooleanProperty m_maskNoCondChannels
StringArrayProperty m_doEtaPhiTotEnergyNames
StringArrayProperty m_doEtaPhiFractionPastTthNames
static std::string strToLower(const std::string &input)
LArCellMonAlg(const std::string &name, ISvcLocator *pSvcLocator)
BooleanProperty m_sporadic_switch
StringArrayProperty m_thresholdTitleTemplates
LArBadChannelMask m_bcMask
FloatArrayProperty m_defaultThresholds
StringArrayProperty m_thresholdDirectionProp
SG::ReadCondHandleKey< CaloNoise > m_noiseCDOKey
StringArrayProperty m_triggersToIncludeProp
StringArrayProperty m_doEtaPhiFractionOverQthNames
std::array< StringProperty, NOTA > m_triggerNames
BooleanArrayProperty m_doBeamBackgroundRemovalProp
StringArrayProperty m_layerNames
FloatArrayProperty m_qualityFactorThresholdProp
static bool isThrListed(const std::vector< std::string > &vec, const std::string &s)
SG::ReadCondHandleKey< LArBadChannelCont > m_BCKey
Gaudi::Property< std::string > m_MonGroupName
IntegerArrayProperty m_layerNcells
void checkTriggerAndBeamBackground(bool passBeamBackgroundRemoval, std::vector< threshold_t > &thresholds) const
StringArrayProperty m_partitionNames
SG::ReadHandleKey< CaloCellContainer > m_cellContainerKey
const LArOnlineID * m_LArOnlineIDHelper
StringArrayProperty m_doEtaPhiPercentageOccupancyNames
FloatProperty m_threshold_HECFCALEMS2S3
StringArrayProperty m_doPhiOccupancyNames
StringArrayProperty m_triggersToExcludeProp
Declare a monitored scalar variable.
const_pointer_type cptr()
Dereference the pointer.
bool isPassed(unsigned int condition=TrigDefs::Physics) const
tells if chain group passed
std::vector< V > buildToolMap(const ToolHandleArray< GenericMonitoringTool > &tools, const std::string &baseName, int nHist)
Builds an array of indices (base case).
ValuesCollection< T > Collection(std::string name, const T &collection)
Declare a monitored (double-convertible) collection.
void fill(H5::Group &out_file, size_t iterations)