CMS 3D CMS Logo

RealisticCluster.h
Go to the documentation of this file.
1 #ifndef __RecoParticleFlow_PFClusterProducer_RealisticCluster_H__
2 #define __RecoParticleFlow_PFClusterProducer_RealisticCluster_H__
3 
4 #include <array>
5 #include <vector>
6 #include <algorithm>
7 
9  using Hit3DPosition = std::array<float, 3>;
10 
11 public:
12  // for each SimCluster and for each layer, we store the position of the most energetic hit of the simcluster in the layer
13 
14  struct LayerInfo {
18  };
19 
21 
22  void increaseEnergy(float value) { totalEnergy += value; }
24 
26  float fraction = 0.f;
27  if (totalEnergy > 0.f) {
29  }
30  return fraction;
31  }
32 
33  float getEnergy() const { return totalEnergy; }
34 
35  float getExclusiveEnergy() const { return exclusiveEnergy; }
36 
37  bool isVisible() const { return visible; }
38 
39  void setVisible(bool vis) { visible = vis; }
40 
41  void setCenterOfGravity(unsigned int layerId, const Hit3DPosition& position) {
42  layerInfo_[layerId].centerOfGravityAtLayer_ = position;
43  }
44 
45  Hit3DPosition getCenterOfGravity(unsigned int layerId) const { return layerInfo_[layerId].centerOfGravityAtLayer_; }
46 
47  bool setMaxEnergyHit(unsigned int layerId, float newEnergy, const Hit3DPosition position) {
48  if (newEnergy > layerInfo_[layerId].maxEnergyHitAtLayer_) {
49  layerInfo_[layerId].maxEnergyHitAtLayer_ = newEnergy;
50  layerInfo_[layerId].maxHitPosAtLayer_ = position;
51  return true;
52  } else
53  return false;
54  }
55 
56  Hit3DPosition getMaxEnergyPosition(unsigned int layerId) const { return layerInfo_[layerId].maxHitPosAtLayer_; }
57 
58  float getMaxEnergy(unsigned int layerId) const { return layerInfo_[layerId].maxEnergyHitAtLayer_; }
59 
60  void setLayersNum(unsigned int numberOfLayers) { layerInfo_.resize(numberOfLayers); }
61 
62  unsigned int getLayersNum() const { return layerInfo_.size(); }
63 
64  void addHitAndFraction(unsigned int hit, float fraction) { hitIdsAndFractions_.emplace_back(hit, fraction); }
65 
66  void modifyFractionForHitId(float fraction, unsigned int hitId) {
67  auto it = std::find_if(hitIdsAndFractions_.begin(),
68  hitIdsAndFractions_.end(),
69  [&hitId](const std::pair<unsigned int, float>& element) { return element.first == hitId; });
70 
71  it->second = fraction;
72  }
73 
74  void modifyFractionByIndex(float fraction, unsigned int index) { hitIdsAndFractions_[index].second = fraction; }
75 
76  const std::vector<std::pair<unsigned int, float> >& hitsIdsAndFractions() const { return hitIdsAndFractions_; }
77 
78 private:
79  std::vector<std::pair<unsigned int, float> > hitIdsAndFractions_;
80  std::vector<LayerInfo> layerInfo_;
81 
82  float totalEnergy;
84  bool visible;
85 };
86 
87 #endif
void increaseExclusiveEnergy(float value)
constexpr uint32_t numberOfLayers
unsigned int getLayersNum() const
std::array< float, 3 > Hit3DPosition
bool isVisible() const
const std::vector< std::pair< unsigned int, float > > & hitsIdsAndFractions() const
Hit3DPosition getMaxEnergyPosition(unsigned int layerId) const
float getExclusiveEnergy() const
std::vector< std::pair< unsigned int, float > > hitIdsAndFractions_
Hit3DPosition centerOfGravityAtLayer_
double f[11][100]
Definition: value.py:1
void setCenterOfGravity(unsigned int layerId, const Hit3DPosition &position)
std::vector< LayerInfo > layerInfo_
void setVisible(bool vis)
float getMaxEnergy(unsigned int layerId) const
void modifyFractionByIndex(float fraction, unsigned int index)
bool setMaxEnergyHit(unsigned int layerId, float newEnergy, const Hit3DPosition position)
void increaseEnergy(float value)
static int position[264][3]
Definition: ReadPGInfo.cc:289
Hit3DPosition getCenterOfGravity(unsigned int layerId) const
float getExclusiveEnergyFraction() const
void setLayersNum(unsigned int numberOfLayers)
float getEnergy() const
void modifyFractionForHitId(float fraction, unsigned int hitId)
void addHitAndFraction(unsigned int hit, float fraction)