18 |
|
#include "FWCore/ParameterSet/interface/ParameterSet.h" |
19 |
|
#include "DataFormats/GeometryVector/interface/GlobalPoint.h" |
20 |
|
#include "Geometry/Records/interface/CaloGeometryRecord.h" |
21 |
+ |
#include "DataFormats/Math/interface/deltaPhi.h" |
22 |
|
|
23 |
|
// Jet and vertex functions |
24 |
|
#include "DataFormats/JetReco/interface/CaloJet.h" |
31 |
|
#include "DataFormats/VertexReco/interface/Vertex.h" |
32 |
|
#include "DataFormats/VertexReco/interface/VertexFwd.h" |
33 |
|
#include "DataFormats/BTauReco/interface/JetTag.h" |
34 |
+ |
//#include "RecoVertex/PrimaryVertexProducer/interface/VertexHigherPtSquared.h" |
35 |
|
|
36 |
< |
#include "DataFormats/Math/interface/deltaPhi.h" |
36 |
> |
//GenParticles |
37 |
> |
#include "DataFormats/HepMCCandidate/interface/GenParticle.h" |
38 |
|
|
39 |
|
// Need to get correctors |
40 |
|
#include "JetMETCorrections/Objects/interface/JetCorrector.h" |
80 |
|
virtual void endJob() ; |
81 |
|
|
82 |
|
bool triggerDecision(edm::Handle<edm::TriggerResults> &hltR, int iTrigger); |
83 |
+ |
double sumPtSquared(const Vertex & v); |
84 |
|
|
85 |
|
// ----------member data --------------------------- |
86 |
|
|
88 |
|
edm::InputTag GenJetHandle_; |
89 |
|
edm::InputTag PrimaryVtxHandle_; |
90 |
|
edm::InputTag triggerResultsTag_; |
91 |
< |
|
91 |
> |
edm::InputTag genParticles_; |
92 |
|
|
93 |
|
// Counting variables // |
94 |
|
|
99 |
|
|
100 |
|
TClonesArray* jet_ak5PF; |
101 |
|
TClonesArray* jetP4_ak5Gen; |
102 |
+ |
TClonesArray* genParticleP4; |
103 |
|
TClonesArray* primaryVtx; |
104 |
|
|
105 |
|
bool doGenJets_; |
123 |
|
PFJetHandle_(iConfig.getUntrackedParameter<edm::InputTag>("PFJetTag")), |
124 |
|
GenJetHandle_(iConfig.getUntrackedParameter<edm::InputTag>("GenJetTag")), |
125 |
|
PrimaryVtxHandle_(iConfig.getUntrackedParameter<edm::InputTag>("PrimaryVtxTag")), |
126 |
+ |
genParticles_(iConfig.getUntrackedParameter<edm::InputTag>("genParticleTag")), |
127 |
|
doGenJets_(iConfig.getUntrackedParameter<bool>("doGenJets")), |
128 |
|
doPFJets_(iConfig.getUntrackedParameter<bool>("doPFJets")), |
129 |
|
triggerHLT_(iConfig.getUntrackedParameter<bool>("triggerHLT")), |
131 |
|
hlTriggerResults_(iConfig.getUntrackedParameter<string>("HLTriggerResults","TriggerResults")), |
132 |
|
hltName_(iConfig.getUntrackedParameter<string>("hltName","HLT")) |
133 |
|
{ |
134 |
< |
//edm::TriggerNames |
129 |
< |
// triggerNames(iConfig); |
134 |
> |
|
135 |
|
|
136 |
|
} |
137 |
|
|
141 |
|
|
142 |
|
} |
143 |
|
|
144 |
+ |
double MPIntuple::sumPtSquared(const Vertex & v) |
145 |
+ |
{ |
146 |
+ |
double sum = 0.; |
147 |
+ |
double pT; |
148 |
+ |
for (Vertex::trackRef_iterator it = v.tracks_begin(); it != v.tracks_end(); it++) { |
149 |
+ |
pT = (**it).pt(); |
150 |
+ |
double epT=(**it).ptError(); pT=pT>epT ? pT-epT : 0; |
151 |
+ |
|
152 |
+ |
sum += pT*pT; |
153 |
+ |
} |
154 |
+ |
return sum; |
155 |
+ |
} |
156 |
+ |
|
157 |
|
// |
158 |
|
// member functions |
159 |
|
// |
168 |
|
bunchCross = (unsigned int)iEvent.bunchCrossing(); |
169 |
|
isRealData = iEvent.isRealData(); |
170 |
|
|
171 |
< |
int PFcount = 0; |
172 |
< |
int Gencount = 0; |
173 |
< |
int Vtxcount = 0; |
171 |
> |
int PFcount = 0; |
172 |
> |
int Gencount = 0; |
173 |
> |
int GenPcount = 0; |
174 |
> |
int Vtxcount = 0; |
175 |
|
|
176 |
|
if(doPFJets_){ |
177 |
|
|
243 |
|
} |
244 |
|
} |
245 |
|
|
246 |
< |
if(doGenJets_){ |
246 |
> |
if(!isRealData){ |
247 |
|
|
248 |
+ |
Handle<reco::GenParticleCollection > genpcoll; |
249 |
+ |
iEvent.getByLabel(genParticles_, genpcoll); |
250 |
+ |
|
251 |
|
Handle<reco::GenJetCollection> GenJets; |
252 |
|
iEvent.getByLabel(GenJetHandle_, GenJets); |
253 |
|
|
264 |
|
|
265 |
|
} |
266 |
|
} |
245 |
– |
} |
246 |
– |
|
267 |
|
|
268 |
+ |
for(reco::GenParticleCollection::const_iterator iGen = genpcoll->begin(); iGen!=genpcoll->end(); ++iGen) { |
269 |
+ |
|
270 |
+ |
reco::GenParticle p = reco::GenParticle(*iGen); |
271 |
+ |
|
272 |
+ |
new ((*genParticleP4)[GenPcount]) TLorentzVector(p.px(), p.py(), p.pz(), p.energy()); |
273 |
+ |
|
274 |
+ |
++GenPcount; |
275 |
+ |
|
276 |
+ |
} |
277 |
+ |
|
278 |
+ |
|
279 |
+ |
} |
280 |
+ |
|
281 |
+ |
|
282 |
|
Handle<reco::VertexCollection> primaryVtcs; |
283 |
|
iEvent.getByLabel(PrimaryVtxHandle_, primaryVtcs); |
284 |
< |
|
284 |
> |
|
285 |
|
for(VertexCollection::const_iterator vtx_iter = primaryVtcs->begin(); vtx_iter!= primaryVtcs->end(); ++vtx_iter){ |
286 |
|
|
287 |
|
reco::Vertex myVtx = reco::Vertex(*vtx_iter); |
288 |
< |
|
288 |
> |
if(!myVtx.isValid() || myVtx.isFake()) continue; |
289 |
|
TCPrimaryVtx* vtxCon = new ((*primaryVtx)[Vtxcount]) TCPrimaryVtx; |
290 |
|
|
291 |
|
vtxCon->SetPosition(myVtx.x(), myVtx.y(), myVtx.z()); |
292 |
|
vtxCon->SetNDof(myVtx.ndof()); |
293 |
|
vtxCon->SetChi2(myVtx.chi2()); |
294 |
< |
|
294 |
> |
//placeholders |
295 |
> |
// vtxCon->SetNTracks(myVtx.tracksSize()); |
296 |
> |
// vtxCon->SetTracksSumPtSquared(sumPtSquared(*myVtx)); |
297 |
> |
int test1 = myVtx.tracksSize(); |
298 |
> |
double test2 = sumPtSquared(myVtx); |
299 |
|
++Vtxcount; |
300 |
|
|
301 |
|
} |
355 |
|
|
356 |
|
jet_ak5PF = new TClonesArray("TCJet"); |
357 |
|
jetP4_ak5Gen = new TClonesArray("TLorentzVector"); |
358 |
+ |
genParticleP4 = new TClonesArray("TLorentzVector"); |
359 |
|
primaryVtx = new TClonesArray("TCPrimaryVtx"); |
360 |
|
|
361 |
|
sTree->Branch("jet_ak5PF",&jet_ak5PF, 6400, 0); |
362 |
|
sTree->Branch("jetP4_ak5Gen",&jetP4_ak5Gen, 6400, 0); |
363 |
+ |
sTree->Branch("genParticleP4",&genParticleP4, 6400, 0); |
364 |
|
sTree->Branch("primaryVtx",&primaryVtx, 6400, 0); |
365 |
|
|
366 |
|
sTree->Branch("eventNumber",&eventNumber, "eventNumber/I"); |