ATLAS Offline Software
Loading...
Searching...
No Matches
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
7NAME: eflowObject.cxx
8PACKAGE: offline/Reconstruction/eflowRec
9
10AUTHORS: D.R. Tovey
11CREATED: 18th November, 2001
12
13UPDATED: 14th March 2003 (P Loch) implement navigation system
14
15UPDATED: 8th April 2004 (P Loch) implement new navigation scheme
16
17********************************************************************/
18
19#include "FourMom/P4EEtaPhiM.h"
20
23
24#include "CaloEvent/CaloCluster.h"
25#include "CaloEvent/CaloClusterContainer.h"
26
29
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
48 m_valid (true)
49{
50}
51
52eflowObject::eflowObject(eflowObject* eflowObj) : P4EEtaPhiM(eflowObj->e(),eflowObj->eta(),eflowObj->phi(),eflowObj->m())
53{
54 this->initialize(eflowObj,true);
55}
56
57eflowObject::eflowObject(eflowObject* eflowObj, bool useClus) : P4EEtaPhiM(eflowObj->e(),eflowObj->eta(),eflowObj->phi(),eflowObj->m())
58{
59 this->initialize(eflowObj,useClus);
60}
61
62
63void 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
100
104
106 if (m_muonElementLink.isValid()) return *m_muonElementLink;
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
142void
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
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->
243 (theClusters,weightedToken,weight);
244 }
245 else if (simpleToken != nullptr)
246 {
247 this->
249 (theClusters,simpleToken);
250 }
251 }
252}
253
254// navigate TrackParticles
255bool
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 {
272 (m_eflowTrack,weightedToken,weight);
273 }
274 else
275 {
277 (m_eflowTrack,simpleToken);
278 }
279 }
280
281 return isHonored;
282}
283
284// navigate Muons
285bool
287 double weight) const
288{
290 dynamic_cast< NavigationToken<Analysis::Muon,double>* >(&thisToken);
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
314bool
316 double weight) const
317{
319 dynamic_cast< NavigationToken<Trk::VxCandidate,double>* >(&thisToken);
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
342template <typename CONT, typename TOKEN>
343void
344eflowObject::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
354template <typename CONT, typename TOKEN>
355void
356eflowObject::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
CaloClusterContainer
Definition CaloTPCnv.cxx:21
The ATLAS Muon object - see doxygen, physics workbookd and the Muon Combined Performance WG's pages f...
Principal data class for CaloCell clusters.
value_type push_back(value_type pElem)
Add an element to the end of the collection.
virtual double p() const =0
momentum magnitude
void setObject(const_child_ptr data)
virtual double e() const
get energy data member
Definition P4EEtaPhiM.h:102
virtual double phi() const
get phi data member
Definition P4EEtaPhiM.h:108
P4EEtaPhiM(const double e, const double eta, const double phi, const double m)
constructor with all data members
Definition P4EEtaPhiM.cxx:7
virtual double eta() const
get eta data member
Definition P4EEtaPhiM.h:105
virtual double m() const
get mass data member
Definition P4EEtaPhiM.h:111
ElementLink< Analysis::MuonContainer > m_muonElementLink
bool m_isSubtracted
void addMuon(const ElementLink< Analysis::MuonContainer > &muonElementLink)
int numClus() const
CaloRecoStatus m_recoStatus
bool m_isDuplicated
int numTrack() const
double d0() const
CaloRecoStatus getCaloRecoStatus() const
int eflowType() const
bool navigateConversions(INavigationToken &aToken, double weight) const
std::vector< CaloClusterContainer * > m_eflowClusContainers
eflowTrack_type m_eflowTrack
void navigateClusters(const cluster_type &theClusters, INavigationToken &aToken, double weight) const
bool navigateTrackParticles(INavigationToken &aToken, double weight) const
void addTrack(const ElementLink< Rec::TrackParticleContainer > &trackElementLink)
virtual void fillToken(INavigationToken &thisToken) const
void addConversion(const ElementLink< VxContainer > &convElementLink)
const ElementLink< Analysis::MuonContainer > & muonLink() const
double m_pi0MVA
bool navigateMuons(INavigationToken &aToken, double weight) const
const ElementLink< VxContainer > & conversionLink() const
bool m_passedEOverPCheck
bool getIsDuplicated() const
bool getIsSubtracted() const
void addClus(const ElementLink< CaloClusterContainer > &clusElementLink)
double z0() const
ParticleType m_eflowObjectType
ElementLink< VxContainer > m_convElementLink
void initialize(eflowObject *eflowObj, bool useClus)
bool checkParticleType(ParticleType particleType) const
const CaloCluster * clus(size_t i) const
double m_centerMag
double getPi0MVA() const
double getCenterMag() const
const Analysis::Muon * muon() const
bool getPassEOverPCheck() const
void toToken(const CONT &theClusters, TOKEN *aToken, double weight) const
NavigableVector< CaloClusterContainer > cluster_type
Definition eflowObject.h:90
eflowClus_type m_eflowClus
int charge() const
bool isValid() const
@ VIEW_ELEMENTS
this data object is a view, it does not own its elmts
void initialize()