CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_6_2_7/src/Calibration/HcalAlCaRecoProducers/src/AlCaEcalHcalReadoutsProducer.cc

Go to the documentation of this file.
00001 #include "Calibration/HcalAlCaRecoProducers/interface/AlCaEcalHcalReadoutsProducer.h"
00002 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00003 
00004 
00005 AlCaEcalHcalReadoutsProducer::AlCaEcalHcalReadoutsProducer(const edm::ParameterSet& iConfig)
00006 {
00007 
00008    hoLabel_ = iConfig.getParameter<edm::InputTag>("hoInput");
00009    hfLabel_ = iConfig.getParameter<edm::InputTag>("hfInput");
00010    hbheLabel_ = iConfig.getParameter<edm::InputTag>("hbheInput");
00011    
00012    //register your products
00013    produces<HBHERecHitCollection>("HBHERecHitCollection");
00014    produces<HORecHitCollection>("HORecHitCollection");
00015    produces<HFRecHitCollection>("HFRecHitCollection");
00016 }
00017 
00018 
00019 AlCaEcalHcalReadoutsProducer::~AlCaEcalHcalReadoutsProducer()
00020 {
00021  
00022 
00023 }
00024 
00025 
00026 // ------------ method called to produce the data  ------------
00027 void
00028 AlCaEcalHcalReadoutsProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup)
00029 {
00030    using namespace edm;
00031    using namespace std;
00032 
00033    edm::Handle<HBHERecHitCollection> hbhe;
00034    edm::Handle<HORecHitCollection> ho;
00035    edm::Handle<HFRecHitCollection> hf;
00036 
00037    iEvent.getByLabel(hbheLabel_,hbhe);
00038    if(!hbhe.isValid()){
00039      LogDebug("") << "AlCaEcalHcalReadoutProducer: Error! can't get hbhe product!" << std::endl;
00040      return ;
00041    }
00042 
00043    iEvent.getByLabel(hoLabel_,ho);
00044     if(!ho.isValid()) {
00045       LogDebug("") << "AlCaEcalHcalReadoutProducer: Error! can't get ho product!" << std::endl;
00046     }
00047     
00048     iEvent.getByLabel(hfLabel_,hf);
00049     if(!hf.isValid()) {
00050       LogDebug("") << "AlCaEcalHcalReadoutProducer: Error! can't get hf product!" << std::endl;
00051     }
00052     //Create empty output collections
00053    
00054   std::auto_ptr<HBHERecHitCollection> miniHBHERecHitCollection(new HBHERecHitCollection);
00055   std::auto_ptr<HORecHitCollection> miniHORecHitCollection(new HORecHitCollection);
00056   std::auto_ptr<HFRecHitCollection> miniHFRecHitCollection(new HFRecHitCollection);
00057 
00058   const HBHERecHitCollection Hithbhe = *(hbhe.product());
00059   for(HBHERecHitCollection::const_iterator hbheItr=Hithbhe.begin(); hbheItr!=Hithbhe.end(); hbheItr++)
00060         {
00061          miniHBHERecHitCollection->push_back(*hbheItr);
00062         }
00063   const HORecHitCollection Hitho = *(ho.product());
00064   for(HORecHitCollection::const_iterator hoItr=Hitho.begin(); hoItr!=Hitho.end(); hoItr++)
00065         {
00066          miniHORecHitCollection->push_back(*hoItr);
00067         }
00068 
00069   const HFRecHitCollection Hithf = *(hf.product());
00070   for(HFRecHitCollection::const_iterator hfItr=Hithf.begin(); hfItr!=Hithf.end(); hfItr++)
00071       {
00072          miniHFRecHitCollection->push_back(*hfItr);
00073       }
00074 
00075 
00076 
00077   //Put selected information in the event
00078   iEvent.put( miniHBHERecHitCollection, "HBHERecHitCollection");
00079   iEvent.put( miniHORecHitCollection, "HORecHitCollection");
00080   iEvent.put( miniHFRecHitCollection, "HFRecHitCollection");
00081   
00082   
00083 }