CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_6_2_5/src/RecoTauTag/RecoTau/plugins/TCRecoTauProducer.cc

Go to the documentation of this file.
00001 /* class CaloRecoTauProducer
00002  * EDProducer of the TCTauCollection, starting from the CaloRecoTauCollection,
00003  * authors: Sami Lehti (sami.lehti@cern.ch)
00004  */
00005 
00006 #include "FWCore/Framework/interface/EventSetup.h"
00007 #include "FWCore/Framework/interface/ESHandle.h"
00008 #include "FWCore/Framework/interface/Event.h"
00009 #include "FWCore/Framework/interface/MakerMacros.h"
00010 #include "FWCore/Framework/interface/Frameworkfwd.h"
00011 #include "FWCore/Framework/interface/EDProducer.h"
00012 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00013 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00014 
00015 #include "RecoTauTag/RecoTau/interface/TCTauAlgorithm.h"
00016 
00017 using namespace edm;
00018 using namespace reco;
00019 
00020 class TCRecoTauProducer : public edm::EDProducer {
00021     public:
00022         explicit TCRecoTauProducer(const edm::ParameterSet& iConfig);
00023         ~TCRecoTauProducer();
00024 
00025         virtual void produce(edm::Event&,const edm::EventSetup&);
00026 
00027     private:
00028         edm::InputTag    caloRecoTauProducer;
00029         TCTauAlgorithm*  tcTauAlgorithm;
00030 };
00031 
00032 TCRecoTauProducer::TCRecoTauProducer(const edm::ParameterSet& iConfig){
00033         caloRecoTauProducer = iConfig.getParameter<edm::InputTag>("CaloRecoTauProducer");
00034         tcTauAlgorithm = new TCTauAlgorithm(iConfig);
00035 
00036         produces<CaloTauCollection>();
00037 }
00038 TCRecoTauProducer::~TCRecoTauProducer(){
00039         delete tcTauAlgorithm;
00040 }
00041   
00042 void TCRecoTauProducer::produce(edm::Event& iEvent,const edm::EventSetup& iSetup){
00043 
00044         std::auto_ptr<CaloTauCollection> tcTauCollection(new CaloTauCollection);
00045 
00046         edm::Handle<CaloTauCollection> theCaloTauHandle;
00047         iEvent.getByLabel(caloRecoTauProducer,theCaloTauHandle);
00048 
00049         tcTauAlgorithm->eventSetup(iEvent,iSetup);
00050 
00051         if(theCaloTauHandle.isValid()){
00052           const CaloTauCollection & caloTaus = *(theCaloTauHandle.product());
00053           CaloTauCollection::const_iterator iTau;
00054           for(iTau = caloTaus.begin(); iTau != caloTaus.end(); iTau++){
00055                 CaloTau theTCTau = *iTau;
00056                 theTCTau.setP4(tcTauAlgorithm->recalculateEnergy(theTCTau));
00057                 tcTauCollection->push_back(theTCTau);
00058           }
00059         }
00060 
00061         iEvent.put(tcTauCollection);
00062 }
00063 
00064 DEFINE_FWK_MODULE(TCRecoTauProducer);