CMS 3D CMS Logo

Public Member Functions | Private Attributes

McSelector Class Reference

#include <McSelector.h>

List of all members.

Public Member Functions

std::string GetName ()
void handleObjects (const edm::Event &)
bool isSelected (const edm::Event &)
 McSelector (edm::ParameterSet userCut_params)
virtual ~McSelector ()

Private Attributes

double ht
std::string m_genJetSrc
std::string m_genMetSrc
std::string m_genSrc
double mc_htMin
double mc_metMin
int mc_nElec
std::string mc_nElecRule
int mc_nJet
int mc_nMuon
std::string mc_nMuonRule
int mc_nPhot
int mc_nTau
double mc_ptElecMin
double mc_ptJetForHtMin
double mc_ptJetMin
double mc_ptMuonMin
double mc_ptPhotMin
double mc_ptTauMin
std::string name
const reco::GenJetCollectiontheGenJetCollection
const reco::GenMETCollectiontheGenMETCollection
const reco::GenParticleCollectiontheGenParticleCollection

Detailed Description

Definition at line 32 of file McSelector.h.


Constructor & Destructor Documentation

McSelector::McSelector ( edm::ParameterSet  userCut_params)

Definition at line 20 of file McSelector.cc.

References edm::ParameterSet::getParameter(), mcSel_RA1_cff::mc_htMin, mcSel_RA1_cff::mc_metMin, mcSel_RA1_cff::mc_nElec, mcSel_RA1_cff::mc_nElecRule, mcSel_RA1_cff::mc_nJet, mcSel_RA1_cff::mc_nMuon, mcSel_RA1_cff::mc_nMuonRule, mcSel_RA1_cff::mc_nPhot, mcSel_RA1_cff::mc_nTau, mcSel_RA1_cff::mc_ptElecMin, mcSel_RA1_cff::mc_ptJetForHtMin, mcSel_RA1_cff::mc_ptJetMin, mcSel_RA1_cff::mc_ptMuonMin, mcSel_RA1_cff::mc_ptPhotMin, mcSel_RA1_cff::mc_ptTauMin, and AlCaRecoCosmics_cfg::name.

