CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 
31 
33 
39 
42 
47 
51 
55 
57 
58 // Geometry
63 
66 
68 
69 #include "TFile.h"
70 #include "TTree.h"
71 
72 using namespace std;
73 
75 public:
78 
79 private:
80  virtual bool filter(edm::Event&, const edm::EventSetup&) override;
81  virtual void beginJob() override;
82  virtual void endJob() override;
83  virtual void beginRun(const edm::Run&, const edm::EventSetup&) override;
84  virtual void envSet(const edm::EventSetup&);
85 
86  // ----------member data ---------------------------
87 
88  const bool taggingMode_;
89 
90  const bool debug_;
91  const int verbose_;
92 
93  const bool doEEfilter_;
94 
95 // Channel status related
98 
99  void loadEcalDigis(edm::Event& iEvent, const edm::EventSetup& iSetup);
100  void loadEcalRecHits(edm::Event& iEvent, const edm::EventSetup& iSetup);
101 
108 
110 
112 
114 
115 // XXX: All the following can be built at the beginning of a job
116 // Store DetId <==> vector<double> (eta, phi, theta)
117  std::map<DetId, std::vector<double> > EcalAllDeadChannelsValMap;
118 // Store EB: DetId <==> vector<int> (subdet, ieta, iphi, status)
119 // Store EE: DetId <==> vector<int> (subdet, ix, iy, iz, status)
120  std::map<DetId, std::vector<int> > EcalAllDeadChannelsBitMap;
121 
122 // Store DetId <==> EcalTrigTowerDetId
123  std::map<DetId, EcalTrigTowerDetId> EcalAllDeadChannelsTTMap;
124 
125  int getChannelStatusMaps();
126 
127 // TP filter
128  const double etValToBeFlagged_;
129 
133 
134 // chnStatus > 0, then exclusive, i.e., only consider status == chnStatus
135 // chnStatus < 0, then inclusive, i.e., consider status >= abs(chnStatus)
136 // Return value: + : positive zside - : negative zside
137  int setEvtTPstatus(const double &tpCntCut, const int &chnStatus);
138 
139  int evtProcessedCnt, totFilteredCnt;
140 
141  const bool makeProfileRoot_;
143  TFile *profFile;
144  TTree *profTree;
145 
146  std::vector<int> *cutFlowFlagTmpPtr;
147  std::vector<std::string> *cutFlowStrTmpPtr;
148 
149  void loadEventInfo(const edm::Event& iEvent, const edm::EventSetup& iSetup);
153 
155 
157  int hastpDigiCollection_, hasReducedRecHits_;
158 
159  bool useTPmethod_, useHITmethod_;
160 
161  void loadEventInfoForFilter(const edm::Event& iEvent);
162 
163 // Only for EB since the dead front-end has one-to-one map to TT
164  std::map<EcalTrigTowerDetId, double> accuTTetMap;
165  std::map<EcalTrigTowerDetId, int> accuTTchnMap;
166  std::map<EcalTrigTowerDetId, int> TTzsideMap;
167 
168 // For EE, the one-to-one map to dead front-end is the SuperCrystal
169  std::map<EcalScDetId, double> accuSCetMap;
170  std::map<EcalScDetId, int> accuSCchnMap;
171  std::map<EcalScDetId, int> SCzsideMap;
172 
173 // To be used before a bug fix
174  std::vector<DetId> avoidDuplicateVec;
175  int setEvtRecHitstatus(const double &tpValCut, const int &chnStatus, const int &towerTest);
176 
177 };
178 
179 //
180 // constructors and destructor
181 //
183  : taggingMode_ (iConfig.getParameter<bool>("taggingMode") )
184  , debug_ (iConfig.getParameter<bool>("debug") )
185  , verbose_ (iConfig.getParameter<int>("verbose") )
186  , doEEfilter_ (iConfig.getUntrackedParameter<bool>("doEEfilter") )
187  , ebReducedRecHitCollection_ (iConfig.getParameter<edm::InputTag>("ebReducedRecHitCollection") )
188  , eeReducedRecHitCollection_ (iConfig.getParameter<edm::InputTag>("eeReducedRecHitCollection") )
189  , ebReducedRecHitCollectionToken_ (consumes<EcalRecHitCollection>(ebReducedRecHitCollection_))
190  , eeReducedRecHitCollectionToken_ (consumes<EcalRecHitCollection>(eeReducedRecHitCollection_))
191  , maskedEcalChannelStatusThreshold_ (iConfig.getParameter<int>("maskedEcalChannelStatusThreshold") )
192  , etValToBeFlagged_ (iConfig.getParameter<double>("etValToBeFlagged") )
193  , tpDigiCollection_ (iConfig.getParameter<edm::InputTag>("tpDigiCollection") )
194  , tpDigiCollectionToken_(consumes<EcalTrigPrimDigiCollection>(tpDigiCollection_))
195  , makeProfileRoot_ (iConfig.getUntrackedParameter<bool>("makeProfileRoot") )
196  , profileRootName_ (iConfig.getUntrackedParameter<std::string>("profileRootName") )
197 {
200  useTPmethod_ = true; useHITmethod_ = false;
201 
202  if( makeProfileRoot_ ){
203 
204  profFile = new TFile(profileRootName_.c_str(), "RECREATE");
205  profTree = new TTree("filter", "filter profile");
206  profTree->Branch("run", &run, "run/I");
207  profTree->Branch("event", &event, "event/I");
208  profTree->Branch("lumi", &ls, "lumi/I");
209  profTree->Branch("cutFlowFlag", &cutFlowFlagTmpPtr);
210  profTree->Branch("cutFlowStr", &cutFlowStrTmpPtr);
211 
212  }
213 
214  produces<bool>();
215 }
216 
218 
219  if( makeProfileRoot_ ){
220  profFile->cd();
221  profTree->Write();
222  delete profTree;
223  profFile->Close();
224  delete profFile;
225  }
226 
227 }
228 
230 
231  std::vector<edm::Provenance const*> provenances;
232  iEvent.getAllProvenance(provenances);
233  const unsigned int nProvenance = provenances.size();
234  for (unsigned int ip = 0; ip < nProvenance; ip++) {
235  const edm::Provenance& provenance = *( provenances[ip] );
236  if( provenance.moduleLabel().data() == tpDigiCollection_.label() ){ hastpDigiCollection_ = 1; }
237  if( provenance.moduleLabel().data() == ebReducedRecHitCollection_.label() || provenance.moduleLabel().data() == eeReducedRecHitCollection_.label() ){
238  hasReducedRecHits_++;
239  }
240  if( hastpDigiCollection_ && hasReducedRecHits_>=2 ){ break; }
241  }
242 
243  if( debug_ ) std::cout<<"\nhastpDigiCollection_ : "<<hastpDigiCollection_<<" hasReducedRecHits_ : "<<hasReducedRecHits_<<std::endl;
244 
245  const edm::ProcessHistory& history = iEvent.processHistory();
246  const unsigned int nHist = history.size();
247 // XXX: the last one is usually a USER process!
248  releaseVersion_ = history[nHist-2].releaseVersion();
249  TString tmpTstr(releaseVersion_);
250  TObjArray * split = tmpTstr.Tokenize("_");
251  int majorV = TString(split->At(1)->GetName()).Atoi();
252  int minorV = TString(split->At(2)->GetName()).Atoi();
253 
254  if( debug_ ) std::cout<<"processName : "<<history[nHist-2].processName().data()<<" releaseVersion : "<<releaseVersion_<<std::endl;
255 
256 // If TP is available, always use TP.
257 // In RECO file, we always have ecalTPSkim (at least from 38X for data and 39X for MC).
258 // In AOD file, we can only have recovered rechits in the reduced rechits collection after 42X
259 // Do NOT expect end-users provide ecalTPSkim or recovered rechits themselves!!
260 // If they really can provide them, they must be experts to modify this code to suit their own purpose :-)
261  if( !hastpDigiCollection_ && !hasReducedRecHits_ ){ useTPmethod_ = false; useHITmethod_ = false;
262  if( debug_ ){
263  std::cout<<"\nWARNING ... Cannot find either tpDigiCollection_ or reducedRecHitCollecion_ ?!"<<std::endl;
264  std::cout<<" Will NOT DO ANY FILTERING !"<<std::endl;
265  }
266  }
267  else if( hastpDigiCollection_ ){ useTPmethod_ = true; useHITmethod_ = false; }
268 // else if( majorV >=4 && minorV >=2 ){ useTPmethod_ = false; useHITmethod_ = true; }
269  else if( majorV >=5 || (majorV==4 && minorV >=2) ){ useTPmethod_ = false; useHITmethod_ = true; }
270  else{ useTPmethod_ = false; useHITmethod_ = false;
271  if( debug_ ){
272  std::cout<<"\nWARNING ... TP filter can ONLY be used in AOD after 42X"<<std::endl;
273  std::cout<<" Will NOT DO ANY FILTERING !"<<std::endl;
274  }
275  }
276 
277  if( debug_ ) std::cout<<"useTPmethod_ : "<<useTPmethod_<<" useHITmethod_ : "<<useHITmethod_<<std::endl;
278 
279  getEventInfoForFilterOnce_ = true;
280 
281 }
282 
283 
285  run = iEvent.id().run();
286  event = iEvent.id().event();
287  ls = iEvent.luminosityBlock();
288 }
289 
290 
292 
293  iEvent.getByToken(tpDigiCollectionToken_, pTPDigis);
294  if ( !pTPDigis.isValid() ) { edm::LogWarning("EcalDeadCellTriggerPrimitiveFilter") << "Can't get the product " << tpDigiCollection_.instance()
295  << " with label " << tpDigiCollection_.label(); return; }
296 }
297 
299 
300  iEvent.getByToken(ebReducedRecHitCollectionToken_,barrelReducedRecHitsHandle);
301  iEvent.getByToken(eeReducedRecHitCollectionToken_,endcapReducedRecHitsHandle);
302 
303 }
304 
305 //
306 // static data member definitions
307 //
308 
310 
311  if (debug_ && verbose_ >=2) std::cout << "***envSet***" << std::endl;
312 
313  ecalScale_.setEventSetup( iSetup );
314  iSetup.get<IdealGeometryRecord>().get(ttMap_);
315 
316  iSetup.get<EcalChannelStatusRcd> ().get(ecalStatus);
317  iSetup.get<CaloGeometryRecord> ().get(geometry);
318 
319  if( !ecalStatus.isValid() ) throw "Failed to get ECAL channel status!";
320  if( !geometry.isValid() ) throw "Failed to get the geometry!";
321 
322 }
323 
324 // ------------ method called on each new Event ------------
326 
327  std::vector<int> cutFlowFlagTmpVec; std::vector<std::string> cutFlowStrTmpVec;
328 
329  loadEventInfo(iEvent, iSetup);
330 
331  if( !getEventInfoForFilterOnce_ ){ loadEventInfoForFilter(iEvent); }
332 
333  evtProcessedCnt++;
334 
335  bool pass = true;
336 
337  int evtTagged = 0;
338 
339  if( useTPmethod_ ){
340  loadEcalDigis(iEvent, iSetup);
341  evtTagged = setEvtTPstatus(etValToBeFlagged_, 13);
342  }
343 
344  if( useHITmethod_ ){
345  loadEcalRecHits(iEvent, iSetup);
346  evtTagged = setEvtRecHitstatus(etValToBeFlagged_, 13, 13);
347  }
348 
349  if( evtTagged ){ pass = false; totFilteredCnt++; }
350 
351  if( makeProfileRoot_ ){
352 
353  cutFlowFlagTmpVec.push_back(evtTagged); cutFlowStrTmpVec.push_back("TP");
354 
355  cutFlowFlagTmpPtr = &cutFlowFlagTmpVec;
356  cutFlowStrTmpPtr = &cutFlowStrTmpVec;
357 
358  profTree->Fill();
359  }
360 
361  if(debug_ && verbose_ >=2){
362  int evtstatusABS = abs(evtTagged);
363  printf("\nrun : %8u event : %10llu lumi : %4u evtTPstatus ABS : %d 13 : % 2d\n", run, event, ls, evtstatusABS, evtTagged);
364  }
365 
366  std::auto_ptr<bool> pOut( new bool(pass) );
367  iEvent.put( pOut );
368 
369  if (taggingMode_) return true;
370  else return pass;
371 }
372 
373 // ------------ method called once each job just before starting event loop ------------
375  evtProcessedCnt = 0;
376  totFilteredCnt = 0;
377 }
378 
379 // ------------ method called once each job just after ending the event loop ------------
381 }
382 
383 // ------------ method called once each run just before starting event loop ------------
385 // Channel status might change for each run (data)
386 // Event setup
387  envSet(iSetup);
388  getChannelStatusMaps();
389  if( debug_ && verbose_ >=2) std::cout<< "EcalAllDeadChannelsValMap.size() : "<<EcalAllDeadChannelsValMap.size()<<" EcalAllDeadChannelsBitMap.size() : "<<EcalAllDeadChannelsBitMap.size()<<std::endl;
390  return ;
391 }
392 
393 int EcalDeadCellTriggerPrimitiveFilter::setEvtRecHitstatus(const double &tpValCut, const int &chnStatus, const int &towerTest){
394 
395  if( debug_ && verbose_ >=2) std::cout<<"***begin setEvtTPstatusRecHits***"<<std::endl;
396 
397  accuTTetMap.clear(); accuTTchnMap.clear(); TTzsideMap.clear();
398  accuSCetMap.clear(); accuSCchnMap.clear(); SCzsideMap.clear();
399  avoidDuplicateVec.clear();
400 
401 /*
402  const EBRecHitCollection HitecalEB = *(barrelRecHitsHandle.product());
403  const EERecHitCollection HitecalEE = *(endcapRecHitsHandle.product());
404 */
405  const EBRecHitCollection HitecalEB = *(barrelReducedRecHitsHandle.product());
406  const EERecHitCollection HitecalEE = *(endcapReducedRecHitsHandle.product());
407 
408  int isPassCut =0;
409 
411  for (ebrechit = HitecalEB.begin(); ebrechit != HitecalEB.end(); ebrechit++) {
412 
413  EBDetId det = ebrechit->id();
414 
415  std::map<DetId, vector<double> >::iterator valItor = EcalAllDeadChannelsValMap.find(det);
416  if( valItor == EcalAllDeadChannelsValMap.end() ) continue;
417 
418  double theta = valItor->second.back();
419 
420  std::map<DetId, vector<int> >::iterator bitItor = EcalAllDeadChannelsBitMap.find(det);
421  if( bitItor == EcalAllDeadChannelsBitMap.end() ) continue;
422 
423  std::map<DetId, EcalTrigTowerDetId>::iterator ttItor = EcalAllDeadChannelsTTMap.find(det);
424  if( ttItor == EcalAllDeadChannelsTTMap.end() ) continue;
425 
426  int status = bitItor->second.back();
427 
428  bool toDo = false;
429  if( chnStatus >0 && status == chnStatus ) toDo = true;
430  if( chnStatus <0 && status >= abs(chnStatus) ) toDo = true;
431 // This might be suitable for channels with status other than 13,
432 // since this function is written as a general one ...
433  if( !ebrechit->isRecovered() ) toDo = false;
434 // if( !ebrechit->checkFlag(EcalRecHit::kTowerRecovered) ) toDo = false;
435 
436  if( toDo ){
437 
438  EcalTrigTowerDetId ttDetId = ttItor->second;
439  int ttzside = ttDetId.zside();
440 
441  std::vector<DetId> vid = ttMap_->constituentsOf(ttDetId);
442  int towerTestCnt =0;
443  for(std::vector<DetId>::const_iterator dit = vid.begin(); dit != vid.end(); ++dit ) {
444  std::map<DetId, vector<int> >::iterator bit2Itor = EcalAllDeadChannelsBitMap.find( (*dit) );
445  if( bit2Itor == EcalAllDeadChannelsBitMap.end() ){ towerTestCnt ++; continue; }
446  if( towerTest >0 && bit2Itor->second.back() == towerTest ) continue;
447  if( towerTest <0 && bit2Itor->second.back() >= abs(towerTest) ) continue;
448  towerTestCnt ++;
449  }
450  if( towerTestCnt !=0 && debug_ && verbose_ >=2) std::cout<<"towerTestCnt : "<<towerTestCnt<<" for towerTest : "<<towerTest<<std::endl;
451 
452  std::vector<DetId>::iterator avoidItor; avoidItor = find( avoidDuplicateVec.begin(), avoidDuplicateVec.end(), det);
453  if( avoidItor == avoidDuplicateVec.end() ){
454  avoidDuplicateVec.push_back(det);
455  }else{
456  continue;
457  }
458 
459  std::map<EcalTrigTowerDetId, double>::iterator ttetItor = accuTTetMap.find(ttDetId);
460  if( ttetItor == accuTTetMap.end() ){
461  accuTTetMap[ttDetId] = ebrechit->energy()*sin(theta);
462  accuTTchnMap[ttDetId] = 1;
463  TTzsideMap[ttDetId] = ttzside;
464  }else{
465  accuTTetMap[ttDetId] += ebrechit->energy()*sin(theta);
466  accuTTchnMap[ttDetId] ++;
467  }
468  }
469  } // loop over EB
470 
472  for (eerechit = HitecalEE.begin(); eerechit != HitecalEE.end(); eerechit++) {
473 
474  EEDetId det = eerechit->id();
475 
476  std::map<DetId, vector<double> >::iterator valItor = EcalAllDeadChannelsValMap.find(det);
477  if( valItor == EcalAllDeadChannelsValMap.end() ) continue;
478 
479  double theta = valItor->second.back();
480 
481  std::map<DetId, vector<int> >::iterator bitItor = EcalAllDeadChannelsBitMap.find(det);
482  if( bitItor == EcalAllDeadChannelsBitMap.end() ) continue;
483 
484  std::map<DetId, EcalTrigTowerDetId>::iterator ttItor = EcalAllDeadChannelsTTMap.find(det);
485  if( ttItor == EcalAllDeadChannelsTTMap.end() ) continue;
486 
487  int status = bitItor->second.back();
488 
489  bool toDo = false;
490  if( chnStatus >0 && status == chnStatus ) toDo = true;
491  if( chnStatus <0 && status >= abs(chnStatus) ) toDo = true;
492 // This might be suitable for channels with status other than 13,
493 // since this function is written as a general one ...
494  if( !eerechit->isRecovered() ) toDo = false;
495 // if( !eerechit->checkFlag(EcalRecHit::kTowerRecovered) ) toDo = false;
496 
497  if( toDo ){
498 
499 // vvvv= Only for debuging or testing purpose =vvvv
500  EcalTrigTowerDetId ttDetId = ttItor->second;
501 // int ttzside = ttDetId.zside();
502 
503  std::vector<DetId> vid = ttMap_->constituentsOf(ttDetId);
504  int towerTestCnt =0;
505  for(std::vector<DetId>::const_iterator dit = vid.begin(); dit != vid.end(); ++dit ) {
506  std::map<DetId, vector<int> >::iterator bit2Itor = EcalAllDeadChannelsBitMap.find( (*dit) );
507  if( bit2Itor == EcalAllDeadChannelsBitMap.end() ){ towerTestCnt ++; continue; }
508  if( towerTest >0 && bit2Itor->second.back() == towerTest ) continue;
509  if( towerTest <0 && bit2Itor->second.back() >= abs(towerTest) ) continue;
510  towerTestCnt ++;
511  }
512  if( towerTestCnt !=0 && debug_ && verbose_ >=2) std::cout<<"towerTestCnt : "<<towerTestCnt<<" for towerTest : "<<towerTest<<std::endl;
513 // ^^^^= END =^^^^
514 
515  EcalScDetId sc( (det.ix()-1)/5+1, (det.iy()-1)/5+1, det.zside() );
516 
517  std::vector<DetId>::iterator avoidItor; avoidItor = find( avoidDuplicateVec.begin(), avoidDuplicateVec.end(), det);
518  if( avoidItor == avoidDuplicateVec.end() ){
519  avoidDuplicateVec.push_back(det);
520  }else{
521  continue;
522  }
523 
524  std::map<EcalScDetId, double>::iterator scetItor = accuSCetMap.find(sc);
525  if( scetItor == accuSCetMap.end() ){
526  accuSCetMap[sc] = eerechit->energy()*sin(theta);
527  accuSCchnMap[sc] = 1;
528  SCzsideMap[sc] = sc.zside();
529  }else{
530  accuSCetMap[sc] += eerechit->energy()*sin(theta);
531  accuSCchnMap[sc] ++;
532  }
533  }
534  } // loop over EE
535 
536 // Checking for EB
537  std::map<EcalTrigTowerDetId, double>::iterator ttetItor;
538  for( ttetItor = accuTTetMap.begin(); ttetItor != accuTTetMap.end(); ttetItor++){
539 
540  EcalTrigTowerDetId ttDetId = ttetItor->first;
541 
542  double ttetVal = ttetItor->second;
543 
544  std::map<EcalTrigTowerDetId, int>::iterator ttchnItor = accuTTchnMap.find(ttDetId);
545  if( ttchnItor == accuTTchnMap.end() ){ cout<<"\nERROR cannot find ttDetId : "<<ttDetId<<" in accuTTchnMap?!"<<endl<<endl; }
546 
547  std::map<EcalTrigTowerDetId, int>::iterator ttzsideItor = TTzsideMap.find(ttDetId);
548  if( ttzsideItor == TTzsideMap.end() ){ cout<<"\nERROR cannot find ttDetId : "<<ttDetId<<" in TTzsideMap?!"<<endl<<endl; }
549 
550  if( ttchnItor->second != 25 && debug_ && verbose_ >=2) cout<<"WARNING ... ttchnCnt : "<<ttchnItor->second<<" NOT equal 25!"<<endl;
551 
552  if( ttetVal >= tpValCut ){ isPassCut = 1; isPassCut *= ttzsideItor->second; }
553 
554  }
555 
556 // Checking for EE
557  std::map<EcalScDetId, double>::iterator scetItor;
558  for( scetItor = accuSCetMap.begin(); scetItor != accuSCetMap.end(); scetItor++){
559 
560  EcalScDetId scDetId = scetItor->first;
561 
562  double scetVal = scetItor->second;
563 
564  std::map<EcalScDetId, int>::iterator scchnItor = accuSCchnMap.find(scDetId);
565  if( scchnItor == accuSCchnMap.end() ){ cout<<"\nERROR cannot find scDetId : "<<scDetId<<" in accuSCchnMap?!"<<endl<<endl; }
566 
567  std::map<EcalScDetId, int>::iterator sczsideItor = SCzsideMap.find(scDetId);
568  if( sczsideItor == SCzsideMap.end() ){ cout<<"\nERROR cannot find scDetId : "<<scDetId<<" in SCzsideMap?!"<<endl<<endl; }
569 
570  if( scchnItor->second != 25 && debug_ && verbose_ >=2) cout<<"WARNING ... scchnCnt : "<<scchnItor->second<<" NOT equal 25!"<<endl;
571 
572  if( scetVal >= tpValCut ){ isPassCut = 1; isPassCut *= sczsideItor->second; }
573 
574  }
575 
576  if( debug_ && verbose_ >=2) std::cout<<"***end setEvtTPstatusRecHits***"<<std::endl;
577 
578  return isPassCut;
579 
580 }
581 
582 
583 int EcalDeadCellTriggerPrimitiveFilter::setEvtTPstatus(const double &tpValCut, const int &chnStatus){
584 
585  if( debug_ && verbose_ >=2) std::cout<<"***begin setEvtTPstatus***"<<std::endl;
586 
587  int isPassCut =0;
588 
589  std::map<DetId, std::vector<int> >::iterator bitItor;
590  for(bitItor = EcalAllDeadChannelsBitMap.begin(); bitItor != EcalAllDeadChannelsBitMap.end(); bitItor++){
591 
592  DetId maskedDetId = bitItor->first;
593  int subdet = bitItor->second.front(), status = bitItor->second.back();
594 
595 // if NOT filtering on EE, skip EE subdet
596  if( !doEEfilter_ && subdet != 1 ) continue;
597 
598  std::map<DetId, EcalTrigTowerDetId>::iterator ttItor = EcalAllDeadChannelsTTMap.find(maskedDetId);
599  if( ttItor == EcalAllDeadChannelsTTMap.end() ) continue;
600 
601  bool toDo = false;
602  if( chnStatus >0 && status == chnStatus ) toDo = true;
603  if( chnStatus <0 && status >= abs(chnStatus) ) toDo = true;
604 
605  if( toDo ){
606 
607  EcalTrigTowerDetId ttDetId = ttItor->second;
608  int ttzside = ttDetId.zside();
609 
610  const EcalTrigPrimDigiCollection * tpDigis = 0;
611  tpDigis = pTPDigis.product();
612  EcalTrigPrimDigiCollection::const_iterator tp = tpDigis->find( ttDetId );
613  if( tp != tpDigis->end() ){
614  double tpEt = ecalScale_.getTPGInGeV( tp->compressedEt(), tp->id() );
615  if(tpEt >= tpValCut ){ isPassCut = 1; isPassCut *= ttzside; }
616  }
617  }
618  } // loop over EB + EE
619 
620  if( debug_ && verbose_ >=2) std::cout<<"***end setEvtTPstatus***"<<std::endl;
621 
622  return isPassCut;
623 }
624 
625 
627 
628  EcalAllDeadChannelsValMap.clear(); EcalAllDeadChannelsBitMap.clear();
629 
630 // Loop over EB ...
631  for( int ieta=-85; ieta<=85; ieta++ ){
632  for( int iphi=0; iphi<=360; iphi++ ){
633  if(! EBDetId::validDetId( ieta, iphi ) ) continue;
634 
635  const EBDetId detid = EBDetId( ieta, iphi, EBDetId::ETAPHIMODE );
636  EcalChannelStatus::const_iterator chit = ecalStatus->find( detid );
637 // refer https://twiki.cern.ch/twiki/bin/viewauth/CMS/EcalChannelStatus
638  int status = ( chit != ecalStatus->end() ) ? chit->getStatusCode() & 0x1F : -1;
639 
640  const CaloSubdetectorGeometry* subGeom = geometry->getSubdetectorGeometry (detid);
641  const CaloCellGeometry* cellGeom = subGeom->getGeometry (detid);
642  double eta = cellGeom->getPosition ().eta ();
643  double phi = cellGeom->getPosition ().phi ();
644  double theta = cellGeom->getPosition().theta();
645 
646  if(status >= maskedEcalChannelStatusThreshold_){
647  std::vector<double> valVec; std::vector<int> bitVec;
648  valVec.push_back(eta); valVec.push_back(phi); valVec.push_back(theta);
649  bitVec.push_back(1); bitVec.push_back(ieta); bitVec.push_back(iphi); bitVec.push_back(status);
650  EcalAllDeadChannelsValMap.insert( std::make_pair(detid, valVec) );
651  EcalAllDeadChannelsBitMap.insert( std::make_pair(detid, bitVec) );
652  }
653  } // end loop iphi
654  } // end loop ieta
655 
656 // Loop over EE detid
657  for( int ix=0; ix<=100; ix++ ){
658  for( int iy=0; iy<=100; iy++ ){
659  for( int iz=-1; iz<=1; iz++ ){
660  if(iz==0) continue;
661  if(! EEDetId::validDetId( ix, iy, iz ) ) continue;
662 
663  const EEDetId detid = EEDetId( ix, iy, iz, EEDetId::XYMODE );
664  EcalChannelStatus::const_iterator chit = ecalStatus->find( detid );
665  int status = ( chit != ecalStatus->end() ) ? chit->getStatusCode() & 0x1F : -1;
666 
667  const CaloSubdetectorGeometry* subGeom = geometry->getSubdetectorGeometry (detid);
668  const CaloCellGeometry* cellGeom = subGeom->getGeometry (detid);
669  double eta = cellGeom->getPosition ().eta () ;
670  double phi = cellGeom->getPosition ().phi () ;
671  double theta = cellGeom->getPosition().theta();
672 
673  if(status >= maskedEcalChannelStatusThreshold_){
674  std::vector<double> valVec; std::vector<int> bitVec;
675  valVec.push_back(eta); valVec.push_back(phi); valVec.push_back(theta);
676  bitVec.push_back(2); bitVec.push_back(ix); bitVec.push_back(iy); bitVec.push_back(iz); bitVec.push_back(status);
677  EcalAllDeadChannelsValMap.insert( std::make_pair(detid, valVec) );
678  EcalAllDeadChannelsBitMap.insert( std::make_pair(detid, bitVec) );
679  }
680  } // end loop iz
681  } // end loop iy
682  } // end loop ix
683 
684  EcalAllDeadChannelsTTMap.clear();
685  std::map<DetId, std::vector<int> >::iterator bitItor;
686  for(bitItor = EcalAllDeadChannelsBitMap.begin(); bitItor != EcalAllDeadChannelsBitMap.end(); bitItor++){
687  const DetId id = bitItor->first;
688  EcalTrigTowerDetId ttDetId = ttMap_->towerOf(id);
689  EcalAllDeadChannelsTTMap.insert(std::make_pair(id, ttDetId) );
690  }
691 
692  return 1;
693 }
694 
695 
696 //define this as a plug-in
RunNumber_t run() const
Definition: EventID.h:39
EventNumber_t event() const
Definition: EventID.h:41
edm::EDGetTokenT< EcalRecHitCollection > ebReducedRecHitCollectionToken_
void getAllProvenance(std::vector< Provenance const * > &provenances) const
Definition: Event.cc:95
size_type size() const
std::map< DetId, std::vector< int > > EcalAllDeadChannelsBitMap
int ix() const
Definition: EEDetId.h:76
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:464
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
static const int XYMODE
Definition: EEDetId.h:339
Geom::Phi< T > phi() const
Definition: PV3DBase.h:69
def ls
Definition: eostools.py:348
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:63
collection_type const & data() const
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:7
std::map< EcalTrigTowerDetId, int > accuTTchnMap
unsigned int LuminosityBlockNumber_t
int zside() const
get the z-side of the tower (1/-1)
virtual 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 i, int j)
check if a valid index combination
Definition: EBDetId.h:124
void beginJob()
Definition: Breakpoints.cc:15
return((rh^lh)&mask)
Geom::Theta< T > theta() const
Definition: PV3DBase.h:75
U second(std::pair< T, U > const &p)
edm::EDGetTokenT< EcalRecHitCollection > eeReducedRecHitCollectionToken_
int iEvent
Definition: GenABIO.cc:230
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:120
int zside() const
Definition: EEDetId.h:70
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
int iy() const
Definition: EEDetId.h:82
edm::Handle< EcalRecHitCollection > endcapReducedRecHitsHandle
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
edm::Handle< EcalRecHitCollection > barrelReducedRecHitsHandle
static const int ETAPHIMODE
Definition: EBDetId.h:166
edm::ESHandle< EcalTrigTowerConstituentsMap > ttMap_
const_iterator end() const
virtual ProcessHistory const & processHistory() const
Definition: Event.cc:192
Definition: DetId.h:18
std::map< EcalTrigTowerDetId, double > accuTTetMap
std::map< DetId, std::vector< double > > EcalAllDeadChannelsValMap
int setEvtRecHitstatus(const double &tpValCut, const int &chnStatus, const int &towerTest)
static bool validDetId(int crystal_ix, int crystal_iy, int iz)
Definition: EEDetId.h:248
const T & get() const
Definition: EventSetup.h:56
std::vector< Item >::const_iterator const_iterator
void loadEventInfo(const edm::Event &iEvent, const edm::EventSetup &iSetup)
std::string const & moduleLabel() const
Definition: Provenance.h:60
virtual bool filter(edm::Event &, const edm::EventSetup &) override
Geom::Phi< T > phi() const
virtual void beginRun(const edm::Run &, const edm::EventSetup &) override
T eta() const
Definition: PV3DBase.h:76
ESHandle< TrackerGeometry > geometry
edm::EventID id() const
Definition: EventBase.h:60
iterator find(key_type k)
edm::EDGetTokenT< EcalTrigPrimDigiCollection > tpDigiCollectionToken_
tuple cout
Definition: gather_cfg.py:121
std::map< EcalTrigTowerDetId, int > TTzsideMap
void loadEcalRecHits(edm::Event &iEvent, const edm::EventSetup &iSetup)
unsigned int RunNumber_t
virtual void envSet(const edm::EventSetup &)
tuple status
Definition: ntuplemaker.py:245
bool isValid() const
Definition: ESHandle.h:47
std::map< DetId, EcalTrigTowerDetId > EcalAllDeadChannelsTTMap
const GlobalPoint & getPosition() const
Returns the position of reference for this cell.
double split
Definition: MVATrainer.cc:139
int setEvtTPstatus(const double &tpCntCut, const int &chnStatus)
void loadEcalDigis(edm::Event &iEvent, const edm::EventSetup &iSetup)
const_iterator begin() const
Definition: Run.h:43
edm::Handle< EcalTrigPrimDigiCollection > pTPDigis