CMS 3D CMS Logo

ElectronRecalibSuperClusterAssociator Class Reference

#include <Calibration/EcalCalibAlgos/interface/ElectronRecalibSuperClusterAssociator.h>

Inheritance diagram for ElectronRecalibSuperClusterAssociator:

edm::EDProducer edm::ProducerBase edm::ProductRegistryHelper

List of all members.

Public Member Functions

virtual void beginJob (edm::EventSetup const &iSetup)
 ElectronRecalibSuperClusterAssociator (const edm::ParameterSet &conf)
virtual void produce (edm::Event &e, const edm::EventSetup &c)
virtual ~ElectronRecalibSuperClusterAssociator ()

Private Attributes

std::string electronCollection_
std::string electronProducer_
std::string scCollection_
std::string scIslandCollection_
std::string scIslandProducer_
std::string scProducer_


Detailed Description

Definition at line 24 of file ElectronRecalibSuperClusterAssociator.h.


Constructor & Destructor Documentation

ElectronRecalibSuperClusterAssociator::ElectronRecalibSuperClusterAssociator ( const edm::ParameterSet conf  )  [explicit]

Definition at line 22 of file ElectronRecalibSuperClusterAssociator.cc.

References GenMuonPlsPt100GeV_cfg::cout, electronCollection_, electronProducer_, lat::endl(), edm::ParameterSet::getParameter(), scCollection_, scIslandCollection_, scIslandProducer_, and scProducer_.

00023 {
00024 #ifdef DEBUG
00025   std::cout<< "ElectronRecalibSuperClusterAssociator::ElectronRecalibSuperClusterAssociator" << std::endl;
00026 #endif
00027 
00028   //register your products
00029   produces<GsfElectronCollection>();
00030   produces<SuperClusterCollection>();
00031   
00032   scProducer_ = iConfig.getParameter<std::string>("scProducer");
00033   scCollection_ = iConfig.getParameter<std::string>("scCollection");
00034 
00035   scIslandProducer_ = iConfig.getParameter<std::string>("scIslandProducer");
00036   scIslandCollection_ = iConfig.getParameter<std::string>("scIslandCollection");
00037 
00038   electronProducer_ = iConfig.getParameter<std::string > ("electronProducer");
00039   electronCollection_ = iConfig.getParameter<std::string > ("electronCollection");
00040 #ifdef DEBUG
00041   std::cout<< "ElectronRecalibSuperClusterAssociator::ElectronRecalibSuperClusterAssociator::end" << std::endl;
00042 #endif
00043 }

ElectronRecalibSuperClusterAssociator::~ElectronRecalibSuperClusterAssociator (  )  [virtual]

Definition at line 45 of file ElectronRecalibSuperClusterAssociator.cc.

00046 {
00047 }


Member Function Documentation

void ElectronRecalibSuperClusterAssociator::beginJob ( edm::EventSetup const &  iSetup  )  [virtual]

Reimplemented from edm::EDProducer.

Definition at line 49 of file ElectronRecalibSuperClusterAssociator.cc.

00050 {     
00051 }

void ElectronRecalibSuperClusterAssociator::produce ( edm::Event e,
const edm::EventSetup c 
) [virtual]

Implements edm::EDProducer.

Definition at line 54 of file ElectronRecalibSuperClusterAssociator.cc.

References TestMuL1L2Filter_cff::cerr, reco::SuperCluster::clustersBegin(), reco::SuperCluster::clustersEnd(), GenMuonPlsPt100GeV_cfg::cout, electronCollection_, electronProducer_, lat::endl(), reco::CaloCluster::energy(), edm::Event::getByLabel(), edm::Event::getRefBeforePut(), edm::Handle< T >::isValid(), reco::CaloCluster::position(), funct::pow(), edm::Handle< T >::product(), edm::RefVector< C, T, F >::push_back(), edm::Event::put(), scCollection_, scIslandCollection_, scIslandProducer_, scProducer_, reco::SuperCluster::seed(), reco::GsfElectron::setGsfTrack(), reco::GsfElectron::setSuperCluster(), and funct::sqrt().

