CMS 3D CMS Logo

EcalRecHitProducer.cc
Go to the documentation of this file.
1 
9 
11 
18 
20 
23 
25  : doEB_(!ps.getParameter<edm::InputTag>("EBuncalibRecHitCollection").label().empty()),
26  doEE_(!ps.getParameter<edm::InputTag>("EEuncalibRecHitCollection").label().empty()),
27  recoverEBIsolatedChannels_(ps.getParameter<bool>("recoverEBIsolatedChannels")),
28  recoverEEIsolatedChannels_(ps.getParameter<bool>("recoverEEIsolatedChannels")),
29  recoverEBVFE_(ps.getParameter<bool>("recoverEBVFE")),
30  recoverEEVFE_(ps.getParameter<bool>("recoverEEVFE")),
31  recoverEBFE_(ps.getParameter<bool>("recoverEBFE")),
32  recoverEEFE_(ps.getParameter<bool>("recoverEEFE")),
33  killDeadChannels_(ps.getParameter<bool>("killDeadChannels")),
34  ebRecHitToken_(produces<EBRecHitCollection>(ps.getParameter<std::string>("EBrechitCollection"))),
35  eeRecHitToken_(produces<EERecHitCollection>(ps.getParameter<std::string>("EErechitCollection"))) {
36  if (doEB_) {
38  consumes<EBUncalibratedRecHitCollection>(ps.getParameter<edm::InputTag>("EBuncalibRecHitCollection"));
39 
41  ebDetIdToBeRecoveredToken_ = consumes<std::set<EBDetId>>(ps.getParameter<edm::InputTag>("ebDetIdToBeRecovered"));
42  }
43 
46  consumes<std::set<EcalTrigTowerDetId>>(ps.getParameter<edm::InputTag>("ebFEToBeRecovered"));
47  }
48  }
49 
50  if (doEE_) {
52  consumes<EEUncalibratedRecHitCollection>(ps.getParameter<edm::InputTag>("EEuncalibRecHitCollection"));
53 
55  eeDetIdToBeRecoveredToken_ = consumes<std::set<EEDetId>>(ps.getParameter<edm::InputTag>("eeDetIdToBeRecovered"));
56  }
57 
59  eeFEToBeRecoveredToken_ = consumes<std::set<EcalScDetId>>(ps.getParameter<edm::InputTag>("eeFEToBeRecovered"));
60  }
61  }
62 
64  ecalChannelStatusToken_ = esConsumes<EcalChannelStatus, EcalChannelStatusRcd>();
65  }
66 
67  std::string componentType = ps.getParameter<std::string>("algo");
68  edm::ConsumesCollector c{consumesCollector()};
69  worker_ = EcalRecHitWorkerFactory::get()->create(componentType, ps, c);
70 
71  // to recover problematic channels
72  componentType = ps.getParameter<std::string>("algoRecover");
73  workerRecover_ = EcalRecHitWorkerFactory::get()->create(componentType, ps, c);
74 
75  edm::ParameterSet cleaningPs = ps.getParameter<edm::ParameterSet>("cleaningConfig");
76  cleaningAlgo_ = std::make_unique<EcalCleaningAlgo>(cleaningPs);
77 }
78 
80 
82  using namespace edm;
83 
84  // collection of rechits to put in the event
85  auto ebRecHits = std::make_unique<EBRecHitCollection>();
86  auto eeRecHits = std::make_unique<EERecHitCollection>();
87 
88  worker_->set(es);
89 
92  workerRecover_->set(es);
93  }
94 
95  // Make EB rechits
96  if (doEB_) {
97  const auto& ebUncalibRecHits = evt.get(ebUncalibRecHitToken_);
98  LogDebug("EcalRecHitDebug") << "total # EB uncalibrated rechits: " << ebUncalibRecHits.size();
99 
100  // loop over uncalibrated rechits to make calibrated ones
101  for (const auto& uncalibRecHit : ebUncalibRecHits) {
102  worker_->run(evt, uncalibRecHit, *ebRecHits);
103  }
104  }
105 
106  // Make EE rechits
107  if (doEE_) {
108  const auto& eeUncalibRecHits = evt.get(eeUncalibRecHitToken_);
109  LogDebug("EcalRecHitDebug") << "total # EE uncalibrated rechits: " << eeUncalibRecHits.size();
110 
111  // loop over uncalibrated rechits to make calibrated ones
112  for (const auto& uncalibRecHit : eeUncalibRecHits) {
113  worker_->run(evt, uncalibRecHit, *eeRecHits);
114  }
115  }
116 
117  // sort collections before attempting recovery, to avoid insertion of double recHits
118  ebRecHits->sort();
119  eeRecHits->sort();
120 
122  const auto& detIds = evt.get(ebDetIdToBeRecoveredToken_);
123  const auto& chStatus = es.getData(ecalChannelStatusToken_);
124 
125  for (const auto& detId : detIds) {
126  // get channel status map to treat dead VFE separately
127  EcalChannelStatusMap::const_iterator chit = chStatus.find(detId);
128  EcalChannelStatusCode chStatusCode;
129  if (chit != chStatus.end()) {
130  chStatusCode = *chit;
131  } else {
132  edm::LogError("EcalRecHitProducerError") << "No channel status found for xtal " << detId.rawId()
133  << "! something wrong with EcalChannelStatus in your DB? ";
134  }
136  if (chStatusCode.getStatusCode() == EcalChannelStatusCode::kDeadVFE) { // dead VFE (from DB info)
137  // uses the EcalUncalibratedRecHit to pass the DetId info
140  workerRecover_->run(evt, urh, *ebRecHits);
141  } else {
142  // uses the EcalUncalibratedRecHit to pass the DetId info
145  workerRecover_->run(evt, urh, *ebRecHits);
146  }
147  }
148  }
149 
151  const auto& detIds = evt.get(eeDetIdToBeRecoveredToken_);
152  const auto& chStatus = es.getData(ecalChannelStatusToken_);
153 
154  for (const auto& detId : detIds) {
155  // get channel status map to treat dead VFE separately
156  EcalChannelStatusMap::const_iterator chit = chStatus.find(detId);
157  EcalChannelStatusCode chStatusCode;
158  if (chit != chStatus.end()) {
159  chStatusCode = *chit;
160  } else {
161  edm::LogError("EcalRecHitProducerError") << "No channel status found for xtal " << detId.rawId()
162  << "! something wrong with EcalChannelStatus in your DB? ";
163  }
165  if (chStatusCode.getStatusCode() == EcalChannelStatusCode::kDeadVFE) { // dead VFE (from DB info)
166  // uses the EcalUncalibratedRecHit to pass the DetId info
169  workerRecover_->run(evt, urh, *eeRecHits);
170  } else {
171  // uses the EcalUncalibratedRecHit to pass the DetId info
174  workerRecover_->run(evt, urh, *eeRecHits);
175  }
176  }
177  }
178 
180  const auto& ttIds = evt.get(ebFEToBeRecoveredToken_);
181 
182  for (const auto& ttId : ttIds) {
183  // uses the EcalUncalibratedRecHit to pass the DetId info
184  int ieta = ((ttId.ietaAbs() - 1) * 5 + 1) * ttId.zside(); // from EcalTrigTowerConstituentsMap
185  int iphi = ((ttId.iphi() - 1) * 5 + 11) % 360; // from EcalTrigTowerConstituentsMap
186  if (iphi <= 0)
187  iphi += 360; // from EcalTrigTowerConstituentsMap
190  workerRecover_->run(evt, urh, *ebRecHits);
191  }
192  }
193 
195  const auto& scIds = evt.get(eeFEToBeRecoveredToken_);
196 
197  for (const auto& scId : scIds) {
198  // uses the EcalUncalibratedRecHit to pass the DetId info
199  if (EEDetId::validDetId((scId.ix() - 1) * 5 + 1, (scId.iy() - 1) * 5 + 1, scId.zside())) {
200  EcalUncalibratedRecHit urh(EEDetId((scId.ix() - 1) * 5 + 1, (scId.iy() - 1) * 5 + 1, scId.zside()),
201  0,
202  0,
203  0,
204  0,
206  workerRecover_->run(evt, urh, *eeRecHits);
207  }
208  }
209  }
210 
211  // without re-sorting, find (used below in cleaning) will lead
212  // to undefined results
213  ebRecHits->sort();
214  eeRecHits->sort();
215 
216  // apply spike cleaning
217  if (cleaningAlgo_) {
218  cleaningAlgo_->setFlags(*ebRecHits);
219  cleaningAlgo_->setFlags(*eeRecHits);
220  }
221 
222  // put the collection of reconstructed hits in the event
223  LogInfo("EcalRecHitInfo") << "total # EB calibrated rechits: " << ebRecHits->size();
224  LogInfo("EcalRecHitInfo") << "total # EE calibrated rechits: " << eeRecHits->size();
225 
226  evt.put(ebRecHitToken_, std::move(ebRecHits));
227  evt.put(eeRecHitToken_, std::move(eeRecHits));
228 }
229 
232  desc.add<bool>("recoverEEVFE", false);
233  desc.add<std::string>("EErechitCollection", "EcalRecHitsEE");
234  desc.add<bool>("recoverEBIsolatedChannels", false);
235  desc.add<bool>("recoverEBVFE", false);
236  desc.add<bool>("laserCorrection", true);
237  desc.add<double>("EBLaserMIN", 0.5);
238  desc.add<bool>("killDeadChannels", true);
239  {
240  std::vector<int> temp1;
241  temp1.reserve(3);
242  temp1.push_back(14);
243  temp1.push_back(78);
244  temp1.push_back(142);
245  desc.add<std::vector<int>>("dbStatusToBeExcludedEB", temp1);
246  }
247  desc.add<edm::InputTag>("EEuncalibRecHitCollection",
248  edm::InputTag("ecalMultiFitUncalibRecHit", "EcalUncalibRecHitsEE"));
249  {
250  std::vector<int> temp1;
251  temp1.reserve(3);
252  temp1.push_back(14);
253  temp1.push_back(78);
254  temp1.push_back(142);
255  desc.add<std::vector<int>>("dbStatusToBeExcludedEE", temp1);
256  }
257  desc.add<double>("EELaserMIN", 0.5);
258  desc.add<edm::InputTag>("ebFEToBeRecovered", edm::InputTag("ecalDetIdToBeRecovered", "ebFE"));
259  {
261  psd0.add<double>("e6e2thresh", 0.04);
262  psd0.add<double>("tightenCrack_e6e2_double", 3);
263  psd0.add<double>("e4e1Threshold_endcap", 0.3);
264  psd0.add<double>("tightenCrack_e4e1_single", 3);
265  psd0.add<double>("tightenCrack_e1_double", 2);
266  psd0.add<double>("cThreshold_barrel", 4);
267  psd0.add<double>("e4e1Threshold_barrel", 0.08);
268  psd0.add<double>("tightenCrack_e1_single", 2);
269  psd0.add<double>("e4e1_b_barrel", -0.024);
270  psd0.add<double>("e4e1_a_barrel", 0.04);
271  psd0.add<double>("ignoreOutOfTimeThresh", 1000000000.0);
272  psd0.add<double>("cThreshold_endcap", 15);
273  psd0.add<double>("e4e1_b_endcap", -0.0125);
274  psd0.add<double>("e4e1_a_endcap", 0.02);
275  psd0.add<double>("cThreshold_double", 10);
276  desc.add<edm::ParameterSetDescription>("cleaningConfig", psd0);
277  }
278  desc.add<double>("logWarningEtThreshold_EE_FE", 50);
279  desc.add<edm::InputTag>("eeDetIdToBeRecovered", edm::InputTag("ecalDetIdToBeRecovered", "eeDetId"));
280  desc.add<bool>("recoverEBFE", true);
281  desc.add<edm::InputTag>("eeFEToBeRecovered", edm::InputTag("ecalDetIdToBeRecovered", "eeFE"));
282  desc.add<edm::InputTag>("ebDetIdToBeRecovered", edm::InputTag("ecalDetIdToBeRecovered", "ebDetId"));
283  desc.add<double>("singleChannelRecoveryThreshold", 8);
284  desc.add<double>("sum8ChannelRecoveryThreshold", 0.);
285  desc.add<edm::FileInPath>("bdtWeightFileNoCracks",
286  edm::FileInPath("RecoLocalCalo/EcalDeadChannelRecoveryAlgos/data/BDTWeights/"
287  "bdtgAllRH_8GT700MeV_noCracks_ZskimData2017_v1.xml"));
288  desc.add<edm::FileInPath>("bdtWeightFileCracks",
289  edm::FileInPath("RecoLocalCalo/EcalDeadChannelRecoveryAlgos/data/BDTWeights/"
290  "bdtgAllRH_8GT700MeV_onlyCracks_ZskimData2017_v1.xml"));
291  {
292  std::vector<std::string> temp1;
293  temp1.reserve(9);
294  temp1.push_back("kNoisy");
295  temp1.push_back("kNNoisy");
296  temp1.push_back("kFixedG6");
297  temp1.push_back("kFixedG1");
298  temp1.push_back("kFixedG0");
299  temp1.push_back("kNonRespondingIsolated");
300  temp1.push_back("kDeadVFE");
301  temp1.push_back("kDeadFE");
302  temp1.push_back("kNoDataNoTP");
303  desc.add<std::vector<std::string>>("ChannelStatusToBeExcluded", temp1);
304  }
305  desc.add<std::string>("EBrechitCollection", "EcalRecHitsEB");
306  desc.add<edm::InputTag>("triggerPrimitiveDigiCollection", edm::InputTag("ecalDigis", "EcalTriggerPrimitives"));
307  desc.add<bool>("recoverEEFE", true);
308  desc.add<std::string>("singleChannelRecoveryMethod", "NeuralNetworks");
309  desc.add<double>("EBLaserMAX", 3.0);
310  {
312  {
313  std::vector<std::string> temp2;
314  temp2.reserve(4);
315  temp2.push_back("kOk");
316  temp2.push_back("kDAC");
317  temp2.push_back("kNoLaser");
318  temp2.push_back("kNoisy");
319  psd0.add<std::vector<std::string>>("kGood", temp2);
320  }
321  {
322  std::vector<std::string> temp2;
323  temp2.reserve(3);
324  temp2.push_back("kFixedG0");
325  temp2.push_back("kNonRespondingIsolated");
326  temp2.push_back("kDeadVFE");
327  psd0.add<std::vector<std::string>>("kNeighboursRecovered", temp2);
328  }
329  {
330  std::vector<std::string> temp2;
331  temp2.reserve(1);
332  temp2.push_back("kNoDataNoTP");
333  psd0.add<std::vector<std::string>>("kDead", temp2);
334  }
335  {
336  std::vector<std::string> temp2;
337  temp2.reserve(3);
338  temp2.push_back("kNNoisy");
339  temp2.push_back("kFixedG6");
340  temp2.push_back("kFixedG1");
341  psd0.add<std::vector<std::string>>("kNoisy", temp2);
342  }
343  {
344  std::vector<std::string> temp2;
345  temp2.reserve(1);
346  temp2.push_back("kDeadFE");
347  psd0.add<std::vector<std::string>>("kTowerRecovered", temp2);
348  }
349  desc.add<edm::ParameterSetDescription>("flagsMapDBReco", psd0);
350  }
351  desc.add<edm::InputTag>("EBuncalibRecHitCollection",
352  edm::InputTag("ecalMultiFitUncalibRecHit", "EcalUncalibRecHitsEB"));
353  desc.add<std::string>("algoRecover", "EcalRecHitWorkerRecover");
354  desc.add<std::string>("algo", "EcalRecHitWorkerSimple");
355  desc.add<double>("EELaserMAX", 8.0);
356  desc.add<double>("logWarningEtThreshold_EB_FE", 50);
357  desc.add<bool>("recoverEEIsolatedChannels", false);
358  desc.add<bool>("skipTimeCalib", false);
359  descriptions.add("ecalRecHit", desc);
360 }
361 
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
const bool killDeadChannels_
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
void reserve(SetDescriptionEntries::size_type n)
bool get(ProductID const &oid, Handle< PROD > &result) const
Definition: Event.h:346
std::unique_ptr< EcalCleaningAlgo > cleaningAlgo_
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
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_
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)