CMS 3D CMS Logo

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