CMS 3D CMS Logo

SimCluster.h
Go to the documentation of this file.
1 #ifndef SimDataFormats_SimCluster_h
2 #define SimDataFormats_SimCluster_h
3 
10 #include <vector>
11 
12 //
13 // Forward declarations
14 //
15 class SimTrack;
16 class EncodedEventId;
17 
29 class SimCluster {
30  friend std::ostream &operator<<(std::ostream &s, SimCluster const &tp);
31 
32 public:
33  typedef int Charge;
38 
41  typedef std::vector<SimTrack>::const_iterator g4t_iterator;
42 
43  SimCluster();
44 
45  SimCluster(const SimTrack &simtrk);
46  SimCluster(EncodedEventId eventID, uint32_t particleID); // for PU
47 
48  // destructor
49  ~SimCluster();
50 
55  int pdgId() const {
56  if (genParticles_.empty())
57  return g4Tracks_[0].type();
58  else
59  return (*genParticles_.begin())->pdgId();
60  }
61 
66  EncodedEventId eventId() const { return event_; }
67 
68  uint64_t particleId() const { return particleId_; }
69 
70  // Setters for G4 and reco::GenParticle
72  void addG4Track(const SimTrack &t) { g4Tracks_.push_back(t); }
76  g4t_iterator g4Track_begin() const { return g4Tracks_.begin(); }
77  g4t_iterator g4Track_end() const { return g4Tracks_.end(); }
78 
79  // Getters for Embd and Sim Tracks
81  // Only for clusters from the signal vertex
82  const std::vector<SimTrack> &g4Tracks() const { return g4Tracks_; }
83 
85  float charge() const { return g4Tracks_[0].charge(); }
87  int threeCharge() const { return lrintf(3.f * charge()); }
88 
91  const math::XYZTLorentzVectorF &p4() const { return theMomentum_; }
92 
94  math::XYZVectorF momentum() const { return p4().Vect(); }
95 
97  math::XYZVectorF boostToCM() const { return p4().BoostToCM(); }
98 
101  float p() const { return p4().P(); }
102 
104  float energy() const { return p4().E(); }
105 
107  float et() const { return p4().Et(); }
108 
110  float mass() const { return p4().M(); }
111 
113  float massSqr() const { return pow(mass(), 2); }
114 
116  float mt() const { return p4().Mt(); }
117 
120  float mtSqr() const { return p4().Mt2(); }
121 
124  float px() const { return p4().Px(); }
125 
128  float py() const { return p4().Py(); }
129 
132  float pz() const { return p4().Pz(); }
133 
136  float pt() const { return p4().Pt(); }
137 
140  float phi() const { return p4().Phi(); }
141 
144  float theta() const { return p4().Theta(); }
145 
148  float eta() const { return p4().Eta(); }
149 
152  float rapidity() const { return p4().Rapidity(); }
153 
155  float y() const { return rapidity(); }
156 
161  int status() const { return genParticles_.empty() ? -99 : (*genParticles_[0]).status(); }
162 
163  static const unsigned int longLivedTag;
164 
166  bool longLived() const { return status() & longLivedTag; }
167 
169  int numberOfSimHits() const { return nsimhits_; }
170 
172  int numberOfRecHits() const { return hits_.size(); }
173 
175  void addRecHitAndFraction(uint32_t hit, float fraction) {
176  hits_.emplace_back(hit);
177  fractions_.emplace_back(fraction);
178  }
179 
181  void addHitEnergy(float energy) { energies_.emplace_back(energy); }
182 
184  std::vector<std::pair<uint32_t, float>> hits_and_fractions() const {
185  std::vector<std::pair<uint32_t, float>> result;
186  for (size_t i = 0; i < hits_.size(); ++i) {
187  result.emplace_back(hits_[i], fractions_[i]);
188  }
189  return result;
190  }
191 
193  std::vector<std::pair<uint32_t, float>> hits_and_energies() const {
194  assert(hits_.size() == energies_.size());
195  std::vector<std::pair<uint32_t, float>> result;
196  result.reserve(hits_.size());
197  for (size_t i = 0; i < hits_.size(); ++i) {
198  result.emplace_back(hits_[i], energies_[i]);
199  }
200  return result;
201  }
202 
205  std::vector<uint32_t>().swap(hits_);
206  std::vector<float>().swap(fractions_);
207  }
208 
210  void clearHitsEnergy() { std::vector<float>().swap(energies_); }
211 
213  float simEnergy() const { return simhit_energy_; }
214 
216  void addSimHit(const PCaloHit &hit) { simhit_energy_ += hit.energy(); }
217 
218 private:
221 
222  uint32_t particleId_;
224  std::vector<uint32_t> hits_;
225  std::vector<float> fractions_;
226  std::vector<float> energies_;
227 
229 
231  std::vector<SimTrack> g4Tracks_;
233 };
234 
235 #endif // SimDataFormats_SimCluster_H
mps_fire.i
i
Definition: mps_fire.py:355
SimCluster::fractions_
std::vector< float > fractions_
Definition: SimCluster.h:225
SimCluster::px
float px() const
x coordinate of momentum vector. Note this is taken from the first SimTrack only.
Definition: SimCluster.h:124
SimCluster::g4Track_end
g4t_iterator g4Track_end() const
Definition: SimCluster.h:77
SimCluster::g4Tracks_
std::vector< SimTrack > g4Tracks_
references to G4 and reco::GenParticle tracks
Definition: SimCluster.h:231
f
double f[11][100]
Definition: MuScleFitUtils.cc:78
SimCluster::threeCharge
int threeCharge() const
Gives charge in unit of quark charge (should be 3 times "charge()")
Definition: SimCluster.h:87
math::XYZTLorentzVectorF
ROOT::Math::LorentzVector< ROOT::Math::PxPyPzE4D< float > > XYZTLorentzVectorF
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:22
math::XYZTLorentzVectorD
ROOT::Math::LorentzVector< ROOT::Math::PxPyPzE4D< double > > XYZTLorentzVectorD
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:14
SimCluster::genParticle_end
genp_iterator genParticle_end() const
Definition: SimCluster.h:75
edm::RefVector::begin
const_iterator begin() const
Initialize an iterator over the RefVector.
Definition: RefVector.h:223
cms::cuda::assert
assert(be >=bs)
SimCluster::pdgId
int pdgId() const
PDG ID.
Definition: SimCluster.h:55
edm::RefVector< GenParticleCollection >
SimCluster::energy
float energy() const
Energy. Note this is taken from the first SimTrack only.
Definition: SimCluster.h:104
SimCluster
Monte Carlo truth information used for tracking validation.
Definition: SimCluster.h:29
SimCluster::genParticles
const reco::GenParticleRefVector & genParticles() const
Definition: SimCluster.h:80
SimCluster::SimCluster
SimCluster()
Definition: SimCluster.cc:11
edm::Ref< GenParticleCollection >
GenParticle.h
SimCluster::genParticle_begin
genp_iterator genParticle_begin() const
iterators
Definition: SimCluster.h:74
EncodedEventId
Definition: EncodedEventId.h:11
SimCluster::longLived
bool longLived() const
is long lived?
Definition: SimCluster.h:166
SimCluster::addSimHit
void addSimHit(const PCaloHit &hit)
add simhit's energy to cluster
Definition: SimCluster.h:216
SimCluster::rapidity
float rapidity() const
Rapidity. Note this is taken from the simtrack before the calorimeter.
Definition: SimCluster.h:152
alignCSCRings.s
s
Definition: alignCSCRings.py:92
edm::RefVector::end
const_iterator end() const
Termination of iteration.
Definition: RefVector.h:228
SimCluster::particleId_
uint32_t particleId_
Definition: SimCluster.h:222
EgammaObjectsElectrons_cfi.particleID
particleID
Definition: EgammaObjectsElectrons_cfi.py:4
edm::RefVector::empty
bool empty() const
Is the RefVector empty.
Definition: RefVector.h:99
SimCluster::numberOfSimHits
int numberOfSimHits() const
Gives the total number of SimHits, in the cluster.
Definition: SimCluster.h:169
SimCluster::mt
float mt() const
Transverse mass. Note this is taken from the first SimTrack only.
Definition: SimCluster.h:116
SimCluster::p
float p() const
Magnitude of momentum vector. Note this is taken from the first SimTrack only.
Definition: SimCluster.h:101
SimCluster::g4Tracks
const std::vector< SimTrack > & g4Tracks() const
Definition: SimCluster.h:82
SimCluster::hits_and_energies
std::vector< std::pair< uint32_t, float > > hits_and_energies() const
Returns list of rechit IDs and energies for this SimCluster.
Definition: SimCluster.h:193
SimCluster::addHitEnergy
void addHitEnergy(float energy)
add rechit energy
Definition: SimCluster.h:181
SimCluster::energies_
std::vector< float > energies_
Definition: SimCluster.h:226
SimCluster::longLivedTag
static const unsigned int longLivedTag
long lived flag
Definition: SimCluster.h:163
SimCluster::genParticles_
reco::GenParticleRefVector genParticles_
Definition: SimCluster.h:232
SimCluster::theMomentum_
math::XYZTLorentzVectorF theMomentum_
Definition: SimCluster.h:228
SimCluster::eventId
EncodedEventId eventId() const
Signal source, crossing number.
Definition: SimCluster.h:66
SimCluster::PolarLorentzVector
math::PtEtaPhiMLorentzVector PolarLorentzVector
Lorentz vector.
Definition: SimCluster.h:35
SimCluster::phi
float phi() const
Momentum azimuthal angle. Note this is taken from the first SimTrack only.
Definition: SimCluster.h:140
OrderedSet.t
t
Definition: OrderedSet.py:90
cmsswSequenceInfo.tp
tp
Definition: cmsswSequenceInfo.py:17
math::XYZVectorD
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > XYZVectorD
spatial vector with cartesian internal representation
Definition: Vector3D.h:8
SimCluster::LorentzVector
math::XYZTLorentzVectorD LorentzVector
Lorentz vector.
Definition: SimCluster.h:34
SimCluster::et
float et() const
Transverse energy. Note this is taken from the first SimTrack only.
Definition: SimCluster.h:107
SimCluster::pz
float pz() const
z coordinate of momentum vector. Note this is taken from the first SimTrack only.
Definition: SimCluster.h:132
math::XYZPointD
ROOT::Math::PositionVector3D< ROOT::Math::Cartesian3D< double > > XYZPointD
point in space with cartesian internal representation
Definition: Point3D.h:8
SimCluster::simhit_energy_
float simhit_energy_
Definition: SimCluster.h:223
PCaloHit.h
LorentzVector.h
SimCluster::Point
math::XYZPointD Point
point in the space
Definition: SimCluster.h:36
SimCluster::addG4Track
void addG4Track(const SimTrack &t)
Definition: SimCluster.h:72
SimCluster::status
int status() const
Status word.
Definition: SimCluster.h:161
SimCluster::Vector
math::XYZVectorD Vector
point in the space
Definition: SimCluster.h:37
SimCluster::eta
float eta() const
Momentum pseudorapidity. Note this is taken from the simtrack before the calorimeter.
Definition: SimCluster.h:148
SimCluster::p4
const math::XYZTLorentzVectorF & p4() const
Four-momentum Lorentz vector. Note this is taken from the first SimTrack only.
Definition: SimCluster.h:91
PCaloHit
Definition: PCaloHit.h:8
SimCluster::g4Track_begin
g4t_iterator g4Track_begin() const
Definition: SimCluster.h:76
SimCluster::operator<<
friend std::ostream & operator<<(std::ostream &s, SimCluster const &tp)
Definition: SimCluster.cc:31
edm::RefVector::push_back
void push_back(value_type const &ref)
Add a Ref<C, T> to the RefVector.
Definition: RefVector.h:67
SimCluster::boostToCM
math::XYZVectorF boostToCM() const
Vector to boost to the particle centre of mass frame.
Definition: SimCluster.h:97
SimCluster::g4t_iterator
std::vector< SimTrack >::const_iterator g4t_iterator
Definition: SimCluster.h:41
SimCluster::massSqr
float massSqr() const
Mass squared. Note this is taken from the first SimTrack only.
Definition: SimCluster.h:113
SimCluster::Charge
int Charge
electric charge type
Definition: SimCluster.h:33
SimCluster::momentum
math::XYZVectorF momentum() const
spatial momentum vector
Definition: SimCluster.h:94
SimCluster::addGenParticle
void addGenParticle(const reco::GenParticleRef &ref)
Definition: SimCluster.h:71
SimCluster::particleId
uint64_t particleId() const
Definition: SimCluster.h:68
type
type
Definition: HCALResponse.h:21
SimCluster::mtSqr
float mtSqr() const
Transverse mass squared. Note this is taken from the first SimTrack only.
Definition: SimCluster.h:120
SimCluster::simEnergy
float simEnergy() const
returns the accumulated sim energy in the cluster
Definition: SimCluster.h:213
SimCluster::event_
EncodedEventId event_
Definition: SimCluster.h:220
SimTrack
Definition: SimTrack.h:6
SimCluster::numberOfRecHits
int numberOfRecHits() const
Gives the total number of SimHits, in the cluster.
Definition: SimCluster.h:172
SimCluster::clearHitsEnergy
void clearHitsEnergy()
clear the energies list
Definition: SimCluster.h:210
SimCluster::~SimCluster
~SimCluster()
Definition: SimCluster.cc:29
edm::RefVectorIterator
Definition: EDProductfwd.h:33
math::XYZVectorF
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< float > > XYZVectorF
spatial vector with cartesian internal representation
Definition: Vector3D.h:16
Point3D.h
SimCluster::charge
float charge() const
Electric charge. Note this is taken from the first SimTrack only.
Definition: SimCluster.h:85
cond::uint64_t
unsigned long long uint64_t
Definition: Time.h:13
SimCluster::hits_and_fractions
std::vector< std::pair< uint32_t, float > > hits_and_fractions() const
Returns list of rechit IDs and fractions for this SimCluster.
Definition: SimCluster.h:184
SimCluster::y
float y() const
Same as rapidity().
Definition: SimCluster.h:155
funct::pow
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:30
SimCluster::py
float py() const
y coordinate of momentum vector. Note this is taken from the first SimTrack only.
Definition: SimCluster.h:128
SimCluster::addRecHitAndFraction
void addRecHitAndFraction(uint32_t hit, float fraction)
add rechit with fraction
Definition: SimCluster.h:175
mps_fire.result
result
Definition: mps_fire.py:303
SimCluster::nsimhits_
uint64_t nsimhits_
Definition: SimCluster.h:219
math::PtEtaPhiMLorentzVector
PtEtaPhiMLorentzVectorD PtEtaPhiMLorentzVector
Lorentz vector with cartesian internal representation.
Definition: LorentzVector.h:25
SimTrack.h
SimCluster::hits_
std::vector< uint32_t > hits_
Definition: SimCluster.h:224
SimCluster::theta
float theta() const
Momentum polar angle. Note this is taken from the first SimTrack only.
Definition: SimCluster.h:144
Vector3D.h
HLT_2018_cff.fraction
fraction
Definition: HLT_2018_cff.py:51317
SimCluster::mass
float mass() const
Mass. Note this is taken from the first SimTrack only.
Definition: SimCluster.h:110
SimCluster::genp_iterator
reco::GenParticleRefVector::iterator genp_iterator
reference to reco::GenParticle
Definition: SimCluster.h:40
SimCluster::clearHitsAndFractions
void clearHitsAndFractions()
clear the hits and fractions list
Definition: SimCluster.h:204
hit
Definition: SiStripHitEffFromCalibTree.cc:88
SimCluster::pt
float pt() const
Transverse momentum. Note this is taken from the first SimTrack only.
Definition: SimCluster.h:136