1 |
amagnan |
1.1 |
#include "DataFormats/Common/interface/Handle.h"
|
2 |
|
|
#include "DataFormats/Common/interface/TriggerResults.h"
|
3 |
|
|
#include "DataFormats/Common/interface/HLTenums.h"
|
4 |
|
|
#include "DataFormats/Common/interface/ValueMap.h"
|
5 |
|
|
#include "DataFormats/Candidate/interface/Candidate.h"
|
6 |
|
|
#include "DataFormats/HepMCCandidate/interface/GenParticle.h"
|
7 |
|
|
#include "DataFormats/MuonReco/interface/Muon.h"
|
8 |
|
|
#include "DataFormats/MuonReco/interface/MuonFwd.h"
|
9 |
|
|
#include "DataFormats/VertexReco/interface/Vertex.h"
|
10 |
|
|
#include "DataFormats/HLTReco/interface/TriggerEvent.h"
|
11 |
|
|
|
12 |
|
|
#include "DataFormats/PatCandidates/interface/Muon.h"
|
13 |
|
|
#include "DataFormats/PatCandidates/interface/Electron.h"
|
14 |
|
|
#include "DataFormats/PatCandidates/interface/Tau.h"
|
15 |
|
|
#include "DataFormats/PatCandidates/interface/Jet.h"
|
16 |
|
|
|
17 |
|
|
#include "FWCore/ServiceRegistry/interface/Service.h"
|
18 |
|
|
#include "PhysicsTools/UtilAlgos/interface/TFileService.h"
|
19 |
|
|
|
20 |
|
|
|
21 |
|
|
#include "UserCode/HbbAnalysis/plugins/HbbAnalyzer.hh"
|
22 |
|
|
|
23 |
|
|
using namespace HbbAnalysis;
|
24 |
|
|
|
25 |
|
|
HbbAnalyzer::HbbAnalyzer(const edm::ParameterSet & pset):
|
26 |
|
|
debug_(pset.getParameter<int>("DEBUG")),
|
27 |
|
|
muonSrc_(pset.getParameter<edm::InputTag>("Muons")),
|
28 |
|
|
tauSrc_(pset.getParameter<edm::InputTag>("Taus")),
|
29 |
|
|
jetSrc_(pset.getParameter<edm::InputTag>("Jets")),
|
30 |
|
|
pfjetSrc_(pset.getParameter<edm::InputTag>("PFJets")),
|
31 |
|
|
vertexSrc_(pset.getParameter<edm::InputTag>("Vertex")),
|
32 |
|
|
triggerSrc_(pset.getParameter<edm::InputTag>("Trigger"))
|
33 |
|
|
//file_(0),
|
34 |
|
|
//processVec_(pset.getParameter<std::vector<std::string> >("ProcessVec"))
|
35 |
|
|
{//constructor
|
36 |
|
|
|
37 |
|
|
|
38 |
|
|
//file_ = TFile::Open(pset.getUntrackedParameter<std::string>("OutputFile","MuTauAnalysis.root").c_str(),"RECREATE");
|
39 |
|
|
//if (!file_) {
|
40 |
|
|
// std::cerr << "### Failed opening output file, please check configuration parameter. Exiting ..." << std::endl;
|
41 |
|
|
// exit(0);
|
42 |
|
|
//}
|
43 |
|
|
//else std::cout << "***** File : " << file_->GetName() << " successfully opened." << std::endl;
|
44 |
|
|
|
45 |
|
|
|
46 |
|
|
}//constructor
|
47 |
|
|
|
48 |
|
|
HbbAnalyzer::~HbbAnalyzer(){//destructor
|
49 |
|
|
//file_->Close();
|
50 |
|
|
}//destructor
|
51 |
|
|
|
52 |
|
|
|
53 |
|
|
|
54 |
|
|
void HbbAnalyzer::beginJob(const edm::EventSetup&){//beginJob
|
55 |
|
|
|
56 |
|
|
edm::Service<TFileService> lFileService;
|
57 |
|
|
|
58 |
|
|
TFileDirectory lSubDir = lFileService->mkdir( "Muons" );
|
59 |
|
|
MuHist_.Initialise(lSubDir,"Muons");
|
60 |
|
|
|
61 |
|
|
TFileDirectory lSubSubDir = lSubDir.mkdir( "GenMatched" );
|
62 |
|
|
MuHistGenMatched_.Initialise(lSubSubDir,"GenMatchedMuons",true);
|
63 |
|
|
|
64 |
|
|
|
65 |
|
|
lSubDir = lFileService->mkdir( "Taus" );
|
66 |
|
|
TauHist_.Initialise(lSubDir,"Taus");
|
67 |
|
|
|
68 |
|
|
lSubDir = lFileService->mkdir( "Jets" );
|
69 |
|
|
JetHist_.Initialise(lSubDir,"Jets");
|
70 |
|
|
|
71 |
|
|
lSubDir = lFileService->mkdir( "PFJets" );
|
72 |
|
|
PFJetHist_.Initialise(lSubDir,"PFJets");
|
73 |
|
|
|
74 |
|
|
|
75 |
|
|
}//beginJob
|
76 |
|
|
|
77 |
|
|
void HbbAnalyzer::endJob(){//endJob
|
78 |
|
|
|
79 |
|
|
MuHist_.FillEffHistograms();
|
80 |
|
|
MuHistGenMatched_.FillEffHistograms();
|
81 |
|
|
|
82 |
|
|
}//endJob
|
83 |
|
|
|
84 |
|
|
void HbbAnalyzer::analyze(const edm::Event& aEvt, const edm::EventSetup& aEvtSetup){//analyze
|
85 |
|
|
|
86 |
|
|
//dumpContent(aEvt,"","MuTauPAT");
|
87 |
|
|
|
88 |
|
|
static bool firstEvent = true;
|
89 |
|
|
|
90 |
|
|
|
91 |
|
|
edm::Handle<std::vector<pat::Muon> > lMuonCollection;
|
92 |
|
|
try {
|
93 |
|
|
aEvt.getByLabel(muonSrc_,lMuonCollection);
|
94 |
|
|
if (!lMuonCollection.isValid()){
|
95 |
|
|
edm::LogInfo("ERROR")<< "Error! Can't get muon by label. ";
|
96 |
|
|
}
|
97 |
|
|
if (debug_) std::cout << "** muoncollection = " << lMuonCollection->size() << " elements." << std::endl;
|
98 |
|
|
} catch(cms::Exception& e) {
|
99 |
|
|
std::cout << "AMM: Collection " << muonSrc_ << " not available! Exception : " << e.what() << ". " << std::endl;
|
100 |
|
|
}
|
101 |
|
|
if (lMuonCollection.isValid()){
|
102 |
|
|
|
103 |
|
|
MuHist_.FillEventHistograms(lMuonCollection);
|
104 |
|
|
MuHistGenMatched_.FillEventHistograms(lMuonCollection);
|
105 |
|
|
|
106 |
|
|
if (lMuonCollection->size() > 0) {
|
107 |
|
|
|
108 |
|
|
//std::vector<pat::Muon>::const_iterator iMuon = lMuonCollection->begin();
|
109 |
|
|
bool isLead = true;
|
110 |
|
|
for (std::vector<pat::Muon>::const_iterator iMuon = lMuonCollection->begin();
|
111 |
|
|
iMuon != lMuonCollection->end();
|
112 |
|
|
iMuon++)
|
113 |
|
|
{
|
114 |
|
|
//if (debug_ > 1) std::cout << "pT,eta,phi = " << (*iMuon).pt() << " " << (*iMuon).eta() << " " << (*iMuon).phi() << std::endl;
|
115 |
|
|
MuHist_.FillHistograms(*iMuon,isLead);
|
116 |
|
|
MuHistGenMatched_.FillHistograms(*iMuon,isLead);
|
117 |
|
|
isLead = false;
|
118 |
|
|
|
119 |
|
|
}
|
120 |
|
|
}
|
121 |
|
|
}
|
122 |
|
|
|
123 |
|
|
edm::Handle<std::vector<reco::Vertex> > lRecoVertices;
|
124 |
|
|
try {
|
125 |
|
|
aEvt.getByLabel(vertexSrc_, lRecoVertices);
|
126 |
|
|
if (!lRecoVertices.isValid()){
|
127 |
|
|
edm::LogInfo("ERROR")<< "Error! Can't get vertex by label. ";
|
128 |
|
|
}
|
129 |
|
|
if (debug_) std::cout << "** vertexcollection = " << lRecoVertices->size() << " elements." << std::endl;
|
130 |
|
|
} catch(cms::Exception& e) {
|
131 |
|
|
std::cout << "AMM: Collection " << vertexSrc_ << " not available! Exception : " << e.what() << ". " << std::endl;
|
132 |
|
|
}
|
133 |
|
|
|
134 |
|
|
|
135 |
|
|
edm::Handle<std::vector<pat::Tau> > lTauCollection;
|
136 |
|
|
try {
|
137 |
|
|
aEvt.getByLabel(tauSrc_,lTauCollection);
|
138 |
|
|
if (!lTauCollection.isValid()){
|
139 |
|
|
edm::LogInfo("ERROR")<< "Error! Can't get tau by label. ";
|
140 |
|
|
}
|
141 |
|
|
if (debug_) std::cout << "** taucollection = " << lTauCollection->size() << " elements." << std::endl;
|
142 |
|
|
} catch(cms::Exception& e) {
|
143 |
|
|
std::cout << "AMM: Collection " << tauSrc_ << " not available! Exception : " << e.what() << ". " << std::endl;
|
144 |
|
|
}
|
145 |
|
|
if (lTauCollection.isValid()){
|
146 |
|
|
if (lTauCollection->size() > 0) {
|
147 |
|
|
std::vector<pat::Tau>::const_iterator iTau = lTauCollection->begin();
|
148 |
|
|
//for (reco::TauCollection::const_iterator iTau = lTauCollection->begin();
|
149 |
|
|
// iTau != lTauCollection->end();
|
150 |
|
|
// iTau++)
|
151 |
|
|
// {
|
152 |
|
|
if (debug_ > 1) std::cout << "pT,eta,phi = " << (*iTau).pt() << " " << (*iTau).eta() << " " << (*iTau).phi() << std::endl;
|
153 |
|
|
TauHist_.FillHistograms(*iTau,lRecoVertices);
|
154 |
|
|
|
155 |
|
|
|
156 |
|
|
// }
|
157 |
|
|
}
|
158 |
|
|
}
|
159 |
|
|
|
160 |
|
|
|
161 |
|
|
edm::Handle<std::vector<pat::Jet> > lJetCollection;
|
162 |
|
|
try {
|
163 |
|
|
aEvt.getByLabel(jetSrc_,lJetCollection);
|
164 |
|
|
if (!lJetCollection.isValid()){
|
165 |
|
|
edm::LogInfo("ERROR")<< "Error! Can't get jet by label. ";
|
166 |
|
|
}
|
167 |
|
|
if (debug_) std::cout << "** jetcollection = " << lJetCollection->size() << " elements." << std::endl;
|
168 |
|
|
} catch(cms::Exception& e) {
|
169 |
|
|
std::cout << "AMM: Collection " << jetSrc_ << " not available! Exception : " << e.what() << ". " << std::endl;
|
170 |
|
|
}
|
171 |
|
|
if (lJetCollection.isValid()){
|
172 |
|
|
|
173 |
|
|
JetHist_.FillEventHistograms(lJetCollection);
|
174 |
|
|
|
175 |
|
|
if (lJetCollection->size() > 0) {
|
176 |
|
|
|
177 |
|
|
//std::vector<pat::Jet>::const_iterator iJet = lJetCollection->begin();
|
178 |
|
|
bool isLead = true;
|
179 |
|
|
for (std::vector<pat::Jet>::const_iterator iJet = lJetCollection->begin();
|
180 |
|
|
iJet != lJetCollection->end();
|
181 |
|
|
iJet++)
|
182 |
|
|
{
|
183 |
|
|
//if (debug_ > 1) std::cout << "pT,eta,phi = " << (*iJet).pt() << " " << (*iJet).eta() << " " << (*iJet).phi() << std::endl;
|
184 |
|
|
JetHist_.FillHistograms(*iJet,isLead);
|
185 |
|
|
isLead = false;
|
186 |
|
|
|
187 |
|
|
}
|
188 |
|
|
}
|
189 |
|
|
}
|
190 |
|
|
|
191 |
|
|
|
192 |
|
|
edm::Handle<std::vector<pat::Jet> > lPFJetCollection;
|
193 |
|
|
try {
|
194 |
|
|
aEvt.getByLabel(pfjetSrc_,lPFJetCollection);
|
195 |
|
|
if (!lPFJetCollection.isValid()){
|
196 |
|
|
edm::LogInfo("ERROR")<< "Error! Can't get jet by label. ";
|
197 |
|
|
}
|
198 |
|
|
if (debug_) std::cout << "** PFjetcollection = " << lPFJetCollection->size() << " elements." << std::endl;
|
199 |
|
|
} catch(cms::Exception& e) {
|
200 |
|
|
std::cout << "AMM: Collection " << pfjetSrc_ << " not available! Exception : " << e.what() << ". " << std::endl;
|
201 |
|
|
}
|
202 |
|
|
if (lPFJetCollection.isValid()){
|
203 |
|
|
|
204 |
|
|
PFJetHist_.FillEventHistograms(lPFJetCollection);
|
205 |
|
|
|
206 |
|
|
if (lPFJetCollection->size() > 0) {
|
207 |
|
|
|
208 |
|
|
//std::vector<pat::Jet>::const_iterator iJet = lPFJetCollection->begin();
|
209 |
|
|
bool isLead = true;
|
210 |
|
|
for (std::vector<pat::Jet>::const_iterator iJet = lPFJetCollection->begin();
|
211 |
|
|
iJet != lPFJetCollection->end();
|
212 |
|
|
iJet++)
|
213 |
|
|
{
|
214 |
|
|
//if (debug_ > 1) std::cout << "pT,eta,phi = " << (*iJet).pt() << " " << (*iJet).eta() << " " << (*iJet).phi() << std::endl;
|
215 |
|
|
PFJetHist_.FillHistograms(*iJet,isLead);
|
216 |
|
|
isLead = false;
|
217 |
|
|
|
218 |
|
|
}
|
219 |
|
|
}
|
220 |
|
|
}
|
221 |
|
|
|
222 |
|
|
firstEvent = false;
|
223 |
|
|
|
224 |
|
|
}//analyze
|
225 |
|
|
|
226 |
|
|
void HbbAnalyzer::dumpContent(const edm::Event& aEvt, std::string aName, std::string aProcess){//dumpContent
|
227 |
|
|
//to dump the content of the event
|
228 |
|
|
|
229 |
|
|
typedef std::vector< edm::Provenance const*> Provenances;
|
230 |
|
|
Provenances lProvenances;
|
231 |
|
|
aEvt.getAllProvenance(lProvenances);
|
232 |
|
|
|
233 |
|
|
for(Provenances::iterator itProv = lProvenances.begin(), itProvEnd = lProvenances.end();
|
234 |
|
|
itProv != itProvEnd;
|
235 |
|
|
++itProv) {
|
236 |
|
|
|
237 |
|
|
std::string lName = (*itProv)->friendlyClassName();
|
238 |
|
|
std::string lModLabel = (*itProv)->moduleLabel();
|
239 |
|
|
std::string lInstanceName = (*itProv)->productInstanceName();
|
240 |
|
|
std::string lProcessName = (*itProv)->processName();
|
241 |
|
|
|
242 |
|
|
//std::cout << " - friendlyName = " << lName << std::endl;
|
243 |
|
|
if (lName.find(aName) != lName.npos && lProcessName.find(aProcess) != lProcessName.npos) {
|
244 |
|
|
|
245 |
|
|
//if (debug_>1) {
|
246 |
|
|
std::cout << " -- Object type = " << lName << std::endl
|
247 |
|
|
<< " ----- Module = " << lModLabel << std::endl
|
248 |
|
|
<< " ----- Instance = " << lInstanceName << std::endl;
|
249 |
|
|
//<< " ----- Process = " << lProcessName << std::endl;
|
250 |
|
|
//}
|
251 |
|
|
}
|
252 |
|
|
}
|
253 |
|
|
}//dumpContent
|
254 |
|
|
|
255 |
|
|
|
256 |
|
|
|
257 |
|
|
|
258 |
|
|
|
259 |
|
|
|
260 |
|
|
|
261 |
|
|
|
262 |
|
|
|
263 |
|
|
|
264 |
|
|
|
265 |
|
|
|
266 |
|
|
|
267 |
|
|
|
268 |
|
|
|
269 |
|
|
|