ATLAS Offline Software
HIGlobalAugmentationTool.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 #include <format>
7 
8 namespace DerivationFramework
9 {
11  const std::string& n,
12  const IInterface* p ) : base_class(t,n,p)
13  {
14  }
15 
16  // Destructor
18  {
19  }
20 
21  // Athena initialize and finalize
23  {
26  ATH_CHECK( m_eventShapeKey.initialize() );
27  ATH_CHECK( m_caloClusterKey.initialize(SG::AllowEmpty) ); // Only needed if m_doTopoClusDec = True
28  unsigned int nTrackSels = m_trkSelTools.size();
29  for (unsigned int its = 0; its < nTrackSels; ++its) {
31  m_decTrack_count.emplace_back(SG::AuxElement::Decorator<int>("TrackParticleMultiplicity_" + m_cutLevels[its] ));
32  }
33  //initilize decorators for flow vectors
34  for (int vn = 1; vn <= m_nHarmonic; ++vn) {
35  m_decFCalEtA_Qnx.emplace_back(SG::AuxElement::Decorator<float>(std::format("FCalEtA_Q{}x", vn + 1)));
36  m_decFCalEtA_Qny.emplace_back(SG::AuxElement::Decorator<float>(std::format("FCalEtA_Q{}y", vn + 1)));
37  m_decFCalEtC_Qnx.emplace_back(SG::AuxElement::Decorator<float>(std::format("FCalEtC_Q{}x", vn + 1)));
38  m_decFCalEtC_Qny.emplace_back(SG::AuxElement::Decorator<float>(std::format("FCalEtC_Q{}y", vn + 1)));
39 
40  // half FCal is for FCal with eta > 4.0 only
41  m_decHalfFCalEtA_Qnx.emplace_back(SG::AuxElement::Decorator<float>(std::format("HalfFCalEtA_Q{}x", vn + 1)));
42  m_decHalfFCalEtA_Qny.emplace_back(SG::AuxElement::Decorator<float>(std::format("HalfFCalEtA_Q{}y", vn + 1)));
43  m_decHalfFCalEtC_Qnx.emplace_back(SG::AuxElement::Decorator<float>(std::format("HalfFCalEtC_Q{}x", vn + 1)));
44  m_decHalfFCalEtC_Qny.emplace_back(SG::AuxElement::Decorator<float>(std::format("HalfFCalEtC_Q{}y", vn + 1)));
45  }
46 
47 
48  return StatusCode::SUCCESS;
49  }
51  {
52  for (auto trkSelTool : m_trkSelTools ) {
53  ATH_CHECK(trkSelTool->finalize());
54  }
55 
56  return StatusCode::SUCCESS;
57  }
58 
59  StatusCode HIGlobalAugmentationTool::addBranches(const EventContext& ctx) const
60  {
62 
63  //Load track particle container
65  if (!tracks.isValid()) {
66  ATH_MSG_ERROR ("Couldn't retrieve TrackParticleContainer with key " << m_TP_key);
67  return StatusCode::FAILURE;
68  }
69 
70  //Count tracks
71  unsigned int nTrackSels = m_trkSelTools.size();
72  std::vector <int> TrackParticleMultiplicity(nTrackSels,0);
73  for (const auto* tp : *tracks) {
74  if (tp) {
75  for (unsigned int its = 0; its < nTrackSels; ++its) {
76  if (m_trkSelTools[its]->accept(*tp)) ++TrackParticleMultiplicity[its];
77  }
78  }
79  }
80  //decorate eventInfo with track multiplicity
81  for (unsigned int its = 0; its < nTrackSels; ++its) {
82  (m_decTrack_count[its])(*eventInfo) = TrackParticleMultiplicity[its];
83  }
84 
85  float FCalEtA = 0;
86  float FCalEtC = 0;
87 
88  std::vector<float> FCalEtA_Qnx(m_nHarmonic,0);
89  std::vector<float> FCalEtA_Qny(m_nHarmonic,0);
90  std::vector<float> FCalEtC_Qnx(m_nHarmonic,0);
91  std::vector<float> FCalEtC_Qny(m_nHarmonic,0);
92 
93  float HalfFCalEtA = 0;
94  float HalfFCalEtC = 0;
95 
96  std::vector<float> HalfFCalEtA_Qnx(m_nHarmonic,0);
97  std::vector<float> HalfFCalEtA_Qny(m_nHarmonic,0);
98  std::vector<float> HalfFCalEtC_Qnx(m_nHarmonic,0);
99  std::vector<float> HalfFCalEtC_Qny(m_nHarmonic,0);
100 
101  // Set up the decorators for FCal Et
102  SG::AuxElement::Decorator< float > decFCalEtA("FCalEtA");
103  SG::AuxElement::Decorator< float > decFCalEtC("FCalEtC");
104 
105  SG::AuxElement::Decorator< float > decHalfFCalEtA("HalfFCalEtA");
106  SG::AuxElement::Decorator< float > decHalfFCalEtC("HalfFCalEtC");
107 
108  //Retrieve HIEventShape
110  if (!eventShape.isValid()){
111  ATH_MSG_ERROR ("Cannot retrieve HIEventShape");
112  return StatusCode::FAILURE;
113  }
114 
115  //Calculate FCal A and FCal C sums
116  for(const auto* ptrEvtShp : *eventShape){
117  if(ptrEvtShp->layer()!=21 && ptrEvtShp->layer()!=22 &&
118  ptrEvtShp->layer()!=23) continue;
119 
120  float eta = ptrEvtShp->etaMin();
121  const std::vector<float>&c1 = ptrEvtShp->etCos();
122  const std::vector<float>&s1 = ptrEvtShp->etSin();
123 
124  if (eta > 0) {
125  FCalEtA += ptrEvtShp->et();
126  for (int vn = 1; vn <= m_nHarmonic; ++vn){
127  FCalEtA_Qnx.at(vn-1) += c1.at(vn);
128  FCalEtA_Qny.at(vn-1) += s1.at(vn);
129  }
130  if(eta > 4.0) {
131  HalfFCalEtA += ptrEvtShp->et();
132  for (int vn = 1; vn <= m_nHarmonic; ++vn){
133  HalfFCalEtA_Qnx.at(vn-1) += c1.at(vn);
134  HalfFCalEtA_Qny.at(vn-1) += s1.at(vn);
135  }
136  }
137  } else if (eta < 0) {
138  FCalEtC += ptrEvtShp->et();
139  for (int vn = 1; vn <= m_nHarmonic; ++vn){
140  FCalEtC_Qnx.at(vn-1) += c1.at(vn);
141  FCalEtC_Qny.at(vn-1) += s1.at(vn);
142  }
143  if(eta < -4.0){
144  HalfFCalEtC += ptrEvtShp->et();
145  for (int vn = 1; vn <= m_nHarmonic; ++vn){
146  HalfFCalEtC_Qnx.at(vn-1) += c1.at(vn);
147  HalfFCalEtC_Qny.at(vn-1) += s1.at(vn);
148  }
149  }
150  }
151  }
152 
153  if (m_doTopoClusDec) {
154  // Setup the decorator for TopoCaloCluster cut
155  // If this is true, the event is not compatible with UPC topologies in the FCal
156  SG::AuxElement::Decorator< bool > decTopoClusterFCalCut("passUPCTopoCaloCut");
157  //Default decoration set to false
158  decTopoClusterFCalCut(*eventInfo) = false;
159 
160  //access topoClusters
162  bool hasTowerA{false};
163  bool hasTowerC{false};
164  for (const auto topo : *topos) {
165  float topo_eta = topo->eta();
166  if (abs(topo_eta) > 3.2 && abs(topo_eta) < 4.9) {
167  float topo_pt = topo->pt() * 1e-3;
168  if (topo_pt > 0.4) {
169  if (topo_eta > 0) {
170  hasTowerA = true;
171  } else {
172  hasTowerC = true;
173  }
174  }
175  }
176  }
177  //decorate
178  decTopoClusterFCalCut(*eventInfo) = (hasTowerA && hasTowerC);
179  }
180 
181 
182  //decorate
183  decFCalEtA(*eventInfo) = FCalEtA;
184  decFCalEtC(*eventInfo) = FCalEtC;
185  decHalfFCalEtA(*eventInfo) = HalfFCalEtA;
186  decHalfFCalEtC(*eventInfo) = HalfFCalEtC;
187 
188  for (int vn = 0; vn < m_nHarmonic; ++vn){
189  (m_decFCalEtA_Qnx[vn])(*eventInfo) = FCalEtA_Qnx.at(vn);
190  (m_decFCalEtA_Qny[vn])(*eventInfo) = FCalEtA_Qny.at(vn);
191  (m_decFCalEtC_Qnx[vn])(*eventInfo) = FCalEtC_Qnx.at(vn);
192  (m_decFCalEtC_Qny[vn])(*eventInfo) = FCalEtC_Qny.at(vn);
193  (m_decHalfFCalEtA_Qnx[vn])(*eventInfo) = HalfFCalEtA_Qnx.at(vn);
194  (m_decHalfFCalEtA_Qny[vn])(*eventInfo) = HalfFCalEtA_Qny.at(vn);
195  (m_decHalfFCalEtC_Qnx[vn])(*eventInfo) = HalfFCalEtC_Qnx.at(vn);
196  (m_decHalfFCalEtC_Qny[vn])(*eventInfo) = HalfFCalEtC_Qny.at(vn);
197  }
198 
199  return StatusCode::SUCCESS;
200  }
201 
202 }
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
AllowedVariables::e
e
Definition: AsgElectronSelectorTool.cxx:37
DerivationFramework::HIGlobalAugmentationTool::m_decTrack_count
std::vector< SG::AuxElement::Decorator< int > > m_decTrack_count
Definition: HIGlobalAugmentationTool.h:61
vtune_athena.format
format
Definition: vtune_athena.py:14
eta
Scalar eta() const
pseudorapidity method
Definition: AmgMatrixBasePlugin.h:83
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:67
HIGlobalAugmentationTool.h
DerivationFramework::HIGlobalAugmentationTool::m_decHalfFCalEtA_Qnx
std::vector< SG::AuxElement::Decorator< float > > m_decHalfFCalEtA_Qnx
Definition: HIGlobalAugmentationTool.h:56
CutsMETMaker::accept
StatusCode accept(const xAOD::Muon *mu)
Definition: CutsMETMaker.cxx:18
extractSporadic.c1
c1
Definition: extractSporadic.py:133
DerivationFramework::HIGlobalAugmentationTool::m_doTopoClusDec
Gaudi::Property< bool > m_doTopoClusDec
Definition: HIGlobalAugmentationTool.h:42
DerivationFramework::HIGlobalAugmentationTool::m_trkSelTools
PublicToolHandleArray< InDet::IInDetTrackSelectionTool > m_trkSelTools
track selection tool which can be optionally used for N_trk and sum pt cuts
Definition: HIGlobalAugmentationTool.h:47
ParticleTest.tp
tp
Definition: ParticleTest.py:25
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
DerivationFramework::HIGlobalAugmentationTool::finalize
StatusCode finalize()
Definition: HIGlobalAugmentationTool.cxx:50
DerivationFramework::HIGlobalAugmentationTool::m_decFCalEtC_Qnx
std::vector< SG::AuxElement::Decorator< float > > m_decFCalEtC_Qnx
Definition: HIGlobalAugmentationTool.h:53
L1TopoRatesCalculator_submatrix_plotter.topo
topo
Definition: L1TopoRatesCalculator_submatrix_plotter.py:78
DerivationFramework::HIGlobalAugmentationTool::m_eventShapeKey
SG::ReadHandleKey< xAOD::HIEventShapeContainer > m_eventShapeKey
Definition: HIGlobalAugmentationTool.h:45
DerivationFramework::HIGlobalAugmentationTool::m_decFCalEtA_Qny
std::vector< SG::AuxElement::Decorator< float > > m_decFCalEtA_Qny
Definition: HIGlobalAugmentationTool.h:52
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:209
DerivationFramework::HIGlobalAugmentationTool::m_nHarmonic
Gaudi::Property< int > m_nHarmonic
Definition: HIGlobalAugmentationTool.h:41
DerivationFramework::HIGlobalAugmentationTool::m_decFCalEtA_Qnx
std::vector< SG::AuxElement::Decorator< float > > m_decFCalEtA_Qnx
Definition: HIGlobalAugmentationTool.h:51
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
SG::Decorator
Helper class to provide type-safe access to aux data.
Definition: Decorator.h:59
DerivationFramework::HIGlobalAugmentationTool::m_cutLevels
Gaudi::Property< std::vector< std::string > > m_cutLevels
Definition: HIGlobalAugmentationTool.h:48
beamspotman.n
n
Definition: beamspotman.py:727
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
DerivationFramework::HIGlobalAugmentationTool::m_caloClusterKey
SG::ReadHandleKey< xAOD::CaloClusterContainer > m_caloClusterKey
Definition: HIGlobalAugmentationTool.h:46
DerivationFramework::HIGlobalAugmentationTool::m_TP_key
SG::ReadHandleKey< xAOD::TrackParticleContainer > m_TP_key
Definition: HIGlobalAugmentationTool.h:44
DerivationFramework
THE reconstruction tool.
Definition: ParticleSortingAlg.h:24
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
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
DerivationFramework::HIGlobalAugmentationTool::HIGlobalAugmentationTool
HIGlobalAugmentationTool(const std::string &t, const std::string &n, const IInterface *p)
Definition: HIGlobalAugmentationTool.cxx:10
DerivationFramework::HIGlobalAugmentationTool::m_eventInfoKey
SG::ReadHandleKey< xAOD::EventInfo > m_eventInfoKey
Definition: HIGlobalAugmentationTool.h:43
DerivationFramework::HIGlobalAugmentationTool::~HIGlobalAugmentationTool
~HIGlobalAugmentationTool()
Definition: HIGlobalAugmentationTool.cxx:17
DerivationFramework::HIGlobalAugmentationTool::m_decFCalEtC_Qny
std::vector< SG::AuxElement::Decorator< float > > m_decFCalEtC_Qny
Definition: HIGlobalAugmentationTool.h:54
DerivationFramework::HIGlobalAugmentationTool::m_decHalfFCalEtC_Qnx
std::vector< SG::AuxElement::Decorator< float > > m_decHalfFCalEtC_Qnx
Definition: HIGlobalAugmentationTool.h:58
DerivationFramework::HIGlobalAugmentationTool::m_decHalfFCalEtA_Qny
std::vector< SG::AuxElement::Decorator< float > > m_decHalfFCalEtA_Qny
Definition: HIGlobalAugmentationTool.h:57
DerivationFramework::HIGlobalAugmentationTool::addBranches
virtual StatusCode addBranches(const EventContext &ctx) const
Definition: HIGlobalAugmentationTool.cxx:59
DerivationFramework::HIGlobalAugmentationTool::m_decHalfFCalEtC_Qny
std::vector< SG::AuxElement::Decorator< float > > m_decHalfFCalEtC_Qny
Definition: HIGlobalAugmentationTool.h:59
DerivationFramework::HIGlobalAugmentationTool::initialize
StatusCode initialize()
Definition: HIGlobalAugmentationTool.cxx:22
SG::AllowEmpty
@ AllowEmpty
Definition: StoreGate/StoreGate/VarHandleKey.h:27