00001 /* File BTagJetSelector.hpp 00002 * 00003 * Created : Wed Feb 1 14:36:54 CST 2006 00004 * Author : Aran GARCIA-BELLIDO, aran@fnal.gov 00005 * Purpose : Select events that contain certain number of b-tagged jets 00006 * Last modified : 00007 * Comments : 00008 */ 00009 00010 #include "cafe/Config.hpp" 00011 #include "caf_util/BTagJetSelector.hpp" 00012 #include <sstream> 00013 00014 using namespace std; 00015 using namespace cafe; 00016 00017 namespace caf_util { 00018 00019 // Constructor, destructor: 00020 BTagJetSelector::BTagJetSelector(const char *name) : cafe::SelectUserObjects<TMBJet>(name), 00021 _nselected(0),_vars("_nchunks") 00022 { 00023 // Here you can read parameters from the config file: 00024 cafe::Config config(name); 00025 00026 _nbjets = config.get("nBJets",1); 00027 _nbjetsmax = config.get("nBJetsMax",-1); 00028 _btagAlgo = config.get("BTagAlgo","EMPTY"); 00029 _btagPoint = config.get("Cut","EMPTY"); 00030 00031 // Report 00032 cout << "\nBTagJetSelector instantiated" 00033 << "\n Tagger: " << _btagAlgo 00034 << "\n Cut level: " << _btagPoint 00035 << "\n # b jets >= " << _nbjets << endl; 00036 if (_nbjetsmax!=0) cout << " # b jets <= " << _nbjetsmax << endl; 00037 00038 } 00039 00040 BTagJetSelector::~BTagJetSelector() 00041 { 00042 00043 } 00044 00045 bool BTagJetSelector::processEvent(cafe::Event& event) 00046 { 00047 _isMC=false; 00048 if (event.getMCEventInfo(_vars)!=NULL) _isMC=true; 00049 // if (_isMC==true) return false; 00050 00051 _nselected = 0; 00052 00053 // Get pointer to statistics collector 00054 event.get("StatPointer", _stat) ; 00055 00056 // Do the actual selection: 00057 SelectUserObjects<TMBJet>::processEvent(event) ; 00058 00059 // Accounting: 00060 for (int i = 1; i <= _nbjets; i++) { 00061 if (_nselected < i) return false; 00062 ostringstream st; 00063 st << "Number of b-jets >= " << i; 00064 _stat.EventSelected(st.str()); 00065 } 00066 00067 if (_nbjetsmax >= 0) { 00068 if (_nselected > _nbjetsmax) return false ; 00069 ostringstream st; 00070 st << "Number of b-jets <= " << _nbjetsmax ; 00071 _stat.EventSelected(st.str()); 00072 } 00073 00074 return true; 00075 } 00076 00077 bool BTagJetSelector::selectObject(const TMBJet &jet) 00078 { 00079 if (jet.taggable() == -1) { 00080 cout << "Taggability not run: BAD or EM jet" << endl; 00081 return false; 00082 } 00083 // Check taggability: 00084 if (jet.taggable() == 0) return false; 00085 // Check if it is taggable and tagged: 00086 if (jet.taggable() == 1) { 00087 // ok, this is taggable, mark it in the Stat: 00088 if (_nbjets > 0) _stat.EventSelected("Taggable Jet"); 00089 // Instantiate the TMBBTag information for this jet: 00090 const TMBBTag* btaginfo = jet.GetBTag(_btagAlgo, _btagPoint); // e.g. ("NN", "L4") 00091 if (! btaginfo) {throw std::runtime_error("BTagJetSelector: Can't find required b-tag");} 00092 if (!btaginfo->is_tagged()) return false; 00093 ostringstream st; 00094 st << _btagAlgo << " " << _btagPoint << " Tagged Jet"; 00095 if (_nbjets > 0) _stat.EventSelected(st.str()); 00096 _nselected++; 00097 } 00098 return true; 00099 }; 00100 00101 void BTagJetSelector::before(Collection<TMBJet>& from) 00102 { 00103 // empty 00104 }; 00105 00106 } 00107 00108 ClassImp(caf_util::BTagJetSelector); 00109
1.3.4