ATLAS Offline Software
Loading...
Searching...
No Matches
Jet_v1.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 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" );
112
114 float w ) {
115
116 constituentAcc( *this ).push_back( link );
117 constituentWeightAcc( *this ).push_back( w );
118 return;
119 }
120
121 void Jet_v1::addConstituent( const IParticle* c, float w ) {
122 int idx = c->index();
123 const IParticleContainer* pcon =
124 dynamic_cast<const IParticleContainer*>(c->container());
125 ElementLink<IParticleContainer> el(*pcon, idx);
126#if 0
128 el.toIndexedElement( *( dynamic_cast< const IParticleContainer* >( c->container() ) ), c->index() );
129#endif
130 constituentAcc(*this).push_back(el);
131 constituentWeightAcc( *this ).push_back( w );
132 return;
133 }
134
135
136 static const SG::AuxElement::Accessor< int > constitScaleAcc( "ConstituentScale" );
137
139 if( constitScaleAcc.isAvailable(*this) ) return (JetConstitScale)constitScaleAcc(*this);
140 return UnknownConstitScale;
141 }
142
146
147
148
154
155 size_t Jet_v1::numConstituents() const {
156 int numConstit = 0;
157 if(constituentAcc.isAvailable( *this )){
158 numConstit = constituentAcc( *this ).size();
159 }
160 else if(numConstitAcc.isAvailable( *this )){
161 numConstit = numConstitAcc( *this );
162 }
163 else{
164 throw std::runtime_error("numConstituents(): neither the aux data item `constituentLinks' nor `numConstit' of the jet is available.");
165 }
166 return numConstit;
167 }
168
169 const IParticle* Jet_v1::rawConstituent(size_t i) const {
170 return * ( constituentAcc(*this)[i]);
171 }
172
173 const std::vector< ElementLink< IParticleContainer > >& Jet_v1::constituentLinks() const {
174 return constituentAcc(*this);
175 }
176
177
179
180
181
183
184 momentumAcc.setAttribute( *this, p4 );
185 return;
186 }
187
190
193 switch( s ){
194 case JetEMScaleMomentum: return jetEMScaleAcc.getAttribute( *this );
195 case JetConstitScaleMomentum : return jetConstitScaleAcc.getAttribute( *this );
196 case JetAssignedScaleMomentum: return jetP4();
197 default :
198 std::cerr << " Error p4(P4SignalState) unknown state "<< s << std::endl;
199 break;
200 }
201 return JetFourMom_t();
202 }
203
205 return jetP4(s);
206 }
207
210 switch( s ){
211 case JetEMScaleMomentum:
212 jetEMScaleAcc.setAttribute( *this, p4 );
213 break;
215 jetConstitScaleAcc.setAttribute(*this, p4 ) ;
216 break;
218 setJetP4(p4);
219 break;
220 default :
221 std::cerr << " Error p4(P4SignalState) unknown state "<< s << std::endl;
222 break;
223 }
224 }
225
227 JetFourMom_t Jet_v1::jetP4(const std::string& statename) const {
228 if(statename=="JetAssignedScaleMomentum") return jetP4();
229 return getAttribute<JetFourMom_t>(statename);
230 }
231
232 JetFourMom_t Jet_v1::genvecP4(const std::string& statename) const {
233 return jetP4(statename);
234 }
235
236 void Jet_v1::setJetP4(const std::string& statename, const JetFourMom_t &p4) {
237 if(statename=="JetAssignedScaleMomentum") return setJetP4(JetAssignedScaleMomentum,p4);
238 return setAttribute<JetFourMom_t>(statename, p4);
239 }
240
241
243 if(m_fastJetLink) delete m_fastJetLink;
244 m_fastJetLink = nullptr;
245 }
246
247 const fastjet::PseudoJet * Jet_v1::getPseudoJet() const {
248 if(m_fastJetLink) return m_fastJetLink->pseudoJet;
249 return nullptr;
250 }
251
252 static const SG::AuxElement::Accessor<int> inputAcc("InputType");
253 static const SG::AuxElement::Accessor<int> algAcc("AlgorithmType");
254 static const SG::AuxElement::Accessor<float> spAcc("SizeParameter");
255
257 return spAcc(*this);
258 }
259
263
265 return (JetInput::Type) inputAcc(*this);
266 }
267
268 void Jet_v1::setSizeParameter(float p) { spAcc(*this) = p;}
271
272
273// void Jet_v1::toPersistent() {
274// No longer needed, as this is done by the POOL converter for the aux container
275
276// if( constituentAcc.isAvailableWritable( *this ) ) {
277// std::vector< ElementLink< IParticleContainer > >::iterator itr =
278// constituentAcc( *this ).begin();
279// std::vector< ElementLink< IParticleContainer > >::iterator end =
280// constituentAcc( *this ).end();
281// for( ; itr != end; ++itr ) {
282// itr->toPersistent();
283// }
284// }
285
286// #ifndef SIMULATIONBASE
287// // On a new object we could only create a link with the new name, so:
288// if( btagAcc2.isAvailableWritable( *this ) ) {
289// btagAcc2( *this ).toPersistent();
290// }
291// #endif //SIMULATIONBASE
292
293
294// return;
295// }
296
297
298} // 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:573
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:242
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:269
void setAttribute(const std::string &name, const T &v)
JetAlgorithmType::ID getAlgorithmType() const
Definition Jet_v1.cxx:260
void addConstituent(const ElementLink< IParticleContainer > &link, float weight=1.0)
Add a constituent directly in the ElementLink format.
Definition Jet_v1.cxx:113
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:155
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:173
void setJetP4(const JetFourMom_t &p4)
Definition Jet_v1.cxx:182
JetConstitScale getConstituentsSignalState() const
The state at which constituents were when this jet was found.
Definition Jet_v1.cxx:138
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:143
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:149
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:256
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:247
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:169
void setSizeParameter(float p)
Definition Jet_v1.cxx:268
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:270
JetInput::Type getInputType() const
Definition Jet_v1.cxx:264
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 > numConstitAcc("numConstit")
The access for the number of constituents.
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