CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_2_SLHC4_patch1/src/RecoEgamma/EgammaHLTProducers/src/ESRecHitsMerger.cc

Go to the documentation of this file.
00001 
00002 //#include <FWCore/Framework/interface/Handle.h>
00003 #include <FWCore/Framework/interface/Event.h>
00004 #include <FWCore/Framework/interface/EventSetup.h>
00005 #include <FWCore/Framework/interface/ESHandle.h>
00006 
00007 #include "DataFormats/EcalRecHit/interface/EcalRecHitCollections.h"
00008 #include "RecoEgamma/EgammaHLTProducers/interface/ESRecHitsMerger.h"
00009 
00010 #include "FWCore/Utilities/interface/Exception.h"
00011 
00012 
00013 using namespace edm;
00014 using namespace std;
00015 
00016 
00017 ESRecHitsMerger::ESRecHitsMerger(const edm::ParameterSet& pset) {
00018 
00019  debug_ = pset.getUntrackedParameter<bool>("debug");
00020  
00021  EgammaSourceES_ = pset.getUntrackedParameter<edm::InputTag>("EgammaSource_ES",edm::InputTag("dummyEgamma"));
00022  MuonsSourceES_  = pset.getUntrackedParameter<edm::InputTag>("MuonsSource_ES",edm::InputTag("dummyMuons"));
00023  TausSourceES_  = pset.getUntrackedParameter<edm::InputTag>("TausSource_ES",edm::InputTag("dummyTaus"));
00024  JetsSourceES_   = pset.getUntrackedParameter<edm::InputTag>("JetsSource_ES",edm::InputTag("dummyJets"));
00025  RestSourceES_   = pset.getUntrackedParameter<edm::InputTag>("RestSource_ES",edm::InputTag("dummyRest"));
00026  Pi0SourceES_   = pset.getUntrackedParameter<edm::InputTag>("Pi0Source_ES",edm::InputTag("dummyPi0"));
00027  EtaSourceES_   = pset.getUntrackedParameter<edm::InputTag>("EtaSource_ES",edm::InputTag("dummyEta"));
00028   
00029 
00030  OutputLabelES_ = pset.getUntrackedParameter<std::string>("OutputLabel_ES");
00031  
00032  InputRecHitES_ = pset.getUntrackedParameter<std::string>("EcalRecHitCollectionES");
00033  
00034  produces<EcalRecHitCollection>(OutputLabelES_);
00035  
00036 }
00037 
00038 
00039 
00040 ESRecHitsMerger::~ESRecHitsMerger() {
00041 }
00042 
00043 
00044 void ESRecHitsMerger::beginJob(){
00045 }
00046 
00047 void ESRecHitsMerger::endJob(){
00048 }
00049 
00050 void ESRecHitsMerger::produce(edm::Event & e, const edm::EventSetup& iSetup){
00051 
00052  if (debug_) std::cout << " ESRecHitMerger : Run " << e.id().run() << " Event " << e.id().event() << std::endl;
00053 
00054 
00055  std::vector< edm::Handle<ESRecHitCollection> > EcalRecHits_done;
00056  e.getManyByType(EcalRecHits_done);
00057  
00058  std::auto_ptr<EcalRecHitCollection> ESMergedRecHits(new EcalRecHitCollection);
00059  
00060  
00061  unsigned int nColl = EcalRecHits_done.size();
00062  
00063  int nES = 0;
00064 
00065 
00066  for (unsigned int i=0; i < nColl; i++) {
00067 
00068    std::string instance = EcalRecHits_done[i].provenance()->productInstanceName();
00069    std::string module_label = EcalRecHits_done[i].provenance()->moduleLabel();
00070 
00071 
00072    if (debug_){
00073      std::cout<<"ESrechit to be merged from "<<module_label.c_str()<<" "<<instance.c_str()<<std::endl;
00074    }
00075    
00076    if ( module_label != EgammaSourceES_.label() && 
00077         module_label != MuonsSourceES_.label() &&
00078         module_label != JetsSourceES_.label() &&
00079         module_label != TausSourceES_.label() &&
00080         module_label != RestSourceES_.label() &&
00081         module_label != Pi0SourceES_.label() &&
00082         module_label != EtaSourceES_.label()) continue;
00083    
00084    if (instance == InputRecHitES_) {
00085      nES += EcalRecHits_done[i] -> size();
00086    }
00087    
00088  }
00089  
00090  
00091  ESMergedRecHits -> reserve(nES);
00092  
00093  if (debug_) std::cout << " Number of ES Rechits to merge  = " << nES << std::endl;
00094  
00095  for (unsigned int i=0; i < nColl; i++) {
00096    std::string instance = EcalRecHits_done[i].provenance()->productInstanceName(); 
00097 
00098    std::string module_label = EcalRecHits_done[i].provenance()->moduleLabel();
00099    if ( module_label != EgammaSourceES_.label() && 
00100         module_label != MuonsSourceES_.label() &&
00101         module_label != JetsSourceES_.label() &&
00102         module_label != TausSourceES_.label() &&
00103         module_label != RestSourceES_.label() &&
00104         module_label != Pi0SourceES_.label() && 
00105         module_label != EtaSourceES_.label() ) continue;
00106 
00107    if (instance == InputRecHitES_) {
00108      for (EcalRecHitCollection::const_iterator it=EcalRecHits_done[i]->begin(); it !=EcalRecHits_done[i]->end(); it++) {
00109        ESMergedRecHits -> push_back(*it);
00110      }
00111    }
00112    
00113  }
00114  
00115  
00116  // std::cout << " avant le put " << std::endl;
00117  e.put(ESMergedRecHits,OutputLabelES_);
00118  // std::cout << " apres le put " << std::endl;
00119 
00120 }
00121