CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_2_SLHC2/src/CommonTools/ParticleFlow/src/PFIsoDepositAlgo.cc

Go to the documentation of this file.
00001 #include "CommonTools/ParticleFlow/interface/PFIsoDepositAlgo.h"
00002 
00003 #include "DataFormats/ParticleFlowCandidate/interface/PFCandidate.h"
00004 
00005 #include "DataFormats/Math/interface/LorentzVector.h"
00006 
00007 #include "FWCore/Framework/interface/EventSetup.h"
00008 
00009 
00010 using namespace std;
00011 using namespace edm;
00012 using namespace reco;
00013 using namespace math;
00014 using namespace pf2pat;
00015 
00016 PFIsoDepositAlgo::PFIsoDepositAlgo(const edm::ParameterSet& iConfig): 
00017   verbose_ ( iConfig.getUntrackedParameter<bool>("verbose",false) )
00018 
00019 {}
00020 
00021 
00022 
00023 PFIsoDepositAlgo::~PFIsoDepositAlgo() { }
00024 
00025 
00026 const PFIsoDepositAlgo::IsoDeposits&  
00027 PFIsoDepositAlgo::produce( const ParticleCollection& toBeIsolated,
00028                            const ParticleCollection& forIsolation) {
00029   
00030 
00031   isoDeposits_.clear();
00032   isoDeposits_.reserve( toBeIsolated.size() );
00033 
00034   for( unsigned i=0; i<toBeIsolated.size(); i++ ) {
00035     const reco::PFCandidate& toBeIso = toBeIsolated[i];
00036 
00037     if(verbose_ ) 
00038       cout<<"to be isolated: "<<toBeIso<<endl;
00039 
00040     isoDeposits_.push_back( buildIsoDeposit( toBeIso, forIsolation ) ); 
00041   }
00042   
00043 
00044   if(verbose_) {
00045     cout<<"PFIsoDepositAlgo "<<endl;
00046   }
00047 
00048   return isoDeposits_;
00049 }
00050 
00051 
00052 IsoDeposit PFIsoDepositAlgo::buildIsoDeposit( const Particle& particle, 
00053                                               const ParticleCollection& forIsolation ) const {
00054   
00055 
00056   reco::isodeposit::Direction pfDir(particle.eta(), 
00057                                     particle.phi());
00058 //   reco::IsoDeposit::Veto veto;
00059 //   veto.vetoDir = pfDir;
00060 //   veto.dR = 0.05; 
00061 
00062   IsoDeposit isoDep( pfDir );
00063   
00064   for( unsigned i=0; i<forIsolation.size(); i++ ) {
00065     
00066     const reco::PFCandidate& pfc = forIsolation[i];
00067 
00068     // need to remove "particle"!
00069 
00070     if( sameParticle( particle, pfc ) ) continue; 
00071 
00072 
00073     XYZTLorentzVector pvi(pfc.p4());
00074     reco::isodeposit::Direction dirPfc(pfc.eta(), pfc.phi());
00075     double dR = pfDir.deltaR(dirPfc);
00076 
00077     //COLIN make a parameter
00078     double maxDeltaRForIsoDep_ = 1;
00079     if(dR > maxDeltaRForIsoDep_) {
00080       //      if( verbose_ ) cout<<"OUT OF CONE"<<endl;
00081       continue;
00082     }
00083     //    else if(verbose_) cout<<endl;
00084 
00085     if(verbose_ ) 
00086       cout<<"\t"<<pfc<<endl;
00087 
00088     double pt = pvi.Pt();
00089     isoDep.addDeposit(dirPfc, pt); 
00090   }
00091 
00092   return isoDep;
00093 }
00094 
00095 
00096 bool PFIsoDepositAlgo::sameParticle( const Particle& particle1,
00097                                      const Particle& particle2 ) const {
00098 
00099   double smallNumber = 1e-15;
00100   
00101   if( particle1.particleId() != particle2.particleId() ) return false;
00102   else if( fabs( particle1.energy() - particle2.energy() ) > smallNumber ) return false;
00103   else if( fabs( particle1.eta() - particle2.eta() ) > smallNumber ) return false;
00104   else if( fabs( particle1.eta() - particle2.eta() ) > smallNumber ) return false;
00105   else return true; 
00106   
00107 }