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