CMS 3D CMS Logo

EcalRecHitProducer.cc
Go to the documentation of this file.
1 
27 
29 public:
30  explicit EcalRecHitProducer(const edm::ParameterSet& ps);
31  ~EcalRecHitProducer() override;
32  void produce(edm::Event& evt, const edm::EventSetup& es) override;
33  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
34 
35 private:
36  const bool doEB_; // consume and use the EB uncalibrated RecHits. An EB collection is produced even if this is false
37  const bool doEE_; // consume and use the EE uncalibrated RecHits. An EE collection is produced even if this is false
40  const bool recoverEBVFE_;
41  const bool recoverEEVFE_;
42  const bool recoverEBFE_;
43  const bool recoverEEFE_;
44  const bool killDeadChannels_;
45 
46  std::unique_ptr<EcalRecHitWorkerBaseClass> worker_;
47  std::unique_ptr<EcalRecHitWorkerBaseClass> workerRecover_;
48 
49  std::unique_ptr<EcalCleaningAlgo> cleaningAlgo_;
50 
60 };
61 
63  : doEB_(!ps.getParameter<edm::InputTag>("EBuncalibRecHitCollection").label().empty()),
64  doEE_(!ps.getParameter<edm::InputTag>("EEuncalibRecHitCollection").label().empty()),
65  recoverEBIsolatedChannels_(ps.getParameter<bool>("recoverEBIsolatedChannels")),
66  recoverEEIsolatedChannels_(ps.getParameter<bool>("recoverEEIsolatedChannels")),
67  recoverEBVFE_(ps.getParameter<bool>("recoverEBVFE")),
68  recoverEEVFE_(ps.getParameter<bool>("recoverEEVFE")),
69  recoverEBFE_(ps.getParameter<bool>("recoverEBFE")),
70  recoverEEFE_(ps.getParameter<bool>("recoverEEFE")),
71  killDeadChannels_(ps.getParameter<bool>("killDeadChannels")),
72  ebRecHitToken_(produces<EBRecHitCollection>(ps.getParameter<std::string>("EBrechitCollection"))),
73  eeRecHitToken_(produces<EERecHitCollection>(ps.getParameter<std::string>("EErechitCollection"))) {
74  if (doEB_) {
76  consumes<EBUncalibratedRecHitCollection>(ps.getParameter<edm::InputTag>("EBuncalibRecHitCollection"));
77 
79  ebDetIdToBeRecoveredToken_ = consumes<std::set<EBDetId>>(ps.getParameter<edm::InputTag>("ebDetIdToBeRecovered"));
80  }
81 
84  consumes<std::set<EcalTrigTowerDetId>>(ps.getParameter<edm::InputTag>("ebFEToBeRecovered"));
85  }
86  }
87 
88  if (doEE_) {
90  consumes<EEUncalibratedRecHitCollection>(ps.getParameter<edm::InputTag>("EEuncalibRecHitCollection"));
91 
93  eeDetIdToBeRecoveredToken_ = consumes<std::set<EEDetId>>(ps.getParameter<edm::InputTag>("eeDetIdToBeRecovered"));
94  }
95 
97  eeFEToBeRecoveredToken_ = consumes<std::set<EcalScDetId>>(ps.getParameter<edm::InputTag>("eeFEToBeRecovered"));
98  }
99  }
100 
102  ecalChannelStatusToken_ = esConsumes<EcalChannelStatus, EcalChannelStatusRcd>();
103  }
104 
105  std::string componentType = ps.getParameter<std::string>("algo");
106  edm::ConsumesCollector c{consumesCollector()};
107  worker_ = EcalRecHitWorkerFactory::get()->create(componentType, ps, c);
108 
109  // to recover problematic channels
110  componentType = ps.getParameter<std::string>("algoRecover");
111  workerRecover_ = EcalRecHitWorkerFactory::get()->create(componentType, ps, c);
112 
113  edm::ParameterSet cleaningPs = ps.getParameter<edm::ParameterSet>("cleaningConfig");
114  cleaningAlgo_ = std::make_unique<EcalCleaningAlgo>(cleaningPs);
115 }
116 
118 
120  using namespace edm;
121 
122  // collection of rechits to put in the event
123  auto ebRecHits = std::make_unique<EBRecHitCollection>();
124  auto eeRecHits = std::make_unique<EERecHitCollection>();
125 
126  worker_->set(es);
127 
130  workerRecover_->set(es);
131  }
132 
133  // Make EB rechits
134  if (doEB_) {
135  const auto& ebUncalibRecHits = evt.get(ebUncalibRecHitToken_);
136  LogDebug("EcalRecHitDebug") << "total # EB uncalibrated rechits: " << ebUncalibRecHits.size();
137 
138  // loop over uncalibrated rechits to make calibrated ones
139  for (const auto& uncalibRecHit : ebUncalibRecHits) {
140  worker_->run(evt, uncalibRecHit, *ebRecHits);
141  }
142  }
143 
144  // Make EE rechits
145  if (doEE_) {
146  const auto& eeUncalibRecHits = evt.get(eeUncalibRecHitToken_);
147  LogDebug("EcalRecHitDebug") << "total # EE uncalibrated rechits: " << eeUncalibRecHits.size();
148 
149  // loop over uncalibrated rechits to make calibrated ones
150  for (const auto& uncalibRecHit : eeUncalibRecHits) {
151  worker_->run(evt, uncalibRecHit, *eeRecHits);
152  }
153  }
154 
155  // sort collections before attempting recovery, to avoid insertion of double recHits
156  ebRecHits->sort();
157  eeRecHits->sort();
158 
160  const auto& detIds = evt.get(ebDetIdToBeRecoveredToken_);
161  const auto& chStatus = es.getData(ecalChannelStatusToken_);
162 
163  for (const auto& detId : detIds) {
164  // get channel status map to treat dead VFE separately
165  EcalChannelStatusMap::const_iterator chit = chStatus.find(detId);
166  EcalChannelStatusCode chStatusCode;
167  if (chit != chStatus.end()) {
168  chStatusCode = *chit;
169  } else {
170  edm::LogError("EcalRecHitProducerError") << "No channel status found for xtal " << detId.rawId()
171  << "! something wrong with EcalChannelStatus in your DB? ";
172  }
174  if (chStatusCode.getStatusCode() == EcalChannelStatusCode::kDeadVFE) { // dead VFE (from DB info)
175  // uses the EcalUncalibratedRecHit to pass the DetId info
178  workerRecover_->run(evt, urh, *ebRecHits);
179  } else {
180  // uses the EcalUncalibratedRecHit to pass the DetId info
183  workerRecover_->run(evt, urh, *ebRecHits);
184  }
185  }
186  }
187 
189  const auto& detIds = evt.get(eeDetIdToBeRecoveredToken_);
190  const auto& chStatus = es.getData(ecalChannelStatusToken_);
191 
192  for (const auto& detId : detIds) {
193  // get channel status map to treat dead VFE separately
194  EcalChannelStatusMap::const_iterator chit = chStatus.find(detId);
195  EcalChannelStatusCode chStatusCode;
196  if (chit != chStatus.end()) {
197  chStatusCode = *chit;
198  } else {
199  edm::LogError("EcalRecHitProducerError") << "No channel status found for xtal " << detId.rawId()
200  << "! something wrong with EcalChannelStatus in your DB? ";
201  }
203  if (chStatusCode.getStatusCode() == EcalChannelStatusCode::kDeadVFE) { // dead VFE (from DB info)
204  // uses the EcalUncalibratedRecHit to pass the DetId info
207  workerRecover_->run(evt, urh, *eeRecHits);
208  } else {
209  // uses the EcalUncalibratedRecHit to pass the DetId info
212  workerRecover_->run(evt, urh, *eeRecHits);
213  }
214  }
215  }
216 
218  const auto& ttIds = evt.get(ebFEToBeRecoveredToken_);
219 
220  for (const auto& ttId : ttIds) {
221  // uses the EcalUncalibratedRecHit to pass the DetId info
222  int ieta = ((ttId.ietaAbs() - 1) * 5 + 1) * ttId.zside(); // from EcalTrigTowerConstituentsMap
223  int iphi = ((ttId.iphi() - 1) * 5 + 11) % 360; // from EcalTrigTowerConstituentsMap
224  if (iphi <= 0)
225  iphi += 360; // from EcalTrigTowerConstituentsMap
228  workerRecover_->run(evt, urh, *ebRecHits);
229  }
230  }
231 
233  const auto& scIds = evt.get(eeFEToBeRecoveredToken_);
234 
235  for (const auto& scId : scIds) {
236  // uses the EcalUncalibratedRecHit to pass the DetId info
237  if (EEDetId::validDetId((scId.ix() - 1) * 5 + 1, (scId.iy() - 1) * 5 + 1, scId.zside())) {
238  EcalUncalibratedRecHit urh(EEDetId((scId.ix() - 1) * 5 + 1, (scId.iy() - 1) * 5 + 1, scId.zside()),
239  0,
240  0,
241  0,
242  0,
244  workerRecover_->run(evt, urh, *eeRecHits);
245  }
246  }
247  }
248 
249  // without re-sorting, find (used below in cleaning) will lead
250  // to undefined results
251  ebRecHits->sort();
252  eeRecHits->sort();
253 
254  // apply spike cleaning
255  if (cleaningAlgo_) {
256  cleaningAlgo_->setFlags(*ebRecHits);
257  cleaningAlgo_->setFlags(*eeRecHits);
258  }
259 
260  // put the collection of reconstructed hits in the event
261  LogInfo("EcalRecHitInfo") << "total # EB calibrated rechits: " << ebRecHits->size();
262  LogInfo("EcalRecHitInfo") << "total # EE calibrated rechits: " << eeRecHits->size();
263 
264  evt.put(ebRecHitToken_, std::move(ebRecHits));
265  evt.put(eeRecHitToken_, std::move(eeRecHits));
266 }
267 
270  desc.add<bool>("recoverEEVFE", false);
271  desc.add<std::string>("EErechitCollection", "EcalRecHitsEE");
272  desc.add<bool>("recoverEBIsolatedChannels", false);
273  desc.add<bool>("recoverEBVFE", false);
274  desc.add<bool>("laserCorrection", true);
275  desc.add<double>("EBLaserMIN", 0.5);
276  desc.add<bool>("killDeadChannels", true);
277  {
278  std::vector<int> temp1;
279  temp1.reserve(3);
280  temp1.push_back(14);
281  temp1.push_back(78);
282  temp1.push_back(142);
283  desc.add<std::vector<int>>("dbStatusToBeExcludedEB", temp1);
284  }
285  desc.add<edm::InputTag>("EEuncalibRecHitCollection",
286  edm::InputTag("ecalMultiFitUncalibRecHit", "EcalUncalibRecHitsEE"));
287  {
288  std::vector<int> temp1;
289  temp1.reserve(3);
290  temp1.push_back(14);
291  temp1.push_back(78);
292  temp1.push_back(142);
293  desc.add<std::vector<int>>("dbStatusToBeExcludedEE", temp1);
294  }
295  desc.add<double>("EELaserMIN", 0.5);
296  desc.add<edm::InputTag>("ebFEToBeRecovered", edm::InputTag("ecalDetIdToBeRecovered", "ebFE"));
297  {
299  psd0.add<double>("e6e2thresh", 0.04);
300  psd0.add<double>("tightenCrack_e6e2_double", 3);
301  psd0.add<double>("e4e1Threshold_endcap", 0.3);
302  psd0.add<double>("tightenCrack_e4e1_single", 3);
303  psd0.add<double>("tightenCrack_e1_double", 2);
304  psd0.add<double>("cThreshold_barrel", 4);
305  psd0.add<double>("e4e1Threshold_barrel", 0.08);
306  psd0.add<double>("tightenCrack_e1_single", 2);
307  psd0.add<double>("e4e1_b_barrel", -0.024);
308  psd0.add<double>("e4e1_a_barrel", 0.04);
309  psd0.add<double>("ignoreOutOfTimeThresh", 1000000000.0);
310  psd0.add<double>("cThreshold_endcap", 15);
311  psd0.add<double>("e4e1_b_endcap", -0.0125);
312  psd0.add<double>("e4e1_a_endcap", 0.02);
313  psd0.add<double>("cThreshold_double", 10);
314  desc.add<edm::ParameterSetDescription>("cleaningConfig", psd0);
315  }
316  desc.add<double>("logWarningEtThreshold_EE_FE", 50);
317  desc.add<edm::InputTag>("eeDetIdToBeRecovered", edm::InputTag("ecalDetIdToBeRecovered", "eeDetId"));
318  desc.add<bool>("recoverEBFE", true);
319  desc.add<edm::InputTag>("eeFEToBeRecovered", edm::InputTag("ecalDetIdToBeRecovered", "eeFE"));
320  desc.add<edm::InputTag>("ebDetIdToBeRecovered", edm::InputTag("ecalDetIdToBeRecovered", "ebDetId"));
321  desc.add<double>("singleChannelRecoveryThreshold", 8);
322  desc.add<double>("sum8ChannelRecoveryThreshold", 0.);
323  desc.add<edm::FileInPath>("bdtWeightFileNoCracks",
324  edm::FileInPath("RecoLocalCalo/EcalDeadChannelRecoveryAlgos/data/BDTWeights/"
325  "bdtgAllRH_8GT700MeV_noCracks_ZskimData2017_v1.xml"));
326  desc.add<edm::FileInPath>("bdtWeightFileCracks",
327  edm::FileInPath("RecoLocalCalo/EcalDeadChannelRecoveryAlgos/data/BDTWeights/"
328  "bdtgAllRH_8GT700MeV_onlyCracks_ZskimData2017_v1.xml"));
329  {
330  std::vector<std::string> temp1;
331  temp1.reserve(9);
332  temp1.push_back("kNoisy");
333  temp1.push_back("kNNoisy");
334  temp1.push_back("kFixedG6");
335  temp1.push_back("kFixedG1");
336  temp1.push_back("kFixedG0");
337  temp1.push_back("kNonRespondingIsolated");
338  temp1.push_back("kDeadVFE");
339  temp1.push_back("kDeadFE");
340  temp1.push_back("kNoDataNoTP");
341  desc.add<std::vector<std::string>>("ChannelStatusToBeExcluded", temp1);
342  }
343  desc.add<std::string>("EBrechitCollection", "EcalRecHitsEB");
344  desc.add<edm::InputTag>("triggerPrimitiveDigiCollection", edm::InputTag("ecalDigis", "EcalTriggerPrimitives"));
345  desc.add<bool>("recoverEEFE", true);
346  desc.add<std::string>("singleChannelRecoveryMethod", "NeuralNetworks");
347  desc.add<double>("EBLaserMAX", 3.0);
348  {
350  {
351  std::vector<std::string> temp2;
352  temp2.reserve(4);
353  temp2.push_back("kOk");
354  temp2.push_back("kDAC");
355  temp2.push_back("kNoLaser");
356  temp2.push_back("kNoisy");
357  psd0.add<std::vector<std::string>>("kGood", temp2);
358  }
359  {
360  std::vector<std::string> temp2;
361  temp2.reserve(3);
362  temp2.push_back("kFixedG0");
363  temp2.push_back("kNonRespondingIsolated");
364  temp2.push_back("kDeadVFE");
365  psd0.add<std::vector<std::string>>("kNeighboursRecovered", temp2);
366  }
367  {
368  std::vector<std::string> temp2;
369  temp2.reserve(1);
370  temp2.push_back("kNoDataNoTP");
371  psd0.add<std::vector<std::string>>("kDead", temp2);
372  }
373  {
374  std::vector<std::string> temp2;
375  temp2.reserve(3);
376  temp2.push_back("kNNoisy");
377  temp2.push_back("kFixedG6");
378  temp2.push_back("kFixedG1");
379  psd0.add<std::vector<std::string>>("kNoisy", temp2);
380  }
381  {
382  std::vector<std::string> temp2;
383  temp2.reserve(1);
384  temp2.push_back("kDeadFE");
385  psd0.add<std::vector<std::string>>("kTowerRecovered", temp2);
386  }
387  desc.add<edm::ParameterSetDescription>("flagsMapDBReco", psd0);
388  }
389  desc.add<edm::InputTag>("EBuncalibRecHitCollection",
390  edm::InputTag("ecalMultiFitUncalibRecHit", "EcalUncalibRecHitsEB"));
391  desc.add<std::string>("algoRecover", "EcalRecHitWorkerRecover");
392  desc.add<std::string>("algo", "EcalRecHitWorkerSimple");
393  desc.add<double>("EELaserMAX", 8.0);
394  desc.add<double>("logWarningEtThreshold_EB_FE", 50);
395  desc.add<bool>("recoverEEIsolatedChannels", false);
396  desc.add<bool>("skipTimeCalib", false);
397  descriptions.add("ecalRecHit", desc);
398 }
399 
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
void reserve(SetDescriptionEntries::size_type n)
bool get(ProductID const &oid, Handle< PROD > &result) const
Definition: Event.h:347
std::unique_ptr< EcalCleaningAlgo > cleaningAlgo_
Log< level::Error, false > LogError
~EcalRecHitProducer() override
EcalRecHitProducer(const edm::ParameterSet &ps)
unsigned ttId(DetId const &, EcalElectronicsMapping const *)
const edm::EDPutTokenT< EBRecHitCollection > ebRecHitToken_
char const * label
edm::ESGetToken< EcalChannelStatus, EcalChannelStatusRcd > ecalChannelStatusToken_
const bool recoverEBIsolatedChannels_
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
bool getData(T &iHolder) const
Definition: EventSetup.h:122
ParameterDescriptionBase * add(U const &iLabel, T const &value)
edm::EDGetTokenT< EEUncalibratedRecHitCollection > eeUncalibRecHitToken_
const edm::EDPutTokenT< EERecHitCollection > eeRecHitToken_
static const int ETAPHIMODE
Definition: EBDetId.h:158
const bool recoverEEIsolatedChannels_
edm::EDGetTokenT< EBUncalibratedRecHitCollection > ebUncalibRecHitToken_
Log< level::Info, false > LogInfo
edm::EDGetTokenT< std::set< EBDetId > > ebDetIdToBeRecoveredToken_
std::unique_ptr< EcalRecHitWorkerBaseClass > workerRecover_
static bool validDetId(int crystal_ix, int crystal_iy, int iz)
Definition: EEDetId.h:248
std::vector< Item >::const_iterator const_iterator
edm::EDGetTokenT< std::set< EcalScDetId > > eeFEToBeRecoveredToken_
void add(std::string const &label, ParameterSetDescription const &psetDescription)
HLT enums.
Code getStatusCode() const
return decoded status
void produce(edm::Event &evt, const edm::EventSetup &es) override
std::unique_ptr< EcalRecHitWorkerBaseClass > worker_
#define get
edm::EDGetTokenT< std::set< EEDetId > > eeDetIdToBeRecoveredToken_
def move(src, dest)
Definition: eostools.py:511
edm::EDGetTokenT< std::set< EcalTrigTowerDetId > > ebFEToBeRecoveredToken_
#define LogDebug(id)