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 |
// $Id: CheckEventContent.cc,v 1.3 2009/11/05 17:47:29 kukartse Exp $
|
17 |
//
|
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 |
std::cout << "=======>: CheckEventContent::CheckEventContent()" << std::endl;
|
36 |
}
|
37 |
|
38 |
|
39 |
CheckEventContent::~CheckEventContent()
|
40 |
{
|
41 |
std::cout << "=======>: CheckEventContent::~CheckEventContent()" << std::endl;
|
42 |
}
|
43 |
|
44 |
|
45 |
void
|
46 |
CheckEventContent::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup)
|
47 |
{
|
48 |
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 |
//
|
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 |
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 |
}
|
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 |
cout << "beamSpot.BeamWidth X,Y: " << beamSpot.BeamWidthX() << ", " << beamSpot.BeamWidthY() << std::endl;
|
143 |
//
|
144 |
//_____ check PAT electrons _______________________________________________
|
145 |
//
|
146 |
std::cout << std::endl << "===> Check PAT electrons: " << std::endl;
|
147 |
Handle< vector< pat::Electron > > electrons;
|
148 |
iEvent . getByLabel( "selectedLayer1Electrons", electrons );
|
149 |
int electron_coll_size = electrons->size();
|
150 |
cout << "electron collection size: "<< electron_coll_size << endl;
|
151 |
if (electron_coll_size>0){
|
152 |
cout << "Robust tight electron selector: " << (*electrons)[0].electronID("eidRobustTight") << std::endl;
|
153 |
/*
|
154 |
double _pt = (*electrons)[0].pt();
|
155 |
double _eta = (*electrons)[0].eta();
|
156 |
double _d0 = (*electrons)[0].dB();
|
157 |
cout << "pT= " << _pt << ", eta=" << _eta << std::endl;
|
158 |
cout << "PAT d0= " << _d0 << std::endl;
|
159 |
//
|
160 |
//_____ check that there is a track
|
161 |
reco::TrackRef _track = (*electrons)[0].track();
|
162 |
if(_track.isNull()){
|
163 |
cout << "there is no pat::electron::track()" << endl;
|
164 |
}
|
165 |
else{
|
166 |
cout << "there is a pat::electron::track()" << endl;
|
167 |
}
|
168 |
reco::GsfTrackRef _gsfTrack = (*electrons)[0].gsfTrack();
|
169 |
if(_gsfTrack.isNull()){
|
170 |
cout << "there is no pat::electron::gsfTrack()" << endl;
|
171 |
}
|
172 |
else{
|
173 |
cout << "there is a pat::electron::gsfTrack()" << endl;
|
174 |
}
|
175 |
*/
|
176 |
const pat::Electron & ele = (*electrons)[0];
|
177 |
//reco::GsfTrackRef _gsfTrack = ele.gsfTrack();
|
178 |
//
|
179 |
//_____ check isolation
|
180 |
cout << "Isolation info is valid..." << endl;
|
181 |
double _trackiso = (*electrons)[0].trackIso();
|
182 |
double _emcaloiso = (*electrons)[0].ecalIso();
|
183 |
double _hadcaloiso = (*electrons)[0].hcalIso();
|
184 |
double _caloiso = (*electrons)[0].caloIso();
|
185 |
cout << "Track iso= " << _trackiso << std::endl;
|
186 |
cout << "EM calo iso= " << _emcaloiso << ", Had calo iso=" << _hadcaloiso << std::endl;
|
187 |
cout << "Calo iso= " << _caloiso << std::endl;
|
188 |
}
|
189 |
//
|
190 |
//_____ check PAT jets _______________________________________________
|
191 |
//
|
192 |
std::cout << std::endl << "===> Check PAT jets: " << std::endl;
|
193 |
Handle< vector< pat::Jet > > jets;
|
194 |
iEvent . getByLabel( "selectedLayer1Jets", jets );
|
195 |
int jet_coll_size = jets->size();
|
196 |
cout << "jet collection size: "<< jet_coll_size << endl;
|
197 |
if (jet_coll_size>0){
|
198 |
double _pt = (*jets)[0].pt();
|
199 |
double _eta = (*jets)[0].eta();
|
200 |
//float _bDiscriminator = (*jets)[0].bDiscriminator("");
|
201 |
const std::vector<std::pair<std::string, float> > & btag = (*jets)[0].getPairDiscri();
|
202 |
cout << "B-tagging discriminators: " << endl;
|
203 |
for (std::vector<std::pair<std::string, float> >::const_iterator _d = btag.begin();
|
204 |
_d != btag.end();
|
205 |
++_d){
|
206 |
cout << _d->first << " = " << _d->second << endl;
|
207 |
}
|
208 |
cout << "pT= " << _pt << ", eta=" << _eta << std::endl;
|
209 |
}
|
210 |
//
|
211 |
//_____ check PAT MET ________________________________________________
|
212 |
//
|
213 |
std::cout << std::endl << "===> Check PAT mets: " << std::endl;
|
214 |
Handle< vector< pat::MET > > mets;
|
215 |
iEvent . getByLabel( "layer1METs", mets );
|
216 |
int met_coll_size = mets->size();
|
217 |
cout << "met collection size: "<< met_coll_size << endl;
|
218 |
if (met_coll_size>0){
|
219 |
double _pt = (*mets)[0].pt();
|
220 |
double _eta = (*mets)[0].eta();
|
221 |
double _phi = (*mets)[0].phi();
|
222 |
cout << "pT= " << _pt << ", eta=" << _eta << ", phi=" << _phi << std::endl;
|
223 |
}
|
224 |
}
|
225 |
|
226 |
|
227 |
void
|
228 |
CheckEventContent::beginJob()
|
229 |
{
|
230 |
std::cout << "=======>: CheckEventContent::beginJob()" << std::endl;
|
231 |
}
|
232 |
|
233 |
|
234 |
void
|
235 |
CheckEventContent::endJob() {
|
236 |
std::cout << "=======>: CheckEventContent::endJob()" << std::endl;
|
237 |
}
|
238 |
|
239 |
|
240 |
|
241 |
//define this as a plug-in
|
242 |
DEFINE_FWK_MODULE(CheckEventContent);
|