Go to the documentation of this file.00001 #ifndef PhysicsTools_PatUtils_interface_ElectronVPlusJetsIDSelectionFunctor_h
00002 #define PhysicsTools_PatUtils_interface_ElectronVPlusJetsIDSelectionFunctor_h
00003
00004 #include "DataFormats/PatCandidates/interface/Electron.h"
00005 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00006
00007 #include "PhysicsTools/SelectorUtils/interface/Selector.h"
00008 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00009
00010 class ElectronVPlusJetsIDSelectionFunctor : public Selector<pat::Electron> {
00011
00012 public:
00013
00014 enum Version_t { SUMMER08, FIRSTDATA, N_VERSIONS };
00015
00016 ElectronVPlusJetsIDSelectionFunctor() {}
00017
00018 ElectronVPlusJetsIDSelectionFunctor( edm::ParameterSet const & parameters ){
00019
00020 std::string versionStr = parameters.getParameter<std::string>("version");
00021 if ( versionStr != "FIRSTDATA") {
00022 std::cout << "The version " << versionStr << " is deprecated. Setting to FIRSTDATA" << std::endl;
00023 }
00024
00025 if (versionStr == "FIRSTDATA") {
00026 initialize( FIRSTDATA,
00027 parameters.getParameter<double>("D0"),
00028 parameters.getParameter<double>("ED0"),
00029 parameters.getParameter<double>("SD0"),
00030 parameters.getParameter<double>("RelIso") );
00031 if ( parameters.exists("cutsToIgnore") )
00032 setIgnoredCuts( parameters.getParameter<std::vector<std::string> >("cutsToIgnore") );
00033 } else {
00034 throw cms::Exception("InvalidInput") << "Expect version to be one of SUMMER08, FIRSTDATA," << std::endl;
00035 }
00036
00037 retInternal_ = getBitTemplate();
00038
00039 }
00040
00041
00042 ElectronVPlusJetsIDSelectionFunctor( Version_t version,
00043 double d0 = 0.2,
00044 double ed0 = 999.0,
00045 double sd0 = 999.0,
00046 double reliso = 0.1) {
00047 initialize( version, d0, ed0, sd0, reliso );
00048 }
00049
00050
00051 void initialize( Version_t version,
00052 double d0,
00053 double ed0,
00054 double sd0,
00055 double reliso)
00056 {
00057 version_ = version;
00058
00059 push_back("D0", d0);
00060 push_back("ED0", ed0);
00061 push_back("SD0", sd0);
00062 push_back("RelIso", reliso);
00063
00064
00065 set("D0");
00066 set("ED0");
00067 set("SD0");
00068 set("RelIso");
00069
00070
00071 indexD0_ = index_type(&bits_, "D0" );
00072 indexED0_ = index_type(&bits_, "ED0" );
00073 indexSD0_ = index_type(&bits_, "SD0" );
00074 indexRelIso_ = index_type(&bits_, "RelIso" );
00075
00076 }
00077
00078
00079 bool operator()( const pat::Electron & electron, pat::strbitset & ret )
00080 {
00081 if ( version_ == FIRSTDATA ) return firstDataCuts( electron, ret );
00082 else {
00083 return false;
00084 }
00085 }
00086
00087 using Selector<pat::Electron>::operator();
00088
00089
00090 bool firstDataCuts( const pat::Electron & electron, pat::strbitset & ret)
00091 {
00092
00093 ret.set(false);
00094 double corr_d0 = electron.dB();
00095 double corr_ed0 = electron.edB();
00096 double corr_sd0 = ( corr_ed0 > 0.000000001 ) ? corr_d0 / corr_ed0 : 999.0;
00097
00098 double hcalIso = electron.dr03HcalTowerSumEt();
00099 double ecalIso = electron.dr03EcalRecHitSumEt();
00100 double trkIso = electron.dr03TkSumPt();
00101 double et = electron.et() ;
00102
00103 double relIso = (ecalIso + hcalIso + trkIso) / et;
00104
00105 if ( fabs(corr_d0) < cut(indexD0_, double()) || ignoreCut(indexD0_) ) passCut(ret, indexD0_ );
00106 if ( fabs(corr_ed0)< cut(indexED0_, double()) || ignoreCut(indexED0_) ) passCut(ret, indexED0_ );
00107 if ( fabs(corr_sd0)< cut(indexSD0_, double()) || ignoreCut(indexSD0_) ) passCut(ret, indexSD0_ );
00108 if ( relIso < cut(indexRelIso_, double()) || ignoreCut(indexRelIso_) ) passCut(ret, indexRelIso_ );
00109
00110 setIgnored(ret);
00111 return (bool)ret;
00112 }
00113
00114
00115 private:
00116
00117 Version_t version_;
00118
00119 index_type indexD0_;
00120 index_type indexED0_;
00121 index_type indexSD0_;
00122 index_type indexRelIso_;
00123
00124 };
00125
00126 #endif