CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_8_patch3/src/DQMOffline/RecoB/src/EtaPtBin.cc

Go to the documentation of this file.
00001 #include "DQMOffline/RecoB/interface/EtaPtBin.h"
00002 
00003 #include <algorithm>
00004 #include <sstream>
00005 
00006 
00007 
00008 
00009 EtaPtBin::EtaPtBin ( const bool& etaActive_ , const double& etaMin_ , const double& etaMax_ ,
00010                      const bool& ptActive_  , const double& ptMin_  , const double& ptMax_ )
00011   : etaActive ( etaActive_ ) , etaMin ( etaMin_ ) , etaMax ( etaMax_ ) ,
00012     ptActive  (  ptActive_ ) , ptMin  (  ptMin_ ) , ptMax  (  ptMax_ )   {
00013 
00014   descriptionString = buildDescriptionString ( etaActive , etaMin , etaMax ,
00015                                                ptActive  , ptMin  , ptMax  );
00016 }
00017 
00018 
00019 
00020 std::string EtaPtBin::buildDescriptionString
00021                 ( const bool& etaActive_ , const double& etaMin_ , const double& etaMax_ ,
00022                   const bool& ptActive_  , const double& ptMin_  , const double& ptMax_)
00023 {
00024   // create string only from the active parts
00025   std::stringstream stream ( "" );
00026 
00027   if ( etaActive_ ) {
00028     stream << "_ETA_" << etaMin_ << "-" << etaMax_;
00029   }
00030 
00031   if ( ptActive_ ) {
00032     stream << "_PT_" << ptMin_ << "-" << ptMax_;
00033   }
00034   if (!(etaActive_||ptActive_)) stream << "_GLOBAL";
00035 
00036   std::string descr(stream.str());
00037   // remove blanks which are introduced when adding doubles
00038   std::remove(descr.begin(), descr.end(), ' ');
00039   std::replace(descr.begin(), descr.end(), '.' , 'v' );
00040 
00041   return descr;
00042 }
00043 
00044 bool EtaPtBin::inBin(const reco::Jet & jet) const
00045 {
00046   return inBin(jet.eta(), jet.pt());
00047 }
00048 
00049 // bool EtaPtBin::inBin(const BTagMCTools::JetFlavour & jetFlavour) const
00050 // {
00051 //   return inBin(jetFlavour.underlyingParton4Vec().Eta(),
00052 //             jetFlavour.underlyingParton4Vec().Pt());
00053 // }
00054 
00055 
00056 bool EtaPtBin::inBin (const double & eta , const double & pt ) const {
00057   if ( etaActive ) {
00058     if ( fabs(eta) < etaMin ) return false;
00059     if ( fabs(eta) > etaMax ) return false;
00060   }
00061 
00062   if ( ptActive ) {
00063     if ( pt < ptMin ) return false;
00064     if ( pt > ptMax ) return false;
00065   }
00066 
00067   return true;
00068 }