ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/LJMet/Utils/src/PlotReco.cc
Revision: 1.2
Committed: Wed Dec 2 19:42:47 2009 UTC (15 years, 5 months ago) by kukartse
Content type: text/plain
Branch: MAIN
Changes since 1.1: +38 -10 lines
Log Message:
EJTerm CVS area added

File Contents

# Content
1 // -*- C++ -*-
2 //
3 // Package: PlotReco
4 // Class: PlotReco
5 //
6 /**\class PlotReco PlotReco.h LJMet/Utils/interface/PlotReco.h
7
8 Description: quick look at the RECO data
9
10 Implementation:
11 Keep this class as simple and fast as possible
12 */
13 //
14 // Original Author: "Gena Kukartsev"
15 // Created: Tue Nov 10 13:39:12 CDT 2009
16 // $Id: PlotReco.cc,v 1.1 2009/11/10 22:29:35 kukartse Exp $
17 //
18 //
19
20 #include "LJMet/Utils/interface/PlotReco.h"
21 #include "FWCore/Framework/interface/TriggerNames.h"
22 #include "DataFormats/Common/interface/TriggerResults.h"
23 #include "DataFormats/PatCandidates/interface/Jet.h"
24 #include "DataFormats/PatCandidates/interface/Electron.h"
25 #include "DataFormats/PatCandidates/interface/Muon.h"
26 #include "DataFormats/PatCandidates/interface/MET.h"
27 #include "DataFormats/PatCandidates/interface/TriggerPath.h"
28 #include "DataFormats/BeamSpot/interface/BeamSpot.h"
29 #include "DataFormats/EgammaCandidates/interface/GsfElectron.h"
30 #include "DataFormats/Math/interface/deltaR.h"
31 #include "FWCore/ServiceRegistry/interface/Service.h"
32 #include "PhysicsTools/UtilAlgos/interface/TFileService.h"
33
34 using namespace edm;
35
36 PlotReco::PlotReco(const edm::ParameterSet& iConfig){
37 std::cout << "=======>: PlotReco::PlotReco()" << std::endl;
38
39 //
40 //_____ init TFileService, needed for the output root file
41 //
42 edm::Service<TFileService> fs;
43 _tree = fs->make<TTree>("ttljets", "ttljets", 64000000);
44
45 irun = 0;
46 ievent = 0;
47 ilumi = 0;
48 njets = 0;
49 jet1_pt = -1.0;
50 jet1_eta = -1.0;
51 jet1_phi = -1.0;
52 }
53
54
55 PlotReco::~PlotReco()
56 {
57 std::cout << "=======>: PlotReco::~PlotReco()" << std::endl;
58 }
59
60
61 void
62 PlotReco::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup)
63 {
64 std::cout << "=======>: PlotReco::analyze()" << std::endl;
65 //
66 //_____ event book keeping
67 //
68 irun = (unsigned int)iEvent.id().run();
69 // this will work starting with CMSSW_340:
70 //unsigned int ilumi = (unsigned int)iEvent.id().luminosityBlock();
71 ilumi = (unsigned int)iEvent.getLuminosityBlock().luminosityBlock();
72 ievent = (unsigned int)iEvent.id().event();
73 cout << std::endl << "===> Provenance: " << std::endl;
74 cout << "Run, lumi, event: " << irun << ", " << ilumi << ", "<< ievent << std::endl;
75 //
76 //_____ check PAT jets _______________________________________________
77 //
78 std::cout << std::endl << "===> Check PAT jets: " << std::endl;
79 Handle< vector< reco::CaloJet > > jets;
80 iEvent . getByLabel( "kt4CaloJets", jets );
81 njets = jets->size();
82 cout << "jet collection size: "<< njets << endl;
83 if (njets>0){
84 jet1_pt = (*jets)[0].pt();
85 jet1_eta = (*jets)[0].eta();
86 jet1_phi = (*jets)[0].phi();
87 cout << "pT= " << jet1_pt << ", eta=" << jet1_eta << std::endl;
88 }
89 //
90 //_____ check trigger
91 //
92 cout << std::endl << "===> Check trigger: " << std::endl;
93 Handle<TriggerResults> hltresults;
94 iEvent.getByLabel("TriggerResults", hltresults);
95 int ntrigs=hltresults->size();
96 edm::TriggerNames triggerNames_;
97 triggerNames_.init(*hltresults);
98 for (int itrig = 0; itrig < ntrigs; ++itrig) {
99 cout << "Trigger name and number: " << triggerNames_.triggerName(itrig) << ", " << itrig;
100 cout << " passed: " << hltresults->accept(itrig) << endl;
101 }
102 //
103 //_____ check Beam spot _____________________________________________________
104 //
105 cout << std::endl << "===> Check Beam spot: " << std::endl;
106 Handle< reco::BeamSpot > beamSpotHandle;
107 iEvent . getByLabel( "offlineBeamSpot", beamSpotHandle);
108 reco::BeamSpot beamSpot;
109 if ( beamSpotHandle.isValid() ){
110 beamSpot = *beamSpotHandle;
111 cout << "beam spot present in the Event..." << std::endl;
112 }
113 else{
114 edm::LogInfo("TtLJetsAnalyzer")
115 << "No beam spot available in the event \n";
116 }
117 cout << beamSpot.x0() << " " << beamSpot.y0() << " " << beamSpot.z0() << std::endl;
118
119 //_____ fill the tree
120 _tree -> Fill();
121 }
122
123
124 void
125 PlotReco::beginJob()
126 {
127 std::cout << "=======>: PlotReco::beginJob()" << std::endl;
128
129 _tree -> Branch("event", &ievent, "event/I" );
130 _tree -> Branch("lumi", &ilumi, "lumi/I" );
131 _tree -> Branch("run", &irun, "run/I" );
132 _tree -> Branch("njets", &njets, "njets/I" );
133 _tree -> Branch("jet1_pt", &jet1_pt, "jet1_pt/D" );
134 _tree -> Branch("jet1_eta", &jet1_eta, "jet1_eta/D" );
135 _tree -> Branch("jet1_phi", &jet1_phi, "jet1_phi/D" );
136 }
137
138
139 void
140 PlotReco::endJob() {
141 std::cout << "=======>: PlotReco::endJob()" << std::endl;
142 }
143
144
145
146 //define this as a plug-in
147 DEFINE_FWK_MODULE(PlotReco);