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 for(size_t i=0;i<25; i++) {
33 std::string number("layer");
34 number+=std::to_string(i);
35 m_layerNames.push_back(number);
36 }
37 for(size_t i=0;i<2; i++) {
38 std::string number("layerIW");
39 number+=std::to_string(i+1);
40 m_layerNamesIW.push_back(number);
41 }
42
43 return StatusCode::SUCCESS;
44}
45
46StatusCode HLTCaloGlobalCellMonitor::execute(EventContext const& context) const {
47 ATH_MSG_DEBUG("HLTCaloGlobalCellMonitor::execute()");
48
50
52 const CaloNoise* noiseCDO=*noiseHdl;
54
55 const auto bcid = context.eventID().bunch_crossing_id();
56
57 uint32_t n_febs = m_onlineId->febHashMax();
58 std::map<HWIdentifier,uint32_t> cells_per_feb;
59 for(uint32_t i=0;i<n_febs;i++){
60 HWIdentifier feb_id = m_onlineId->feb_Id(IdentifierHash(i));
61 cells_per_feb[feb_id]=0;
62 }
63
64 auto mon_bcid = Monitored::Scalar<int>("BCID",0);
65 auto mon_inputSize = Monitored::Scalar<int>("inputContSize", 0);
66 auto mon_outputSize = Monitored::Scalar<int>("outputContSize", 0);
67 auto mon_larSize = Monitored::Scalar<int>("larContSize", 0);
68 auto mon_larAboveSigmaSize = Monitored::Scalar<int>("larAboveSigmaContSize", 0);
69
70
71 std::vector<uint32_t> febID;
72 febID.reserve(2000);
73 std::vector<uint32_t> cellCount;
74 cellCount.reserve(2000);
75 std::vector<uint32_t> cellCountPerLayer[25];
76 for(size_t i=0;i<25;i++)cellCountPerLayer[i].reserve(200);
77 std::vector<uint32_t> cellCountPerLayerIW[2];
78 for(size_t i=0;i<2;i++)cellCountPerLayerIW[i].reserve(200);
79 int larSize=0;
80 int larAboveSizeSize=0;
81 int outputSize=0;
82
83 for (auto const* cell : *inputCellHandle) {
84 if (!cell->caloDDE()->is_tile() ){
85 larSize++;
86 Identifier cellID = cell->ID();
87 float noiseSigma = noiseCDO->getNoise(cellID,cell->gain());
88 IdentifierHash offhashid = m_caloCell_ID->calo_cell_hash(cellID);
89 HWIdentifier hwid = (*onoff)->createSignalChannelIDFromHash(offhashid);
90 HWIdentifier hwid_feb = m_onlineId->feb_Id(hwid);
91 uint32_t ncells_in_feb = cells_per_feb[hwid_feb];
92 if (cell->energy() > m_NumberOfSigma*noiseSigma) {
93 larAboveSizeSize++;
94 if( ncells_in_feb < m_MaxNCellsPerFEB ) {
95 cells_per_feb[hwid_feb]=ncells_in_feb+1;
96 outputSize++;
97 }
98 }
99 } else outputSize++;
100 }
101 for(uint32_t i=0;i<n_febs;i++){
102 HWIdentifier feb_id = m_onlineId->feb_Id(IdentifierHash(i));
103 febID.push_back( feb_id.get_identifier32().get_compact() );
104 HWIdentifier hw = m_onlineId->channel_Id(feb_id,0); // first channel layer
105 Identifier id = (*onoff)->cnvToIdentifier(hw);
106 cellCount.push_back(cells_per_feb[feb_id]);
107 int calosample = m_caloCell_ID->calo_sample(id);
108 if (calosample < 5 ) {
109 cellCountPerLayer[calosample].push_back(cells_per_feb[feb_id]);
110 } else {
111 if ( !m_onlineId->isEMECIW(hw) ){
112 if ( calosample<25)
113 cellCountPerLayer[calosample].push_back(cells_per_feb[feb_id]);
114 }else{
115 if ( calosample<8)
116 cellCountPerLayerIW[calosample-6].push_back(cells_per_feb[feb_id]);
117 }
118 }
119 }
120
121 mon_bcid = bcid;
122 mon_inputSize = (*inputCellHandle).size();
123 mon_outputSize = outputSize;
124 mon_larSize = larSize;
125 mon_larAboveSigmaSize = larAboveSizeSize;
126 auto mon_febID = Monitored::Collection("FEBID",febID);
127 auto mon_cells = Monitored::Collection("CellsPerFEB",cellCount);
128 auto mon0 = Monitored::Collection(m_layerNames[0],cellCountPerLayer[0]);
129 auto mon1 = Monitored::Collection(m_layerNames[1],cellCountPerLayer[1]);
130 auto mon2 = Monitored::Collection(m_layerNames[2],cellCountPerLayer[2]);
131 auto mon3 = Monitored::Collection(m_layerNames[3],cellCountPerLayer[3]);
132 auto mon4 = Monitored::Collection(m_layerNames[4],cellCountPerLayer[4]);
133 auto mon5 = Monitored::Collection(m_layerNames[5],cellCountPerLayer[5]);
134 auto mon6 = Monitored::Collection(m_layerNames[6],cellCountPerLayer[6]);
135 auto mon7 = Monitored::Collection(m_layerNames[7],cellCountPerLayer[7]);
136 auto mon8 = Monitored::Collection(m_layerNamesIW[0],cellCountPerLayerIW[0]);
137 auto mon9 = Monitored::Collection(m_layerNamesIW[1],cellCountPerLayerIW[1]);
138 std::vector<std::reference_wrapper<Monitored::IMonitoredVariable>> variables;
139 variables.reserve(50);
140 variables.push_back(std::ref(mon_bcid));
141 variables.push_back(std::ref(mon_inputSize));
142 variables.push_back(std::ref(mon_outputSize));
143 variables.push_back(std::ref(mon_larSize));
144 variables.push_back(std::ref(mon_larAboveSigmaSize) );
145 variables.push_back(std::ref(mon_cells) );
146 variables.push_back(std::ref(mon_febID) );
147 variables.push_back(std::ref(mon0));
148 variables.push_back(std::ref(mon1));
149 variables.push_back(std::ref(mon2));
150 variables.push_back(std::ref(mon3));
151 variables.push_back(std::ref(mon4));
152 variables.push_back(std::ref(mon5));
153 variables.push_back(std::ref(mon6));
154 variables.push_back(std::ref(mon7));
155 variables.push_back(std::ref(mon8));
156 variables.push_back(std::ref(mon9));
157 auto monitorIt = Monitored::Group( m_moniTool, variables);
158 variables.clear();
159
160 return StatusCode::SUCCESS;
161}
#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