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