CMS 3D CMS Logo

HGCalRecHitWorkerSimple.cc
Go to the documentation of this file.
2 
3 #include <memory>
4 
13 
16  caloGeomToken_(iC.esConsumes<CaloGeometry, CaloGeometryRecord>()),
17  ee_geometry_token_(iC.esConsumes(edm::ESInputTag("", "HGCalEESensitive"))),
18  hef_geometry_token_(iC.esConsumes(edm::ESInputTag("", "HGCalHESiliconSensitive"))),
19  hfnose_geometry_token_(iC.esConsumes(edm::ESInputTag("", "HGCalHFNoseSensitive"))) {
20  rechitMaker_ = std::make_unique<HGCalRecHitSimpleAlgo>();
21  tools_ = std::make_unique<hgcal::RecHitTools>();
22  constexpr float keV2GeV = 1e-6;
23 
24  // HGCee constants
25  hgcEE_keV2DIGI_ = ps.getParameter<double>("HGCEE_keV2DIGI");
26  hgcEE_fCPerMIP_ = ps.getParameter<std::vector<double> >("HGCEE_fCPerMIP");
27  hgcEE_isSiFE_ = ps.getParameter<bool>("HGCEE_isSiFE");
29 
30  // HGChef constants
31  hgcHEF_keV2DIGI_ = ps.getParameter<double>("HGCHEF_keV2DIGI");
32  hgcHEF_fCPerMIP_ = ps.getParameter<std::vector<double> >("HGCHEF_fCPerMIP");
33  hgcHEF_isSiFE_ = ps.getParameter<bool>("HGCHEF_isSiFE");
35 
36  // HGCheb constants
37  hgcHEB_keV2DIGI_ = ps.getParameter<double>("HGCHEB_keV2DIGI");
38  hgcHEB_isSiFE_ = ps.getParameter<bool>("HGCHEB_isSiFE");
40 
41  // HGChfnose constants
42  hgcHFNose_keV2DIGI_ = ps.getParameter<double>("HGCHFNose_keV2DIGI");
43  hgcHFNose_fCPerMIP_ = ps.getParameter<std::vector<double> >("HGCHFNose_fCPerMIP");
44  hgcHFNose_isSiFE_ = ps.getParameter<bool>("HGCHFNose_isSiFE");
46 
47  // layer weights (from Valeri/Arabella)
48  const auto& dweights = ps.getParameter<std::vector<double> >("layerWeights");
49  for (auto weight : dweights) {
50  weights_.push_back(weight);
51  }
52  const auto& weightnose = ps.getParameter<std::vector<double> >("layerNoseWeights");
53  for (auto const& weight : weightnose)
54  weightsNose_.emplace_back(weight);
55 
56  rechitMaker_->setLayerWeights(weights_);
57  rechitMaker_->setNoseLayerWeights(weightsNose_);
58 
59  // residual correction for cell thickness
60  // first for silicon
61  const auto& rcorr = ps.getParameter<std::vector<double> >("thicknessCorrection");
62  rcorr_.clear();
63  rcorr_.push_back(1.f);
64  for (auto corr : rcorr) {
65  rcorr_.push_back(1.0 / corr);
66  }
67  // here for scintillator
68  rcorrscint_ = 1.0 / ps.getParameter<double>("sciThicknessCorrection");
69 
70  //This is for the index position in CE_H silicon thickness cases
71  deltasi_index_regemfac_ = ps.getParameter<int>("deltasi_index_regemfac");
72  const auto& rcorrnose = ps.getParameter<std::vector<double> >("thicknessNoseCorrection");
73  rcorrNose_.clear();
74  rcorrNose_.push_back(1.f);
75  for (auto corr : rcorrnose) {
76  rcorrNose_.push_back(1.0 / corr);
77  }
78 
79  hgcEE_noise_fC_ = ps.getParameter<edm::ParameterSet>("HGCEE_noise_fC").getParameter<std::vector<double> >("values");
80  hgcEE_cce_ = ps.getParameter<edm::ParameterSet>("HGCEE_cce").getParameter<std::vector<double> >("values");
81  hgcHEF_noise_fC_ = ps.getParameter<edm::ParameterSet>("HGCHEF_noise_fC").getParameter<std::vector<double> >("values");
82  hgcHEF_cce_ = ps.getParameter<edm::ParameterSet>("HGCHEF_cce").getParameter<std::vector<double> >("values");
83  hgcHEB_noise_MIP_ = ps.getParameter<edm::ParameterSet>("HGCHEB_noise_MIP").getParameter<double>("noise_MIP");
85  ps.getParameter<edm::ParameterSet>("HGCHFNose_noise_fC").getParameter<std::vector<double> >("values");
86  hgcHFNose_cce_ = ps.getParameter<edm::ParameterSet>("HGCHFNose_cce").getParameter<std::vector<double> >("values");
87 
88  // don't produce rechit if detid is a ghost one
89  rangeMatch_ = ps.getParameter<uint32_t>("rangeMatch");
90  rangeMask_ = ps.getParameter<uint32_t>("rangeMask");
91 
92  // error for recHit time
94  ps.getParameter<double>("maxValSiPar"),
95  ps.getParameter<double>("constSiPar"),
96  ps.getParameter<double>("noiseSiPar"));
97 }
98 
101  tools_->setGeometry(geom);
102  rechitMaker_->set(geom);
103  if (hgcEE_isSiFE_) {
104  const HGCalGeometry& hgceeGeoHandle = es.getData(ee_geometry_token_);
105  ddds_[0] = &(hgceeGeoHandle.topology().dddConstants());
106  } else {
107  ddds_[0] = nullptr;
108  }
109  if (hgcHEF_isSiFE_) {
111  ddds_[1] = &(hgchefGeoHandle->topology().dddConstants());
112  } else {
113  ddds_[1] = nullptr;
114  }
115  ddds_[2] = nullptr;
116  if (hgcHFNose_isSiFE_) {
118  ddds_[3] = &(hgchfnoseGeoHandle->topology().dddConstants());
119  } else {
120  ddds_[3] = nullptr;
121  }
122 }
123 
125  const HGCUncalibratedRecHitCollection& uncalibRHColl,
127  for (const auto& uncalibRH : uncalibRHColl) {
128  DetId detid = uncalibRH.id();
129  // don't produce rechit if detid is a ghost one
130 
131  if (detid.det() == DetId::Forward || detid.det() == DetId::Hcal) {
132  if ((detid & rangeMask_) == rangeMatch_)
133  continue;
134  }
135 
136  int thickness = -1;
137  float sigmaNoiseGeV = 0.f;
138  unsigned int layer = tools_->getLayerWithOffset(detid);
139  float cce_correction = 1.0f;
140  int idtype(0);
141 
142  switch (detid.det()) {
143  case DetId::HGCalEE:
144  idtype = hgcee;
146  break;
147  case DetId::HGCalHSi:
148  idtype = hgcfh;
150  break;
151  case DetId::HGCalHSc:
152  idtype = hgcbh;
153  break;
154  default:
155  switch (detid.subdetId()) {
156  case HGCEE:
157  idtype = hgcee;
158  thickness = ddds_[detid.subdetId() - 3]->waferTypeL(HGCalDetId(detid).wafer());
159  break;
160  case HGCHEF:
161  idtype = hgcfh;
162  thickness = ddds_[detid.subdetId() - 3]->waferTypeL(HGCalDetId(detid).wafer());
163  break;
164  case HcalEndcap:
165  [[fallthrough]];
166  case HGCHEB:
167  idtype = hgcbh;
168  break;
169  case HFNose:
170  idtype = hgchfnose;
171  thickness = 1 + HFNoseDetId(detid).type();
172  break;
173  default:
174  break;
175  }
176  }
177 
178  switch (idtype) {
179  case hgcee:
180  rechitMaker_->setADCToGeVConstant(float(hgceeUncalib2GeV_));
181  cce_correction = hgcEE_cce_[thickness - 1];
182  sigmaNoiseGeV = 1e-3 * weights_[layer] * rcorr_[thickness] * hgcEE_noise_fC_[thickness - 1] /
184  break;
185  case hgcfh:
186  rechitMaker_->setADCToGeVConstant(float(hgchefUncalib2GeV_));
187  cce_correction = hgcHEF_cce_[thickness - 1];
188  sigmaNoiseGeV = 1e-3 * weights_[layer] * rcorr_[thickness + deltasi_index_regemfac_] *
190  break;
191  case hgcbh:
192  rechitMaker_->setADCToGeVConstant(float(hgchebUncalib2GeV_));
193  sigmaNoiseGeV = 1e-3 * hgcHEB_noise_MIP_ * weights_[layer] * rcorrscint_;
194  break;
195  case hgchfnose:
196  rechitMaker_->setADCToGeVConstant(float(hgchfnoseUncalib2GeV_));
197  cce_correction = hgcHFNose_cce_[thickness - 1];
198  sigmaNoiseGeV = 1e-3 * weightsNose_[layer] * rcorrNose_[thickness] * hgcHFNose_noise_fC_[thickness - 1] /
200  break;
201  default:
202  throw cms::Exception("NonHGCRecHit") << "Rechit with detid = " << detid.rawId() << " is not HGC!";
203  }
204 
205  // make the rechit and put in the output collection
206 
207  HGCRecHit myrechit(rechitMaker_->makeRecHit(uncalibRH, 0));
208  double new_E = myrechit.energy();
209  if (detid.det() == DetId::Forward && detid.subdetId() == ForwardSubdetector::HFNose) {
210  new_E *= (thickness == -1 ? 1.0 : rcorrNose_[thickness]) / cce_correction;
211  } //regional factors for silicon in CE_H
212  else if (idtype == hgcfh) {
213  new_E *= rcorr_[thickness + deltasi_index_regemfac_] / cce_correction;
214  } //regional factors for scintillator and silicon in CE_E
215  else {
216  new_E *= (thickness == -1 ? rcorrscint_ : rcorr_[thickness]) / cce_correction;
217  }
218 
219  myrechit.setEnergy(new_E);
220  float SoN = new_E / sigmaNoiseGeV;
221  myrechit.setSignalOverSigmaNoise(SoN);
222 
223  if (detid.det() == DetId::HGCalHSc || myrechit.time() == -99.) {
224  myrechit.setTimeError(-1.);
225  } else {
226  float timeError = timeEstimatorSi_.getTimeError("recHit", SoN);
227  myrechit.setTimeError(timeError);
228  }
229 
230  result.push_back(myrechit);
231  }
232 }
233 
235 
void run(const edm::Event &evt, const HGCUncalibratedRecHitCollection &uncalibRH, HGCRecHitCollection &result) override
ESGetTokenH3DDVariant esConsumes(std::string const &Record, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
std::vector< float > weights_
std::vector< HGCRecHit > HGCRecHitCollection
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
Definition: EventSetup.h:119
std::vector< double > hgcEE_cce_
std::vector< float > weightsNose_
std::vector< double > hgcHEF_fCPerMIP_
std::vector< double > hgcEE_fCPerMIP_
HGCalRecHitWorkerSimple(const edm::ParameterSet &, edm::ConsumesCollector iC)
Definition: weight.py:1
hgcalsimclustertime::ComputeClusterTime timeEstimatorSi_
std::vector< double > hgcEE_noise_fC_
constexpr float energy() const
Definition: CaloRecHit.h:29
std::vector< double > hgcHFNose_cce_
std::vector< double > hgcHEF_cce_
dictionary corr
std::vector< double > hgcHFNose_fCPerMIP_
std::vector< double > hgcHEF_noise_fC_
std::vector< double > rcorr_
void set(const edm::EventSetup &es) override
double f[11][100]
int type() const
get the type
Definition: HFNoseDetId.h:51
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:130
const HGCalTopology & topology() const
std::unique_ptr< hgcal::RecHitTools > tools_
Definition: DetId.h:17
float getTimeError(std::string type, float xVal)
HLT enums.
#define DEFINE_EDM_PLUGIN(factory, type, name)
edm::ESGetToken< CaloGeometry, CaloGeometryRecord > caloGeomToken_
edm::ESGetToken< HGCalGeometry, IdealGeometryRecord > ee_geometry_token_
edm::ESGetToken< HGCalGeometry, IdealGeometryRecord > hfnose_geometry_token_
constexpr int32_t type() const
get the type
std::unique_ptr< HGCalRecHitSimpleAlgo > rechitMaker_
const HGCalDDDConstants & dddConstants() const
Definition: HGCalTopology.h:98
std::vector< double > rcorrNose_
std::array< const HGCalDDDConstants *, 4 > ddds_
edm::ESGetToken< HGCalGeometry, IdealGeometryRecord > hef_geometry_token_
std::vector< double > hgcHFNose_noise_fC_