ATLAS Offline Software
Loading...
Searching...
No Matches
Jet_v1.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
3*/
4
5
6
7// Local include(s):
11
12namespace xAOD {
13
15 : IParticle()
16 , m_fastJetLink(nullptr)
17 {
18 }
19
21
22
24 , m_fastJetLink(nullptr)
25 {
28 }
29
31 if(this == &o) return *this;
32
33 if( ( ! hasStore() ) && ( ! container() ) ) makePrivateStore();
34 this->IParticle::operator=( o );
35 if( (o.m_fastJetLink) && (m_fastJetLink==nullptr) ) m_fastJetLink = o.m_fastJetLink->clone();
36 return *this;
37 }
38
42
43
44 double Jet_v1::pt() const {
45
46 return momentumAcc.pt( *this );
47 }
48
49 double Jet_v1::eta() const {
50
51 return momentumAcc.eta( *this );
52 }
53
54 double Jet_v1::phi() const {
55
56 return momentumAcc.phi( *this );
57 }
58
59 double Jet_v1::m() const {
60 return momentumAcc.m( *this );
61 }
62
63 double Jet_v1::e() const {
64 return jetP4().E();
65 }
66
67 double Jet_v1::rapidity() const {
68 return jetP4().Rapidity();
69 }
70
72 JetFourMom_t p = jetP4();
73 return FourMom_t(p.Px(), p.Py(), p.Pz(), p.E() );
74 }
75
77 return momentumAcc.getAttribute( *this);
78 }
79
80
82 return jetP4();
83 }
84
85 Type::ObjectType Jet_v1::type() const {
86 return Type::Jet;
87 }
88
90 float Jet_v1::px() const {
91
92 return p4().Px();
93 }
94 float Jet_v1::py() const {
95
96 return p4().Py();
97 }
98
99 float Jet_v1::pz() const {
100
101 return p4().Pz();
102 }
103
104
107 constituentAcc( "constituentLinks" );
109 constituentWeightAcc( "constituentWeights" );
110
112 float w ) {
113
114 constituentAcc( *this ).push_back( link );
115 constituentWeightAcc( *this ).push_back( w );
116 return;
117 }
118
119 void Jet_v1::addConstituent( const IParticle* c, float w ) {
120 int idx = c->index();
121 const IParticleContainer* pcon =
122 dynamic_cast<const IParticleContainer*>(c->container());
123 ElementLink<IParticleContainer> el(*pcon, idx);
124#if 0
126 el.toIndexedElement( *( dynamic_cast< const IParticleContainer* >( c->container() ) ), c->index() );
127#endif
128 constituentAcc(*this).push_back(el);
129 constituentWeightAcc( *this ).push_back( w );
130 return;
131 }
132
133
134 static const SG::AuxElement::Accessor< int > constitScaleAcc( "ConstituentScale" );
135
137 if( constitScaleAcc.isAvailable(*this) ) return (JetConstitScale)constitScaleAcc(*this);
138 return UnknownConstitScale;
139 }
140
144
145
146
152
153 size_t Jet_v1::numConstituents() const {
154
155 return constituentAcc( *this ).size();
156 }
157
158 const IParticle* Jet_v1::rawConstituent(size_t i) const {
159 return * ( constituentAcc(*this)[i]);
160 }
161
162 const std::vector< ElementLink< IParticleContainer > >& Jet_v1::constituentLinks() const {
163 return constituentAcc(*this);
164 }
165
166
168
169
170
172
173 momentumAcc.setAttribute( *this, p4 );
174 return;
175 }
176
179
182 switch( s ){
183 case JetEMScaleMomentum: return jetEMScaleAcc.getAttribute( *this );
184 case JetConstitScaleMomentum : return jetConstitScaleAcc.getAttribute( *this );
185 case JetAssignedScaleMomentum: return jetP4();
186 default :
187 std::cerr << " Error p4(P4SignalState) unknown state "<< s << std::endl;
188 break;
189 }
190 return JetFourMom_t();
191 }
192
194 return jetP4(s);
195 }
196
199 switch( s ){
200 case JetEMScaleMomentum:
201 jetEMScaleAcc.setAttribute( *this, p4 );
202 break;
204 jetConstitScaleAcc.setAttribute(*this, p4 ) ;
205 break;
207 setJetP4(p4);
208 break;
209 default :
210 std::cerr << " Error p4(P4SignalState) unknown state "<< s << std::endl;
211 break;
212 }
213 }
214
216 JetFourMom_t Jet_v1::jetP4(const std::string& statename) const {
217 if(statename=="JetAssignedScaleMomentum") return jetP4();
218 return getAttribute<JetFourMom_t>(statename);
219 }
220
221 JetFourMom_t Jet_v1::genvecP4(const std::string& statename) const {
222 return jetP4(statename);
223 }
224
225 void Jet_v1::setJetP4(const std::string& statename, const JetFourMom_t &p4) {
226 if(statename=="JetAssignedScaleMomentum") return setJetP4(JetAssignedScaleMomentum,p4);
227 return setAttribute<JetFourMom_t>(statename, p4);
228 }
229
230
232 if(m_fastJetLink) delete m_fastJetLink;
233 m_fastJetLink = nullptr;
234 }
235
236 const fastjet::PseudoJet * Jet_v1::getPseudoJet() const {
237 if(m_fastJetLink) return m_fastJetLink->pseudoJet;
238 return nullptr;
239 }
240
241 static const SG::AuxElement::Accessor<int> inputAcc("InputType");
242 static const SG::AuxElement::Accessor<int> algAcc("AlgorithmType");
243 static const SG::AuxElement::Accessor<float> spAcc("SizeParameter");
244
246 return spAcc(*this);
247 }
248
252
254 return (JetInput::Type) inputAcc(*this);
255 }
256
257 void Jet_v1::setSizeParameter(float p) { spAcc(*this) = p;}
260
261
262// void Jet_v1::toPersistent() {
263// No longer needed, as this is done by the POOL converter for the aux container
264
265// if( constituentAcc.isAvailableWritable( *this ) ) {
266// std::vector< ElementLink< IParticleContainer > >::iterator itr =
267// constituentAcc( *this ).begin();
268// std::vector< ElementLink< IParticleContainer > >::iterator end =
269// constituentAcc( *this ).end();
270// for( ; itr != end; ++itr ) {
271// itr->toPersistent();
272// }
273// }
274
275// #ifndef SIMULATIONBASE
276// // On a new object we could only create a link with the new name, so:
277// if( btagAcc2.isAvailableWritable( *this ) ) {
278// btagAcc2( *this ).toPersistent();
279// }
280// #endif //SIMULATIONBASE
281
282
283// return;
284// }
285
286
287} // namespace xAOD
std::vector< size_t > vec
This header defines wrapper classes around SG::AuxElement::Accessor used internally in the Jet EDM.
static Double_t a
void makePrivateStore()
Create a new (empty) private store for this object.
bool hasStore() const
Return true if this object has an associated store.
SG::Accessor< T, ALLOC > Accessor
Definition AuxElement.h:572
const SG::AuxVectorData * container() const
Return the container holding this element.
virtual FastJetLinkBase * clone()
IParticle & operator=(const IParticle &)=default
IParticle()=default
Specialiazed accessor for JetFourMom_t : internally stores the JetFourMom_t as 4 floats in the Aux St...
A vector of jet constituents at the scale used during jet finding.
void reset()
Function making sure that the object is ready for persistification.
Definition Jet_v1.cxx:231
FastJetLinkBase * m_fastJetLink
Pointer to the fastjet object this jet is build from.
Definition Jet_v1.h:346
virtual double phi() const
The azimuthal angle ( ) of the particle.
Definition Jet_v1.cxx:54
void setAlgorithmType(JetAlgorithmType::ID a)
Definition Jet_v1.cxx:258
void setAttribute(const std::string &name, const T &v)
JetAlgorithmType::ID getAlgorithmType() const
Definition Jet_v1.cxx:249
void addConstituent(const ElementLink< IParticleContainer > &link, float weight=1.0)
Add a constituent directly in the ElementLink format.
Definition Jet_v1.cxx:111
size_t numConstituents() const
Number of constituents in this jets (this is valid even when reading a file where the constituents ha...
Definition Jet_v1.cxx:153
virtual FourMom_t p4() const
The full 4-momentum of the particle.
Definition Jet_v1.cxx:71
JetFourMom_t genvecP4() const
The full 4-momentum of the particle : internal jet type (same).
Definition Jet_v1.cxx:81
const std::vector< ElementLink< IParticleContainer > > & constituentLinks() const
Direct access to constituents. WARNING expert use only.
Definition Jet_v1.cxx:162
void setJetP4(const JetFourMom_t &p4)
Definition Jet_v1.cxx:171
JetConstitScale getConstituentsSignalState() const
The state at which constituents were when this jet was found.
Definition Jet_v1.cxx:136
void setConstituentsSignalState(JetConstitScale t)
Set the state at which constituents were when this jet was found. This function is called by jet buil...
Definition Jet_v1.cxx:141
float py() const
The y-component of the jet's momentum.
Definition Jet_v1.cxx:94
JetConstituentVector getConstituents() const
Return a vector of consituents. The object behaves like vector<const IParticle*>. See JetConstituentV...
Definition Jet_v1.cxx:147
virtual double pt() const
The transverse momentum ( ) of the particle.
Definition Jet_v1.cxx:44
virtual double rapidity() const
The true rapidity (y) of the particle.
Definition Jet_v1.cxx:67
float px() const
The x-component of the jet's momentum.
Definition Jet_v1.cxx:90
float getSizeParameter() const
Definition Jet_v1.cxx:245
IParticle::FourMom_t FourMom_t
Definition of the 4-momentum type.
Definition Jet_v1.h:92
const fastjet::PseudoJet * getPseudoJet() const
Definition Jet_v1.cxx:236
float pz() const
The z-component of the jet's momentum.
Definition Jet_v1.cxx:99
const IParticle * rawConstituent(size_t i) const
Direct access to constituents. WARNING expert use only.
Definition Jet_v1.cxx:158
void setSizeParameter(float p)
Definition Jet_v1.cxx:257
virtual double m() const
The invariant mass of the particle.
Definition Jet_v1.cxx:59
bool getAttribute(AttributeID type, T &value) const
Retrieve attribute moment by enum.
void setInputType(JetInput::Type t)
Definition Jet_v1.cxx:259
JetInput::Type getInputType() const
Definition Jet_v1.cxx:253
Jet_v1()
Default constructor.
Definition Jet_v1.cxx:14
Jet_v1 & operator=(const Jet_v1 &other)
Definition Jet_v1.cxx:30
virtual double eta() const
The pseudorapidity ( ) of the particle.
Definition Jet_v1.cxx:49
virtual double e() const
The total energy of the particle.
Definition Jet_v1.cxx:63
JetFourMom_t jetP4() const
The full 4-momentum of the particle : internal jet type.
Definition Jet_v1.cxx:76
virtual Type::ObjectType type() const
The type of the object as a simple enumeration.
Definition Jet_v1.cxx:85
ID
//////////////////////////////////////// JetAlgorithmType::ID defines most common physics jet finding...
ICaloAffectedTool is abstract interface for tools checking if 4 mom is in calo affected region.
static const SG::AuxElement::Accessor< int > constitScaleAcc("ConstituentScale")
static const JetAttributeAccessor::AccessorWrapper< JetFourMom_t > jetConstitScaleAcc("JetConstitScaleMomentum")
static const JetAttributeAccessor::AccessorWrapper< JetFourMom_t > jetEMScaleAcc("JetEMScaleMomentum")
static const SG::AuxElement::Accessor< int > algAcc("AlgorithmType")
static const SG::AuxElement::Accessor< std::vector< ElementLink< IParticleContainer > > > constituentAcc("constituentLinks")
The accessor for the cluster element links.
static const SG::AuxElement::Accessor< float > spAcc("SizeParameter")
static const SG::AuxElement::Accessor< std::vector< float > > constituentWeightAcc("constituentWeights")
JetScale
Definition JetTypes.h:26
@ JetEMScaleMomentum
Definition JetTypes.h:28
@ JetAssignedScaleMomentum
Definition JetTypes.h:30
@ JetConstitScaleMomentum
Definition JetTypes.h:29
JetConstitScale
Definition JetTypes.h:20
@ UnknownConstitScale
Definition JetTypes.h:23
static const JetAttributeAccessor::AccessorWrapper< JetFourMom_t > momentumAcc
Definition Jet_v1.cxx:20
DataVector< IParticle > IParticleContainer
Simple convenience declaration of IParticleContainer.
static const SG::AuxElement::Accessor< int > inputAcc("InputType")
ROOT::Math::LorentzVector< ROOT::Math::PtEtaPhiM4D< double > > JetFourMom_t
Base 4 Momentum type for Jet.
Definition JetTypes.h:17