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
RealisticCluster::RealisticCluster
RealisticCluster()
Definition: RealisticCluster.h:20
f
double f[11][100]
Definition: MuScleFitUtils.cc:78
RealisticCluster::setVisible
void setVisible(bool vis)
Definition: RealisticCluster.h:39
RealisticCluster::setCenterOfGravity
void setCenterOfGravity(unsigned int layerId, const Hit3DPosition &position)
Definition: RealisticCluster.h:41
RealisticCluster::getMaxEnergy
float getMaxEnergy(unsigned int layerId) const
Definition: RealisticCluster.h:58
RealisticCluster::getExclusiveEnergyFraction
float getExclusiveEnergyFraction() const
Definition: RealisticCluster.h:25
RealisticCluster::getEnergy
float getEnergy() const
Definition: RealisticCluster.h:33
RealisticCluster::totalEnergy
float totalEnergy
Definition: RealisticCluster.h:82
RealisticCluster::setLayersNum
void setLayersNum(unsigned int numberOfLayers)
Definition: RealisticCluster.h:60
RealisticCluster::setMaxEnergyHit
bool setMaxEnergyHit(unsigned int layerId, float newEnergy, const Hit3DPosition position)
Definition: RealisticCluster.h:47
RealisticCluster::LayerInfo::centerOfGravityAtLayer_
Hit3DPosition centerOfGravityAtLayer_
Definition: RealisticCluster.h:15
RealisticCluster::increaseEnergy
void increaseEnergy(float value)
Definition: RealisticCluster.h:22
RealisticCluster::layerInfo_
std::vector< LayerInfo > layerInfo_
Definition: RealisticCluster.h:80
RealisticCluster::getCenterOfGravity
Hit3DPosition getCenterOfGravity(unsigned int layerId) const
Definition: RealisticCluster.h:45
RealisticCluster::visible
bool visible
Definition: RealisticCluster.h:84
RealisticCluster::modifyFractionByIndex
void modifyFractionByIndex(float fraction, unsigned int index)
Definition: RealisticCluster.h:74
runTauDisplay.vis
vis
Definition: runTauDisplay.py:328
RealisticCluster::addHitAndFraction
void addHitAndFraction(unsigned int hit, float fraction)
Definition: RealisticCluster.h:64
RealisticCluster::getLayersNum
unsigned int getLayersNum() const
Definition: RealisticCluster.h:62
funct::true
true
Definition: Factorize.h:173
RealisticCluster::LayerInfo::maxHitPosAtLayer_
Hit3DPosition maxHitPosAtLayer_
Definition: RealisticCluster.h:16
RealisticCluster::modifyFractionForHitId
void modifyFractionForHitId(float fraction, unsigned int hitId)
Definition: RealisticCluster.h:66
position
static int position[264][3]
Definition: ReadPGInfo.cc:289
RealisticCluster::LayerInfo::maxEnergyHitAtLayer_
float maxEnergyHitAtLayer_
Definition: RealisticCluster.h:17
RealisticCluster::isVisible
bool isVisible() const
Definition: RealisticCluster.h:37
value
Definition: value.py:1
RealisticCluster
Definition: RealisticCluster.h:8
RealisticCluster::hitsIdsAndFractions
const std::vector< std::pair< unsigned int, float > > & hitsIdsAndFractions() const
Definition: RealisticCluster.h:76
RealisticCluster::increaseExclusiveEnergy
void increaseExclusiveEnergy(float value)
Definition: RealisticCluster.h:23
RealisticCluster::Hit3DPosition
std::array< float, 3 > Hit3DPosition
Definition: RealisticCluster.h:9
RealisticCluster::exclusiveEnergy
float exclusiveEnergy
Definition: RealisticCluster.h:83
relativeConstraints.value
value
Definition: relativeConstraints.py:53
AlignmentPI::index
index
Definition: AlignmentPayloadInspectorHelper.h:46
RealisticCluster::getExclusiveEnergy
float getExclusiveEnergy() const
Definition: RealisticCluster.h:35
numberOfLayers
const map< TString, int > numberOfLayers(TString Year="2018")
Definition: DMRtrends.cc:253
RealisticCluster::getMaxEnergyPosition
Hit3DPosition getMaxEnergyPosition(unsigned int layerId) const
Definition: RealisticCluster.h:56
RealisticCluster::LayerInfo
Definition: RealisticCluster.h:14
RealisticCluster::hitIdsAndFractions_
std::vector< std::pair< unsigned int, float > > hitIdsAndFractions_
Definition: RealisticCluster.h:79
HLT_2018_cff.fraction
fraction
Definition: HLT_2018_cff.py:51317
hit
Definition: SiStripHitEffFromCalibTree.cc:88