ATLAS Offline Software
Loading...
Searching...
No Matches
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
12namespace 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
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}
Scalar eta() const
pseudorapidity method
std::vector< size_t > vec
This file defines helper classes to deal with jet constituents.
Class providing the definition of the 4-vector interface.
iterator(ELiterator it, JetConstitScale s)
bool operator==(const iterator &other) const
bool operator!=(const iterator &other) const
const std::vector< ElementLink< IParticleContainer > > * m_elVector
iterator begin() const
iterator on the first constituent
size_t size() const
number of constituents
JetConstituent operator[](size_t i) const
Constituent proxy at position i.
std::vector< const IParticle * > asIParticleVector() const
vector of pointer to the underlying IParticles.
JetConstituent front() const
first constituent proxy
bool isValid() const
Check if element links are valid.
JetConstituent back() const
last constituent proxy
iterator end() const
iterator after the last constituent
bool empty() const
true if vector is empty()
std::vector< JetConstituent > asSTLVector()
Returns this vector as a std::vector Provided for convenience when dealing with the JetConstituentVec...
JetConstituent at(size_t i) const
Constituent proxy at position i.
4-vector of jet constituent at the scale used during jet finding.
virtual double ptEM() const
get EM scale pt
Definition PFO_v1.cxx:204
virtual double etaEM() const
get EM scale eta
Definition PFO_v1.cxx:215
virtual double phiEM() const
get EM scale phi
Definition PFO_v1.cxx:220
virtual double mEM() const
get EM scale mass
Definition PFO_v1.cxx:224
ICaloAffectedTool is abstract interface for tools checking if 4 mom is in calo affected region.
void fillJetConstituent(const IParticle *part, JetConstituent &constit, JetConstitScale sigState)
PFO_v1 PFO
Definition of the current "pfo version".
Definition PFO.h:17
CaloCluster_v1 CaloCluster
Define the latest version of the calorimeter cluster class.
double ptFromEEtaM(const double e, const double eta, const double m)
JetConstituentVector::iterator iterator
JetConstitScale
Definition JetTypes.h:20
@ UncalibratedJetConstituent
Definition JetTypes.h:21