CMS 3D CMS Logo

MtdSimCluster.h
Go to the documentation of this file.
1 // Author: Aurora Perego, Fabio Cossutti - aurora.perego@cern.ch, fabio.cossutti@ts.infn.it
2 // Date: 05/2023
3 
4 #ifndef SimDataFormats_CaloAnalysis_MtdSimCluster_h
5 #define SimDataFormats_CaloAnalysis_MtdSimCluster_h
6 
9 #include <vector>
10 
11 class MtdSimCluster : public SimCluster {
12  friend std::ostream &operator<<(std::ostream &s, MtdSimCluster const &tp);
13 
14 public:
15  MtdSimCluster();
16  MtdSimCluster(const SimTrack &simtrk);
17  MtdSimCluster(EncodedEventId eventID, uint32_t particleID); // for PU
18 
19  // destructor
21 
23  void addHitTime(float time) {
24  times_.emplace_back(time);
25  ++nsimhits_;
26  }
27 
30  mtdHits_.emplace_back(hit);
31  fractions_.emplace_back(fraction);
32  }
33 
35  std::vector<std::pair<uint64_t, float>> hits_and_fractions() const {
36  assert(mtdHits_.size() == fractions_.size());
37  std::vector<std::pair<uint64_t, float>> result;
38  result.reserve(mtdHits_.size());
39  for (size_t i = 0; i < mtdHits_.size(); ++i) {
40  result.emplace_back(mtdHits_[i], fractions_[i]);
41  }
42  return result;
43  }
44 
46  std::vector<std::pair<uint64_t, float>> hits_and_energies() const {
47  assert(mtdHits_.size() == energies_.size());
48  std::vector<std::pair<uint64_t, float>> result;
49  result.reserve(mtdHits_.size());
50  for (size_t i = 0; i < mtdHits_.size(); ++i) {
51  result.emplace_back(mtdHits_[i], energies_[i]);
52  }
53  return result;
54  }
55 
58  std::vector<uint64_t>().swap(mtdHits_);
59  std::vector<float>().swap(fractions_);
60  }
61 
63  std::vector<std::pair<uint64_t, float>> hits_and_times() const {
64  assert(mtdHits_.size() == times_.size());
65  std::vector<std::pair<uint64_t, float>> result;
66  result.reserve(mtdHits_.size());
67  for (size_t i = 0; i < mtdHits_.size(); ++i) {
68  result.emplace_back(mtdHits_[i], times_[i]);
69  }
70  return result;
71  }
72 
74  std::vector<std::pair<uint32_t, std::pair<uint8_t, uint8_t>>> detIds_and_rows() const {
75  std::vector<std::pair<uint32_t, std::pair<uint8_t, uint8_t>>> result;
76  result.reserve(mtdHits_.size());
77  for (size_t i = 0; i < mtdHits_.size(); ++i) {
78  result.emplace_back(
79  mtdHits_[i] >> 32,
80  std::pair<uint8_t, uint8_t>(static_cast<uint8_t>(mtdHits_[i] >> 16), static_cast<uint8_t>(mtdHits_[i])));
81  }
82  return result;
83  }
84 
86  void clearHitsTime() { std::vector<float>().swap(times_); }
87 
88  void clear() {
91  clearHitsTime();
92  }
93 
95  void addSimHit(const PSimHit &hit) {
96  simhit_energy_ += hit.energyLoss();
97  ++nsimhits_;
98  }
99 
100 protected:
101  std::vector<uint64_t> mtdHits_;
102  std::vector<float> times_;
103 };
104 
105 #endif
float simhit_energy_
Definition: SimCluster.h:226
assert(be >=bs)
void swap(Association< C > &lhs, Association< C > &rhs)
Definition: Association.h:112
uint64_t nsimhits_
Definition: SimCluster.h:222
void clearHitsEnergy()
clear the energies list
Definition: SimCluster.h:210
void clearHitsAndFractions()
clear the hits and fractions list
Definition: MtdSimCluster.h:57
Monte Carlo truth information used for tracking validation.
Definition: SimCluster.h:29
void addSimHit(const PSimHit &hit)
add simhit&#39;s energy to cluster
Definition: MtdSimCluster.h:95
std::vector< float > times_
std::vector< float > fractions_
Definition: SimCluster.h:228
std::vector< std::pair< uint64_t, float > > hits_and_energies() const
Returns list of hit IDs and energies for this SimCluster.
Definition: MtdSimCluster.h:46
std::vector< std::pair< uint64_t, float > > hits_and_times() const
Returns list of hit IDs and times for this SimCluster.
Definition: MtdSimCluster.h:63
unsigned long long uint64_t
Definition: Time.h:13
std::vector< std::pair< uint64_t, float > > hits_and_fractions() const
Returns list of hit IDs and fractions for this SimCluster.
Definition: MtdSimCluster.h:35
std::vector< uint64_t > mtdHits_
void addHitAndFraction(uint64_t hit, float fraction)
add hit with fraction
Definition: MtdSimCluster.h:29
friend std::ostream & operator<<(std::ostream &s, MtdSimCluster const &tp)
void addHitTime(float time)
add hit time
Definition: MtdSimCluster.h:23
void clearHitsTime()
clear the times list
Definition: MtdSimCluster.h:86
std::vector< float > energies_
Definition: SimCluster.h:229
std::vector< std::pair< uint32_t, std::pair< uint8_t, uint8_t > > > detIds_and_rows() const
Returns list of detIds, rows and columns for this SimCluster.
Definition: MtdSimCluster.h:74