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<std::string>("doseMap", "");
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  // To compute the cluster position
122  std::vector<double> thresholdW0_;
123  const double positionDeltaRho2_;
124 
125  // The two parameters used to identify clusters
126  std::vector<double> vecDeltas_;
127  double kappa_;
128 
129  // The hit energy cutoff
130  double ecut_;
131 
132  // For keeping the density per hit
134 
135  // various parameters used for calculating the noise levels for a given sensor (and whether to use
136  // them)
138  std::vector<double> dEdXweights_;
139  std::vector<double> thicknessCorrection_;
143  std::vector<double> fcPerMip_;
144  double fcPerEle_;
145  std::vector<double> nonAgedNoises_;
146  double noiseMip_;
147  std::vector<std::vector<double>> thresholds_;
148  std::vector<std::vector<double>> v_sigmaNoise_;
149 
150  bool use2x2_;
151 
152  // initialization bool
154 
155  float outlierDeltaFactor_ = 2.f;
156 
157  struct CellsOnLayer {
158  std::vector<DetId> detid;
159  std::vector<bool> isSi;
160  std::vector<float> x;
161  std::vector<float> y;
162  std::vector<float> eta;
163  std::vector<float> phi;
164 
165  std::vector<float> weight;
166  std::vector<float> rho;
167 
168  std::vector<float> delta;
169  std::vector<int> nearestHigher;
170  std::vector<int> clusterIndex;
171  std::vector<float> sigmaNoise;
172  std::vector<std::vector<int>> followers;
173  std::vector<bool> isSeed;
174 
175  void clear() {
176  detid.clear();
177  isSi.clear();
178  x.clear();
179  y.clear();
180  eta.clear();
181  phi.clear();
182  weight.clear();
183  rho.clear();
184  delta.clear();
185  nearestHigher.clear();
186  clusterIndex.clear();
187  sigmaNoise.clear();
188  followers.clear();
189  isSeed.clear();
190  }
191 
192  void shrink_to_fit() {
193  detid.shrink_to_fit();
194  isSi.shrink_to_fit();
195  x.shrink_to_fit();
196  y.shrink_to_fit();
197  eta.shrink_to_fit();
198  phi.shrink_to_fit();
199  weight.shrink_to_fit();
200  rho.shrink_to_fit();
201  delta.shrink_to_fit();
202  nearestHigher.shrink_to_fit();
203  clusterIndex.shrink_to_fit();
204  sigmaNoise.shrink_to_fit();
205  followers.shrink_to_fit();
206  isSeed.shrink_to_fit();
207  }
208  };
209 
210  std::vector<CellsOnLayer> cells_;
211 
212  std::vector<int> numberOfClustersPerLayer_;
213 
214  inline float distance2(int cell1, int cell2, int layerId, bool isEtaPhi) const { // distance squared
215  if (isEtaPhi) {
216  const float dphi = reco::deltaPhi(cells_[layerId].phi[cell1], cells_[layerId].phi[cell2]);
217  const float deta = cells_[layerId].eta[cell1] - cells_[layerId].eta[cell2];
218  return (deta * deta + dphi * dphi);
219  } else {
220  const float dx = cells_[layerId].x[cell1] - cells_[layerId].x[cell2];
221  const float dy = cells_[layerId].y[cell1] - cells_[layerId].y[cell2];
222  return (dx * dx + dy * dy);
223  }
224  }
225 
226  inline float distance(int cell1, int cell2, int layerId, bool isEtaPhi) const { // 2-d distance on the layer (x-y)
227  return std::sqrt(distance2(cell1, cell2, layerId, isEtaPhi));
228  }
229 
230  void prepareDataStructures(const unsigned int layerId);
231  void calculateLocalDensity(const TILE& lt,
232  const unsigned int layerId,
233  float delta_c,
234  float delta_r); // return max density
235  void calculateDistanceToHigher(const TILE& lt, const unsigned int layerId, float delta_c, float delta_r);
236  int findAndAssignClusters(const unsigned int layerId, float delta_c, float delta_r);
237  math::XYZPoint calculatePosition(const std::vector<int>& v, const unsigned int layerId) const;
238  void setDensity(const unsigned int layerId);
239 };
240 
241 // explicit template instantiation
242 extern template class HGCalCLUEAlgoT<HGCalLayerTiles>;
243 extern template class HGCalCLUEAlgoT<HFNoseLayerTiles>;
244 
247 
248 #endif
HGCalCLUEAlgoT::use2x2_
bool use2x2_
Definition: HGCalCLUEAlgo.h:150
ConfigurationDescriptions.h
HGCalCLUEAlgoT::vecDeltas_
std::vector< double > vecDeltas_
Definition: HGCalCLUEAlgo.h:126
electrons_cff.bool
bool
Definition: electrons_cff.py:372
edm::ParameterSetDescription::add
ParameterDescriptionBase * add(U const &iLabel, T const &value)
Definition: ParameterSetDescription.h:95
HGCalCLUEAlgoT::CellsOnLayer
Definition: HGCalCLUEAlgo.h:157
funct::false
false
Definition: Factorize.h:34
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:137
reco::deltaPhi
constexpr double deltaPhi(double phi1, double phi2)
Definition: deltaPhi.h:26
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:144
HGCalCLUEAlgoT::outlierDeltaFactor_
float outlierDeltaFactor_
Definition: HGCalCLUEAlgo.h:155
HGCalCLUEAlgoT::thresholds_
std::vector< std::vector< double > > thresholds_
Definition: HGCalCLUEAlgo.h:147
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
HGCalCLUEAlgoT::noiseMip_
double noiseMip_
Definition: HGCalCLUEAlgo.h:146
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:139
edm::SortedCollection
Definition: SortedCollection.h:49
HGCalCLUEAlgoT::thresholdW0_
std::vector< double > thresholdW0_
Definition: HGCalCLUEAlgo.h:122
HGCalLayerTiles.h
HGCalCLUEAlgoT::CellsOnLayer::clear
void clear()
Definition: HGCalCLUEAlgo.h:175
HGCalCLUEAlgoT::CellsOnLayer::x
std::vector< float > x
Definition: HGCalCLUEAlgo.h:160
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:192
HGCalCLUEAlgoT::positionDeltaRho2_
const double positionDeltaRho2_
Definition: HGCalCLUEAlgo.h:123
HGCalCLUEAlgoT::CellsOnLayer::isSi
std::vector< bool > isSi
Definition: HGCalCLUEAlgo.h:159
GetRecoTauVFromDQM_MC_cff.cl
cl
Definition: GetRecoTauVFromDQM_MC_cff.py:38
HGCalCLUEAlgoT::Point
math::XYZPoint Point
point in the space
Definition: HGCalCLUEAlgo.h:118
HGCalCLUEAlgoT::makeClusters
void makeClusters() override
Definition: HGCalCLUEAlgo.cc:99
HGCalCLUEAlgoT::cells_
std::vector< CellsOnLayer > cells_
Definition: HGCalCLUEAlgo.h:210
HGCalCLUEAlgoT::v_sigmaNoise_
std::vector< std::vector< double > > v_sigmaNoise_
Definition: HGCalCLUEAlgo.h:148
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:127
hgcal_clustering::Density
std::map< DetId, float > Density
Definition: HGCalClusteringAlgoBase.h:43
HGCalCLUEAlgoT::CellsOnLayer::y
std::vector< float > y
Definition: HGCalCLUEAlgo.h:161
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
HGCalCLUEAlgoT::CellsOnLayer::isSeed
std::vector< bool > isSeed
Definition: HGCalCLUEAlgo.h:173
HGCalCLUEAlgoT::CellsOnLayer::phi
std::vector< float > phi
Definition: HGCalCLUEAlgo.h:163
HGCalCLUEAlgoT::ecut_
double ecut_
Definition: HGCalCLUEAlgo.h:130
HGCalCLUEAlgoT::prepareDataStructures
void prepareDataStructures(const unsigned int layerId)
Definition: HGCalCLUEAlgo.cc:79
HGCalCLUEAlgoT::maxNumberOfThickIndices_
unsigned maxNumberOfThickIndices_
Definition: HGCalCLUEAlgo.h:142
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:140
HGCalCLUEAlgoT::deltasi_index_regemfac_
int deltasi_index_regemfac_
Definition: HGCalCLUEAlgo.h:141
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:36
math::XYZPoint
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
HGCalCLUEAlgoT::fcPerMip_
std::vector< double > fcPerMip_
Definition: HGCalCLUEAlgo.h:143
ParameterSet
Definition: Functions.h:16
HGCalCLUEAlgoT::CellsOnLayer::detid
std::vector< DetId > detid
Definition: HGCalCLUEAlgo.h:158
HGCalCLUEAlgoT::HGCalCLUEAlgoT
HGCalCLUEAlgoT(const edm::ParameterSet &ps)
Definition: HGCalCLUEAlgo.h:32
HGCalCLUEAlgoT::CellsOnLayer::followers
std::vector< std::vector< int > > followers
Definition: HGCalCLUEAlgo.h:172
HGCalCLUEAlgoT::CellsOnLayer::eta
std::vector< float > eta
Definition: HGCalCLUEAlgo.h:162
createfilelist.int
int
Definition: createfilelist.py:10
HGCalCLUEAlgoT::CellsOnLayer::nearestHigher
std::vector< int > nearestHigher
Definition: HGCalCLUEAlgo.h:169
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:133
HGCalCLUEAlgoT::distance
float distance(int cell1, int cell2, int layerId, bool isEtaPhi) const
Definition: HGCalCLUEAlgo.h:226
hgcalTopologyTester_cfi.cell1
cell1
Definition: hgcalTopologyTester_cfi.py:11
HGCalCLUEAlgoT::CellsOnLayer::clusterIndex
std::vector< int > clusterIndex
Definition: HGCalCLUEAlgo.h:170
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:145
HGCalCLUEAlgoT::distance2
float distance2(int cell1, int cell2, int layerId, bool isEtaPhi) const
Definition: HGCalCLUEAlgo.h:214
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:212
HGCalCLUEAlgoT::initialized_
bool initialized_
Definition: HGCalCLUEAlgo.h:153
HGCalCLUEAlgoT::CellsOnLayer::delta
std::vector< float > delta
Definition: HGCalCLUEAlgo.h:168
HGCalClusteringAlgoBase::VerbosityLevel
VerbosityLevel
Definition: HGCalClusteringAlgoBase.h:49
HGCalCLUEAlgoT::~HGCalCLUEAlgoT
~HGCalCLUEAlgoT() override
Definition: HGCalCLUEAlgo.h:54
HGCalCLUEAlgoT::dEdXweights_
std::vector< double > dEdXweights_
Definition: HGCalCLUEAlgo.h:138
HGCalClusteringAlgoBase
Definition: HGCalClusteringAlgoBase.h:47
PVValHelper::dx
Definition: PVValidationHelpers.h:48
weight
Definition: weight.py:1
RecHitTools.h
deltaPhi.h
HGCalCLUEAlgoT::CellsOnLayer::rho
std::vector< float > rho
Definition: HGCalCLUEAlgo.h:166
Density
hgcal_clustering::Density Density
Definition: HGCalImagingAlgo.h:29
HGCalCLUEAlgoT::CellsOnLayer::weight
std::vector< float > weight
Definition: HGCalCLUEAlgo.h:165
HGCalCLUEAlgoT::CellsOnLayer::sigmaNoise
std::vector< float > sigmaNoise
Definition: HGCalCLUEAlgo.h:171