00055 {
00056 #ifdef DEBUG
00057   std::cout<< "ElectronRecalibSuperClusterAssociator::produce" << std::endl;
00058 #endif
00059   // Create the output collections   
00060   std::auto_ptr<GsfElectronCollection> pOutEle(new GsfElectronCollection);
00061   std::auto_ptr<SuperClusterCollection> pOutNewEndcapSC(new SuperClusterCollection);
00062 
00063   reco::SuperClusterRefProd rSC = e.getRefBeforePut<SuperClusterCollection>();
00064   edm::Ref<SuperClusterCollection>::key_type idxSC = 0;
00065 
00066   //Get Hybrid SuperClusters
00067   Handle<reco::SuperClusterCollection> pSuperClusters;
00068   e.getByLabel(scProducer_, scCollection_, pSuperClusters);
00069   if (!pSuperClusters.isValid()) {
00070     std::cerr << "Error! can't get the product SuperClusterCollection "<< std::endl;
00071   }
00072   const reco::SuperClusterCollection* scCollection = pSuperClusters.product();
00073   
00074 #ifdef DEBUG
00075   std::cout<<"scCollection->size()"<<scCollection->size()<<std::endl;
00076 #endif
00077   
00078   //Get Island SuperClusters
00079   Handle<reco::SuperClusterCollection> pIslandSuperClusters;
00080   e.getByLabel(scIslandProducer_, scIslandCollection_, pIslandSuperClusters);
00081   if (!pIslandSuperClusters.isValid()) {
00082     std::cerr << "Error! can't get the product IslandSuperClusterCollection "<< std::endl;
00083   }
00084   const reco::SuperClusterCollection* scIslandCollection = pIslandSuperClusters.product();
00085   
00086 #ifdef DEBUG
00087   std::cout<<"scEECollection->size()"<<scIslandCollection->size()<<std::endl;
00088 #endif
00089 
00090   // Get Electrons
00091   Handle<reco::GsfElectronCollection> pElectrons;
00092   e.getByLabel(electronProducer_, electronCollection_, pElectrons);
00093   if (!pElectrons.isValid()) {
00094     std::cerr << "Error! can't get the product ElectronCollection "<< std::endl;
00095   }
00096   const reco::GsfElectronCollection* electronCollection = pElectrons.product();
00097   
00098   for(reco::GsfElectronCollection::const_iterator eleIt = electronCollection->begin(); eleIt != electronCollection->end(); eleIt++)
00099     {
00100       float DeltaRMineleSCbarrel(0.15); 
00101       float DeltaRMineleSCendcap(0.15); 
00102       const reco::SuperCluster* nearestSCbarrel=0;
00103       const reco::SuperCluster* nearestSCendcap=0;
00104       int iscRef=-1;
00105       int iSC=0;
00106       
00107       // first loop is on EB superClusters
00108       for(reco::SuperClusterCollection::const_iterator scIt = scCollection->begin();
00109           scIt != scCollection->end(); scIt++){
00110 #ifdef DEBUG    
00111         std::cout << scIt->energy() << " " << scIt->eta() << " " << scIt->phi() << " " << eleIt->eta() << " " << eleIt->phi() << std::endl;
00112 #endif
00113         
00114         double DeltaReleSC = sqrt ( pow(  eleIt->eta() - scIt->eta(),2) + pow(eleIt->phi() - scIt->phi(),2));
00115         
00116         if(DeltaReleSC<DeltaRMineleSCbarrel)
00117           {
00118             DeltaRMineleSCbarrel = DeltaReleSC;
00119             nearestSCbarrel = &*scIt;
00120             iscRef = iSC;
00121           }
00122         iSC++;
00123       }
00124       iSC = 0;
00125       
00126       // second loop is on EE superClusters
00127       int iscRefendcap=-1;
00128       
00129       for(reco::SuperClusterCollection::const_iterator scItEndcap = scIslandCollection->begin();
00130           scItEndcap != scIslandCollection->end(); scItEndcap++){
00131 #ifdef DEBUG    
00132         std::cout << "EE " << scItEndcap->energy() << " " << scItEndcap->eta() << " " << scItEndcap->phi() << " " << eleIt->eta() << " " << eleIt->phi() << std::endl;
00133 #endif
00134         
00135         double DeltaReleSC = sqrt ( pow(  eleIt->eta() - scItEndcap->eta(),2) + pow(eleIt->phi() - scItEndcap->phi(),2));
00136         
00137         if(DeltaReleSC<DeltaRMineleSCendcap)
00138           {
00139             DeltaRMineleSCendcap = DeltaReleSC;
00140             nearestSCendcap = &*scItEndcap;
00141             iscRefendcap = iSC;
00142           }
00143         iSC++;
00144       }
00146        
00147       
00148       if(nearestSCbarrel && !nearestSCendcap){
00149         reco::GsfElectron newEle(*eleIt);
00150         newEle.setGsfTrack(eleIt->gsfTrack());
00151         reco::SuperClusterRef scRef(reco::SuperClusterRef(pSuperClusters, iscRef));
00152         newEle.setSuperCluster(scRef);
00153         pOutEle->push_back(newEle);
00154 #ifdef DEBUG
00155         std::cout << "Association is with EB superCluster "<< std::endl;
00156 #endif  
00157       }  
00158 
00159       if(!nearestSCbarrel && nearestSCendcap)
00160         {
00161 #ifdef DEBUG
00162         std::cout << "Starting Association is with EE superCluster "<< std::endl;
00163 #endif  
00164           reco::GsfElectron newEle(*eleIt);
00165           newEle.setGsfTrack(eleIt->gsfTrack());
00166           float preshowerEnergy=eleIt->superCluster()->preshowerEnergy(); 
00167 #ifdef DEBUG
00168           std::cout << "preshowerEnergy"<< preshowerEnergy << std::endl;
00169 #endif  
00170           BasicClusterRefVector newBCRef;
00171           for (BasicClusterRefVector::const_iterator bcRefIt=nearestSCendcap->clustersBegin();bcRefIt!=nearestSCendcap->clustersEnd();++bcRefIt)
00172             newBCRef.push_back(*bcRefIt);
00173           reco::SuperCluster newSC(nearestSCendcap->energy() + preshowerEnergy, nearestSCendcap->position() , nearestSCendcap->seed(),newBCRef , preshowerEnergy );
00174           pOutNewEndcapSC->push_back(newSC);
00175           reco::SuperClusterRef scRef(reco::SuperClusterRef(rSC, idxSC ++));
00176           newEle.setSuperCluster(scRef);
00177           pOutEle->push_back(newEle);
00178 #ifdef DEBUG
00179         std::cout << "Association is with EE superCluster "<< std::endl;
00180 #endif  
00181       }  
00182     
00183       if(nearestSCbarrel && nearestSCendcap){
00184         
00185         reco::GsfElectron newEle(*eleIt);
00186         newEle.setGsfTrack(eleIt->gsfTrack());
00187         
00188         if(DeltaRMineleSCendcap>=DeltaRMineleSCbarrel)
00189           {
00190             reco::SuperClusterRef scRef(reco::SuperClusterRef(pSuperClusters, iscRef));
00191             newEle.setSuperCluster(scRef);
00192             pOutEle->push_back(newEle);
00193 #ifdef DEBUG
00194             std::cout << "Association is with EB superCluster, after quarrel "<< std::endl;
00195 #endif  
00196           }
00197         else if(DeltaRMineleSCendcap<DeltaRMineleSCbarrel)
00198           {
00199           float preshowerEnergy=eleIt->superCluster()->preshowerEnergy(); 
00200           BasicClusterRefVector newBCRef;
00201           for (BasicClusterRefVector::const_iterator bcRefIt=nearestSCendcap->clustersBegin();bcRefIt!=nearestSCendcap->clustersEnd();++bcRefIt)
00202             newBCRef.push_back(*bcRefIt);
00203           reco::SuperCluster newSC(nearestSCendcap->energy() + preshowerEnergy,  nearestSCendcap->position() , nearestSCendcap->seed(), newBCRef , preshowerEnergy );
00204           pOutNewEndcapSC->push_back(newSC);
00205           reco::SuperClusterRef scRef(reco::SuperClusterRef(rSC, idxSC ++));
00206           newEle.setSuperCluster(scRef);
00207           pOutEle->push_back(newEle);
00208 #ifdef DEBUG
00209           std::cout << "Association is with EE superCluster, after quarrel "<< std::endl;
00210 #endif  
00211           }     
00212       }
00213       
00214 
00215     }
00216   
00217   
00218   
00219 #ifdef DEBUG
00220   std::cout << "Filled new electrons  " << pOutEle->size() << std::endl;
00221   std::cout << "Filled new endcapSC  " << pOutNewEndcapSC->size() << std::endl;
00222 #endif  
00223   
00224   // put result into the Event
00225   e.put(pOutEle);
00226   e.put(pOutNewEndcapSC);
00227   
00228 }


