CMS 3D CMS Logo

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 {
10  using Hit3DPosition = std::array<float,3>;
11 
12  public:
13 
14  // for each SimCluster and for each layer, we store the position of the most energetic hit of the simcluster in the layer
15 
16  struct LayerInfo
17  {
21  };
22 
24  totalEnergy(0.f),
25  exclusiveEnergy(0.f),
26  visible(true)
27  {
28 
29  }
30 
31  void increaseEnergy(float value)
32  {
34  }
36  {
38  }
39 
41  {
42  float fraction = 0.f;
43  if(totalEnergy>0.f){
44  fraction = exclusiveEnergy/totalEnergy;
45  }
46  return fraction;
47  }
48 
49  float getEnergy() const
50  {
51  return totalEnergy;
52  }
53 
54  float getExclusiveEnergy() const
55  {
56  return exclusiveEnergy;
57  }
58 
59  bool isVisible() const
60  {
61  return visible;
62  }
63 
64  void setVisible(bool vis)
65  {
66  visible = vis;
67  }
68 
69  void setCenterOfGravity(unsigned int layerId, const Hit3DPosition& position)
70  {
71  layerInfo_[layerId].centerOfGravityAtLayer_ = position;
72  }
73 
74  Hit3DPosition getCenterOfGravity(unsigned int layerId) const
75  {
76  return layerInfo_[layerId].centerOfGravityAtLayer_ ;
77  }
78 
79  bool setMaxEnergyHit(unsigned int layerId, float newEnergy, const Hit3DPosition position)
80  {
81  if (newEnergy > layerInfo_[layerId].maxEnergyHitAtLayer_)
82  {
83  layerInfo_[layerId].maxEnergyHitAtLayer_ = newEnergy;
84  layerInfo_[layerId].maxHitPosAtLayer_ = position;
85  return true;
86  }
87  else
88  return false;
89  }
90 
91  Hit3DPosition getMaxEnergyPosition (unsigned int layerId) const
92  {
93  return layerInfo_[layerId].maxHitPosAtLayer_;
94  }
95 
96  float getMaxEnergy(unsigned int layerId) const
97  {
98  return layerInfo_[layerId].maxEnergyHitAtLayer_;
99  }
100 
101  void setLayersNum(unsigned int numberOfLayers)
102  {
103  layerInfo_.resize(numberOfLayers);
104  }
105 
106  unsigned int getLayersNum() const
107  {
108  return layerInfo_.size();
109  }
110 
111  void addHitAndFraction(unsigned int hit, float fraction)
112  {
113  hitIdsAndFractions_.emplace_back(hit,fraction);
114  }
115 
116  void modifyFractionForHitId(float fraction, unsigned int hitId)
117  {
118  auto it = std::find_if( hitIdsAndFractions_.begin(), hitIdsAndFractions_.end(),
119  [&hitId](const std::pair<unsigned int, float>& element){ return element.first == hitId;} );
120 
121  it->second = fraction;
122  }
123 
124  void modifyFractionByIndex(float fraction, unsigned int index)
125  {
127  }
128 
129  const std::vector< std::pair<unsigned int, float> > & hitsIdsAndFractions() const { return hitIdsAndFractions_; }
130 
131  private:
132  std::vector<std::pair<unsigned int, float> > hitIdsAndFractions_;
133  std::vector<LayerInfo> layerInfo_;
134 
135  float totalEnergy;
137  bool visible;
138 };
139 
140 #endif
void increaseExclusiveEnergy(float value)
float getMaxEnergy(unsigned int layerId) const
unsigned int getLayersNum() const
const std::vector< std::pair< unsigned int, float > > & hitsIdsAndFractions() const
bool isVisible() const
std::vector< std::pair< unsigned int, float > > hitIdsAndFractions_
Hit3DPosition centerOfGravityAtLayer_
std::array< float, 3 > Hit3DPosition
double f[11][100]
Definition: value.py:1
Hit3DPosition getMaxEnergyPosition(unsigned int layerId) const
float getEnergy() const
void setCenterOfGravity(unsigned int layerId, const Hit3DPosition &position)
std::vector< LayerInfo > layerInfo_
float getExclusiveEnergy() const
void setVisible(bool vis)
float getExclusiveEnergyFraction() 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:509
Hit3DPosition getCenterOfGravity(unsigned int layerId) const
void setLayersNum(unsigned int numberOfLayers)
void modifyFractionForHitId(float fraction, unsigned int hitId)
void addHitAndFraction(unsigned int hit, float fraction)