CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
HGCalRecHitWorkerSimple.cc
Go to the documentation of this file.
2 
3 #include <memory>
4 
13 
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 HGCUncalibratedRecHit& uncalibRH,
127  DetId detid = uncalibRH.id();
128  // don't produce rechit if detid is a ghost one
129 
130  if (detid.det() == DetId::Forward || detid.det() == DetId::Hcal) {
131  if ((detid & rangeMask_) == rangeMatch_)
132  return false;
133  }
134 
135  int thickness = -1;
136  float sigmaNoiseGeV = 0.f;
137  unsigned int layer = tools_->getLayerWithOffset(detid);
138  float cce_correction = 1.0;
139  int idtype(0);
140 
141  switch (detid.det()) {
142  case DetId::HGCalEE:
143  idtype = hgcee;
144  thickness = 1 + HGCSiliconDetId(detid).type();
145  break;
146  case DetId::HGCalHSi:
147  idtype = hgcfh;
148  thickness = 1 + HGCSiliconDetId(detid).type();
149  break;
150  case DetId::HGCalHSc:
151  idtype = hgcbh;
152  break;
153  default:
154  switch (detid.subdetId()) {
155  case HGCEE:
156  idtype = hgcee;
157  thickness = ddds_[detid.subdetId() - 3]->waferTypeL(HGCalDetId(detid).wafer());
158  break;
159  case HGCHEF:
160  idtype = hgcfh;
161  thickness = ddds_[detid.subdetId() - 3]->waferTypeL(HGCalDetId(detid).wafer());
162  break;
163  case HcalEndcap:
164  [[fallthrough]];
165  case HGCHEB:
166  idtype = hgcbh;
167  break;
168  case HFNose:
169  idtype = hgchfnose;
170  thickness = 1 + HFNoseDetId(detid).type();
171  break;
172  default:
173  break;
174  }
175  }
176 
177  switch (idtype) {
178  case hgcee:
179  rechitMaker_->setADCToGeVConstant(float(hgceeUncalib2GeV_));
180  cce_correction = hgcEE_cce_[thickness - 1];
181  sigmaNoiseGeV =
182  1e-3 * weights_[layer] * rcorr_[thickness] * hgcEE_noise_fC_[thickness - 1] / hgcEE_fCPerMIP_[thickness - 1];
183  break;
184  case hgcfh:
185  rechitMaker_->setADCToGeVConstant(float(hgchefUncalib2GeV_));
186  cce_correction = hgcHEF_cce_[thickness - 1];
187  sigmaNoiseGeV = 1e-3 * weights_[layer] * rcorr_[thickness + deltasi_index_regemfac_] *
188  hgcHEF_noise_fC_[thickness - 1] / hgcHEF_fCPerMIP_[thickness - 1];
189  break;
190  case hgcbh:
191  rechitMaker_->setADCToGeVConstant(float(hgchebUncalib2GeV_));
192  sigmaNoiseGeV = 1e-3 * hgcHEB_noise_MIP_ * weights_[layer] * rcorrscint_;
193  break;
194  case hgchfnose:
195  rechitMaker_->setADCToGeVConstant(float(hgchfnoseUncalib2GeV_));
196  cce_correction = hgcHFNose_cce_[thickness - 1];
197  sigmaNoiseGeV = 1e-3 * weightsNose_[layer] * rcorrNose_[thickness] * hgcHFNose_noise_fC_[thickness - 1] /
198  hgcHFNose_fCPerMIP_[thickness - 1];
199  break;
200  default:
201  throw cms::Exception("NonHGCRecHit") << "Rechit with detid = " << detid.rawId() << " is not HGC!";
202  }
203 
204  // make the rechit and put in the output collection
205 
206  HGCRecHit myrechit(rechitMaker_->makeRecHit(uncalibRH, 0));
207  double new_E = myrechit.energy();
208  if (detid.det() == DetId::Forward && detid.subdetId() == ForwardSubdetector::HFNose) {
209  new_E *= (thickness == -1 ? 1.0 : rcorrNose_[thickness]) / cce_correction;
210  } //regional factors for silicon in CE_H
211  else if (idtype == hgcfh) {
212  new_E *= rcorr_[thickness + deltasi_index_regemfac_] / cce_correction;
213  } //regional factors for scintillator and silicon in CE_E
214  else {
215  new_E *= (thickness == -1 ? rcorrscint_ : rcorr_[thickness]) / cce_correction;
216  }
217 
218  myrechit.setEnergy(new_E);
219  float SoN = new_E / sigmaNoiseGeV;
220  myrechit.setSignalOverSigmaNoise(SoN);
221 
222  if (detid.det() == DetId::HGCalHSc || myrechit.time() < 0.) {
223  myrechit.setTimeError(-1.);
224  } else {
225  float timeError = timeEstimatorSi_.getTimeError("recHit", SoN);
226  myrechit.setTimeError(timeError);
227  }
228 
229  result.push_back(myrechit);
230 
231  return true;
232 }
233 
235 
constexpr float energy() const
Definition: CaloRecHit.h:29
std::vector< float > weights_
std::vector< double > hgcEE_cce_
int type() const
get the type
Definition: HFNoseDetId.h:50
std::vector< float > weightsNose_
std::vector< double > hgcHEF_fCPerMIP_
std::vector< double > hgcEE_fCPerMIP_
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
void push_back(T const &t)
HGCalRecHitWorkerSimple(const edm::ParameterSet &, edm::ConsumesCollector iC)
hgcalsimclustertime::ComputeClusterTime timeEstimatorSi_
std::vector< double > hgcEE_noise_fC_
constexpr std::array< uint8_t, layerIndexSize > layer
tuple result
Definition: mps_fire.py:311
bool getData(T &iHolder) const
Definition: EventSetup.h:122
std::vector< double > hgcHFNose_cce_
std::vector< double > hgcHEF_cce_
std::vector< double > hgcHFNose_fCPerMIP_
std::vector< double > hgcHEF_noise_fC_
int type() const
get the type
std::vector< double > rcorr_
const HGCalTopology & topology() const
void set(const edm::EventSetup &es) override
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:48
std::unique_ptr< hgcal::RecHitTools > tools_
Definition: DetId.h:17
const HGCalDDDConstants & dddConstants() const
Definition: HGCalTopology.h:98
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
float getTimeError(std::string type, float xVal)
bool run(const edm::Event &evt, const HGCUncalibratedRecHit &uncalibRH, HGCRecHitCollection &result) override
#define DEFINE_EDM_PLUGIN(factory, type, name)
edm::ESGetToken< CaloGeometry, CaloGeometryRecord > caloGeomToken_
edm::ESGetToken< HGCalGeometry, IdealGeometryRecord > ee_geometry_token_
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:151
edm::ESGetToken< HGCalGeometry, IdealGeometryRecord > hfnose_geometry_token_
int weight
Definition: histoStyle.py:51
std::unique_ptr< HGCalRecHitSimpleAlgo > rechitMaker_
ESGetTokenH3DDVariant esConsumes(std::string const &Reccord, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
std::vector< double > rcorrNose_
std::array< const HGCalDDDConstants *, 4 > ddds_
edm::ESGetToken< HGCalGeometry, IdealGeometryRecord > hef_geometry_token_
constexpr Detector det() const
get the detector field from this detid
Definition: DetId.h:46
std::vector< double > hgcHFNose_noise_fC_