Member Data Documentation

std::string ElectronRecalibSuperClusterAssociator::electronCollection_ [private]

Definition at line 44 of file ElectronRecalibSuperClusterAssociator.h.

Referenced by ElectronRecalibSuperClusterAssociator(), and produce().

std::string ElectronRecalibSuperClusterAssociator::electronProducer_ [private]

Definition at line 43 of file ElectronRecalibSuperClusterAssociator.h.

Referenced by ElectronRecalibSuperClusterAssociator(), and produce().

std::string ElectronRecalibSuperClusterAssociator::scCollection_ [private]

Definition at line 38 of file ElectronRecalibSuperClusterAssociator.h.

Referenced by ElectronRecalibSuperClusterAssociator(), and produce().

std::string ElectronRecalibSuperClusterAssociator::scIslandCollection_ [private]

Definition at line 41 of file ElectronRecalibSuperClusterAssociator.h.

Referenced by ElectronRecalibSuperClusterAssociator(), and produce().

std::string ElectronRecalibSuperClusterAssociator::scIslandProducer_ [private]

Definition at line 40 of file ElectronRecalibSuperClusterAssociator.h.

Referenced by ElectronRecalibSuperClusterAssociator(), and produce().

std::string ElectronRecalibSuperClusterAssociator::scProducer_ [private]

Definition at line 37 of file ElectronRecalibSuperClusterAssociator.h.

Referenced by ElectronRecalibSuperClusterAssociator(), and produce().


The documentation for this class was generated from the following files:
Generated on Tue Jun 9 18:20:21 2009 for CMSSW by  doxygen 1.5.4