Main Page | Modules | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members

METSelector.cpp

Go to the documentation of this file.
00001 #include "caf_util/METSelector.hpp"
00002 #include "cafe/Stat.hpp"
00003 #include "tmb_tree/TMBMet.hpp"
00004 #include "met_util/BMetQualInfo.hpp"
00005 #include "cafe/Config.hpp"
00006 
00007 #include <sstream>
00008 
00009 using namespace std ;
00010 using namespace cafe ;
00011  
00012 namespace caf_util {
00013 
00014   METSelector::METSelector(const char *name) : cafe::Processor(name),
00015                                                _vars("_metqualinfos"),
00016                                                _mcvars("_nchunks")
00017   {
00018     // get parameters from the configuration file
00019     cafe::Config config(name);
00020 
00021     _fromBranch = config.get("From", "Met");
00022     out() << "METSelector \"" << name << "\" Read MET From: " << _fromBranch << endl ;
00023 
00024     _minMET = config.get("minMET", 0) ;
00025     _maxMET = config.get("maxMET", 0) ;
00026 
00027     _minSET = config.get("minSET", 0) ;
00028     _maxSET = config.get("maxSET", 0) ;
00029     
00030     string jetAlgoType = config.get("jetAlgoType","JCCB") ;
00031     bool jesMuCorrected = config.get("jesMuCorrected", false) ;
00032     _muCorrected = config.get("MuCorrected", false) ; 
00033     _MCsmeared = config.get("MCsmeared", true) ; 
00034 
00035     if (jetAlgoType != "JCCA" && jetAlgoType != "JCCB") {
00036       err() << "METSelector ERROR: .jetAlgoType should be JCCA or JCCB, you value is \"" 
00037             << jetAlgoType << "\". WILL USE JCCB!" << endl ;
00038       jetAlgoType = "JCCB" ;
00039     }      
00040 
00041     _algo = jetAlgoType ;
00042     if (!jesMuCorrected)  _algo = "corr" + _algo ;
00043     else _algo = "corrmu" + _algo ;
00044 
00045   };
00046   
00047   bool METSelector::processEvent(cafe::Event &event)
00048   {
00049     //get pointer to statistics collector
00050     StatPointer stat ;
00051     event.get("StatPointer", stat) ;
00052 
00053     // For MC : MC smearing "a la d0correct" on EM/jet/muons is propagated to MET
00054     // There is no additional MET oversmearing    if ( isMC )
00055     // No smearing for data
00056     string algo = _algo ;
00057     if (_MCsmeared && event.getMCEventInfo(_mcvars)->nchunks() > 0) algo = "smear_" + _algo ;
00058 
00059     const metid::BMetQualInfo* metqual =  event.get<TMBMet>(_fromBranch, _vars)->getMetQualInfo(algo) ;
00060 
00061     if (!metqual) {
00062       err() << "METSelector: pointer to the metid::BMetQualInfo object is 0!" 
00063             << " Algo name \"" << algo 
00064             << endl ;
00065       return false ;   
00066     }
00067 
00068     float met = -10.0;       
00069     float metx = -10.0;       
00070     float mety = -10.0;       
00071     float set = -10.0 ;
00072 
00073     if (!_muCorrected) {
00074       // MET corrected for CH+EM+JES
00075       met = metqual->getMETcorrCALO().getmet();
00076       metx = metqual->getMETcorrCALO().getmex();
00077       mety = metqual->getMETcorrCALO().getmey();
00078       set = metqual->getMETcorrCALO().getset();
00079     } else {
00080       // MET corrected for CH+EM+JES+muon
00081       met = metqual->getMETcorrCALOMU().getmet();
00082       metx = metqual->getMETcorrCALOMU().getmex();
00083       mety = metqual->getMETcorrCALOMU().getmey();
00084       set = metqual->getMETcorrCALOMU().getset();
00085     }
00086 
00087     event.put("caf_util::MET", met) ;
00088     event.put("caf_util::SET", set) ;
00089     event.put("caf_util::METx", metx) ;
00090     event.put("caf_util::METy", mety) ;
00091     
00092     if (debug() > 1) 
00093       out() << "METSelector: " 
00094             << " MET = " << met 
00095             << " METx = " << metx 
00096             << " METy = " << mety 
00097             << " SET = " << set 
00098             << " GeV for algo name \"" << algo << "\""      
00099             << endl ;
00100 
00101     if (_minMET > 0) {
00102       if (met < _minMET) return false ;
00103       ostringstream st ;
00104       st << "MET >= " << _minMET << " GeV" ;
00105       stat.EventSelected(st.str()) ;
00106     }
00107     
00108     if (_maxMET > 0) {
00109       if (met > _maxMET) return false ;
00110       ostringstream st ;
00111       st << "MET <= " << _maxMET << " GeV" ;
00112       stat.EventSelected(st.str()) ;
00113     }
00114 
00115     if (_minSET > 0) {
00116       if (set < _minSET) return false ;
00117       ostringstream st ;
00118       st << "SET >= " << _minSET << " GeV" ;
00119       stat.EventSelected(st.str()) ;
00120     }
00121     
00122     if (_maxSET > 0) {
00123       if (set > _maxSET) return false ;
00124       ostringstream st ;
00125       st << "SET <= " << _maxSET << " GeV" ;
00126       stat.EventSelected(st.str()) ;
00127     }
00128 
00129     return true  ;      
00130   };
00131 }
00132 ClassImp(caf_util::METSelector) ;
00133   

Generated on Tue Mar 28 10:13:04 2006 for CAF by doxygen 1.3.4