{
  //******************** PLEASE PAY ATTENTION: number of electron and muons is strictly equal, for jets, taus and photons the requirement is >= ********************
  name     = userCut_params.getParameter<string>("name");
  m_genSrc       = userCut_params.getParameter<string>("mcparticles");
  m_genJetSrc    = userCut_params.getParameter<string>("genJets");
  m_genMetSrc    = userCut_params.getParameter<string>("genMet");
  mc_ptElecMin     = userCut_params.getParameter<double>("mc_ptElecMin"     );
  mc_ptMuonMin     = userCut_params.getParameter<double>("mc_ptMuonMin"     );
  mc_ptTauMin      = userCut_params.getParameter<double>("mc_ptTauMin"      );
  mc_ptPhotMin     = userCut_params.getParameter<double>("mc_ptPhotMin"     );
  mc_ptJetMin      = userCut_params.getParameter<double>("mc_ptJetMin"      );   
  mc_ptJetForHtMin = userCut_params.getParameter<double>("mc_ptJetForHtMin" );
  mc_metMin        = userCut_params.getParameter<double>("mc_metMin"        );
  mc_htMin         = userCut_params.getParameter<double>("mc_htMin"         );
  mc_nElec     = userCut_params.getParameter<int>("mc_nElec");
  mc_nElecRule = userCut_params.getParameter<string>("mc_nElecRule");
  mc_nMuon     = userCut_params.getParameter<int>("mc_nMuon");
  mc_nMuonRule = userCut_params.getParameter<string>("mc_nMuonRule");
  mc_nTau      = userCut_params.getParameter<int>("mc_nTau");
  mc_nPhot     = userCut_params.getParameter<int>("mc_nPhot");
  mc_nJet      = userCut_params.getParameter<int>("mc_nJet" );


  edm::LogInfo("HLTriggerOfflineSUSYBSM") << "UserAnalysis parameters, MC for " << name << " selection:" ;
  edm::LogInfo("HLTriggerOfflineSUSYBSM") << " mc_ptElecMin      = " << mc_ptElecMin    ;
  edm::LogInfo("HLTriggerOfflineSUSYBSM") << " mc_ptMuonMin      = " << mc_ptMuonMin    ;
  edm::LogInfo("HLTriggerOfflineSUSYBSM") << " mc_ptTauMin       = " << mc_ptTauMin     ;
  edm::LogInfo("HLTriggerOfflineSUSYBSM") << " mc_ptPhotMin      = " << mc_ptPhotMin    ;
  edm::LogInfo("HLTriggerOfflineSUSYBSM") << " mc_ptJetMin       = " << mc_ptJetMin     ;
  edm::LogInfo("HLTriggerOfflineSUSYBSM") << " mc_ptJetForHtMin  = " << mc_ptJetForHtMin   ;
  edm::LogInfo("HLTriggerOfflineSUSYBSM") << " mc_metMin         = " << mc_metMin       ;
  edm::LogInfo("HLTriggerOfflineSUSYBSM") << " mc_htMin          = " << mc_htMin        ;

  edm::LogInfo("HLTriggerOfflineSUSYBSM") << " mc_nElec          = " << mc_nElec   ;
  edm::LogInfo("HLTriggerOfflineSUSYBSM") << " mc_nElecRule = " << mc_nElecRule ;
  edm::LogInfo("HLTriggerOfflineSUSYBSM") << " mc_nMuon          = " << mc_nMuon   ;
  edm::LogInfo("HLTriggerOfflineSUSYBSM") << " mc_nMuonRule = " << mc_nMuonRule ;
  edm::LogInfo("HLTriggerOfflineSUSYBSM") << " mc_nTau           = " << mc_nTau    ;
  edm::LogInfo("HLTriggerOfflineSUSYBSM") << " mc_nPhot          = " << mc_nPhot   ;
  edm::LogInfo("HLTriggerOfflineSUSYBSM") << " mc_nJet           = " << mc_nJet    ;


}
virtual McSelector::~McSelector ( ) [inline, virtual]

Definition at line 39 of file McSelector.h.

{};

Member Function Documentation

string McSelector::GetName ( )

Definition at line 65 of file McSelector.cc.

References AlCaRecoCosmics_cfg::name.

{return name;}
void McSelector::handleObjects ( const edm::Event iEvent)

Definition at line 249 of file McSelector.cc.

References edm::Event::getByLabel(), and edm::Handle< T >::product().

{

  //Get the GenParticleCandidates
  Handle< reco::GenParticleCollection > theCandidateCollectionHandle;
  iEvent.getByLabel(m_genSrc, theCandidateCollectionHandle);
  theGenParticleCollection = theCandidateCollectionHandle.product();

  
  //Get the GenJets
  Handle< GenJetCollection > theGenJetCollectionHandle ;
  iEvent.getByLabel( m_genJetSrc, theGenJetCollectionHandle);  
  theGenJetCollection = theGenJetCollectionHandle.product();


  //Get the GenMET
  Handle< GenMETCollection > theGenMETCollectionHandle;
  iEvent.getByLabel( m_genMetSrc, theGenMETCollectionHandle);
  theGenMETCollection = theGenMETCollectionHandle.product();


}
bool McSelector::isSelected ( const edm::Event iEvent)

Definition at line 67 of file McSelector.cc.

