Loading [MathJax]/extensions/tex2jax.js
ATLAS Offline Software
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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 
6 #include "AthenaKernel/Units.h"
8 
9 ClusterMonitorAlgorithm::ClusterMonitorAlgorithm( const std::string& name, ISvcLocator* pSvcLocator )
10 :AthMonitorAlgorithm(name,pSvcLocator)
11 {
12 
13 }
14 
15 
17 
18 
20  using namespace Monitored;
21 
24 
25  // initialize superclass
27 
28  return StatusCode::SUCCESS;
29 }
30 
31 
32 StatusCode 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  fill("ClusterMonitorNCBPlots", eta, ClusTime, PhiRegion1, PhiRegion2);
141 
142  // cutmasks for cluster energy thresholds
143  Threshold1 = E>m_lowEthresh;
144  Threshold2 = E>m_medEthresh;
145  Threshold3 = E>m_medhiEthresh;
146  Threshold4 = E>m_hiEthresh;
147  // Plot occupancies and energies by calorimeter region
148  if (eta > 1.4) {
149  fill("ClusterMonitorCalECA",eta,phi,E,Threshold1,Threshold2,Threshold3,Threshold4);
150  }
151  else if (eta < -1.4) {
152  fill("ClusterMonitorCalECC",eta,phi,E,Threshold1,Threshold2,Threshold3,Threshold4);
153  }
154  else {
155  fill("ClusterMonitorCalBAR",eta,phi,E,Threshold1,Threshold2,Threshold3,Threshold4);
156  }
157  }
158 
159  // Repeat for EM clusters - Set monitored variables for this event
160  for (const auto emcluster : *emclusters) {
161  emeta = emcluster->eta();
162  emphi = emcluster->phi();
163  emE = emcluster->e()/GeV;
164  emET = emcluster->pt()/GeV;
165  // Access CaloTopoCluster moments
166  nCellsEM = emcluster->numberCells();
167  emClusTime = emcluster->time();
168 
169  nBadCellsEM = emcluster->getMomentValue(xAOD::CaloCluster::N_BAD_CELLS); // return value probably 0 if moment does not exist
170  EBadCellsEM = emcluster->getMomentValue(xAOD::CaloCluster::ENG_BAD_CELLS)/GeV;
171  emHotRat = emcluster->getMomentValue(xAOD::CaloCluster::ENG_FRAC_MAX); // return value probably 999 if moment does not exist
172  (emHotRat > 0.9) ? HighHotRat=true : HighHotRat=false;
173  emIsolation = emcluster->getMomentValue(xAOD::CaloCluster::ISOLATION);
174  emBadLARQFrac = emcluster->getMomentValue(xAOD::CaloCluster::BADLARQ_FRAC);
175  emEngPos = emcluster->getMomentValue(xAOD::CaloCluster::ENG_POS)/GeV;
176  emAveLARQ = emcluster->getMomentValue(xAOD::CaloCluster::AVG_LAR_Q);
177 
178  // Fill. First argument is the tool name, all others are the variables to be saved.
179  fill("ClusterMonitorAllEMClusters", emeta, emphi, emE, emET);
180  fill("ClusterMonitorExpertPlotsEM", nCellsEM, emClusTime, nBadCellsEM, EBadCellsEM, emHotRat, HighHotRat, emIsolation, emBadLARQFrac, emEngPos, emAveLARQ, emE, emeta, emphi);
181 
182  // cutmasks for cluster energy thresholds
183  EMThreshold1 = emE>m_EMlowEthresh;
184  EMThreshold2 = emE>m_EMmedEthresh;
185  EMThreshold3 = emE>m_EMmedhiEthresh;
186  EMThreshold4 = emE>m_EMhiEthresh;
187  // Plot occupancies and energies by calorimeter region
188  if (emeta > 1.4) {
189  fill("ClusterMonitorEMECA",emeta,emphi,emE,EMThreshold1,EMThreshold2,EMThreshold3,EMThreshold4);
190  }
191  else if (emeta < -1.4) {
192  fill("ClusterMonitorEMECC",emeta,emphi,emE,EMThreshold1,EMThreshold2,EMThreshold3,EMThreshold4);
193  }
194  else {
195  fill("ClusterMonitorEMBAR",emeta,emphi,emE,EMThreshold1,EMThreshold2,EMThreshold3,EMThreshold4);
196  }
197 
198  }
199 
200  return StatusCode::SUCCESS;
201 }
202 
203 
ClusterMonitorAlgorithm::m_lowEthresh
Gaudi::Property< float > m_lowEthresh
Definition: ClusterMonitorAlgorithm.h:24
ClusterMonitorAlgorithm::m_medhiEthresh
Gaudi::Property< float > m_medhiEthresh
Definition: ClusterMonitorAlgorithm.h:26
ClusterMonitorAlgorithm::m_EMlowEthresh
Gaudi::Property< float > m_EMlowEthresh
Definition: ClusterMonitorAlgorithm.h:29
GeV
#define GeV
Definition: PhysicsAnalysis/TauID/TauAnalysisTools/Root/HelperFunctions.cxx:17
ClusterMonitorAlgorithm::m_EMmedEthresh
Gaudi::Property< float > m_EMmedEthresh
Definition: ClusterMonitorAlgorithm.h:30
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:67
xAOD::CaloCluster_v1::AVG_LAR_Q
@ AVG_LAR_Q
Sum(E_cell_LAr^2 Q_cell_LAr)/Sum(E_cell_LAr^2)
Definition: CaloCluster_v1.h:166
ClusterMonitorAlgorithm::~ClusterMonitorAlgorithm
virtual ~ClusterMonitorAlgorithm()
LArG4FSStartPointFilter.evt
evt
Definition: LArG4FSStartPointFilter.py:42
xAOD::CaloCluster_v1::ENG_FRAC_MAX
@ ENG_FRAC_MAX
Energy fraction of hottest cell.
Definition: CaloCluster_v1.h:143
ClusterMonitorAlgorithm::m_EMClusterContainerKey
SG::ReadHandleKey< xAOD::CaloClusterContainer > m_EMClusterContainerKey
Definition: ClusterMonitorAlgorithm.h:36
AthMonitorAlgorithm
Base class for Athena Monitoring Algorithms.
Definition: AthMonitorAlgorithm.h:36
ClusterMonitorAlgorithm::fillHistograms
virtual StatusCode fillHistograms(const EventContext &ctx) const override
adds event to the monitoring histograms
Definition: ClusterMonitorAlgorithm.cxx:32
ClusterMonitorAlgorithm::ClusterMonitorAlgorithm
ClusterMonitorAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Definition: ClusterMonitorAlgorithm.cxx:9
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
xAOD::nCells
setRawEt setRawPhi nCells
Definition: TrigCaloCluster_v1.cxx:33
Monitored
Generic monitoring tool for athena components.
Definition: GenericMonitoringTool.h:30
ClusterMonitorAlgorithm.h
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ClusterMonitorAlgorithm::m_medEthresh
Gaudi::Property< float > m_medEthresh
Definition: ClusterMonitorAlgorithm.h:25
xAOD::CaloCluster_v1::ISOLATION
@ ISOLATION
Energy weighted fraction of non-clustered perimeter cells.
Definition: CaloCluster_v1.h:149
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
ClusterMonitorAlgorithm::initialize
virtual StatusCode initialize() override
initialize
Definition: ClusterMonitorAlgorithm.cxx:19
run
Definition: run.py:1
AthMonitorAlgorithm::fill
void fill(const ToolHandle< GenericMonitoringTool > &groupHandle, std::vector< std::reference_wrapper< Monitored::IMonitoredVariable >> &&variables) const
Fills a vector of variables to a group by reference.
SG::VarHandleKey::initialize
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:103
AthMonitorAlgorithm::GetEventInfo
SG::ReadHandle< xAOD::EventInfo > GetEventInfo(const EventContext &) const
Return a ReadHandle for an EventInfo object (get run/event numbers, etc.)
Definition: AthMonitorAlgorithm.cxx:107
ClusterMonitorAlgorithm::m_EMmedhiEthresh
Gaudi::Property< float > m_EMmedhiEthresh
Definition: ClusterMonitorAlgorithm.h:31
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
xAOD::CaloCluster_v1::ENG_BAD_CELLS
@ ENG_BAD_CELLS
Total em-scale energy of bad cells in this cluster.
Definition: CaloCluster_v1.h:151
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:240
VP1PartSpect::E
@ E
Definition: VP1PartSpectFlags.h:21
xAOD::CaloCluster_v1::AVG_TILE_Q
@ AVG_TILE_Q
Sum(E_cell_Tile^2 Q_cell_Tile)/Sum(E_cell_Tile^2)
Definition: CaloCluster_v1.h:168
Units.h
Wrapper to avoid constant divisions when using units.
AthMonitorAlgorithm::initialize
virtual StatusCode initialize() override
initialize
Definition: AthMonitorAlgorithm.cxx:18
ClusterMonitorAlgorithm::m_CaloClusterContainerKey
SG::ReadHandleKey< xAOD::CaloClusterContainer > m_CaloClusterContainerKey
Definition: ClusterMonitorAlgorithm.h:34
RunTileMonitoring.clusters
clusters
Definition: RunTileMonitoring.py:133
Monitored::Scalar
Declare a monitored scalar variable.
Definition: MonitoredScalar.h:34
ClusterMonitorAlgorithm::m_hiEthresh
Gaudi::Property< float > m_hiEthresh
Definition: ClusterMonitorAlgorithm.h:27
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.
xAOD::CaloCluster_v1::N_BAD_CELLS
@ N_BAD_CELLS
number of bad cells
Definition: CaloCluster_v1.h:152
xAOD::CaloCluster_v1::ENG_POS
@ ENG_POS
Total positive Energy of this cluster.
Definition: CaloCluster_v1.h:159
ClusterMonitorAlgorithm::m_EMhiEthresh
Gaudi::Property< float > m_EMhiEthresh
Definition: ClusterMonitorAlgorithm.h:32
xAOD::CaloCluster_v1::BADLARQ_FRAC
@ BADLARQ_FRAC
Energy fraction of LAr cells with quality larger than a given cut.
Definition: CaloCluster_v1.h:158