CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Attributes
McSelector Class Reference

#include <McSelector.h>

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 mergeVDriftHistosByStation::name.

21 {
22  //******************** PLEASE PAY ATTENTION: number of electron and muons is strictly equal, for jets, taus and photons the requirement is >= ********************
23  name = userCut_params.getParameter<string>("name");
24  m_genSrc = userCut_params.getParameter<string>("mcparticles");
25  m_genJetSrc = userCut_params.getParameter<string>("genJets");
26  m_genMetSrc = userCut_params.getParameter<string>("genMet");
27  mc_ptElecMin = userCut_params.getParameter<double>("mc_ptElecMin" );
28  mc_ptMuonMin = userCut_params.getParameter<double>("mc_ptMuonMin" );
29  mc_ptTauMin = userCut_params.getParameter<double>("mc_ptTauMin" );
30  mc_ptPhotMin = userCut_params.getParameter<double>("mc_ptPhotMin" );
31  mc_ptJetMin = userCut_params.getParameter<double>("mc_ptJetMin" );
32  mc_ptJetForHtMin = userCut_params.getParameter<double>("mc_ptJetForHtMin" );
33  mc_metMin = userCut_params.getParameter<double>("mc_metMin" );
34  mc_htMin = userCut_params.getParameter<double>("mc_htMin" );
35  mc_nElec = userCut_params.getParameter<int>("mc_nElec");
36  mc_nElecRule = userCut_params.getParameter<string>("mc_nElecRule");
37  mc_nMuon = userCut_params.getParameter<int>("mc_nMuon");
38  mc_nMuonRule = userCut_params.getParameter<string>("mc_nMuonRule");
39  mc_nTau = userCut_params.getParameter<int>("mc_nTau");
40  mc_nPhot = userCut_params.getParameter<int>("mc_nPhot");
41  mc_nJet = userCut_params.getParameter<int>("mc_nJet" );
42 
43 
44  edm::LogInfo("HLTriggerOfflineSUSYBSM") << "UserAnalysis parameters, MC for " << name << " selection:" ;
45  edm::LogInfo("HLTriggerOfflineSUSYBSM") << " mc_ptElecMin = " << mc_ptElecMin ;
46  edm::LogInfo("HLTriggerOfflineSUSYBSM") << " mc_ptMuonMin = " << mc_ptMuonMin ;
47  edm::LogInfo("HLTriggerOfflineSUSYBSM") << " mc_ptTauMin = " << mc_ptTauMin ;
48  edm::LogInfo("HLTriggerOfflineSUSYBSM") << " mc_ptPhotMin = " << mc_ptPhotMin ;
49  edm::LogInfo("HLTriggerOfflineSUSYBSM") << " mc_ptJetMin = " << mc_ptJetMin ;
50  edm::LogInfo("HLTriggerOfflineSUSYBSM") << " mc_ptJetForHtMin = " << mc_ptJetForHtMin ;
51  edm::LogInfo("HLTriggerOfflineSUSYBSM") << " mc_metMin = " << mc_metMin ;
52  edm::LogInfo("HLTriggerOfflineSUSYBSM") << " mc_htMin = " << mc_htMin ;
53 
54  edm::LogInfo("HLTriggerOfflineSUSYBSM") << " mc_nElec = " << mc_nElec ;
55  edm::LogInfo("HLTriggerOfflineSUSYBSM") << " mc_nElecRule = " << mc_nElecRule ;
56  edm::LogInfo("HLTriggerOfflineSUSYBSM") << " mc_nMuon = " << mc_nMuon ;
57  edm::LogInfo("HLTriggerOfflineSUSYBSM") << " mc_nMuonRule = " << mc_nMuonRule ;
58  edm::LogInfo("HLTriggerOfflineSUSYBSM") << " mc_nTau = " << mc_nTau ;
59  edm::LogInfo("HLTriggerOfflineSUSYBSM") << " mc_nPhot = " << mc_nPhot ;
60  edm::LogInfo("HLTriggerOfflineSUSYBSM") << " mc_nJet = " << mc_nJet ;
61 
62 
63 }
T getParameter(std::string const &) const
double mc_ptPhotMin
Definition: McSelector.h:56
int mc_nPhot
Definition: McSelector.h:66
double mc_htMin
Definition: McSelector.h:60
int mc_nMuon
Definition: McSelector.h:63
std::string name
Definition: McSelector.h:49
double mc_ptJetForHtMin
Definition: McSelector.h:58
double mc_metMin
Definition: McSelector.h:59
std::string m_genSrc
Definition: McSelector.h:50
int mc_nJet
Definition: McSelector.h:67
double mc_ptElecMin
Definition: McSelector.h:53
int mc_nElec
Definition: McSelector.h:61
double mc_ptTauMin
Definition: McSelector.h:55
double mc_ptJetMin
Definition: McSelector.h:57
std::string mc_nElecRule
Definition: McSelector.h:62
std::string m_genJetSrc
Definition: McSelector.h:51
double mc_ptMuonMin
Definition: McSelector.h:54
int mc_nTau
Definition: McSelector.h:65
std::string m_genMetSrc
Definition: McSelector.h:52
std::string mc_nMuonRule
Definition: McSelector.h:64
virtual McSelector::~McSelector ( )
inlinevirtual