References gather_cfg::cout, reco::LeafCandidate::eta(), i, mcSel_RA1_cff::mc_htMin, mcSel_RA1_cff::mc_metMin, mcSel_RA1_cff::mc_nElec, mcSel_RA1_cff::mc_nElecRule, mcSel_RA1_cff::mc_nJet, mcSel_RA1_cff::mc_nMuon, mcSel_RA1_cff::mc_nMuonRule, mcSel_RA1_cff::mc_nPhot, mcSel_RA1_cff::mc_nTau, mcSel_RA1_cff::mc_ptElecMin, mcSel_RA1_cff::mc_ptJetForHtMin, mcSel_RA1_cff::mc_ptJetMin, mcSel_RA1_cff::mc_ptMuonMin, mcSel_RA1_cff::mc_ptPhotMin, mcSel_RA1_cff::mc_ptTauMin, reco::Candidate::mother(), reco::CompositeRefCandidateT< D >::mother(), reco::CompositeRefCandidateT< D >::numberOfMothers(), reco::LeafCandidate::pdgId(), reco::Candidate::pdgId(), reco::LeafCandidate::pt(), and reco::LeafCandidate::status().

{


  this->handleObjects(iEvent);


  bool TotalCutPassed = false;


  bool ElectronCutPassed = false;
  bool MuonCutPassed = false;
  bool TauCutPassed = false;
  bool PhotonCutPassed = false;
  bool JetCutPassed = false;  
  bool MetCutPassed = false;  
  bool HtCutPassed = false;  

  int nMcElectrons = 0;
  int nMcMuons     = 0;
  int nMcTaus     = 0;
  int nMcPhotons   = 0;
  int nMcJets      = 0;
  
  //  cout <<"----------------------------------------------------------------------------" << endl;
  
  for(unsigned int i=0; i<theGenParticleCollection->size(); i++) {
    const GenParticle* genParticle = (&(*theGenParticleCollection)[i]);    
    if(genParticle->status() == 2) {
      //taus
      if(fabs(genParticle->pdgId()) == 15) {
        //      cout << "Tau Mother = " << genParticle->mother()->pdgId() << endl;
        //      if(fabs(genParticle->mother()->pdgId()) == 15)  cout << "Tau GrandMother = " << genParticle->mother()->mother()->pdgId() << endl;
        if(genParticle->pt() > mc_ptTauMin && fabs(genParticle->eta())<2.5) {
          nMcTaus++;
        }
      }
    }
    if(genParticle->status() == 1) {
      //      cout << "genParticle->status() = " << genParticle->status() << "    genParticle->pdgId() = " << genParticle->pdgId() << "     genParticle->pt() = " << genParticle->pt() << endl;
      //electrons
      if(fabs(genParticle->pdgId()) == 11 && genParticle->numberOfMothers()) {
        //              cout << "Mc Electron, pt = " << genParticle->pt() << endl;
        //              cout << "Electron Mother = " << genParticle->mother()->pdgId() << endl;
//              if(fabs(genParticle->mother()->pdgId()) == 11 || fabs(genParticle->mother()->pdgId()) == 15) 
//                cout << "Electron GrandMother = " << genParticle->mother()->mother()->pdgId() << endl;
//              if(fabs(genParticle->mother()->mother()->pdgId()) == 11 || fabs(genParticle->mother()->mother()->pdgId()) == 15)
//                cout << "Electron GrandGrandMother = " << genParticle->mother()->mother()->mother()->pdgId() << endl;
        int motherCode = genParticle->mother()->pdgId();
        if(fabs(motherCode) == fabs(genParticle->pdgId()) || fabs(motherCode) == 15) {
          motherCode = genParticle->mother()->mother()->pdgId();
          if(fabs(motherCode) == fabs(genParticle->pdgId()) || fabs(motherCode) == 15) motherCode = genParticle->mother()->mother()->mother()->pdgId();
        }
        if(fabs(motherCode) == 23 || fabs(motherCode) == 24 || fabs(motherCode) > 999999) {
          if(genParticle->pt() > mc_ptElecMin && fabs(genParticle->eta())<2.5) {
            nMcElectrons++;
            //            cout << "Mc Electron, pt = " << genParticle->pt() << endl;
          }
        }
      }
      //muons
      if(fabs(genParticle->pdgId()) == 13 && genParticle->numberOfMothers()) {
        //      cout << "Mc Muon, pt = " << genParticle->pt() << endl;
        //              cout << "Muon Mother = " << genParticle->mother()->pdgId() << endl;
//              if(fabs(genParticle->mother()->pdgId()) == 13 || fabs(genParticle->mother()->pdgId()) == 15)
//                cout << "Muon GrandMother = " << genParticle->mother()->mother()->pdgId() << endl;
//              if(fabs(genParticle->mother()->mother()->pdgId()) == 13 || fabs(genParticle->mother()->mother()->pdgId()) == 15)
//                cout << "Muon GrandGrandMother = " << genParticle->mother()->mother()->mother()->pdgId() << endl;
        int motherCode = genParticle->mother()->pdgId();
        if(fabs(motherCode) == fabs(genParticle->pdgId()) || fabs(motherCode) == 15) {
          motherCode = genParticle->mother()->mother()->pdgId();
          if(fabs(motherCode) == fabs(genParticle->pdgId()) || fabs(motherCode) == 15) motherCode = genParticle->mother()->mother()->mother()->pdgId();
        }
        if(fabs(motherCode) == 23 || fabs(motherCode) == 24 || fabs(motherCode) > 999999) {
          if(genParticle->pt() > mc_ptMuonMin && fabs(genParticle->eta())<2.5) {
            nMcMuons++;
          //              cout << "Mc Muon, pt = " << genParticle->pt() << endl;
          }
        }
      }
      //photons
      if(fabs(genParticle->pdgId()) == 22 && fabs(genParticle->eta())<2.5) {
        //      cout << "Mc Photon, pt = " << genParticle->pt() << endl;
        if(genParticle->pt() > mc_ptPhotMin) {
          //      cout << "Photon Mother = " << genParticle->mother()->pdgId() << endl;
          nMcPhotons++;
          //      cout << "Mc Photon, pt = " << genParticle->pt() << endl;
        }
      }
    }
  }

  ht = 0;
  for(unsigned int i=0; i<theGenJetCollection->size();i++) {
    GenJet genjet = (*theGenJetCollection)[i];
    //    cout << "Mc Jet, pt = " << genjet.pt() << endl;
    if(genjet.pt() > mc_ptJetMin && fabs(genjet.eta())<3) {
      nMcJets++;
      //           cout << "Mc Jet, pt = " << genjet.pt() << endl;
    }
    if(genjet.pt() > mc_ptJetForHtMin) ht =+ genjet.pt();
  }
  if(ht>mc_htMin) HtCutPassed = true;
  
  
  const GenMET theGenMET = theGenMETCollection->front();
  //  cout << "GenMET = " << theGenMET.pt() << endl;
  if(theGenMET.pt() > mc_metMin) MetCutPassed = true;
  
  //  cout <<"----------------------------------------------------------------------------" << endl;
  

//   cout << "nMcElectrons = " << nMcElectrons << endl;
//   cout << "nMcMuons     = " << nMcMuons     << endl;
//   cout << "nMcTaus      = " << nMcTaus      << endl;
//   cout << "nMcPhotons   = " << nMcPhotons   << endl;
//   cout << "nMcJets      = " << nMcJets      << endl;
  
  if(mc_nElecRule == "strictEqual") {
    if(nMcElectrons == mc_nElec) ElectronCutPassed = true;
  } 
  else if (mc_nElecRule == "greaterEqual") {
    if(nMcElectrons >= mc_nElec) ElectronCutPassed = true;
  } 
  else cout << "WARNING: not a correct definition of cuts at gen level for electrons! " << endl;
  
  
  if(mc_nMuonRule == "strictEqual") {
    if(nMcMuons     == mc_nMuon) MuonCutPassed     = true;
  }
  else if (mc_nMuonRule == "greaterEqual") {
    if(nMcMuons >= mc_nMuon) MuonCutPassed = true;
  } 
  else cout << "WARNING: not a correct definition of cuts at gen level for muons! " << endl;
  if(nMcTaus      >= mc_nTau)  TauCutPassed      = true;
  if(nMcPhotons   >= mc_nPhot) PhotonCutPassed   = true;
  if(nMcJets      >= mc_nJet ) JetCutPassed      = true;
  
  
//   cout << "ElectronCutPassed = " << (int)ElectronCutPassed << endl;
//   cout << "MuonCutPassed     = " << (int)MuonCutPassed << endl;
//   cout << "PhotonCutPassed   = " << (int)PhotonCutPassed << endl;
//   cout << "JetCutPassed      = " << (int)JetCutPassed << endl;
//   cout << "MetCutPassed      = " << (int)MetCutPassed << endl;
  
  
//   if(
//      (ElectronCutPassed || MuonCutPassed) &&
//      PhotonCutPassed                      &&
//      JetCutPassed                         &&
//      MetCutPassed      )   TotalCutPassed = true;
  
  
  if(
     ElectronCutPassed   && 
     MuonCutPassed       &&
     TauCutPassed        &&
     PhotonCutPassed     &&
     JetCutPassed        &&
     MetCutPassed        &&
     HtCutPassed          )   TotalCutPassed = true;


  // Apply a veto: removed because we require the exact number of leptons
  // and not >=
  // the veto is hence equivalent to request 0 leptons

//   if(TotalCutPassed) {
//     if(mc_ElecVeto) {
//       if(nMcElectrons>0) TotalCutPassed = false;
//     }
//     if(mc_MuonVeto) {
//       if(nMcMuons>0) TotalCutPassed = false;
//     }
//   }

  
//  cout << "TotalCutPassed = " << TotalCutPassed << endl;

  return TotalCutPassed;
}

