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