CMS 3D CMS Logo

CaloParticle.h
Go to the documentation of this file.
1 #ifndef SimDataFormats_CaloParticle_h
2 #define SimDataFormats_CaloParticle_h
3 
4 #include <vector>
12 
13 class SimTrack;
14 class EncodedEventId;
15 
17 {
18  friend std::ostream& operator<< (std::ostream& s, CaloParticle const& tp);
19 public:
20  typedef int Charge;
25 
28  typedef std::vector<SimTrack>::const_iterator g4t_iterator;
30 
31  CaloParticle();
32 
33  CaloParticle( const SimTrack& simtrk );
34  CaloParticle( EncodedEventId eventID, uint32_t particleID ); // for PU
35 
36  // destructor
37  ~CaloParticle();
38 
43  int pdgId() const {
44  if( genParticles_.empty() ) return g4Tracks_[0].type();
45  else return (*genParticles_.begin())->pdgId();
46  }
47 
53  return event_;
54  }
55 
56  uint64_t particleId() const {
57  return particleId_;
58  }
59 
60  // Setters for G4 and reco::GenParticle
62  void addSimCluster( const SimClusterRef& ref) { simClusters_.push_back( ref ); }
63  void addG4Track( const SimTrack& t) { g4Tracks_.push_back(t); }
65  genp_iterator genParticle_begin() const { return genParticles_.begin(); }
66  genp_iterator genParticle_end() const { return genParticles_.end(); }
67  g4t_iterator g4Track_begin() const { return g4Tracks_.begin(); }
68  g4t_iterator g4Track_end() const { return g4Tracks_.end(); }
69  sc_iterator simCluster_begin() const { return simClusters_.begin(); }
70  sc_iterator simCluster_end() const { return simClusters_.end(); }
71 
72  // Getters for Embd and Sim Tracks
74  const SimClusterRefVector& simClusters() const { return simClusters_; }
75  // Only for clusters from the signal vertex
76  const std::vector<SimTrack>& g4Tracks() const { return g4Tracks_; }
77 
79  float charge() const { return g4Tracks_[0].charge(); }
81  int threeCharge() const { return lrintf(3.f*charge()); }
82 
84  const math::XYZTLorentzVectorF& p4() const {
85  return theMomentum_;
86  }
87 
90  return p4().Vect();
91  }
92 
95  return p4().BoostToCM();
96  }
97 
99  float p() const {
100  return p4().P();
101  }
102 
104  float energy() const {
105  return p4().E();
106  }
107 
109  float et() const {
110  return p4().Et();
111  }
112 
114  float mass() const {
115  return p4().M();
116  }
117 
119  float massSqr() const {
120  return pow( mass(), 2 );
121  }
122 
124  float mt() const {
125  return p4().Mt();
126  }
127 
129  float mtSqr() const {
130  return p4().Mt2();
131  }
132 
134  float px() const {
135  return p4().Px();
136  }
137 
139  float py() const {
140  return p4().Py();
141  }
142 
144  float pz() const {
145  return p4().Pz();
146  }
147 
149  float pt() const {
150  return p4().Pt();
151  }
152 
154  float phi() const {
155  return p4().Phi();
156  }
157 
159  float theta() const {
160  return p4().Theta();
161  }
162 
164  float eta() const {
165  return p4().Eta();
166  }
167 
169  float rapidity() const {
170  return p4().Rapidity();
171  }
172 
174  float y() const {
175  return rapidity();
176  }
177 
181  int status() const {
182  return genParticles_.empty() ? -99 : (*genParticles_[0]).status();
183  }
184 
185  static const unsigned int longLivedTag;
186 
188  bool longLived() const { return status()&longLivedTag;}
189 
191  int numberOfSimHits() const {return nsimhits_;}
192 
194  int numberOfRecHits() const {return hits_.size();}
195 
197  void addRecHitAndFraction(uint32_t hit, float fraction) {
198  hits_.emplace_back(hit);
199  fractions_.emplace_back(fraction);
200  }
201 
203  std::vector<std::pair<uint32_t,float> > hits_and_fractions() const {
204  std::vector<std::pair<uint32_t,float> > result;
205  for(size_t i = 0; i < hits_.size(); ++i) {
206  result.emplace_back(hits_[i],fractions_[i]);
207  }
208  return result;
209  }
210 
212  float simEnergy() const { return simhit_energy_; }
213 
215  void addSimHit(const PCaloHit& hit) { simhit_energy_ += hit.energy(); }
216 
217 private:
220 
221  uint32_t particleId_;
223  std::vector<uint32_t> hits_;
224  std::vector<float> fractions_;
225 
227 
229  std::vector<SimTrack> g4Tracks_;
231 
233 };
234 
235 #endif // SimDataFormats_CaloParticle_H
float pz() const
z coordinate of momentum vector. Note this is taken from the first SimTrack only. ...
Definition: CaloParticle.h:144
type
Definition: HCALResponse.h:21
int Charge
electric charge type
Definition: CaloParticle.h:20
std::vector< uint32_t > hits_
Definition: CaloParticle.h:223
float simEnergy() const
returns the accumulated sim energy in the cluster
Definition: CaloParticle.h:212
ROOT::Math::LorentzVector< ROOT::Math::PxPyPzE4D< double > > XYZTLorentzVectorD
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:14
uint64_t nsimhits_
Definition: CaloParticle.h:218
double energy() const
Definition: PCaloHit.h:29
SimClusterRefVector::iterator sc_iterator
Definition: CaloParticle.h:29
void addG4Track(const SimTrack &t)
Definition: CaloParticle.h:63
void addRecHitAndFraction(uint32_t hit, float fraction)
add rechit with fraction
Definition: CaloParticle.h:197
EncodedEventId eventId() const
Signal source, crossing number.
Definition: CaloParticle.h:52
float charge() const
Electric charge. Note this is taken from the first SimTrack only.
Definition: CaloParticle.h:79
math::XYZTLorentzVectorD LorentzVector
Lorentz vector.
Definition: CaloParticle.h:21
float p() const
Magnitude of momentum vector. Note this is taken from the first SimTrack only.
Definition: CaloParticle.h:99
reco::GenParticleRefVector genParticles_
Definition: CaloParticle.h:230
int status() const
Status word.
Definition: CaloParticle.h:181
std::vector< float > fractions_
Definition: CaloParticle.h:224
math::XYZVectorD Vector
point in the space
Definition: CaloParticle.h:24
EncodedEventId event_
Definition: CaloParticle.h:219
int numberOfSimHits() const
Gives the total number of SimHits, in the cluster.
Definition: CaloParticle.h:191
const std::vector< SimTrack > & g4Tracks() const
Definition: CaloParticle.h:76
float eta() const
Momentum pseudorapidity. Note this is taken from the simtrack before the calorimeter.
Definition: CaloParticle.h:164
float massSqr() const
Mass squared. Note this is taken from the first SimTrack only.
Definition: CaloParticle.h:119
const_iterator end() const
Termination of iteration.
Definition: RefVector.h:253
bool empty() const
Is the RefVector empty.
Definition: RefVector.h:104
math::PtEtaPhiMLorentzVector PolarLorentzVector
Lorentz vector.
Definition: CaloParticle.h:22
SimClusterRefVector simClusters_
Definition: CaloParticle.h:232
std::vector< SimTrack >::const_iterator g4t_iterator
Definition: CaloParticle.h:28
genp_iterator genParticle_begin() const
iterators
Definition: CaloParticle.h:65
const_iterator begin() const
Initialize an iterator over the RefVector.
Definition: RefVector.h:248
math::XYZTLorentzVectorF theMomentum_
Definition: CaloParticle.h:226
int numberOfRecHits() const
Gives the total number of SimHits, in the cluster.
Definition: CaloParticle.h:194
uint64_t particleId() const
Definition: CaloParticle.h:56
math::XYZPointD Point
point in the space
Definition: CaloParticle.h:23
reco::GenParticleRefVector::iterator genp_iterator
reference to reco::GenParticle
Definition: CaloParticle.h:27
sc_iterator simCluster_end() const
Definition: CaloParticle.h:70
PtEtaPhiMLorentzVectorD PtEtaPhiMLorentzVector
Lorentz vector with cartesian internal representation.
Definition: LorentzVector.h:25
const math::XYZTLorentzVectorF & p4() const
Four-momentum Lorentz vector. Note this is taken from the first SimTrack only.
Definition: CaloParticle.h:84
static const unsigned int longLivedTag
long lived flag
Definition: CaloParticle.h:185
uint32_t particleId_
Definition: CaloParticle.h:221
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > XYZVectorD
spatial vector with cartesian internal representation
Definition: Vector3D.h:8
sc_iterator simCluster_begin() const
Definition: CaloParticle.h:69
const reco::GenParticleRefVector & genParticles() const
Definition: CaloParticle.h:73
const SimClusterRefVector & simClusters() const
Definition: CaloParticle.h:74
void addGenParticle(const reco::GenParticleRef &ref)
Definition: CaloParticle.h:61
void addSimHit(const PCaloHit &hit)
add simhit&#39;s energy to cluster
Definition: CaloParticle.h:215
float energy() const
Energy. Note this is taken from the first SimTrack only.
Definition: CaloParticle.h:104
float theta() const
Momentum polar angle. Note this is taken from the first SimTrack only.
Definition: CaloParticle.h:159
double f[11][100]
float simhit_energy_
Definition: CaloParticle.h:222
void addSimCluster(const SimClusterRef &ref)
Definition: CaloParticle.h:62
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< float > > XYZVectorF
spatial vector with cartesian internal representation
Definition: Vector3D.h:17
math::XYZVectorF boostToCM() const
Vector to boost to the particle centre of mass frame.
Definition: CaloParticle.h:94
std::vector< std::pair< uint32_t, float > > hits_and_fractions() const
Returns list of rechit IDs and fractions for this CaloParticle.
Definition: CaloParticle.h:203
float mt() const
Transverse mass. Note this is taken from the first SimTrack only.
Definition: CaloParticle.h:124
float y() const
Same as rapidity().
Definition: CaloParticle.h:174
math::XYZVectorF momentum() const
spatial momentum vector
Definition: CaloParticle.h:89
float px() const
x coordinate of momentum vector. Note this is taken from the first SimTrack only. ...
Definition: CaloParticle.h:134
ROOT::Math::PositionVector3D< ROOT::Math::Cartesian3D< double > > XYZPointD
point in space with cartesian internal representation
Definition: Point3D.h:8
friend std::ostream & operator<<(std::ostream &s, CaloParticle const &tp)
Definition: CaloParticle.cc:37
unsigned long long uint64_t
Definition: Time.h:15
float pt() const
Transverse momentum. Note this is taken from the first SimTrack only.
Definition: CaloParticle.h:149
int pdgId() const
PDG ID.
Definition: CaloParticle.h:43
std::vector< SimTrack > g4Tracks_
references to G4 and reco::GenParticle tracks
Definition: CaloParticle.h:229
float phi() const
Momentum azimuthal angle. Note this is taken from the first SimTrack only.
Definition: CaloParticle.h:154
float rapidity() const
Rapidity. Note this is taken from the simtrack before the calorimeter.
Definition: CaloParticle.h:169
g4t_iterator g4Track_end() const
Definition: CaloParticle.h:68
bool longLived() const
is long lived?
Definition: CaloParticle.h:188
float mtSqr() const
Transverse mass squared. Note this is taken from the first SimTrack only.
Definition: CaloParticle.h:129
float mass() const
Mass. Note this is taken from the first SimTrack only.
Definition: CaloParticle.h:114
g4t_iterator g4Track_begin() const
Definition: CaloParticle.h:67
void push_back(value_type const &ref)
Add a Ref<C, T> to the RefVector.
Definition: RefVector.h:69
int threeCharge() const
Gives charge in unit of quark charge (should be 3 times "charge()")
Definition: CaloParticle.h:81
float et() const
Transverse energy. Note this is taken from the first SimTrack only.
Definition: CaloParticle.h:109
ROOT::Math::LorentzVector< ROOT::Math::PxPyPzE4D< float > > XYZTLorentzVectorF
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:22
float py() const
y coordinate of momentum vector. Note this is taken from the first SimTrack only. ...
Definition: CaloParticle.h:139
genp_iterator genParticle_end() const
Definition: CaloParticle.h:66
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40