ATLAS Offline Software
eflowObject.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 /********************************************************************
6 
7 NAME: eflowObject.cxx
8 PACKAGE: offline/Reconstruction/eflowRec
9 
10 AUTHORS: D.R. Tovey
11 CREATED: 18th November, 2001
12 
13 UPDATED: 14th March 2003 (P Loch) implement navigation system
14 
15 UPDATED: 8th April 2004 (P Loch) implement new navigation scheme
16 
17 ********************************************************************/
18 
19 #include "FourMom/P4EEtaPhiM.h"
20 
21 #include "eflowEvent/eflowObject.h"
23 
24 #include "CaloEvent/CaloCluster.h"
25 #include "CaloEvent/CaloClusterContainer.h"
26 
27 #include "Particle/TrackParticle.h"
29 
30 #include "VxVertex/VxCandidate.h"
31 
32 #include <cmath>
33 #include <vector>
34 
38 
40 // temporary for navigation !!
41 #include <any>
42 
44  : P4EEtaPhiM(0.,0.,0.,0.),
45  m_passedEOverPCheck (true), //by default true
46  m_eflowObjectType (ChargedPion),
47  m_recoStatus(),
48  m_valid (true)
49 {
50 }
51 
52 eflowObject::eflowObject(eflowObject* eflowObj) : P4EEtaPhiM(eflowObj->e(),eflowObj->eta(),eflowObj->phi(),eflowObj->m())
53 {
54  this->initialize(eflowObj,true);
55 }
56 
57 eflowObject::eflowObject(eflowObject* eflowObj, bool useClus) : P4EEtaPhiM(eflowObj->e(),eflowObj->eta(),eflowObj->phi(),eflowObj->m())
58 {
59  this->initialize(eflowObj,useClus);
60 }
61 
62 
63 void eflowObject::initialize(eflowObject* eflowObj, bool useClus)
64 {
65  m_d0 = eflowObj->d0();
66  m_z0 = eflowObj->z0();
67  m_eflowType = eflowObj->eflowType();
68  m_charge = eflowObj->charge();
69  m_valid = eflowObj->isValid();
71  m_isSubtracted = eflowObj->getIsSubtracted();
72  m_isDuplicated = eflowObj->getIsDuplicated();
73  m_recoStatus = eflowObj->getCaloRecoStatus();
74  m_nTrack = eflowObj->numTrack();
75  m_nClus = eflowObj->numClus();
76  m_pi0MVA = eflowObj->getPi0MVA();
77  m_centerMag = eflowObj->getCenterMag();
79 
80  //add the conversion
81  this->addConversion(eflowObj->m_convElementLink);
82  //add the muon
83  this->addMuon(eflowObj->m_muonElementLink);
84 
85  //add any tracks
86  this->m_eflowTrack = eflowObj->m_eflowTrack;
87 
88  //*possibly* add some clusters
89  if (useClus) this->m_eflowClus = eflowObj->m_eflowClus;
90 
91 
92 }
93 
94 
96 {
98  delete c;
99 }
100 
103 }
104 
107  else{
108  const Analysis::Muon* muon(nullptr);
109  return muon;
110  }
111  }
112 
113 
114 // new interface supports persistency
116 {
117  m_eflowClus.addElement(clusElementLink);
118 }
119 
121 {
123  eflowCaloCluster* newClus = new eflowCaloCluster(clus);
124  newContainer->push_back(newClus);
125  m_eflowClus.addElement(newContainer,newClus);
126  m_eflowClusContainers.push_back(newContainer);
127 }
128 
129 
131 {
132  //const Rec::TrackParticleContainer* trackContainer = trackElementLink.getDataPtr();
133  //const Rec::TrackParticle* track = *trackElementLink;
134  //m_eflowTrack.addElement(trackContainer,track);
135  m_eflowTrack.addElement(trackElementLink);
136 }
137 
139 // Navigation //
141 
142 void
144  const std::any& aRelation) const
145 {
146  //---------------------------------------------------------------------------
147  // eflowObject can honor several queries:
148  //
149  // - CaloCluster
150  // - TrackParticle
151  // - Muon
152  // - Conversion
153  //
154  // There are two potential objects to forward the query to, CaloCluster and
155  // the egamma object.
156  //---------------------------------------------------------------------------
157 
158  // parameter type checking
159  double weight;
160  try { weight = std::any_cast<double>(aRelation); }
161  catch(...) { return; }
162 
164  // Calorimeter Response //
166 
167  if ( m_eflowClus.size() > 0 )
168  {
169  this->navigateClusters(m_eflowClus,thisToken,weight);
170  }
171 
173  // TrackParticle //
175 
176  // called from within navigateClusters for performance optimization
177 
179  // Muon //
181 
182  // called from within navigateClusters for performance optimization
183 
185  // Conversion //
187 
188  // called from within navigateClusters for performance optimization
189 
190 }
191 
193 // New Navigation: Temporary Implementation //
195 
196 // navigate CaloClusters
198  INavigationToken& thisToken,
199  double weight) const
200 {
201  // navigation with weights
202  NavigationToken<CaloCluster,double>* weightedToken =
203  dynamic_cast< NavigationToken<CaloCluster,double>* >(&thisToken);
204  NavigationToken<CaloCluster>* simpleToken =
205  weightedToken == nullptr
206  ? dynamic_cast< NavigationToken<CaloCluster>* >(&thisToken)
207  : nullptr;
208 
209  // query can not be honored, check on other types within eflowObject
210  bool isHonored = weightedToken != nullptr || simpleToken != nullptr;
211  if ( ! isHonored )
212  {
213  if ( m_eflowTrack.size() > 0 )
214  {
215  isHonored = this->navigateTrackParticles(thisToken,weight);
216  }
217  }
218  if ( ! isHonored )
219  {
220  isHonored = this->navigateMuons(thisToken,weight);
221  }
222  if ( ! isHonored )
223  {
224  isHonored = this->navigateConversions(thisToken,weight);
225  }
226 
227  // forward query
228  if ( ! isHonored )
229  {
230  for (const CaloCluster* c : theClusters)
231  {
232  c->fillToken(thisToken,weight);
233  }
234  }
235 
236  // fill token
237  else
238  {
239  if ( weightedToken != nullptr )
240  {
241  this->
242  toToken< cluster_type, NavigationToken<CaloCluster,double> >
243  (theClusters,weightedToken,weight);
244  }
245  else if (simpleToken != nullptr)
246  {
247  this->
248  toToken< cluster_type, NavigationToken<CaloCluster> >
249  (theClusters,simpleToken);
250  }
251  }
252 }
253 
254 // navigate TrackParticles
255 bool
257  double weight) const
258 {
260  dynamic_cast< NavigationToken<Rec::TrackParticle,double>* >(&thisToken);
262  weightedToken == nullptr
263  ? dynamic_cast< NavigationToken<Rec::TrackParticle>* >(&thisToken)
264  : nullptr;
265  bool isHonored = weightedToken != nullptr || simpleToken != nullptr;
266 
267  if ( isHonored )
268  {
269  if ( weightedToken != nullptr )
270  {
271  this->toToken< eflowTrack_type, NavigationToken<Rec::TrackParticle,double> >
272  (m_eflowTrack,weightedToken,weight);
273  }
274  else
275  {
276  this->toToken< eflowTrack_type, NavigationToken<Rec::TrackParticle> >
277  (m_eflowTrack,simpleToken);
278  }
279  }
280 
281  return isHonored;
282 }
283 
284 // navigate Muons
285 bool
287  double weight) const
288 {
290  dynamic_cast< NavigationToken<Analysis::Muon,double>* >(&thisToken);
291  NavigationToken<Analysis::Muon>* simpleToken =
292  weightedToken == nullptr
293  ? dynamic_cast< NavigationToken<Analysis::Muon>* >(&thisToken)
294  : nullptr;
295  // honored
296  bool isHonored = weightedToken != nullptr || simpleToken != nullptr;
297 
298  if ( isHonored )
299  {
300  if ( weightedToken != nullptr )
301  {
302  weightedToken->setObject(*m_muonElementLink,weight);
303  }
304  else
305  {
306  simpleToken->setObject(*m_muonElementLink);
307  }
308  }
309 
310  return isHonored;
311 }
312 
313 // navigate conversions
314 bool
316  double weight) const
317 {
319  dynamic_cast< NavigationToken<Trk::VxCandidate,double>* >(&thisToken);
320  NavigationToken<Trk::VxCandidate>* simpleToken =
321  weightedToken == nullptr
322  ? dynamic_cast< NavigationToken<Trk::VxCandidate>* >(&thisToken)
323  : nullptr;
324 
325  bool isHonored = weightedToken != nullptr || simpleToken != nullptr;
326 
327  if ( isHonored )
328  {
329  if ( weightedToken != nullptr )
330  {
331  weightedToken->setObject(*m_convElementLink,weight);
332  }
333  else
334  {
335  simpleToken->setObject(*m_convElementLink);
336  }
337  }
338 
339  return isHonored;
340 }
341 
342 template <typename CONT, typename TOKEN>
343 void
344 eflowObject::toToken(const CONT& theData,
345  TOKEN* theToken,
346  double weight) const
347 {
348  for (const auto* p : theData)
349  {
350  theToken->setObject(p,weight);
351  }
352 }
353 
354 template <typename CONT, typename TOKEN>
355 void
356 eflowObject::toToken(const CONT& theData,
357  TOKEN* theToken) const
358 {
359  for (const auto* p : theData)
360  {
361  theToken->setObject(p);
362  }
363 }
364 
366 
368 
369 
NavigableVector::size
unsigned int size() const
Definition: NavigableVector.h:61
INavigationToken.h
eflowObject::eflowObject
eflowObject()
Definition: eflowObject.cxx:43
eflowObject::navigateMuons
bool navigateMuons(INavigationToken &aToken, double weight) const
Definition: eflowObject.cxx:286
eflowObject::m_passedEOverPCheck
bool m_passedEOverPCheck
Definition: eflowObject.h:195
python.SystemOfUnits.m
int m
Definition: SystemOfUnits.py:91
TrackParticle.h
phi
Scalar phi() const
phi method
Definition: AmgMatrixBasePlugin.h:64
SG::VIEW_ELEMENTS
@ VIEW_ELEMENTS
this data object is a view, it does not own its elmts
Definition: OwnershipPolicy.h:18
eta
Scalar eta() const
pseudorapidity method
Definition: AmgMatrixBasePlugin.h:79
eflowObject::d0
double d0() const
Definition: eflowObject.h:140
CaloClusterContainer
Storable container for CaloCluster.
Definition: Calorimeter/CaloEvent/CaloEvent/CaloClusterContainer.h:37
eflowObject::z0
double z0() const
Definition: eflowObject.h:143
eflowObject::conversionLink
const ElementLink< VxContainer > & conversionLink() const
Definition: eflowObject.cxx:367
I4Momentum::p
virtual double p() const =0
momentum magnitude
NavigationToken.h
eflowObject::addConversion
void addConversion(const ElementLink< VxContainer > &convElementLink)
Definition: eflowObject.h:130
eflowObject::getCaloRecoStatus
CaloRecoStatus getCaloRecoStatus() const
Definition: eflowObject.h:185
P4EEtaPhiM
Definition: P4EEtaPhiM.h:25
eflowObject::m_nTrack
int m_nTrack
Definition: eflowObject.h:234
eflowObject::eflowType
int eflowType() const
Definition: eflowObject.h:151
eflowObject
Definition: eflowObject.h:60
eflowObject::addClus
void addClus(const ElementLink< CaloClusterContainer > &clusElementLink)
Definition: eflowObject.cxx:115
particleType
Definition: particleType.h:29
eflowObject::m_isDuplicated
bool m_isDuplicated
Definition: eflowObject.h:197
eflowObject::navigateConversions
bool navigateConversions(INavigationToken &aToken, double weight) const
Definition: eflowObject.cxx:315
dqt_zlumi_pandas.weight
int weight
Definition: dqt_zlumi_pandas.py:200
eflowObject::getPi0MVA
double getPi0MVA() const
Definition: eflowObject.h:161
eflowObject::m_pi0MVA
double m_pi0MVA
Definition: eflowObject.h:241
eflowCaloCluster
Definition: eflowCaloCluster.h:30
eflowObject::~eflowObject
~eflowObject()
Definition: eflowObject.cxx:95
NavigableVector< CaloClusterContainer >
eflowObject::muon
const Analysis::Muon * muon() const
Definition: eflowObject.cxx:105
eflowObject::initialize
void initialize(eflowObject *eflowObj, bool useClus)
Definition: eflowObject.cxx:63
INavigationToken
Definition: INavigationToken.h:24
eflowObject::m_recoStatus
CaloRecoStatus m_recoStatus
Definition: eflowObject.h:229
CaloCluster
Principal data class for CaloCell clusters.
Definition: Calorimeter/CaloEvent/CaloEvent/CaloCluster.h:79
eflowObject::toToken
void toToken(const CONT &theClusters, TOKEN *aToken, double weight) const
Definition: eflowObject.cxx:344
eflowObject::addTrack
void addTrack(const ElementLink< Rec::TrackParticleContainer > &trackElementLink)
Definition: eflowObject.cxx:130
Analysis::Muon
The ATLAS Muon object - see doxygen, physics workbookd and the Muon Combined Performance WG's pages f...
Definition: Reconstruction/MuonIdentification/muonEvent/muonEvent/Muon.h:48
NavigationToken::setObject
void setObject(const_child_ptr data)
Definition: NavigationToken.h:252
eflowObject::m_eflowObjectType
ParticleType m_eflowObjectType
Definition: eflowObject.h:218
eflowCaloCluster.h
eflowObject::ParticleType
ParticleType
Definition: eflowObject.h:76
eflowObject::m_eflowClusContainers
std::vector< CaloClusterContainer * > m_eflowClusContainers
Definition: eflowObject.h:220
VxCandidate.h
eflowObject::m_d0
double m_d0
Definition: eflowObject.h:231
P4EEtaPhiM.h
eflowObject::numClus
int numClus() const
Definition: eflowObject.h:122
NavigationToken
Definition: NavigationToken.h:50
DataVector::push_back
value_type push_back(value_type pElem)
Add an element to the end of the collection.
eflowObject::m_valid
bool m_valid
Definition: eflowObject.h:236
eflowObject::m_centerMag
double m_centerMag
Definition: eflowObject.h:242
eflowObject::m_isSubtracted
bool m_isSubtracted
Definition: eflowObject.h:196
eflowObject::m_eflowTrack
eflowTrack_type m_eflowTrack
Definition: eflowObject.h:226
eflowObject.h
NavigableVector::addElement
void addElement(const CONT *aContainer, const OBJCT *anObject)
Definition: NavigableVector.h:42
CaloClusterContainer
CaloClusterContainer
Definition: CaloTPCnv.cxx:21
eflowObject::m_muonElementLink
ElementLink< Analysis::MuonContainer > m_muonElementLink
Definition: eflowObject.h:238
NavigableVector.h
eflowObject::getIsSubtracted
bool getIsSubtracted() const
Definition: eflowObject.h:179
DiTauMassTools::MaxHistStrategyV2::e
e
Definition: PhysicsAnalysis/TauID/DiTauMassTools/DiTauMassTools/HelperFunctions.h:26
eflowObject::muonLink
const ElementLink< Analysis::MuonContainer > & muonLink() const
Definition: eflowObject.cxx:365
eflowObject::getCenterMag
double getCenterMag() const
Definition: eflowObject.h:188
eflowObject::charge
int charge() const
Definition: eflowObject.h:154
eflowObject::getPassEOverPCheck
bool getPassEOverPCheck() const
Definition: eflowObject.h:176
eflowObject::m_eflowType
int m_eflowType
Definition: eflowObject.h:233
eflowObject::m_nClus
int m_nClus
Definition: eflowObject.h:234
eflowObject::isValid
bool isValid() const
Definition: eflowObject.h:157
eflowObject::numTrack
int numTrack() const
Definition: eflowObject.h:121
eflowObject::m_z0
double m_z0
Definition: eflowObject.h:231
eflowObject::navigateTrackParticles
bool navigateTrackParticles(INavigationToken &aToken, double weight) const
Definition: eflowObject.cxx:256
eflowObject::m_charge
int m_charge
Definition: eflowObject.h:233
eflowObject::m_convElementLink
ElementLink< VxContainer > m_convElementLink
Definition: eflowObject.h:239
eflowObject::navigateClusters
void navigateClusters(const cluster_type &theClusters, INavigationToken &aToken, double weight) const
Definition: eflowObject.cxx:197
eflowObject::checkParticleType
bool checkParticleType(ParticleType particleType) const
Definition: eflowObject.cxx:101
eflowObject::clus
const CaloCluster * clus(size_t i) const
Definition: eflowObject.h:112
python.compressB64.c
def c
Definition: compressB64.py:93
eflowObject::m_eflowClus
eflowClus_type m_eflowClus
Definition: eflowObject.h:223
eflowObject::fillToken
virtual void fillToken(INavigationToken &thisToken) const
Definition: eflowObject.h:165
eflowObject::addMuon
void addMuon(const ElementLink< Analysis::MuonContainer > &muonElementLink)
Definition: eflowObject.h:126
TrackParticleContainer.h
eflowObject::getIsDuplicated
bool getIsDuplicated() const
Definition: eflowObject.h:182