ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/HbbAnalysis/plugins/HbbAnalyzer.cc
Revision: 1.15
Committed: Thu Mar 4 15:17:42 2010 UTC (15 years, 2 months ago) by amagnan
Content type: text/plain
Branch: MAIN
CVS Tags: v00-05-00, HbbAnaFor35X, v00-04-02, v00-04-01, v00-04-00
Changes since 1.14: +3 -2 lines
Log Message:
update beginJob and TFileService from CommonTools

File Contents

# Content
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/Lepton.h"
13 #include "DataFormats/PatCandidates/interface/Muon.h"
14 #include "DataFormats/PatCandidates/interface/Electron.h"
15 #include "DataFormats/PatCandidates/interface/Tau.h"
16 #include "DataFormats/PatCandidates/interface/Jet.h"
17 #include "DataFormats/PatCandidates/interface/MET.h"
18
19 #include "FWCore/ServiceRegistry/interface/Service.h"
20
21 #include "CommonTools/UtilAlgos/interface/TFileService.h"
22
23
24 #include "UserCode/HbbAnalysis/plugins/HbbAnalyzer.hh"
25
26 using namespace HbbAnalysis;
27
28 HbbAnalyzer::HbbAnalyzer(const edm::ParameterSet & pset):
29 debug_(pset.getParameter<int>("DEBUG")),
30 flavour_(pset.getParameter<unsigned int>("JetFlavour")),
31 jetLeptonIsolation_(pset.getParameter<double>("JetLeptonDeltaRCut")),
32 doElectrons_(pset.getParameter<bool>("DoElectrons")),
33 doMuons_(pset.getParameter<bool>("DoMuons")),
34 doTaus_(pset.getParameter<bool>("DoTaus")),
35 doJets_(pset.getParameter<bool>("DoJets")),
36 doMETs_(pset.getParameter<bool>("DoMETs")),
37 doPairs_(pset.getParameter<bool>("DoPairs")),
38 //doLepLepPairs_(pset.getParameter<bool>("DoLepLepPairs")),
39 genParticleSrc_(pset.getParameter<edm::InputTag>("GenParticles")),
40 electronSrc_(pset.getParameter<edm::InputTag>("Electrons")),
41 muonSrc_(pset.getParameter<edm::InputTag>("Muons")),
42 //caloTauSrc_(pset.getParameter<edm::InputTag>("CaloTaus")),
43 tauSrc_(pset.getParameter<edm::InputTag>("Taus")),
44 jetSrc_(pset.getParameter<edm::InputTag>("Jets")),
45 //jptjetSrc_(pset.getParameter<edm::InputTag>("JPTJets")),
46 //pfjetSrc_(pset.getParameter<edm::InputTag>("PFJets")),
47 metSrc_(pset.getParameter<edm::InputTag>("MET")),
48 //tcMetSrc_(pset.getParameter<edm::InputTag>("TCMET")),
49 //pfMetSrc_(pset.getParameter<edm::InputTag>("PFMET")),
50 pairSrc_(pset.getParameter<edm::InputTag>("Pair")),
51 //mmPairSrc_(pset.getParameter<edm::InputTag>("MuMuPair")),
52 //etPairSrc_(pset.getParameter<edm::InputTag>("ETauPair")),
53 //mtPairSrc_(pset.getParameter<edm::InputTag>("MuTauPair")),
54 vertexSrc_(pset.getParameter<edm::InputTag>("Vertex")),
55 triggerSrc_(pset.getParameter<edm::InputTag>("Trigger")),
56 hltPaths_(pset.getParameter<std::vector<std::string> >("HLTPaths"))
57 //file_(0),
58 //processVec_(pset.getParameter<std::vector<std::string> >("ProcessVec"))
59 {//constructor
60
61 //file_ = TFile::Open(pset.getUntrackedParameter<std::string>("OutputFile","MuTauAnalysis.root").c_str(),"RECREATE");
62 //if (!file_) {
63 // std::cerr << "### Failed opening output file, please check configuration parameter. Exiting ..." << std::endl;
64 // exit(0);
65 //}
66 //else std::cout << "***** File : " << file_->GetName() << " successfully opened." << std::endl;
67
68
69 }//constructor
70
71 HbbAnalyzer::~HbbAnalyzer(){//destructor
72 //file_->Close();
73 }//destructor
74
75
76
77 void HbbAnalyzer::beginJob(){//beginJob
78
79
80 edm::Service<TFileService> lFileService;
81
82 TFileDirectory lDir = lFileService->mkdir("Dummy");
83 TFileDirectory lSubDir = lDir.mkdir("Dummy");
84 TFileDirectory lSubSubDir = lSubDir.mkdir("Dummy");
85 TFileDirectory lSubSubSubDir = lSubSubDir.mkdir("Dummy");
86
87 if (doJets_){
88 if (debug_) std::cout << "Initialising JetFlavour : " << std::endl;
89
90 lDir = lFileService->mkdir("JetFlavours");
91
92 jetFlav_.Initialise(lDir, debug_, flavour_);
93 }
94
95 if (doElectrons_){
96 if (debug_) std::cout << "Initialising electrons histograms : " << std::endl;
97
98 lDir = lFileService->mkdir("Electrons");
99
100 lSubDir = lDir.mkdir("All");
101
102 lSubSubDir = lSubDir.mkdir("Leading");
103 ElecHistLead_.Initialise(lSubSubDir,"Electrons");
104 lSubSubSubDir = lSubSubDir.mkdir( "GenMatched" );
105 ElecHistLeadGenMatched_.Initialise(lSubSubSubDir,"Electrons",true);
106
107 lSubSubDir = lSubDir.mkdir("NextToLeading");
108 ElecHistNtoLead_.Initialise(lSubSubDir,"Electrons");
109 lSubSubSubDir = lSubSubDir.mkdir( "GenMatched" );
110 ElecHistNtoLeadGenMatched_.Initialise(lSubSubSubDir,"Electrons",true);
111
112 lSubDir = lDir.mkdir("Barrel");
113
114 lSubSubDir = lSubDir.mkdir("Leading");
115 ElecHistBarrelLead_.Initialise(lSubSubDir,"Electrons");
116 lSubSubSubDir = lSubSubDir.mkdir( "GenMatched" );
117 ElecHistBarrelLeadGenMatched_.Initialise(lSubSubSubDir,"Electrons",true);
118
119 lSubSubDir = lSubDir.mkdir("NextToLeading");
120 ElecHistBarrelNtoLead_.Initialise(lSubSubDir,"Electrons");
121 lSubSubSubDir = lSubSubDir.mkdir( "GenMatched" );
122 ElecHistBarrelNtoLeadGenMatched_.Initialise(lSubSubSubDir,"Electrons",true);
123
124 lSubDir = lDir.mkdir("EndCap");
125
126 lSubSubDir = lSubDir.mkdir("Leading");
127 ElecHistEndCapLead_.Initialise(lSubSubDir,"Electrons");
128 lSubSubSubDir = lSubSubDir.mkdir( "GenMatched" );
129 ElecHistEndCapLeadGenMatched_.Initialise(lSubSubSubDir,"Electrons",true);
130
131 lSubSubDir = lSubDir.mkdir("NextToLeading");
132 ElecHistEndCapNtoLead_.Initialise(lSubSubDir,"Electrons");
133 lSubSubSubDir = lSubSubDir.mkdir( "GenMatched" );
134 ElecHistEndCapNtoLeadGenMatched_.Initialise(lSubSubSubDir,"Electrons",true);
135 }
136
137 if (doMuons_){
138 if (debug_) std::cout << "Initialising muons histograms : " << std::endl;
139
140 lDir = lFileService->mkdir( "Muons" );
141
142 lSubDir = lDir.mkdir("Leading");
143 MuHistLead_.Initialise(lSubDir,"Muons");
144 lSubSubDir = lSubDir.mkdir( "GenMatched" );
145 MuHistLeadGenMatched_.Initialise(lSubSubDir,"Muons",true);
146
147 lSubDir = lDir.mkdir("NextToLeading");
148 MuHistNtoLead_.Initialise(lSubDir,"Muons");
149 lSubSubDir = lSubDir.mkdir( "GenMatched" );
150 MuHistNtoLeadGenMatched_.Initialise(lSubSubDir,"Muons",true);
151 }
152
153 if (doTaus_){
154 if (debug_) std::cout << "Initialising taus histograms : " << std::endl;
155
156 lDir = lFileService->mkdir( "Taus" );
157 TauHist_.Initialise(lDir,"Taus");
158 lSubDir = lDir.mkdir( "GenMatched" );
159 TauHistGenMatched_.Initialise(lSubDir,"GenMatchedTaus",true);
160
161 // lDir = lFileService->mkdir( "PFTaus" );
162 // PFTauHist_.Initialise(lDir,"PFTaus");
163 // lSubDir = lDir.mkdir( "GenMatched" );
164 // PFTauHistGenMatched_.Initialise(lSubDir,"GenMatchedTaus",true);
165 }
166
167 if (doJets_){
168 if (debug_) std::cout << "Initialising jets histograms : " << std::endl;
169
170 lDir = lFileService->mkdir( "Jets" );
171
172 lSubDir = lDir.mkdir("All");
173 JetHist_.Initialise(lSubDir,"Jets",debug_);
174 lSubDir = lDir.mkdir("Leading");
175 JetHistLead_.Initialise(lSubDir,"Jets",debug_);
176 //lSubSubDir = lSubDir.mkdir( "GenMatched" );
177 //JetHistLeadGenMatched_.Initialise(lSubSubDir,"Jets",true);
178
179
180 lSubDir = lDir.mkdir("NextToLeading");
181 JetHistNtoLead_.Initialise(lSubDir,"Jets",debug_);
182 //lSubSubDir = lSubDir.mkdir( "GenMatched" );
183 //JetHistNtoLeadGenMatched_.Initialise(lSubSubDir,"Jets",true);
184
185
186 // lDir = lFileService->mkdir( "PFJets" );
187
188 // lSubDir = lDir.mkdir("All");
189 // PFJetHist_.Initialise(lSubDir,"Jets",debug_);
190 // lSubDir = lDir.mkdir("Leading");
191 // PFJetHistLead_.Initialise(lSubDir,"PFJets",debug_);
192 // lSubDir = lDir.mkdir("NextToLeading");
193 // PFJetHistNtoLead_.Initialise(lSubDir,"PFJets",debug_);
194
195 // lDir = lFileService->mkdir( "JPTJets" );
196
197 // lSubDir = lDir.mkdir("All");
198 // JPTJetHist_.Initialise(lSubDir,"Jets",debug_);
199 // lSubDir = lDir.mkdir("Leading");
200 // JPTJetHistLead_.Initialise(lSubDir,"JPTJets",debug_);
201 // lSubDir = lDir.mkdir("NextToLeading");
202 // JPTJetHistNtoLead_.Initialise(lSubDir,"JPTJets",debug_);
203 }
204
205
206 if (doPairs_){
207 lDir = lFileService->mkdir("Pairs");
208 if (debug_) std::cout << "Initialising pairs histograms : " << std::endl;
209
210 lSubDir = lDir.mkdir("All");
211 PairHist_.Initialise(lSubDir,"Pairs",debug_);
212
213 lSubDir = lDir.mkdir("Leading");
214 PairHistLead_.Initialise(lSubDir,"Pairs",debug_);
215 }
216
217 // if (doLepTauPairs_){
218 // lSubDir = lDir.mkdir("etau");
219 // ETPairHist_.Initialise(lSubDir,"Pairs",debug_);
220
221 // lSubDir = lDir.mkdir("mutau");
222 // MTPairHist_.Initialise(lSubDir,"Pairs",debug_);
223 // }
224
225 if (doMETs_){
226 if (debug_) std::cout << "Initialising METs histograms : " << std::endl;
227
228 lDir = lFileService->mkdir("MET");
229 //lSubDir = lDir.mkdir("CaloMET");
230 MetHist_.Initialise(lDir,"MET",debug_);
231
232 // lSubDir = lDir.mkdir("PFMET");
233 // PFMetHist_.Initialise(lSubDir,"MET",debug_);
234
235 // lSubDir = lDir.mkdir("TcMET");
236 // TcMetHist_.Initialise(lSubDir,"MET",debug_);
237 }
238
239 }//beginJob
240
241 void HbbAnalyzer::endJob(){//endJob
242
243 if (doElectrons_){
244 ElecHistLead_.FillEffHistograms();
245 ElecHistLeadGenMatched_.FillEffHistograms();
246
247 ElecHistNtoLead_.FillEffHistograms();
248 ElecHistNtoLeadGenMatched_.FillEffHistograms();
249
250 ElecHistBarrelLead_.FillEffHistograms();
251 ElecHistBarrelLeadGenMatched_.FillEffHistograms();
252
253 ElecHistBarrelNtoLead_.FillEffHistograms();
254 ElecHistBarrelNtoLeadGenMatched_.FillEffHistograms();
255
256 ElecHistEndCapLead_.FillEffHistograms();
257 ElecHistEndCapLeadGenMatched_.FillEffHistograms();
258
259 ElecHistEndCapNtoLead_.FillEffHistograms();
260 ElecHistEndCapNtoLeadGenMatched_.FillEffHistograms();
261 }
262
263 if (doMuons_){
264 MuHistLead_.FillEffHistograms();
265 MuHistLeadGenMatched_.FillEffHistograms();
266
267 MuHistNtoLead_.FillEffHistograms();
268 MuHistNtoLeadGenMatched_.FillEffHistograms();
269 }
270
271 if (doJets_){
272 jetFlav_.printSummary();
273 //JetHistLead_.FillEffHistograms();
274 //JetHistLeadGenMatched_.FillEffHistograms();
275
276 //JetHistNtoLead_.FillEffHistograms();
277 //JetHistNtoLeadGenMatched_.FillEffHistograms();
278
279
280 }
281
282 }//endJob
283
284 void HbbAnalyzer::analyze(const edm::Event& aEvt, const edm::EventSetup& aEvtSetup){//analyze
285
286 //dumpContent(aEvt,"","MuTauPAT");
287
288 static bool firstEvent = true;
289
290
291 edm::Handle<reco::GenParticleCollection> lGenParticles;
292 try {
293 aEvt.getByLabel(genParticleSrc_,lGenParticles);
294 if (debug_) std::cout << "** ngenParticles = " << lGenParticles->size() << std::endl;
295 } catch(cms::Exception& e) {
296 std::cout << "AMM: Collection genParticles not available! Exception : " << e.what() << ". " << std::endl;
297 }
298
299 unsigned int lNPartons = 0;
300
301 if (doJets_){
302 lNPartons = jetFlav_.fillPartons(lGenParticles);
303 }
304
305 if (debug_) std::cout << "--- Number of partons = " << lNPartons << " (doJets=" << doJets_ << ")." << std::endl;
306
307
308 edm::Handle<std::vector<reco::Vertex> > lRecoVertices;
309 try {
310 aEvt.getByLabel(vertexSrc_, lRecoVertices);
311 if (!lRecoVertices.isValid()){
312 edm::LogInfo("ERROR")<< "Error! Can't get vertex by label. ";
313 }
314 if (debug_) std::cout << "** vertexcollection = " << lRecoVertices->size() << " elements." << std::endl;
315 } catch(cms::Exception& e) {
316 std::cout << "AMM: Collection " << vertexSrc_ << " not available! Exception : " << e.what() << ". " << std::endl;
317 }
318
319
320
321 edm::Handle<std::vector<pat::Electron> > lElectronCollection;
322
323 if (doElectrons_ || doJets_){
324 try {
325 aEvt.getByLabel(electronSrc_,lElectronCollection);
326 if (!lElectronCollection.isValid()){
327 edm::LogInfo("ERROR")<< "Error! Can't get electron by label. ";
328 }
329 if (debug_) std::cout << "** electroncollection = " << lElectronCollection->size() << " elements." << std::endl;
330 } catch(cms::Exception& e) {
331 std::cout << "AMM: Collection " << electronSrc_ << " not available! Exception : " << e.what() << ". " << std::endl;
332 }
333 if (lElectronCollection.isValid() && doElectrons_){
334
335 ElecHistLead_.FillEventHistograms(lElectronCollection);
336 ElecHistLeadGenMatched_.FillEventHistograms(lElectronCollection);
337
338 ElecHistNtoLead_.FillEventHistograms(lElectronCollection);
339 ElecHistNtoLeadGenMatched_.FillEventHistograms(lElectronCollection);
340
341 if (lElectronCollection->size() > 0) {
342
343 //std::vector<pat::Electron>::const_iterator iElectron = lElectronCollection->begin();
344 unsigned int iEle = 0;
345 for (std::vector<pat::Electron>::const_iterator iElectron = lElectronCollection->begin();
346 iElectron != lElectronCollection->end();
347 iElectron++)
348 {
349 //if (debug_ > 1) std::cout << "pT,eta,phi = " << (*iElectron).pt() << " " << (*iElectron).eta() << " " << (*iElectron).phi() << std::endl;
350 if (iEle == 0) {
351 ElecHistLead_.FillHistograms(*iElectron,lRecoVertices);
352 ElecHistLeadGenMatched_.FillHistograms(*iElectron,lRecoVertices);
353 if (fabs((*iElectron).eta())<1.47) {
354 ElecHistBarrelLead_.FillHistograms(*iElectron,lRecoVertices);
355 ElecHistBarrelLeadGenMatched_.FillHistograms(*iElectron,lRecoVertices);
356 }
357 else {
358 ElecHistEndCapLead_.FillHistograms(*iElectron,lRecoVertices);
359 ElecHistEndCapLeadGenMatched_.FillHistograms(*iElectron,lRecoVertices);
360 }
361 }
362 else if (iEle == 1){
363 ElecHistNtoLead_.FillHistograms(*iElectron,lRecoVertices);
364 ElecHistNtoLeadGenMatched_.FillHistograms(*iElectron,lRecoVertices);
365 if (fabs((*iElectron).eta())<1.47) {
366 ElecHistBarrelNtoLead_.FillHistograms(*iElectron,lRecoVertices);
367 ElecHistBarrelNtoLeadGenMatched_.FillHistograms(*iElectron,lRecoVertices);
368 }
369 else {
370 ElecHistEndCapNtoLead_.FillHistograms(*iElectron,lRecoVertices);
371 ElecHistEndCapNtoLeadGenMatched_.FillHistograms(*iElectron,lRecoVertices);
372 }
373 }
374 iEle++;
375 }
376 }
377 }
378 }//if doElec or doJets
379
380 edm::Handle<std::vector<pat::Muon> > lMuonCollection;
381 if (doMuons_ || doJets_){
382 try {
383 aEvt.getByLabel(muonSrc_,lMuonCollection);
384 if (!lMuonCollection.isValid()){
385 edm::LogInfo("ERROR")<< "Error! Can't get muon by label. ";
386 }
387 if (debug_) std::cout << "** muoncollection = " << lMuonCollection->size() << " elements." << std::endl;
388 } catch(cms::Exception& e) {
389 std::cout << "AMM: Collection " << muonSrc_ << " not available! Exception : " << e.what() << ". " << std::endl;
390 }
391 if (lMuonCollection.isValid() && doMuons_){
392
393 MuHistLead_.FillEventHistograms(lMuonCollection);
394 MuHistLeadGenMatched_.FillEventHistograms(lMuonCollection);
395
396 MuHistNtoLead_.FillEventHistograms(lMuonCollection);
397 MuHistNtoLeadGenMatched_.FillEventHistograms(lMuonCollection);
398
399 if (lMuonCollection->size() > 0) {
400
401 //std::vector<pat::Muon>::const_iterator iMuon = lMuonCollection->begin();
402 unsigned int iMu = 0;
403 for (std::vector<pat::Muon>::const_iterator iMuon = lMuonCollection->begin();
404 iMuon != lMuonCollection->end();
405 iMuon++)
406 {
407 //if (debug_ > 1) std::cout << "pT,eta,phi = " << (*iMuon).pt() << " " << (*iMuon).eta() << " " << (*iMuon).phi() << std::endl;
408 if (iMu == 0) {
409 MuHistLead_.FillHistograms(*iMuon,lRecoVertices);
410 MuHistLeadGenMatched_.FillHistograms(*iMuon,lRecoVertices);
411 }
412 else if (iMu == 1){
413 MuHistNtoLead_.FillHistograms(*iMuon,lRecoVertices);
414 MuHistNtoLeadGenMatched_.FillHistograms(*iMuon,lRecoVertices);
415 }
416 iMu++;
417 }
418 }
419 }
420 }
421
422
423 edm::Handle<std::vector<pat::Tau> > lTauCollection;
424 if (doTaus_ || doJets_){
425 try {
426 aEvt.getByLabel(tauSrc_,lTauCollection);
427 if (!lTauCollection.isValid()){
428 edm::LogInfo("ERROR")<< "Error! Can't get Tau by label. ";
429 }
430 if (debug_) std::cout << "** Taucollection = " << lTauCollection->size() << " elements." << std::endl;
431 } catch(cms::Exception& e) {
432 std::cout << "AMM: Collection " << tauSrc_ << " not available! Exception : " << e.what() << ". " << std::endl;
433 }
434 if (lTauCollection.isValid() && doTaus_){
435
436 TauHist_.FillEventHistograms(lTauCollection);
437 TauHistGenMatched_.FillEventHistograms(lTauCollection);
438
439 if (lTauCollection->size() > 0) {
440
441 bool isLead = true;
442 //std::vector<pat::Tau>::const_iterator iTau = lTauCollection->begin();
443 for (std::vector<pat::Tau>::const_iterator iTau = lTauCollection->begin();
444 iTau != lTauCollection->end();
445 iTau++)
446 {
447 //if (debug_ > 1) std::cout << "pT,eta,phi = " << (*iTau).pt() << " " << (*iTau).eta() << " " << (*iTau).phi() << std::endl;
448 TauHist_.FillHistograms(*iTau,lRecoVertices,isLead);
449 TauHistGenMatched_.FillHistograms(*iTau,lRecoVertices,isLead);
450 isLead = false;
451 }
452 }
453 }
454 }
455
456
457 edm::Handle<std::vector<pat::Jet> > lJetCollection;
458
459 if (doJets_){
460 try {
461 aEvt.getByLabel(jetSrc_,lJetCollection);
462 if (!lJetCollection.isValid()){
463 edm::LogInfo("ERROR")<< "Error! Can't get jet by label. ";
464 }
465 if (debug_) std::cout << "** jetcollection = " << lJetCollection->size() << " elements." << std::endl;
466 } catch(cms::Exception& e) {
467 std::cout << "AMM: Collection " << jetSrc_ << " not available! Exception : " << e.what() << ". " << std::endl;
468 }
469 if (lJetCollection.isValid()){
470
471 JetHist_.FillEventHistograms(lJetCollection,jetFlav_);
472 JetHistLead_.FillEventHistograms(lJetCollection,jetFlav_);
473 JetHistNtoLead_.FillEventHistograms(lJetCollection,jetFlav_);
474 //JetHistLeadGenMatched_.FillEventHistograms(lJetCollection,jetFlav_);
475 //JetHistNtoLeadGenMatched_.FillEventHistograms(lJetCollection,jetFlav_);
476
477 if (lJetCollection->size() > 0) {
478
479 //std::vector<pat::Jet>::const_iterator iJet = lJetCollection->begin();
480 unsigned int ij = 0;
481 for (std::vector<pat::Jet>::const_iterator iJet = lJetCollection->begin();
482 iJet != lJetCollection->end();
483 iJet++)
484 {
485 double lDeltaRele = deltaRwithLepton<pat::Electron>(*iJet,lElectronCollection);
486 double lDeltaRmu = deltaRwithLepton<pat::Muon>(*iJet,lMuonCollection);
487 double lDeltaRtau = deltaRwithLepton<pat::Tau>(*iJet,lTauCollection);
488
489 JetHist_.FillIsolationHistograms(lDeltaRele,lDeltaRmu,lDeltaRtau);
490
491 if (debug_ > 1) std::cout << "Jet #" << ij << ": pT,eta,phi = " << (*iJet).pt() << " " << (*iJet).eta() << " " << (*iJet).phi() << std::endl;
492 JetHist_.FillHistograms(*iJet,lGenParticles);
493 if (ij == 0) {
494 JetHistLead_.FillHistograms(*iJet,lGenParticles);
495 //JetHistLeadGenMatched_.FillHistograms(*iJet,lGenParticles);
496 }
497 else if (ij == 1) {
498 JetHistNtoLead_.FillHistograms(*iJet,lGenParticles);
499 //JetHistNtoLeadGenMatched_.FillHistograms(*iJet,lGenParticles);
500 }
501 ij++;
502
503 }
504 }
505 }
506
507 }//if doJets_
508
509
510 // edm::Handle<std::vector<CompositePtrCandidateT1T2MEt<reco::Candidate, reco::Candidate> > > lPair;
511 // //edm::Handle<std::vector<CompositePtrCandidateT1T2MEt<reco::Candidate, reco::Candidate> > > lmmPair;
512
513 // if (doPairs_){
514 // try {
515 // aEvt.getByLabel(pairSrc_,lPair);
516 // if (!lPair.isValid()){
517 // edm::LogInfo("ERROR")<< "Error! Can't get pairs by label. ";
518 // }
519 // if (debug_) std::cout << "** Pairs = " << lPair->size() << " elements." << std::endl;
520 // } catch(cms::Exception& e) {
521 // std::cout << "AMM: Collection " << pairSrc_ << " not available! Exception : " << e.what() << ". " << std::endl;
522 // }
523 // if (lPair.isValid()){
524
525 // PairHist_.FillEventHistograms(lPair);
526 // PairHistLead_.FillEventHistograms(lPair);
527
528 // if (lPair->size() > 0) {
529 // bool isLead = true;
530 // for (std::vector<CompositePtrCandidateT1T2MEt<reco::Candidate, reco::Candidate> >::const_iterator iP = lPair->begin();
531 // iP != lPair->end();
532 // iP++)
533 // {
534 // PairHist_.FillHistograms(*iP);
535 // if (isLead) PairHistLead_.FillHistograms(*iP);
536 // isLead = false;
537 // }
538 // }
539 // }
540
541 // }//if doPairs_
542
543
544 edm::Handle<std::vector<pat::MET> > lMetCol;
545
546 if (doMETs_){
547 try {
548 aEvt.getByLabel(metSrc_,lMetCol);
549 if (!lMetCol.isValid()){
550 edm::LogInfo("ERROR")<< "Error! Can't get Met by label. ";
551 }
552 if (debug_) std::cout << "** Met = " << lMetCol->size() << " elements." << std::endl;
553 } catch(cms::Exception& e) {
554 std::cout << "AMM: Collection " << metSrc_ << " not available! Exception : " << e.what() << ". " << std::endl;
555 }
556 if (lMetCol.isValid()){
557
558 MetHist_.FillEventHistograms(lMetCol);
559 }
560
561 }//if doMETs_
562
563
564
565 // //triggers
566 // edm::Handle<edm::TriggerResults> lTrigCol;
567 // try {
568 // aEvt.getByLabel(triggerSrc_,lTrigCol);
569 // if (!lTrigCol.isValid()){
570 // edm::LogInfo("ERROR")<< "Error! Can't get triggers by label. ";
571 // }
572 // if (debug_) std::cout << "** triggers = " << lTrigCol->size() << std::endl;
573 // } catch(cms::Exception& e) {
574 // std::cout << "AMM: Collection " << triggerSrc_ << " not available! Exception : " << e.what() << ". " << std::endl;
575 // }
576 // if (lTrigCol.isValid()){
577 // edm::TriggerNames lNames;
578 // lNames.init(*lTrigCol);
579
580 // for (unsigned int j=0; j<hltPaths_.size(); j++) {
581 // bool valid=false;
582 // for (unsigned int i=0; i<lTrigCol->size(); i++){
583 // std::string trueName = lNames_.triggerNames().at(i);
584 // //if (debug_ && j==0) std::cout << " Trigger #" << i << ", name = " << trueName << std::endl;
585 // if (trueName.find(hltPaths_.at(j)) != trueName.npos){
586 // //HLTPathsByIndex_[j]=triggerNames_.triggerIndex(HLTPathsByName_[j]);
587 // if (debug_) std::cout << "Trigger: " << trueName << " is valid. Index = " << i << std::endl;
588 // //triggerCol->accept(HLTPathsByIndex_[j]);
589 // valid=true;
590 // break;
591 // }
592 // }
593 // if (!valid) {
594 // std::cout << "*WARNING* Trigger: " << hltPaths_.at(j) << " is invalid." << std::endl;
595 // }
596 // }
597
598 // }
599
600 firstEvent = false;
601
602 }//analyze
603
604
605 void HbbAnalyzer::dumpContent(const edm::Event& aEvt,
606 std::string aName,
607 std::string aProcess
608 )
609 {//dumpContent
610 //to dump the content of the event
611
612 typedef std::vector< edm::Provenance const*> Provenances;
613 Provenances lProvenances;
614 aEvt.getAllProvenance(lProvenances);
615
616 for(Provenances::iterator itProv = lProvenances.begin(), itProvEnd = lProvenances.end();
617 itProv != itProvEnd;
618 ++itProv) {
619
620 std::string lName = (*itProv)->friendlyClassName();
621 std::string lModLabel = (*itProv)->moduleLabel();
622 std::string lInstanceName = (*itProv)->productInstanceName();
623 std::string lProcessName = (*itProv)->processName();
624
625 //std::cout << " - friendlyName = " << lName << std::endl;
626 if (lName.find(aName) != lName.npos && lProcessName.find(aProcess) != lProcessName.npos) {
627
628 //if (debug_>1) {
629 std::cout << " -- Object type = " << lName << std::endl
630 << " ----- Module = " << lModLabel << std::endl
631 << " ----- Instance = " << lInstanceName << std::endl;
632 //<< " ----- Process = " << lProcessName << std::endl;
633 //}
634 }
635 }
636 }//dumpContent
637
638
639 #include "FWCore/Framework/interface/MakerMacros.h"
640 DEFINE_FWK_MODULE(HbbAnalyzer);
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655