CMS 3D CMS Logo

EgammaEcalIsolationProducer.cc

Go to the documentation of this file.
00001 //*****************************************************************************
00002 // File:      EgammaEcalIsolationProducer.cc
00003 // ----------------------------------------------------------------------------
00004 // OrigAuth:  Matthias Mozer
00005 // Institute: IIHE-VUB
00006 //=============================================================================
00007 //*****************************************************************************
00008 
00009 
00010 #include "EgammaAnalysis/EgammaIsolationProducers/interface/EgammaEcalIsolationProducer.h"
00011 
00012 // Framework
00013 #include "DataFormats/Common/interface/Handle.h"
00014 
00015 #include "DataFormats/Candidate/interface/Candidate.h"
00016 #include "DataFormats/Candidate/interface/CandAssociation.h"
00017 #include "DataFormats/RecoCandidate/interface/RecoCandidate.h"
00018 #include "DataFormats/EgammaReco/interface/SuperCluster.h"
00019 #include "DataFormats/EgammaReco/interface/SuperClusterFwd.h"
00020 #include "DataFormats/EgammaReco/interface/BasicClusterFwd.h"
00021 
00022 
00023 EgammaEcalIsolationProducer::EgammaEcalIsolationProducer(const edm::ParameterSet& config) : conf_(config)
00024 {
00025  // use configuration file to setup input/output collection names
00026   emObjectProducer_               = conf_.getParameter<edm::InputTag>("emObjectProducer");
00027 
00028   basicClusterProducer_           = conf_.getParameter<edm::InputTag>("basicClusterProducer");
00029   superClusterProducer_           = conf_.getParameter<edm::InputTag>("superClusterProducer");
00030 
00031   etLow_               = conf_.getParameter<double>("etMin");
00032   extRadius_            = conf_.getParameter<double>("extRadius");
00033 
00034   absolut_ = conf_.getParameter<bool>("absolut");
00035 
00036   //register your products
00037   produces < reco::CandViewDoubleAssociations >();
00038 }
00039 
00040 
00041 EgammaEcalIsolationProducer::~EgammaEcalIsolationProducer(){}
00042 
00043 
00044 //
00045 // member functions
00046 //
00047 
00048 // ------------ method called to produce the data  ------------
00049 void
00050 EgammaEcalIsolationProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup)
00051 {
00052   
00053   // Get the  filtered objects
00054   edm::Handle< edm::View<reco::Candidate> > emObjectHandle;
00055   iEvent.getByLabel(emObjectProducer_,emObjectHandle);
00056   
00057   // Get the basicClusters hcal hits
00058   edm::Handle<reco::BasicClusterCollection> basicClusterHandle;
00059   iEvent.getByLabel(basicClusterProducer_, basicClusterHandle);
00060   const reco::BasicClusterCollection* basicClusters = basicClusterHandle.product();
00061   
00062   // Get the superClusters hcal hits
00063   edm::Handle<reco::SuperClusterCollection> superClusterHandle;
00064   iEvent.getByLabel(superClusterProducer_, superClusterHandle);
00065   const reco::SuperClusterCollection* superClusters = superClusterHandle.product();
00066   
00067 
00068   reco::CandViewDoubleAssociations* isoMap = new reco::CandViewDoubleAssociations( reco::CandidateBaseRefProd( emObjectHandle ) );
00069 
00070 
00071   EgammaEcalIsolation myEcalIsolation(extRadius_,
00072                                       etLow_,
00073                                       basicClusters,
00074                                       superClusters) ;
00075 
00076   
00077   for( size_t i = 0 ; i < emObjectHandle->size(); ++i) {
00078     double isoValue = myEcalIsolation.getEcalEtSum(&(emObjectHandle->at(i)));
00079     if(absolut_==true){
00080       isoMap->setValue(i,isoValue);
00081     }
00082     else{
00083       reco::SuperClusterRef sc = (emObjectHandle->at(i)).get<reco::SuperClusterRef>();
00084       double et = sc.get()->energy()*sin(2*atan(exp(-sc.get()->eta())));
00085       isoMap->setValue(i,isoValue/et);
00086     }
00087   }
00088 
00089 
00090 
00091   std::auto_ptr<reco::CandViewDoubleAssociations> isolMap(isoMap);
00092   iEvent.put(isolMap);
00093 
00094 }
00095 
00096 //define this as a plug-in
00097 //DEFINE_FWK_MODULE(EgammaEcalIsolationProducer);

Generated on Tue Jun 9 17:34:16 2009 for CMSSW by  doxygen 1.5.4