ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/LJMet/Utils/src/CheckEventContent.cc
Revision: 1.3
Committed: Thu Nov 5 17:47:29 2009 UTC (15 years, 5 months ago) by kukartse
Content type: text/plain
Branch: MAIN
CVS Tags: gak110409
Changes since 1.2: +17 -338 lines
Log Message:
*** empty log message ***

File Contents

# User Rev Content
1 kukartse 1.1 // -*- C++ -*-
2     //
3     // Package: CheckEventContent
4     // Class: CheckEventContent
5     //
6     /**\class CheckEventContent CheckEventContent.h LJMet/Utils/interface/CheckEventContent.h
7    
8     Description: times various aspects of data processing
9    
10     Implementation:
11     Keep this class as simple and fast as possible
12     */
13     //
14     // Original Author: "Gennadiy Kukartsev"
15     // Created: Tue Oct 6 13:39:12 CDT 2009
16 kukartse 1.3 // $Id: CheckEventContent.cc,v 1.2 2009/11/04 14:12:22 kukartse Exp $
17 kukartse 1.1 //
18     //
19    
20     #include "LJMet/Utils/interface/CheckEventContent.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    
32     using namespace edm;
33    
34     CheckEventContent::CheckEventContent(const edm::ParameterSet& iConfig){
35 kukartse 1.2 std::cout << "=======>: CheckEventContent::CheckEventContent()" << std::endl;
36 kukartse 1.1 }
37    
38    
39     CheckEventContent::~CheckEventContent()
40     {
41 kukartse 1.2 std::cout << "=======>: CheckEventContent::~CheckEventContent()" << std::endl;
42 kukartse 1.1 }
43    
44    
45     void
46     CheckEventContent::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup)
47     {
48 kukartse 1.2 std::cout << "=======>: CheckEventContent::analyze()" << std::endl;
49     //
50     //_____ event book keeping
51     //
52     unsigned int irun = (unsigned int)iEvent.id().run();
53     // this will work starting with CMSSW_340:
54     //unsigned int ilumi = (unsigned int)iEvent.id().luminosityBlock();
55     unsigned int ilumi = (unsigned int)iEvent.getLuminosityBlock().luminosityBlock();
56     unsigned int ievent = (unsigned int)iEvent.id().event();
57     cout << std::endl << "===> Provenance: " << std::endl;
58     cout << "Run, lumi, event: " << irun << ", " << ilumi << ", "<< ievent << std::endl;
59 kukartse 1.1 //
60     //_____ check trigger
61     //
62     cout << std::endl << "===> Check trigger: " << std::endl;
63     Handle<std::vector<pat::TriggerPath> > trigs;
64     iEvent.getByLabel("patTrigger", trigs);
65     std::string triggerName = "HLT_Mu9";
66     for (std::vector<pat::TriggerPath>::const_iterator trig = trigs->begin();
67     trig!=trigs->end();
68     ++trig){
69     //cout << "Trigger name and number: " << trig->name() << ", " << trig->index() << std::endl;
70     if( trig->name().find(triggerName)!=std::string::npos ){
71     cout << "Trigger " << triggerName << " is found in the event..." << std::endl;
72     //trig->wasAccept();
73     }
74     }
75     //
76     //_____ check PAT muons _______________________________________________
77     //
78     cout << std::endl << "===> Check PAT muons: " << std::endl;
79     Handle< vector< pat::Muon > > muons;
80     iEvent . getByLabel( "selectedLayer1Muons", muons );
81 kukartse 1.2 int muon_coll_size = muons->size();
82     cout << "muon collection size: "<< muon_coll_size << endl;
83     if (muon_coll_size>0){
84     cout << "Global muon selector: " << (*muons)[0].isGlobalMuon() << std::endl;
85     double _pt = (*muons)[0].pt();
86     double _eta = (*muons)[0].eta();
87     double _d0 = (*muons)[0].dB(); // global track
88     double _chi2ndof = (*muons)[0].normChi2();
89     int _nhits = (*muons)[0].numberOfValidHits();
90     cout << "pT= " << _pt << ", eta=" << _eta << std::endl;
91     cout << "PAT d0= " << _d0 << ", PAT norm chi2=" << _chi2ndof << std::endl;
92     cout << "PAT n of hits on track= " << _nhits << std::endl;
93     //
94     //_____ check that there is a track
95     reco::TrackRef _track = (*muons)[0].track();
96     reco::TrackRef _innertrack = (*muons)[0].innerTrack();
97     if(_track.isNull()){
98     cout << "there is no pat::muon::track()" << endl;
99     }
100     else{
101     cout << "there is a pat::muon::track()" << endl;
102     }
103     if(_innertrack.isNull()){
104     cout << "there is no pat::muon::innerTrack()" << endl;
105     }
106     else{
107     cout << "there is a pat::muon::innerTrack()" << endl;
108     }
109     //
110     //_____ check isolation
111     if ( !((*muons)[0].isIsolationValid()) ) {
112     cout << "Isolation info is invalid" << endl;
113     }
114     else{
115     cout << "Isolation info is valid..." << endl;
116     double _emveto = (*muons)[0].isolationR03().emVetoEt;
117     double _hadveto = (*muons)[0].isolationR03().hadVetoEt;
118     double _trackiso = (*muons)[0].isolationR03().sumPt;
119     double _emcaloiso = (*muons)[0].isolationR03().emEt;
120     double _hadcaloiso = (*muons)[0].isolationR03().hadEt;
121     cout << "EM veto= " << _emveto << ", Had veto=" << _hadveto << std::endl;
122     cout << "Track iso= " << _trackiso << std::endl;
123     cout << "EM calo iso= " << _emcaloiso << ", Had calo iso=" << _hadcaloiso << std::endl;
124     }
125 kukartse 1.1 }
126     //
127     //_____ check Beam spot _____________________________________________________
128     //
129     cout << std::endl << "===> Check Beam spot: " << std::endl;
130     Handle< reco::BeamSpot > beamSpotHandle;
131     iEvent . getByLabel( "offlineBeamSpot", beamSpotHandle);
132     reco::BeamSpot beamSpot;
133     if ( beamSpotHandle.isValid() ){
134     beamSpot = *beamSpotHandle;
135     cout << "beam spot present in the Event..." << std::endl;
136     }
137     else{
138     edm::LogInfo("TtLJetsAnalyzer")
139     << "No beam spot available in the event \n";
140     }
141     cout << beamSpot.x0() << " " << beamSpot.y0() << " " << beamSpot.z0() << std::endl;
142 kukartse 1.2 //
143     //_____ check PAT electrons _______________________________________________
144     //
145     std::cout << std::endl << "===> Check PAT electrons: " << std::endl;
146     Handle< vector< pat::Electron > > electrons;
147     iEvent . getByLabel( "selectedLayer1Electrons", electrons );
148     int electron_coll_size = electrons->size();
149     cout << "electron collection size: "<< electron_coll_size << endl;
150     if (electron_coll_size>0){
151     cout << "Robust tight electron selector: " << (*electrons)[0].electronID("eidRobustTight") << std::endl;
152     double _pt = (*electrons)[0].pt();
153     double _eta = (*electrons)[0].eta();
154     double _d0 = (*electrons)[0].dB();
155     cout << "pT= " << _pt << ", eta=" << _eta << std::endl;
156     cout << "PAT d0= " << _d0 << std::endl;
157     //
158     //_____ check that there is a track
159     /*
160     reco::TrackRef _track = (*electrons)[0].track();
161     if(_track.isNull()){
162     cout << "there is no pat::electron::track()" << endl;
163     }
164     else{
165     cout << "there is a pat::electron::track()" << endl;
166     }
167     reco::GsfTrackRef _gsfTrack = (*electrons)[0].gsfTrack();
168     if(_gsfTrack.isNull()){
169     cout << "there is no pat::electron::gsfTrack()" << endl;
170     }
171     else{
172     cout << "there is a pat::electron::gsfTrack()" << endl;
173     }
174 kukartse 1.3 */
175     reco::GsfTrackRef _gsfTrack = (*electrons)[0].gsfTrack();
176 kukartse 1.2 //
177     //_____ check isolation
178     cout << "Isolation info is valid..." << endl;
179     double _trackiso = (*electrons)[0].trackIso();
180     double _emcaloiso = (*electrons)[0].ecalIso();
181     double _hadcaloiso = (*electrons)[0].hcalIso();
182     double _caloiso = (*electrons)[0].caloIso();
183     cout << "Track iso= " << _trackiso << std::endl;
184     cout << "EM calo iso= " << _emcaloiso << ", Had calo iso=" << _hadcaloiso << std::endl;
185     cout << "Calo iso= " << _caloiso << std::endl;
186     }
187     //
188     //_____ check PAT jets _______________________________________________
189     //
190     std::cout << std::endl << "===> Check PAT jets: " << std::endl;
191     Handle< vector< pat::Jet > > jets;
192     iEvent . getByLabel( "selectedLayer1Jets", jets );
193     int jet_coll_size = jets->size();
194     cout << "jet collection size: "<< jet_coll_size << endl;
195     if (jet_coll_size>0){
196     double _pt = (*jets)[0].pt();
197     double _eta = (*jets)[0].eta();
198     //float _bDiscriminator = (*jets)[0].bDiscriminator("");
199     const std::vector<std::pair<std::string, float> > & btag = (*jets)[0].getPairDiscri();
200     cout << "B-tagging discriminators: " << endl;
201     for (std::vector<std::pair<std::string, float> >::const_iterator _d = btag.begin();
202     _d != btag.end();
203     ++_d){
204     cout << _d->first << " = " << _d->second << endl;
205     }
206     cout << "pT= " << _pt << ", eta=" << _eta << std::endl;
207     }
208 kukartse 1.3 //
209     //_____ check PAT MET ________________________________________________
210     //
211     std::cout << std::endl << "===> Check PAT mets: " << std::endl;
212     Handle< vector< pat::MET > > mets;
213     iEvent . getByLabel( "layer1METs", mets );
214     int met_coll_size = mets->size();
215     cout << "met collection size: "<< met_coll_size << endl;
216     if (met_coll_size>0){
217     double _pt = (*mets)[0].pt();
218     double _eta = (*mets)[0].eta();
219     double _phi = (*mets)[0].phi();
220     cout << "pT= " << _pt << ", eta=" << _eta << ", phi=" << _phi << std::endl;
221     }
222 kukartse 1.1 }
223    
224    
225     void
226     CheckEventContent::beginJob()
227     {
228 kukartse 1.2 std::cout << "=======>: CheckEventContent::beginJob()" << std::endl;
229 kukartse 1.1 }
230    
231    
232     void
233     CheckEventContent::endJob() {
234 kukartse 1.2 std::cout << "=======>: CheckEventContent::endJob()" << std::endl;
235 kukartse 1.1 }
236    
237    
238    
239     //define this as a plug-in
240     DEFINE_FWK_MODULE(CheckEventContent);