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 ) : AthAlgTool(t,n,p)
21  {
22  declareInterface<DerivationFramework::IAugmentationTool>(this);
23  declareProperty("InDetTrackParticlesKey", m_TP_key="InDetTrackParticles");
24  declareProperty("TrackSelectionTools", m_trkSelTools, "Track selection tools" );
25  declareProperty("cutLevels", m_cutLevels, "Cut levels");
26  declareProperty("nHarmonic", m_nHarmonic = 1, "Flow harmonic starting from v2" );
27  }
28 
29  // Destructor
31  {
32  }
33 
34  // Athena initialize and finalize
36  {
37  unsigned int nTrackSels = m_trkSelTools.size();
38  for (unsigned int its = 0; its < nTrackSels; ++its) {
40  m_decTrack_count.emplace_back(SG::AuxElement::Decorator<int>("TrackParticleMultiplicity_" + m_cutLevels[its] ));
41  }
42  //initilize decorators for flow vectors
43  for (int vn = 1; vn <= m_nHarmonic; ++vn) {
44  m_decFCalEtA_Qnx.emplace_back(SG::AuxElement::Decorator<float>(std::format("FCalEtA_Q{}x", vn + 1)));
45  m_decFCalEtA_Qny.emplace_back(SG::AuxElement::Decorator<float>(std::format("FCalEtA_Q{}y", vn + 1)));
46  m_decFCalEtC_Qnx.emplace_back(SG::AuxElement::Decorator<float>(std::format("FCalEtC_Q{}x", vn + 1)));
47  m_decFCalEtC_Qny.emplace_back(SG::AuxElement::Decorator<float>(std::format("FCalEtC_Q{}y", vn + 1)));
48 
49  // half FCal is for FCal with eta > 4.0 only
50  m_decHalfFCalEtA_Qnx.emplace_back(SG::AuxElement::Decorator<float>(std::format("HalfFCalEtA_Q{}x", vn + 1)));
51  m_decHalfFCalEtA_Qny.emplace_back(SG::AuxElement::Decorator<float>(std::format("HalfFCalEtA_Q{}y", vn + 1)));
52  m_decHalfFCalEtC_Qnx.emplace_back(SG::AuxElement::Decorator<float>(std::format("HalfFCalEtC_Q{}x", vn + 1)));
53  m_decHalfFCalEtC_Qny.emplace_back(SG::AuxElement::Decorator<float>(std::format("HalfFCalEtC_Q{}y", vn + 1)));
54  }
55 
56 
57  return StatusCode::SUCCESS;
58  }
60  {
61  for (auto trkSelTool : m_trkSelTools ) {
62  ATH_CHECK(trkSelTool->finalize());
63  }
64 
65  return StatusCode::SUCCESS;
66  }
67 
69  {
70 
71  //Load event EventInfo
72  const xAOD::EventInfo* eventInfo = nullptr;
73  if(evtStore()->retrieve( eventInfo ).isFailure()){
74  ATH_MSG_ERROR ("Cannot retrieve event info");
75  return StatusCode::FAILURE;
76  }
77 
78  //Load track particle container
79  const xAOD::TrackParticleContainer* tracks = evtStore()->retrieve< const xAOD::TrackParticleContainer >(m_TP_key);
80  if(!tracks)
81  {
82  ATH_MSG_ERROR ("Couldn't retrieve TrackParticleContainer with key " << m_TP_key);
83  return StatusCode::FAILURE;
84  }
85 
86  //Count tracks
87  unsigned int nTrackSels = m_trkSelTools.size();
88  std::vector <int> TrackParticleMultiplicity(nTrackSels,0);
89  for(auto tp : *tracks)
90  {
91  if(tp)
92  {
93  for (unsigned int its = 0; its < nTrackSels; ++its) {
94  if(m_trkSelTools[its]->accept(*tp)) ++TrackParticleMultiplicity[its];
95  }
96  }
97  }
98  //decorate eventInfo with track multiplicity
99  for (unsigned int its = 0; its < nTrackSels; ++its) {
100  (m_decTrack_count[its])(*eventInfo) = TrackParticleMultiplicity[its];
101  }
102 
103  float FCalEtA = 0;
104  float FCalEtC = 0;
105 
106  std::vector<float> FCalEtA_Qnx(m_nHarmonic,0);
107  std::vector<float> FCalEtA_Qny(m_nHarmonic,0);
108  std::vector<float> FCalEtC_Qnx(m_nHarmonic,0);
109  std::vector<float> FCalEtC_Qny(m_nHarmonic,0);
110 
111  float HalfFCalEtA = 0;
112  float HalfFCalEtC = 0;
113 
114  std::vector<float> HalfFCalEtA_Qnx(m_nHarmonic,0);
115  std::vector<float> HalfFCalEtA_Qny(m_nHarmonic,0);
116  std::vector<float> HalfFCalEtC_Qnx(m_nHarmonic,0);
117  std::vector<float> HalfFCalEtC_Qny(m_nHarmonic,0);
118 
119  // Set up the decorators for FCal Et
120  SG::AuxElement::Decorator< float > decFCalEtA("FCalEtA");
121  SG::AuxElement::Decorator< float > decFCalEtC("FCalEtC");
122 
123  SG::AuxElement::Decorator< float > decHalfFCalEtA("HalfFCalEtA");
124  SG::AuxElement::Decorator< float > decHalfFCalEtC("HalfFCalEtC");
125 
126  //Retrieve HIEventShape
127  const xAOD::HIEventShapeContainer *eventShape = nullptr;
128  if(evtStore()->retrieve( eventShape, "HIEventShape" ).isFailure()){
129  ATH_MSG_ERROR ("Cannot retrieve HIEventShape");
130  return StatusCode::FAILURE;
131  }
132 
133  //Calculate FCal A and FCal C sums
134  for(const auto* ptrEvtShp : *eventShape){
135  if(ptrEvtShp->layer()!=21 && ptrEvtShp->layer()!=22 &&
136  ptrEvtShp->layer()!=23) continue;
137 
138  float eta = ptrEvtShp->etaMin();
139  const std::vector<float>&c1 = ptrEvtShp->etCos();
140  const std::vector<float>&s1 = ptrEvtShp->etSin();
141 
142  if (eta > 0) {
143  FCalEtA += ptrEvtShp->et();
144  for (int vn = 1; vn <= m_nHarmonic; ++vn){
145  FCalEtA_Qnx.at(vn-1) += c1.at(vn);
146  FCalEtA_Qny.at(vn-1) += s1.at(vn);
147  }
148  if(eta > 4.0) {
149  HalfFCalEtA += ptrEvtShp->et();
150  for (int vn = 1; vn <= m_nHarmonic; ++vn){
151  HalfFCalEtA_Qnx.at(vn-1) += c1.at(vn);
152  HalfFCalEtA_Qny.at(vn-1) += s1.at(vn);
153  }
154  }
155  } else if (eta < 0) {
156  FCalEtC += ptrEvtShp->et();
157  for (int vn = 1; vn <= m_nHarmonic; ++vn){
158  FCalEtC_Qnx.at(vn-1) += c1.at(vn);
159  FCalEtC_Qny.at(vn-1) += s1.at(vn);
160  }
161  if(eta < -4.0){
162  HalfFCalEtC += ptrEvtShp->et();
163  for (int vn = 1; vn <= m_nHarmonic; ++vn){
164  HalfFCalEtC_Qnx.at(vn-1) += c1.at(vn);
165  HalfFCalEtC_Qny.at(vn-1) += s1.at(vn);
166  }
167  }
168  }
169  }
170  //decorate
171  decFCalEtA(*eventInfo) = FCalEtA;
172  decFCalEtC(*eventInfo) = FCalEtC;
173  decHalfFCalEtA(*eventInfo) = HalfFCalEtA;
174  decHalfFCalEtC(*eventInfo) = HalfFCalEtC;
175  for (int vn = 0; vn < m_nHarmonic; ++vn){
176  (m_decFCalEtA_Qnx[vn])(*eventInfo) = FCalEtA_Qnx.at(vn);
177  (m_decFCalEtA_Qny[vn])(*eventInfo) = FCalEtA_Qny.at(vn);
178  (m_decFCalEtC_Qnx[vn])(*eventInfo) = FCalEtC_Qnx.at(vn);
179  (m_decFCalEtC_Qny[vn])(*eventInfo) = FCalEtC_Qny.at(vn);
180  (m_decHalfFCalEtA_Qnx[vn])(*eventInfo) = HalfFCalEtA_Qnx.at(vn);
181  (m_decHalfFCalEtA_Qny[vn])(*eventInfo) = HalfFCalEtA_Qny.at(vn);
182  (m_decHalfFCalEtC_Qnx[vn])(*eventInfo) = HalfFCalEtC_Qnx.at(vn);
183  (m_decHalfFCalEtC_Qny[vn])(*eventInfo) = HalfFCalEtC_Qny.at(vn);
184  }
185 
186  return StatusCode::SUCCESS;
187  }
188 
189 }
190 
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
DerivationFramework::HIGlobalAugmentationTool::m_decTrack_count
std::vector< SG::AuxElement::Decorator< int > > m_decTrack_count
Definition: HIGlobalAugmentationTool.h:56
DerivationFramework::HIGlobalAugmentationTool::m_TP_key
std::string m_TP_key
Definition: HIGlobalAugmentationTool.h:41
vtune_athena.format
format
Definition: vtune_athena.py:14
DerivationFramework::HIGlobalAugmentationTool::addBranches
virtual StatusCode addBranches() const
Pass the thinning service
Definition: HIGlobalAugmentationTool.cxx:68
AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
HIGlobalAugmentationTool.h
DerivationFramework::HIGlobalAugmentationTool::m_decHalfFCalEtA_Qnx
std::vector< SG::AuxElement::Decorator< float > > m_decHalfFCalEtA_Qnx
Definition: HIGlobalAugmentationTool.h:51
CutsMETMaker::accept
StatusCode accept(const xAOD::Muon *mu)
Definition: CutsMETMaker.cxx:18
extractSporadic.c1
c1
Definition: extractSporadic.py:134
DerivationFramework::HIGlobalAugmentationTool::m_cutLevels
std::vector< std::string > m_cutLevels
Definition: HIGlobalAugmentationTool.h:43
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:59
DerivationFramework::HIGlobalAugmentationTool::m_decFCalEtC_Qnx
std::vector< SG::AuxElement::Decorator< float > > m_decFCalEtC_Qnx
Definition: HIGlobalAugmentationTool.h:48
DerivationFramework::HIGlobalAugmentationTool::m_decFCalEtA_Qny
std::vector< SG::AuxElement::Decorator< float > > m_decFCalEtA_Qny
Definition: HIGlobalAugmentationTool.h:47
AthCommonDataStore< AthCommonMsg< AlgTool > >::evtStore
ServiceHandle< StoreGateSvc > & evtStore()
The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:85
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
DerivationFramework::HIGlobalAugmentationTool::m_decFCalEtA_Qnx
std::vector< SG::AuxElement::Decorator< float > > m_decFCalEtA_Qnx
Definition: HIGlobalAugmentationTool.h:46
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
DerivationFramework::HIGlobalAugmentationTool::m_nHarmonic
int m_nHarmonic
Definition: HIGlobalAugmentationTool.h:40
SG::Decorator
Helper class to provide type-safe access to aux data.
Definition: Decorator.h:59
beamspotman.n
n
Definition: beamspotman.py:731
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:42
DataVector
Derived DataVector<T>.
Definition: DataVector.h:581
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:30
DerivationFramework::HIGlobalAugmentationTool::m_decFCalEtC_Qny
std::vector< SG::AuxElement::Decorator< float > > m_decFCalEtC_Qny
Definition: HIGlobalAugmentationTool.h:49
DerivationFramework::HIGlobalAugmentationTool::m_decHalfFCalEtC_Qnx
std::vector< SG::AuxElement::Decorator< float > > m_decHalfFCalEtC_Qnx
Definition: HIGlobalAugmentationTool.h:53
DerivationFramework::HIGlobalAugmentationTool::m_decHalfFCalEtA_Qny
std::vector< SG::AuxElement::Decorator< float > > m_decHalfFCalEtA_Qny
Definition: HIGlobalAugmentationTool.h:52
AthAlgTool
Definition: AthAlgTool.h:26
DerivationFramework::HIGlobalAugmentationTool::m_decHalfFCalEtC_Qny
std::vector< SG::AuxElement::Decorator< float > > m_decHalfFCalEtC_Qny
Definition: HIGlobalAugmentationTool.h:54
DerivationFramework::HIGlobalAugmentationTool::initialize
StatusCode initialize()
Definition: HIGlobalAugmentationTool.cxx:35
TrackParticleContainer.h