CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_6_2_5/src/CommonTools/ParticleFlow/plugins/PFCandWithSuperClusterExtractor.cc

Go to the documentation of this file.
00001 #include "PFCandWithSuperClusterExtractor.h"
00002 
00003 #include "RecoMuon/MuonIsolation/interface/Range.h"
00004 #include "DataFormats/RecoCandidate/interface/IsoDepositDirection.h"
00005 #include "DataFormats/Common/interface/Handle.h"
00006 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00007 #include "DataFormats/Math/interface/deltaR.h"
00008 #include "DataFormats/GsfTrackReco/interface/GsfTrack.h"
00009 
00010 using namespace edm;
00011 using namespace reco;
00012 
00013 PFCandWithSuperClusterExtractor::PFCandWithSuperClusterExtractor( const ParameterSet& par ) :
00014   thePFCandTag(par.getParameter<edm::InputTag>("inputCandView")),
00015   theDepositLabel(par.getUntrackedParameter<std::string>("DepositLabel")),
00016   theVetoSuperClusterMatch(par.getParameter<bool>("SCMatch_Veto")),
00017   theMissHitVetoSuperClusterMatch(par.getParameter<bool>("MissHitSCMatch_Veto")),
00018   theDiff_r(par.getParameter<double>("Diff_r")),
00019   theDiff_z(par.getParameter<double>("Diff_z")),
00020   theDR_Max(par.getParameter<double>("DR_Max")),
00021   theDR_Veto(par.getParameter<double>("DR_Veto"))
00022 {
00023   //  std::cout << " Loading PFCandWithSuperClusterExtractor "  << std::endl;
00024 }
00025 /*
00026 reco::IsoDeposit::Vetos PFCandWithSuperClusterExtractor::vetos(const edm::Event & ev,
00027       const edm::EventSetup & evSetup, const reco::Candidate & cand) const
00028 {
00029   reco::isodeposit::Direction dir(cand.eta(),cand.phi());
00030   return reco::IsoDeposit::Vetos(1,veto(dir));
00031 }
00032 */
00033 
00034 reco::IsoDeposit::Veto PFCandWithSuperClusterExtractor::veto(const reco::IsoDeposit::Direction & dir) const
00035 {
00036   reco::IsoDeposit::Veto result;
00037   result.vetoDir = dir;
00038   result.dR = theDR_Veto;
00039   return result;
00040 }
00041 
00042 
00043 IsoDeposit PFCandWithSuperClusterExtractor::depositFromObject(const Event & event, const EventSetup & eventSetup, const Photon & cand) const
00044 {
00045     reco::isodeposit::Direction candDir(cand.eta(), cand.phi());
00046     IsoDeposit deposit(candDir );
00047     deposit.setVeto( veto(candDir) );
00048     deposit.addCandEnergy(cand.pt());
00049 
00050     Handle< PFCandidateCollection > PFCandH;
00051     event.getByLabel(thePFCandTag, PFCandH);
00052 
00053     double eta = cand.eta(), phi = cand.phi();
00054     reco::Particle::Point vtx = cand.vertex();
00055     for (PFCandidateCollection::const_iterator it = PFCandH->begin(), ed = PFCandH->end(); it != ed; ++it) {
00056       double dR = deltaR(it->eta(), it->phi(), eta, phi);
00057       // veto SC 
00058       if (theVetoSuperClusterMatch && cand.superCluster().isNonnull() && it->superClusterRef().isNonnull() && cand.superCluster() == it->superClusterRef()) continue;
00059       if ( (dR < theDR_Max) && (dR > theDR_Veto) &&
00060            (std::abs(it->vz() - cand.vz()) < theDiff_z) &&
00061            ((it->vertex() - vtx).Rho() < theDiff_r)) {
00062         // ok
00063         reco::isodeposit::Direction dirTrk(it->eta(), it->phi());
00064         deposit.addDeposit(dirTrk, it->pt());
00065       }
00066     }
00067     
00068     return deposit;
00069 }
00070 
00071 
00072 IsoDeposit PFCandWithSuperClusterExtractor::depositFromObject(const Event & event, const EventSetup & eventSetup, const GsfElectron & cand) const
00073 {
00074     reco::isodeposit::Direction candDir(cand.eta(), cand.phi());
00075     IsoDeposit deposit(candDir );
00076     deposit.setVeto( veto(candDir) );
00077     deposit.addCandEnergy(cand.pt());
00078 
00079     Handle< PFCandidateCollection > PFCandH;
00080     event.getByLabel(thePFCandTag, PFCandH);
00081 
00082     double eta = cand.eta(), phi = cand.phi();
00083     reco::Particle::Point vtx = cand.vertex();
00084     for (PFCandidateCollection::const_iterator it = PFCandH->begin(), ed = PFCandH->end(); it != ed; ++it) {
00085       double dR = deltaR(it->eta(), it->phi(), eta, phi);
00086       // If MissHits>0 (possibly reconstructed as a photon in the PF in this case, kill the the photon if sharing the same SC)
00087       if (cand.gsfTrack()->trackerExpectedHitsInner().numberOfHits()>0 && theMissHitVetoSuperClusterMatch && 
00088           it->mva_nothing_gamma() > 0.99 && cand.superCluster().isNonnull() 
00089           && it->superClusterRef().isNonnull() 
00090           && cand.superCluster() == it->superClusterRef())   continue;
00091       if ( (dR < theDR_Max) && (dR > theDR_Veto) &&
00092            (std::abs(it->vz() - cand.vz()) < theDiff_z) &&
00093            ((it->vertex() - vtx).Rho() < theDiff_r)) {
00094         // ok
00095         reco::isodeposit::Direction dirTrk(it->eta(), it->phi());
00096         deposit.addDeposit(dirTrk, it->pt());
00097       }
00098     }
00099     
00100     return deposit;
00101 }
00102 
00103 
00104 
00105 IsoDeposit PFCandWithSuperClusterExtractor::depositFromObject(const Event & event, const EventSetup & eventSetup, const Track & cand) const
00106 {
00107     reco::isodeposit::Direction candDir(cand.eta(), cand.phi());
00108     IsoDeposit deposit(candDir );
00109     deposit.setVeto( veto(candDir) );
00110     deposit.addCandEnergy(cand.pt());
00111     Handle< PFCandidateCollection > PFCandH;
00112     event.getByLabel(thePFCandTag, PFCandH);
00113 
00114     double eta = cand.eta(), phi = cand.phi();
00115     reco::Particle::Point vtx = cand.vertex();
00116     for (PFCandidateCollection::const_iterator it = PFCandH->begin(), ed = PFCandH->end(); it != ed; ++it) {
00117         double dR = deltaR(it->eta(), it->phi(), eta, phi);
00118 
00119         if ( (dR < theDR_Max) && (dR > theDR_Veto) &&
00120                 (std::abs(it->vz() - cand.vz()) < theDiff_z) &&
00121                 ((it->vertex() - vtx).Rho() < theDiff_r)) {
00122             // ok
00123             reco::isodeposit::Direction dirTrk(it->eta(), it->phi());
00124             deposit.addDeposit(dirTrk, it->pt());
00125         }
00126     }
00127     
00128     return deposit;
00129 }
00130 
00131 
00132 IsoDeposit PFCandWithSuperClusterExtractor::depositFromObject(const Event & event, const EventSetup & eventSetup, const PFCandidate & cand) const
00133 {
00134     reco::isodeposit::Direction candDir(cand.eta(), cand.phi());
00135     IsoDeposit deposit(candDir );
00136     deposit.setVeto( veto(candDir) );
00137     deposit.addCandEnergy(cand.pt());
00138     Handle< PFCandidateCollection > PFCandH;
00139     event.getByLabel(thePFCandTag, PFCandH);
00140 
00141     double eta = cand.eta(), phi = cand.phi();
00142     reco::Particle::Point vtx = cand.vertex();
00143     for (PFCandidateCollection::const_iterator it = PFCandH->begin(), ed = PFCandH->end(); it != ed; ++it) {
00144       // veto SC 
00145       if (theVetoSuperClusterMatch && cand.superClusterRef().isNonnull() && it->superClusterRef().isNonnull() && cand.superClusterRef() == it->superClusterRef()) continue;
00146       double dR = deltaR(it->eta(), it->phi(), eta, phi);
00147       
00148       if ( (dR < theDR_Max) && (dR > theDR_Veto) &&
00149            (std::abs(it->vz() - cand.vz()) < theDiff_z) &&
00150            ((it->vertex() - vtx).Rho() < theDiff_r)) {
00151         // ok
00152         reco::isodeposit::Direction dirTrk(it->eta(), it->phi());
00153         deposit.addDeposit(dirTrk, it->pt());
00154       }
00155     }
00156     
00157     return deposit;
00158 }
00159 
00160 
00161  
00162 #include "FWCore/PluginManager/interface/ModuleDef.h"
00163 #include "FWCore/Framework/interface/MakerMacros.h"
00164 
00165 
00166 #include "PhysicsTools/IsolationAlgos/interface/IsoDepositExtractor.h"
00167 #include "PhysicsTools/IsolationAlgos/interface/IsoDepositExtractorFactory.h"
00168 #include "PFCandWithSuperClusterExtractor.h"
00169 DEFINE_EDM_PLUGIN(IsoDepositExtractorFactory, PFCandWithSuperClusterExtractor, "PFCandWithSuperClusterExtractor");