ATLAS Offline Software
JetConstituentVector.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 #include <cmath>
8 #if !defined(SIMULATIONBASE) and !defined(GENERATIONBASE)
9 #include "xAODPFlow/PFO.h"
10 #endif // not SIMULATIONBASE or GENERATIONBASE
11 
12 namespace xAOD {
13 
14  double ptFromEEtaM(const double e, const double eta, const double m){
15  double p = 0.0;
16  if( std::abs( m ) < 0.00001 ) {
17  p = e;
18  } else {
19  p = std::sqrt( e * e - m * m );
20  if( e < 0 ) {
21  p = -p;
22  }
23  }
24 
25  // Calculate sinTh:
26  double aEta = std::abs( eta );
27  if( aEta > 710.0 ) {
28  aEta = 710.0;
29  }
30  const double sinTh = 1.0 / std::cosh( aEta );
31 
32  // Calculate pT from these two:
33  return ( p * sinTh );
34  }
35 
36 
37  void fillJetConstituent(const IParticle* part, JetConstituent & constit , JetConstitScale sigState ){
38  if( sigState == UncalibratedJetConstituent) {
39  switch( part->type() ){
40  case Type::CaloCluster: {
41  const xAOD::CaloCluster *cl = dynamic_cast<const xAOD::CaloCluster*>(part);
42  if( cl ) {
43  constit.SetCoordinates( ptFromEEtaM( cl->rawE(), cl->rawEta(), cl->rawM() ),
44  cl->rawEta(),
45  cl->rawPhi(),
46  cl->rawM() );
47  }
48  return;
49  }
50 #if !defined(SIMULATIONBASE) and !defined(GENERATIONBASE)
51  case Type::ParticleFlow: {
52  const xAOD::PFO *pfo = dynamic_cast<const xAOD::PFO*>(part);
53  if(pfo->ptEM()!=0) constit.SetCoordinates( pfo->ptEM(), pfo->etaEM(), pfo->phiEM(), pfo->mEM() );
54  else constit.SetCoordinates( 0, 1, 1, 0 ); // To avoid Warnings from root.
55  return;
56  }
57 #endif // not SIMULATIONBASE or GENERATIONBASE
58  default:
59  break;// fall back on default kinematics
60  }
61  }
62  // if we have not returned above, the fall back is using the default scale :
63  constit.SetCoordinates( part->pt(), part->eta(),
64  part->phi(), part->m() );
65  }
66 
67 
69 
70  iterator & iterator::operator++(){ ++m_index; return *this ; }
71  iterator iterator::operator++(int) { iterator tmp = *this; ++m_index; return tmp ; }
72  iterator & iterator::operator--() { --m_index; return *this ; }
73  iterator iterator::operator--(int) { iterator tmp = *this; --m_index; return tmp ; }
74  bool iterator::operator==( const iterator & other) const { return m_index == other.m_index; }
75  bool iterator::operator!=( const iterator & other) const { return m_index != other.m_index; }
76 
79 
80 
82 
83  if( m_index == m_cachedMomIndex ) return;
85  const IParticle* part = *(*m_index);
86  m_4mom.m_part = part;
87 
88  // now get the right scale from the constituent :
90  }
91 
93  using ELVector = std::vector<ElementLink<IParticleContainer> >;
94  for ( ELVector::const_iterator icon=m_elVector->begin(); icon!=m_elVector->end(); ++icon ) {
95  const ElementLink<IParticleContainer>& el = *icon;
96  if ( ! el.isValid() ) return false;
97  }
98  return true;
99  }
100 
101  bool JetConstituentVector::empty() const { return m_elVector->empty() ; }
102  size_t JetConstituentVector::size() const { return m_elVector->size() ; }
105 
108 
110 
112  JetConstituent c;
114  c.m_part = *(m_elVector->at(i));
115  return c;
116  }
117 
119 
121 
122  std::vector<const IParticle*> JetConstituentVector::asIParticleVector() const {
123  std::vector<const IParticle*> v( m_elVector->size() );
124  for(size_t i=0;i<v.size(); i++) v[i] = *(m_elVector->at(i));
125  return v;
126  }
127 
128  std::vector<JetConstituent> JetConstituentVector::asSTLVector(){
129  size_t N = size();
130  std::vector<JetConstituent> vec(N);
131  for ( size_t i=0;i<N;i++ ) {
132  fillJetConstituent( *(m_elVector->at(i)) , vec[i], m_sigState );
133  vec[i].m_part = *(m_elVector->at(i));
134  }
135  return vec;
136  }
137 
138 
139 }
LArG4FSStartPointFilter.part
part
Definition: LArG4FSStartPointFilter.py:21
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
python.SystemOfUnits.s
int s
Definition: SystemOfUnits.py:131
python.SystemOfUnits.m
int m
Definition: SystemOfUnits.py:91
xAOD::JetConstituentVector::at
JetConstituent at(size_t i) const
Constituent proxy at position i.
Definition: JetConstituentVector.cxx:111
xAOD::JetConstituentVector::iterator::m_index
ELiterator m_index
Definition: JetConstituentVector.h:148
xAOD::JetConstituentVector::operator[]
JetConstituent operator[](size_t i) const
Constituent proxy at position i.
Definition: JetConstituentVector.cxx:109
xAOD::ptFromEEtaM
double ptFromEEtaM(const double e, const double eta, const double m)
Definition: JetConstituentVector.cxx:14
xAOD::JetConstituentVector::iterator::operator*
const JetConstituent * operator*()
Definition: JetConstituentVector.cxx:77
xAOD::JetConstituentVector::iterator::operator--
iterator & operator--()
Definition: JetConstituentVector.cxx:72
xAOD::JetConstituentVector::end
iterator end() const
iterator after the last constituent
Definition: JetConstituentVector.cxx:104
xAOD::JetConstituentVector::back
JetConstituent back() const
last constituent proxy
Definition: JetConstituentVector.cxx:120
xAOD::PFO_v1::phiEM
virtual double phiEM() const
get EM scale phi
Definition: PFO_v1.cxx:220
xAOD::JetConstituentVector::iterator::operator==
bool operator==(const iterator &other) const
Definition: JetConstituentVector.cxx:74
xAOD::other
@ other
Definition: TrackingPrimitives.h:509
xAOD::JetConstituentVector::size
size_t size() const
number of constituents
Definition: JetConstituentVector.cxx:102
xAOD::JetConstituentVector::isValid
bool isValid() const
Check if element links are valid.
Definition: JetConstituentVector.cxx:92
xAOD
ICaloAffectedTool is abstract interface for tools checking if 4 mom is in calo affected region.
Definition: ICaloAffectedTool.h:24
JetTiledMap::N
@ N
Definition: TiledEtaPhiMap.h:44
vec
std::vector< size_t > vec
Definition: CombinationsGeneratorTest.cxx:12
xAOD::JetConstituentVector::m_elVector
const std::vector< ElementLink< IParticleContainer > > * m_elVector
Definition: JetConstituentVector.h:201
JetConstituentVector.h
This file defines helper classes to deal with jet constituents.
xAOD::IParticle
Class providing the definition of the 4-vector interface.
Definition: Event/xAOD/xAODBase/xAODBase/IParticle.h:41
xAOD::CaloCluster
CaloCluster_v1 CaloCluster
Define the latest version of the calorimeter cluster class.
Definition: Event/xAOD/xAODCaloEvent/xAODCaloEvent/CaloCluster.h:19
xAOD::PFO_v1::ptEM
virtual double ptEM() const
get EM scale pt
Definition: PFO_v1.cxx:204
xAOD::JetConstituentVector::empty
bool empty() const
true if vector is empty()
Definition: JetConstituentVector.cxx:101
xAOD::JetConstituent::m_part
const IParticle * m_part
Definition: JetConstituentVector.h:105
CxxUtils::vec
typename vecDetail::vec_typedef< T, N >::type vec
Define a nice alias for the vectorized type.
Definition: vec.h:207
PFO.h
xAOD::JetConstituentVector::begin
iterator begin() const
iterator on the first constituent
Definition: JetConstituentVector.cxx:103
xAOD::CaloCluster_v1
Description of a calorimeter cluster.
Definition: CaloCluster_v1.h:59
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
xAOD::JetConstituentVector::iterator::operator++
iterator & operator++()
Definition: JetConstituentVector.cxx:70
lumiFormat.i
int i
Definition: lumiFormat.py:85
CaloCluster.h
xAOD::e
setPy e
Definition: CompositeParticle_v1.cxx:166
xAOD::JetConstituentVector::iterator::m_cachedMomIndex
ELiterator m_cachedMomIndex
Definition: JetConstituentVector.h:149
plotIsoValidation.el
el
Definition: plotIsoValidation.py:197
xAODType::ParticleFlow
@ ParticleFlow
The object is a particle-flow object.
Definition: ObjectType.h:41
xAOD::PFO_v1::mEM
virtual double mEM() const
get EM scale mass
Definition: PFO_v1.cxx:224
DeMoUpdate.tmp
string tmp
Definition: DeMoUpdate.py:1167
xAOD::JetConstituentVector::iterator::update4Mom
void update4Mom()
Definition: JetConstituentVector.cxx:81
xAOD::JetConstituentVector::iterator::m_4mom
JetConstituent m_4mom
Definition: JetConstituentVector.h:150
xAOD::PFO_v1
Class describing a particle flow object.
Definition: PFO_v1.h:35
xAOD::JetConstituentVector::front
JetConstituent front() const
first constituent proxy
Definition: JetConstituentVector.cxx:118
xAOD::JetConstitScale
JetConstitScale
Definition: JetTypes.h:20
xAOD::PFO_v1::etaEM
virtual double etaEM() const
get EM scale eta
Definition: PFO_v1.cxx:215
xAOD::JetConstituentVector::m_sigState
JetConstitScale m_sigState
Definition: JetConstituentVector.h:202
xAOD::JetConstituentVector::iterator::m_sigState
JetConstitScale m_sigState
Definition: JetConstituentVector.h:152
python.PyAthena.v
v
Definition: PyAthena.py:154
xAOD::JetConstituentVector::asSTLVector
std::vector< JetConstituent > asSTLVector()
Returns this vector as a std::vector Provided for convenience when dealing with the JetConstituentVec...
Definition: JetConstituentVector.cxx:128
xAOD::JetConstituentVector::asIParticleVector
std::vector< const IParticle * > asIParticleVector() const
vector of pointer to the underlying IParticles.
Definition: JetConstituentVector.cxx:122
xAOD::UncalibratedJetConstituent
@ UncalibratedJetConstituent
Definition: JetTypes.h:21
xAOD::JetConstituentVector::iterator::operator!=
bool operator!=(const iterator &other) const
Definition: JetConstituentVector.cxx:75
xAOD::JetConstituent
4-vector of jet constituent at the scale used during jet finding.
Definition: JetConstituentVector.h:61
xAOD::JetConstituentVector::iterator
Definition: JetConstituentVector.h:121
xAOD::JetConstituentVector::iterator::operator->
const JetConstituent * operator->()
Definition: JetConstituentVector.cxx:78
python.compressB64.c
def c
Definition: compressB64.py:93
dq_make_web_display.cl
cl
print [x.__class__ for x in toList(dqregion.getSubRegions()) ]
Definition: dq_make_web_display.py:26
xAOD::fillJetConstituent
void fillJetConstituent(const IParticle *part, JetConstituent &constit, JetConstitScale sigState)
Definition: JetConstituentVector.cxx:37