CMS 3D CMS Logo

EcalRecHitProducer.cc
Go to the documentation of this file.
1 
11 
13 
21 
24 
26 
29 
31 {
32 
33  ebRechitCollection_ = ps.getParameter<std::string>("EBrechitCollection");
34  eeRechitCollection_ = ps.getParameter<std::string>("EErechitCollection");
35 
36  recoverEBIsolatedChannels_ = ps.getParameter<bool>("recoverEBIsolatedChannels");
37  recoverEEIsolatedChannels_ = ps.getParameter<bool>("recoverEEIsolatedChannels");
38  recoverEBVFE_ = ps.getParameter<bool>("recoverEBVFE");
39  recoverEEVFE_ = ps.getParameter<bool>("recoverEEVFE");
40  recoverEBFE_ = ps.getParameter<bool>("recoverEBFE");
41  recoverEEFE_ = ps.getParameter<bool>("recoverEEFE");
42  killDeadChannels_ = ps.getParameter<bool>("killDeadChannels");
43 
44 
45  produces< EBRecHitCollection >(ebRechitCollection_);
46  produces< EERecHitCollection >(eeRechitCollection_);
47 
48 
50  consumes<EBUncalibratedRecHitCollection>( ps.getParameter<edm::InputTag>("EBuncalibRecHitCollection"));
51 
53  consumes<EEUncalibratedRecHitCollection>( ps.getParameter<edm::InputTag>("EEuncalibRecHitCollection"));
54 
56  consumes<std::set<EBDetId>>(ps.getParameter<edm::InputTag>("ebDetIdToBeRecovered"));
57 
59  consumes<std::set<EEDetId>>(ps.getParameter<edm::InputTag>("eeDetIdToBeRecovered"));
60 
61  ebFEToBeRecoveredToken_ = consumes<std::set<EcalTrigTowerDetId>>(ps.getParameter<edm::InputTag>("ebFEToBeRecovered"));
62 
63  eeFEToBeRecoveredToken_= consumes<std::set<EcalScDetId>>( ps.getParameter<edm::InputTag>("eeFEToBeRecovered")) ;
64 
65  std::string componentType = ps.getParameter<std::string>("algo");
66  edm::ConsumesCollector c{consumesCollector()};
67  worker_ = std::unique_ptr<EcalRecHitWorkerBaseClass>{EcalRecHitWorkerFactory::get()->create(componentType, ps, c)};
68 
69  // to recover problematic channels
70  componentType = ps.getParameter<std::string>("algoRecover");
71  workerRecover_ = std::unique_ptr<EcalRecHitWorkerBaseClass>{EcalRecHitWorkerFactory::get()->create(componentType, ps, c)};
72 
73  edm::ParameterSet cleaningPs =
74  ps.getParameter<edm::ParameterSet>("cleaningConfig");
75  cleaningAlgo_ = std::make_unique<EcalCleaningAlgo>(cleaningPs);
76 }
77 
79 
80 void
82 {
83  using namespace edm;
84 
87 
88  const EBUncalibratedRecHitCollection* ebUncalibRecHits = nullptr;
89  const EEUncalibratedRecHitCollection* eeUncalibRecHits = nullptr;
90 
91  // get the barrel uncalib rechit collection
92 
93  evt.getByToken( ebUncalibRecHitToken_, pEBUncalibRecHits);
94  ebUncalibRecHits = pEBUncalibRecHits.product();
95  LogDebug("EcalRecHitDebug") << "total # EB uncalibrated rechits: " << ebUncalibRecHits->size();
96 
97 
98 
99  evt.getByToken( eeUncalibRecHitToken_, pEEUncalibRecHits);
100  eeUncalibRecHits = pEEUncalibRecHits.product(); // get a ptr to the product
101  LogDebug("EcalRecHitDebug") << "total # EE uncalibrated rechits: " << eeUncalibRecHits->size();
102 
103  // collection of rechits to put in the event
104  auto ebRecHits = std::make_unique<EBRecHitCollection>();
105  auto eeRecHits = std::make_unique<EERecHitCollection>();
106 
107  worker_->set(es);
108 
112  || killDeadChannels_ ) {
113  workerRecover_->set(es);
114  }
115 
116  if (ebUncalibRecHits)
117  {
118  // loop over uncalibrated rechits to make calibrated ones
119  for(EBUncalibratedRecHitCollection::const_iterator it = ebUncalibRecHits->begin(); it != ebUncalibRecHits->end(); ++it) {
120  worker_->run(evt, *it, *ebRecHits);
121  }
122  }
123 
124  if (eeUncalibRecHits)
125  {
126  // loop over uncalibrated rechits to make calibrated ones
127  for(EEUncalibratedRecHitCollection::const_iterator it = eeUncalibRecHits->begin(); it != eeUncalibRecHits->end(); ++it) {
128  worker_->run(evt, *it, *eeRecHits);
129  }
130  }
131 
132  // sort collections before attempting recovery, to avoid insertion of double recHits
133  ebRecHits->sort();
134  eeRecHits->sort();
135 
137  {
139  const std::set<EBDetId> * detIds = nullptr;
140  evt.getByToken( ebDetIdToBeRecoveredToken_, pEBDetId);
141  detIds = pEBDetId.product();
142 
143 
144  if ( detIds ) {
146  es.get<EcalChannelStatusRcd>().get(chStatus);
147  for( std::set<EBDetId>::const_iterator it = detIds->begin(); it != detIds->end(); ++it ) {
148  // get channel status map to treat dead VFE separately
149  EcalChannelStatusMap::const_iterator chit = chStatus->find( *it );
150  EcalChannelStatusCode chStatusCode;
151  if ( chit != chStatus->end() ) {
152  chStatusCode = *chit;
153  } else {
154  edm::LogError("EcalRecHitProducerError") << "No channel status found for xtal "
155  << (*it).rawId()
156  << "! something wrong with EcalChannelStatus in your DB? ";
157  }
159  if ( chStatusCode.getStatusCode() == EcalChannelStatusCode::kDeadVFE ) { // dead VFE (from DB info)
160  // uses the EcalUncalibratedRecHit to pass the DetId info
162  if ( recoverEBVFE_ || killDeadChannels_ ) workerRecover_->run( evt, urh, *ebRecHits );
163  } else {
164  // uses the EcalUncalibratedRecHit to pass the DetId info
166  if ( recoverEBIsolatedChannels_ || killDeadChannels_ ) workerRecover_->run( evt, urh, *ebRecHits );
167  }
168 
169  }
170  }
171  }
172 
174  {
176  const std::set<EEDetId> * detIds = nullptr;
177 
178  evt.getByToken( eeDetIdToBeRecoveredToken_, pEEDetId);
179  detIds = pEEDetId.product();
180 
181  if ( detIds ) {
183  es.get<EcalChannelStatusRcd>().get(chStatus);
184  for( std::set<EEDetId>::const_iterator it = detIds->begin(); it != detIds->end(); ++it ) {
185  // get channel status map to treat dead VFE separately
186  EcalChannelStatusMap::const_iterator chit = chStatus->find( *it );
187  EcalChannelStatusCode chStatusCode;
188  if ( chit != chStatus->end() ) {
189  chStatusCode = *chit;
190  } else {
191  edm::LogError("EcalRecHitProducerError") << "No channel status found for xtal "
192  << (*it).rawId()
193  << "! something wrong with EcalChannelStatus in your DB? ";
194  }
196  if ( chStatusCode.getStatusCode() == EcalChannelStatusCode::kDeadVFE) { // dead VFE (from DB info)
197  // uses the EcalUncalibratedRecHit to pass the DetId info
199  if ( recoverEEVFE_ || killDeadChannels_ ) workerRecover_->run( evt, urh, *eeRecHits );
200  } else {
201  // uses the EcalUncalibratedRecHit to pass the DetId info
203  if ( recoverEEIsolatedChannels_ || killDeadChannels_ ) workerRecover_->run( evt, urh, *eeRecHits );
204  }
205  }
206  }
207  }
208 
210  {
212  const std::set<EcalTrigTowerDetId> * ttIds = nullptr;
213 
214  evt.getByToken( ebFEToBeRecoveredToken_, pEBFEId);
215  ttIds = pEBFEId.product();
216 
217  if ( ttIds ) {
218  for( std::set<EcalTrigTowerDetId>::const_iterator it = ttIds->begin(); it != ttIds->end(); ++it ) {
219  // uses the EcalUncalibratedRecHit to pass the DetId info
220  int ieta = (((*it).ietaAbs()-1)*5+1)*(*it).zside(); // from EcalTrigTowerConstituentsMap
221  int iphi = (((*it).iphi()-1)*5+11)%360; // from EcalTrigTowerConstituentsMap
222  if( iphi <= 0 ) iphi += 360; // from EcalTrigTowerConstituentsMap
224  workerRecover_->run( evt, urh, *ebRecHits );
225  }
226  }
227  }
228 
230  {
232  const std::set<EcalScDetId> * scIds = nullptr;
233 
234  evt.getByToken( eeFEToBeRecoveredToken_, pEEFEId);
235  scIds = pEEFEId.product();
236 
237 
238  if ( scIds ) {
239  for( std::set<EcalScDetId>::const_iterator it = scIds->begin(); it != scIds->end(); ++it ) {
240  // uses the EcalUncalibratedRecHit to pass the DetId info
241  if (EEDetId::validDetId( ((*it).ix()-1)*5+1, ((*it).iy()-1)*5+1, (*it).zside() )) {
242  EcalUncalibratedRecHit urh( EEDetId( ((*it).ix()-1)*5+1, ((*it).iy()-1)*5+1, (*it).zside() ), 0, 0, 0, 0, EcalRecHitWorkerBaseClass::EE_FE );
243  workerRecover_->run( evt, urh, *eeRecHits );
244  }
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 
261  // put the collection of recunstructed hits in the event
262  LogInfo("EcalRecHitInfo") << "total # EB calibrated rechits: " << ebRecHits->size();
263  LogInfo("EcalRecHitInfo") << "total # EE calibrated rechits: " << eeRecHits->size();
264 
265  evt.put(std::move(ebRecHits), ebRechitCollection_);
266  evt.put(std::move(eeRecHits), eeRechitCollection_);
267 }
268 
271  desc.add<bool>("recoverEEVFE",false);
272  desc.add<std::string>("EErechitCollection","EcalRecHitsEE");
273  desc.add<bool>("recoverEBIsolatedChannels",false);
274  desc.add<bool>("recoverEBVFE",false);
275  desc.add<bool>("laserCorrection",true);
276  desc.add<double>("EBLaserMIN",0.5);
277  desc.add<bool>("killDeadChannels",true);
278  {
279  std::vector<int> temp1;
280  temp1.reserve(3);
281  temp1.push_back(14);
282  temp1.push_back(78);
283  temp1.push_back(142);
284  desc.add<std::vector<int> >("dbStatusToBeExcludedEB",temp1);
285  }
286  desc.add<edm::InputTag>("EEuncalibRecHitCollection",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  {
323  std::vector<std::string> temp1;
324  temp1.reserve(9);
325  temp1.push_back("kNoisy");
326  temp1.push_back("kNNoisy");
327  temp1.push_back("kFixedG6");
328  temp1.push_back("kFixedG1");
329  temp1.push_back("kFixedG0");
330  temp1.push_back("kNonRespondingIsolated");
331  temp1.push_back("kDeadVFE");
332  temp1.push_back("kDeadFE");
333  temp1.push_back("kNoDataNoTP");
334  desc.add<std::vector<std::string> >("ChannelStatusToBeExcluded",temp1);
335  }
336  desc.add<std::string>("EBrechitCollection","EcalRecHitsEB");
337  desc.add<edm::InputTag>("triggerPrimitiveDigiCollection",edm::InputTag("ecalDigis","EcalTriggerPrimitives"));
338  desc.add<bool>("recoverEEFE",true);
339  desc.add<std::string>("singleChannelRecoveryMethod","NeuralNetworks");
340  desc.add<double>("EBLaserMAX",3.0);
341  {
343  {
344  std::vector<std::string> temp2;
345  temp2.reserve(4);
346  temp2.push_back("kOk");
347  temp2.push_back("kDAC");
348  temp2.push_back("kNoLaser");
349  temp2.push_back("kNoisy");
350  psd0.add<std::vector<std::string> >("kGood",temp2);
351  }
352  {
353  std::vector<std::string> temp2;
354  temp2.reserve(3);
355  temp2.push_back("kFixedG0");
356  temp2.push_back("kNonRespondingIsolated");
357  temp2.push_back("kDeadVFE");
358  psd0.add<std::vector<std::string> >("kNeighboursRecovered",temp2);
359  }
360  {
361  std::vector<std::string> temp2;
362  temp2.reserve(1);
363  temp2.push_back("kNoDataNoTP");
364  psd0.add<std::vector<std::string> >("kDead",temp2);
365  }
366  {
367  std::vector<std::string> temp2;
368  temp2.reserve(3);
369  temp2.push_back("kNNoisy");
370  temp2.push_back("kFixedG6");
371  temp2.push_back("kFixedG1");
372  psd0.add<std::vector<std::string> >("kNoisy",temp2);
373  }
374  {
375  std::vector<std::string> temp2;
376  temp2.reserve(1);
377  temp2.push_back("kDeadFE");
378  psd0.add<std::vector<std::string> >("kTowerRecovered",temp2);
379  }
380  desc.add<edm::ParameterSetDescription>("flagsMapDBReco",psd0);
381  }
382  desc.add<edm::InputTag>("EBuncalibRecHitCollection",edm::InputTag("ecalMultiFitUncalibRecHit","EcalUncalibRecHitsEB"));
383  desc.add<std::string>("algoRecover","EcalRecHitWorkerRecover");
384  desc.add<std::string>("algo","EcalRecHitWorkerSimple");
385  desc.add<double>("EELaserMAX",8.0);
386  desc.add<double>("logWarningEtThreshold_EB_FE",50);
387  desc.add<bool>("recoverEEIsolatedChannels",false);
388  desc.add<bool>("skipTimeCalib",false);
389  descriptions.add("ecalRecHit",desc);
390 }
391 
#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_