CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch9/src/Calibration/Tools/plugins/ElectronSqPtTkIsolationProducer.cc

Go to the documentation of this file.
00001 #include "FWCore/Framework/interface/Event.h"
00002 #include "FWCore/Framework/interface/EventSetup.h"
00003 #include "DataFormats/Common/interface/Handle.h"
00004 #include "FWCore/Framework/interface/ESHandle.h"
00005 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00006 #include "FWCore/Utilities/interface/Exception.h"
00007 
00008 #include "DataFormats/EgammaCandidates/interface/GsfElectronFwd.h"
00009 #include "DataFormats/Candidate/interface/CandAssociation.h"
00010 
00011 
00012 #include "Calibration/Tools/plugins/ElectronSqPtTkIsolationProducer.h"
00013 #include "Calibration/Tools/plugins/ElectronSqPtTkIsolation.h"
00014 
00015 ElectronSqPtTkIsolationProducer::ElectronSqPtTkIsolationProducer(const edm::ParameterSet& config) : conf_(config)
00016 {
00017   // use configuration file to setup input/output collection names
00018   electronProducer_               = conf_.getParameter<edm::InputTag>("electronProducer");
00019   
00020   trackProducer_           = conf_.getParameter<edm::InputTag>("trackProducer");
00021 
00022   ptMin_                = conf_.getParameter<double>("ptMin");
00023   intRadius_            = conf_.getParameter<double>("intRadius");
00024   extRadius_            = conf_.getParameter<double>("extRadius");
00025   maxVtxDist_           = conf_.getParameter<double>("maxVtxDist");
00026 
00027   absolut_              = conf_.getParameter<bool>("absolut");
00028 
00029   //register your products
00030   produces < reco::CandViewDoubleAssociations>();
00031 
00032 }
00033 
00034 ElectronSqPtTkIsolationProducer::~ElectronSqPtTkIsolationProducer(){}
00035 
00036 
00037                                                                        
00038 void ElectronSqPtTkIsolationProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup)
00039 {
00040   // Get the  filtered objects
00041   edm::Handle< reco::GsfElectronCollection> electronHandle;
00042   iEvent.getByLabel(electronProducer_,electronHandle);
00043   
00044   //get the tracks
00045   edm::Handle<reco::TrackCollection> tracks;
00046   iEvent.getByLabel(trackProducer_,tracks);
00047   const reco::TrackCollection* trackCollection = tracks.product();
00048   
00049   reco::CandViewDoubleAssociations* isoMap = new reco::CandViewDoubleAssociations(reco::GsfElectronRefProd( electronHandle ));
00050   
00051   ElectronSqPtTkIsolation myTkIsolation (extRadius_,intRadius_,ptMin_,maxVtxDist_,trackCollection) ;
00052   
00053   for(unsigned int i = 0 ; i < electronHandle->size(); ++i ){
00054     double isoValue = myTkIsolation.getPtTracks(&(electronHandle->at(i)));
00055     if(absolut_==true){
00056       isoMap->setValue(i,isoValue);
00057     }
00058     else{
00059       reco::SuperClusterRef sc = (electronHandle->at(i)).superCluster();
00060       double et = sc.get()->energy()*sin(2*atan(exp(-sc.get()->eta())));
00061       isoMap->setValue(i,isoValue/et);
00062     }
00063   }
00064   
00065   std::auto_ptr<reco::CandViewDoubleAssociations> isolMap(isoMap);
00066   iEvent.put(isolMap);
00067 }