15#include "CaloDetDescr/CaloDetDescrElement.h"
17#include "Identifier/Identifier.h"
68LArCellMonAlg::~LArCellMonAlg() =
default;
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;
227 const threshold_t& thr=*thrIt;
228 if (!(thr.m_doEtaPhiOccupancy || thr.m_doPercentageOccupancy || thr.m_doEtaOccupancy || thr.m_doPhiOccupancy || thr.m_doEtaPhiTotalEnergy ||
229 thr.m_doEtaPhiAverageQuality || thr.m_doEtaPhiFractionOverQth || thr.m_doEtaPhiAverageTime || thr.m_doEtaPhiFractionPastTth)) {
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(0x1<<
NOTA);
298 constexpr std::bitset<MAXTRIGTYPE> NOTAmask=~(0x1<<
NOTA);
300 for (
unsigned i=0;i<
NOTA;++i) {
302 if(!chainName.empty()) {
305 triggersPassed.set(i);
312 for (threshold_t& thr : thresholds) {
313 thr.m_threshTriggerDecision=(thr.m_triggersToInclude & triggersPassed).any() && (thr.m_triggersToExclude & triggersPassed & NOTAmask).none();
324 for (
const threshold_t& thr : thresholds) {
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();
508 const uint16_t cellquality = cell->quality();
509 const uint16_t cellprovenance = cell->provenance();
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) {
544 if (thr.m_inSigNoise) thresholdVal*=noisep->
getNoise(cellHash, gain);
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) {
594 fill(
m_MonGroupName,sporadicCellE,sporadicCellTime,sporadicCellQuality,sporadicCellID,lumiBlock);
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;
677 fill(
m_MonGroupNamePerJob,badCellWord,cellnoisedb,mon_eta,mon_phi,fillBadChannelPlot,doDatabaseNoisePlot,doCellsActiveEtaPlot,doCellsActivePhiPlot);
680 return StatusCode::SUCCESS;
687 for (
const auto& c : input) {
688 output.push_back(std::tolower(c));
694 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
Wrapper to avoid constant divisions when using units.
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
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
virtual StatusCode initialize()
initialize
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
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
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
BooleanArrayProperty m_doBeamBackgroundRemovalProp
StringProperty m_triggerNames[NOTA]
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
FloatArrayProperty m_thresholdsProp[MAXLYRNS]
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)