ATLAS Offline Software
ClusterMonitorAlgorithm.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2021 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  // Access the Clusters via StoreGate
88  if (! clusters.isValid() ) {
89  ATH_MSG_ERROR("evtStore() does not contain CaloTopoCluster Collection with name "<< m_CaloClusterContainerKey);
90  return StatusCode::FAILURE;
91  }
92 
93  // Access the egamma Clusters via StoreGate
95  if (! emclusters.isValid() ) {
96  ATH_MSG_ERROR("evtStore() does not contain CaloTopoCluster Collection with name "<< m_EMClusterContainerKey);
97  return StatusCode::FAILURE;
98  }
99 
100  // Set the values of the monitored variables for the event
101  run = GetEventInfo(ctx)->runNumber();
102  evt = GetEventInfo(ctx)->eventNumber();
103 
104  // Set monitored variables for this event
105  nClusters = clusters->size();
106  fill("ClusterMonitorAllClusters", nClusters);
107  nEMClusters = emclusters->size();
108  fill("ClusterMonitorAllEMClusters", nEMClusters);
109 
110  for (const auto& cluster : *clusters) {
111  eta = cluster->eta();
112  phi = cluster->phi();
113  E = cluster->e()/GeV;
114  ET = cluster->pt()/GeV;
115  // Access CaloTopoCluster moments
116  nCells = cluster->numberCells();
117  ClusTime = cluster->time();
118 
119  nBadCells = cluster->getMomentValue(xAOD::CaloCluster::N_BAD_CELLS); // return value probably 0 if moment does not exist
120  EBadCells = cluster->getMomentValue(xAOD::CaloCluster::ENG_BAD_CELLS)/GeV;
121  HotRat = cluster->getMomentValue(xAOD::CaloCluster::ENG_FRAC_MAX); // return value probably 999 if moment does not exist
122  (HotRat > 0.9) ? HighHotRat=true : HighHotRat=false;
123  Isolation = cluster->getMomentValue(xAOD::CaloCluster::ISOLATION);
124  BadLARQFrac = cluster->getMomentValue(xAOD::CaloCluster::BADLARQ_FRAC);
125  EngPos = cluster->getMomentValue(xAOD::CaloCluster::ENG_POS)/GeV;
126  AveLARQ = cluster->getMomentValue(xAOD::CaloCluster::AVG_LAR_Q);
127  AveTileQ = cluster->getMomentValue(xAOD::CaloCluster::AVG_TILE_Q);
128 
129  // Fill. First argument is the tool name, all others are the variables to be saved.
130  fill("ClusterMonitorAllClusters", eta, phi, E, ET);
131  fill("ClusterMonitorExpertPlots", nCells, ClusTime, nBadCells, EBadCells, HotRat, HighHotRat, Isolation, BadLARQFrac, EngPos, AveLARQ, AveTileQ, E, eta, phi);
132 
133  // cutmasks for cluster energy thresholds
134  Threshold1 = E>m_lowEthresh;
135  Threshold2 = E>m_medEthresh;
136  Threshold3 = E>m_medhiEthresh;
137  Threshold4 = E>m_hiEthresh;
138  // Plot occupancies and energies by calorimeter region
139  if (eta > 1.4) {
140  fill("ClusterMonitorCalECA",eta,phi,E,Threshold1,Threshold2,Threshold3,Threshold4);
141  }
142  else if (eta < -1.4) {
143  fill("ClusterMonitorCalECC",eta,phi,E,Threshold1,Threshold2,Threshold3,Threshold4);
144  }
145  else {
146  fill("ClusterMonitorCalBAR",eta,phi,E,Threshold1,Threshold2,Threshold3,Threshold4);
147  }
148  }
149 
150  // Repeat for EM clusters - Set monitored variables for this event
151  for (const auto& emcluster : *emclusters) {
152  emeta = emcluster->eta();
153  emphi = emcluster->phi();
154  emE = emcluster->e()/GeV;
155  emET = emcluster->pt()/GeV;
156  // Access CaloTopoCluster moments
157  nCellsEM = emcluster->numberCells();
158  emClusTime = emcluster->time();
159 
160  nBadCellsEM = emcluster->getMomentValue(xAOD::CaloCluster::N_BAD_CELLS); // return value probably 0 if moment does not exist
161  EBadCellsEM = emcluster->getMomentValue(xAOD::CaloCluster::ENG_BAD_CELLS)/GeV;
162  emHotRat = emcluster->getMomentValue(xAOD::CaloCluster::ENG_FRAC_MAX); // return value probably 999 if moment does not exist
163  (emHotRat > 0.9) ? HighHotRat=true : HighHotRat=false;
164  emIsolation = emcluster->getMomentValue(xAOD::CaloCluster::ISOLATION);
165  emBadLARQFrac = emcluster->getMomentValue(xAOD::CaloCluster::BADLARQ_FRAC);
166  emEngPos = emcluster->getMomentValue(xAOD::CaloCluster::ENG_POS)/GeV;
167  emAveLARQ = emcluster->getMomentValue(xAOD::CaloCluster::AVG_LAR_Q);
168 
169  // Fill. First argument is the tool name, all others are the variables to be saved.
170  fill("ClusterMonitorAllEMClusters", emeta, emphi, emE, emET);
171  fill("ClusterMonitorExpertPlotsEM", nCellsEM, emClusTime, nBadCellsEM, EBadCellsEM, emHotRat, HighHotRat, emIsolation, emBadLARQFrac, emEngPos, emAveLARQ, emE, emeta, emphi);
172 
173  // cutmasks for cluster energy thresholds
174  EMThreshold1 = emE>m_EMlowEthresh;
175  EMThreshold2 = emE>m_EMmedEthresh;
176  EMThreshold3 = emE>m_EMmedhiEthresh;
177  EMThreshold4 = emE>m_EMhiEthresh;
178  // Plot occupancies and energies by calorimeter region
179  if (emeta > 1.4) {
180  fill("ClusterMonitorEMECA",emeta,emphi,emE,EMThreshold1,EMThreshold2,EMThreshold3,EMThreshold4);
181  }
182  else if (emeta < -1.4) {
183  fill("ClusterMonitorEMECC",emeta,emphi,emE,EMThreshold1,EMThreshold2,EMThreshold3,EMThreshold4);
184  }
185  else {
186  fill("ClusterMonitorEMBAR",emeta,emphi,emE,EMThreshold1,EMThreshold2,EMThreshold3,EMThreshold4);
187  }
188 
189  }
190 
191  return StatusCode::SUCCESS;
192 }
193 
194 
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
phi
Scalar phi() const
phi method
Definition: AmgMatrixBasePlugin.h:64
ClusterMonitorAlgorithm::m_EMmedEthresh
Gaudi::Property< float > m_EMmedEthresh
Definition: ClusterMonitorAlgorithm.h:30
eta
Scalar eta() const
pseudorapidity method
Definition: AmgMatrixBasePlugin.h:79
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
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:163
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:140
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:146
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:148
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
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:165
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
GeV
#define GeV
Definition: CaloTransverseBalanceVecMon.cxx:30
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:149
xAOD::CaloCluster_v1::ENG_POS
@ ENG_POS
Total positive Energy of this cluster.
Definition: CaloCluster_v1.h:156
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:155