Member Data Documentation

double McSelector::ht [private]

Definition at line 70 of file McSelector.h.

std::string McSelector::m_genJetSrc [private]

Definition at line 51 of file McSelector.h.

std::string McSelector::m_genMetSrc [private]

Definition at line 52 of file McSelector.h.

std::string McSelector::m_genSrc [private]

Definition at line 50 of file McSelector.h.

double McSelector::mc_htMin [private]

Definition at line 60 of file McSelector.h.

double McSelector::mc_metMin [private]

Definition at line 59 of file McSelector.h.

int McSelector::mc_nElec [private]

Definition at line 61 of file McSelector.h.

std::string McSelector::mc_nElecRule [private]

Definition at line 62 of file McSelector.h.

int McSelector::mc_nJet [private]

Definition at line 67 of file McSelector.h.

int McSelector::mc_nMuon [private]

Definition at line 63 of file McSelector.h.

std::string McSelector::mc_nMuonRule [private]

Definition at line 64 of file McSelector.h.

int McSelector::mc_nPhot [private]

Definition at line 66 of file McSelector.h.

int McSelector::mc_nTau [private]

Definition at line 65 of file McSelector.h.

double McSelector::mc_ptElecMin [private]

Definition at line 53 of file McSelector.h.

double McSelector::mc_ptJetForHtMin [private]

Definition at line 58 of file McSelector.h.

double McSelector::mc_ptJetMin [private]

Definition at line 57 of file McSelector.h.

double McSelector::mc_ptMuonMin [private]

Definition at line 54 of file McSelector.h.

double McSelector::mc_ptPhotMin [private]

Definition at line 56 of file McSelector.h.

double McSelector::mc_ptTauMin [private]

Definition at line 55 of file McSelector.h.

std::string McSelector::name [private]

Definition at line 49 of file McSelector.h.

Definition at line 76 of file McSelector.h.

Definition at line 77 of file McSelector.h.

Definition at line 75 of file McSelector.h.