ATLAS Offline Software
HIGlobalAugmentationTool.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 // HIGlobalAugmentationTool.cxx, (c) ATLAS Detector software
8 
13 #include <vector>
14 #include <format>
15 
16 namespace DerivationFramework
17 {
19  const std::string& n,
20  const IInterface* p ) : base_class(t,n,p)
21  {
22  declareProperty("InDetTrackParticlesKey", m_TP_key="InDetTrackParticles");
23  declareProperty("TrackSelectionTools", m_trkSelTools, "Track selection tools" );
24  declareProperty("cutLevels", m_cutLevels, "Cut levels");
25  declareProperty("nHarmonic", m_nHarmonic = 1, "Flow harmonic starting from v2" );
26  }
27 
28  // Destructor
30  {
31  }
32 
33  // Athena initialize and finalize
35  {
36  unsigned int nTrackSels = m_trkSelTools.size();
37  for (unsigned int its = 0; its < nTrackSels; ++its) {
39  m_decTrack_count.emplace_back(SG::AuxElement::Decorator<int>("TrackParticleMultiplicity_" + m_cutLevels[its] ));
40  }
41  //initilize decorators for flow vectors
42  for (int vn = 1; vn <= m_nHarmonic; ++vn) {
43  m_decFCalEtA_Qnx.emplace_back(SG::AuxElement::Decorator<float>(std::format("FCalEtA_Q{}x", vn + 1)));
44  m_decFCalEtA_Qny.emplace_back(SG::AuxElement::Decorator<float>(std::format("FCalEtA_Q{}y", vn + 1)));
45  m_decFCalEtC_Qnx.emplace_back(SG::AuxElement::Decorator<float>(std::format("FCalEtC_Q{}x", vn + 1)));
46  m_decFCalEtC_Qny.emplace_back(SG::AuxElement::Decorator<float>(std::format("FCalEtC_Q{}y", vn + 1)));
47 
48  // half FCal is for FCal with eta > 4.0 only
49  m_decHalfFCalEtA_Qnx.emplace_back(SG::AuxElement::Decorator<float>(std::format("HalfFCalEtA_Q{}x", vn + 1)));
50  m_decHalfFCalEtA_Qny.emplace_back(SG::AuxElement::Decorator<float>(std::format("HalfFCalEtA_Q{}y", vn + 1)));
51  m_decHalfFCalEtC_Qnx.emplace_back(SG::AuxElement::Decorator<float>(std::format("HalfFCalEtC_Q{}x", vn + 1)));
52  m_decHalfFCalEtC_Qny.emplace_back(SG::AuxElement::Decorator<float>(std::format("HalfFCalEtC_Q{}y", vn + 1)));
53  }
54 
55 
56  return StatusCode::SUCCESS;
57  }
59  {
60  for (auto trkSelTool : m_trkSelTools ) {
61  ATH_CHECK(trkSelTool->finalize());
62  }
63 
64  return StatusCode::SUCCESS;
65  }
66 
68  {
69 
70  //Load event EventInfo
71  const xAOD::EventInfo* eventInfo = nullptr;
72  if(evtStore()->retrieve( eventInfo ).isFailure()){
73  ATH_MSG_ERROR ("Cannot retrieve event info");
74  return StatusCode::FAILURE;
75  }
76 
77  //Load track particle container
78  const xAOD::TrackParticleContainer* tracks = evtStore()->retrieve< const xAOD::TrackParticleContainer >(m_TP_key);
79  if(!tracks)
80  {
81  ATH_MSG_ERROR ("Couldn't retrieve TrackParticleContainer with key " << m_TP_key);
82  return StatusCode::FAILURE;
83  }
84 
85  //Count tracks
86  unsigned int nTrackSels = m_trkSelTools.size();
87  std::vector <int> TrackParticleMultiplicity(nTrackSels,0);
88  for(auto tp : *tracks)
89  {
90  if(tp)
91  {
92  for (unsigned int its = 0; its < nTrackSels; ++its) {
93  if(m_trkSelTools[its]->accept(*tp)) ++TrackParticleMultiplicity[its];
94  }
95  }
96  }
97  //decorate eventInfo with track multiplicity
98  for (unsigned int its = 0; its < nTrackSels; ++its) {
99  (m_decTrack_count[its])(*eventInfo) = TrackParticleMultiplicity[its];
100  }
101 
102  float FCalEtA = 0;
103  float FCalEtC = 0;
104 
105  std::vector<float> FCalEtA_Qnx(m_nHarmonic,0);
106  std::vector<float> FCalEtA_Qny(m_nHarmonic,0);
107  std::vector<float> FCalEtC_Qnx(m_nHarmonic,0);
108  std::vector<float> FCalEtC_Qny(m_nHarmonic,0);
109 
110  float HalfFCalEtA = 0;
111  float HalfFCalEtC = 0;
112 
113  std::vector<float> HalfFCalEtA_Qnx(m_nHarmonic,0);
114  std::vector<float> HalfFCalEtA_Qny(m_nHarmonic,0);
115  std::vector<float> HalfFCalEtC_Qnx(m_nHarmonic,0);
116  std::vector<float> HalfFCalEtC_Qny(m_nHarmonic,0);
117 
118  // Set up the decorators for FCal Et
119  SG::AuxElement::Decorator< float > decFCalEtA("FCalEtA");
120  SG::AuxElement::Decorator< float > decFCalEtC("FCalEtC");
121 
122  SG::AuxElement::Decorator< float > decHalfFCalEtA("HalfFCalEtA");
123  SG::AuxElement::Decorator< float > decHalfFCalEtC("HalfFCalEtC");
124 
125  //Retrieve HIEventShape
126  const xAOD::HIEventShapeContainer *eventShape = nullptr;
127  if(evtStore()->retrieve( eventShape, "HIEventShape" ).isFailure()){
128  ATH_MSG_ERROR ("Cannot retrieve HIEventShape");
129  return StatusCode::FAILURE;
130  }
131 
132  //Calculate FCal A and FCal C sums
133  for(const auto* ptrEvtShp : *eventShape){
134  if(ptrEvtShp->layer()!=21 && ptrEvtShp->layer()!=22 &&
135  ptrEvtShp->layer()!=23) continue;
136 
137  float eta = ptrEvtShp->etaMin();
138  const std::vector<float>&c1 = ptrEvtShp->etCos();
139  const std::vector<float>&s1 = ptrEvtShp->etSin();
140 
141  if (eta > 0) {
142  FCalEtA += ptrEvtShp->et();
143  for (int vn = 1; vn <= m_nHarmonic; ++vn){
144  FCalEtA_Qnx.at(vn-1) += c1.at(vn);
145  FCalEtA_Qny.at(vn-1) += s1.at(vn);
146  }
147  if(eta > 4.0) {
148  HalfFCalEtA += ptrEvtShp->et();
149  for (int vn = 1; vn <= m_nHarmonic; ++vn){
150  HalfFCalEtA_Qnx.at(vn-1) += c1.at(vn);
151  HalfFCalEtA_Qny.at(vn-1) += s1.at(vn);
152  }
153  }
154  } else if (eta < 0) {
155  FCalEtC += ptrEvtShp->et();
156  for (int vn = 1; vn <= m_nHarmonic; ++vn){
157  FCalEtC_Qnx.at(vn-1) += c1.at(vn);
158  FCalEtC_Qny.at(vn-1) += s1.at(vn);
159  }
160  if(eta < -4.0){
161  HalfFCalEtC += ptrEvtShp->et();
162  for (int vn = 1; vn <= m_nHarmonic; ++vn){
163  HalfFCalEtC_Qnx.at(vn-1) += c1.at(vn);
164  HalfFCalEtC_Qny.at(vn-1) += s1.at(vn);
165  }
166  }
167  }
168  }
169 
170  // Setup the decorator for TopoCaloCluster cut
171  // If this is true, the event is not compatible with UPC topologies in the FCal
172  SG::AuxElement::Decorator< bool > decTopoClusterFCalCut("passUPCTopoCaloCut");
173  //Default decoration set to false
174  decTopoClusterFCalCut(*eventInfo) = false;
175 
176  //access topoClusters
177  const xAOD::CaloClusterContainer *topos = 0;
178  ATH_CHECK(evtStore()->retrieve(topos, "CaloCalTopoClusters"));
179  bool hasTowerA{false};
180  bool hasTowerC{false};
181  for (const auto topo : *topos) {
182  float topo_eta = topo->eta();
183  if (abs(topo_eta) > 3.2 && abs(topo_eta) < 4.9) {
184  float topo_pt = topo->pt() * 1e-3;
185  if (topo_pt > 0.4) {
186  if (topo_eta > 0) {
187  hasTowerA = true;
188  } else {
189  hasTowerC = true;
190  }
191  }
192  }
193  }
194 
195 
196  //decorate
197  decFCalEtA(*eventInfo) = FCalEtA;
198  decFCalEtC(*eventInfo) = FCalEtC;
199  decHalfFCalEtA(*eventInfo) = HalfFCalEtA;
200  decHalfFCalEtC(*eventInfo) = HalfFCalEtC;
201  decTopoClusterFCalCut(*eventInfo) = (hasTowerA && hasTowerC);
202 
203  for (int vn = 0; vn < m_nHarmonic; ++vn){
204  (m_decFCalEtA_Qnx[vn])(*eventInfo) = FCalEtA_Qnx.at(vn);
205  (m_decFCalEtA_Qny[vn])(*eventInfo) = FCalEtA_Qny.at(vn);
206  (m_decFCalEtC_Qnx[vn])(*eventInfo) = FCalEtC_Qnx.at(vn);
207  (m_decFCalEtC_Qny[vn])(*eventInfo) = FCalEtC_Qny.at(vn);
208  (m_decHalfFCalEtA_Qnx[vn])(*eventInfo) = HalfFCalEtA_Qnx.at(vn);
209  (m_decHalfFCalEtA_Qny[vn])(*eventInfo) = HalfFCalEtA_Qny.at(vn);
210  (m_decHalfFCalEtC_Qnx[vn])(*eventInfo) = HalfFCalEtC_Qnx.at(vn);
211  (m_decHalfFCalEtC_Qny[vn])(*eventInfo) = HalfFCalEtC_Qny.at(vn);
212  }
213 
214  return StatusCode::SUCCESS;
215  }
216 
217 }
218 
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:57
DerivationFramework::HIGlobalAugmentationTool::m_TP_key
std::string m_TP_key
Definition: HIGlobalAugmentationTool.h:42
vtune_athena.format
format
Definition: vtune_athena.py:14
DerivationFramework::HIGlobalAugmentationTool::addBranches
virtual StatusCode addBranches() const
Definition: HIGlobalAugmentationTool.cxx:67
HIGlobalAugmentationTool.h
DerivationFramework::HIGlobalAugmentationTool::m_decHalfFCalEtA_Qnx
std::vector< SG::AuxElement::Decorator< float > > m_decHalfFCalEtA_Qnx
Definition: HIGlobalAugmentationTool.h:52
CutsMETMaker::accept
StatusCode accept(const xAOD::Muon *mu)
Definition: CutsMETMaker.cxx:18
extractSporadic.c1
c1
Definition: extractSporadic.py:133
DerivationFramework::HIGlobalAugmentationTool::m_cutLevels
std::vector< std::string > m_cutLevels
Definition: HIGlobalAugmentationTool.h:44
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:58
DerivationFramework::HIGlobalAugmentationTool::m_decFCalEtC_Qnx
std::vector< SG::AuxElement::Decorator< float > > m_decFCalEtC_Qnx
Definition: HIGlobalAugmentationTool.h:49
L1TopoRatesCalculator_submatrix_plotter.topo
topo
Definition: L1TopoRatesCalculator_submatrix_plotter.py:78
DerivationFramework::HIGlobalAugmentationTool::m_decFCalEtA_Qny
std::vector< SG::AuxElement::Decorator< float > > m_decFCalEtA_Qny
Definition: HIGlobalAugmentationTool.h:48
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:209
DerivationFramework::HIGlobalAugmentationTool::m_decFCalEtA_Qnx
std::vector< SG::AuxElement::Decorator< float > > m_decFCalEtA_Qnx
Definition: HIGlobalAugmentationTool.h:47
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
DerivationFramework::HIGlobalAugmentationTool::m_nHarmonic
int m_nHarmonic
Definition: HIGlobalAugmentationTool.h:41
SG::Decorator
Helper class to provide type-safe access to aux data.
Definition: Decorator.h:59
beamspotman.n
n
Definition: beamspotman.py:729
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
HIEventShapeContainer.h
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
DerivationFramework
THE reconstruction tool.
Definition: ParticleSortingAlg.h:24
DerivationFramework::HIGlobalAugmentationTool::m_trkSelTools
ToolHandleArray< InDet::IInDetTrackSelectionTool > m_trkSelTools
track selection tool which can be optionally used for N_trk and sum pt cuts
Definition: HIGlobalAugmentationTool.h:43
DataVector
Derived DataVector<T>.
Definition: DataVector.h:794
DerivationFramework::HIGlobalAugmentationTool::HIGlobalAugmentationTool
HIGlobalAugmentationTool(const std::string &t, const std::string &n, const IInterface *p)
Definition: HIGlobalAugmentationTool.cxx:18
EventInfo.h
xAOD::EventInfo_v1
Class describing the basic event information.
Definition: EventInfo_v1.h:43
DerivationFramework::HIGlobalAugmentationTool::~HIGlobalAugmentationTool
~HIGlobalAugmentationTool()
Definition: HIGlobalAugmentationTool.cxx:29
DerivationFramework::HIGlobalAugmentationTool::m_decFCalEtC_Qny
std::vector< SG::AuxElement::Decorator< float > > m_decFCalEtC_Qny
Definition: HIGlobalAugmentationTool.h:50
DerivationFramework::HIGlobalAugmentationTool::m_decHalfFCalEtC_Qnx
std::vector< SG::AuxElement::Decorator< float > > m_decHalfFCalEtC_Qnx
Definition: HIGlobalAugmentationTool.h:54
DerivationFramework::HIGlobalAugmentationTool::m_decHalfFCalEtA_Qny
std::vector< SG::AuxElement::Decorator< float > > m_decHalfFCalEtA_Qny
Definition: HIGlobalAugmentationTool.h:53
DerivationFramework::HIGlobalAugmentationTool::m_decHalfFCalEtC_Qny
std::vector< SG::AuxElement::Decorator< float > > m_decHalfFCalEtC_Qny
Definition: HIGlobalAugmentationTool.h:55
DerivationFramework::HIGlobalAugmentationTool::initialize
StatusCode initialize()
Definition: HIGlobalAugmentationTool.cxx:34
TrackParticleContainer.h