ATLAS Offline Software
Loading...
Searching...
No Matches
HLTCaloGlobalCellMonitor.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
6
15#include <memory>
16#include <cmath>
17
18HLTCaloGlobalCellMonitor::HLTCaloGlobalCellMonitor(std::string const& name, ISvcLocator* pSvcLocator)
19 : AthReentrantAlgorithm(name, pSvcLocator) {
20}
21
23
24 ATH_CHECK( detStore()->retrieve(m_onlineId,"LArOnlineID") );
25 ATH_CHECK( detStore()->retrieve(m_caloCell_ID) );
26 ATH_CHECK( m_onOffIdMappingKey.initialize() );
27 ATH_CHECK(m_noiseCDOKey.initialize());
29 if (!m_moniTool.empty()) {
30 ATH_CHECK(m_moniTool.retrieve());
31 }
32 m_layerNames.reserve(25);
33 for(size_t i=0;i<25; i++) {
34 std::string number("layer");
35 number+=std::to_string(i);
36 m_layerNames.push_back(std::move(number));
37 }
38 m_layerNamesIW.reserve(2);
39 for(size_t i=0;i<2; i++) {
40 std::string number("layerIW");
41 number+=std::to_string(i+1);
42 m_layerNamesIW.push_back(std::move(number));
43 }
44
45 return StatusCode::SUCCESS;
46}
47
48StatusCode HLTCaloGlobalCellMonitor::execute(EventContext const& context) const {
49 ATH_MSG_DEBUG("HLTCaloGlobalCellMonitor::execute()");
50
52
54 const CaloNoise* noiseCDO=*noiseHdl;
56
57 const auto bcid = context.eventID().bunch_crossing_id();
58
59 uint32_t n_febs = m_onlineId->febHashMax();
60 std::map<HWIdentifier,uint32_t> cells_per_feb;
61 for(uint32_t i=0;i<n_febs;i++){
62 HWIdentifier feb_id = m_onlineId->feb_Id(IdentifierHash(i));
63 cells_per_feb[feb_id]=0;
64 }
65
66 auto mon_bcid = Monitored::Scalar<int>("BCID",0);
67 auto mon_inputSize = Monitored::Scalar<int>("inputContSize", 0);
68 auto mon_outputSize = Monitored::Scalar<int>("outputContSize", 0);
69 auto mon_larSize = Monitored::Scalar<int>("larContSize", 0);
70 auto mon_larAboveSigmaSize = Monitored::Scalar<int>("larAboveSigmaContSize", 0);
71
72
73 std::vector<uint32_t> febID;
74 febID.reserve(2000);
75 std::vector<uint32_t> cellCount;
76 cellCount.reserve(2000);
77 std::vector<uint32_t> cellCountPerLayer[25];
78 for(size_t i=0;i<25;i++)cellCountPerLayer[i].reserve(200);
79 std::vector<uint32_t> cellCountPerLayerIW[2];
80 for(size_t i=0;i<2;i++)cellCountPerLayerIW[i].reserve(200);
81 int larSize=0;
82 int larAboveSizeSize=0;
83 int outputSize=0;
84
85 for (auto const* cell : *inputCellHandle) {
86 if (!cell->caloDDE()->is_tile() ){
87 larSize++;
88 Identifier cellID = cell->ID();
89 float noiseSigma = noiseCDO->getNoise(cellID,cell->gain());
90 IdentifierHash offhashid = m_caloCell_ID->calo_cell_hash(cellID);
91 HWIdentifier hwid = (*onoff)->createSignalChannelIDFromHash(offhashid);
92 HWIdentifier hwid_feb = m_onlineId->feb_Id(hwid);
93 uint32_t ncells_in_feb = cells_per_feb[hwid_feb];
94 if (cell->energy() > m_NumberOfSigma*noiseSigma) {
95 larAboveSizeSize++;
96 if( ncells_in_feb < m_MaxNCellsPerFEB ) {
97 cells_per_feb[hwid_feb]=ncells_in_feb+1;
98 outputSize++;
99 }
100 }
101 } else outputSize++;
102 }
103 for(uint32_t i=0;i<n_febs;i++){
104 HWIdentifier feb_id = m_onlineId->feb_Id(IdentifierHash(i));
105 febID.push_back( feb_id.get_identifier32().get_compact() );
106 HWIdentifier hw = m_onlineId->channel_Id(feb_id,0); // first channel layer
107 Identifier id = (*onoff)->cnvToIdentifier(hw);
108 cellCount.push_back(cells_per_feb[feb_id]);
109 int calosample = m_caloCell_ID->calo_sample(id);
110 if (calosample < 5 ) {
111 cellCountPerLayer[calosample].push_back(cells_per_feb[feb_id]);
112 } else {
113 if ( !m_onlineId->isEMECIW(hw) ){
114 if ( calosample<25)
115 cellCountPerLayer[calosample].push_back(cells_per_feb[feb_id]);
116 }else{
117 if ( calosample<8)
118 cellCountPerLayerIW[calosample-6].push_back(cells_per_feb[feb_id]);
119 }
120 }
121 }
122
123 mon_bcid = bcid;
124 mon_inputSize = (*inputCellHandle).size();
125 mon_outputSize = outputSize;
126 mon_larSize = larSize;
127 mon_larAboveSigmaSize = larAboveSizeSize;
128 auto mon_febID = Monitored::Collection("FEBID",febID);
129 auto mon_cells = Monitored::Collection("CellsPerFEB",cellCount);
130 auto mon0 = Monitored::Collection(m_layerNames[0],cellCountPerLayer[0]);
131 auto mon1 = Monitored::Collection(m_layerNames[1],cellCountPerLayer[1]);
132 auto mon2 = Monitored::Collection(m_layerNames[2],cellCountPerLayer[2]);
133 auto mon3 = Monitored::Collection(m_layerNames[3],cellCountPerLayer[3]);
134 auto mon4 = Monitored::Collection(m_layerNames[4],cellCountPerLayer[4]);
135 auto mon5 = Monitored::Collection(m_layerNames[5],cellCountPerLayer[5]);
136 auto mon6 = Monitored::Collection(m_layerNames[6],cellCountPerLayer[6]);
137 auto mon7 = Monitored::Collection(m_layerNames[7],cellCountPerLayer[7]);
138 auto mon8 = Monitored::Collection(m_layerNamesIW[0],cellCountPerLayerIW[0]);
139 auto mon9 = Monitored::Collection(m_layerNamesIW[1],cellCountPerLayerIW[1]);
140 std::vector<std::reference_wrapper<Monitored::IMonitoredVariable>> variables;
141 variables.reserve(50);
142 variables.push_back(std::ref(mon_bcid));
143 variables.push_back(std::ref(mon_inputSize));
144 variables.push_back(std::ref(mon_outputSize));
145 variables.push_back(std::ref(mon_larSize));
146 variables.push_back(std::ref(mon_larAboveSigmaSize) );
147 variables.push_back(std::ref(mon_cells) );
148 variables.push_back(std::ref(mon_febID) );
149 variables.push_back(std::ref(mon0));
150 variables.push_back(std::ref(mon1));
151 variables.push_back(std::ref(mon2));
152 variables.push_back(std::ref(mon3));
153 variables.push_back(std::ref(mon4));
154 variables.push_back(std::ref(mon5));
155 variables.push_back(std::ref(mon6));
156 variables.push_back(std::ref(mon7));
157 variables.push_back(std::ref(mon8));
158 variables.push_back(std::ref(mon9));
159 auto monitorIt = Monitored::Group( m_moniTool, variables);
160 variables.clear();
161
162 return StatusCode::SUCCESS;
163}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_DEBUG(x)
const ServiceHandle< StoreGateSvc > & detStore() const
An algorithm that can be simultaneously executed in multiple threads.
float getNoise(const IdentifierHash h, const int gain) const
Accessor by IdentifierHash and gain.
Definition CaloNoise.h:35
Gaudi::Property< float > m_NumberOfSigma
std::vector< std::string > m_layerNames
virtual StatusCode execute(EventContext const &context) const override
std::vector< std::string > m_layerNamesIW
HLTCaloGlobalCellMonitor(std::string const &name, ISvcLocator *pSvcLocator)
SG::ReadCondHandleKey< CaloNoise > m_noiseCDOKey
SG::ReadHandleKey< CaloConstCellContainer > m_inputCellContainerKey
ToolHandle< GenericMonitoringTool > m_moniTool
Monitoring tool.
virtual StatusCode initialize() override
SG::ReadCondHandleKey< LArOnOffIdMapping > m_onOffIdMappingKey
Gaudi::Property< uint32_t > m_MaxNCellsPerFEB
value_type get_compact() const
Get the compact id.
This is a "hash" representation of an Identifier.
Identifier32 get_identifier32() const
Get the 32-bit version Identifier, will be invalid if >32 bits needed.
Group of local monitoring quantities and retain correlation when filling histograms
Declare a monitored scalar variable.
ValuesCollection< T > Collection(std::string name, const T &collection)
Declare a monitored (double-convertible) collection.
std::string number(const double &d, const std::string &s)
Definition utils.cxx:186