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 {
10  // Athena initialize and finalize
12  {
15  ATH_CHECK( m_eventShapeKey.initialize() );
16  ATH_CHECK( m_caloClusterKey.initialize(SG::AllowEmpty) ); // Only needed if m_doTopoClusDec = True
17  unsigned int nTrackSels = m_trkSelTools.size();
18  for (unsigned int its = 0; its < nTrackSels; ++its) {
20  m_decTrack_count.emplace_back(SG::AuxElement::Decorator<int>("TrackParticleMultiplicity_" + m_cutLevels[its] ));
21  }
22  //initilize decorators for flow vectors
23  for (int vn = 1; vn <= m_nHarmonic; ++vn) {
24  m_decFCalEtA_Qnx.emplace_back(SG::AuxElement::Decorator<float>(std::format("FCalEtA_Q{}x", vn + 1)));
25  m_decFCalEtA_Qny.emplace_back(SG::AuxElement::Decorator<float>(std::format("FCalEtA_Q{}y", vn + 1)));
26  m_decFCalEtC_Qnx.emplace_back(SG::AuxElement::Decorator<float>(std::format("FCalEtC_Q{}x", vn + 1)));
27  m_decFCalEtC_Qny.emplace_back(SG::AuxElement::Decorator<float>(std::format("FCalEtC_Q{}y", vn + 1)));
28 
29  // half FCal is for FCal with eta > 4.0 only
30  m_decHalfFCalEtA_Qnx.emplace_back(SG::AuxElement::Decorator<float>(std::format("HalfFCalEtA_Q{}x", vn + 1)));
31  m_decHalfFCalEtA_Qny.emplace_back(SG::AuxElement::Decorator<float>(std::format("HalfFCalEtA_Q{}y", vn + 1)));
32  m_decHalfFCalEtC_Qnx.emplace_back(SG::AuxElement::Decorator<float>(std::format("HalfFCalEtC_Q{}x", vn + 1)));
33  m_decHalfFCalEtC_Qny.emplace_back(SG::AuxElement::Decorator<float>(std::format("HalfFCalEtC_Q{}y", vn + 1)));
34  }
35 
36 
37  return StatusCode::SUCCESS;
38  }
40  {
41  for (auto trkSelTool : m_trkSelTools ) {
42  ATH_CHECK(trkSelTool->finalize());
43  }
44 
45  return StatusCode::SUCCESS;
46  }
47 
48  StatusCode HIGlobalAugmentationTool::addBranches(const EventContext& ctx) const
49  {
51 
52  //Load track particle container
54  if (!tracks.isValid()) {
55  ATH_MSG_ERROR ("Couldn't retrieve TrackParticleContainer with key " << m_TP_key);
56  return StatusCode::FAILURE;
57  }
58 
59  //Count tracks
60  unsigned int nTrackSels = m_trkSelTools.size();
61  std::vector <int> TrackParticleMultiplicity(nTrackSels,0);
62  for (const auto* tp : *tracks) {
63  if (tp) {
64  for (unsigned int its = 0; its < nTrackSels; ++its) {
65  if (m_trkSelTools[its]->accept(*tp)) ++TrackParticleMultiplicity[its];
66  }
67  }
68  }
69  //decorate eventInfo with track multiplicity
70  for (unsigned int its = 0; its < nTrackSels; ++its) {
71  (m_decTrack_count[its])(*eventInfo) = TrackParticleMultiplicity[its];
72  }
73 
74  float FCalEtA = 0;
75  float FCalEtC = 0;
76 
77  std::vector<float> FCalEtA_Qnx(m_nHarmonic,0);
78  std::vector<float> FCalEtA_Qny(m_nHarmonic,0);
79  std::vector<float> FCalEtC_Qnx(m_nHarmonic,0);
80  std::vector<float> FCalEtC_Qny(m_nHarmonic,0);
81 
82  float HalfFCalEtA = 0;
83  float HalfFCalEtC = 0;
84 
85  std::vector<float> HalfFCalEtA_Qnx(m_nHarmonic,0);
86  std::vector<float> HalfFCalEtA_Qny(m_nHarmonic,0);
87  std::vector<float> HalfFCalEtC_Qnx(m_nHarmonic,0);
88  std::vector<float> HalfFCalEtC_Qny(m_nHarmonic,0);
89 
90  // Set up the decorators for FCal Et
91  SG::AuxElement::Decorator< float > decFCalEtA("FCalEtA");
92  SG::AuxElement::Decorator< float > decFCalEtC("FCalEtC");
93 
94  SG::AuxElement::Decorator< float > decHalfFCalEtA("HalfFCalEtA");
95  SG::AuxElement::Decorator< float > decHalfFCalEtC("HalfFCalEtC");
96 
97  //Retrieve HIEventShape
99  if (!eventShape.isValid()){
100  ATH_MSG_ERROR ("Cannot retrieve HIEventShape");
101  return StatusCode::FAILURE;
102  }
103 
104  //Calculate FCal A and FCal C sums
105  for(const auto* ptrEvtShp : *eventShape){
106  if(ptrEvtShp->layer()!=21 && ptrEvtShp->layer()!=22 &&
107  ptrEvtShp->layer()!=23) continue;
108 
109  float eta = ptrEvtShp->etaMin();
110  const std::vector<float>&c1 = ptrEvtShp->etCos();
111  const std::vector<float>&s1 = ptrEvtShp->etSin();
112 
113  if (eta > 0) {
114  FCalEtA += ptrEvtShp->et();
115  for (int vn = 1; vn <= m_nHarmonic; ++vn){
116  FCalEtA_Qnx.at(vn-1) += c1.at(vn);
117  FCalEtA_Qny.at(vn-1) += s1.at(vn);
118  }
119  if(eta > 4.0) {
120  HalfFCalEtA += ptrEvtShp->et();
121  for (int vn = 1; vn <= m_nHarmonic; ++vn){
122  HalfFCalEtA_Qnx.at(vn-1) += c1.at(vn);
123  HalfFCalEtA_Qny.at(vn-1) += s1.at(vn);
124  }
125  }
126  } else if (eta < 0) {
127  FCalEtC += ptrEvtShp->et();
128  for (int vn = 1; vn <= m_nHarmonic; ++vn){
129  FCalEtC_Qnx.at(vn-1) += c1.at(vn);
130  FCalEtC_Qny.at(vn-1) += s1.at(vn);
131  }
132  if(eta < -4.0){
133  HalfFCalEtC += ptrEvtShp->et();
134  for (int vn = 1; vn <= m_nHarmonic; ++vn){
135  HalfFCalEtC_Qnx.at(vn-1) += c1.at(vn);
136  HalfFCalEtC_Qny.at(vn-1) += s1.at(vn);
137  }
138  }
139  }
140  }
141 
142  if (m_doTopoClusDec) {
143  // Setup the decorator for TopoCaloCluster cut
144  // If this is true, the event is not compatible with UPC topologies in the FCal
145  SG::AuxElement::Decorator< bool > decTopoClusterFCalCut("passUPCTopoCaloCut");
146  //Default decoration set to false
147  decTopoClusterFCalCut(*eventInfo) = false;
148 
149  //access topoClusters
151  bool hasTowerA{false};
152  bool hasTowerC{false};
153  for (const auto topo : *topos) {
154  float topo_eta = topo->eta();
155  if (abs(topo_eta) > 3.2 && abs(topo_eta) < 4.9) {
156  float topo_pt = topo->pt() * 1e-3;
157  if (topo_pt > 0.4) {
158  if (topo_eta > 0) {
159  hasTowerA = true;
160  } else {
161  hasTowerC = true;
162  }
163  }
164  }
165  }
166  //decorate
167  decTopoClusterFCalCut(*eventInfo) = (hasTowerA && hasTowerC);
168  }
169 
170 
171  //decorate
172  decFCalEtA(*eventInfo) = FCalEtA;
173  decFCalEtC(*eventInfo) = FCalEtC;
174  decHalfFCalEtA(*eventInfo) = HalfFCalEtA;
175  decHalfFCalEtC(*eventInfo) = HalfFCalEtC;
176 
177  for (int vn = 0; vn < m_nHarmonic; ++vn){
178  (m_decFCalEtA_Qnx[vn])(*eventInfo) = FCalEtA_Qnx.at(vn);
179  (m_decFCalEtA_Qny[vn])(*eventInfo) = FCalEtA_Qny.at(vn);
180  (m_decFCalEtC_Qnx[vn])(*eventInfo) = FCalEtC_Qnx.at(vn);
181  (m_decFCalEtC_Qny[vn])(*eventInfo) = FCalEtC_Qny.at(vn);
182  (m_decHalfFCalEtA_Qnx[vn])(*eventInfo) = HalfFCalEtA_Qnx.at(vn);
183  (m_decHalfFCalEtA_Qny[vn])(*eventInfo) = HalfFCalEtA_Qny.at(vn);
184  (m_decHalfFCalEtC_Qnx[vn])(*eventInfo) = HalfFCalEtC_Qnx.at(vn);
185  (m_decHalfFCalEtC_Qny[vn])(*eventInfo) = HalfFCalEtC_Qny.at(vn);
186  }
187 
188  return StatusCode::SUCCESS;
189  }
190 
191 }
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
AllowedVariables::e
e
Definition: AsgElectronSelectorTool.cxx:37
DerivationFramework::HIGlobalAugmentationTool::addBranches
virtual StatusCode addBranches(const EventContext &ctx) const override final
Definition: HIGlobalAugmentationTool.cxx:48
DerivationFramework::HIGlobalAugmentationTool::m_decTrack_count
std::vector< SG::AuxElement::Decorator< int > > m_decTrack_count
Definition: HIGlobalAugmentationTool.h:61
DerivationFramework::HIGlobalAugmentationTool::initialize
virtual StatusCode initialize() override final
Definition: HIGlobalAugmentationTool.cxx:11
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
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:79
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
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
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::m_eventInfoKey
SG::ReadHandleKey< xAOD::EventInfo > m_eventInfoKey
Definition: HIGlobalAugmentationTool.h:43
DerivationFramework::HIGlobalAugmentationTool::finalize
virtual StatusCode finalize() override final
Definition: HIGlobalAugmentationTool.cxx:39
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::m_decHalfFCalEtC_Qny
std::vector< SG::AuxElement::Decorator< float > > m_decHalfFCalEtC_Qny
Definition: HIGlobalAugmentationTool.h:59
SG::AllowEmpty
@ AllowEmpty
Definition: StoreGate/StoreGate/VarHandleKey.h:27