CMS 3D CMS Logo

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