ATLAS Offline Software
Loading...
Searching...
No Matches
TrigBphys_v1.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3*/
4
5
6// xAOD include(s):
8
9// Local include(s):
13
14namespace xAOD {
15
17 : SG::AuxElement() {
18 } // TrigBphys_v1
19
20
21 //** initialise with defaults. Attempt to call this after creating a particle */
23 setRoiId(0);
24 setEta (0.);
25 setPhi (0.);
26 setPt (0.);
27 setMass (0.);
30 // set defaults
31 setFitmass(-99.);
32 setFitchi2(-99.);
33 setFitndof(-99.);
34 setFitx (-99.);
35 setFity (-99.);
36 setFitz (-99.);
37
38 setFitmassError( -99.);
39 setLxy ( -99.);
40 setLxyError( -99.);
41 setTau ( -99.);
42 setTauError( -99.);
43
44
45 // ensure that we clear unused variables
46 //secondaryDecay.clear();
47 //trackVector.clear();
48
49
50 } // initialise
51
52
53
55 if (this == &rhs) {
56 // if attempting to clone oneself, dont
57 return;
58 }
59 initialise(rhs.roiId(), rhs.eta(), rhs.phi(), rhs.pt(),
60 rhs.particleType(),
61 rhs.mass(), rhs.level());
62 setFitmass(rhs.fitmass());
63 setFitchi2(rhs.fitchi2());
64 setFitndof(rhs.fitndof());
65 setFitx (rhs.fitx());
66 setFity (rhs.fity());
67 setFitz (rhs.fitz());
68
71
75 }
76
77
78 //** initialise with default parameters */
79 void TrigBphys_v1::initialise(uint32_t roi, float eta, float phi, float pt,
81 float mass, levelType level) {
82 setRoiId(roi);
83 setEta (eta);
84 setPhi (phi);
85 setPt (pt);
86 setMass (mass);
89 // set defaults
90 setFitmass(-99.);
91 setFitchi2(-99.);
92 setFitndof(-99.);
93 setFitx (-99.);
94 setFity (-99.);
95 setFitz (-99.);
96
97 setFitmassError( -99.);
98 setLxy ( -99.);
99 setLxyError( -99.);
100 setTau ( -99.);
101 setTauError( -99.);
102
103 // ensure that we clear unused variables
104 //secondaryDecay.clear();
105 //trackVector.clear(); #FIXME
106
107 } //initialise
108
109
110 //** initialise with default parameters */
112 float mass, levelType level) {
113 // deprecated method, as pt is initialised to 0. here.
114 // use the alternative initialise method
115 setRoiId(roi);
116 setEta (eta);
117 setPhi (phi);
118 setPt (0.0);
119 setMass (mass);
122 // set defaults
123 setFitmass(-99.);
124 setFitchi2(-99.);
125 setFitndof(-99.);
126 setFitx (-99.);
127 setFity (-99.);
128 setFitz (-99.);
129
130 setFitmassError( -99.);
131 setLxy ( -99.);
132 setLxyError( -99.);
133 setTau ( -99.);
134 setTauError( -99.);
135
136 // ensure that we clear unused variables
137 //secondaryDecay.clear();
138 //trackVector.clear(); #FIXME
139
140 } //initialise
141
147 // deprecated method, as pt is initialised to 0. here.
148 // use the alternative initialise method
149
150 // call this method first, as it clears the trackVector and
152 setSecondaryDecayLink(sDecay);
153 } // initialise
154
157 void TrigBphys_v1::initialise(uint32_t roi, float eta, float phi, float pt,
161 // call this method first, as it clears the trackVector and
163 setSecondaryDecayLink(sDecay);
164 } // initialise
165
166
167 // use macros to create the getter and setter class methods
175 // no default pt method, as need to check if it exists for older file compatibility
177 AUXSTORE_PRIMITIVE_SETTER_AND_GETTER( xAOD::TrigBphys_v1, float, fitmass, setFitmass )
178 AUXSTORE_PRIMITIVE_SETTER_AND_GETTER( xAOD::TrigBphys_v1, float, fitchi2, setFitchi2 )
183
185 secondaryDecayLink, setSecondaryDecayLink )
186
187
189 static const Accessor< ElementLink< TrigBphysContainer_v1 > > acc( "secondaryDecayLink" );
190 if( ! acc.isAvailable( *this ) ) {
191 return nullptr;
192 }
193 const ElementLink< TrigBphysContainer_v1 > & sd = acc( *this );
194 if (sd.isValid()) {
195 return *sd;
196 } else {
197 return nullptr;
198 }
199 } //pSecondDecay
200
203 trackParticleLinks, setTrackParticleLinks )
204
205
207 trackAcc( "trackParticleLinks" );
208
209 size_t TrigBphys_v1::nTrackParticles() const {
210
211 if( ! trackAcc.isAvailable( *this ) ) {
212 return 0;
213 }
214 return trackAcc( *this ).size();
215 }
216
218
219 if( ! trackAcc.isAvailable( *this ) ) {
220 return nullptr;
221 }
222 if( i >= nTrackParticles() ) {
223 return nullptr;
224 }
225 if( ! trackAcc( *this )[ i ].isValid() ) {
226 return nullptr;
227 }
228 return *( trackAcc( *this )[ i ] );
229 }
230
233 trackAcc( *this ).push_back( track );
234 return;
235 } //addTrack
236
237 bool TrigBphys_v1::operator==(const TrigBphys_v1& rhs) const {
238 const double epsilon = 1e-5;
239
240 int aHasSD = (secondaryDecay() !=nullptr)?1:0;
241 int bHasSD = (rhs.secondaryDecay()!=nullptr)?1:0;
242 if((aHasSD+bHasSD)==1)
243 return false;
244
245 if(trackParticleLinks().size()!=rhs.trackParticleLinks().size())
246 return false;
247
248 if(roiId() != rhs.roiId()) return false;
249 if(particleType() != rhs.particleType()) return false;
250 if(level() != rhs.level()) return false;
251 if(fitndof() != rhs.fitndof()) return false;
252
253 if(fabs(eta()-rhs.eta())>epsilon) return false;
254 if(fabs(phi()-rhs.phi())>epsilon) return false;
255 if(fabs(pt()*0.001-rhs.pt()*0.001)>epsilon)return false; // internal conversion to GeV for more sensible comparison.
256 if(fabs(mass()*0.001-rhs.mass()*0.001)>epsilon) return false;
257 if(fabs(fitmass()-rhs.fitmass())>epsilon) return false;
258 if(fabs(fitchi2()-rhs.fitchi2())>epsilon) return false;
259 if(fabs(fitx()-rhs.fitx())>epsilon) return false;
260 if(fabs(fity()-rhs.fity())>epsilon) return false;
261 if(fabs(fitz()-rhs.fitz())>epsilon) return false;
262
263 if((aHasSD+bHasSD)==2)
264 {
265 if ( secondaryDecay() != rhs.secondaryDecay() )
266 return false;
267 }
268
269 return true;
270 }
271
272
273
275 lowerChainLink, setLowerChainLink )
276
277
279 static const Accessor< ElementLink< TrigBphysContainer_v1 > > acc( "lowerChainLink" );
280 if( ! acc.isAvailable( *this ) ) {
281 return nullptr;
282 }
283 const ElementLink< TrigBphysContainer_v1 > & sd = acc( *this );
284 if (sd.isValid()) {
285 return *sd;
286 } else {
287 return nullptr;
288 }
289 } //pLowerChain
290
292 std::vector< ElementLink< IParticleContainer > >,
293 particleLinks, setParticleLinks )
294
295
297 particleAcc( "particleLinks" );
298
299 size_t TrigBphys_v1::nParticles() const {
300
301 if( ! particleAcc.isAvailable( *this ) ) {
302 return 0;
303 }
304 return particleAcc( *this ).size();
305 }
306
307 const IParticle * TrigBphys_v1::particle( size_t i ) const {
308
309 if( ! particleAcc.isAvailable( *this ) ) {
310 return nullptr;
311 }
312 if( i >= nParticles() ) {
313 return nullptr;
314 }
315 if( ! particleAcc( *this )[ i ].isValid() ) {
316 return nullptr;
317 }
318 return *( particleAcc( *this )[ i ] );
319 }
320
323 particleAcc( *this ).push_back( particle );
324 return;
325 } //addTrack
326
327
329 std::vector< uint32_t >,
330 vecRoiIds, setVecRoiIds )
331
332
334 vRoiAcc( "vecRoiIds" );
335
336 size_t TrigBphys_v1::nVecRoiIds() const {
337
338 if( ! vRoiAcc.isAvailable( *this ) ) {
339 return 0;
340 }
341 return vRoiAcc( *this ).size();
342 }
343
345
346 if( ! vRoiAcc.isAvailable( *this ) ) {
347 return ~0;
348 }
349 if( i >= nVecRoiIds() ) {
350 return ~0;
351 }
352 return vRoiAcc( *this )[ i ];
353 }
354
357 vRoiAcc( *this ).push_back( roiId );
358 return;
359 } //addTrack
360
361 // get pT, but check if is in the object
362 float TrigBphys_v1::pt() const {
363 // #FIXME - why doesn't this work as expected?
364 static const SG::AuxElement::Accessor< float > ptAcc( "pt" );
365 if( ! ptAcc.isAvailable( *this ) ) {
366 return 0.;
367 }
368 return ptAcc( *this );
369 }
370
372 static const SG::AuxElement::Accessor< float > ptAcc( "pt" );
373 ptAcc(*this) = pt;
374 return;
375 }
376
382
383
385 return fitmassErrorAcc.isAvailable(*this)? fitmassErrorAcc(*this) : -99.;
386 }
387 float TrigBphys_v1::lxy() const {
388 return lxyAcc.isAvailable(*this) ? lxyAcc(*this) : -99.;
389 }
391 return lxyErrorAcc.isAvailable(*this) ? lxyErrorAcc(*this) : -99.;
392 }
393 float TrigBphys_v1::tau() const {
394 return tauAcc.isAvailable(*this) ? tauAcc(*this) : -99.;
395 }
397 return tauErrorAcc.isAvailable(*this) ? tauErrorAcc(*this) : -99.;
398 }
399
400
402 fitmassErrorAcc(*this) = x;
403 return;
404 }
406 lxyAcc(*this) = x;
407 return;
408 }
410 lxyErrorAcc(*this) = x;
411 return;
412 }
414 tauAcc(*this) = x;
415 return;
416 }
418 tauErrorAcc(*this) = x;
419 return;
420 }
421
422
423
424} // namespace xAOD
Scalar eta() const
pseudorapidity method
bool isValid(const T &p)
Av: we implement here an ATLAS-sepcific convention: all particles which are 99xxxxx are fine.
Definition AtlasPID.h:878
#define AUXSTORE_PRIMITIVE_GETTER_WITH_CAST(CL, PERSTYPE, TRANSTYPE, NAME)
Macro creating a getter function with a type conversion.
#define AUXSTORE_PRIMITIVE_SETTER_WITH_CAST(CL, PERSTYPE, TRANSTYPE, NAME, SETTER)
Macro creating a setter function with a type conversion.
#define AUXSTORE_PRIMITIVE_SETTER_AND_GETTER(CL, TYPE, NAME, SETTER)
Macro creating the accessors of primitive auxiliary properties.
#define AUXSTORE_OBJECT_SETTER_AND_GETTER(CL, TYPE, NAME, SETTER)
Macro creating the accessors of complex auxiliary properties.
#define x
SG::Accessor< T, ALLOC > Accessor
Definition AuxElement.h:572
AuxElement()
Default constructor.
bool isAvailable(const ELT &e) const
Test to see if this variable exists in the store.
Class providing the definition of the 4-vector interface.
Class describing a Bphysics online composite object.
int fitndof() const
accessor method: ndof from vertex fit
void setPhi(float)
Set the azimuth angle of the object.
float tau() const
accessor method: tau
void setFitchi2(float FitChi2)
set method: chi2 from vertex fit
size_t nTrackParticles() const
Number of tracks used to make particle.
void setTau(float v)
set method: tau
void setParticleType(pType type)
set method: particle type
void addParticleLink(const ElementLink< xAOD::IParticleContainer > &particle)
add a track to the vector of particles
void addTrackParticleLink(const ElementLink< xAOD::TrackParticleContainer > &track)
set method: add track to particle
float pt() const
accessor method: pt
void setFitx(float FitX)
set method: x position of vertex
uint32_t roiId() const
accessor method: ID of L1 RoI
void setFity(float FitY)
set method: y position of vertex
uint32_t vecRoiId(size_t i) const
Get the Nth roiId.
void setRoiId(uint32_t id)
set method: roiId
float eta() const
accessor method: eta
pType particleType() const
accessor method: particle Type
float tauError() const
accessor method: tau uncertainty
const ElementLink< TrigBphysContainer_v1 > & lowerChainLink() const
accessor method: lowerChain decay particle
size_t nParticles() const
Number of tracks used to make particle.
void setSecondaryDecayLink(const ElementLink< xAOD::TrigBphysContainer_v1 > &link)
set method: link to secondary decay particle
const TrigBphys_v1 * secondaryDecay() const
accessor method: secondary decay particle
const xAOD::TrackParticle * trackParticle(size_t i) const
Get the Nth track's pointer.
void addVecRoiId(uint32_t roiId)
add a roiId to the vector
void setParticleLinks(const std::vector< ElementLink< IParticleContainer > > &links)
Set the track particle links on the object.
float phi() const
accessor method: phi
const std::vector< ElementLink< xAOD::IParticleContainer > > & particleLinks() const
accessor method:vector of tracks used to make particle
levelType
enum to describe the level this object is operating at
float fitchi2() const
accessor method: chi2 from vertex fit
void setFitndof(int FitNdof)
set method: ndof from vertex fit
void setVecRoiIds(const std::vector< uint32_t > &roiIds)
Set the track particle links on the object.
void setFitz(float FitZ)
set method: z position of vertex
const TrigBphys_v1 * lowerChain() const
accessor method: lowerChain decay particle
float lxy() const
accessor method: lxy
void clone(const TrigBphys_v1 &rhs)
const ElementLink< TrigBphysContainer_v1 > & secondaryDecayLink() const
accessor method: secondary decay particle
void setTauError(float v)
set method: tauError
float fitx() const
accessor method: x position of vertex
void setPt(float)
Set the pT of the object.
void setLxy(float v)
set method: lxy
void setFitmass(float FitMass)
set method: mass from vertex fit
size_t nVecRoiIds() const
Number of tracks used to make particle.
void setFitmassError(float v)
set method: fitmassError
float fitz() const
accessor method: z position of vertex
float fitmass() const
accessor method: mass from vertex fit
void setLevel(levelType type)
set method: level type
const std::vector< ElementLink< xAOD::TrackParticleContainer > > & trackParticleLinks() const
accessor method:vector of tracks used to make particle
float lxyError() const
accessor method: lxy uncertainty
const std::vector< uint32_t > & vecRoiIds() const
accessor method:vector of tracks used to make particle
float mass() const
accessor method: mass
float fitmassError() const
accessor method: fitmass uncertainty
void setEta(float)
Set the pseudorapidity of the object.
const xAOD::IParticle * particle(size_t i) const
Get the Nth track's pointer.
void setMass(float)
Set the mass of the object.
pType
enum for different particle types
TrigBphys_v1()
Default constructor.
float fity() const
accessor method: y position of vertex
levelType level() const
accessor method: level Type
void setTrackParticleLinks(const std::vector< ElementLink< TrackParticleContainer > > &links)
Set the track particle links on the object.
void setLowerChainLink(const ElementLink< xAOD::TrigBphysContainer_v1 > &link)
set method: link to lowerChain decay particle
void setLxyError(float v)
set method: lxyError
bool operator==(const TrigBphys_v1 &rhs) const
Forward declaration.
ICaloAffectedTool is abstract interface for tools checking if 4 mom is in calo affected region.
static const SG::AuxElement::Accessor< float > tauErrorAcc("tauError")
setStrategy setMatchFlag ElementLink< TrackParticleContainer >
static const SG::AuxElement::Accessor< Vertex_v1::TrackParticleLinks_t > trackAcc("trackParticleLinks")
Accessor for the track links.
static const SG::AuxElement::Accessor< float > fitmassErrorAcc("fitmassError")
TrackParticle_v1 TrackParticle
Reference the current persistent version:
static const SG::AuxElement::Accessor< float > lxyAcc("lxy")
static const SG::AuxElement::Accessor< float > tauAcc("tau")
static const SG::AuxElement::Accessor< ElementLink< IParticleContainer > > acc("originalObjectLink")
Object used for setting/getting the dynamic decoration in question.
static const SG::AuxElement::Accessor< float > lxyErrorAcc("lxyError")
setWord1 uint16_t
setTeId setLumiBlock roiId
setEventNumber uint32_t