00001 #include "caf_util/TopologicalSelector.hpp"
00002 #include "cafe/Stat.hpp"
00003 #include "cafe/Config.hpp"
00004
00005 #include <sstream>
00006
00007 using namespace std ;
00008 using namespace cafe ;
00009
00010 namespace caf_util {
00011
00012 TopologicalSelector::TopologicalSelector(const char *name) : cafe::Processor(name),
00013 _jetvars("fX","fY"),
00014 _emvars("fX","fY"),
00015 _muvars("fX","fY")
00016 {
00017
00018 cafe::Config config(name);
00019
00020 _electronBranch = config.get("electronBranch", "EMscone") ;
00021 _muonBranch = config.get("muonBranch", "Muon") ;
00022 _jetBranch = config.get("jetBranch", "JCCB") ;
00023
00024 _nelectrons = config.get("nelectrons", -1) ;
00025 _nmuons = config.get("nmuons", -1) ;
00026 _njets = config.get("njets", -1) ;
00027
00028 _minHT = config.get("minHT", 0) ;
00029 _maxHT = config.get("maxHT", 0) ;
00030
00031 _minHTleadL = config.get("minHTleadL", 0) ;
00032 _maxHTleadL = config.get("maxHTleadL", 0) ;
00033
00034 _minHTleptons = config.get("minHTleptons", 0) ;
00035 _maxHTleptons = config.get("maxHTleptons", 0) ;
00036
00037 _calcHT = config.get("CalculateHT", true);
00038 _calcHTLeadL = config.get("CalculateHTleadL", false);
00039 _calcHTLeptons = config.get("CalculateHTleptons", false);
00040
00041 _htVarName = config.get("HTVarName", "HT");
00042 _htLeadLVarName = config.get("HTVarLeadLName", "HTleadL");
00043 _htLeptonsVarName = config.get("HTVarLeptonsName", "HTleptons");
00044
00045 }
00046
00047 bool TopologicalSelector::processEvent(cafe::Event &event)
00048 {
00049
00050 StatPointer stat ;
00051 event.get("StatPointer", stat) ;
00052
00053
00054
00055 if (_njets != 0 && (_calcHT || _minHT >0 || _maxHT > 0) ) {
00056
00057 Collection<TMBJet> from(event.getCollection<TMBJet>(_jetBranch.c_str(), _jetvars));
00058 if (from.size() == 0) {
00059 out() << "TOPOLOGICAL SELECTOR WARNING! Jet branch "
00060 << _jetBranch << " is empty or is not existing! "
00061 << endl ;
00062 return false ;
00063 }
00064
00065 float HT = 0 ;
00066 for(Collection<TMBJet>::const_iterator it = from.begin() ;
00067 it != from.end(); ++it)
00068 if (_njets < 0 || it - from.begin() < _njets) HT += it->Pt() ;
00069
00070 if(_htVarName!="") event.put(_htVarName, HT);
00071
00072 if (_minHT > 0) {
00073 if (HT < _minHT) return false ;
00074
00075 ostringstream st ;
00076 st << "HT >= " << _minHT << " GeV" ;
00077 stat.EventSelected(st.str()) ;
00078 }
00079
00080 if (_maxHT > 0) {
00081 if (HT > _maxHT) return false ;
00082
00083 ostringstream st ;
00084 st << "HT <= " << _maxHT << " GeV" ;
00085 stat.EventSelected(st.str()) ;
00086 }
00087 }
00088
00089
00090
00091
00092 if (_calcHTLeptons || _minHTleptons >0 || _maxHTleptons > 0) {
00093
00094 float HT = 0 ;
00095 if (_njets != 0) {
00096 Collection<TMBJet> from(event.getCollection<TMBJet>(_jetBranch.c_str(), _emvars));
00097 if (from.size() == 0) {
00098 out() << "TOPOLOGICAL SELECTOR WARNING! Jet branch "
00099 << _jetBranch << " is empty or is not existing! "
00100 << endl ;
00101 return false ;
00102 }
00103
00104 for(Collection<TMBJet>::const_iterator it = from.begin() ;
00105 it != from.end(); ++it)
00106 if (_njets < 0 || it - from.begin() < _njets) HT += it->Pt() ;
00107 }
00108
00109 if (_nmuons != 0) {
00110 Collection<TMBMuon> from(event.getCollection<TMBMuon>(_muonBranch.c_str(), _muvars));
00111 if (from.size() == 0) {
00112 out() << "TOPOLOGICAL SELECTOR WARNING! Muon branch "
00113 << _muonBranch << " is empty or is not existing! "
00114 << endl ;
00115 return false ;
00116 }
00117
00118 for(Collection<TMBMuon>::const_iterator it = from.begin() ;
00119 it != from.end(); ++it)
00120 if (_nmuons < 0 || it - from.begin() <= _nmuons) HT += it->Pt() ;
00121 }
00122
00123
00124 if (_nelectrons != 0) {
00125 Collection<TMBEMCluster> from(event.getCollection<TMBEMCluster>(_electronBranch.c_str(),_emvars));
00126 if (from.size() == 0) {
00127 out() << "TOPOLOGICAL SELECTOR WARNING! Electron branch "
00128 << _electronBranch << " is empty or is not existing! "
00129 << endl ;
00130 return false ;
00131 }
00132
00133 for(Collection<TMBEMCluster>::const_iterator it = from.begin() ;
00134 it != from.end(); ++it)
00135 if (_nelectrons < 0 || it - from.begin() <= _nelectrons) HT += it->Pt() ;
00136 }
00137
00138 if(_htLeptonsVarName!="") event.put(_htLeptonsVarName, HT);
00139
00140 if (_minHTleptons > 0) {
00141 if (HT < _minHTleptons) return false ;
00142
00143 ostringstream st ;
00144 st << "HT (with leptons) >= " << _minHTleptons << " GeV" ;
00145 stat.EventSelected(st.str()) ;
00146 }
00147
00148 if (_maxHTleptons > 0) {
00149 if (HT > _maxHTleptons) return false ;
00150
00151 ostringstream st ;
00152 st << "HT (with leptons) <= " << _maxHTleptons << " GeV" ;
00153 stat.EventSelected(st.str()) ;
00154 }
00155 }
00156
00157
00158
00159
00160 if (_calcHTLeadL || _minHTleadL >0 || _maxHTleadL > 0) {
00161
00162 float HT = 0 ;
00163 if (_njets != 0) {
00164 Collection<TMBJet> from(event.getCollection<TMBJet>(_jetBranch.c_str(),_jetvars));
00165 if (from.size() == 0) {
00166 out() << "TOPOLOGICAL SELECTOR WARNING! Jet branch "
00167 << _jetBranch << " is empty or is not existing! "
00168 << endl ;
00169 return false ;
00170 }
00171
00172 for(Collection<TMBJet>::const_iterator it = from.begin() ;
00173 it != from.end(); ++it)
00174 if (_njets < 0 || it - from.begin() < _njets) HT += it->Pt() ;
00175 }
00176
00177 float leadPT = 0 ;
00178 if (_nmuons != 0) {
00179 Collection<TMBMuon> from(event.getCollection<TMBMuon>(_muonBranch.c_str(),_muvars));
00180 if (from.size() == 0) {
00181 out() << "TOPOLOGICAL SELECTOR WARNING! Muon branch "
00182 << _muonBranch << " is empty or is not existing! "
00183 << endl ;
00184 return false ;
00185 }
00186
00187 for(Collection<TMBMuon>::const_iterator it = from.begin() ;
00188 it != from.end(); ++it)
00189 if (it->Pt() > leadPT ) leadPT = it->Pt() ;
00190 }
00191
00192
00193 if (_nelectrons != 0) {
00194 Collection<TMBEMCluster> from(event.getCollection<TMBEMCluster>(_electronBranch.c_str(),_emvars));
00195 if (from.size() == 0) {
00196 out() << "TOPOLOGICAL SELECTOR WARNING! Electron branch "
00197 << _electronBranch << " is empty or is not existing! "
00198 << endl ;
00199 return false ;
00200 }
00201
00202 for(Collection<TMBEMCluster>::const_iterator it = from.begin() ;
00203 it != from.end(); ++it)
00204 if (it->Pt() > leadPT ) leadPT = it->Pt() ;
00205 }
00206
00207 HT += leadPT ;
00208
00209 if(_htLeadLVarName!="") event.put(_htLeadLVarName, HT);
00210
00211 if (_minHTleadL > 0) {
00212 if (HT < _minHTleadL) return false ;
00213
00214 ostringstream st ;
00215 st << "HT (with leading lepton) >= " << _minHTleadL << " GeV" ;
00216 stat.EventSelected(st.str()) ;
00217 }
00218
00219 if (_maxHTleadL > 0) {
00220 if (HT > _maxHTleadL) return false ;
00221
00222 ostringstream st ;
00223 st << "HT (with leading lepton) <= " << _maxHTleadL << " GeV" ;
00224 stat.EventSelected(st.str()) ;
00225 }
00226 }
00227
00228
00229 return true ;
00230
00231 }
00232 }
00233 ClassImp(caf_util::TopologicalSelector) ;
00234