CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_6_2_7/src/RecoEgamma/EgammaIsolationAlgos/plugins/EgammaEcalExtractor.cc

Go to the documentation of this file.
00001 //*****************************************************************************
00002 // File:      EgammaEcalExtractor.cc
00003 // ----------------------------------------------------------------------------
00004 // OrigAuth:  Gilles De Lentdecker
00005 // Institute: IIHE-ULB
00006 //=============================================================================
00007 //*****************************************************************************
00008 
00009 //C++ includes
00010 #include <vector>
00011 #include <functional>
00012 
00013 //ROOT includes
00014 #include <Math/VectorUtil.h>
00015 
00016 //CMSSW includes
00017 #include "RecoEgamma/EgammaIsolationAlgos/plugins/EgammaEcalExtractor.h"
00018 #include "DataFormats/RecoCandidate/interface/RecoCandidate.h"
00019 
00020 using namespace egammaisolation;
00021 using namespace reco::isodeposit;
00022 
00023 EgammaEcalExtractor::~EgammaEcalExtractor(){}
00024 
00025 reco::IsoDeposit EgammaEcalExtractor::deposit(const edm::Event & ev, const edm::EventSetup & evSetup, const reco::Candidate & candidate) const {
00026   edm::Handle<reco::SuperClusterCollection> superClusterCollectionH;
00027   edm::Handle<reco::BasicClusterCollection> basicClusterCollectionH;
00028   ev.getByLabel(superClusterTag_, superClusterCollectionH);
00029   ev.getByLabel(basicClusterTag_, basicClusterCollectionH);
00030 
00031   reco::SuperClusterRef sc = candidate.get<reco::SuperClusterRef>();
00032   math::XYZPoint position = sc->position();  
00033   // match the photon hybrid supercluster with those with Algo==0 (island)
00034   double delta1=1000.;
00035   double deltacur=1000.;
00036   const reco::SuperCluster *matchedsupercluster=0;
00037   bool MATCHEDSC = false;
00038 
00039   Direction candDir(position.eta(), position.phi());
00040   reco::IsoDeposit deposit(candDir );
00041   deposit.setVeto( reco::IsoDeposit::Veto(candDir, 0) ); // no veto is needed for this deposit
00042   deposit.addCandEnergy(sc->energy()*sin(2*atan(exp(-sc->eta()))));
00043 
00044   for(reco::SuperClusterCollection::const_iterator scItr = superClusterCollectionH->begin(); scItr != superClusterCollectionH->end(); ++scItr){
00045   
00046     const reco::SuperCluster *supercluster = &(*scItr);
00047    
00048     if(supercluster->seed()->algo() == 0){
00049       deltacur = ROOT::Math::VectorUtil::DeltaR(supercluster->position(), position); 
00050       if (deltacur < delta1) {
00051         delta1=deltacur;
00052         matchedsupercluster = supercluster;
00053         MATCHEDSC = true;
00054       }
00055     }
00056   }
00057 
00058   const reco::BasicCluster *cluster= 0;
00059   
00060   //loop over basic clusters
00061   for(reco::BasicClusterCollection::const_iterator cItr = basicClusterCollectionH->begin(); cItr != basicClusterCollectionH->end(); ++cItr){
00062  
00063     cluster = &(*cItr);
00064 //    double ebc_bcchi2 = cluster->chi2();
00065     int    ebc_bcalgo = cluster->algo();
00066     double ebc_bce    = cluster->energy();
00067     double ebc_bceta  = cluster->eta();
00068     double ebc_bcet   = ebc_bce*sin(2*atan(exp(ebc_bceta)));
00069     double newDelta = 0.;
00070 
00071     if (ebc_bcet > etMin_ && ebc_bcalgo == 0) {
00072 //      if (ebc_bcchi2 < 30.) {
00073         
00074         if(MATCHEDSC || !scmatch_ ){  //skip selection if user wants to fill all superclusters
00075           bool inSuperCluster = false;
00076 
00077           if( scmatch_ ){ // only try the matching if needed
00078             reco::CaloCluster_iterator theEclust = matchedsupercluster->clustersBegin();
00079             // loop over the basic clusters of the matched supercluster
00080             for(;theEclust != matchedsupercluster->clustersEnd(); ++theEclust) {
00081             if ((**theEclust) ==  (*cluster) ) inSuperCluster = true;
00082             }
00083           }
00084           if (!inSuperCluster || !scmatch_ ) {  //skip selection if user wants to fill all superclusters
00085             newDelta=ROOT::Math::VectorUtil::DeltaR(cluster->position(),position);
00086             if(newDelta < conesize_) {
00087               deposit.addDeposit( Direction(cluster->eta(), cluster->phi()), ebc_bcet);
00088             }
00089           }
00090         }
00091 //      } // matches ebc_bcchi2
00092     } // matches ebc_bcet && ebc_bcalgo
00093 
00094   }
00095   
00096   //  std::cout << "Will return ecalIsol = " << ecalIsol << std::endl; 
00097   return deposit;
00098   
00099 }