ATLAS Offline Software
Loading...
Searching...
No Matches
ClusterMonitorAlgorithm.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3*/
4
7using Athena::Units::GeV;
8
9ClusterMonitorAlgorithm::ClusterMonitorAlgorithm( const std::string& name, ISvcLocator* pSvcLocator )
10:AthMonitorAlgorithm(name,pSvcLocator)
11{
12
13}
14
15
16ClusterMonitorAlgorithm::~ClusterMonitorAlgorithm() = default;
17
18
20 using namespace Monitored;
21
23 ATH_CHECK( m_EMClusterContainerKey.initialize() );
24
25 // initialize superclass
27
28 return StatusCode::SUCCESS;
29}
30
31
32StatusCode ClusterMonitorAlgorithm::fillHistograms( const EventContext& ctx ) const {
33 using namespace Monitored;
34
35 // Declare the quantities which should be monitored
36 auto nClusters = Monitored::Scalar<float>("nClusters",0.0);
37 auto nEMClusters = Monitored::Scalar<float>("nEMClusters",0.0);
38
39 auto eta = Monitored::Scalar<float>("clusterEta",0.0);
40 auto phi = Monitored::Scalar<float>("clusterPhi",0.0);
41 auto evt = Monitored::Scalar<int>("event num",0);
42 auto run = Monitored::Scalar<int>("run",0);
43 auto E = Monitored::Scalar<float>("clusterE",0.0);
44 auto ET = Monitored::Scalar<float>("clusterET",1.0);
45
46 auto emeta = Monitored::Scalar<float>("emclusterEta",0.0);
47 auto emphi = Monitored::Scalar<float>("emclusterPhi",0.0);
48 auto emE = Monitored::Scalar<float>("emclusterE",0.0);
49 auto emET = Monitored::Scalar<float>("emclusterET",1.0);
50
51 auto nCells = Monitored::Scalar<float>("nCells",0.0);
52 auto nBadCells= Monitored::Scalar<float>("nBadCells",0.0);
53 auto EBadCells= Monitored::Scalar<float>("EBadCells",0.0);
54 auto HotRat = Monitored::Scalar<float>("HotRat",-1.0);
55 auto ClusTime = Monitored::Scalar<float>("clusterTime",-999.0);
56 auto Isolation= Monitored::Scalar<float>("clusterIsol",-999);
57 auto BadLARQFrac = Monitored::Scalar<float>("BadLARQFrac",-999);
58 auto EngPos = Monitored::Scalar<float>("EngPos",-999);
59 auto AveLARQ = Monitored::Scalar<float>("AveLARQ",-999);
60 auto AveTileQ = Monitored::Scalar<float>("AveTileQ",-999);
61
62 auto nCellsEM = Monitored::Scalar<float>("nCellsEM",0.0);
63 auto nBadCellsEM = Monitored::Scalar<float>("nBadCellsEM",0.0);
64 auto EBadCellsEM = Monitored::Scalar<float>("EBadCellsEM",0.0);
65 auto emHotRat = Monitored::Scalar<float>("emHotRat",-1.0);
66 auto emClusTime = Monitored::Scalar<float>("emclusterTime",-999.0);
67 auto emIsolation = Monitored::Scalar<float>("emclusterIsol",-999);
68 auto emBadLARQFrac = Monitored::Scalar<float>("emBadLARQFrac",-999);
69 auto emEngPos = Monitored::Scalar<float>("emEngPos",-999);
70 auto emAveLARQ = Monitored::Scalar<float>("emAveLARQ",-999);
71
72 // Declare cutmasks for high leading cell energy fraction
73 auto HighHotRat = Monitored::Scalar<bool>("HighHotRat",false);
74
75 // Declare cutmasks for plots with thresholds
76 auto Threshold1 = Monitored::Scalar<bool>("Threshold1",false);
77 auto Threshold2 = Monitored::Scalar<bool>("Threshold2",false);
78 auto Threshold3 = Monitored::Scalar<bool>("Threshold3",false);
79 auto Threshold4 = Monitored::Scalar<bool>("Threshold4",false);
80
81 auto EMThreshold1 = Monitored::Scalar<bool>("EMThreshold1",false);
82 auto EMThreshold2 = Monitored::Scalar<bool>("EMThreshold2",false);
83 auto EMThreshold3 = Monitored::Scalar<bool>("EMThreshold3",false);
84 auto EMThreshold4 = Monitored::Scalar<bool>("EMThreshold4",false);
85
86 // Declare cutmasks for plots with specific phi selection
87 auto PhiRegion1 = Monitored::Scalar<bool>("PhiRegion1",false);
88 auto PhiRegion2 = Monitored::Scalar<bool>("PhiRegion2",false);
89
90 // Access the Clusters via StoreGate
92 if (! clusters.isValid() ) {
93 ATH_MSG_ERROR("evtStore() does not contain CaloTopoCluster Collection with name "<< m_CaloClusterContainerKey);
94 return StatusCode::FAILURE;
95 }
96
97 // Access the egamma Clusters via StoreGate
99 if (! emclusters.isValid() ) {
100 ATH_MSG_ERROR("evtStore() does not contain CaloTopoCluster Collection with name "<< m_EMClusterContainerKey);
101 return StatusCode::FAILURE;
102 }
103
104 // Set the values of the monitored variables for the event
105 run = GetEventInfo(ctx)->runNumber();
106 evt = GetEventInfo(ctx)->eventNumber();
107
108 // Set monitored variables for this event
109 nClusters = clusters->size();
110 fill("ClusterMonitorAllClusters", nClusters);
111 nEMClusters = emclusters->size();
112 fill("ClusterMonitorAllEMClusters", nEMClusters);
113
114 for (const auto cluster : *clusters) {
115 eta = cluster->eta();
116 phi = cluster->phi();
117 E = cluster->e()/GeV;
118 ET = cluster->pt()/GeV;
119 // Access CaloTopoCluster moments
120 nCells = cluster->numberCells();
121 ClusTime = cluster->time();
122
123 nBadCells = cluster->getMomentValue(xAOD::CaloCluster::N_BAD_CELLS); // return value probably 0 if moment does not exist
124 EBadCells = cluster->getMomentValue(xAOD::CaloCluster::ENG_BAD_CELLS)/GeV;
125 HotRat = cluster->getMomentValue(xAOD::CaloCluster::ENG_FRAC_MAX); // return value probably 999 if moment does not exist
126 (HotRat > 0.9) ? HighHotRat=true : HighHotRat=false;
127 Isolation = cluster->getMomentValue(xAOD::CaloCluster::ISOLATION);
128 BadLARQFrac = cluster->getMomentValue(xAOD::CaloCluster::BADLARQ_FRAC);
129 EngPos = cluster->getMomentValue(xAOD::CaloCluster::ENG_POS)/GeV;
130 AveLARQ = cluster->getMomentValue(xAOD::CaloCluster::AVG_LAR_Q);
131 AveTileQ = cluster->getMomentValue(xAOD::CaloCluster::AVG_TILE_Q);
132
133 // Fill. First argument is the tool name, all others are the variables to be saved.
134 fill("ClusterMonitorAllClusters", eta, phi, E, ET);
135 fill("ClusterMonitorExpertPlots", nCells, ClusTime, nBadCells, EBadCells, HotRat, HighHotRat, Isolation, BadLARQFrac, EngPos, AveLARQ, AveTileQ, E, eta, phi);
136
137 // NCB specific histograms:
138 PhiRegion1 = std::abs(phi) <= 0.3 || std::abs(phi) >= 2.7;
139 PhiRegion2 = std::abs(phi) > 0.3 && std::abs(phi) < 2.7;
140 if(std::abs(ClusTime) > 1e-6){
141 fill("ClusterMonitorNCBPlots", eta, ClusTime, PhiRegion1, PhiRegion2);
142 }
143
144 // cutmasks for cluster energy thresholds
145 Threshold1 = E>m_lowEthresh;
146 Threshold2 = E>m_medEthresh;
147 Threshold3 = E>m_medhiEthresh;
148 Threshold4 = E>m_hiEthresh;
149 // Plot occupancies and energies by calorimeter region
150 if (eta > 1.4) {
151 fill("ClusterMonitorCalECA",eta,phi,E,Threshold1,Threshold2,Threshold3,Threshold4);
152 }
153 else if (eta < -1.4) {
154 fill("ClusterMonitorCalECC",eta,phi,E,Threshold1,Threshold2,Threshold3,Threshold4);
155 }
156 else {
157 fill("ClusterMonitorCalBAR",eta,phi,E,Threshold1,Threshold2,Threshold3,Threshold4);
158 }
159 }
160
161 // Repeat for EM clusters - Set monitored variables for this event
162 for (const auto emcluster : *emclusters) {
163 emeta = emcluster->eta();
164 emphi = emcluster->phi();
165 emE = emcluster->e()/GeV;
166 emET = emcluster->pt()/GeV;
167 // Access CaloTopoCluster moments
168 nCellsEM = emcluster->numberCells();
169 emClusTime = emcluster->time();
170
171 nBadCellsEM = emcluster->getMomentValue(xAOD::CaloCluster::N_BAD_CELLS); // return value probably 0 if moment does not exist
172 EBadCellsEM = emcluster->getMomentValue(xAOD::CaloCluster::ENG_BAD_CELLS)/GeV;
173 emHotRat = emcluster->getMomentValue(xAOD::CaloCluster::ENG_FRAC_MAX); // return value probably 999 if moment does not exist
174 (emHotRat > 0.9) ? HighHotRat=true : HighHotRat=false;
175 emIsolation = emcluster->getMomentValue(xAOD::CaloCluster::ISOLATION);
176 emBadLARQFrac = emcluster->getMomentValue(xAOD::CaloCluster::BADLARQ_FRAC);
177 emEngPos = emcluster->getMomentValue(xAOD::CaloCluster::ENG_POS)/GeV;
178 emAveLARQ = emcluster->getMomentValue(xAOD::CaloCluster::AVG_LAR_Q);
179
180 // Fill. First argument is the tool name, all others are the variables to be saved.
181 fill("ClusterMonitorAllEMClusters", emeta, emphi, emE, emET);
182 fill("ClusterMonitorExpertPlotsEM", nCellsEM, emClusTime, nBadCellsEM, EBadCellsEM, emHotRat, HighHotRat, emIsolation, emBadLARQFrac, emEngPos, emAveLARQ, emE, emeta, emphi);
183
184 // cutmasks for cluster energy thresholds
185 EMThreshold1 = emE>m_EMlowEthresh;
186 EMThreshold2 = emE>m_EMmedEthresh;
187 EMThreshold3 = emE>m_EMmedhiEthresh;
188 EMThreshold4 = emE>m_EMhiEthresh;
189 // Plot occupancies and energies by calorimeter region
190 if (emeta > 1.4) {
191 fill("ClusterMonitorEMECA",emeta,emphi,emE,EMThreshold1,EMThreshold2,EMThreshold3,EMThreshold4);
192 }
193 else if (emeta < -1.4) {
194 fill("ClusterMonitorEMECC",emeta,emphi,emE,EMThreshold1,EMThreshold2,EMThreshold3,EMThreshold4);
195 }
196 else {
197 fill("ClusterMonitorEMBAR",emeta,emphi,emE,EMThreshold1,EMThreshold2,EMThreshold3,EMThreshold4);
198 }
199
200 }
201
202 return StatusCode::SUCCESS;
203}
204
205
Scalar eta() const
pseudorapidity method
Scalar phi() const
phi method
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
Wrapper to avoid constant divisions when using units.
virtual StatusCode initialize() override
initialize
SG::ReadHandle< xAOD::EventInfo > GetEventInfo(const EventContext &) const
Return a ReadHandle for an EventInfo object (get run/event numbers, etc.)
AthMonitorAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
Gaudi::Property< float > m_EMlowEthresh
Gaudi::Property< float > m_hiEthresh
ClusterMonitorAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
SG::ReadHandleKey< xAOD::CaloClusterContainer > m_CaloClusterContainerKey
virtual StatusCode initialize() override
initialize
Gaudi::Property< float > m_lowEthresh
virtual StatusCode fillHistograms(const EventContext &ctx) const override
adds event to the monitoring histograms
SG::ReadHandleKey< xAOD::CaloClusterContainer > m_EMClusterContainerKey
Gaudi::Property< float > m_EMmedEthresh
Gaudi::Property< float > m_medEthresh
Gaudi::Property< float > m_medhiEthresh
Gaudi::Property< float > m_EMhiEthresh
Gaudi::Property< float > m_EMmedhiEthresh
Declare a monitored scalar variable.
virtual bool isValid() override final
Can the handle be successfully dereferenced?
@ AVG_TILE_Q
Sum(E_cell_Tile^2 Q_cell_Tile)/Sum(E_cell_Tile^2)
@ N_BAD_CELLS
number of bad cells
@ ENG_FRAC_MAX
Energy fraction of hottest cell.
@ AVG_LAR_Q
Sum(E_cell_LAr^2 Q_cell_LAr)/Sum(E_cell_LAr^2)
@ ENG_BAD_CELLS
Total em-scale energy of bad cells in this cluster.
@ ENG_POS
Total positive Energy of this cluster.
@ BADLARQ_FRAC
Energy fraction of LAr cells with quality larger than a given cut.
@ ISOLATION
Energy weighted fraction of non-clustered perimeter cells.
Generic monitoring tool for athena components.
Definition run.py:1
void fill(H5::Group &out_file, size_t iterations)