ATLAS Offline Software
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):
9 #include "xAODJet/JetAccessors.h"
11 
12 namespace xAOD {
13 
15  : IParticle()
16  , m_fastJetLink(nullptr)
17  {
18  }
19 
21 
22 
23  Jet_v1::Jet_v1(const Jet_v1& o ) : IParticle( o )
24  , m_fastJetLink(nullptr)
25  {
26  makePrivateStore( o );
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 
40  if(m_fastJetLink) delete m_fastJetLink;
41  }
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 
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());
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 
142  constitScaleAcc(*this) = t;
143  }
144 
145 
146 
148 
149  JetConstituentVector vec( & constituentAcc(*this) , getConstituentsSignalState() );
150  return vec;
151  }
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 
171  void Jet_v1::setJetP4( const JetFourMom_t& p4 ) {
172 
173  momentumAcc.setAttribute( *this, p4 );
174  return;
175  }
176 
177  static const JetAttributeAccessor::AccessorWrapper< JetFourMom_t > jetEMScaleAcc("JetEMScaleMomentum");
178  static const JetAttributeAccessor::AccessorWrapper< JetFourMom_t > jetConstitScaleAcc("JetConstitScaleMomentum");
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 
231  void Jet_v1::reset() {
232  if(m_fastJetLink) delete m_fastJetLink;
233  m_fastJetLink = nullptr;
234  }
235 
236  const fastjet::PseudoJet * Jet_v1::getPseudoJet() const {
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 
245  float Jet_v1::getSizeParameter() const {
246  return spAcc(*this);
247  }
248 
250  return (JetAlgorithmType::ID) algAcc(*this);
251  }
252 
254  return (JetInput::Type) inputAcc(*this);
255  }
256 
257  void Jet_v1::setSizeParameter(float p) { spAcc(*this) = p;}
259  void Jet_v1::setInputType(JetInput::Type t) {inputAcc(*this)=t;}
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
xAOD::Jet_v1::getPseudoJet
const fastjet::PseudoJet * getPseudoJet() const
Definition: Jet_v1.cxx:236
python.SystemOfUnits.s
int s
Definition: SystemOfUnits.py:131
xAOD::Jet_v1::m_fastJetLink
FastJetLinkBase * m_fastJetLink
Pointer to the fastjet object this jet is build from.
Definition: Jet_v1.h:346
SG::Accessor
Helper class to provide type-safe access to aux data.
Definition: Control/AthContainers/AthContainers/Accessor.h:68
xAOD::Jet_v1::Jet_v1
Jet_v1()
Default constructor.
Definition: Jet_v1.cxx:14
xAOD::Jet_v1::operator=
Jet_v1 & operator=(const Jet_v1 &other)
Definition: Jet_v1.cxx:30
xAOD::JetAttributeAccessor::AccessorWrapper< JetFourMom_t >::m
const float & m(const SG::AuxElement &p) const
Definition: JetAccessors.h:164
xAOD::FastJetLinkBase::clone
virtual FastJetLinkBase * clone()
Definition: FastJetLinkBase.h:30
xAOD::Jet_v1::jetP4
JetFourMom_t jetP4() const
The full 4-momentum of the particle : internal jet type.
Definition: Jet_v1.cxx:76
xAOD::Jet_v1::phi
virtual double phi() const
The azimuthal angle ( ) of the particle.
Definition: Jet_v1.cxx:54
xAOD
ICaloAffectedTool is abstract interface for tools checking if 4 mom is in calo affected region.
Definition: ICaloAffectedTool.h:24
xAOD::UnknownConstitScale
@ UnknownConstitScale
Definition: JetTypes.h:23
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
xAOD::Jet_v1::getAlgorithmType
JetAlgorithmType::ID getAlgorithmType() const
Definition: Jet_v1.cxx:249
xAOD::Jet_v1::getConstituents
JetConstituentVector getConstituents() const
Return a vector of consituents. The object behaves like vector<const IParticle*>. See JetConstituentV...
Definition: Jet_v1.cxx:147
xAOD::IParticle
Class providing the definition of the 4-vector interface.
Definition: Event/xAOD/xAODBase/xAODBase/IParticle.h:41
xAOD::Jet_v1::getInputType
JetInput::Type getInputType() const
Definition: Jet_v1.cxx:253
xAOD::JetAttributeAccessor::AccessorWrapper< JetFourMom_t >::phi
const float & phi(const SG::AuxElement &p) const
Definition: JetAccessors.h:163
xAOD::Jet_v1::~Jet_v1
~Jet_v1()
Definition: Jet_v1.cxx:39
xAOD::Jet_v1::setJetP4
void setJetP4(const JetFourMom_t &p4)
Definition: Jet_v1.cxx:171
Jet_v1.h
xAOD::JetConstitScaleMomentum
@ JetConstitScaleMomentum
Definition: JetTypes.h:29
CxxUtils::vec
typename vecDetail::vec_typedef< T, N >::type vec
Define a nice alias for the vectorized type.
Definition: vec.h:207
xAOD::Jet_v1::pz
float pz() const
The z-component of the jet's momentum.
Definition: Jet_v1.cxx:99
xAOD::Jet_v1::type
virtual Type::ObjectType type() const
The type of the object as a simple enumeration.
Definition: Jet_v1.cxx:85
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
lumiFormat.i
int i
Definition: lumiFormat.py:85
xAOD::Jet_v1::setSizeParameter
void setSizeParameter(float p)
Definition: Jet_v1.cxx:257
xAOD::Jet_v1::reset
void reset()
Function making sure that the object is ready for persistification.
Definition: Jet_v1.cxx:231
xAOD::Jet_v1::getSizeParameter
float getSizeParameter() const
Definition: Jet_v1.cxx:245
xAOD::Jet_v1::getConstituentsSignalState
JetConstitScale getConstituentsSignalState() const
The state at which constituents were when this jet was found.
Definition: Jet_v1.cxx:136
xAOD::Jet_v1::setConstituentsSignalState
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
plotIsoValidation.el
el
Definition: plotIsoValidation.py:197
xAOD::JetScale
JetScale
Definition: JetTypes.h:26
xAOD::FastJetLinkBase::pseudoJet
const fastjet::PseudoJet * pseudoJet
Definition: FastJetLinkBase.h:31
xAOD::Jet_v1::FourMom_t
IParticle::FourMom_t FourMom_t
Definition of the 4-momentum type.
Definition: Jet_v1.h:92
FastJetLinkBase.h
xAOD::JetAlgorithmType::ID
ID
//////////////////////////////////////// JetAlgorithmType::ID defines most common physics jet finding...
Definition: JetContainerInfo.h:29
xAOD::Jet_v1::py
float py() const
The y-component of the jet's momentum.
Definition: Jet_v1.cxx:94
xAOD::JetInput::Type
Type
Definition: JetContainerInfo.h:54
DataVector
Derived DataVector<T>.
Definition: DataVector.h:581
xAOD::Jet_v1::addConstituent
void addConstituent(const ElementLink< IParticleContainer > &link, float weight=1.0)
Add a constituent directly in the ElementLink format.
Definition: Jet_v1.cxx:111
xAOD::Jet_v1::rapidity
virtual double rapidity() const
The true rapidity (y) of the particle.
Definition: Jet_v1.cxx:67
xAOD::Jet_v1::eta
virtual double eta() const
The pseudorapidity ( ) of the particle.
Definition: Jet_v1.cxx:49
xAOD::Jet_v1::constituentLinks
const std::vector< ElementLink< IParticleContainer > > & constituentLinks() const
Direct access to constituents. WARNING expert use only.
Definition: Jet_v1.cxx:162
xAOD::JetEMScaleMomentum
@ JetEMScaleMomentum
Definition: JetTypes.h:28
xAOD::JetFourMom_t
ROOT::Math::LorentzVector< ROOT::Math::PtEtaPhiM4D< double > > JetFourMom_t
Base 4 Momentum type for Jet.
Definition: JetTypes.h:17
xAOD::Jet_v1::px
float px() const
The x-component of the jet's momentum.
Definition: Jet_v1.cxx:90
xAOD::JetConstitScale
JetConstitScale
Definition: JetTypes.h:20
xAOD::JetAttributeAccessor::AccessorWrapper< JetFourMom_t >::getAttribute
void getAttribute(const SG::AuxElement &p, JetFourMom_t &v) const
Definition: JetAccessors.h:173
xAOD::Jet_v1::rawConstituent
const IParticle * rawConstituent(size_t i) const
Direct access to constituents. WARNING expert use only.
Definition: Jet_v1.cxx:158
SG::AuxElement::makePrivateStore
void makePrivateStore()
Create a new (empty) private store for this object.
Definition: AuxElement.cxx:172
xAOD::JetAttributeAccessor::AccessorWrapper< JetFourMom_t >
Specialiazed accessor for JetFourMom_t : internally stores the JetFourMom_t as 4 floats in the Aux St...
Definition: JetAccessors.h:156
xAOD::Jet_v1::setInputType
void setInputType(JetInput::Type t)
Definition: Jet_v1.cxx:259
xAOD::JetAssignedScaleMomentum
@ JetAssignedScaleMomentum
Definition: JetTypes.h:30
SG::AuxElement::hasStore
bool hasStore() const
Return true if this object has an associated store.
Definition: AuxElement.cxx:355
xAOD::Jet_v1
Class describing a jet.
Definition: Jet_v1.h:57
xAOD::Jet_v1::p4
virtual FourMom_t p4() const
The full 4-momentum of the particle.
Definition: Jet_v1.cxx:71
xAOD::Jet_v1::m
virtual double m() const
The invariant mass of the particle.
Definition: Jet_v1.cxx:59
a
TList * a
Definition: liststreamerinfos.cxx:10
xAOD::JetAttributeAccessor::AccessorWrapper< JetFourMom_t >::eta
const float & eta(const SG::AuxElement &p) const
Definition: JetAccessors.h:162
xAOD::Jet_v1::e
virtual double e() const
The total energy of the particle.
Definition: Jet_v1.cxx:63
LArNewCalib_DelayDump_OFC_Cali.idx
idx
Definition: LArNewCalib_DelayDump_OFC_Cali.py:69
xAOD::JetAttributeAccessor::AccessorWrapper< JetFourMom_t >::setAttribute
void setAttribute(SG::AuxElement &p, const JetFourMom_t &v) const
Definition: JetAccessors.h:166
xAOD::Jet_v1::genvecP4
JetFourMom_t genvecP4() const
The full 4-momentum of the particle : internal jet type (same).
Definition: Jet_v1.cxx:81
xAOD::JetConstituentVector
A vector of jet constituents at the scale used during jet finding.
Definition: JetConstituentVector.h:117
SG::AuxElement::container
const SG::AuxVectorData * container() const
Return the container holding this element.
python.CaloScaleNoiseConfig.default
default
Definition: CaloScaleNoiseConfig.py:79
python.IoTestsLib.w
def w
Definition: IoTestsLib.py:200
xAOD::JetAttributeAccessor::AccessorWrapper< JetFourMom_t >::pt
const float & pt(const SG::AuxElement &p) const
Definition: JetAccessors.h:161
xAODType::ObjectType
ObjectType
Type of objects that have a representation in the xAOD EDM.
Definition: ObjectType.h:32
JetAccessors.h
This header defines wrapper classes around SG::AuxElement::Accessor used internally in the Jet EDM.
xAOD::Jet_v1::numConstituents
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
xAOD::Jet_v1::pt
virtual double pt() const
The transverse momentum ( ) of the particle.
Definition: Jet_v1.cxx:44
python.compressB64.c
def c
Definition: compressB64.py:93
xAOD::Jet_v1::setAlgorithmType
void setAlgorithmType(JetAlgorithmType::ID a)
Definition: Jet_v1.cxx:258
xAOD::IParticle::operator=
IParticle & operator=(const IParticle &)=default
xAOD::Jet
Jet_v1 Jet
Definition of the current "jet version".
Definition: Event/xAOD/xAODJet/xAODJet/Jet.h:17