CMS 3D CMS Logo

HGCalCLUEAlgo.h
Go to the documentation of this file.
1 #ifndef RecoLocalCalo_HGCalRecProducers_HGCalCLUEAlgo_h
2 #define RecoLocalCalo_HGCalRecProducers_HGCalCLUEAlgo_h
3 
5 
7 
13 
17 
20 
22 
23 // C/C++ headers
24 #include <string>
25 #include <vector>
26 #include <limits>
27 
28 template <typename TILE, typename STRATEGY>
30 public:
33  (HGCalClusteringAlgoBase::VerbosityLevel)ps.getUntrackedParameter<unsigned int>("verbosity", 3),
34  reco::CaloCluster::undefined),
35  vecDeltas_(ps.getParameter<std::vector<double>>("deltac")),
36  kappa_(ps.getParameter<double>("kappa")),
37  ecut_(ps.getParameter<double>("ecut")),
38  dependSensor_(ps.getParameter<bool>("dependSensor")),
39  dEdXweights_(ps.getParameter<std::vector<double>>("dEdXweights")),
40  thicknessCorrection_(ps.getParameter<std::vector<double>>("thicknessCorrection")),
41  sciThicknessCorrection_(ps.getParameter<double>("sciThicknessCorrection")),
42  deltasi_index_regemfac_(ps.getParameter<int>("deltasi_index_regemfac")),
43  maxNumberOfThickIndices_(ps.getParameter<unsigned>("maxNumberOfThickIndices")),
44  fcPerMip_(ps.getParameter<std::vector<double>>("fcPerMip")),
45  fcPerEle_(ps.getParameter<double>("fcPerEle")),
46  nonAgedNoises_(ps.getParameter<std::vector<double>>("noises")),
47  noiseMip_(ps.getParameter<edm::ParameterSet>("noiseMip").getParameter<double>("noise_MIP")),
48  thresholdW0_(ps.getParameter<std::vector<double>>("thresholdW0")),
49  positionDeltaRho2_(ps.getParameter<double>("positionDeltaRho2")),
50  use2x2_(ps.getParameter<bool>("use2x2")),
52 
53  ~HGCalCLUEAlgoT() override {}
54 
55  void getEventSetupPerAlgorithm(const edm::EventSetup& es) override;
56 
57  void populate(const HGCRecHitCollection& hits) override;
58 
59  // this is the method that will start the clusterisation (it is possible to invoke this method
60  // more than once - but make sure it is with different hit collections (or else use reset)
61 
62  void makeClusters() override;
63 
64  // this is the method to get the cluster collection out
65  std::vector<reco::BasicCluster> getClusters(bool) override;
66 
67  void reset() override {
68  clusters_v_.clear();
69  clusters_v_.shrink_to_fit();
70  for (auto& cl : numberOfClustersPerLayer_) {
71  cl = 0;
72  }
73 
74  for (auto& cells : cells_) {
75  cells.clear();
76  cells.shrink_to_fit();
77  }
78  }
79 
80  void computeThreshold();
81 
83  iDesc.add<std::vector<double>>("thresholdW0", {2.9, 2.9, 2.9});
84  iDesc.add<double>("positionDeltaRho2", 1.69);
85  iDesc.add<std::vector<double>>("deltac",
86  {
87  1.3,
88  1.3,
89  1.3,
90  0.0315, // for scintillator
91  });
92  iDesc.add<bool>("dependSensor", true);
93  iDesc.add<double>("ecut", 3.0);
94  iDesc.add<double>("kappa", 9.0);
95  iDesc.addUntracked<unsigned int>("verbosity", 3);
96  iDesc.add<std::vector<double>>("dEdXweights", {});
97  iDesc.add<std::vector<double>>("thicknessCorrection", {});
98  iDesc.add<double>("sciThicknessCorrection", 0.9);
99  iDesc.add<int>("deltasi_index_regemfac", 3);
100  iDesc.add<unsigned>("maxNumberOfThickIndices", 6);
101  iDesc.add<std::vector<double>>("fcPerMip", {});
102  iDesc.add<double>("fcPerEle", 0.0);
103  iDesc.add<std::vector<double>>("noises", {});
104  edm::ParameterSetDescription descNestedNoiseMIP;
105  descNestedNoiseMIP.add<bool>("scaleByDose", false);
106  descNestedNoiseMIP.add<unsigned int>("scaleByDoseAlgo", 0);
107  descNestedNoiseMIP.add<double>("scaleByDoseFactor", 1.);
108  descNestedNoiseMIP.add<std::string>("doseMap", "");
109  descNestedNoiseMIP.add<std::string>("sipmMap", "");
110  descNestedNoiseMIP.add<double>("referenceIdark", -1);
111  descNestedNoiseMIP.add<double>("referenceXtalk", -1);
112  descNestedNoiseMIP.add<double>("noise_MIP", 1. / 100.);
113  iDesc.add<edm::ParameterSetDescription>("noiseMip", descNestedNoiseMIP);
114  iDesc.add<bool>("use2x2", true); // use 2x2 or 3x3 scenario for scint density calculation
115  }
116 
119 
120 private:
121  // The two parameters used to identify clusters
122  std::vector<double> vecDeltas_;
123  double kappa_;
124 
125  // The hit energy cutoff
126  double ecut_;
127 
128  // various parameters used for calculating the noise levels for a given sensor (and whether to use
129  // them)
131  std::vector<double> dEdXweights_;
132  std::vector<double> thicknessCorrection_;
136  std::vector<double> fcPerMip_;
137  double fcPerEle_;
138  std::vector<double> nonAgedNoises_;
139  double noiseMip_;
140  std::vector<std::vector<double>> thresholds_;
141  std::vector<std::vector<double>> v_sigmaNoise_;
142  std::vector<double> thresholdW0_;
144 
145  bool use2x2_;
146 
147  // initialization bool
149 
150  float outlierDeltaFactor_ = 2.f;
151 
152  struct CellsOnLayer {
153  std::vector<DetId> detid;
154  std::vector<float> dim1;
155  std::vector<float> dim2;
156 
157  std::vector<float> weight;
158  std::vector<float> rho;
159 
160  std::vector<float> delta;
161  std::vector<int> nearestHigher;
162  std::vector<int> clusterIndex;
163  std::vector<float> sigmaNoise;
164  std::vector<std::vector<int>> followers;
165  std::vector<bool> isSeed;
167 
168  void clear() {
169  detid.clear();
170  dim1.clear();
171  dim2.clear();
172  weight.clear();
173  rho.clear();
174  delta.clear();
175  nearestHigher.clear();
176  clusterIndex.clear();
177  sigmaNoise.clear();
178  followers.clear();
179  isSeed.clear();
180  }
181 
182  void shrink_to_fit() {
183  detid.shrink_to_fit();
184  dim1.shrink_to_fit();
185  dim2.shrink_to_fit();
186  weight.shrink_to_fit();
187  rho.shrink_to_fit();
188  delta.shrink_to_fit();
189  nearestHigher.shrink_to_fit();
190  clusterIndex.shrink_to_fit();
191  sigmaNoise.shrink_to_fit();
192  followers.shrink_to_fit();
193  isSeed.shrink_to_fit();
194  }
195  };
196 
197  std::vector<CellsOnLayer> cells_;
198 
199  std::vector<int> numberOfClustersPerLayer_;
200 
201  inline float distance(const TILE& lt, int cell1, int cell2, int layerId) const { // 2-d distance on the layer (x-y)
202  return std::sqrt(lt.distance2(cells_[layerId].dim1[cell1],
203  cells_[layerId].dim2[cell1],
204  cells_[layerId].dim1[cell2],
205  cells_[layerId].dim2[cell2]));
206  }
207 
208  void prepareDataStructures(const unsigned int layerId);
209  void calculateLocalDensity(const TILE& lt, const unsigned int layerId,
210  float delta); // return max density
211  void calculateLocalDensity(const TILE& lt, const unsigned int layerId, float delta, HGCalSiliconStrategy strategy);
212  void calculateLocalDensity(const TILE& lt,
213  const unsigned int layerId,
214  float delta,
216  void calculateDistanceToHigher(const TILE& lt, const unsigned int layerId, float delta);
217  int findAndAssignClusters(const unsigned int layerId, float delta);
218 };
219 
220 // explicit template instantiation
224 
228 
229 #endif
void computeThreshold()
std::vector< double > nonAgedNoises_
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
~HGCalCLUEAlgoT() override
Definition: HGCalCLUEAlgo.h:53
HGCalCLUEAlgoT(const edm::ParameterSet &ps)
Definition: HGCalCLUEAlgo.h:31
std::vector< double > vecDeltas_
std::vector< reco::BasicCluster > clusters_v_
Definition: weight.py:1
std::vector< int > clusterIndex
void calculateDistanceToHigher(const TILE &lt, const unsigned int layerId, float delta)
int deltasi_index_regemfac_
void populate(const HGCRecHitCollection &hits) override
float outlierDeltaFactor_
double positionDeltaRho2_
double sciThicknessCorrection_
std::vector< std::vector< int > > followers
std::vector< int > nearestHigher
T sqrt(T t)
Definition: SSEVec.h:23
const double infinity
std::vector< double > thicknessCorrection_
void makeClusters() override
std::vector< bool > isSeed
ParameterDescriptionBase * add(U const &iLabel, T const &value)
std::vector< double > fcPerMip_
std::vector< float > weight
float distance(const TILE &lt, int cell1, int cell2, int layerId) const
std::vector< double > dEdXweights_
std::vector< std::vector< double > > v_sigmaNoise_
void getEventSetupPerAlgorithm(const edm::EventSetup &es) override
std::vector< int > numberOfClustersPerLayer_
void calculateLocalDensity(const TILE &lt, const unsigned int layerId, float delta)
static void fillPSetDescription(edm::ParameterSetDescription &iDesc)
Definition: HGCalCLUEAlgo.h:82
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
unsigned maxNumberOfThickIndices_
std::vector< double > thresholdW0_
std::vector< CellsOnLayer > cells_
math::XYZPoint Point
point in the space
void prepareDataStructures(const unsigned int layerId)
std::vector< float > delta
std::vector< DetId > detid
fixed size matrix
HLT enums.
std::vector< float > dim1
std::vector< float > rho
std::vector< float > sigmaNoise
std::vector< std::vector< double > > thresholds_
strategy
Definition: nnet_common.h:18
void reset() override
Definition: HGCalCLUEAlgo.h:67
int findAndAssignClusters(const unsigned int layerId, float delta)
std::vector< reco::BasicCluster > getClusters(bool) override
std::vector< float > dim2