1 |
naodell |
1.1 |
// Original Author: "Nathaniel Odell"
|
2 |
|
|
// Secondary Author: Steven Won
|
3 |
andrey |
1.2 |
// With contributions from: Andrey Pozdnyakov
|
4 |
naodell |
1.1 |
// Created: Thurs April 22 2010
|
5 |
naodell |
1.26 |
// $Id: MPIntuple.cc,v 1.25 2010/11/30 14:08:14 naodell Exp $
|
6 |
naodell |
1.1 |
|
7 |
|
|
// system include files
|
8 |
|
|
#include <memory>
|
9 |
|
|
#include <string>
|
10 |
|
|
|
11 |
|
|
// user include files
|
12 |
|
|
#include "FWCore/Framework/interface/Frameworkfwd.h"
|
13 |
|
|
#include "FWCore/Framework/interface/EDAnalyzer.h"
|
14 |
|
|
#include "FWCore/Framework/interface/ESHandle.h"
|
15 |
|
|
#include "FWCore/Framework/interface/EventSetup.h"
|
16 |
|
|
#include "FWCore/Framework/interface/Event.h"
|
17 |
|
|
#include "FWCore/Framework/interface/MakerMacros.h"
|
18 |
naodell |
1.26 |
#include "FWCore/Framework/interface/LuminosityBlock.h"
|
19 |
naodell |
1.1 |
#include "FWCore/ParameterSet/interface/ParameterSet.h"
|
20 |
naodell |
1.26 |
|
21 |
|
|
#include "Geometry/Records/interface/CaloGeometryRecord.h"
|
22 |
naodell |
1.1 |
#include "DataFormats/GeometryVector/interface/GlobalPoint.h"
|
23 |
naodell |
1.26 |
#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 |
naodell |
1.10 |
#include "DataFormats/Math/interface/deltaPhi.h"
|
30 |
naodell |
1.1 |
|
31 |
naodell |
1.15 |
// Libraries for objects
|
32 |
naodell |
1.26 |
#include "DataFormats/ParticleFlowCandidate/interface/PFCandidate.h"
|
33 |
|
|
#include "DataFormats/ParticleFlowCandidate/interface/PFCandidateFwd.h"
|
34 |
|
|
#include "DataFormats/HepMCCandidate/interface/GenParticle.h"
|
35 |
naodell |
1.1 |
#include "DataFormats/JetReco/interface/CaloJet.h"
|
36 |
|
|
#include "DataFormats/JetReco/interface/CaloJetCollection.h"
|
37 |
naodell |
1.26 |
#include "DataFormats/JetReco/interface/GenJet.h"
|
38 |
|
|
#include "DataFormats/JetReco/interface/GenJetCollection.h"
|
39 |
naodell |
1.1 |
#include "DataFormats/JetReco/interface/PFJet.h"
|
40 |
|
|
#include "DataFormats/JetReco/interface/PFJetCollection.h"
|
41 |
naodell |
1.26 |
#include "DataFormats/MuonReco/interface/Muon.h"
|
42 |
|
|
#include "DataFormats/MuonReco/interface/MuonFwd.h"
|
43 |
|
|
#include "DataFormats/MuonReco/interface/MuonSelectors.h"
|
44 |
|
|
#include "DataFormats/EgammaCandidates/interface/GsfElectron.h"
|
45 |
|
|
#include "DataFormats/EgammaCandidates/interface/GsfElectronFwd.h"
|
46 |
|
|
#include "DataFormats/EgammaCandidates/interface/Photon.h"
|
47 |
|
|
#include "DataFormats/EgammaCandidates/interface/PhotonFwd.h"
|
48 |
|
|
#include "DataFormats/TrackReco/interface/Track.h"
|
49 |
|
|
#include "DataFormats/TrackReco/interface/TrackFwd.h"
|
50 |
|
|
#include "DataFormats/GsfTrackReco/interface/GsfTrack.h"
|
51 |
naodell |
1.1 |
#include "DataFormats/VertexReco/interface/Vertex.h"
|
52 |
|
|
#include "DataFormats/VertexReco/interface/VertexFwd.h"
|
53 |
naodell |
1.7 |
#include "DataFormats/BTauReco/interface/JetTag.h"
|
54 |
naodell |
1.16 |
#include "DataFormats/BeamSpot/interface/BeamSpot.h"
|
55 |
naodell |
1.26 |
#include "DataFormats/Luminosity/interface/LumiSummary.h"
|
56 |
|
|
#include "DataFormats/Common/interface/ValueMap.h"
|
57 |
naodell |
1.18 |
#include "SimDataFormats/GeneratorProducts/interface/GenEventInfoProduct.h"
|
58 |
naodell |
1.24 |
#include "SimDataFormats/GeneratorProducts/interface/GenRunInfoProduct.h"
|
59 |
naodell |
1.26 |
#include "SimDataFormats/PileupSummaryInfo/interface/PileupSummaryInfo.h"
|
60 |
naodell |
1.18 |
|
61 |
devildog |
1.11 |
//#include "RecoVertex/PrimaryVertexProducer/interface/VertexHigherPtSquared.h"
|
62 |
naodell |
1.7 |
|
63 |
naodell |
1.26 |
// Need to get corrections
|
64 |
naodell |
1.4 |
#include "JetMETCorrections/Objects/interface/JetCorrector.h"
|
65 |
|
|
|
66 |
|
|
// ntuple storage classes
|
67 |
|
|
#include "TCJet.h"
|
68 |
|
|
#include "TCPrimaryVtx.h"
|
69 |
naodell |
1.25 |
#include "TCGenJet.h"
|
70 |
naodell |
1.26 |
#include "TCMuon.h"
|
71 |
|
|
#include "TCElectron.h"
|
72 |
naodell |
1.4 |
|
73 |
andrey |
1.2 |
// Need for HLT trigger info:
|
74 |
|
|
#include "FWCore/Common/interface/TriggerNames.h"
|
75 |
|
|
#include "DataFormats/Common/interface/TriggerResults.h"
|
76 |
|
|
#include "HLTrigger/HLTcore/interface/HLTConfigProvider.h"
|
77 |
|
|
|
78 |
naodell |
1.4 |
//Root stuff
|
79 |
naodell |
1.1 |
#include "TROOT.h"
|
80 |
naodell |
1.15 |
#include "TH1.h"
|
81 |
naodell |
1.16 |
#include "TH2.h"
|
82 |
naodell |
1.15 |
#include "TProfile.h"
|
83 |
naodell |
1.1 |
#include "TFile.h"
|
84 |
|
|
#include "TTree.h"
|
85 |
|
|
#include "TString.h"
|
86 |
|
|
#include "TObject.h"
|
87 |
|
|
#include "TObjArray.h"
|
88 |
|
|
#include "TClonesArray.h"
|
89 |
|
|
#include "TRefArray.h"
|
90 |
|
|
#include "TLorentzVector.h"
|
91 |
|
|
#include "TVector3.h"
|
92 |
|
|
|
93 |
|
|
using namespace edm;
|
94 |
|
|
using namespace std;
|
95 |
|
|
using namespace reco;
|
96 |
|
|
|
97 |
|
|
//
|
98 |
|
|
// class declaration
|
99 |
|
|
//
|
100 |
|
|
|
101 |
|
|
class MPIntuple : public edm::EDAnalyzer {
|
102 |
|
|
public:
|
103 |
|
|
explicit MPIntuple(const edm::ParameterSet&);
|
104 |
|
|
~MPIntuple();
|
105 |
|
|
|
106 |
|
|
|
107 |
|
|
private:
|
108 |
|
|
virtual void beginJob() ;
|
109 |
naodell |
1.26 |
virtual void beginRun(const edm::Run&, const edm::EventSetup&) ;
|
110 |
naodell |
1.1 |
virtual void analyze(const edm::Event&, const edm::EventSetup&);
|
111 |
naodell |
1.26 |
virtual void endLuminosityBlock(const edm::LuminosityBlock&,const edm::EventSetup&);
|
112 |
|
|
virtual void endRun(const edm::Run&, const edm::EventSetup&);
|
113 |
naodell |
1.1 |
virtual void endJob() ;
|
114 |
|
|
|
115 |
naodell |
1.26 |
bool triggerDecision(edm::Handle<edm::TriggerResults>& hltR, int iTrigger);
|
116 |
|
|
double sumPtSquared(const Vertex& v);
|
117 |
andrey |
1.2 |
|
118 |
naodell |
1.1 |
// ----------member data ---------------------------
|
119 |
|
|
|
120 |
|
|
|
121 |
naodell |
1.26 |
int eventNumber, runNumber, lumiSection, bunchCross;
|
122 |
|
|
double ptHat, qScale, crossSection;
|
123 |
naodell |
1.18 |
|
124 |
naodell |
1.26 |
TTree* sTree;
|
125 |
|
|
TFile* ntupleFile;
|
126 |
|
|
edm::InputTag recoJetTag_;
|
127 |
|
|
edm::InputTag genJetTag_;
|
128 |
|
|
edm::InputTag muonTag_;
|
129 |
|
|
edm::InputTag electronTag_;
|
130 |
|
|
edm::InputTag primaryVtxTag_;
|
131 |
|
|
edm::InputTag triggerResultsTag_;
|
132 |
|
|
edm::InputTag electronIDMap_;
|
133 |
|
|
bool doGenJets_;
|
134 |
|
|
bool doPFJets_;
|
135 |
|
|
bool triggerHLT_;
|
136 |
|
|
bool isRealData;
|
137 |
|
|
string rootfilename;
|
138 |
|
|
|
139 |
|
|
TClonesArray* recoJets;
|
140 |
|
|
TClonesArray* genJets;
|
141 |
|
|
TClonesArray* primaryVtx;
|
142 |
|
|
TClonesArray* recoMuons;
|
143 |
|
|
TClonesArray* recoElectrons;
|
144 |
|
|
|
145 |
|
|
//Triggers
|
146 |
|
|
string hlTriggerResults_, hltProcess_, triggerName_;
|
147 |
|
|
TriggerNames triggerNames;
|
148 |
|
|
HLTConfigProvider hltConfig_;
|
149 |
|
|
vector<string> hlNames;
|
150 |
|
|
unsigned int triggerStatus;
|
151 |
|
|
|
152 |
|
|
//Histograms
|
153 |
|
|
TH1D * h1_fracAssociatedTracks;
|
154 |
|
|
TH1D * h1_meanJetTrackZ;
|
155 |
|
|
TH1D * h1_trackDxy;
|
156 |
|
|
TH1D * h1_jetVertexZ;
|
157 |
|
|
TH1D * h1_associatedSumPt;
|
158 |
|
|
TH1D * h1_associatedVertexIndex;
|
159 |
|
|
TH2F * h2_nAssTracksVsJetPt;
|
160 |
|
|
TProfile * p1_nVtcs;
|
161 |
naodell |
1.1 |
};
|
162 |
|
|
|
163 |
naodell |
1.18 |
MPIntuple::MPIntuple(const edm::ParameterSet& iConfig)
|
164 |
naodell |
1.1 |
{
|
165 |
naodell |
1.26 |
recoJetTag_ = iConfig.getUntrackedParameter<edm::InputTag>("RecoJetTag");
|
166 |
|
|
muonTag_ = iConfig.getUntrackedParameter<edm::InputTag>("MuonTag");
|
167 |
|
|
electronTag_ = iConfig.getUntrackedParameter<edm::InputTag>("ElectronTag");
|
168 |
|
|
genJetTag_ = iConfig.getUntrackedParameter<edm::InputTag>("GenJetTag");
|
169 |
|
|
primaryVtxTag_ = iConfig.getUntrackedParameter<edm::InputTag>("PrimaryVtxTag");
|
170 |
|
|
electronIDMap_ = iConfig.getParameter<edm::InputTag>("electronIDMap");
|
171 |
|
|
doGenJets_ = iConfig.getUntrackedParameter<bool>("doGenJets");
|
172 |
|
|
doPFJets_ = iConfig.getUntrackedParameter<bool>("doPFJets");
|
173 |
|
|
triggerHLT_ = iConfig.getUntrackedParameter<bool>("triggerHLT");
|
174 |
naodell |
1.18 |
hlTriggerResults_ = iConfig.getUntrackedParameter<string>("HLTriggerResults","TriggerResults");
|
175 |
naodell |
1.26 |
hltProcess_ = iConfig.getUntrackedParameter<string>("hltName");
|
176 |
|
|
rootfilename = iConfig.getUntrackedParameter<string>("rootfilename");
|
177 |
naodell |
1.1 |
}
|
178 |
|
|
|
179 |
|
|
MPIntuple::~MPIntuple()
|
180 |
|
|
{
|
181 |
|
|
|
182 |
|
|
}
|
183 |
|
|
|
184 |
|
|
//
|
185 |
|
|
// member functions
|
186 |
|
|
//
|
187 |
|
|
|
188 |
|
|
// ------------ method called to for each event ------------
|
189 |
|
|
void MPIntuple::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup)
|
190 |
|
|
{
|
191 |
|
|
|
192 |
naodell |
1.6 |
eventNumber = iEvent.id().event();
|
193 |
|
|
runNumber = iEvent.id().run();
|
194 |
naodell |
1.1 |
lumiSection = (unsigned int)iEvent.getLuminosityBlock().luminosityBlock();
|
195 |
naodell |
1.8 |
bunchCross = (unsigned int)iEvent.bunchCrossing();
|
196 |
|
|
isRealData = iEvent.isRealData();
|
197 |
|
|
|
198 |
naodell |
1.18 |
|
199 |
naodell |
1.16 |
edm::Handle<reco::BeamSpot> beamSpotHandle;
|
200 |
|
|
iEvent.getByLabel("offlineBeamSpot", beamSpotHandle);
|
201 |
|
|
reco::BeamSpot vertexBeamSpot = *beamSpotHandle;
|
202 |
|
|
|
203 |
|
|
int pfCount = 0;
|
204 |
|
|
int genCount = 0;
|
205 |
|
|
int vtxCount = 0;
|
206 |
naodell |
1.24 |
double primaryVertexZ = -999;
|
207 |
naodell |
1.16 |
|
208 |
|
|
//////////////////////////
|
209 |
|
|
//Get vertex information//
|
210 |
|
|
//////////////////////////
|
211 |
|
|
|
212 |
|
|
Handle<reco::VertexCollection> primaryVtcs;
|
213 |
naodell |
1.26 |
iEvent.getByLabel(primaryVtxTag_, primaryVtcs);
|
214 |
naodell |
1.16 |
|
215 |
|
|
for(VertexCollection::const_iterator vtx_iter = primaryVtcs->begin(); vtx_iter!= primaryVtcs->end(); ++vtx_iter){
|
216 |
|
|
|
217 |
|
|
reco::Vertex myVtx = reco::Vertex(*vtx_iter);
|
218 |
|
|
if(!myVtx.isValid() || myVtx.isFake()) continue;
|
219 |
|
|
TCPrimaryVtx* vtxCon = new ((*primaryVtx)[vtxCount]) TCPrimaryVtx;
|
220 |
|
|
|
221 |
naodell |
1.23 |
//cout<<myVtx.nTracks()<<endl;
|
222 |
|
|
|
223 |
naodell |
1.16 |
vtxCon->SetPosition(myVtx.x(), myVtx.y(), myVtx.z());
|
224 |
|
|
vtxCon->SetNDof(myVtx.ndof());
|
225 |
|
|
vtxCon->SetChi2(myVtx.chi2());
|
226 |
|
|
vtxCon->SetNTrks(myVtx.tracksSize());
|
227 |
|
|
vtxCon->SetSumPt2Trks(sumPtSquared(myVtx));
|
228 |
|
|
|
229 |
|
|
if(vtxCount == 0) primaryVertexZ = myVtx.z();
|
230 |
|
|
|
231 |
|
|
++vtxCount;
|
232 |
|
|
|
233 |
|
|
}
|
234 |
|
|
|
235 |
|
|
p1_nVtcs->Fill(runNumber, vtxCount);
|
236 |
|
|
|
237 |
|
|
///////////////////////
|
238 |
|
|
//get jet information//
|
239 |
|
|
///////////////////////
|
240 |
naodell |
1.1 |
|
241 |
|
|
if(doPFJets_){
|
242 |
naodell |
1.4 |
|
243 |
naodell |
1.7 |
edm::Handle<reco::JetTagCollection> bTagHandle1;
|
244 |
|
|
iEvent.getByLabel("trackCountingHighEffBJetTags", bTagHandle1);
|
245 |
|
|
const reco::JetTagCollection & bTags1 = *(bTagHandle1.product());
|
246 |
|
|
reco::JetTagCollection::const_iterator jet_it_1;
|
247 |
|
|
|
248 |
|
|
edm::Handle<reco::JetTagCollection> bTagHandle2;
|
249 |
|
|
iEvent.getByLabel("trackCountingHighPurBJetTags", bTagHandle2);
|
250 |
|
|
const reco::JetTagCollection & bTags2 = *(bTagHandle2.product());
|
251 |
|
|
reco::JetTagCollection::const_iterator jet_it_2;
|
252 |
|
|
|
253 |
naodell |
1.4 |
const JetCorrector* correctorL2 = JetCorrector::getJetCorrector ("ak5PFL2Relative",iSetup);
|
254 |
|
|
const JetCorrector* correctorL3 = JetCorrector::getJetCorrector ("ak5PFL3Absolute",iSetup);
|
255 |
|
|
|
256 |
naodell |
1.1 |
Handle<reco::PFJetCollection> PFJets;
|
257 |
naodell |
1.26 |
iEvent.getByLabel(recoJetTag_, PFJets);
|
258 |
naodell |
1.16 |
|
259 |
naodell |
1.1 |
for(PFJetCollection::const_iterator jet_iter = PFJets->begin(); jet_iter!= PFJets->end(); ++jet_iter){
|
260 |
|
|
|
261 |
|
|
reco::PFJet myJet = reco::PFJet(*jet_iter);
|
262 |
naodell |
1.22 |
if(myJet.pt() > 5){
|
263 |
naodell |
1.7 |
|
264 |
|
|
for(jet_it_1 = bTags1.begin(); jet_it_1 != bTags1.end(); jet_it_1++) {
|
265 |
|
|
if( (fabs(jet_it_1->first->eta() - myJet.eta()) < .005) && (deltaPhi(jet_it_1->first->phi(),myJet.phi()) < .005)) break;
|
266 |
|
|
}
|
267 |
|
|
|
268 |
|
|
for(jet_it_2 = bTags2.begin(); jet_it_2 != bTags2.end(); jet_it_2++) {
|
269 |
|
|
if( (fabs(jet_it_2->first->eta() - myJet.eta()) < .005) && (deltaPhi(jet_it_2->first->phi(),myJet.phi()) < .005)) break;
|
270 |
|
|
}
|
271 |
naodell |
1.6 |
|
272 |
naodell |
1.26 |
TCJet* jetCon = new ((*recoJets)[pfCount]) TCJet;
|
273 |
naodell |
1.6 |
|
274 |
|
|
jetCon->SetP4(myJet.px(), myJet.py(), myJet.pz(), myJet.energy());
|
275 |
naodell |
1.15 |
jetCon->SetVtx(-999.0, -999.0, -999.0);
|
276 |
naodell |
1.6 |
jetCon->SetChHadFrac(myJet.chargedHadronEnergyFraction());
|
277 |
|
|
jetCon->SetNeuHadFrac(myJet.neutralHadronEnergyFraction());
|
278 |
|
|
jetCon->SetChEmFrac(myJet.chargedEmEnergyFraction());
|
279 |
|
|
jetCon->SetNeuEmFrac(myJet.neutralEmEnergyFraction());
|
280 |
|
|
jetCon->SetNumConstit(myJet.chargedMultiplicity() + myJet.neutralMultiplicity());
|
281 |
|
|
jetCon->SetNumChPart(myJet.chargedMultiplicity());
|
282 |
naodell |
1.4 |
|
283 |
naodell |
1.7 |
if(jet_it_2 != bTags2.end()) jetCon->SetBDiscrTrkCountHiPure(jet_it_2->second);
|
284 |
|
|
if(jet_it_1 != bTags1.end()) jetCon->SetBDiscrTrkCountHiEff(jet_it_1->second);
|
285 |
|
|
|
286 |
naodell |
1.24 |
double scale2 = correctorL2->correction(myJet);
|
287 |
naodell |
1.7 |
myJet.scaleEnergy(scale2);
|
288 |
naodell |
1.24 |
double scale3 = correctorL3->correction(myJet);
|
289 |
naodell |
1.7 |
myJet.scaleEnergy(scale3);
|
290 |
|
|
|
291 |
|
|
//more corrections?
|
292 |
|
|
|
293 |
naodell |
1.6 |
jetCon->SetJetCorr(2, scale2);
|
294 |
|
|
jetCon->SetJetCorr(3, scale3);
|
295 |
naodell |
1.7 |
|
296 |
naodell |
1.16 |
/////////////////////////
|
297 |
|
|
//get associated tracks//
|
298 |
|
|
/////////////////////////
|
299 |
naodell |
1.15 |
|
300 |
|
|
const reco::TrackRefVector &tracks = myJet.getTrackRefs();
|
301 |
|
|
|
302 |
naodell |
1.24 |
vector<TVector3> vtxPositionCollection;
|
303 |
|
|
vector<double> associatedTrackSumPt;
|
304 |
|
|
vector<unsigned int> jetTrackAddresses;
|
305 |
|
|
double sumTrackX, sumTrackY, sumTrackZ, sumTrackIP, sumTrackPt;
|
306 |
|
|
int nJetTracks, nVertexTracks, nAssociatedTracks, vertexIndex;
|
307 |
naodell |
1.23 |
int vCount = 0;
|
308 |
naodell |
1.16 |
|
309 |
naodell |
1.24 |
nJetTracks = nVertexTracks = nAssociatedTracks = 0;
|
310 |
|
|
sumTrackX = sumTrackY = sumTrackZ = sumTrackIP = sumTrackPt = 0;
|
311 |
naodell |
1.15 |
|
312 |
naodell |
1.23 |
if(myJet.pt() > 10 && fabs(myJet.eta()) < 2.4){
|
313 |
naodell |
1.17 |
|
314 |
naodell |
1.15 |
for(TrackRefVector::const_iterator iTrack = tracks.begin(); iTrack != tracks.end(); ++iTrack){
|
315 |
naodell |
1.23 |
const reco::Track &myJetTrack = **iTrack;
|
316 |
naodell |
1.20 |
|
317 |
naodell |
1.23 |
sumTrackPt += myJetTrack.pt();
|
318 |
naodell |
1.24 |
sumTrackX += myJetTrack.vx();
|
319 |
|
|
sumTrackY += myJetTrack.vy();
|
320 |
naodell |
1.23 |
sumTrackZ += myJetTrack.vz();
|
321 |
naodell |
1.21 |
sumTrackIP += myJetTrack.dxy(vertexBeamSpot.position());
|
322 |
naodell |
1.24 |
jetTrackAddresses.push_back((unsigned int)&myJetTrack);
|
323 |
|
|
++nJetTracks;
|
324 |
|
|
}
|
325 |
|
|
|
326 |
naodell |
1.26 |
if (nJetTracks > 0) {
|
327 |
naodell |
1.24 |
jetCon->SetVtx(sumTrackX/nJetTracks, sumTrackY/nJetTracks, sumTrackZ/nJetTracks);
|
328 |
|
|
h1_meanJetTrackZ->Fill(sumTrackZ/nJetTracks);
|
329 |
|
|
h1_trackDxy->Fill(sumTrackIP/nJetTracks);
|
330 |
naodell |
1.23 |
}
|
331 |
naodell |
1.24 |
if(jetTrackAddresses.size() > 0){
|
332 |
naodell |
1.23 |
|
333 |
naodell |
1.26 |
for (VertexCollection::const_iterator vtx_iter = primaryVtcs->begin(); vtx_iter!= primaryVtcs->end(); ++vtx_iter) {
|
334 |
naodell |
1.24 |
reco::Vertex myVtx = reco::Vertex(*vtx_iter);
|
335 |
naodell |
1.23 |
if(!myVtx.isValid() || myVtx.isFake()) continue;
|
336 |
naodell |
1.24 |
TVector3 *iVtxPosition = new TVector3(myVtx.x(), myVtx.y(), myVtx.z());
|
337 |
|
|
vtxPositionCollection.push_back(*iVtxPosition);
|
338 |
|
|
associatedTrackSumPt.push_back(0);
|
339 |
|
|
|
340 |
naodell |
1.23 |
for(Vertex::trackRef_iterator iTrackRef = myVtx.tracks_begin(); iTrackRef != myVtx.tracks_end(); ++iTrackRef){
|
341 |
naodell |
1.24 |
const edm::RefToBase<reco::Track> &myTrackRef = *iTrackRef;
|
342 |
naodell |
1.23 |
if(myTrackRef.isAvailable()){
|
343 |
|
|
const reco::Track &myVertexTrack = *myTrackRef.get();
|
344 |
|
|
|
345 |
naodell |
1.24 |
for(vector<unsigned int>::const_iterator iTrackAddress = jetTrackAddresses.begin(); iTrackAddress != jetTrackAddresses.end(); ++iTrackAddress){
|
346 |
naodell |
1.26 |
if (*iTrackAddress == (unsigned int)&myVertexTrack) {
|
347 |
naodell |
1.24 |
associatedTrackSumPt.at(vCount) += myVertexTrack.pt()/sumTrackPt;
|
348 |
|
|
++nAssociatedTracks;
|
349 |
|
|
}
|
350 |
|
|
}
|
351 |
naodell |
1.23 |
}
|
352 |
naodell |
1.24 |
}
|
353 |
|
|
++vCount;
|
354 |
|
|
}
|
355 |
|
|
|
356 |
|
|
double maxSumPtFraction = 0;
|
357 |
|
|
vCount = vertexIndex = 0;
|
358 |
|
|
|
359 |
naodell |
1.26 |
for (vector<double>::const_iterator iTrackSumPt = associatedTrackSumPt.begin(); iTrackSumPt != associatedTrackSumPt.end(); ++iTrackSumPt) {
|
360 |
|
|
if (*iTrackSumPt > maxSumPtFraction) {
|
361 |
naodell |
1.24 |
maxSumPtFraction = *iTrackSumPt;
|
362 |
|
|
vertexIndex = vCount + 1;
|
363 |
|
|
}
|
364 |
|
|
++vCount;
|
365 |
|
|
}
|
366 |
naodell |
1.26 |
if (vertexIndex > 0) {
|
367 |
naodell |
1.24 |
h1_jetVertexZ->Fill(vtxPositionCollection[vertexIndex-1].z());
|
368 |
|
|
}
|
369 |
|
|
jetCon->SetVtxSumPt(maxSumPtFraction);
|
370 |
|
|
jetCon->SetVtxIndex(vertexIndex);
|
371 |
|
|
|
372 |
|
|
h1_fracAssociatedTracks->Fill((double)nAssociatedTracks/(double)nJetTracks);
|
373 |
|
|
h1_associatedSumPt->Fill(maxSumPtFraction);
|
374 |
|
|
h1_associatedVertexIndex->Fill(vertexIndex);
|
375 |
|
|
h2_nAssTracksVsJetPt->Fill(myJet.pt(), nAssociatedTracks);
|
376 |
naodell |
1.23 |
}
|
377 |
naodell |
1.24 |
}
|
378 |
naodell |
1.16 |
++pfCount;
|
379 |
naodell |
1.4 |
}
|
380 |
|
|
}
|
381 |
naodell |
1.1 |
}
|
382 |
naodell |
1.26 |
|
383 |
|
|
|
384 |
|
|
///////////////////
|
385 |
|
|
// Get muon info //
|
386 |
|
|
///////////////////
|
387 |
|
|
|
388 |
|
|
|
389 |
|
|
Handle<MuonCollection> muons;
|
390 |
|
|
iEvent.getByLabel(muonTag_,muons);
|
391 |
|
|
|
392 |
|
|
int muCount = 0;
|
393 |
|
|
for (MuonCollection::const_iterator mu = muons->begin(); mu != muons->end(); ++mu) {
|
394 |
|
|
if (mu->isGlobalMuon() && mu->pt() > 8){
|
395 |
|
|
TCMuon* lepCon = new ((*recoMuons)[muCount]) TCMuon;
|
396 |
|
|
lepCon->Setp4(mu->px(), mu->py(), mu->pz(), mu->p());
|
397 |
|
|
lepCon->SetVtx(mu->globalTrack()->vx(),mu->globalTrack()->vy(),mu->globalTrack()->vz());
|
398 |
|
|
lepCon->SetEta(mu->eta());
|
399 |
|
|
lepCon->SetPhi(mu->phi());
|
400 |
|
|
lepCon->SetCharge(mu->charge());
|
401 |
|
|
lepCon->SetisGLB(mu->isGlobalMuon());
|
402 |
|
|
lepCon->SetisTRK(mu->isTrackerMuon());
|
403 |
|
|
lepCon->Setdxy(mu->globalTrack()->dxy(vertexBeamSpot.position()));
|
404 |
|
|
lepCon->SetnPXLHits(mu->globalTrack()->hitPattern().numberOfValidPixelHits());
|
405 |
|
|
lepCon->SetnTRKHits(mu->globalTrack()->hitPattern().numberOfValidTrackerHits());
|
406 |
|
|
lepCon->SetnValidMuHits(mu->globalTrack()->hitPattern().numberOfValidMuonHits());
|
407 |
|
|
lepCon->SetnMatchSeg(mu->numberOfMatches());
|
408 |
|
|
lepCon->SetNormChi2(mu->globalTrack()->normalizedChi2());
|
409 |
|
|
lepCon->SetCaloComp(mu->caloCompatibility());
|
410 |
|
|
lepCon->SetSegComp(muon::segmentCompatibility(*mu));
|
411 |
|
|
lepCon->SetEMIso(mu->isolationR03().emEt);
|
412 |
|
|
lepCon->SetHADIso(mu->isolationR03().hadEt);
|
413 |
|
|
lepCon->SetTRKIso(mu->isolationR03().sumPt);
|
414 |
|
|
muCount++;
|
415 |
|
|
}
|
416 |
|
|
}
|
417 |
|
|
|
418 |
naodell |
1.1 |
|
419 |
naodell |
1.26 |
///////////////////////
|
420 |
|
|
// Get electron info //
|
421 |
|
|
///////////////////////
|
422 |
|
|
|
423 |
|
|
|
424 |
|
|
Handle<edm::ValueMap<float> > eIDValueMap;
|
425 |
|
|
iEvent.getByLabel( electronIDMap_ , eIDValueMap );
|
426 |
|
|
const edm::ValueMap<float> & eIDmap = * eIDValueMap ;
|
427 |
|
|
|
428 |
|
|
Handle<GsfElectronCollection> electrons;
|
429 |
|
|
iEvent.getByLabel(electronTag_,electrons);
|
430 |
|
|
|
431 |
|
|
int elCount = 0;
|
432 |
|
|
for (unsigned int i = 0; i < electrons->size(); i++){
|
433 |
|
|
edm::Ref<reco::GsfElectronCollection> electronRef(electrons,i);
|
434 |
|
|
if ( eIDmap[electronRef] == 7 && electronRef->pt() > 15){
|
435 |
|
|
TCElectron* lepCon = new ((*recoElectrons)[elCount]) TCElectron;
|
436 |
|
|
lepCon->Setp4(electronRef->px(),electronRef->py(),electronRef->pz(),electronRef->p());
|
437 |
|
|
lepCon->SetVtx(electronRef->gsfTrack()->vx(),electronRef->gsfTrack()->vy(),electronRef->gsfTrack()->vz());
|
438 |
|
|
lepCon->SetCharge(electronRef->charge());
|
439 |
|
|
lepCon->SetEta(electronRef->eta());
|
440 |
|
|
lepCon->SetPhi(electronRef->phi());
|
441 |
|
|
lepCon->Setdxy(electronRef->gsfTrack()->dxy(vertexBeamSpot.position()));
|
442 |
|
|
lepCon->SetNormChi2(electronRef->gsfTrack()->normalizedChi2());
|
443 |
|
|
lepCon->SetEMIso(electronRef->dr03EcalRecHitSumEt());
|
444 |
|
|
lepCon->SetHADIso(electronRef->dr03HcalTowerSumEt());
|
445 |
|
|
lepCon->SetTRKIso(electronRef->dr03TkSumPt());
|
446 |
|
|
elCount++;
|
447 |
|
|
}
|
448 |
|
|
}
|
449 |
|
|
|
450 |
|
|
|
451 |
|
|
////////////////////////
|
452 |
|
|
// Get gen-level info //
|
453 |
|
|
////////////////////////
|
454 |
|
|
|
455 |
|
|
|
456 |
|
|
if (!isRealData) {
|
457 |
naodell |
1.1 |
|
458 |
naodell |
1.24 |
Handle<GenEventInfoProduct> GenEventInfoHandle;
|
459 |
|
|
iEvent.getByLabel("generator", GenEventInfoHandle);
|
460 |
|
|
Handle<GenRunInfoProduct> GenRunInfoHandle;
|
461 |
|
|
iEvent.getByLabel("generator", GenRunInfoHandle);
|
462 |
naodell |
1.1 |
Handle<reco::GenJetCollection> GenJets;
|
463 |
naodell |
1.26 |
iEvent.getByLabel(genJetTag_, GenJets);
|
464 |
naodell |
1.18 |
|
465 |
naodell |
1.24 |
ptHat = qScale = -1; crossSection = 0;
|
466 |
naodell |
1.18 |
|
467 |
naodell |
1.26 |
if (GenEventInfoHandle.isValid()) {
|
468 |
naodell |
1.24 |
qScale = GenEventInfoHandle->qScale();
|
469 |
|
|
ptHat = (GenEventInfoHandle->hasBinningValues() ? GenEventInfoHandle->binningValues()[0] : 0.0);
|
470 |
|
|
}
|
471 |
naodell |
1.26 |
if (GenRunInfoHandle.isValid()) {
|
472 |
naodell |
1.24 |
crossSection = GenRunInfoHandle->crossSection();
|
473 |
naodell |
1.18 |
}
|
474 |
naodell |
1.16 |
|
475 |
naodell |
1.26 |
for (GenJetCollection::const_iterator jet_iter = GenJets->begin(); jet_iter!= GenJets->end(); ++jet_iter) {
|
476 |
|
|
reco::GenJet myJet = reco::GenJet(*jet_iter);
|
477 |
|
|
if (myJet.pt() > 5) {
|
478 |
naodell |
1.25 |
|
479 |
naodell |
1.26 |
TCGenJet* jetCon = new ((*genJets)[genCount]) TCGenJet;
|
480 |
naodell |
1.25 |
jetCon->SetP4(myJet.px(), myJet.py(), myJet.pz(), myJet.energy());
|
481 |
|
|
jetCon->SetHadEnergy(myJet.hadEnergy());
|
482 |
|
|
jetCon->SetEmEnergy(myJet.emEnergy());
|
483 |
|
|
jetCon->SetInvEnergy(myJet.invisibleEnergy());
|
484 |
|
|
jetCon->SetAuxEnergy(myJet.auxiliaryEnergy());
|
485 |
|
|
jetCon->SetNumConstit(myJet.getGenConstituents().size());
|
486 |
naodell |
1.24 |
|
487 |
naodell |
1.26 |
/*const reco::GenParticle *myGenParticle = myJet.getGenConstituent(0);
|
488 |
naodell |
1.24 |
|
489 |
naodell |
1.26 |
if(myGenParticle->numberOfMothers() == 1)
|
490 |
naodell |
1.24 |
{
|
491 |
naodell |
1.26 |
const reco::Candidate *myMother = myGenParticle->mother();
|
492 |
|
|
int nGrandMas = myMother->numberOfMothers();
|
493 |
|
|
|
494 |
|
|
for(int iter = 0; nGrandMas != 0 ; ++iter)
|
495 |
|
|
{
|
496 |
|
|
myMother = myMother->mother();
|
497 |
|
|
nGrandMas = myMother->mother()->numberOfMothers();
|
498 |
|
|
//cout<<myMother->pdgId()<<endl;
|
499 |
|
|
}
|
500 |
|
|
//if(nGrandMas == 0) jetCon->SetJetFlavor((int)myMother->pdgId()); else jetCon->SetJetFlavor(0);
|
501 |
|
|
}*/
|
502 |
|
|
++genCount;
|
503 |
naodell |
1.1 |
}
|
504 |
naodell |
1.13 |
}
|
505 |
naodell |
1.1 |
}
|
506 |
naodell |
1.10 |
|
507 |
naodell |
1.16 |
///////////////////////////
|
508 |
|
|
//get trigger information//
|
509 |
|
|
///////////////////////////
|
510 |
andrey |
1.2 |
|
511 |
naodell |
1.26 |
if (triggerHLT_) {
|
512 |
andrey |
1.2 |
|
513 |
naodell |
1.7 |
edm::Handle<TriggerResults> hltR;
|
514 |
naodell |
1.26 |
triggerResultsTag_ = InputTag(hlTriggerResults_,"",hltProcess_);
|
515 |
naodell |
1.7 |
iEvent.getByLabel(triggerResultsTag_,hltR);
|
516 |
naodell |
1.26 |
|
517 |
naodell |
1.7 |
const TriggerNames & triggerNames = iEvent.triggerNames(*hltR);
|
518 |
naodell |
1.26 |
hlNames=triggerNames.triggerNames();
|
519 |
|
|
|
520 |
|
|
bool triggerPassed = false;
|
521 |
|
|
triggerStatus = 0x0;
|
522 |
|
|
string MPI_TriggerNames[] = {"HLT_QuadJet15U",
|
523 |
|
|
"HLT_DiJetAve50U",
|
524 |
|
|
"HLT_DiJetAve30U",
|
525 |
|
|
"HLT_DiJetAve15U",
|
526 |
naodell |
1.24 |
"HLT_FwdJet20U",
|
527 |
naodell |
1.26 |
"HLT_Jet100U",
|
528 |
|
|
"HLT_Jet70U",
|
529 |
naodell |
1.24 |
"HLT_Jet50U",
|
530 |
|
|
"HLT_Jet30U",
|
531 |
|
|
"HLT_Jet15U",
|
532 |
|
|
"HLT_BTagMu_Jet10U",
|
533 |
|
|
"HLT_DoubleJet15U_ForwardBackward",
|
534 |
|
|
"HLT_BTagIP_Jet50U",
|
535 |
|
|
"HLT_DoubleLooseIsoTau15",
|
536 |
|
|
"HLT_SingleLooseIsoTau20",
|
537 |
|
|
"HLT_HT100U",
|
538 |
|
|
"HLT_MET100",
|
539 |
|
|
"HLT_MET45"};
|
540 |
naodell |
1.26 |
|
541 |
|
|
for (int i=0; i < (int)hlNames.size(); ++i) {
|
542 |
|
|
triggerPassed = triggerDecision(hltR, i);
|
543 |
|
|
if(triggerPassed){
|
544 |
|
|
for (int j = 0; j < 17; ++j){
|
545 |
|
|
if (hlNames[i] == MPI_TriggerNames[j]) {
|
546 |
naodell |
1.24 |
triggerStatus |= 0x01 << j;
|
547 |
|
|
}
|
548 |
naodell |
1.7 |
}
|
549 |
naodell |
1.4 |
}
|
550 |
naodell |
1.7 |
}
|
551 |
|
|
}
|
552 |
naodell |
1.14 |
|
553 |
naodell |
1.24 |
if((pfCount > 1 || genCount > 1) && vtxCount > 0) sTree -> Fill();
|
554 |
naodell |
1.15 |
|
555 |
naodell |
1.26 |
recoJets->Clear();
|
556 |
|
|
recoElectrons->Clear();
|
557 |
|
|
recoMuons->Clear();
|
558 |
naodell |
1.5 |
primaryVtx->Clear();
|
559 |
naodell |
1.26 |
genJets->Clear();
|
560 |
naodell |
1.1 |
}
|
561 |
|
|
|
562 |
|
|
// ------------ method called once each job just before starting event loop ------------
|
563 |
|
|
void MPIntuple::beginJob()
|
564 |
naodell |
1.26 |
{
|
565 |
naodell |
1.24 |
ntupleFile = new TFile(rootfilename.c_str(), "RECREATE");
|
566 |
|
|
sTree = new TTree("mpiTree", "Tree for Jets");
|
567 |
naodell |
1.15 |
|
568 |
naodell |
1.24 |
h1_fracAssociatedTracks = new TH1D("h1_fracAssociatedTracks", "Fraction of associated jet tracks", 20, 0.0, 1.0);
|
569 |
|
|
h1_trackDxy = new TH1D("h1_trackDxy", "dxy for all associated tracks", 50, -0.4, 0.4);
|
570 |
|
|
h1_meanJetTrackZ = new TH1D("h1_meanJetTrackZ", "<z> from jet tracks", 50, -25.0, 25.0);
|
571 |
|
|
h1_jetVertexZ = new TH1D("h1_jetVertexZ", "z for vertex associated to jet", 50, -25.0, 25.0);
|
572 |
|
|
h1_associatedSumPt = new TH1D("h1_associatedSumPt", "ratio of sum p_{T} between associatedTracks and jetTracks", 20, 0.0, 1.0);
|
573 |
|
|
h1_associatedVertexIndex = new TH1D("h1_associatedVertex", "number of jets associated to primary vertex", 5, -0.5, 4.5);
|
574 |
|
|
h2_nAssTracksVsJetPt = new TH2F("h2_nAssTracksVsJetPt", "nTracks vs Jet p_{T}", 50, 0, 100, 20, -0.5, 19.5);
|
575 |
|
|
p1_nVtcs = new TProfile("p1_nVtcs", "<N> per run", 5200.0, 132300.0, 137500.0, 0.0, 6.0);
|
576 |
|
|
|
577 |
naodell |
1.26 |
recoJets = new TClonesArray("TCJet");
|
578 |
|
|
recoElectrons = new TClonesArray("TCElectron");
|
579 |
|
|
recoMuons = new TClonesArray("TCMuon");
|
580 |
|
|
genJets = new TClonesArray("TCGenJet");
|
581 |
naodell |
1.24 |
primaryVtx = new TClonesArray("TCPrimaryVtx");
|
582 |
naodell |
1.1 |
|
583 |
naodell |
1.26 |
sTree->Branch("recoJets",&recoJets, 6400, 0);
|
584 |
|
|
sTree->Branch("recoElectrons",&recoElectrons, 6400, 0);
|
585 |
|
|
sTree->Branch("recoMuons",&recoMuons, 6400, 0);
|
586 |
|
|
sTree->Branch("genJets",&genJets, 6400, 0);
|
587 |
naodell |
1.5 |
sTree->Branch("primaryVtx",&primaryVtx, 6400, 0);
|
588 |
naodell |
1.1 |
sTree->Branch("eventNumber",&eventNumber, "eventNumber/I");
|
589 |
|
|
sTree->Branch("runNumber",&runNumber, "runNumber/I");
|
590 |
|
|
sTree->Branch("lumiSection",&lumiSection, "lumiSection/I");
|
591 |
naodell |
1.6 |
sTree->Branch("triggerStatus",&triggerStatus, "triggerStatus/i");
|
592 |
naodell |
1.8 |
sTree->Branch("isRealData",&isRealData, "isRealData/i");
|
593 |
|
|
sTree->Branch("bunchCross",&bunchCross, "bunchCross/i");
|
594 |
naodell |
1.18 |
sTree->Branch("ptHat",&ptHat, "ptHat/d");
|
595 |
naodell |
1.24 |
sTree->Branch("qScale", &qScale, "qScale/d");
|
596 |
|
|
sTree->Branch("crossSection", &crossSection, "crossSection/d");
|
597 |
naodell |
1.1 |
}
|
598 |
|
|
|
599 |
naodell |
1.26 |
void MPIntuple::beginRun(const edm::Run& iRun, const edm::EventSetup& iEvent)
|
600 |
|
|
{
|
601 |
|
|
bool changed = true;
|
602 |
|
|
hltConfig_.init(iRun, iEvent, hltProcess_, changed);
|
603 |
|
|
|
604 |
|
|
}
|
605 |
|
|
|
606 |
|
|
void MPIntuple::endLuminosityBlock(const edm::LuminosityBlock& iLumi, const edm::EventSetup& iEvent)
|
607 |
|
|
{
|
608 |
|
|
edm::Handle<LumiSummary> lumiSummary;
|
609 |
|
|
iLumi.getByLabel("lumiProducer", lumiSummary);
|
610 |
|
|
|
611 |
|
|
|
612 |
|
|
}
|
613 |
|
|
|
614 |
|
|
void MPIntuple::endRun(const edm::Run& iRun, const edm::EventSetup& iEvent)
|
615 |
|
|
{
|
616 |
|
|
|
617 |
|
|
}
|
618 |
naodell |
1.1 |
// ------------ method called once each job just after ending the event loop ------------
|
619 |
|
|
void MPIntuple::endJob()
|
620 |
|
|
{
|
621 |
naodell |
1.15 |
|
622 |
naodell |
1.17 |
ntupleFile->cd();
|
623 |
|
|
|
624 |
naodell |
1.24 |
h1_fracAssociatedTracks->Write();
|
625 |
|
|
h1_meanJetTrackZ->Write();
|
626 |
naodell |
1.16 |
h1_trackDxy->Write();
|
627 |
naodell |
1.24 |
h1_jetVertexZ->Write();
|
628 |
|
|
h1_associatedSumPt->Write();
|
629 |
|
|
h1_associatedVertexIndex->Write();
|
630 |
naodell |
1.16 |
h2_nAssTracksVsJetPt->Write();
|
631 |
naodell |
1.15 |
p1_nVtcs->Write();
|
632 |
|
|
|
633 |
naodell |
1.1 |
ntupleFile->Write();
|
634 |
|
|
ntupleFile->Close();
|
635 |
|
|
|
636 |
|
|
}
|
637 |
|
|
|
638 |
|
|
|
639 |
andrey |
1.2 |
bool MPIntuple::triggerDecision(edm::Handle<edm::TriggerResults> &hltR, int iTrigger)
|
640 |
|
|
{
|
641 |
|
|
bool triggerPassed = false;
|
642 |
|
|
if(hltR->wasrun(iTrigger) &&
|
643 |
|
|
hltR->accept(iTrigger) &&
|
644 |
|
|
!hltR->error(iTrigger) ){
|
645 |
|
|
triggerPassed = true;
|
646 |
|
|
}
|
647 |
|
|
return triggerPassed;
|
648 |
naodell |
1.16 |
}
|
649 |
|
|
|
650 |
|
|
double MPIntuple::sumPtSquared(const Vertex & v)
|
651 |
|
|
{
|
652 |
|
|
double sum = 0.;
|
653 |
|
|
double pT;
|
654 |
|
|
for (Vertex::trackRef_iterator it = v.tracks_begin(); it != v.tracks_end(); it++) {
|
655 |
|
|
pT = (**it).pt();
|
656 |
|
|
double epT=(**it).ptError(); pT=pT>epT ? pT-epT : 0;
|
657 |
|
|
|
658 |
|
|
sum += pT*pT;
|
659 |
andrey |
1.2 |
}
|
660 |
naodell |
1.16 |
return sum;
|
661 |
|
|
}
|
662 |
andrey |
1.2 |
|
663 |
naodell |
1.1 |
//define this as a plug-in
|
664 |
|
|
DEFINE_FWK_MODULE(MPIntuple);
|