CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch13/src/HLTriggerOffline/SUSYBSM/src/RecoSelector.cc

Go to the documentation of this file.
00001 /*  \class RecoSelector
00002 *
00003 *  Class to apply analysis cuts in the TriggerValidation Code
00004 *
00005 *  Author: Massimiliano Chiorboli      Date: August 2007
00006 //         Maurizio Pierini
00007 //         Maria Spiropulu
00008 *
00009 */
00010 
00011 #include "HLTriggerOffline/SUSYBSM/interface/RecoSelector.h"
00012 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00013 
00014 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00015 
00016 using namespace edm;
00017 using namespace reco;
00018 using namespace std;
00019 
00020 RecoSelector::RecoSelector(edm::ParameterSet userCut_params)
00021 {
00022 
00023   name                   = userCut_params.getParameter<string>("name");
00024   m_electronSrc          = userCut_params.getParameter<string>("electrons");
00025   m_muonSrc              = userCut_params.getParameter<string>("muons");
00026   m_jetsSrc              = userCut_params.getParameter<string>("jets");
00027   m_photonProducerSrc    = userCut_params.getParameter<string>("photonProducer");
00028   m_photonSrc            = userCut_params.getParameter<string>("photons");
00029   m_calometSrc           = userCut_params.getParameter<string>("calomet");
00030 
00031   reco_metMin    = userCut_params.getParameter<double>("reco_metMin") ;
00032   reco_ptJet1Min = userCut_params.getParameter<double>("reco_ptJet1Min");
00033   reco_ptJet2Min = userCut_params.getParameter<double>("reco_ptJet2Min");
00034   reco_ptElecMin = userCut_params.getParameter<double>("reco_ptElecMin");
00035   reco_ptMuonMin = userCut_params.getParameter<double>("reco_ptMuonMin");
00036   reco_ptPhotMin = userCut_params.getParameter<double>("reco_ptPhotMin");
00037 
00038   edm::LogInfo("RecoSelectorParameters") << endl;
00039   edm::LogInfo("RecoSelectorParameters") << "UserAnalysis parameters for " << name << " selection:" << endl;
00040   edm::LogInfo("RecoSelectorParameters") << " reco_metMin    = " << reco_metMin << endl;
00041   edm::LogInfo("RecoSelectorParameters") << " reco_ptJet1Min = " << reco_ptJet1Min  << endl;
00042   edm::LogInfo("RecoSelectorParameters") << " reco_ptJet2Min = " << reco_ptJet2Min  << endl;
00043   edm::LogInfo("RecoSelectorParameters") << " reco_ptElecMin = " << reco_ptElecMin  << endl;
00044   edm::LogInfo("RecoSelectorParameters") << " reco_ptMuonMin = " << reco_ptMuonMin  << endl;
00045   edm::LogInfo("RecoSelectorParameters") << " reco_ptPhotMin = " << reco_ptPhotMin  << endl;
00046 
00047 }
00048 
00049 string RecoSelector::GetName(){return name;}
00050 
00051 bool RecoSelector::isSelected(const edm::Event& iEvent)
00052 {
00053 
00054 
00055   this->handleObjects(iEvent);
00056 
00057 
00058   bool TotalCutPassed = false;
00059 
00060   bool ElectronCutPassed = false;
00061   for(unsigned int i=0; i<theElectronCollection->size(); i++) {
00062     GsfElectron electron = (*theElectronCollection)[i];
00063     if (electron.ecalDrivenSeed()) {
00064       float elenergy = electron.superCluster()->energy();
00065       float elpt = electron.pt() * elenergy / electron.p();
00066       if(elpt>reco_ptElecMin)  ElectronCutPassed = true;
00067       LogDebug("RecoSelectorCuts") << "elpt = " << elpt << endl;
00068     }
00069     else {
00070       //      float elenergy = 0;
00071       //      float elpt = 0;
00072       ElectronCutPassed = false;
00073     }
00074   }
00075 
00076   bool MuonCutPassed = false;
00077   for(unsigned int i=0; i<theMuonCollection->size(); i++) {
00078     Muon muon = (*theMuonCollection)[i];
00079     float muonpt = muon.pt();
00080     if(muonpt>reco_ptMuonMin) MuonCutPassed = true;
00081     LogDebug("RecoSelectorCuts") << "muonpt = " << muonpt << endl;
00082   }
00083   
00084   bool PhotonCutPassed = false;
00085   for(unsigned int i=0; i<thePhotonCollection->size(); i++) {
00086     Photon photon = (*thePhotonCollection)[i];
00087     float photonpt = photon.pt();
00088     if(photonpt>reco_ptPhotMin) PhotonCutPassed = true;
00089     LogDebug("RecoSelectorCuts") << "photonpt = " << photonpt << endl;
00090   }
00091 
00092 
00093   bool JetCutPassed = false;  
00094   if(theCaloJetCollection->size()>1) {
00095     if((*theCaloJetCollection)[0].pt() > reco_ptJet1Min &&
00096        (*theCaloJetCollection)[1].pt() > reco_ptJet2Min ) JetCutPassed = true;
00097   }
00098 
00099   bool MetCutPassed = false;  
00100   const CaloMET theCaloMET = theCaloMETCollection->front();
00101   float calomet = theCaloMET.pt();
00102   LogDebug("RecoSelectorCuts") << "calomet = " << calomet << endl;
00103   if(calomet > reco_metMin) MetCutPassed = true;
00104 
00105   edm::LogInfo("RecoSelectorPassed") << "ElectronCutPassed = " << (int)ElectronCutPassed << endl;
00106   edm::LogInfo("RecoSelectorPassed") << "MuonCutPassed     = " << (int)MuonCutPassed << endl;
00107   edm::LogInfo("RecoSelectorPassed") << "PhotonCutPassed   = " << (int)PhotonCutPassed << endl;
00108   edm::LogInfo("RecoSelectorPassed") << "JetCutPassed      = " << (int)JetCutPassed << endl;
00109   edm::LogInfo("RecoSelectorPassed") << "MetCutPassed      = " << (int)MetCutPassed << endl;
00110 
00111 
00112   if(
00113      (ElectronCutPassed || MuonCutPassed) &&
00114      PhotonCutPassed                      &&
00115      JetCutPassed                         &&
00116      MetCutPassed      )   TotalCutPassed = true;
00117 
00118   return TotalCutPassed;
00119 }
00120  
00121 void RecoSelector::handleObjects(const edm::Event& iEvent)
00122 {
00123 
00124   //Get the electrons
00125   Handle<GsfElectronCollection> theElectronCollectionHandle; 
00126   iEvent.getByLabel(m_electronSrc, theElectronCollectionHandle);
00127   theElectronCollection = theElectronCollectionHandle.product();
00128 
00129   //Get the Muons
00130   Handle<MuonCollection> theMuonCollectionHandle; 
00131   iEvent.getByLabel(m_muonSrc, theMuonCollectionHandle);
00132   theMuonCollection = theMuonCollectionHandle.product();
00133 
00134   //Get the Photons
00135   Handle<PhotonCollection> thePhotonCollectionHandle; 
00136   iEvent.getByLabel(m_photonProducerSrc, m_photonSrc, thePhotonCollectionHandle);
00137   thePhotonCollection = thePhotonCollectionHandle.product();
00138 
00139   //Get the CaloJets
00140   Handle<CaloJetCollection> theCaloJetCollectionHandle;
00141   iEvent.getByLabel(m_jetsSrc, theCaloJetCollectionHandle);
00142   theCaloJetCollection = theCaloJetCollectionHandle.product();
00143 
00144   //Get the CaloMET
00145   Handle<CaloMETCollection> theCaloMETCollectionHandle;
00146   iEvent.getByLabel(m_calometSrc, theCaloMETCollectionHandle);
00147   theCaloMETCollection = theCaloMETCollectionHandle.product();
00148 
00149 }