-
Notifications
You must be signed in to change notification settings - Fork 0
/
CheckGenContent.cc
157 lines (124 loc) · 4 KB
/
CheckGenContent.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
// -*- C++ -*-
//
// Package: CheckGenContent
// Class: CheckGenContent
//
/**\class CheckGenContent CheckGenContent.cc CheckGenContent/CheckGenContent/src/CheckGenContent.cc
Description: [one line class summary]
Implementation:
[Notes on implementation]
*/
//
// Original Author: Saptaparna Bhattacharya
// Created: Thu May 22 12:21:29 CDT 2014
// $Id$
//
//
#include"CheckGenContent/CheckGenContent/interface/CheckGenContent.h"
#include"DataFormats/HepMCCandidate/interface/GenParticle.h"
#include"RecoEgamma/Examples/plugins/GsfElectronMCAnalyzer.h"
#include"FWCore/ParameterSet/interface/ParameterSet.h"
#include"FWCore/Framework/interface/EDAnalyzer.h"
#include"FWCore/Framework/interface/Event.h"
#include"DataFormats/HepMCCandidate/interface/GenParticleFwd.h"
CheckGenContent::CheckGenContent(const edm::ParameterSet& iConfig)
{
electrons=0;
muons=0;
taus = 0;
n_ditaus = 0;
n_dielectrons=0;
n_dimuons=0;
}
CheckGenContent::~CheckGenContent()
{
// do anything here that needs to be done at desctruction time
// (e.g. close files, deallocate resources etc.)
}
//
// member functions
//
// ------------ method called for each event ------------
void
CheckGenContent::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup)
{
using namespace edm;
Handle<std::vector<reco::GenParticle> > genParticles;
iEvent.getByLabel("genParticles", genParticles) ;
int n_electrons=0;
int n_muons=0;
int n_taus=0;
for(std::vector<reco::GenParticle>::const_iterator genParticle = genParticles->begin(); genParticle != genParticles->end(); genParticle++){
int id = genParticle->pdgId();
int st = genParticle->status();
double pt = genParticle->pt();
if (abs(id)==11 && st==3){
electrons++;
n_electrons++;
}
if (abs(id)==13 && st==3){
muons++;
n_muons++;
}
if (abs(id)==15 && st==3){
taus++;
n_taus++;
}
}
if(n_electrons==2 && n_muons==0 && n_taus==0){
n_dielectrons++;
}
if(n_muons==2 && n_electrons==0 && n_taus==0){
n_dimuons++;
}
if(n_taus==2 && n_electrons==0 && n_muons==0){
n_ditaus++;
}
}
// ------------ method called once each job just before starting event loop ------------
void
CheckGenContent::beginJob()
{
}
// ------------ method called once each job just after ending the event loop ------------
void
CheckGenContent::endJob()
{
std::cout << "electrons = " << electrons << std::endl;
std::cout << "muons = " << muons << std::endl;
std::cout << "taus = " << taus << std::endl;
std::cout << "n_ditaus = " << n_ditaus << std::endl;
std::cout << "n_dielectrons = " << n_dielectrons << std::endl;
std::cout << "n_dimuons = " << n_dimuons << std::endl;
}
// ------------ method called when starting to processes a run ------------
void
CheckGenContent::beginRun(edm::Run const&, edm::EventSetup const&)
{
}
// ------------ method called when ending the processing of a run ------------
void
CheckGenContent::endRun(edm::Run const&, edm::EventSetup const&)
{
}
// ------------ method called when starting to processes a luminosity block ------------
void
CheckGenContent::beginLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&)
{
}
// ------------ method called when ending the processing of a luminosity block ------------
void
CheckGenContent::endLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&)
{
}
// ------------ method fills 'descriptions' with the allowed parameters for the module ------------
void
CheckGenContent::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
//The following says we do not know what parameters are allowed so do no validation
// Please change this to state exactly what you do use, even if it is no parameters
edm::ParameterSetDescription desc;
desc.setUnknown();
descriptions.addDefault(desc);
}
//define this as a plug-in
DEFINE_FWK_MODULE(CheckGenContent);