CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_5_3_14/src/DQMOffline/RecoB/src/AcceptJet.cc

Go to the documentation of this file.
00001 #include "DQMOffline/RecoB/interface/AcceptJet.h"
00002 #include "DataFormats/Math/interface/deltaR.h"
00003 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00004 
00005 #include<iostream>
00006 
00007 using namespace std;
00008 
00009 AcceptJet::AcceptJet(const double& etaMin_, const double& etaMax_, const double& ptMin_, const double& ptMax_,
00010           const double& pMin_, const double& pMax_, const double& ratioMin_, const double& ratioMax_) :
00011   etaMin(etaMin_), etaMax(etaMax_), ptRecJetMin(ptMin_), ptRecJetMax(ptMax_), pRecJetMin(pMin_),
00012   pRecJetMax(pMax_), ratioMin(ratioMin_), ratioMax(ratioMax_) {}
00013 
00014 
00015 bool AcceptJet::operator() (const reco::Jet & jet, const int & jetFlavour, const edm::Handle<reco::SoftLeptonTagInfoCollection> & infos) const
00016 {
00017 
00018   // temporary fudge to correct for double loop error
00019   //  jetPartonMomentum /= 2.0;
00020 
00021   if ( fabs(jet.eta()) < etaMin  ||
00022        fabs(jet.eta()) > etaMax  ) return false;
00023 
00024 //   if ( jetFlavour.underlyingParton4Vec().P() < pPartonMin  ||
00025 //        jetFlavour.underlyingParton4Vec().P() > pPartonMax  ) accept = false;
00026 // 
00027 //   if ( jetFlavour.underlyingParton4Vec().Pt() < ptPartonMin  ||
00028 //        jetFlavour.underlyingParton4Vec().Pt() > ptPartonMax  ) accept = false;
00029 
00030   if ( jet.pt() < ptRecJetMin ||
00031        jet.pt() > ptRecJetMax ) return false;
00032 
00033   if ( jet.p() < pRecJetMin ||
00034        jet.p() > pRecJetMax ) return false;
00035 
00036   if ( !infos.isValid() ) {
00037     edm::LogWarning("infos not valid") << "A valid SoftLeptonTagInfoCollection was not found!"
00038                                      << " Skipping ratio check.";
00039   }
00040   else {
00041     double pToEratio = ratio( jet, infos );
00042     if ( pToEratio < ratioMin ||
00043          pToEratio > ratioMax ) return false;
00044   }
00045 
00046   return true;
00047 }
00048 
00049 double AcceptJet::ratio(const reco::Jet & jet, const edm::Handle<reco::SoftLeptonTagInfoCollection>& infos) const
00050 {
00051   double jetRatio = 0.0;
00052   reco::SoftLeptonTagInfoCollection::const_iterator infoiter = infos->begin();
00053   for( ; infoiter != infos->end(); ++infoiter)
00054   {
00055     if( reco::deltaR(jet.eta(), jet.phi(), infoiter->jet()->eta(), infoiter->jet()->phi()) > 1e-4 )
00056       continue;
00057 
00058     if( infoiter->leptons() == 0 )
00059       break;
00060 
00061     for( unsigned int k = 0; k != infoiter->leptons(); ++k )
00062     {
00063       double tempRatio = infoiter->properties(k).ratio;
00064       if( tempRatio > jetRatio )
00065         jetRatio = tempRatio;
00066     }
00067   }
00068 
00069   return jetRatio;
00070 }