Definition at line 39 of file McSelector.h.

39 {};

Member Function Documentation

string McSelector::GetName ( )

Definition at line 65 of file McSelector.cc.

References mergeVDriftHistosByStation::name.

65 {return name;}
std::string name
Definition: McSelector.h:49
void McSelector::handleObjects ( const edm::Event iEvent)

Definition at line 249 of file McSelector.cc.

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

250 {
251 
252  //Get the GenParticleCandidates
253  Handle< reco::GenParticleCollection > theCandidateCollectionHandle;
254  iEvent.getByLabel(m_genSrc, theCandidateCollectionHandle);
255  theGenParticleCollection = theCandidateCollectionHandle.product();
256 
257 
258  //Get the GenJets
259  Handle< GenJetCollection > theGenJetCollectionHandle ;
260  iEvent.getByLabel( m_genJetSrc, theGenJetCollectionHandle);
261  theGenJetCollection = theGenJetCollectionHandle.product();
262 
263 
264  //Get the GenMET
265  Handle< GenMETCollection > theGenMETCollectionHandle;
266  iEvent.getByLabel( m_genMetSrc, theGenMETCollectionHandle);
267  theGenMETCollection = theGenMETCollectionHandle.product();
268 
269 
270 }
std::string m_genSrc
Definition: McSelector.h:50
const reco::GenJetCollection * theGenJetCollection
Definition: McSelector.h:76
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:361
const reco::GenParticleCollection * theGenParticleCollection
Definition: McSelector.h:75
T const * product() const
Definition: Handle.h:74
std::string m_genJetSrc
Definition: McSelector.h:51
std::string m_genMetSrc
Definition: McSelector.h:52
const reco::GenMETCollection * theGenMETCollection
Definition: McSelector.h:77
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::CompositeRefCandidateT< D >::mother(), reco::Candidate::mother(), reco::CompositeRefCandidateT< D >::numberOfMothers(), reco::Candidate::pdgId(), reco::LeafCandidate::pdgId(), reco::LeafCandidate::pt(), and reco::LeafCandidate::status().

