CMS 3D CMS Logo

HiggsToZZ4LeptonsSkimEff.cc
Go to the documentation of this file.
1 
2 /* \class HiggsTo4LeptonsSkimEff
3  *
4  * Consult header file for description
5  *
6  * author: Dominique Fortin - UC Riverside
7  *
8  */
9 
10 // system include files
12 
13 // User include files
15 
16 // Muons:
18 
19 // Electrons
21 
22 // Candidate handling
26 
27 // C++
28 #include <iostream>
29 #include <vector>
30 
31 using namespace std;
32 using namespace edm;
33 using namespace reco;
34 
35 // Constructor
37  // Local Debug flag
38  debug = pset.getParameter<bool>("DebugHiggsToZZ4LeptonsSkim");
39 
40  // Reconstructed objects
41  theGLBMuonToken = consumes<reco::TrackCollection>(pset.getParameter<edm::InputTag>("GlobalMuonCollectionLabel"));
42  theGsfEToken = consumes<reco::GsfElectronCollection>(pset.getParameter<edm::InputTag>("ElectronCollectionLabel"));
43  genToken = consumes<GenParticleCollection>(edm::InputTag("genParticles"));
44 
45  // Minimum Pt for leptons for skimming
46  // Minimum Pt for leptons for skimming
47  stiffMinPt = pset.getParameter<double>("stiffMinimumPt");
48  softMinPt = pset.getParameter<double>("softMinimumPt");
49  nStiffLeptonMin = pset.getParameter<int>("nStiffLeptonMinimum");
50  nLeptonMin = pset.getParameter<int>("nLeptonMinimum");
51 
52  nEvents = 0;
53  nSelFourE = nSelFourM = nSelTwoETwoM = nSelFourL = nSelTau = 0;
54  nFourE = nFourM = nTwoETwoM = nFourL = nTau = 0;
55 }
56 
57 // Destructor
59  std::cout << "Number of events read " << nEvents << std::endl;
60  std::cout << "*** Efficiency for the various subsamples *** " << endl;
61 
62  std::cout << "Four leptons: "
63  << " pres " << nFourL << " kept " << nSelFourL << " eff "
64  << ((double)nSelFourL) / ((double)nFourL + 0.0001) << std::endl;
65  std::cout << "Four muons: "
66  << " pres " << nFourM << " kept " << nSelFourM << " eff "
67  << ((double)nSelFourM) / ((double)nFourM + 0.0001) << std::endl;
68  std::cout << "Four elecs: "
69  << " pres " << nFourE << " kept " << nSelFourE << " eff "
70  << ((double)nSelFourE) / ((double)nFourE + 0.0001) << std::endl;
71  std::cout << "2 elec 2 mu: "
72  << " pres " << nTwoETwoM << " kept " << nSelTwoETwoM << " eff "
73  << ((double)nSelTwoETwoM) / ((double)nTwoETwoM + 0.0001) << std::endl;
74  std::cout << "with taus: "
75  << " pres " << nTau << " kept " << nSelTau << " eff " << ((double)nSelTau) / ((double)nTau + 0.0001)
76  << std::endl;
77 }
78 
79 // Filter event
81  nEvents++;
82 
84 
85  bool keepEvent = false;
86 
87  // First, pre-selection:
88  int nMuon = 0;
89  int nElec = 0;
90  int nTau = 0;
91 
92  bool isFourE = false;
93  bool isFourM = false;
94  bool isTwoETwoM = false;
95  bool isFourL = false;
96  bool isTau = false;
97 
98  // get gen particle candidates
100  event.getByToken(genToken, genCandidates);
101 
102  for (CandidateCollection::const_iterator mcIter = genCandidates->begin(); mcIter != genCandidates->end(); ++mcIter) {
103  // Muons:
104  if (mcIter->pdgId() == 13 || mcIter->pdgId() == -13) {
105  // Mother is a Z
106  if (mcIter->mother()->pdgId() == 23) {
107  // In fiducial volume:
108  if (mcIter->eta() > -2.4 && mcIter->eta() < 2.4)
109  nMuon++;
110  }
111  }
112  // Electrons:
113  if (mcIter->pdgId() == 11 || mcIter->pdgId() == -11) {
114  // Mother is a Z
115  if (mcIter->mother()->pdgId() == 23) {
116  // In fiducial volume:
117  if (mcIter->eta() > -2.5 && mcIter->eta() < 2.5)
118  nElec++;
119  }
120  }
121  // Taus:
122  if (mcIter->pdgId() == 15 || mcIter->pdgId() == -15) {
123  // Mother is a Z
124  if (mcIter->mother()->pdgId() == 23) {
125  // In fiducial volume:
126  if (mcIter->eta() > -2.5 && mcIter->eta() < 2.5)
127  nTau++;
128  }
129  }
130  }
131 
132  if (nElec > 3) {
133  isFourE = true;
134  nFourE++;
135  }
136  if (nMuon > 3) {
137  isFourM = true;
138  nFourM++;
139  }
140  if (nMuon > 1 && nElec > 1) {
141  isTwoETwoM = true;
142  nTwoETwoM++;
143  }
144  if (isFourE || isFourM || isTwoETwoM) {
145  isFourL = true;
146  nFourL++;
147  }
148  if (nTau > 1) {
149  isTau = true;
150  nTau++;
151  }
152 
153  if (isFourL) {
154  keepEvent = true;
155  } else {
156  return;
157  }
158 
159  int nStiffLeptons = 0;
160  int nLeptons = 0;
161 
162  // First look at muons:
163 
164  // Get the muon track collection from the event
166  event.getByToken(theGLBMuonToken, muTracks);
167 
168  if (muTracks.isValid()) {
169  reco::TrackCollection::const_iterator muons;
170 
171  // Loop over muon collections and count how many muons there are,
172  // and how many are above threshold
173  for (muons = muTracks->begin(); muons != muTracks->end(); ++muons) {
174  float pt_mu = muons->pt();
175  if (pt_mu > stiffMinPt)
176  nStiffLeptons++;
177  if (pt_mu > softMinPt)
178  nLeptons++;
179  }
180  }
181 
182  // Now look at electrons:
183 
184  // Get the electron track collection from the event
186  event.getByToken(theGsfEToken, pTracks);
187 
188  if (pTracks.isValid()) {
189  const reco::GsfElectronCollection* eTracks = pTracks.product();
190 
191  reco::GsfElectronCollection::const_iterator electrons;
192 
193  // Loop over electron collections and count how many muons there are,
194  // and how many are above threshold
195  for (electrons = eTracks->begin(); electrons != eTracks->end(); ++electrons) {
196  float pt_e = electrons->pt();
197  if (pt_e > stiffMinPt)
198  nStiffLeptons++;
199  if (pt_e > softMinPt)
200  nLeptons++;
201  }
202  }
203 
204  // Make decision:
205  if (nStiffLeptons >= nStiffLeptonMin && nLeptons >= nLeptonMin) {
206  keepEvent = true;
207  } else {
208  keepEvent = false;
209  }
210 
211  if (keepEvent) {
212  if (isFourE)
213  nSelFourE++;
214  if (isFourM)
215  nSelFourM++;
216  if (isTwoETwoM)
217  nSelTwoETwoM++;
218  if (isFourL)
219  nSelFourL++;
220  if (isTau)
221  nSelTau++;
222  }
223 }
PDWG_BPHSkim_cff.muons
muons
Definition: PDWG_BPHSkim_cff.py:47
edm::Handle::product
T const * product() const
Definition: Handle.h:70
edm
HLT enums.
Definition: AlignableModifier.h:19
gather_cfg.cout
cout
Definition: gather_cfg.py:144
reco::GsfElectronCollection
std::vector< GsfElectron > GsfElectronCollection
collection of GsfElectron objects
Definition: GsfElectronFwd.h:14
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:45
HiggsToZZ4LeptonsSkimEff::~HiggsToZZ4LeptonsSkimEff
~HiggsToZZ4LeptonsSkimEff() override
Definition: HiggsToZZ4LeptonsSkimEff.cc:58
edm::Handle
Definition: AssociativeIterator.h:50
singleTopDQM_cfi.setup
setup
Definition: singleTopDQM_cfi.py:37
CandMatchMap.h
debug
#define debug
Definition: HDRShower.cc:19
Track.h
GsfElectron.h
edm::OwnVector::const_iterator
Definition: OwnVector.h:41
genCandidates_cfi.genCandidates
genCandidates
Definition: genCandidates_cfi.py:3
edm::ParameterSet
Definition: ParameterSet.h:47
edm::EventSetup
Definition: EventSetup.h:57
std
Definition: JetResolutionObject.h:76
pwdgSkimBPark_cfi.electrons
electrons
Definition: pwdgSkimBPark_cfi.py:6
HiggsToZZ4LeptonsSkimEff.h
reco::isTau
bool isTau(const Candidate &part)
Definition: pdgIdUtils.h:11
AssociationVector.h
Candidate.h
ParameterSet.h
edm::HandleBase::isValid
bool isValid() const
Definition: HandleBase.h:70
event
Definition: event.py:1
nEvents
UInt_t nEvents
Definition: hcalCalib.cc:41
edm::Event
Definition: Event.h:73
HiggsToZZ4LeptonsSkimEff::HiggsToZZ4LeptonsSkimEff
HiggsToZZ4LeptonsSkimEff(const edm::ParameterSet &)
Definition: HiggsToZZ4LeptonsSkimEff.cc:36
edm::InputTag
Definition: InputTag.h:15
reco::TrackCollection
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:14
muonDTDigis_cfi.pset
pset
Definition: muonDTDigis_cfi.py:27
HiggsToZZ4LeptonsSkimEff::analyze
void analyze(const edm::Event &, const edm::EventSetup &) override
Get event properties to send to builder to fill seed collection.
Definition: HiggsToZZ4LeptonsSkimEff.cc:80