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 
19 
21 
22 // C/C++ headers
23 #include <set>
24 #include <string>
25 #include <vector>
26 
28 
29 template <typename TILE>
31 public:
34  (HGCalClusteringAlgoBase::VerbosityLevel)ps.getUntrackedParameter<unsigned int>("verbosity", 3),
35  reco::CaloCluster::undefined),
36  thresholdW0_(ps.getParameter<std::vector<double>>("thresholdW0")),
37  positionDeltaRho2_(ps.getParameter<double>("positionDeltaRho2")),
38  vecDeltas_(ps.getParameter<std::vector<double>>("deltac")),
39  kappa_(ps.getParameter<double>("kappa")),
40  ecut_(ps.getParameter<double>("ecut")),
41  dependSensor_(ps.getParameter<bool>("dependSensor")),
42  dEdXweights_(ps.getParameter<std::vector<double>>("dEdXweights")),
43  thicknessCorrection_(ps.getParameter<std::vector<double>>("thicknessCorrection")),
44  sciThicknessCorrection_(ps.getParameter<double>("sciThicknessCorrection")),
45  deltasi_index_regemfac_(ps.getParameter<int>("deltasi_index_regemfac")),
46  maxNumberOfThickIndices_(ps.getParameter<unsigned>("maxNumberOfThickIndices")),
47  fcPerMip_(ps.getParameter<std::vector<double>>("fcPerMip")),
48  fcPerEle_(ps.getParameter<double>("fcPerEle")),
49  nonAgedNoises_(ps.getParameter<std::vector<double>>("noises")),
50  noiseMip_(ps.getParameter<edm::ParameterSet>("noiseMip").getParameter<double>("noise_MIP")),
51  use2x2_(ps.getParameter<bool>("use2x2")),
53 
54  ~HGCalCLUEAlgoT() override {}
55 
56  void getEventSetupPerAlgorithm(const edm::EventSetup& es) override;
57 
58  void populate(const HGCRecHitCollection& hits) override;
59 
60  // this is the method that will start the clusterisation (it is possible to invoke this method
61  // more than once - but make sure it is with different hit collections (or else use reset)
62 
63  void makeClusters() override;
64 
65  // this is the method to get the cluster collection out
66  std::vector<reco::BasicCluster> getClusters(bool) override;
67 
68  void reset() override {
69  clusters_v_.clear();
70  clusters_v_.shrink_to_fit();
71  for (auto& cl : numberOfClustersPerLayer_) {
72  cl = 0;
73  }
74 
75  for (auto& cells : cells_) {
76  cells.clear();
77  cells.shrink_to_fit();
78  }
79  density_.clear();
80  }
81 
82  Density getDensity() override;
83 
84  void computeThreshold();
85 
87  iDesc.add<std::vector<double>>("thresholdW0", {2.9, 2.9, 2.9});
88  iDesc.add<double>("positionDeltaRho2", 1.69);
89  iDesc.add<std::vector<double>>("deltac",
90  {
91  1.3,
92  1.3,
93  5.0,
94  0.0315, // for scintillator
95  });
96  iDesc.add<bool>("dependSensor", true);
97  iDesc.add<double>("ecut", 3.0);
98  iDesc.add<double>("kappa", 9.0);
99  iDesc.addUntracked<unsigned int>("verbosity", 3);
100  iDesc.add<std::vector<double>>("dEdXweights", {});
101  iDesc.add<std::vector<double>>("thicknessCorrection", {});
102  iDesc.add<double>("sciThicknessCorrection", 0.9);
103  iDesc.add<int>("deltasi_index_regemfac", 3);
104  iDesc.add<unsigned>("maxNumberOfThickIndices", 6);
105  iDesc.add<std::vector<double>>("fcPerMip", {});
106  iDesc.add<double>("fcPerEle", 0.0);
107  iDesc.add<std::vector<double>>("noises", {});
108  edm::ParameterSetDescription descNestedNoiseMIP;
109  descNestedNoiseMIP.add<bool>("scaleByDose", false);
110  descNestedNoiseMIP.add<unsigned int>("scaleByDoseAlgo", 0);
111  descNestedNoiseMIP.add<double>("scaleByDoseFactor", 1.);
112  descNestedNoiseMIP.add<std::string>("doseMap", "");
113  descNestedNoiseMIP.add<double>("noise_MIP", 1. / 100.);
114  iDesc.add<edm::ParameterSetDescription>("noiseMip", descNestedNoiseMIP);
115  iDesc.add<bool>("use2x2", true); // use 2x2 or 3x3 scenario for scint density calculation
116  }
117 
120 
121 private:
122  // To compute the cluster position
123  std::vector<double> thresholdW0_;
124  const double positionDeltaRho2_;
125 
126  // The two parameters used to identify clusters
127  std::vector<double> vecDeltas_;
128  double kappa_;
129 
130  // The hit energy cutoff
131  double ecut_;
132 
133  // For keeping the density per hit
135 
136  // various parameters used for calculating the noise levels for a given sensor (and whether to use
137  // them)
139  std::vector<double> dEdXweights_;
140  std::vector<double> thicknessCorrection_;
144  std::vector<double> fcPerMip_;
145  double fcPerEle_;
146  std::vector<double> nonAgedNoises_;
147  double noiseMip_;
148  std::vector<std::vector<double>> thresholds_;
149  std::vector<std::vector<double>> v_sigmaNoise_;
150 
151  bool use2x2_;
152 
153  // initialization bool
155 
156  float outlierDeltaFactor_ = 2.f;
157 
158  struct CellsOnLayer {
159  std::vector<DetId> detid;
160  std::vector<bool> isSi;
161  std::vector<float> x;
162  std::vector<float> y;
163  std::vector<float> eta;
164  std::vector<float> phi;
165 
166  std::vector<float> weight;
167  std::vector<float> rho;
168 
169  std::vector<float> delta;
170  std::vector<int> nearestHigher;
171  std::vector<int> clusterIndex;
172  std::vector<float> sigmaNoise;
173  std::vector<std::vector<int>> followers;
174  std::vector<bool> isSeed;
175 
176  void clear() {
177  detid.clear();
178  isSi.clear();
179  x.clear();
180  y.clear();
181  eta.clear();
182  phi.clear();
183  weight.clear();
184  rho.clear();
185  delta.clear();
186  nearestHigher.clear();
187  clusterIndex.clear();
188  sigmaNoise.clear();
189  followers.clear();
190  isSeed.clear();
191  }
192 
193  void shrink_to_fit() {
194  detid.shrink_to_fit();
195  isSi.shrink_to_fit();
196  x.shrink_to_fit();
197  y.shrink_to_fit();
198  eta.shrink_to_fit();
199  phi.shrink_to_fit();
200  weight.shrink_to_fit();
201  rho.shrink_to_fit();
202  delta.shrink_to_fit();
203  nearestHigher.shrink_to_fit();
204  clusterIndex.shrink_to_fit();
205  sigmaNoise.shrink_to_fit();
206  followers.shrink_to_fit();
207  isSeed.shrink_to_fit();
208  }
209  };
210 
211  std::vector<CellsOnLayer> cells_;
212 
213  std::vector<int> numberOfClustersPerLayer_;
214 
215  inline float distance2(int cell1, int cell2, int layerId, bool isEtaPhi) const { // distance squared
216  if (isEtaPhi) {
217  const float dphi = reco::deltaPhi(cells_[layerId].phi[cell1], cells_[layerId].phi[cell2]);
218  const float deta = cells_[layerId].eta[cell1] - cells_[layerId].eta[cell2];
219  return (deta * deta + dphi * dphi);
220  } else {
221  const float dx = cells_[layerId].x[cell1] - cells_[layerId].x[cell2];
222  const float dy = cells_[layerId].y[cell1] - cells_[layerId].y[cell2];
223  return (dx * dx + dy * dy);
224  }
225  }
226 
227  inline float distance(int cell1, int cell2, int layerId, bool isEtaPhi) const { // 2-d distance on the layer (x-y)
228  return std::sqrt(distance2(cell1, cell2, layerId, isEtaPhi));
229  }
230 
231  void prepareDataStructures(const unsigned int layerId);
232  void calculateLocalDensity(const TILE& lt,
233  const unsigned int layerId,
234  float delta_c,
235  float delta_r); // return max density
236  void calculateDistanceToHigher(const TILE& lt, const unsigned int layerId, float delta_c, float delta_r);
237  int findAndAssignClusters(const unsigned int layerId, float delta_c, float delta_r);
238  math::XYZPoint calculatePosition(const std::vector<int>& v, const unsigned int layerId) const;
239  void setDensity(const unsigned int layerId);
240 };
241 
242 // explicit template instantiation
243 extern template class HGCalCLUEAlgoT<HGCalLayerTiles>;
244 extern template class HGCalCLUEAlgoT<HFNoseLayerTiles>;
245 
248 
249 #endif
HGCalCLUEAlgoT::use2x2_
bool use2x2_
Definition: HGCalCLUEAlgo.h:151
ConfigurationDescriptions.h
HGCalCLUEAlgoT::vecDeltas_
std::vector< double > vecDeltas_
Definition: HGCalCLUEAlgo.h:127
electrons_cff.bool
bool
Definition: electrons_cff.py:393
edm::ParameterSetDescription::add
ParameterDescriptionBase * add(U const &iLabel, T const &value)
Definition: ParameterSetDescription.h:95
HGCalCLUEAlgoT::CellsOnLayer
Definition: HGCalCLUEAlgo.h:158
funct::false
false
Definition: Factorize.h:29
HGCalClusteringAlgoBase.h
HGCalCLUEAlgoT::findAndAssignClusters
int findAndAssignClusters(const unsigned int layerId, float delta_c, float delta_r)
Definition: HGCalCLUEAlgo.cc:465
hfClusterShapes_cfi.hits
hits
Definition: hfClusterShapes_cfi.py:5
HGCalCLUEAlgoT::calculateLocalDensity
void calculateLocalDensity(const TILE &lt, const unsigned int layerId, float delta_c, float delta_r)
Definition: HGCalCLUEAlgo.cc:247
HGCalCLUEAlgoT::dependSensor_
bool dependSensor_
Definition: HGCalCLUEAlgo.h:138
reco::deltaPhi
constexpr double deltaPhi(double phi1, double phi2)
Definition: deltaPhi.h:26
deltaPhi.h
BasicCluster.h
edm
HLT enums.
Definition: AlignableModifier.h:19
hitfit::delta_r
double delta_r(const Fourvec &a, const Fourvec &b)
Find the distance between two four-vectors in the two-dimensional space .
Definition: fourvec.cc:238
HGCalCLUEAlgoT::fcPerEle_
double fcPerEle_
Definition: HGCalCLUEAlgo.h:145
HGCalCLUEAlgoT::outlierDeltaFactor_
float outlierDeltaFactor_
Definition: HGCalCLUEAlgo.h:156
HGCalCLUEAlgoT::thresholds_
std::vector< std::vector< double > > thresholds_
Definition: HGCalCLUEAlgo.h:148
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
HGCalCLUEAlgoT::noiseMip_
double noiseMip_
Definition: HGCalCLUEAlgo.h:147
HGCalCLUEAlgoT
Definition: HGCalCLUEAlgo.h:30
HGCalCLUEAlgoT::getEventSetupPerAlgorithm
void getEventSetupPerAlgorithm(const edm::EventSetup &es) override
Definition: HGCalCLUEAlgo.cc:19
HGCalCLUEAlgoT::thicknessCorrection_
std::vector< double > thicknessCorrection_
Definition: HGCalCLUEAlgo.h:140
edm::SortedCollection
Definition: SortedCollection.h:49
HGCalCLUEAlgoT::thresholdW0_
std::vector< double > thresholdW0_
Definition: HGCalCLUEAlgo.h:123
HGCalLayerTiles.h
HGCalCLUEAlgoT::CellsOnLayer::clear
void clear()
Definition: HGCalCLUEAlgo.h:176
HGCalCLUEAlgoT::CellsOnLayer::x
std::vector< float > x
Definition: HGCalCLUEAlgo.h:161
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:45
findQualityFiles.v
v
Definition: findQualityFiles.py:179
HGCalCLUEAlgoT::CellsOnLayer::shrink_to_fit
void shrink_to_fit()
Definition: HGCalCLUEAlgo.h:193
HGCalCLUEAlgoT::positionDeltaRho2_
const double positionDeltaRho2_
Definition: HGCalCLUEAlgo.h:124
HGCalCLUEAlgoT::CellsOnLayer::isSi
std::vector< bool > isSi
Definition: HGCalCLUEAlgo.h:160
GetRecoTauVFromDQM_MC_cff.cl
cl
Definition: GetRecoTauVFromDQM_MC_cff.py:38
HGCalCLUEAlgoT::Point
math::XYZPoint Point
point in the space
Definition: HGCalCLUEAlgo.h:119
HGCalCLUEAlgoT::makeClusters
void makeClusters() override
Definition: HGCalCLUEAlgo.cc:99
HGCalCLUEAlgoT::cells_
std::vector< CellsOnLayer > cells_
Definition: HGCalCLUEAlgo.h:211
HGCalCLUEAlgoT::v_sigmaNoise_
std::vector< std::vector< double > > v_sigmaNoise_
Definition: HGCalCLUEAlgo.h:149
HGCalCLUEAlgoT::fillPSetDescription
static void fillPSetDescription(edm::ParameterSetDescription &iDesc)
Definition: HGCalCLUEAlgo.h:86
HGCalClusteringAlgoBase::clusters_v_
std::vector< reco::BasicCluster > clusters_v_
Definition: HGCalClusteringAlgoBase.h:92
HGCalTopology.h
DDAxes::undefined
HGCalCLUEAlgoT::getClusters
std::vector< reco::BasicCluster > getClusters(bool) override
Definition: HGCalCLUEAlgo.cc:131
HGCalCLUEAlgoT::populate
void populate(const HGCRecHitCollection &hits) override
Definition: HGCalCLUEAlgo.cc:27
HGCalCLUEAlgoT::kappa_
double kappa_
Definition: HGCalCLUEAlgo.h:128
hgcal_clustering::Density
std::map< DetId, float > Density
Definition: HGCalClusteringAlgoBase.h:43
HGCalCLUEAlgoT::CellsOnLayer::y
std::vector< float > y
Definition: HGCalCLUEAlgo.h:162
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
HGCalCLUEAlgoT::CellsOnLayer::isSeed
std::vector< bool > isSeed
Definition: HGCalCLUEAlgo.h:174
HGCalCLUEAlgoT::CellsOnLayer::phi
std::vector< float > phi
Definition: HGCalCLUEAlgo.h:164
HGCalCLUEAlgoT::ecut_
double ecut_
Definition: HGCalCLUEAlgo.h:131
HGCalCLUEAlgoT::prepareDataStructures
void prepareDataStructures(const unsigned int layerId)
Definition: HGCalCLUEAlgo.cc:79
HGCalCLUEAlgoT::maxNumberOfThickIndices_
unsigned maxNumberOfThickIndices_
Definition: HGCalCLUEAlgo.h:143
HGCalCLUEAlgoT::computeThreshold
void computeThreshold()
Definition: HGCalCLUEAlgo.cc:513
CaloGeometryRecord.h
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
HGCalCLUEAlgoT::sciThicknessCorrection_
double sciThicknessCorrection_
Definition: HGCalCLUEAlgo.h:141
HGCalCLUEAlgoT::deltasi_index_regemfac_
int deltasi_index_regemfac_
Definition: HGCalCLUEAlgo.h:142
HGCalCLUEAlgoT::getDensity
Density getDensity() override
Definition: HGCalCLUEAlgo.cc:564
edm::ParameterSetDescription::addUntracked
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
Definition: ParameterSetDescription.h:100
HGCRecHitCollections.h
HGCalGeometry.h
edm::ParameterSet
Definition: ParameterSet.h:47
math::XYZPoint
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
HGCalCLUEAlgoT::fcPerMip_
std::vector< double > fcPerMip_
Definition: HGCalCLUEAlgo.h:144
ParameterSet
Definition: Functions.h:16
HGCalCLUEAlgoT::CellsOnLayer::detid
std::vector< DetId > detid
Definition: HGCalCLUEAlgo.h:159
HGCalCLUEAlgoT::HGCalCLUEAlgoT
HGCalCLUEAlgoT(const edm::ParameterSet &ps)
Definition: HGCalCLUEAlgo.h:32
HGCalCLUEAlgoT::CellsOnLayer::followers
std::vector< std::vector< int > > followers
Definition: HGCalCLUEAlgo.h:173
HGCalCLUEAlgoT::CellsOnLayer::eta
std::vector< float > eta
Definition: HGCalCLUEAlgo.h:163
createfilelist.int
int
Definition: createfilelist.py:10
trackerHitRTTI::vector
Definition: trackerHitRTTI.h:21
HGCalCLUEAlgoT::CellsOnLayer::nearestHigher
std::vector< int > nearestHigher
Definition: HGCalCLUEAlgo.h:170
hgcalTopologyTester_cfi.cell2
cell2
Definition: hgcalTopologyTester_cfi.py:12
PVValHelper::dy
Definition: PVValidationHelpers.h:49
HGCalCLUEAlgoT::setDensity
void setDensity(const unsigned int layerId)
Definition: HGCalCLUEAlgo.cc:556
edm::EventSetup
Definition: EventSetup.h:57
HGCalCLUEAlgoT::density_
Density density_
Definition: HGCalCLUEAlgo.h:134
HGCalCLUEAlgoT::distance
float distance(int cell1, int cell2, int layerId, bool isEtaPhi) const
Definition: HGCalCLUEAlgo.h:227
hgcalTopologyTester_cfi.cell1
cell1
Definition: hgcalTopologyTester_cfi.py:11
HGCalCLUEAlgoT::CellsOnLayer::clusterIndex
std::vector< int > clusterIndex
Definition: HGCalCLUEAlgo.h:171
DDAxes::phi
std
Definition: JetResolutionObject.h:76
HGCalCLUEAlgoT::calculatePosition
math::XYZPoint calculatePosition(const std::vector< int > &v, const unsigned int layerId) const
Definition: HGCalCLUEAlgo.cc:187
HGCalCLUEAlgoT::nonAgedNoises_
std::vector< double > nonAgedNoises_
Definition: HGCalCLUEAlgo.h:146
HGCalCLUEAlgoT::distance2
float distance2(int cell1, int cell2, int layerId, bool isEtaPhi) const
Definition: HGCalCLUEAlgo.h:215
DetId.h
postprocess-scan-build.cells
cells
Definition: postprocess-scan-build.py:13
Point3D.h
HGCalCLUEAlgoT::calculateDistanceToHigher
void calculateDistanceToHigher(const TILE &lt, const unsigned int layerId, float delta_c, float delta_r)
Definition: HGCalCLUEAlgo.cc:346
HGCalCLUEAlgoT::reset
void reset() override
Definition: HGCalCLUEAlgo.h:68
HGCalCLUEAlgoT::numberOfClustersPerLayer_
std::vector< int > numberOfClustersPerLayer_
Definition: HGCalCLUEAlgo.h:213
HGCalCLUEAlgoT::initialized_
bool initialized_
Definition: HGCalCLUEAlgo.h:154
HGCalCLUEAlgoT::CellsOnLayer::delta
std::vector< float > delta
Definition: HGCalCLUEAlgo.h:169
HGCalClusteringAlgoBase::VerbosityLevel
VerbosityLevel
Definition: HGCalClusteringAlgoBase.h:49
HGCalCLUEAlgoT::~HGCalCLUEAlgoT
~HGCalCLUEAlgoT() override
Definition: HGCalCLUEAlgo.h:54
HGCalCLUEAlgoT::dEdXweights_
std::vector< double > dEdXweights_
Definition: HGCalCLUEAlgo.h:139
HGCalClusteringAlgoBase
Definition: HGCalClusteringAlgoBase.h:47
PVValHelper::dx
Definition: PVValidationHelpers.h:48
weight
Definition: weight.py:1
RecHitTools.h
HGCalCLUEAlgoT::CellsOnLayer::rho
std::vector< float > rho
Definition: HGCalCLUEAlgo.h:167
Density
hgcal_clustering::Density Density
Definition: HGCalImagingAlgo.h:29
HGCalCLUEAlgoT::CellsOnLayer::weight
std::vector< float > weight
Definition: HGCalCLUEAlgo.h:166
HGCalCLUEAlgoT::CellsOnLayer::sigmaNoise
std::vector< float > sigmaNoise
Definition: HGCalCLUEAlgo.h:172