68 {
69 
70 
71  this->handleObjects(iEvent);
72 
73 
74  bool TotalCutPassed = false;
75 
76 
77  bool ElectronCutPassed = false;
78  bool MuonCutPassed = false;
79  bool TauCutPassed = false;
80  bool PhotonCutPassed = false;
81  bool JetCutPassed = false;
82  bool MetCutPassed = false;
83  bool HtCutPassed = false;
84 
85  int nMcElectrons = 0;
86  int nMcMuons = 0;
87  int nMcTaus = 0;
88  int nMcPhotons = 0;
89  int nMcJets = 0;
90 
91  // cout <<"----------------------------------------------------------------------------" << endl;
92 
93  for(unsigned int i=0; i<theGenParticleCollection->size(); i++) {
94  const GenParticle* genParticle = (&(*theGenParticleCollection)[i]);
95  if(genParticle->status() == 2) {
96  //taus
97  if(fabs(genParticle->pdgId()) == 15) {
98  // cout << "Tau Mother = " << genParticle->mother()->pdgId() << endl;
99  // if(fabs(genParticle->mother()->pdgId()) == 15) cout << "Tau GrandMother = " << genParticle->mother()->mother()->pdgId() << endl;
100  if(genParticle->pt() > mc_ptTauMin && fabs(genParticle->eta())<2.5) {
101  nMcTaus++;
102  }
103  }
104  }
105  if(genParticle->status() == 1) {
106  // cout << "genParticle->status() = " << genParticle->status() << " genParticle->pdgId() = " << genParticle->pdgId() << " genParticle->pt() = " << genParticle->pt() << endl;
107  //electrons
108  if(fabs(genParticle->pdgId()) == 11 && genParticle->numberOfMothers()) {
109  // cout << "Mc Electron, pt = " << genParticle->pt() << endl;
110  // cout << "Electron Mother = " << genParticle->mother()->pdgId() << endl;
111 // if(fabs(genParticle->mother()->pdgId()) == 11 || fabs(genParticle->mother()->pdgId()) == 15)
112 // cout << "Electron GrandMother = " << genParticle->mother()->mother()->pdgId() << endl;
113 // if(fabs(genParticle->mother()->mother()->pdgId()) == 11 || fabs(genParticle->mother()->mother()->pdgId()) == 15)
114 // cout << "Electron GrandGrandMother = " << genParticle->mother()->mother()->mother()->pdgId() << endl;
115  int motherCode = genParticle->mother()->pdgId();
116  if(fabs(motherCode) == fabs(genParticle->pdgId()) || fabs(motherCode) == 15) {
117  motherCode = genParticle->mother()->mother()->pdgId();
118  if(fabs(motherCode) == fabs(genParticle->pdgId()) || fabs(motherCode) == 15) motherCode = genParticle->mother()->mother()->mother()->pdgId();
119  }
120  if(fabs(motherCode) == 23 || fabs(motherCode) == 24 || fabs(motherCode) > 999999) {
121  if(genParticle->pt() > mc_ptElecMin && fabs(genParticle->eta())<2.5) {
122  nMcElectrons++;
123  // cout << "Mc Electron, pt = " << genParticle->pt() << endl;
124  }
125  }
126  }
127  //muons
128  if(fabs(genParticle->pdgId()) == 13 && genParticle->numberOfMothers()) {
129  // cout << "Mc Muon, pt = " << genParticle->pt() << endl;
130  // cout << "Muon Mother = " << genParticle->mother()->pdgId() << endl;
131 // if(fabs(genParticle->mother()->pdgId()) == 13 || fabs(genParticle->mother()->pdgId()) == 15)
132 // cout << "Muon GrandMother = " << genParticle->mother()->mother()->pdgId() << endl;
133 // if(fabs(genParticle->mother()->mother()->pdgId()) == 13 || fabs(genParticle->mother()->mother()->pdgId()) == 15)
134 // cout << "Muon GrandGrandMother = " << genParticle->mother()->mother()->mother()->pdgId() << endl;
135  int motherCode = genParticle->mother()->pdgId();
136  if(fabs(motherCode) == fabs(genParticle->pdgId()) || fabs(motherCode) == 15) {
137  motherCode = genParticle->mother()->mother()->pdgId();
138  if(fabs(motherCode) == fabs(genParticle->pdgId()) || fabs(motherCode) == 15) motherCode = genParticle->mother()->mother()->mother()->pdgId();
139  }
140  if(fabs(motherCode) == 23 || fabs(motherCode) == 24 || fabs(motherCode) > 999999) {
141  if(genParticle->pt() > mc_ptMuonMin && fabs(genParticle->eta())<2.5) {
142  nMcMuons++;
143  // cout << "Mc Muon, pt = " << genParticle->pt() << endl;
144  }
145  }
146  }
147  //photons
148  if(fabs(genParticle->pdgId()) == 22 && fabs(genParticle->eta())<2.5) {
149  // cout << "Mc Photon, pt = " << genParticle->pt() << endl;
150  if(genParticle->pt() > mc_ptPhotMin) {
151  // cout << "Photon Mother = " << genParticle->mother()->pdgId() << endl;
152  nMcPhotons++;
153  // cout << "Mc Photon, pt = " << genParticle->pt() << endl;
154  }
155  }
156  }
157  }
158 
159  ht = 0;
160  for(unsigned int i=0; i<theGenJetCollection->size();i++) {
161  GenJet genjet = (*theGenJetCollection)[i];
162  // cout << "Mc Jet, pt = " << genjet.pt() << endl;
163  if(genjet.pt() > mc_ptJetMin && fabs(genjet.eta())<3) {
164  nMcJets++;
165  // cout << "Mc Jet, pt = " << genjet.pt() << endl;
166  }
167  if(genjet.pt() > mc_ptJetForHtMin) ht =+ genjet.pt();
168  }
169  if(ht>mc_htMin) HtCutPassed = true;
170 
171 
172  const GenMET theGenMET = theGenMETCollection->front();
173  // cout << "GenMET = " << theGenMET.pt() << endl;
174  if(theGenMET.pt() > mc_metMin) MetCutPassed = true;
175 
176  // cout <<"----------------------------------------------------------------------------" << endl;
177 
178 
179 // cout << "nMcElectrons = " << nMcElectrons << endl;
180 // cout << "nMcMuons = " << nMcMuons << endl;
181 // cout << "nMcTaus = " << nMcTaus << endl;
182 // cout << "nMcPhotons = " << nMcPhotons << endl;
183 // cout << "nMcJets = " << nMcJets << endl;
184 
185  if(mc_nElecRule == "strictEqual") {
186  if(nMcElectrons == mc_nElec) ElectronCutPassed = true;
187  }
188  else if (mc_nElecRule == "greaterEqual") {
189  if(nMcElectrons >= mc_nElec) ElectronCutPassed = true;
190  }
191  else cout << "WARNING: not a correct definition of cuts at gen level for electrons! " << endl;
192 
193 
194  if(mc_nMuonRule == "strictEqual") {
195  if(nMcMuons == mc_nMuon) MuonCutPassed = true;
196  }
197  else if (mc_nMuonRule == "greaterEqual") {
198  if(nMcMuons >= mc_nMuon) MuonCutPassed = true;
199  }
200  else cout << "WARNING: not a correct definition of cuts at gen level for muons! " << endl;
201  if(nMcTaus >= mc_nTau) TauCutPassed = true;
202  if(nMcPhotons >= mc_nPhot) PhotonCutPassed = true;
203  if(nMcJets >= mc_nJet ) JetCutPassed = true;
204 
205 
206 // cout << "ElectronCutPassed = " << (int)ElectronCutPassed << endl;
207 // cout << "MuonCutPassed = " << (int)MuonCutPassed << endl;
208 // cout << "PhotonCutPassed = " << (int)PhotonCutPassed << endl;
209 // cout << "JetCutPassed = " << (int)JetCutPassed << endl;
210 // cout << "MetCutPassed = " << (int)MetCutPassed << endl;
211 
212 
213 // if(
214 // (ElectronCutPassed || MuonCutPassed) &&
215 // PhotonCutPassed &&
216 // JetCutPassed &&
217 // MetCutPassed ) TotalCutPassed = true;
218 
219 
220  if(
221  ElectronCutPassed &&
222  MuonCutPassed &&
223  TauCutPassed &&
224  PhotonCutPassed &&
225  JetCutPassed &&
226  MetCutPassed &&
227  HtCutPassed ) TotalCutPassed = true;
228 
229 
230  // Apply a veto: removed because we require the exact number of leptons
231  // and not >=
232  // the veto is hence equivalent to request 0 leptons
233 
234 // if(TotalCutPassed) {
235 // if(mc_ElecVeto) {
236 // if(nMcElectrons>0) TotalCutPassed = false;
237 // }
238 // if(mc_MuonVeto) {
239 // if(nMcMuons>0) TotalCutPassed = false;
240 // }
241 // }
242 
243 
244 // cout << "TotalCutPassed = " << TotalCutPassed << endl;
245 
246  return TotalCutPassed;
247 }
int i
Definition: DBlmapReader.cc:9
double mc_ptPhotMin
Definition: McSelector.h:56
virtual const Candidate * mother(size_type i=0) const =0
return pointer to mother
int mc_nPhot
Definition: McSelector.h:66
virtual int pdgId() const GCC11_FINAL
PDG identifier.
void handleObjects(const edm::Event &)
Definition: McSelector.cc:249
double mc_htMin
Definition: McSelector.h:60
double ht
Definition: McSelector.h:70
int mc_nMuon
Definition: McSelector.h:63
double mc_ptJetForHtMin
Definition: McSelector.h:58
double mc_metMin
Definition: McSelector.h:59
virtual int status() const GCC11_FINAL
status word
virtual size_t numberOfMothers() const
number of mothers
const reco::GenJetCollection * theGenJetCollection
Definition: McSelector.h:76
Jets made from MC generator particles.
Definition: GenJet.h:25
int mc_nJet
Definition: McSelector.h:67
double mc_ptElecMin
Definition: McSelector.h:53
int mc_nElec
Definition: McSelector.h:61
virtual float eta() const GCC11_FINAL
momentum pseudorapidity
double mc_ptTauMin
Definition: McSelector.h:55
virtual int pdgId() const =0
PDG identifier.
double mc_ptJetMin
Definition: McSelector.h:57
const reco::GenParticleCollection * theGenParticleCollection
Definition: McSelector.h:75
std::string mc_nElecRule
Definition: McSelector.h:62
double mc_ptMuonMin
Definition: McSelector.h:54
int mc_nTau
Definition: McSelector.h:65
tuple cout
Definition: gather_cfg.py:121
const reco::GenMETCollection * theGenMETCollection
Definition: McSelector.h:77
virtual float pt() const GCC11_FINAL
transverse momentum
virtual const Candidate * mother(size_type=0) const
return mother at a given position, i = 0, ... numberOfMothers() - 1 (read only mode) ...
std::string mc_nMuonRule
Definition: McSelector.h:64

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
const reco::GenJetCollection* McSelector::theGenJetCollection
private

Definition at line 76 of file McSelector.h.

const reco::GenMETCollection* McSelector::theGenMETCollection
private

Definition at line 77 of file McSelector.h.

const reco::GenParticleCollection* McSelector::theGenParticleCollection
private

Definition at line 75 of file McSelector.h.