1 |
– |
/* |
2 |
– |
Description: <one line class summary> |
3 |
– |
|
4 |
– |
Implementation: |
5 |
– |
n-tuple creator for jet studies |
6 |
– |
*/ |
7 |
– |
// |
1 |
|
// Original Author: "Nathaniel Odell" |
2 |
|
// Secondary Author: Steven Won |
3 |
|
// With contributions from: Andrey Pozdnyakov |
4 |
|
// Created: Thurs April 22 2010 |
5 |
|
// $Id$ |
13 |
– |
// |
14 |
– |
// |
15 |
– |
|
6 |
|
|
7 |
|
// system include files |
8 |
|
#include <memory> |
15 |
|
#include "FWCore/Framework/interface/EventSetup.h" |
16 |
|
#include "FWCore/Framework/interface/Event.h" |
17 |
|
#include "FWCore/Framework/interface/MakerMacros.h" |
18 |
< |
|
18 |
> |
#include "FWCore/Framework/interface/LuminosityBlock.h" |
19 |
|
#include "FWCore/ParameterSet/interface/ParameterSet.h" |
20 |
|
|
31 |
– |
#include "DataFormats/GeometryVector/interface/GlobalPoint.h" |
21 |
|
#include "Geometry/Records/interface/CaloGeometryRecord.h" |
22 |
< |
|
22 |
> |
#include "DataFormats/GeometryVector/interface/GlobalPoint.h" |
23 |
> |
#include "DataFormats/GeometryVector/interface/GlobalVector.h" |
24 |
> |
#include "DataFormats/GeometryVector/interface/LocalPoint.h" |
25 |
> |
#include "DataFormats/GeometryVector/interface/LocalVector.h" |
26 |
> |
#include "DataFormats/Math/interface/Point3D.h" |
27 |
> |
#include "DataFormats/Math/interface/Vector3D.h" |
28 |
> |
#include "DataFormats/Math/interface/LorentzVector.h" |
29 |
> |
#include "DataFormats/Math/interface/deltaPhi.h" |
30 |
> |
|
31 |
> |
// Libraries for objects |
32 |
> |
#include "DataFormats/ParticleFlowCandidate/interface/PFCandidate.h" |
33 |
> |
#include "DataFormats/ParticleFlowCandidate/interface/PFCandidateFwd.h" |
34 |
> |
#include "DataFormats/HepMCCandidate/interface/GenParticle.h" |
35 |
|
#include "DataFormats/JetReco/interface/CaloJet.h" |
36 |
|
#include "DataFormats/JetReco/interface/CaloJetCollection.h" |
36 |
– |
#include "DataFormats/JetReco/interface/PFJet.h" |
37 |
– |
#include "DataFormats/JetReco/interface/PFJetCollection.h" |
37 |
|
#include "DataFormats/JetReco/interface/GenJet.h" |
38 |
|
#include "DataFormats/JetReco/interface/GenJetCollection.h" |
39 |
< |
#include "DataFormats/JetReco/interface/Jet.h" |
39 |
> |
#include "DataFormats/JetReco/interface/PFJet.h" |
40 |
> |
#include "DataFormats/JetReco/interface/PFJetCollection.h" |
41 |
> |
#include "DataFormats/METReco/interface/PFMET.h" |
42 |
> |
#include "DataFormats/METReco/interface/PFMETCollection.h" |
43 |
> |
#include "DataFormats/METReco/interface/PFMETFwd.h" |
44 |
> |
#include "DataFormats/METReco/interface/MET.h" |
45 |
> |
#include "DataFormats/METReco/interface/METCollection.h" |
46 |
> |
#include "DataFormats/METReco/interface/METFwd.h" |
47 |
> |
#include "DataFormats/MuonReco/interface/Muon.h" |
48 |
> |
#include "DataFormats/MuonReco/interface/MuonFwd.h" |
49 |
> |
#include "DataFormats/MuonReco/interface/MuonSelectors.h" |
50 |
> |
#include "DataFormats/EgammaCandidates/interface/GsfElectron.h" |
51 |
> |
#include "DataFormats/EgammaCandidates/interface/GsfElectronFwd.h" |
52 |
> |
#include "DataFormats/EgammaCandidates/interface/Photon.h" |
53 |
> |
#include "DataFormats/EgammaCandidates/interface/PhotonFwd.h" |
54 |
> |
#include "DataFormats/TrackReco/interface/Track.h" |
55 |
> |
#include "DataFormats/TrackReco/interface/TrackFwd.h" |
56 |
> |
#include "DataFormats/GsfTrackReco/interface/GsfTrack.h" |
57 |
|
#include "DataFormats/VertexReco/interface/Vertex.h" |
58 |
|
#include "DataFormats/VertexReco/interface/VertexFwd.h" |
59 |
+ |
#include "DataFormats/BTauReco/interface/JetTag.h" |
60 |
+ |
#include "DataFormats/BeamSpot/interface/BeamSpot.h" |
61 |
+ |
#include "DataFormats/Luminosity/interface/LumiSummary.h" |
62 |
+ |
#include "DataFormats/Common/interface/ValueMap.h" |
63 |
+ |
#include "SimDataFormats/GeneratorProducts/interface/HepMCProduct.h" |
64 |
+ |
#include "SimDataFormats/GeneratorProducts/interface/GenEventInfoProduct.h" |
65 |
+ |
#include "SimDataFormats/GeneratorProducts/interface/GenRunInfoProduct.h" |
66 |
+ |
#include "SimDataFormats/PileupSummaryInfo/interface/PileupSummaryInfo.h" |
67 |
+ |
|
68 |
+ |
//#include "RecoVertex/PrimaryVertexProducer/interface/VertexHigherPtSquared.h" |
69 |
+ |
|
70 |
+ |
// JEC |
71 |
+ |
#include "JetMETCorrections/Objects/interface/JetCorrector.h" |
72 |
+ |
#include "CondFormats/JetMETObjects/interface/JetCorrectionUncertainty.h" |
73 |
+ |
|
74 |
+ |
// ntuple storage classes |
75 |
+ |
#include "TCJet.h" |
76 |
+ |
#include "TCMET.h" |
77 |
+ |
#include "TCPrimaryVtx.h" |
78 |
+ |
#include "TCGenJet.h" |
79 |
+ |
#include "TCMuon.h" |
80 |
+ |
#include "TCElectron.h" |
81 |
|
|
82 |
|
// Need for HLT trigger info: |
83 |
|
#include "FWCore/Common/interface/TriggerNames.h" |
84 |
|
#include "DataFormats/Common/interface/TriggerResults.h" |
85 |
|
#include "HLTrigger/HLTcore/interface/HLTConfigProvider.h" |
48 |
– |
// |
86 |
|
|
87 |
+ |
//Root stuff |
88 |
|
#include "TROOT.h" |
89 |
+ |
#include "TH1.h" |
90 |
+ |
#include "TH2.h" |
91 |
+ |
#include "TProfile.h" |
92 |
|
#include "TFile.h" |
93 |
|
#include "TTree.h" |
94 |
|
#include "TString.h" |
99 |
|
#include "TLorentzVector.h" |
100 |
|
#include "TVector3.h" |
101 |
|
|
102 |
+ |
//MC stuff |
103 |
+ |
//#include "HepMC/GenEvent" |
104 |
+ |
|
105 |
|
using namespace edm; |
106 |
|
using namespace std; |
107 |
|
using namespace reco; |
111 |
|
// |
112 |
|
|
113 |
|
class MPIntuple : public edm::EDAnalyzer { |
114 |
< |
public: |
115 |
< |
explicit MPIntuple(const edm::ParameterSet&); |
116 |
< |
~MPIntuple(); |
117 |
< |
|
118 |
< |
|
119 |
< |
private: |
120 |
< |
virtual void beginJob() ; |
121 |
< |
virtual void analyze(const edm::Event&, const edm::EventSetup&); |
122 |
< |
virtual void endJob() ; |
123 |
< |
|
124 |
< |
bool triggerDecision(edm::Handle<edm::TriggerResults> &hltR, int iTrigger); |
125 |
< |
|
126 |
< |
// ----------member data --------------------------- |
127 |
< |
|
128 |
< |
edm::InputTag PFJetHandle_; |
129 |
< |
edm::InputTag CaloJetHandle_; |
130 |
< |
edm::InputTag PFJetHandle_corr; |
131 |
< |
edm::InputTag CaloJetHandle_corr; |
132 |
< |
edm::InputTag GenJetHandle_; |
133 |
< |
edm::InputTag PrimaryVtxHandle_; |
134 |
< |
|
135 |
< |
|
136 |
< |
// Counting variables // |
137 |
< |
|
138 |
< |
int eventNumber, runNumber, lumiSection; |
139 |
< |
|
140 |
< |
TTree *sTree; |
141 |
< |
TFile* ntupleFile; |
142 |
< |
|
143 |
< |
TClonesArray* jetP4_ak5PF; |
144 |
< |
TClonesArray* jetP4_ak5PF_corr; |
145 |
< |
TClonesArray* jetVtx3_ak5PF; |
146 |
< |
TClonesArray* jetVtx3_ak5PF_corr; |
147 |
< |
TClonesArray* jetP4_ak5Calo; |
148 |
< |
TClonesArray* jetP4_ak5Calo_corr; |
149 |
< |
TClonesArray* jetVtx3_ak5Calo; |
150 |
< |
TClonesArray* jetVtx3_ak5Calo_corr; |
151 |
< |
TClonesArray* jetP4_ak5Gen; |
152 |
< |
TClonesArray* jetVtx3_ak5Gen; |
153 |
< |
TClonesArray* PrimaryVtx3; |
154 |
< |
|
155 |
< |
bool doGenJets_; |
156 |
< |
bool doCaloJets_; |
157 |
< |
bool doPFJets_; |
158 |
< |
|
159 |
< |
string rootfilename; |
160 |
< |
|
161 |
< |
//Triggers |
162 |
< |
std::string hlTriggerResults_; |
163 |
< |
edm::TriggerNames triggerNames; |
164 |
< |
std::string hltName_; |
165 |
< |
std::string triggerName_; |
166 |
< |
HLTConfigProvider hltConfig_; |
167 |
< |
edm::InputTag triggerResultsTag_; |
168 |
< |
std::vector<std::string> hlNames; |
169 |
< |
|
170 |
< |
|
114 |
> |
public: |
115 |
> |
explicit MPIntuple(const edm::ParameterSet&); |
116 |
> |
~MPIntuple(); |
117 |
> |
|
118 |
> |
|
119 |
> |
private: |
120 |
> |
virtual void beginJob() ; |
121 |
> |
virtual void beginRun(const edm::Run&, const edm::EventSetup&) ; |
122 |
> |
virtual void analyze(const edm::Event&, const edm::EventSetup&); |
123 |
> |
virtual void endLuminosityBlock(const edm::LuminosityBlock&,const edm::EventSetup&); |
124 |
> |
virtual void endRun(const edm::Run&, const edm::Event&, const edm::EventSetup&); |
125 |
> |
virtual void endJob() ; |
126 |
> |
|
127 |
> |
bool genParticleMatch(const HepMC::GenParticle& genParticle, const reco::Candidate& motherParticle); |
128 |
> |
bool triggerDecision(edm::Handle<edm::TriggerResults>& hltR, int iTrigger); |
129 |
> |
float sumPtSquared(const Vertex& v); |
130 |
> |
|
131 |
> |
// ----------member data --------------------------- |
132 |
> |
|
133 |
> |
|
134 |
> |
int eventNumber, runNumber, lumiSection, bunchCross; |
135 |
> |
float ptHat, qScale, crossSection, evtWeight; |
136 |
> |
float lumiDeadCount, lumiLiveFrac, intDelLumi; |
137 |
> |
|
138 |
> |
TTree* sTree; |
139 |
> |
TFile* ntupleFile; |
140 |
> |
edm::InputTag recoJetTag_; |
141 |
> |
edm::InputTag recoMETTag_; |
142 |
> |
edm::InputTag genJetTag_; |
143 |
> |
edm::InputTag muonTag_; |
144 |
> |
edm::InputTag electronTag_; |
145 |
> |
edm::InputTag primaryVtxTag_; |
146 |
> |
edm::InputTag triggerResultsTag_; |
147 |
> |
edm::InputTag electronIDMap_; |
148 |
> |
bool doGenJets_; |
149 |
> |
bool doPFJets_; |
150 |
> |
bool triggerHLT_; |
151 |
> |
bool isRealData; |
152 |
> |
int nJets_; |
153 |
> |
string rootfilename; |
154 |
> |
|
155 |
> |
TClonesArray* recoJets; |
156 |
> |
TClonesArray* recoMET; |
157 |
> |
TClonesArray* genJets; |
158 |
> |
TClonesArray* primaryVtx; |
159 |
> |
TClonesArray* recoMuons; |
160 |
> |
TClonesArray* recoElectrons; |
161 |
> |
|
162 |
> |
//Triggers |
163 |
> |
string hlTriggerResults_, hltProcess_, triggerName_; |
164 |
> |
TriggerNames triggerNames; |
165 |
> |
HLTConfigProvider hltConfig_; |
166 |
> |
vector<string> hlNames; |
167 |
> |
vector<string> mpiTriggers_; |
168 |
> |
unsigned int triggerStatus; |
169 |
> |
unsigned int hltPrescale[32]; |
170 |
> |
|
171 |
> |
|
172 |
> |
//Histograms |
173 |
> |
TH1D * h1_ptHat; |
174 |
> |
TH1D * h1_fracAssociatedTracks; |
175 |
> |
TH1D * h1_meanJetTrackZ; |
176 |
> |
TH1D * h1_trackDxy; |
177 |
> |
TH1D * h1_jetVertexZ; |
178 |
> |
TH1D * h1_associatedSumPt; |
179 |
> |
TH1D * h1_associatedVertexIndex; |
180 |
> |
TH1D * h1_partonJetMatch; |
181 |
> |
TH2F * h2_nAssTracksVsJetPt; |
182 |
> |
TProfile * p1_nVtcs; |
183 |
|
}; |
184 |
|
|
185 |
< |
MPIntuple::MPIntuple(const edm::ParameterSet& iConfig): |
130 |
< |
|
131 |
< |
PFJetHandle_(iConfig.getUntrackedParameter<edm::InputTag>("PFJetTag")), |
132 |
< |
CaloJetHandle_(iConfig.getUntrackedParameter<edm::InputTag>("CaloJetTag")), |
133 |
< |
PFJetHandle_corr(iConfig.getUntrackedParameter<edm::InputTag>("PFJetTag_corr")), |
134 |
< |
CaloJetHandle_corr(iConfig.getUntrackedParameter<edm::InputTag>("CaloJetTag_corr")), |
135 |
< |
GenJetHandle_(iConfig.getUntrackedParameter<edm::InputTag>("GenJetTag")), |
136 |
< |
PrimaryVtxHandle_(iConfig.getUntrackedParameter<edm::InputTag>("PrimaryVtxTag")), |
137 |
< |
doGenJets_(iConfig.getUntrackedParameter<bool>("doGenJets")), |
138 |
< |
doCaloJets_(iConfig.getUntrackedParameter<bool>("doCaloJets")), |
139 |
< |
doPFJets_(iConfig.getUntrackedParameter<bool>("doPFJets")), |
140 |
< |
rootfilename(iConfig.getUntrackedParameter<string>("rootfilename")), |
141 |
< |
hlTriggerResults_(iConfig.getUntrackedParameter<string>("HLTriggerResults","TriggerResults")), |
142 |
< |
hltName_(iConfig.getUntrackedParameter<string>("hltName","HLT")) |
185 |
> |
MPIntuple::MPIntuple(const edm::ParameterSet& iConfig) |
186 |
|
{ |
187 |
< |
//edm::TriggerNames |
188 |
< |
// triggerNames(iConfig); |
189 |
< |
|
187 |
> |
recoJetTag_ = iConfig.getUntrackedParameter<edm::InputTag>("RecoJetTag"); |
188 |
> |
recoMETTag_ = iConfig.getUntrackedParameter<edm::InputTag>("RecoMETTag"); |
189 |
> |
muonTag_ = iConfig.getUntrackedParameter<edm::InputTag>("MuonTag"); |
190 |
> |
electronTag_ = iConfig.getUntrackedParameter<edm::InputTag>("ElectronTag"); |
191 |
> |
genJetTag_ = iConfig.getUntrackedParameter<edm::InputTag>("GenJetTag"); |
192 |
> |
primaryVtxTag_ = iConfig.getUntrackedParameter<edm::InputTag>("PrimaryVtxTag"); |
193 |
> |
electronIDMap_ = iConfig.getParameter<edm::InputTag>("electronIDMap"); |
194 |
> |
nJets_ = iConfig.getUntrackedParameter<int>("nJets"); |
195 |
> |
doGenJets_ = iConfig.getUntrackedParameter<bool>("doGenJets"); |
196 |
> |
doPFJets_ = iConfig.getUntrackedParameter<bool>("doPFJets"); |
197 |
> |
triggerHLT_ = iConfig.getUntrackedParameter<bool>("triggerHLT"); |
198 |
> |
hlTriggerResults_ = iConfig.getUntrackedParameter<string>("HLTriggerResults","TriggerResults"); |
199 |
> |
hltProcess_ = iConfig.getUntrackedParameter<string>("hltName"); |
200 |
> |
mpiTriggers_ = iConfig.getUntrackedParameter<vector<string> >("triggers"); |
201 |
> |
rootfilename = iConfig.getUntrackedParameter<string>("rootfilename"); |
202 |
|
} |
203 |
|
|
149 |
– |
|
204 |
|
MPIntuple::~MPIntuple() |
205 |
|
{ |
206 |
|
|
207 |
|
} |
208 |
|
|
155 |
– |
|
209 |
|
// |
210 |
|
// member functions |
211 |
|
// |
214 |
|
void MPIntuple::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) |
215 |
|
{ |
216 |
|
|
217 |
< |
eventNumber = iEvent.id().event(); |
218 |
< |
runNumber = iEvent.id().run(); |
219 |
< |
lumiSection = (unsigned int)iEvent.getLuminosityBlock().luminosityBlock(); |
220 |
< |
|
221 |
< |
int PFcount = 0; |
222 |
< |
int Calocount = 0; |
223 |
< |
int PFcount_corr = 0; |
224 |
< |
int Calocount_corr = 0; |
225 |
< |
int Gencount = 0; |
226 |
< |
int Vtxcount = 0; |
227 |
< |
|
228 |
< |
if(doPFJets_){ |
229 |
< |
|
230 |
< |
Handle<reco::PFJetCollection> PFJets; |
231 |
< |
iEvent.getByLabel(PFJetHandle_, PFJets); |
232 |
< |
|
233 |
< |
PFcount = 0; |
234 |
< |
|
235 |
< |
for(PFJetCollection::const_iterator jet_iter = PFJets->begin(); jet_iter!= PFJets->end(); ++jet_iter){ |
236 |
< |
|
237 |
< |
reco::PFJet myJet = reco::PFJet(*jet_iter); |
238 |
< |
|
239 |
< |
if(myJet.et() > 5){ |
240 |
< |
|
241 |
< |
new ((*jetP4_ak5PF)[PFcount]) TLorentzVector(myJet.px(), myJet.py(), myJet.pz(), myJet.energy()); |
242 |
< |
new ((*jetVtx3_ak5PF)[PFcount]) TVector3(myJet.vx(), myJet.vy(), myJet.vz()); |
243 |
< |
|
244 |
< |
++PFcount; |
245 |
< |
} |
246 |
< |
|
247 |
< |
} |
248 |
< |
|
249 |
< |
|
250 |
< |
PFcount_corr = 0; |
251 |
< |
|
252 |
< |
Handle<reco::PFJetCollection> PFJets_corr; |
253 |
< |
iEvent.getByLabel(PFJetHandle_corr, PFJets_corr); |
254 |
< |
|
255 |
< |
for(PFJetCollection::const_iterator jet_iter = PFJets_corr->begin(); jet_iter!= PFJets_corr->end(); ++jet_iter){ |
256 |
< |
|
257 |
< |
reco::PFJet myJet = reco::PFJet(*jet_iter); |
258 |
< |
|
259 |
< |
if(myJet.et() > 5){ |
260 |
< |
|
261 |
< |
new ((*jetP4_ak5PF_corr)[PFcount_corr]) TLorentzVector(myJet.px(), myJet.py(), myJet.pz(), myJet.energy()); |
262 |
< |
new ((*jetVtx3_ak5PF_corr)[PFcount_corr]) TVector3(myJet.vx(), myJet.vy(), myJet.vz()); |
263 |
< |
|
264 |
< |
++PFcount_corr; |
265 |
< |
} |
266 |
< |
} |
267 |
< |
} |
268 |
< |
|
269 |
< |
if(doCaloJets_){ |
270 |
< |
|
271 |
< |
Calocount = 0; |
272 |
< |
|
273 |
< |
Handle<reco::CaloJetCollection> CaloJets; |
274 |
< |
iEvent.getByLabel(CaloJetHandle_, CaloJets); |
275 |
< |
|
276 |
< |
for(CaloJetCollection::const_iterator jet_iter = CaloJets->begin(); jet_iter!= CaloJets->end(); ++jet_iter){ |
277 |
< |
|
278 |
< |
reco::CaloJet myJet = reco::CaloJet(*jet_iter); |
279 |
< |
|
280 |
< |
if(myJet.et() > 5){ |
281 |
< |
|
282 |
< |
new ((*jetP4_ak5Calo)[Calocount]) TLorentzVector(myJet.px(), myJet.py(), myJet.pz(), myJet.energy()); |
283 |
< |
new ((*jetVtx3_ak5Calo)[Calocount]) TVector3(myJet.vx(), myJet.vy(), myJet.vz()); |
284 |
< |
|
285 |
< |
++Calocount; |
286 |
< |
|
287 |
< |
} |
288 |
< |
} |
289 |
< |
|
290 |
< |
Handle<reco::CaloJetCollection> CaloJets_corr; |
291 |
< |
iEvent.getByLabel(CaloJetHandle_corr, CaloJets_corr); |
292 |
< |
|
293 |
< |
Calocount_corr = 0; |
294 |
< |
|
295 |
< |
for(CaloJetCollection::const_iterator jet_iter = CaloJets_corr->begin(); jet_iter!= CaloJets_corr->end(); ++jet_iter){ |
296 |
< |
|
297 |
< |
reco::CaloJet myJet = reco::CaloJet(*jet_iter); |
298 |
< |
|
299 |
< |
if(myJet.et() > 5){ |
300 |
< |
|
301 |
< |
new ((*jetP4_ak5Calo_corr)[Calocount_corr]) TLorentzVector(myJet.px(), myJet.py(), myJet.pz(), myJet.energy()); |
302 |
< |
new ((*jetVtx3_ak5Calo_corr)[Calocount_corr]) TVector3(myJet.vx(), myJet.vy(), myJet.vz()); |
303 |
< |
|
304 |
< |
++Calocount_corr; |
305 |
< |
} |
306 |
< |
} |
307 |
< |
} |
308 |
< |
|
309 |
< |
if(doGenJets_){ |
310 |
< |
|
311 |
< |
Handle<reco::GenJetCollection> GenJets; |
312 |
< |
iEvent.getByLabel(GenJetHandle_, GenJets); |
313 |
< |
|
314 |
< |
|
315 |
< |
for(GenJetCollection::const_iterator jet_iter = GenJets->begin(); jet_iter!= GenJets->end(); ++jet_iter){ |
316 |
< |
|
317 |
< |
reco::GenJet myJet = reco::GenJet(*jet_iter); |
318 |
< |
|
319 |
< |
if(myJet.et() > 5){ |
320 |
< |
|
321 |
< |
new ((*jetP4_ak5Gen)[Gencount]) TLorentzVector(myJet.px(), myJet.py(), myJet.pz(), myJet.energy()); |
322 |
< |
new ((*jetVtx3_ak5Gen)[Gencount]) TVector3(myJet.vx(), myJet.vy(), myJet.vz()); |
323 |
< |
|
324 |
< |
++Gencount; |
325 |
< |
|
326 |
< |
} |
327 |
< |
} |
328 |
< |
} |
329 |
< |
|
330 |
< |
|
331 |
< |
Handle<reco::VertexCollection> primaryVtx; |
332 |
< |
iEvent.getByLabel(PrimaryVtxHandle_, primaryVtx); |
333 |
< |
|
334 |
< |
for(VertexCollection::const_iterator vtx_iter = primaryVtx->begin(); vtx_iter!= primaryVtx->end(); ++vtx_iter){ |
335 |
< |
|
336 |
< |
reco::Vertex myVtx = reco::Vertex(*vtx_iter); |
337 |
< |
|
338 |
< |
new ((*PrimaryVtx3)[Vtxcount]) TVector3(myVtx.x(), myVtx.y(), myVtx.z()); |
339 |
< |
|
340 |
< |
++Vtxcount; |
341 |
< |
|
217 |
> |
eventNumber = iEvent.id().event(); |
218 |
> |
runNumber = iEvent.id().run(); |
219 |
> |
lumiSection = (unsigned int)iEvent.getLuminosityBlock().luminosityBlock(); |
220 |
> |
bunchCross = (unsigned int)iEvent.bunchCrossing(); |
221 |
> |
isRealData = iEvent.isRealData(); |
222 |
> |
|
223 |
> |
edm::Handle<reco::BeamSpot> beamSpotHandle; |
224 |
> |
iEvent.getByLabel("offlineBeamSpot", beamSpotHandle); |
225 |
> |
reco::BeamSpot vertexBeamSpot = *beamSpotHandle; |
226 |
> |
|
227 |
> |
int pfCount = 0; |
228 |
> |
int genCount = 0; |
229 |
> |
int vtxCount = 0; |
230 |
> |
float primaryVertexZ = -999; |
231 |
> |
|
232 |
> |
////////////////////////// |
233 |
> |
//Get vertex information// |
234 |
> |
////////////////////////// |
235 |
> |
|
236 |
> |
Handle<reco::VertexCollection> primaryVtcs; |
237 |
> |
iEvent.getByLabel(primaryVtxTag_, primaryVtcs); |
238 |
> |
|
239 |
> |
for(VertexCollection::const_iterator vtx_iter = primaryVtcs->begin(); vtx_iter!= primaryVtcs->end(); ++vtx_iter){ |
240 |
> |
reco::Vertex myVtx = reco::Vertex(*vtx_iter); |
241 |
> |
if(!myVtx.isValid() || myVtx.isFake()) continue; |
242 |
> |
TCPrimaryVtx* vtxCon = new ((*primaryVtx)[vtxCount]) TCPrimaryVtx; |
243 |
> |
vtxCon->SetPosition(myVtx.x(), myVtx.y(), myVtx.z()); |
244 |
> |
vtxCon->SetNDof(myVtx.ndof()); |
245 |
> |
vtxCon->SetChi2(myVtx.chi2()); |
246 |
> |
vtxCon->SetNTrks(myVtx.tracksSize()); |
247 |
> |
vtxCon->SetSumPt2Trks(sumPtSquared(myVtx)); |
248 |
> |
if(vtxCount == 0) primaryVertexZ = myVtx.z(); |
249 |
> |
++vtxCount; |
250 |
> |
} |
251 |
> |
|
252 |
> |
p1_nVtcs->Fill(runNumber, vtxCount); |
253 |
> |
|
254 |
> |
/////////////////////// |
255 |
> |
//get jet information// |
256 |
> |
/////////////////////// |
257 |
> |
|
258 |
> |
if(doPFJets_){ |
259 |
> |
|
260 |
> |
edm::Handle<reco::JetTagCollection> bTagHandle1; |
261 |
> |
iEvent.getByLabel("trackCountingHighEffBJetTags", bTagHandle1); |
262 |
> |
const reco::JetTagCollection & bTags1 = *(bTagHandle1.product()); |
263 |
> |
reco::JetTagCollection::const_iterator jet_it_1; |
264 |
> |
|
265 |
> |
edm::Handle<reco::JetTagCollection> bTagHandle2; |
266 |
> |
iEvent.getByLabel("trackCountingHighPurBJetTags", bTagHandle2); |
267 |
> |
const reco::JetTagCollection & bTags2 = *(bTagHandle2.product()); |
268 |
> |
reco::JetTagCollection::const_iterator jet_it_2; |
269 |
> |
|
270 |
> |
edm::FileInPath fip("CondFormats/JetMETObjects/data/Spring10_Uncertainty_AK5PF.txt"); |
271 |
> |
//JetCorrectionUncertainty *jecUnc = new JetCorrectionUncertainty(fip.fullPath()); |
272 |
> |
|
273 |
> |
const JetCorrector* correctorL2 = JetCorrector::getJetCorrector("ak5PFL2Relative",iSetup); |
274 |
> |
const JetCorrector* correctorL3 = JetCorrector::getJetCorrector("ak5PFL3Absolute",iSetup); |
275 |
> |
const JetCorrector* correctorRes = JetCorrector::getJetCorrector("ak5PFResidual", iSetup); |
276 |
> |
|
277 |
> |
Handle<reco::PFJetCollection> PFJets; |
278 |
> |
iEvent.getByLabel(recoJetTag_, PFJets); |
279 |
> |
|
280 |
> |
for (PFJetCollection::const_iterator jet_iter = PFJets->begin(); jet_iter!= PFJets->end(); ++jet_iter) { |
281 |
> |
|
282 |
> |
reco::PFJet myJet = reco::PFJet(*jet_iter); |
283 |
> |
reco::PFJet corJet = reco::PFJet(*jet_iter); |
284 |
> |
|
285 |
> |
float scale2 = correctorL2->correction(corJet); |
286 |
> |
corJet.scaleEnergy(scale2); |
287 |
> |
float scale3 = correctorL3->correction(corJet); |
288 |
> |
corJet.scaleEnergy(scale3); |
289 |
> |
|
290 |
> |
if (corJet.pt() > 5) { |
291 |
> |
|
292 |
> |
for (jet_it_1 = bTags1.begin(); jet_it_1 != bTags1.end(); jet_it_1++) { |
293 |
> |
if ((fabs(jet_it_1->first->eta() - myJet.eta()) < .005) && (deltaPhi(jet_it_1->first->phi(),myJet.phi()) < .005)) break; |
294 |
> |
} |
295 |
> |
|
296 |
> |
for (jet_it_2 = bTags2.begin(); jet_it_2 != bTags2.end(); jet_it_2++) { |
297 |
> |
if ((fabs(jet_it_2->first->eta() - myJet.eta()) < .005) && (deltaPhi(jet_it_2->first->phi(),myJet.phi()) < .005)) break; |
298 |
> |
} |
299 |
> |
|
300 |
> |
TCJet* jetCon = new ((*recoJets)[pfCount]) TCJet; |
301 |
> |
|
302 |
> |
jetCon->SetP4(myJet.px(), myJet.py(), myJet.pz(), myJet.energy()); |
303 |
> |
jetCon->SetVtx(-999.0, -999.0, -999.0); |
304 |
> |
jetCon->SetChHadFrac(myJet.chargedHadronEnergyFraction()); |
305 |
> |
jetCon->SetNeuHadFrac(myJet.neutralHadronEnergyFraction()); |
306 |
> |
jetCon->SetChEmFrac(myJet.chargedEmEnergyFraction()); |
307 |
> |
jetCon->SetNeuEmFrac(myJet.neutralEmEnergyFraction()); |
308 |
> |
jetCon->SetNumConstit(myJet.chargedMultiplicity() + myJet.neutralMultiplicity()); |
309 |
> |
jetCon->SetNumChPart(myJet.chargedMultiplicity()); |
310 |
> |
|
311 |
> |
if(jet_it_2 != bTags2.end()) jetCon->SetBDiscrTrkCountHiPure(jet_it_2->second); |
312 |
> |
if(jet_it_1 != bTags1.end()) jetCon->SetBDiscrTrkCountHiEff(jet_it_1->second); |
313 |
> |
|
314 |
> |
//more corrections? |
315 |
> |
|
316 |
> |
jetCon->SetJetCorr(2, scale2); |
317 |
> |
jetCon->SetJetCorr(3, scale3); |
318 |
> |
|
319 |
> |
if (isRealData) { |
320 |
> |
float scaleRes = correctorRes->correction(corJet); |
321 |
> |
jetCon->SetJetCorr(4, scaleRes); |
322 |
> |
|
323 |
> |
//jecUnc->setJetEta(corJet.eta()); |
324 |
> |
//jecUnc->setJetPt(corJet.pt()); |
325 |
> |
//jetCon->SetUncertaintyJES(jecUnc->getUncertainty(true)); |
326 |
> |
} |
327 |
> |
|
328 |
> |
///////////////////////// |
329 |
> |
//get associated tracks// |
330 |
> |
///////////////////////// |
331 |
> |
|
332 |
> |
const reco::TrackRefVector &tracks = myJet.getTrackRefs(); |
333 |
> |
|
334 |
> |
vector<TVector3> vtxPositionCollection; |
335 |
> |
vector<float> associatedTrackSumPt; |
336 |
> |
vector<unsigned int> jetTrackAddresses; |
337 |
> |
float sumTrackX, sumTrackY, sumTrackZ, sumTrackIP, sumTrackPt; |
338 |
> |
int nJetTracks, nVertexTracks, nAssociatedTracks, vertexIndex; |
339 |
> |
int vCount = 0; |
340 |
> |
|
341 |
> |
nJetTracks = nVertexTracks = nAssociatedTracks = 0; |
342 |
> |
sumTrackX = sumTrackY = sumTrackZ = sumTrackIP = sumTrackPt = 0; |
343 |
> |
|
344 |
> |
if(fabs(myJet.eta()) < 2.5){ |
345 |
> |
|
346 |
> |
for (TrackRefVector::const_iterator iTrack = tracks.begin(); iTrack != tracks.end(); ++iTrack) { |
347 |
> |
const reco::Track &myJetTrack = **iTrack; |
348 |
> |
|
349 |
> |
sumTrackPt += myJetTrack.pt(); |
350 |
> |
sumTrackX += myJetTrack.vx(); |
351 |
> |
sumTrackY += myJetTrack.vy(); |
352 |
> |
sumTrackZ += myJetTrack.vz(); |
353 |
> |
sumTrackIP += myJetTrack.dxy(vertexBeamSpot.position()); |
354 |
> |
jetTrackAddresses.push_back((unsigned int)&myJetTrack); |
355 |
> |
++nJetTracks; |
356 |
> |
} |
357 |
> |
|
358 |
> |
if (nJetTracks > 0) { |
359 |
> |
jetCon->SetVtx(sumTrackX/nJetTracks, sumTrackY/nJetTracks, sumTrackZ/nJetTracks); |
360 |
> |
h1_meanJetTrackZ->Fill(sumTrackZ/nJetTracks); |
361 |
> |
h1_trackDxy->Fill(sumTrackIP/nJetTracks); |
362 |
> |
} |
363 |
> |
if(jetTrackAddresses.size() > 0){ |
364 |
> |
|
365 |
> |
for (VertexCollection::const_iterator vtx_iter = primaryVtcs->begin(); vtx_iter!= primaryVtcs->end(); ++vtx_iter) { |
366 |
> |
reco::Vertex myVtx = reco::Vertex(*vtx_iter); |
367 |
> |
if(!myVtx.isValid() || myVtx.isFake()) continue; |
368 |
> |
TVector3 *iVtxPosition = new TVector3(myVtx.x(), myVtx.y(), myVtx.z()); |
369 |
> |
vtxPositionCollection.push_back(*iVtxPosition); |
370 |
> |
associatedTrackSumPt.push_back(0); |
371 |
> |
|
372 |
> |
for(Vertex::trackRef_iterator iTrackRef = myVtx.tracks_begin(); iTrackRef != myVtx.tracks_end(); ++iTrackRef){ |
373 |
> |
const edm::RefToBase<reco::Track> &myTrackRef = *iTrackRef; |
374 |
> |
if(myTrackRef.isAvailable()){ |
375 |
> |
const reco::Track &myVertexTrack = *myTrackRef.get(); |
376 |
> |
|
377 |
> |
for(vector<unsigned int>::const_iterator iTrackAddress = jetTrackAddresses.begin(); iTrackAddress != jetTrackAddresses.end(); ++iTrackAddress){ |
378 |
> |
if (*iTrackAddress == (unsigned int)&myVertexTrack) { |
379 |
> |
associatedTrackSumPt.at(vCount) += myVertexTrack.pt()/sumTrackPt; |
380 |
> |
++nAssociatedTracks; |
381 |
> |
} |
382 |
> |
} |
383 |
> |
} |
384 |
> |
} |
385 |
> |
++vCount; |
386 |
> |
} |
387 |
> |
|
388 |
> |
float maxSumPtFraction = 0; |
389 |
> |
vCount = vertexIndex = 0; |
390 |
> |
|
391 |
> |
for (vector<float>::const_iterator iTrackSumPt = associatedTrackSumPt.begin(); iTrackSumPt != associatedTrackSumPt.end(); ++iTrackSumPt) { |
392 |
> |
if (*iTrackSumPt > maxSumPtFraction) { |
393 |
> |
maxSumPtFraction = *iTrackSumPt; |
394 |
> |
vertexIndex = vCount + 1; |
395 |
> |
} |
396 |
> |
++vCount; |
397 |
> |
} |
398 |
> |
if (vertexIndex > 0) { |
399 |
> |
h1_jetVertexZ->Fill(vtxPositionCollection[vertexIndex-1].z()); |
400 |
> |
} |
401 |
> |
|
402 |
> |
jetCon->SetVtxSumPtFrac(maxSumPtFraction); |
403 |
> |
jetCon->SetVtxSumPt(sumTrackPt); |
404 |
> |
jetCon->SetVtxTrackFrac((float)nAssociatedTracks/(float)nJetTracks); |
405 |
> |
jetCon->SetVtxNTracks(nJetTracks); |
406 |
> |
jetCon->SetVtxIndex(vertexIndex); |
407 |
> |
} |
408 |
> |
} |
409 |
> |
++pfCount; |
410 |
> |
} |
411 |
> |
} |
412 |
> |
} |
413 |
> |
|
414 |
> |
|
415 |
> |
////////////////// |
416 |
> |
// Get MET info // |
417 |
> |
////////////////// |
418 |
> |
|
419 |
> |
|
420 |
> |
Handle<PFMETCollection> MET; |
421 |
> |
iEvent.getByLabel(recoMETTag_, MET); |
422 |
> |
|
423 |
> |
int metCount = 0; |
424 |
> |
for (PFMETCollection::const_iterator iMET = MET->begin(); iMET != MET->end(); ++iMET) { |
425 |
> |
TCMET* metCon = new ((*recoMET)[metCount]) TCMET; |
426 |
> |
metCon->SetSumEt(iMET->sumEt()); |
427 |
> |
metCon->SetMet(iMET->et()); |
428 |
> |
metCon->SetPhi(iMET->phi()); |
429 |
> |
metCon->SetPhotonEtFraction(iMET->photonEtFraction()); |
430 |
> |
metCon->SetElectronEtFraction(iMET->electronEtFraction()); |
431 |
> |
metCon->SetMuonEtFraction(iMET->muonEtFraction()); |
432 |
> |
metCon->SetNeutralHadronEtFraction(iMET->neutralHadronEtFraction()); |
433 |
> |
metCon->SetChargedHadronEtFraction(iMET->chargedHadronEtFraction()); |
434 |
> |
metCon->SetHFHadronEtFraction(iMET->HFHadronEtFraction()); |
435 |
> |
metCon->SetHFEMEtFraction(iMET->HFEMEtFraction()); |
436 |
> |
} |
437 |
> |
|
438 |
> |
/////////////////// |
439 |
> |
// Get muon info // |
440 |
> |
/////////////////// |
441 |
> |
|
442 |
> |
|
443 |
> |
Handle<MuonCollection> muons; |
444 |
> |
iEvent.getByLabel(muonTag_, muons); |
445 |
> |
|
446 |
> |
int muCount = 0; |
447 |
> |
for (MuonCollection::const_iterator mu = muons->begin(); mu != muons->end(); ++mu) { |
448 |
> |
if (mu->isGlobalMuon() && mu->pt() > 8){ |
449 |
> |
TCMuon* lepCon = new ((*recoMuons)[muCount]) TCMuon; |
450 |
> |
lepCon->Setp4(mu->px(), mu->py(), mu->pz(), mu->p()); |
451 |
> |
lepCon->SetVtx(mu->globalTrack()->vx(),mu->globalTrack()->vy(),mu->globalTrack()->vz()); |
452 |
> |
lepCon->SetEta(mu->eta()); |
453 |
> |
lepCon->SetPhi(mu->phi()); |
454 |
> |
lepCon->SetCharge(mu->charge()); |
455 |
> |
lepCon->SetisGLB(mu->isGlobalMuon()); |
456 |
> |
lepCon->SetisTRK(mu->isTrackerMuon()); |
457 |
> |
lepCon->Setdxy(mu->globalTrack()->dxy(vertexBeamSpot.position())); |
458 |
> |
lepCon->SetnPXLHits(mu->globalTrack()->hitPattern().numberOfValidPixelHits()); |
459 |
> |
lepCon->SetnTRKHits(mu->globalTrack()->hitPattern().numberOfValidTrackerHits()); |
460 |
> |
lepCon->SetnValidMuHits(mu->globalTrack()->hitPattern().numberOfValidMuonHits()); |
461 |
> |
lepCon->SetnMatchSeg(mu->numberOfMatches()); |
462 |
> |
lepCon->SetNormChi2(mu->globalTrack()->normalizedChi2()); |
463 |
> |
lepCon->SetCaloComp(mu->caloCompatibility()); |
464 |
> |
lepCon->SetSegComp(muon::segmentCompatibility(*mu)); |
465 |
> |
lepCon->SetEMIso(mu->isolationR03().emEt); |
466 |
> |
lepCon->SetHADIso(mu->isolationR03().hadEt); |
467 |
> |
lepCon->SetTRKIso(mu->isolationR03().sumPt); |
468 |
> |
muCount++; |
469 |
> |
} |
470 |
> |
} |
471 |
> |
|
472 |
> |
|
473 |
> |
/////////////////////// |
474 |
> |
// Get electron info // |
475 |
> |
/////////////////////// |
476 |
> |
|
477 |
> |
|
478 |
> |
Handle<edm::ValueMap<float> > eIDValueMap; |
479 |
> |
iEvent.getByLabel( electronIDMap_ , eIDValueMap ); |
480 |
> |
const edm::ValueMap<float> & eIDmap = * eIDValueMap ; |
481 |
> |
|
482 |
> |
Handle<GsfElectronCollection> electrons; |
483 |
> |
iEvent.getByLabel(electronTag_, electrons); |
484 |
> |
|
485 |
> |
int elCount = 0; |
486 |
> |
for (unsigned int i = 0; i < electrons->size(); i++){ |
487 |
> |
edm::Ref<reco::GsfElectronCollection> electronRef(electrons,i); |
488 |
> |
if ( eIDmap[electronRef] == 7 && electronRef->pt() > 15){ |
489 |
> |
TCElectron* lepCon = new ((*recoElectrons)[elCount]) TCElectron; |
490 |
> |
lepCon->Setp4(electronRef->px(),electronRef->py(),electronRef->pz(),electronRef->p()); |
491 |
> |
lepCon->SetVtx(electronRef->gsfTrack()->vx(),electronRef->gsfTrack()->vy(),electronRef->gsfTrack()->vz()); |
492 |
> |
lepCon->SetCharge(electronRef->charge()); |
493 |
> |
lepCon->SetEta(electronRef->eta()); |
494 |
> |
lepCon->SetPhi(electronRef->phi()); |
495 |
> |
lepCon->Setdxy(electronRef->gsfTrack()->dxy(vertexBeamSpot.position())); |
496 |
> |
lepCon->SetNormChi2(electronRef->gsfTrack()->normalizedChi2()); |
497 |
> |
lepCon->SetEMIso(electronRef->dr03EcalRecHitSumEt()); |
498 |
> |
lepCon->SetHADIso(electronRef->dr03HcalTowerSumEt()); |
499 |
> |
lepCon->SetTRKIso(electronRef->dr03TkSumPt()); |
500 |
> |
elCount++; |
501 |
> |
} |
502 |
> |
} |
503 |
> |
|
504 |
> |
|
505 |
> |
//////////////////////// |
506 |
> |
// Get gen-level info // |
507 |
> |
//////////////////////// |
508 |
> |
|
509 |
> |
|
510 |
> |
if (!isRealData) { |
511 |
> |
|
512 |
> |
Handle<HepMCProduct > genEvtHandle; |
513 |
> |
iEvent.getByLabel( "generator", genEvtHandle) ; |
514 |
> |
const HepMC::GenEvent* Evt = genEvtHandle->GetEvent(); |
515 |
> |
|
516 |
> |
Handle<GenEventInfoProduct> GenEventInfoHandle; |
517 |
> |
iEvent.getByLabel("generator", GenEventInfoHandle); |
518 |
> |
|
519 |
> |
Handle<reco::GenJetCollection> GenJets; |
520 |
> |
iEvent.getByLabel(genJetTag_, GenJets); |
521 |
> |
|
522 |
> |
ptHat = qScale = -1; crossSection = 0; |
523 |
> |
|
524 |
> |
if (GenEventInfoHandle.isValid()) { |
525 |
> |
qScale = GenEventInfoHandle->qScale(); |
526 |
> |
ptHat = (GenEventInfoHandle->hasBinningValues() ? GenEventInfoHandle->binningValues()[0] : 0.0); |
527 |
> |
evtWeight = GenEventInfoHandle->weight(); |
528 |
> |
|
529 |
> |
h1_ptHat->Fill(ptHat); |
530 |
> |
} |
531 |
> |
struct genParticles { |
532 |
> |
HepMC::GenParticle* genParticleCore; |
533 |
> |
vector<HepMC::GenParticle*> genParticlesEnd; |
534 |
> |
} genForMatching[4]; |
535 |
> |
int hardCount = 0; |
536 |
> |
|
537 |
> |
//cout<<"Event: "<<Evt->signal_process_id()<<endl; |
538 |
> |
|
539 |
> |
for (HepMC::GenEvent::particle_const_iterator iGenParticle = Evt->particles_begin(); iGenParticle != Evt->particles_end(); ++iGenParticle) { |
540 |
> |
HepMC::GenParticle *myGenPart = *iGenParticle; |
541 |
> |
if (myGenPart->status() == 23 && hardCount < 4) { |
542 |
> |
genForMatching[hardCount].genParticleCore = myGenPart; |
543 |
> |
|
544 |
> |
for(HepMC::GenVertex::particle_iterator iGenDescend = myGenPart->end_vertex()->particles_begin(HepMC::descendants); |
545 |
> |
iGenDescend != myGenPart->end_vertex()->particles_end(HepMC::descendants); ++iGenDescend) { |
546 |
> |
HepMC::GenParticle *myGenDescend = *iGenDescend; |
547 |
> |
if (myGenDescend->status() == 71) genForMatching[hardCount].genParticlesEnd.push_back(myGenDescend); |
548 |
> |
} |
549 |
> |
++hardCount; |
550 |
> |
} |
551 |
> |
} |
552 |
> |
|
553 |
> |
for (GenJetCollection::const_iterator jet_iter = GenJets->begin(); jet_iter!= GenJets->end(); ++jet_iter) { |
554 |
> |
reco::GenJet myJet = reco::GenJet(*jet_iter); |
555 |
> |
if (myJet.pt() > 15 && fabs(myJet.eta()) < 2.5) { |
556 |
> |
|
557 |
> |
TCGenJet* jetCon = new ((*genJets)[genCount]) TCGenJet; |
558 |
> |
jetCon->SetP4(myJet.px(), myJet.py(), myJet.pz(), myJet.energy()); |
559 |
> |
jetCon->SetHadEnergy(myJet.hadEnergy()); |
560 |
> |
jetCon->SetEmEnergy(myJet.emEnergy()); |
561 |
> |
jetCon->SetInvEnergy(myJet.invisibleEnergy()); |
562 |
> |
jetCon->SetAuxEnergy(myJet.auxiliaryEnergy()); |
563 |
> |
jetCon->SetNumConstit(myJet.getGenConstituents().size()); |
564 |
> |
|
565 |
> |
//cout<<"~~JET "<<genCount+1<<"~~"<<endl; |
566 |
> |
//cout<<"(pt, phi, eta) = ("<<myJet.pt()<<", "<<myJet.phi()<<", "<<myJet.eta()<<")"<<endl; |
567 |
> |
|
568 |
> |
vector<const reco::GenParticle*> jetParticles = myJet.getGenConstituents(); |
569 |
> |
vector<const reco::Candidate*> mothers; |
570 |
> |
|
571 |
> |
for (vector<const reco::GenParticle*>::const_iterator gen_iter = jetParticles.begin(); gen_iter != jetParticles.end(); ++gen_iter) { |
572 |
> |
const reco::GenParticle *myParticle = *gen_iter; |
573 |
> |
const reco::Candidate *myMother = myParticle->mother(0); |
574 |
> |
const reco::Candidate *seedCandidate; |
575 |
> |
|
576 |
> |
if (myMother->status() == 71) { |
577 |
> |
seedCandidate = myParticle; |
578 |
> |
} else while (myMother->status() != 71 && myMother->numberOfMothers() != 0) { |
579 |
> |
seedCandidate = myMother; |
580 |
> |
myMother = myMother->mother(); |
581 |
> |
} |
582 |
> |
if (myMother->status() == 4) continue; |
583 |
> |
|
584 |
> |
for (int iter = 0; iter < (int)seedCandidate->numberOfMothers(); ++iter) { |
585 |
> |
const reco::Candidate *jetPartonCandidate = seedCandidate->mother(iter); |
586 |
> |
if (mothers.size() == 0) { |
587 |
> |
mothers.push_back(jetPartonCandidate); |
588 |
> |
continue; |
589 |
> |
} |
590 |
> |
bool newCandidate = true; |
591 |
> |
for (vector<const reco::Candidate*>::const_iterator cand_iter = mothers.begin(); cand_iter != mothers.end(); ++cand_iter) { |
592 |
> |
if (*cand_iter == jetPartonCandidate) { |
593 |
> |
newCandidate = false; |
594 |
> |
break; |
595 |
> |
} |
596 |
> |
} |
597 |
> |
if (newCandidate == true) { |
598 |
> |
mothers.push_back(jetPartonCandidate); |
599 |
> |
//cout<<jetPartonCandidate<<", status: "<<jetPartonCandidate->status()<<" | pdgId : "<<jetPartonCandidate->pdgId()<<endl; |
600 |
> |
} |
601 |
> |
} |
602 |
> |
} |
603 |
> |
vector<unsigned int> matchCount; |
604 |
> |
bool isMixed = false; |
605 |
> |
int sourceIndex = -1; |
606 |
> |
|
607 |
> |
for (vector<const reco::Candidate*>::const_iterator mother_iter = mothers.begin(); mother_iter != mothers.end(); ++mother_iter) { |
608 |
> |
const reco::Candidate *myMother = *mother_iter; |
609 |
> |
|
610 |
> |
for (int i = 0; i <hardCount; ++i) { |
611 |
> |
matchCount.push_back(0); |
612 |
> |
bool matchFound = false; |
613 |
> |
|
614 |
> |
for (vector<HepMC::GenParticle*>::const_iterator match_iter = genForMatching[i].genParticlesEnd.begin(); |
615 |
> |
match_iter != genForMatching[i].genParticlesEnd.end(); |
616 |
> |
++match_iter) { |
617 |
> |
HepMC::GenParticle *myMatch = *match_iter; |
618 |
> |
float matchPt = sqrt(pow(myMatch->momentum().px(), 2) + pow(myMatch->momentum().py(), 2)); |
619 |
> |
|
620 |
> |
if (myMatch->pdg_id() == myMother->pdgId()) { |
621 |
> |
float dEta = fabs(myMatch->momentum().eta() - myMother->eta()); |
622 |
> |
float dPhi = fabs(myMatch->momentum().phi() - myMother->phi()); |
623 |
> |
float dPt = fabs(matchPt - myMother->pt()); |
624 |
> |
|
625 |
> |
if (dEta < 0.0001 && dPhi < 0.0001 && dPt < 0.0001) { |
626 |
> |
matchFound = true; |
627 |
> |
if (i != sourceIndex && sourceIndex != -1) isMixed = true; |
628 |
> |
sourceIndex = i; |
629 |
> |
++matchCount[i]; |
630 |
> |
break; |
631 |
> |
} |
632 |
> |
} |
633 |
> |
} |
634 |
> |
if (matchFound == true) break; |
635 |
> |
} |
636 |
> |
} |
637 |
> |
if (isMixed) { |
638 |
> |
h1_partonJetMatch->Fill(5); |
639 |
> |
float matchSum1 = matchCount[0] + matchCount[1]; |
640 |
> |
float matchSum2 = matchCount[2] + matchCount[3]; |
641 |
> |
float D1 = matchCount[0]/matchSum1;//(mothers.size() * genForMatching[0].genParticlesEnd.size()); |
642 |
> |
float D2 = matchCount[2]/matchSum2;//(mothers.size() * genForMatching[1].genParticlesEnd.size()); |
643 |
> |
//cout<<"Discriminator 1: "<<D1<<" | Discriminator 2: "<<D2<<endl; |
644 |
> |
} else if (sourceIndex == -1) { |
645 |
> |
h1_partonJetMatch->Fill(0); |
646 |
> |
} else { |
647 |
> |
h1_partonJetMatch->Fill(sourceIndex+1); |
648 |
> |
} |
649 |
> |
++genCount; |
650 |
> |
} |
651 |
> |
} |
652 |
> |
//cout<<"END EVENT"<<endl; |
653 |
> |
} |
654 |
> |
|
655 |
> |
/////////////////////////// |
656 |
> |
//get trigger information// |
657 |
> |
/////////////////////////// |
658 |
> |
|
659 |
> |
if (triggerHLT_) { |
660 |
> |
|
661 |
> |
edm::Handle<TriggerResults> hltR; |
662 |
> |
triggerResultsTag_ = InputTag(hlTriggerResults_,"",hltProcess_); |
663 |
> |
iEvent.getByLabel(triggerResultsTag_,hltR); |
664 |
> |
|
665 |
> |
const TriggerNames & triggerNames = iEvent.triggerNames(*hltR); |
666 |
> |
hlNames=triggerNames.triggerNames(); |
667 |
> |
|
668 |
> |
triggerStatus = 0x0; |
669 |
> |
|
670 |
> |
//for(int i = 0; i < (int)mpiTriggers_.size(); ++i) hltPrescale[i] = hltConfig_.prescaleValue(iEvent, iSetup, mpiTriggers_[i]); |
671 |
> |
|
672 |
> |
for (int i=0; i < (int)hlNames.size(); ++i) { |
673 |
> |
if (!triggerDecision(hltR, i)) continue; |
674 |
> |
for (int j = 0; j < (int)mpiTriggers_.size(); ++j){ |
675 |
> |
if (hlNames[i].compare(0, mpiTriggers_[j].length(),mpiTriggers_[j]) == 0) { |
676 |
> |
triggerStatus |= 0x01 << j; |
677 |
> |
} |
678 |
> |
} |
679 |
> |
} |
680 |
|
} |
290 |
– |
|
291 |
– |
|
292 |
– |
if(Calocount > 0 || Calocount_corr >0 || PFcount_corr > 0 || PFcount > 0 || Gencount > 0) sTree -> Fill(); |
293 |
– |
|
294 |
– |
jetP4_ak5PF->Clear(); |
295 |
– |
jetP4_ak5PF_corr->Clear(); |
296 |
– |
jetVtx3_ak5PF->Clear(); |
297 |
– |
jetP4_ak5Calo->Clear(); |
298 |
– |
jetP4_ak5Calo_corr->Clear(); |
299 |
– |
jetVtx3_ak5Calo->Clear(); |
300 |
– |
jetP4_ak5Gen->Clear(); |
301 |
– |
jetVtx3_ak5Gen->Clear(); |
302 |
– |
|
303 |
– |
|
304 |
– |
|
305 |
– |
//---------- Filling HLT trigger bits! ------------ |
306 |
– |
|
307 |
– |
edm::Handle<TriggerResults> hltR; |
308 |
– |
triggerResultsTag_ = InputTag(hlTriggerResults_,"",hltName_); |
309 |
– |
iEvent.getByLabel(triggerResultsTag_,hltR); |
310 |
– |
const edm::TriggerNames & triggerNames = iEvent.triggerNames(*hltR); |
311 |
– |
hlNames=triggerNames.triggerNames(); |
312 |
– |
bool triggerPassed = false; |
313 |
– |
|
314 |
– |
for (uint iT=0; iT<hlNames.size(); ++iT) |
315 |
– |
{ |
316 |
– |
triggerPassed = triggerDecision(hltR, iT); |
317 |
– |
cout<<"trigger name: "<<hlNames[iT]<<" status: "<<triggerPassed<<endl; |
318 |
– |
|
319 |
– |
// ----------->> Fill them Here! <<---------------------- |
320 |
– |
} |
321 |
– |
//---------- ------------------ --------------- |
322 |
– |
|
681 |
|
|
682 |
+ |
if((pfCount >= nJets_ || genCount >= nJets_) && vtxCount > 0) sTree -> Fill(); |
683 |
|
|
684 |
+ |
recoJets->Clear(); |
685 |
+ |
recoMET->Clear(); |
686 |
+ |
recoElectrons->Clear(); |
687 |
+ |
recoMuons->Clear(); |
688 |
+ |
primaryVtx->Clear(); |
689 |
+ |
genJets->Clear(); |
690 |
|
} |
691 |
|
|
327 |
– |
|
692 |
|
// ------------ method called once each job just before starting event loop ------------ |
693 |
|
void MPIntuple::beginJob() |
694 |
< |
{ |
695 |
< |
|
696 |
< |
ntupleFile = new TFile(rootfilename.c_str(), "RECREATE"); |
697 |
< |
sTree = new TTree("dpsTree", "Tree for Jets"); |
698 |
< |
|
699 |
< |
jetP4_ak5PF = new TClonesArray("TLorentzVector"); |
700 |
< |
jetVtx3_ak5PF = new TClonesArray("TVector3"); |
701 |
< |
jetP4_ak5Calo = new TClonesArray("TLorentzVector"); |
702 |
< |
jetVtx3_ak5Calo = new TClonesArray("TVector3"); |
703 |
< |
jetP4_ak5PF_corr = new TClonesArray("TLorentzVector"); |
704 |
< |
jetVtx3_ak5PF_corr = new TClonesArray("TVector3"); |
705 |
< |
jetP4_ak5Calo_corr = new TClonesArray("TLorentzVector"); |
706 |
< |
jetVtx3_ak5Calo_corr = new TClonesArray("TVector3"); |
707 |
< |
jetP4_ak5Gen = new TClonesArray("TLorentzVector"); |
708 |
< |
jetVtx3_ak5Gen = new TClonesArray("TVector3"); |
709 |
< |
PrimaryVtx3 = new TClonesArray("TVector3"); |
710 |
< |
|
711 |
< |
sTree->Branch("jetP4_ak5PF",&jetP4_ak5PF, 6400, 0); |
712 |
< |
sTree->Branch("jetP4_ak5PF_corr",&jetP4_ak5PF_corr, 6400, 0); |
713 |
< |
sTree->Branch("jetVtx3_ak5PF",&jetVtx3_ak5PF, 6400, 0); |
714 |
< |
sTree->Branch("jetVtx3_ak5PF_corr",&jetVtx3_ak5PF, 6400, 0); |
715 |
< |
sTree->Branch("jetP4_ak5Calo",&jetP4_ak5Calo, 6400, 0); |
716 |
< |
sTree->Branch("jetP4_ak5Calo_corr",&jetP4_ak5Calo_corr, 6400, 0); |
717 |
< |
sTree->Branch("jetVtx3_ak5Calo",&jetVtx3_ak5Calo, 6400, 0); |
718 |
< |
sTree->Branch("jetVtx3_ak5Calo_corr",&jetVtx3_ak5Calo, 6400, 0); |
719 |
< |
sTree->Branch("jetP4_ak5Gen",&jetP4_ak5Gen, 6400, 0); |
720 |
< |
sTree->Branch("jetVtx3_ak5Gen",&jetVtx3_ak5Gen, 6400, 0); |
721 |
< |
sTree->Branch("PrimaryVtx",&PrimaryVtx3, 6400, 0); |
358 |
< |
|
694 |
> |
{ |
695 |
> |
ntupleFile = new TFile(rootfilename.c_str(), "RECREATE"); |
696 |
> |
sTree = new TTree("mpiTree", "Tree for Jets"); |
697 |
> |
|
698 |
> |
h1_ptHat = new TH1D("h1_ptHat", "ptHat", 15, 10.0, 160.0); |
699 |
> |
h1_fracAssociatedTracks = new TH1D("h1_fracAssociatedTracks", "Fraction of associated jet tracks", 20, 0.0, 1.0); |
700 |
> |
h1_trackDxy = new TH1D("h1_trackDxy", "dxy for all associated tracks", 50, -0.4, 0.4); |
701 |
> |
h1_meanJetTrackZ = new TH1D("h1_meanJetTrackZ", "<z> from jet tracks", 50, -25.0, 25.0); |
702 |
> |
h1_jetVertexZ = new TH1D("h1_jetVertexZ", "z for vertex associated to jet", 50, -25.0, 25.0); |
703 |
> |
h1_associatedSumPt = new TH1D("h1_associatedSumPt", "ratio of sum p_{T} between associatedTracks and jetTracks", 20, 0.0, 1.0); |
704 |
> |
h1_associatedVertexIndex = new TH1D("h1_associatedVertex", "number of jets associated to primary vertex", 5, -0.5, 4.5); |
705 |
> |
h1_partonJetMatch = new TH1D("h1_partonJetMatch", "jet association to hardest scattering", 6, -0.5, 5.5); |
706 |
> |
h2_nAssTracksVsJetPt = new TH2F("h2_nAssTracksVsJetPt", "nTracks vs Jet p_{T}", 50, 0, 100, 20, -0.5, 19.5); |
707 |
> |
p1_nVtcs = new TProfile("p1_nVtcs", "<N> per run", 5200.0, 132300.0, 137500.0, 0.0, 6.0); |
708 |
> |
|
709 |
> |
recoJets = new TClonesArray("TCJet"); |
710 |
> |
recoMET = new TClonesArray("TCMET"); |
711 |
> |
recoElectrons = new TClonesArray("TCElectron"); |
712 |
> |
recoMuons = new TClonesArray("TCMuon"); |
713 |
> |
genJets = new TClonesArray("TCGenJet"); |
714 |
> |
primaryVtx = new TClonesArray("TCPrimaryVtx"); |
715 |
> |
|
716 |
> |
sTree->Branch("recoJets",&recoJets, 6400, 0); |
717 |
> |
sTree->Branch("recoElectrons",&recoElectrons, 6400, 0); |
718 |
> |
sTree->Branch("recoMuons",&recoMuons, 6400, 0); |
719 |
> |
sTree->Branch("genJets",&genJets, 6400, 0); |
720 |
> |
sTree->Branch("primaryVtx",&primaryVtx, 6400, 0); |
721 |
> |
sTree->Branch("recoMET",&recoMET, 6400, 0); |
722 |
|
sTree->Branch("eventNumber",&eventNumber, "eventNumber/I"); |
723 |
|
sTree->Branch("runNumber",&runNumber, "runNumber/I"); |
724 |
|
sTree->Branch("lumiSection",&lumiSection, "lumiSection/I"); |
725 |
+ |
sTree->Branch("triggerStatus",&triggerStatus, "triggerStatus/i"); |
726 |
+ |
sTree->Branch("hltPrescale",hltPrescale, "hltPrescale[32]/i"); |
727 |
+ |
sTree->Branch("isRealData",&isRealData, "isRealData/i"); |
728 |
+ |
sTree->Branch("bunchCross",&bunchCross, "bunchCross/i"); |
729 |
+ |
sTree->Branch("lumiDeadCount",&lumiDeadCount, "lumiDeadCount/f"); |
730 |
+ |
sTree->Branch("lumiLiveFrac",&lumiLiveFrac, "lumiLiveFrac/f"); |
731 |
+ |
sTree->Branch("intDelLumi",&intDelLumi, "intDelLumi/f"); |
732 |
+ |
sTree->Branch("ptHat",&ptHat, "ptHat/f"); |
733 |
+ |
sTree->Branch("qScale", &qScale, "qScale/f"); |
734 |
+ |
sTree->Branch("evtWeight", &evtWeight, "evtWeight/f"); |
735 |
+ |
sTree->Branch("crossSection", &crossSection, "crossSection/f"); |
736 |
+ |
} |
737 |
+ |
|
738 |
+ |
void MPIntuple::beginRun(const edm::Run& iRun, const edm::EventSetup& iEvent) |
739 |
+ |
{ |
740 |
+ |
bool changed = true; |
741 |
+ |
hltConfig_.init(iRun, iEvent, hltProcess_, changed); |
742 |
+ |
} |
743 |
|
|
744 |
+ |
void MPIntuple::endLuminosityBlock(const edm::LuminosityBlock& iLumi, const edm::EventSetup& iEvent) |
745 |
+ |
{ |
746 |
+ |
edm::Handle<LumiSummary> lumiSummary; |
747 |
+ |
iLumi.getByLabel("lumiProducer", lumiSummary); |
748 |
+ |
|
749 |
+ |
lumiDeadCount = lumiSummary->deadcount(); |
750 |
+ |
lumiLiveFrac = lumiSummary->liveFrac(); |
751 |
+ |
intDelLumi = lumiSummary->avgInsDelLumi()*93.244; |
752 |
+ |
|
753 |
+ |
//cout<<iLumi.id().luminosityBlock()<<endl; |
754 |
+ |
//cout<<"\t Dead Count = "<<lumiSummary->deadcount()<<endl; |
755 |
+ |
//cout<<"\t Fraction of dead time = "<<1 - lumiSummary->liveFrac()<<endl; |
756 |
+ |
//cout<<"\t Integrated luminosity = "<<lumiSummary->avgInsDelLumi()*93.244<<endl; |
757 |
+ |
//cout<<"\t Dead time corrected luminosity = "<<lumiSummary->avgInsDelLumi()*lumiSummary->liveFrac()*93.244<<endl; |
758 |
|
} |
759 |
|
|
760 |
+ |
void MPIntuple::endRun(const edm::Run& iRun, const edm::Event& iEvent, const edm::EventSetup& iSetup) |
761 |
+ |
{ |
762 |
+ |
Handle<GenRunInfoProduct> GenRunInfoHandle; |
763 |
+ |
iEvent.getByLabel("generator", GenRunInfoHandle); |
764 |
+ |
|
765 |
+ |
if (GenRunInfoHandle.isValid()) { |
766 |
+ |
crossSection = GenRunInfoHandle->crossSection(); |
767 |
+ |
} |
768 |
+ |
|
769 |
+ |
for(int i = 0; i < (int)mpiTriggers_.size(); ++i) hltPrescale[i] = hltConfig_.prescaleValue(iEvent, iSetup, mpiTriggers_[i]); |
770 |
+ |
//for (int i = 0; i < (int)mpiTriggers_.size(); ++i) cout << mpiTriggers_[i] << " prescale = " << hltPrescale[i] <<endl; |
771 |
+ |
} |
772 |
|
// ------------ method called once each job just after ending the event loop ------------ |
773 |
|
void MPIntuple::endJob() |
774 |
|
{ |
775 |
+ |
ntupleFile->cd(); |
776 |
+ |
|
777 |
+ |
h1_ptHat->Write(); |
778 |
+ |
h1_fracAssociatedTracks->Write(); |
779 |
+ |
h1_meanJetTrackZ->Write(); |
780 |
+ |
h1_trackDxy->Write(); |
781 |
+ |
h1_jetVertexZ->Write(); |
782 |
+ |
h1_associatedSumPt->Write(); |
783 |
+ |
h1_associatedVertexIndex->Write(); |
784 |
+ |
h1_partonJetMatch->Write(); |
785 |
+ |
h2_nAssTracksVsJetPt->Write(); |
786 |
+ |
p1_nVtcs->Write(); |
787 |
+ |
|
788 |
|
ntupleFile->Write(); |
789 |
|
ntupleFile->Close(); |
370 |
– |
|
790 |
|
} |
791 |
|
|
792 |
+ |
bool MPIntuple::genParticleMatch(const HepMC::GenParticle& genParticle, const reco::Candidate& motherParticle) |
793 |
+ |
{ |
794 |
+ |
float genPhi, momPhi, genEta, momEta; |
795 |
+ |
genPhi = genParticle.momentum().phi(); |
796 |
+ |
genEta = genParticle.momentum().eta(); |
797 |
+ |
momPhi = motherParticle.phi(); |
798 |
+ |
momEta = motherParticle.eta(); |
799 |
+ |
|
800 |
+ |
float dR = sqrt(pow((genPhi - momPhi), 2) + pow((genEta - momEta), 2)); |
801 |
+ |
if (dR < 0.00001) return true; |
802 |
+ |
else return false; |
803 |
+ |
} |
804 |
|
|
805 |
|
bool MPIntuple::triggerDecision(edm::Handle<edm::TriggerResults> &hltR, int iTrigger) |
806 |
|
{ |
811 |
|
triggerPassed = true; |
812 |
|
} |
813 |
|
return triggerPassed; |
814 |
< |
} |
814 |
> |
} |
815 |
|
|
816 |
+ |
float MPIntuple::sumPtSquared(const Vertex & v) |
817 |
+ |
{ |
818 |
+ |
float sum = 0.; |
819 |
+ |
float pT; |
820 |
+ |
for (Vertex::trackRef_iterator it = v.tracks_begin(); it != v.tracks_end(); it++) { |
821 |
+ |
pT = (**it).pt(); |
822 |
+ |
float epT=(**it).ptError(); pT=pT>epT ? pT-epT : 0; |
823 |
+ |
|
824 |
+ |
sum += pT*pT; |
825 |
+ |
} |
826 |
+ |
return sum; |
827 |
+ |
} |
828 |
|
|
829 |
|
//define this as a plug-in |
830 |
|
DEFINE_FWK_MODULE(MPIntuple); |