CMS 3D CMS Logo

EcalDeadCellTriggerPrimitiveFilter.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: EcalDeadCellTriggerPrimitiveFilter
4 // Class: EcalDeadCellTriggerPrimitiveFilter
5 //
12 //
13 // Original Author: Hongxuan Liu and Kenichi Hatakeyama
14 // in collaboration with Konstantinos Theofilatos and Ulla Gebbert
15 
16 // system include files
17 #include <memory>
18 #include <fstream>
19 
20 // user include files
23 
26 
29 
32 
34 
40 
43 
48 
52 
56 
58 
59 // Geometry
64 
67 
69 
70 using namespace std;
71 
73 public:
76 
77 private:
78  void beginStream(edm::StreamID) override;
79  bool filter(edm::Event&, const edm::EventSetup&) override;
80  void beginRun(const edm::Run&, const edm::EventSetup&) override;
81  void envSet(const edm::EventSetup&);
82 
83  // ----------member data ---------------------------
84 
85  const bool taggingMode_;
86 
87  const bool debug_;
88  const int verbose_;
89 
90  const bool doEEfilter_;
91 
92 // Channel status related
95 
96  void loadEcalDigis(edm::Event& iEvent,
98  void loadEcalRecHits(edm::Event& iEvent,
99  edm::Handle<EcalRecHitCollection>& barrelReducedRecHitsHandle,
100  edm::Handle<EcalRecHitCollection>& endcapReducedRecHitsHandle);
101 
106 
108 
110 
111 // XXX: All the following can be built at the beginning of a job
112 // Store DetId <==> vector<double> (eta, phi, theta)
113  std::map<DetId, std::vector<double> > EcalAllDeadChannelsValMap;
114 // Store EB: DetId <==> vector<int> (subdet, ieta, iphi, status)
115 // Store EE: DetId <==> vector<int> (subdet, ix, iy, iz, status)
116  std::map<DetId, std::vector<int> > EcalAllDeadChannelsBitMap;
117 
118 // Store DetId <==> EcalTrigTowerDetId
119  std::map<DetId, EcalTrigTowerDetId> EcalAllDeadChannelsTTMap;
120 
121  int getChannelStatusMaps();
122 
123 // TP filter
124  const double etValToBeFlagged_;
125 
128 
129 // chnStatus > 0, then exclusive, i.e., only consider status == chnStatus
130 // chnStatus < 0, then inclusive, i.e., consider status >= abs(chnStatus)
131 // Return value: + : positive zside - : negative zside
132  int setEvtTPstatus(const EcalTrigPrimDigiCollection& , const double &tpCntCut, const int &chnStatus, EcalTPGScale& );
133 
134  const bool useTTsum_; //If set to true, the filter will compare the sum of the 5x5 tower to the provided energy threshold
135  const bool usekTPSaturated_; //If set to true, the filter will check the kTPSaturated flag
136 
137  int hasReducedRecHits_ = 0;
138 
139  bool useTPmethod_ = false;
140  bool useHITmethod_ = false;
141 
143 
144 // Only for EB since the dead front-end has one-to-one map to TT
145  std::map<EcalTrigTowerDetId, double> accuTTetMap;
146  std::map<EcalTrigTowerDetId, int> accuTTchnMap;
147  std::map<EcalTrigTowerDetId, int> TTzsideMap;
148 
149 // For EE, the one-to-one map to dead front-end is the SuperCrystal
150  std::map<EcalScDetId, double> accuSCetMap;
151  std::map<EcalScDetId, int> accuSCchnMap;
152  std::map<EcalScDetId, int> SCzsideMap;
153 
154 // To be used before a bug fix
155  std::vector<DetId> avoidDuplicateVec;
156  int setEvtRecHitstatus(const double &tpValCut, const int &chnStatus, const int &towerTest,
157  const EBRecHitCollection& HitecalEB,
158  const EERecHitCollection& HitecalEE);
159 
160 };
161 
162 //
163 // constructors and destructor
164 //
166  : taggingMode_ (iConfig.getParameter<bool>("taggingMode") )
167  , debug_ (iConfig.getParameter<bool>("debug") )
168  , verbose_ (iConfig.getParameter<int>("verbose") )
169  , doEEfilter_ (iConfig.getUntrackedParameter<bool>("doEEfilter") )
170  , ebReducedRecHitCollection_ (iConfig.getParameter<edm::InputTag>("ebReducedRecHitCollection") )
171  , eeReducedRecHitCollection_ (iConfig.getParameter<edm::InputTag>("eeReducedRecHitCollection") )
172  , maskedEcalChannelStatusThreshold_ (iConfig.getParameter<int>("maskedEcalChannelStatusThreshold") )
173  , etValToBeFlagged_ (iConfig.getParameter<double>("etValToBeFlagged") )
174  , tpDigiCollection_ (iConfig.getParameter<edm::InputTag>("tpDigiCollection") )
175  , tpDigiCollectionToken_(consumes<EcalTrigPrimDigiCollection>(tpDigiCollection_))
176  , useTTsum_ (iConfig.getParameter<bool>("useTTsum") )
177  , usekTPSaturated_ (iConfig.getParameter<bool>("usekTPSaturated") )
178  , putToken_ ( produces<bool>() )
179 {
181  // If TP is available, always use TP.
182  // In RECO file, we always have ecalTPSkim (at least from 38X for data and 39X for MC).
183  // In AOD file, we can only have recovered rechits in the reduced rechits collection after 42X
184  // Do NOT expect end-users provide ecalTPSkim or recovered rechits themselves!!
185  // If they really can provide them, they must be experts to modify this code to suit their own purpose :-)
186  if( iBranch.moduleLabel() == tpDigiCollection_.label() ){
187  useTPmethod_ = true;
188  //if both collections are in the job then we may already have seen the reduced collections
189  useHITmethod_ = false;
190  }
193  if(not useTPmethod_ && hasReducedRecHits_ == 2) {
194  useHITmethod_ = true;
195  ebReducedRecHitCollectionToken_ = consumes<EcalRecHitCollection>(ebReducedRecHitCollection_);
196  eeReducedRecHitCollectionToken_ = consumes<EcalRecHitCollection>(eeReducedRecHitCollection_);
197  }
198  }
199  });
200 }
201 
203 }
204 
206 
207  if( debug_ ) edm::LogInfo("EcalDeadCellTriggerPrimitiveFilter")<<"\nuseTPmethod_ : "<<useTPmethod_<<" hasReducedRecHits_ : "<<hasReducedRecHits_;
208 
209  if( not useTPmethod_ and not useHITmethod_){
210  if( debug_ ){
211  edm::LogInfo("EcalDeadCellTriggerPrimitiveFilter")<<"\nWARNING ... Cannot find either tpDigiCollection_ or reducedRecHitCollecion_ ?!";
212  edm::LogInfo("EcalDeadCellTriggerPrimitiveFilter")<<" Will NOT DO ANY FILTERING !";
213  }
214  }
215 
216  if( debug_ ) edm::LogInfo("EcalDeadCellTriggerPrimitiveFilter")<<"useTPmethod_ : "<<useTPmethod_<<" useHITmethod_ : "<<useHITmethod_;
217 
218 }
219 
221 
222  iEvent.getByToken(tpDigiCollectionToken_, pTPDigis);
223  if ( !pTPDigis.isValid() ) { edm::LogWarning("EcalDeadCellTriggerPrimitiveFilter") << "Can't get the product " << tpDigiCollection_.instance()
224  << " with label " << tpDigiCollection_.label(); return; }
225 }
226 
228  edm::Handle<EcalRecHitCollection>& barrelReducedRecHitsHandle,
229  edm::Handle<EcalRecHitCollection>& endcapReducedRecHitsHandle)
230 {
231 
232  iEvent.getByToken(ebReducedRecHitCollectionToken_,barrelReducedRecHitsHandle);
233  iEvent.getByToken(eeReducedRecHitCollectionToken_,endcapReducedRecHitsHandle);
234 
235 }
236 
237 //
238 // static data member definitions
239 //
240 
242 
243  if (debug_ && verbose_ >=2) edm::LogInfo("EcalDeadCellTriggerPrimitiveFilter") << "***envSet***";
244 
245  iSetup.get<IdealGeometryRecord>().get(ttMap_);
246 
247  iSetup.get<EcalChannelStatusRcd> ().get(ecalStatus);
248  iSetup.get<CaloGeometryRecord> ().get(geometry);
249 
250  if( !ecalStatus.isValid() ) throw "Failed to get ECAL channel status!";
251  if( !geometry.isValid() ) throw "Failed to get the geometry!";
252 
253 }
254 
255 // ------------ method called on each new Event ------------
257 
258  edm::RunNumber_t run = iEvent.id().run();
259  edm::EventNumber_t event = iEvent.id().event();
261 
262  bool pass = true;
263 
264  int evtTagged = 0;
265 
266 
267  if( useTPmethod_ ){
269  loadEcalDigis(iEvent, pTPDigis);
270 
271  EcalTPGScale ecalScale;
272  ecalScale.setEventSetup(iSetup);
273  evtTagged = setEvtTPstatus(*pTPDigis, etValToBeFlagged_, 13, ecalScale);
274  }
275 
276  if( useHITmethod_ ){
277  edm::Handle<EcalRecHitCollection> barrelReducedRecHitsHandle;
278  edm::Handle<EcalRecHitCollection> endcapReducedRecHitsHandle;
279  loadEcalRecHits(iEvent, barrelReducedRecHitsHandle, endcapReducedRecHitsHandle);
280  evtTagged = setEvtRecHitstatus(etValToBeFlagged_, 13, 13, *barrelReducedRecHitsHandle, *endcapReducedRecHitsHandle);
281  }
282 
283  if( evtTagged ){ pass = false; }
284 
285  if(debug_ && verbose_ >=2){
286  int evtstatusABS = abs(evtTagged);
287  printf("\nrun : %8u event : %10llu lumi : %4u evtTPstatus ABS : %d 13 : % 2d\n", run, event, ls, evtstatusABS, evtTagged);
288  }
289 
290  iEvent.emplace(putToken_, pass);
291 
292  if (taggingMode_) return true;
293  else return pass;
294 }
295 
296 // ------------ method called once each run just before starting event loop ------------
298 // Channel status might change for each run (data)
299 // Event setup
300  envSet(iSetup);
302  if( debug_ && verbose_ >=2) edm::LogInfo("EcalDeadCellTriggerPrimitiveFilter")<< "EcalAllDeadChannelsValMap.size() : "<<EcalAllDeadChannelsValMap.size()<<" EcalAllDeadChannelsBitMap.size() : "<<EcalAllDeadChannelsBitMap.size();
303  return ;
304 }
305 
306 int EcalDeadCellTriggerPrimitiveFilter::setEvtRecHitstatus(const double &tpValCut, const int &chnStatus, const int &towerTest,
307  const EBRecHitCollection& HitecalEB,
308  const EERecHitCollection& HitecalEE
309  ){
310 
311  if( debug_ && verbose_ >=2) edm::LogInfo("EcalDeadCellTriggerPrimitiveFilter")<<"***begin setEvtTPstatusRecHits***";
312 
313  accuTTetMap.clear(); accuTTchnMap.clear(); TTzsideMap.clear();
314  accuSCetMap.clear(); accuSCchnMap.clear(); SCzsideMap.clear();
315  avoidDuplicateVec.clear();
316 
317 /*
318  const EBRecHitCollection HitecalEB = *(barrelRecHitsHandle.product());
319  const EERecHitCollection HitecalEE = *(endcapRecHitsHandle.product());
320 */
321  int isPassCut =0;
322 
324 
325  for (ebrechit = HitecalEB.begin(); ebrechit != HitecalEB.end(); ebrechit++) {
326 
327  EBDetId det = ebrechit->id();
328 
329  std::map<DetId, vector<double> >::iterator valItor = EcalAllDeadChannelsValMap.find(det);
330  if( valItor == EcalAllDeadChannelsValMap.end() ) continue;
331 
332  double theta = valItor->second.back();
333 
334  std::map<DetId, vector<int> >::iterator bitItor = EcalAllDeadChannelsBitMap.find(det);
335  if( bitItor == EcalAllDeadChannelsBitMap.end() ) continue;
336 
337  std::map<DetId, EcalTrigTowerDetId>::iterator ttItor = EcalAllDeadChannelsTTMap.find(det);
338  if( ttItor == EcalAllDeadChannelsTTMap.end() ) continue;
339 
340  int status = bitItor->second.back();
341 
342  bool toDo = false;
343  if( chnStatus >0 && status == chnStatus ) toDo = true;
344  if( chnStatus <0 && status >= abs(chnStatus) ) toDo = true;
345 // This might be suitable for channels with status other than 13,
346 // since this function is written as a general one ...
347  if( !ebrechit->isRecovered() ) toDo = false;
348 // if( !ebrechit->checkFlag(EcalRecHit::kTowerRecovered) ) toDo = false;
349 
350 
351 
352  if( toDo ){
353 
354  //If we considerkTPSaturated and a recHit has a flag set, we can immediately flag the event.
355  if(ebrechit->checkFlag(EcalRecHit::kTPSaturated) && usekTPSaturated_) return 1;
356 
357  EcalTrigTowerDetId ttDetId = ttItor->second;
358  int ttzside = ttDetId.zside();
359 
360  std::vector<DetId> vid = ttMap_->constituentsOf(ttDetId);
361  int towerTestCnt =0;
362  for(std::vector<DetId>::const_iterator dit = vid.begin(); dit != vid.end(); ++dit ) {
363  std::map<DetId, vector<int> >::iterator bit2Itor = EcalAllDeadChannelsBitMap.find( (*dit) );
364  if( bit2Itor == EcalAllDeadChannelsBitMap.end() ){ towerTestCnt ++; continue; }
365  if( towerTest >0 && bit2Itor->second.back() == towerTest ) continue;
366  if( towerTest <0 && bit2Itor->second.back() >= abs(towerTest) ) continue;
367  towerTestCnt ++;
368  }
369  if( towerTestCnt !=0 && debug_ && verbose_ >=2) edm::LogInfo("EcalDeadCellTriggerPrimitiveFilter")<<"towerTestCnt : "<<towerTestCnt<<" for towerTest : "<<towerTest;
370 
371  std::vector<DetId>::iterator avoidItor; avoidItor = find( avoidDuplicateVec.begin(), avoidDuplicateVec.end(), det);
372  if( avoidItor == avoidDuplicateVec.end() ){
373  avoidDuplicateVec.push_back(det);
374  }else{
375  continue;
376  }
377 
378  std::map<EcalTrigTowerDetId, double>::iterator ttetItor = accuTTetMap.find(ttDetId);
379  if( ttetItor == accuTTetMap.end() ){
380  accuTTetMap[ttDetId] = ebrechit->energy()*sin(theta);
381  accuTTchnMap[ttDetId] = 1;
382  TTzsideMap[ttDetId] = ttzside;
383  }else{
384  accuTTetMap[ttDetId] += ebrechit->energy()*sin(theta);
385  accuTTchnMap[ttDetId] ++;
386  }
387  }
388  } // loop over EB
389 
391  for (eerechit = HitecalEE.begin(); eerechit != HitecalEE.end(); eerechit++) {
392 
393  EEDetId det = eerechit->id();
394 
395  std::map<DetId, vector<double> >::iterator valItor = EcalAllDeadChannelsValMap.find(det);
396  if( valItor == EcalAllDeadChannelsValMap.end() ) continue;
397 
398  double theta = valItor->second.back();
399 
400  std::map<DetId, vector<int> >::iterator bitItor = EcalAllDeadChannelsBitMap.find(det);
401  if( bitItor == EcalAllDeadChannelsBitMap.end() ) continue;
402 
403  std::map<DetId, EcalTrigTowerDetId>::iterator ttItor = EcalAllDeadChannelsTTMap.find(det);
404  if( ttItor == EcalAllDeadChannelsTTMap.end() ) continue;
405 
406  int status = bitItor->second.back();
407 
408  bool toDo = false;
409  if( chnStatus >0 && status == chnStatus ) toDo = true;
410  if( chnStatus <0 && status >= abs(chnStatus) ) toDo = true;
411 // This might be suitable for channels with status other than 13,
412 // since this function is written as a general one ...
413  if( !eerechit->isRecovered() ) toDo = false;
414 // if( !eerechit->checkFlag(EcalRecHit::kTowerRecovered) ) toDo = false;
415 
416  if( toDo ){
417 
418  //If we considerkTPSaturated and a recHit has a flag set, we can immediately flag the event.
419  if(eerechit->checkFlag(EcalRecHit::kTPSaturated) && usekTPSaturated_) return 1;
420 
421 // vvvv= Only for debuging or testing purpose =vvvv
422  EcalTrigTowerDetId ttDetId = ttItor->second;
423 // int ttzside = ttDetId.zside();
424 
425  std::vector<DetId> vid = ttMap_->constituentsOf(ttDetId);
426  int towerTestCnt =0;
427  for(std::vector<DetId>::const_iterator dit = vid.begin(); dit != vid.end(); ++dit ) {
428  std::map<DetId, vector<int> >::iterator bit2Itor = EcalAllDeadChannelsBitMap.find( (*dit) );
429  if( bit2Itor == EcalAllDeadChannelsBitMap.end() ){ towerTestCnt ++; continue; }
430  if( towerTest >0 && bit2Itor->second.back() == towerTest ) continue;
431  if( towerTest <0 && bit2Itor->second.back() >= abs(towerTest) ) continue;
432  towerTestCnt ++;
433  }
434  if( towerTestCnt !=0 && debug_ && verbose_ >=2) edm::LogInfo("EcalDeadCellTriggerPrimitiveFilter")<<"towerTestCnt : "<<towerTestCnt<<" for towerTest : "<<towerTest;
435 // ^^^^= END =^^^^
436 
437  EcalScDetId sc( (det.ix()-1)/5+1, (det.iy()-1)/5+1, det.zside() );
438 
439  std::vector<DetId>::iterator avoidItor; avoidItor = find( avoidDuplicateVec.begin(), avoidDuplicateVec.end(), det);
440  if( avoidItor == avoidDuplicateVec.end() ){
441  avoidDuplicateVec.push_back(det);
442  }else{
443  continue;
444  }
445 
446  std::map<EcalScDetId, double>::iterator scetItor = accuSCetMap.find(sc);
447  if( scetItor == accuSCetMap.end() ){
448  accuSCetMap[sc] = eerechit->energy()*sin(theta);
449  accuSCchnMap[sc] = 1;
450  SCzsideMap[sc] = sc.zside();
451  }else{
452  accuSCetMap[sc] += eerechit->energy()*sin(theta);
453  accuSCchnMap[sc] ++;
454  }
455  }
456  } // loop over EE
457 
458  //If we are not using the TT sum, then at this point we need not do anything further, we'll pass the event
459  if(!useTTsum_) return 0;
460 
461 // Checking for EB
462  std::map<EcalTrigTowerDetId, double>::iterator ttetItor;
463  for( ttetItor = accuTTetMap.begin(); ttetItor != accuTTetMap.end(); ttetItor++){
464 
465  EcalTrigTowerDetId ttDetId = ttetItor->first;
466 
467  double ttetVal = ttetItor->second;
468 
469  std::map<EcalTrigTowerDetId, int>::iterator ttchnItor = accuTTchnMap.find(ttDetId);
470  if( ttchnItor == accuTTchnMap.end() ){ edm::LogError("EcalDeadCellTriggerPrimitiveFilter")<<"\nERROR cannot find ttDetId : "<<ttDetId<<" in accuTTchnMap?!"; }
471 
472  std::map<EcalTrigTowerDetId, int>::iterator ttzsideItor = TTzsideMap.find(ttDetId);
473  if( ttzsideItor == TTzsideMap.end() ){ edm::LogError("EcalDeadCellTriggerPrimitiveFilter")<<"\nERROR cannot find ttDetId : "<<ttDetId<<" in TTzsideMap?!"; }
474 
475  if( ttchnItor->second != 25 && debug_ && verbose_ >=2) edm::LogInfo("EcalDeadCellTriggerPrimitiveFilter")<<"WARNING ... ttchnCnt : "<<ttchnItor->second<<" NOT equal 25!";
476 
477  if( ttetVal >= tpValCut ){ isPassCut = 1; isPassCut *= ttzsideItor->second; }
478 
479  }
480 
481 // Checking for EE
482  std::map<EcalScDetId, double>::iterator scetItor;
483  for( scetItor = accuSCetMap.begin(); scetItor != accuSCetMap.end(); scetItor++){
484 
485  EcalScDetId scDetId = scetItor->first;
486 
487  double scetVal = scetItor->second;
488 
489  std::map<EcalScDetId, int>::iterator scchnItor = accuSCchnMap.find(scDetId);
490  if( scchnItor == accuSCchnMap.end() ){ edm::LogError("EcalDeadCellTriggerPrimitiveFilter")<<"\nERROR cannot find scDetId : "<<scDetId<<" in accuSCchnMap?!"; }
491 
492  std::map<EcalScDetId, int>::iterator sczsideItor = SCzsideMap.find(scDetId);
493  if( sczsideItor == SCzsideMap.end() ){ edm::LogError("EcalDeadCellTriggerPrimitiveFilter")<<"\nERROR cannot find scDetId : "<<scDetId<<" in SCzsideMap?!"; }
494 
495  if( scchnItor->second != 25 && debug_ && verbose_ >=2) edm::LogInfo("EcalDeadCellTriggerPrimitiveFilter")<<"WARNING ... scchnCnt : "<<scchnItor->second<<" NOT equal 25!";
496 
497  if( scetVal >= tpValCut ){ isPassCut = 1; isPassCut *= sczsideItor->second; }
498 
499  }
500 
501  if( debug_ && verbose_ >=2) edm::LogInfo("EcalDeadCellTriggerPrimitiveFilter")<<"***end setEvtTPstatusRecHits***";
502 
503  return isPassCut;
504 
505 }
506 
507 
508 int EcalDeadCellTriggerPrimitiveFilter::setEvtTPstatus(EcalTrigPrimDigiCollection const& tpDigis, const double &tpValCut, const int &chnStatus, EcalTPGScale& ecalScale) {
509 
510  if( debug_ && verbose_ >=2) edm::LogInfo("EcalDeadCellTriggerPrimitiveFilter")<<"***begin setEvtTPstatus***";
511 
512  int isPassCut =0;
513 
514  std::map<DetId, std::vector<int> >::iterator bitItor;
515  for(bitItor = EcalAllDeadChannelsBitMap.begin(); bitItor != EcalAllDeadChannelsBitMap.end(); bitItor++){
516 
517  DetId maskedDetId = bitItor->first;
518  int subdet = bitItor->second.front(), status = bitItor->second.back();
519 
520 // if NOT filtering on EE, skip EE subdet
521  if( !doEEfilter_ && subdet != 1 ) continue;
522 
523  std::map<DetId, EcalTrigTowerDetId>::iterator ttItor = EcalAllDeadChannelsTTMap.find(maskedDetId);
524  if( ttItor == EcalAllDeadChannelsTTMap.end() ) continue;
525 
526  bool toDo = false;
527  if( chnStatus >0 && status == chnStatus ) toDo = true;
528  if( chnStatus <0 && status >= abs(chnStatus) ) toDo = true;
529 
530  if( toDo ){
531 
532  EcalTrigTowerDetId ttDetId = ttItor->second;
533  int ttzside = ttDetId.zside();
534 
535  EcalTrigPrimDigiCollection::const_iterator tp = tpDigis.find( ttDetId );
536  if( tp != tpDigis.end() ){
537  double tpEt = ecalScale.getTPGInGeV( tp->compressedEt(), tp->id() );
538  if(tpEt >= tpValCut ){ isPassCut = 1; isPassCut *= ttzside; }
539  }
540  }
541  } // loop over EB + EE
542 
543  if( debug_ && verbose_ >=2) edm::LogInfo("EcalDeadCellTriggerPrimitiveFilter")<<"***end setEvtTPstatus***";
544 
545  return isPassCut;
546 }
547 
548 
550 
552 
553 // Loop over EB ...
554  for( int ieta=-85; ieta<=85; ieta++ ){
555  for( int iphi=0; iphi<=360; iphi++ ){
556  if(! EBDetId::validDetId( ieta, iphi ) ) continue;
557 
558  const EBDetId detid = EBDetId( ieta, iphi, EBDetId::ETAPHIMODE );
559  EcalChannelStatus::const_iterator chit = ecalStatus->find( detid );
560 // refer https://twiki.cern.ch/twiki/bin/viewauth/CMS/EcalChannelStatus
561  int status = ( chit != ecalStatus->end() ) ? chit->getStatusCode() & 0x1F : -1;
562 
563  const CaloSubdetectorGeometry* subGeom = geometry->getSubdetectorGeometry (detid);
564  auto cellGeom = subGeom->getGeometry (detid);
565  double eta = cellGeom->getPosition ().eta ();
566  double phi = cellGeom->getPosition ().phi ();
567  double theta = cellGeom->getPosition().theta();
568 
569  if(status >= maskedEcalChannelStatusThreshold_){
570  std::vector<double> valVec; std::vector<int> bitVec;
571  valVec.push_back(eta); valVec.push_back(phi); valVec.push_back(theta);
572  bitVec.push_back(1); bitVec.push_back(ieta); bitVec.push_back(iphi); bitVec.push_back(status);
573  EcalAllDeadChannelsValMap.insert( std::make_pair(detid, valVec) );
574  EcalAllDeadChannelsBitMap.insert( std::make_pair(detid, bitVec) );
575  }
576  } // end loop iphi
577  } // end loop ieta
578 
579 // Loop over EE detid
580  if (doEEfilter_) {
581  for( int ix=0; ix<=100; ix++ ){
582  for( int iy=0; iy<=100; iy++ ){
583  for( int iz=-1; iz<=1; iz++ ){
584  if(iz==0) continue;
585  if(! EEDetId::validDetId( ix, iy, iz ) ) continue;
586 
587  const EEDetId detid = EEDetId( ix, iy, iz, EEDetId::XYMODE );
588  EcalChannelStatus::const_iterator chit = ecalStatus->find( detid );
589  int status = ( chit != ecalStatus->end() ) ? chit->getStatusCode() & 0x1F : -1;
590 
591  const CaloSubdetectorGeometry* subGeom = geometry->getSubdetectorGeometry (detid);
592  auto cellGeom = subGeom->getGeometry (detid);
593  double eta = cellGeom->getPosition ().eta () ;
594  double phi = cellGeom->getPosition ().phi () ;
595  double theta = cellGeom->getPosition().theta();
596 
597  if(status >= maskedEcalChannelStatusThreshold_){
598  std::vector<double> valVec; std::vector<int> bitVec;
599  valVec.push_back(eta); valVec.push_back(phi); valVec.push_back(theta);
600  bitVec.push_back(2); bitVec.push_back(ix); bitVec.push_back(iy); bitVec.push_back(iz); bitVec.push_back(status);
601  EcalAllDeadChannelsValMap.insert( std::make_pair(detid, valVec) );
602  EcalAllDeadChannelsBitMap.insert( std::make_pair(detid, bitVec) );
603  }
604  } // end loop iz
605  } // end loop iy
606  } // end loop ix
607  }
608 
609  EcalAllDeadChannelsTTMap.clear();
610  std::map<DetId, std::vector<int> >::iterator bitItor;
611  for(bitItor = EcalAllDeadChannelsBitMap.begin(); bitItor != EcalAllDeadChannelsBitMap.end(); bitItor++){
612  const DetId id = bitItor->first;
613  EcalTrigTowerDetId ttDetId = ttMap_->towerOf(id);
614  EcalAllDeadChannelsTTMap.insert(std::make_pair(id, ttDetId) );
615  }
616 
617  return 1;
618 }
619 
620 
621 //define this as a plug-in
RunNumber_t run() const
Definition: EventID.h:39
void callWhenNewProductsRegistered(std::function< void(BranchDescription const &)> const &func)
Definition: ProducerBase.h:79
EventNumber_t event() const
Definition: EventID.h:41
edm::EDGetTokenT< EcalRecHitCollection > ebReducedRecHitCollectionToken_
std::map< DetId, std::vector< int > > EcalAllDeadChannelsBitMap
int ix() const
Definition: EEDetId.h:77
void setEventSetup(const edm::EventSetup &evtSetup)
Definition: EcalTPGScale.cc:19
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:517
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
static const int XYMODE
Definition: EEDetId.h:335
std::vector< EcalRecHit >::const_iterator const_iterator
Geom::Theta< T > theta() const
unsigned long long EventNumber_t
edm::LuminosityBlockNumber_t luminosityBlock() const
Definition: EventBase.h:61
double getTPGInGeV(const EcalTriggerPrimitiveDigi &tpDigi)
Definition: EcalTPGScale.cc:24
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:20
std::map< EcalTrigTowerDetId, int > accuTTchnMap
void loadEcalDigis(edm::Event &iEvent, edm::Handle< EcalTrigPrimDigiCollection > &pTPDigis)
unsigned int LuminosityBlockNumber_t
EcalTrigTowerDetId towerOf(const DetId &id) const
Get the tower id for this det id (or null if not known)
int zside() const
get the z-side of the tower (1/-1)
static bool validDetId(int i, int j)
check if a valid index combination
Definition: EBDetId.h:118
return((rh^lh)&mask)
U second(std::pair< T, U > const &p)
edm::EDGetTokenT< EcalRecHitCollection > eeReducedRecHitCollectionToken_
int iEvent
Definition: GenABIO.cc:224
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
std::string const & moduleLabel() const
int zside() const
Definition: EEDetId.h:71
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
int iy() const
Definition: EEDetId.h:83
bool isValid() const
Definition: HandleBase.h:74
std::vector< DetId > constituentsOf(const EcalTrigTowerDetId &id) const
Get the constituent detids for this tower id.
static const int ETAPHIMODE
Definition: EBDetId.h:158
edm::ESHandle< EcalTrigTowerConstituentsMap > ttMap_
const_iterator end() const
int setEvtRecHitstatus(const double &tpValCut, const int &chnStatus, const int &towerTest, const EBRecHitCollection &HitecalEB, const EERecHitCollection &HitecalEE)
Definition: DetId.h:18
def ls(path, rec=False)
Definition: eostools.py:349
std::map< EcalTrigTowerDetId, double > accuTTetMap
std::map< DetId, std::vector< double > > EcalAllDeadChannelsValMap
OrphanHandle< PROD > emplace(EDPutTokenT< PROD > token, Args &&...args)
puts a new product
Definition: Event.h:413
virtual std::shared_ptr< const CaloCellGeometry > getGeometry(const DetId &id) const
Get the cell geometry of a given detector id. Should return false if not found.
static bool validDetId(int crystal_ix, int crystal_iy, int iz)
Definition: EEDetId.h:248
std::vector< Item >::const_iterator const_iterator
int setEvtTPstatus(const EcalTrigPrimDigiCollection &, const double &tpCntCut, const int &chnStatus, EcalTPGScale &)
bool filter(edm::Event &, const edm::EventSetup &) override
void beginRun(const edm::Run &, const edm::EventSetup &) override
std::string const & label() const
Definition: InputTag.h:36
edm::EventID id() const
Definition: EventBase.h:59
iterator find(key_type k)
HLT enums.
T get() const
Definition: EventSetup.h:71
edm::EDGetTokenT< EcalTrigPrimDigiCollection > tpDigiCollectionToken_
std::map< EcalTrigTowerDetId, int > TTzsideMap
unsigned int RunNumber_t
std::map< DetId, EcalTrigTowerDetId > EcalAllDeadChannelsTTMap
std::string const & instance() const
Definition: InputTag.h:37
const_iterator begin() const
Definition: event.py:1
Definition: Run.h:45
void loadEcalRecHits(edm::Event &iEvent, edm::Handle< EcalRecHitCollection > &barrelReducedRecHitsHandle, edm::Handle< EcalRecHitCollection > &endcapReducedRecHitsHandle)