12 |
|
*/ |
13 |
|
// |
14 |
|
// Original Author: "Geng-yuan Jeng/UC Riverside" |
15 |
+ |
// "Yanyan Gao/Fermilab ygao@fnal.gov" |
16 |
|
// Created: Thu Aug 20 11:55:40 CDT 2009 |
17 |
|
// $Id$ |
18 |
|
// |
25 |
|
#include <vector> |
26 |
|
#include <iostream> |
27 |
|
#include <sstream> |
28 |
+ |
#include <algorithm> |
29 |
|
|
30 |
|
// user include files |
31 |
|
#include "FWCore/Framework/interface/Frameworkfwd.h" |
61 |
|
|
62 |
|
using namespace std; |
63 |
|
|
64 |
< |
PVStudy::PVStudy(const edm::ParameterSet& iConfig): |
63 |
< |
nTrkMin_(10),nTrkMax_(100) |
64 |
> |
PVStudy::PVStudy(const edm::ParameterSet& iConfig) |
65 |
|
{ |
66 |
+ |
//======================================================================= |
67 |
+ |
// Get configuration for TrackTupleMaker |
68 |
+ |
//======================================================================= |
69 |
|
simG4_ = iConfig.getParameter<edm::InputTag>( "simG4" ); |
70 |
< |
tracksLabel_ = iConfig.getUntrackedParameter<edm::InputTag>("tracks"); |
71 |
< |
vtxSample_ = iConfig.getUntrackedParameter<edm::InputTag>("vtxSample"); |
72 |
< |
verbose_ = iConfig.getUntrackedParameter<bool>("verbose", false); |
70 |
> |
trackCollectionTag_ = iConfig.getUntrackedParameter<edm::InputTag>("trackCollection"); |
71 |
> |
splitTrackCollection1Tag_ = iConfig.getUntrackedParameter<edm::InputTag>("splitTrackCollection1"); |
72 |
> |
splitTrackCollection2Tag_ = iConfig.getUntrackedParameter<edm::InputTag>("splitTrackCollection2"); |
73 |
> |
vertexCollectionTag_ = iConfig.getUntrackedParameter<edm::InputTag>("vertexCollection"); |
74 |
> |
splitVertexCollection1Tag_ = iConfig.getUntrackedParameter<edm::InputTag>("splitVertexCollection1"); |
75 |
> |
splitVertexCollection2Tag_ = iConfig.getUntrackedParameter<edm::InputTag>("splitVertexCollection2"); |
76 |
> |
pixelVertexCollectionTag_ = iConfig.getParameter<edm::InputTag>("pixelVertexCollectionTag"); |
77 |
> |
verbose_ = iConfig.getUntrackedParameter<bool>("verbose",false); |
78 |
|
realData_ = iConfig.getUntrackedParameter<bool>("realData",false); |
79 |
|
analyze_ = iConfig.getUntrackedParameter<bool>("analyzeOnTheFly",false); |
80 |
< |
outputfilename_ = iConfig.getUntrackedParameter<string>("OutputFileName"); |
80 |
> |
saventuple_ = iConfig.getUntrackedParameter<bool>("saventuple",false); |
81 |
> |
outputfilename_ = iConfig.getUntrackedParameter<string>("OutputFileName"); |
82 |
> |
ntrkdiffcut_ = iConfig.getUntrackedParameter<double>("ntrkdiffcut"); |
83 |
> |
zsigncut_ = iConfig.getUntrackedParameter<int>("zsigncut"); |
84 |
> |
nTrkMin_ = iConfig.getUntrackedParameter<int>("nTrkMin"); |
85 |
> |
nTrkMax_ = iConfig.getUntrackedParameter<int>("nTrkMax"); |
86 |
|
|
87 |
|
//now do what ever initialization is needed |
88 |
|
pvinfo.clear(); |
89 |
|
|
76 |
– |
file_ = TFile::Open(outputfilename_.c_str(),"RECREATE"); |
77 |
– |
ftree_ = new TTree("mytree","mytree"); |
78 |
– |
ftree_->AutoSave(); |
79 |
– |
ftree_->Branch("residual",&fres,"fres[3]/D"); |
80 |
– |
ftree_->Branch("error",&ferror,"ferror[3]/D"); |
81 |
– |
ftree_->Branch("nTrk",&fntrk,"fntrk/I"); |
90 |
|
|
91 |
+ |
// Specify the data mode vector |
92 |
+ |
if(realData_) datamode.push_back(0); |
93 |
+ |
else { |
94 |
+ |
datamode.push_back(0); |
95 |
+ |
datamode.push_back(1); |
96 |
+ |
datamode.push_back(2); |
97 |
+ |
datamode.push_back(3); |
98 |
+ |
} |
99 |
+ |
|
100 |
+ |
// Create ntuple files if needed |
101 |
+ |
if(saventuple_) { |
102 |
+ |
file_ = TFile::Open(outputfilename_.c_str(),"RECREATE"); |
103 |
+ |
ftree_ = new TTree("mytree","mytree"); |
104 |
+ |
ftree_->AutoSave(); |
105 |
+ |
ftree_->Branch("residual",&fres_,"fres_[3]/D"); |
106 |
+ |
ftree_->Branch("error",&ferror_,"ferror_[3]/D"); |
107 |
+ |
ftree_->Branch("nTrkPV",&fntrk_,"fntrk_/I"); |
108 |
+ |
|
109 |
+ |
// pvtxtree_ analyzing the pvtxs ootb |
110 |
+ |
pvtxtree_ = new TTree("pvtxtree","pvtxtree"); |
111 |
+ |
//pvtx using all tracks |
112 |
+ |
pvtxtree_->Branch("nrecPV",&nrecPV_,"nrecPV/I"); |
113 |
+ |
pvtxtree_->Branch("nTrkPV",&nTrkPV_,"nTrkPV[nrecPV]/I"); |
114 |
+ |
pvtxtree_->Branch("sumptsq",&sumptsq_,"sumptsq[nrecPV]/D"); |
115 |
+ |
pvtxtree_->Branch("isValid",&isValid_,"isValid/I"); |
116 |
+ |
pvtxtree_->Branch("isFake",&isFake_,"isFake/I"); |
117 |
+ |
pvtxtree_->Branch("recx",&recx_,"recx[nrecPV]/D"); |
118 |
+ |
pvtxtree_->Branch("recy",&recy_,"recy[nrecPV]/D"); |
119 |
+ |
pvtxtree_->Branch("recz",&recz_,"recz[nrecPV]/D"); |
120 |
+ |
pvtxtree_->Branch("recx_err",&recx_err_,"recx_err[nrecPV]/D"); |
121 |
+ |
pvtxtree_->Branch("recy_err",&recy_err_,"recy_err[nrecPV]/D"); |
122 |
+ |
pvtxtree_->Branch("recz_err",&recz_err_,"recz_err[nrecPV]/D"); |
123 |
+ |
|
124 |
+ |
pvtxtree_->Branch("min_zsep",&min_zsep_,"min_zsep/D"); |
125 |
+ |
pvtxtree_->Branch("min_ntrksep",&min_ntrksep_,"min_ntrksep/D"); |
126 |
+ |
pvtxtree_->Branch("min_sumpt2sep",&min_sumpt2sep_,"min_sumpt2sep/D"); |
127 |
+ |
|
128 |
+ |
//pvtx using splittracks1 |
129 |
+ |
pvtxtree_->Branch("nrecPV1_spl",&nrecPV1_spl_,"nrecPV1_spl/I"); |
130 |
+ |
pvtxtree_->Branch("nTrkPV1_spl",&nTrkPV1_spl_,"nTrkPV1_spl[nrecPV1_spl]/I"); |
131 |
+ |
pvtxtree_->Branch("sumptsq1_spl",&sumptsq1_spl_,"sumptsq1_spl[nrecPV1_spl]/D"); |
132 |
+ |
pvtxtree_->Branch("isValid1_spl",&isValid1_spl_,"isValid1_spl/I"); |
133 |
+ |
pvtxtree_->Branch("isFake1_spl",&isFake1_spl_,"isFake1_spl/I"); |
134 |
+ |
pvtxtree_->Branch("recx1_spl",&recx1_spl_,"recx1_spl[nrecPV1_spl]/D"); |
135 |
+ |
pvtxtree_->Branch("recy1_spl",&recy1_spl_,"recy1_spl[nrecPV1_spl]/D"); |
136 |
+ |
pvtxtree_->Branch("recz1_spl",&recz1_spl_,"recz1_spl[nrecPV1_spl]/D"); |
137 |
+ |
pvtxtree_->Branch("recx1_err_spl",&recx1_err_spl_,"recx1_err_spl[nrecPV1_spl]/D"); |
138 |
+ |
pvtxtree_->Branch("recy1_err_spl",&recy1_err_spl_,"recy1_err_spl[nrecPV1_spl]/D"); |
139 |
+ |
pvtxtree_->Branch("recz1_err_spl",&recz1_err_spl_,"recz1_err_spl[nrecPV1_spl]/D"); |
140 |
+ |
|
141 |
+ |
//pvtx using splittracks2 |
142 |
+ |
pvtxtree_->Branch("nrecPV2_spl",&nrecPV2_spl_,"nrecPV2_spl/I"); |
143 |
+ |
pvtxtree_->Branch("nTrkPV2_spl",&nTrkPV2_spl_,"nTrkPV2_spl[nrecPV2_spl]/I"); |
144 |
+ |
pvtxtree_->Branch("sumptsq2_spl",&sumptsq2_spl_,"sumptsq2_spl[nrecPV2_spl]/D"); |
145 |
+ |
pvtxtree_->Branch("isValid2_spl",&isValid2_spl_,"isValid2_spl/I"); |
146 |
+ |
pvtxtree_->Branch("isFake2_spl",&isFake2_spl_,"isFake2_spl/I"); |
147 |
+ |
pvtxtree_->Branch("recx2_spl",&recx2_spl_,"recx2_spl[nrecPV2_spl]/D"); |
148 |
+ |
pvtxtree_->Branch("recy2_spl",&recy2_spl_,"recy2_spl[nrecPV2_spl]/D"); |
149 |
+ |
pvtxtree_->Branch("recz2_spl",&recz2_spl_,"recz2_spl[nrecPV2_spl]/D"); |
150 |
+ |
pvtxtree_->Branch("recx2_err_spl",&recx2_err_spl_,"recx2_err_spl[nrecPV2_spl]/D"); |
151 |
+ |
pvtxtree_->Branch("recy2_err_spl",&recy2_err_spl_,"recy2_err_spl[nrecPV2_spl]/D"); |
152 |
+ |
pvtxtree_->Branch("recz2_err_spl",&recz2_err_spl_,"recz2_err_spl[nrecPV2_spl]/D"); |
153 |
+ |
|
154 |
+ |
//Fill the variables in the twovtx pair (recvtx1, recvtx2) |
155 |
+ |
pvtxtree_->Branch("nrecPV_twovtx",&nrecPV_twovtx_,"nrecPV_twovtx/I"); |
156 |
+ |
pvtxtree_->Branch("nTrkPV1_spl_twovtx",&nTrkPV1_spl_twovtx_,"nTrkPV1_spl_twovtx[nrecPV_twovtx]/I"); |
157 |
+ |
pvtxtree_->Branch("nTrkPV2_spl_twovtx",&nTrkPV2_spl_twovtx_,"nTrkPV2_spl_twovtx[nrecPV_twovtx]/I"); |
158 |
+ |
pvtxtree_->Branch("sumptsq1_spl_twovtx",&sumptsq1_spl_twovtx_,"sumptsq1_spl_twovtx[nrecPV_twovtx]/D"); |
159 |
+ |
pvtxtree_->Branch("sumptsq2_spl_twovtx",&sumptsq2_spl_twovtx_,"sumptsq2_spl_twovtx[nrecPV_twovtx]/D"); |
160 |
+ |
pvtxtree_->Branch("nTrkPV_twovtx",&nTrkPV_twovtx_,"nTrkPV_twovtx[nrecPV_twovtx]/I"); |
161 |
+ |
pvtxtree_->Branch("deltax_twovtx",&deltax_twovtx_,"deltax_twovtx[nrecPV_twovtx]/D"); |
162 |
+ |
pvtxtree_->Branch("deltay_twovtx",&deltay_twovtx_,"deltay_twovtx[nrecPV_twovtx]/D"); |
163 |
+ |
pvtxtree_->Branch("deltaz_twovtx",&deltaz_twovtx_,"deltaz_twovtx[nrecPV_twovtx]/D"); |
164 |
+ |
pvtxtree_->Branch("errx_twovtx",&errx_twovtx_,"errx_twovtx[nrecPV_twovtx]/D"); |
165 |
+ |
pvtxtree_->Branch("erry_twovtx",&erry_twovtx_,"erry_twovtx[nrecPV_twovtx]/D"); |
166 |
+ |
pvtxtree_->Branch("errz_twovtx",&errz_twovtx_,"errz_twovtx[nrecPV_twovtx]/D"); |
167 |
+ |
pvtxtree_->Branch("pullx_twovtx",&pullx_twovtx_,"pullx_twovtx[nrecPV_twovtx]/D"); |
168 |
+ |
pvtxtree_->Branch("pully_twovtx",&pully_twovtx_,"pully_twovtx[nrecPV_twovtx]/D"); |
169 |
+ |
pvtxtree_->Branch("pullz_twovtx",&pullz_twovtx_,"pullz_twovtx[nrecPV_twovtx]/D"); |
170 |
+ |
|
171 |
+ |
// MC variables |
172 |
+ |
if(!realData_) { |
173 |
+ |
pvtxtree_->Branch("nsimPV",&nsimPV_,"nsimPV/I"); |
174 |
+ |
pvtxtree_->Branch("nsimTrkPV",&nsimTrkPV_,"nsimTrkPV[nsimPV]/I"); |
175 |
+ |
pvtxtree_->Branch("simx",&simx_,"simx[nsimPV]/D"); |
176 |
+ |
pvtxtree_->Branch("simy",&simy_,"simy[nsimPV]/D"); |
177 |
+ |
pvtxtree_->Branch("simz",&simz_,"simz[nsimPV]/D"); |
178 |
+ |
pvtxtree_->Branch("simptsq",&simptsq_,"simptsq[nsimPV]/D"); |
179 |
+ |
|
180 |
+ |
// For pvtxs with all the tracks |
181 |
+ |
pvtxtree_->Branch("nrecPV_mct",&nrecPV_mct_,"nrecPV_mct/I"); |
182 |
+ |
pvtxtree_->Branch("deltax_mct",&deltax_mct_,"deltax_mct[nrecPV_mct]/D"); |
183 |
+ |
pvtxtree_->Branch("deltay_mct",&deltay_mct_,"deltay_mct[nrecPV_mct]/D"); |
184 |
+ |
pvtxtree_->Branch("deltaz_mct",&deltaz_mct_,"deltaz_mct[nrecPV_mct]/D"); |
185 |
+ |
pvtxtree_->Branch("pullx_mct",&pullx_mct_,"pullx_mct[nrecPV_mct]/D"); |
186 |
+ |
pvtxtree_->Branch("pully_mct",&pully_mct_,"pully_mct[nrecPV_mct]/D"); |
187 |
+ |
pvtxtree_->Branch("pullz_mct",&pullz_mct_,"pullz_mct[nrecPV_mct]/D"); |
188 |
+ |
// For pvtxs with splittracks1 |
189 |
+ |
pvtxtree_->Branch("nrecPV_spl1_mct",&nrecPV_spl1_mct_,"nrecPV_spl1_mct/I"); |
190 |
+ |
pvtxtree_->Branch("deltax_spl1_mct",&deltax_spl1_mct_,"deltax_spl1_mct[nrecPV_spl1_mct]/D"); |
191 |
+ |
pvtxtree_->Branch("deltay_spl1_mct",&deltay_spl1_mct_,"deltay_spl1_mct[nrecPV_spl1_mct]/D"); |
192 |
+ |
pvtxtree_->Branch("deltaz_spl1_mct",&deltaz_spl1_mct_,"deltaz_spl1_mct[nrecPV_spl1_mct]/D"); |
193 |
+ |
pvtxtree_->Branch("pullx_spl1_mct",&pullx_spl1_mct_,"pullx_spl1_mct[nrecPV_spl1_mct]/D"); |
194 |
+ |
pvtxtree_->Branch("pully_spl1_mct",&pully_spl1_mct_,"pully_spl1_mct[nrecPV_spl1_mct]/D"); |
195 |
+ |
pvtxtree_->Branch("pullz_spl1_mct",&pullz_spl1_mct_,"pullz_spl1_mct[nrecPV_spl1_mct]/D"); |
196 |
+ |
// For pvtxs with splittracks1 |
197 |
+ |
pvtxtree_->Branch("nrecPV_spl2_mct",&nrecPV_spl2_mct_,"nrecPV_spl2_mct/I"); |
198 |
+ |
pvtxtree_->Branch("deltax_spl2_mct",&deltax_spl2_mct_,"deltax_spl2_mct[nrecPV_spl2_mct]/D"); |
199 |
+ |
pvtxtree_->Branch("deltay_spl2_mct",&deltay_spl2_mct_,"deltay_spl2_mct[nrecPV_spl2_mct]/D"); |
200 |
+ |
pvtxtree_->Branch("deltaz_spl2_mct",&deltaz_spl2_mct_,"deltaz_spl2_mct[nrecPV_spl2_mct]/D"); |
201 |
+ |
pvtxtree_->Branch("pullx_spl2_mct",&pullx_spl2_mct_,"pullx_spl2_mct[nrecPV_spl2_mct]/D"); |
202 |
+ |
pvtxtree_->Branch("pully_spl2_mct",&pully_spl2_mct_,"pully_spl2_mct[nrecPV_spl2_mct]/D"); |
203 |
+ |
pvtxtree_->Branch("pullz_spl2_mct",&pullz_spl2_mct_,"pullz_spl2_mct[nrecPV_spl2_mct]/D"); |
204 |
+ |
} |
205 |
+ |
} |
206 |
+ |
|
207 |
|
edm::Service<TFileService> fs; |
208 |
|
TFileDirectory subDir = fs->mkdir( "Summary" ); |
209 |
|
TFileDirectory subDir1 = fs->mkdir( "Others" ); |
210 |
|
// TFileDirectory subSubDir = subDir.mkdir( "mySubSubDirectory" ); |
211 |
|
|
212 |
|
setRootStyle(); |
213 |
< |
|
214 |
< |
h["nTrk"] = subDir.make<TH1F>("nTrk","Num of total tracks",300,0,300); |
215 |
< |
h["nTrkPV"] = subDir.make<TH1F>("nTrkPV","Num of Tracks from PV",300,0,300); |
216 |
< |
h["trkPt"] = subDir.make<TH1D>("trkPt","Pt of all tracks",100,0,100); |
217 |
< |
h["trkPtPV"] = subDir.make<TH1D>("trkPtPV","Pt dist of tracks from PV",100,0,100); |
218 |
< |
|
219 |
< |
if (!realData_) { |
220 |
< |
h["deltax"] = subDir.make<TH1D>("deltax","x-distance (Rec - Sim)",800,-0.04,0.04); |
221 |
< |
h["deltay"] = subDir.make<TH1D>("deltay","y-distance (Rec - Sim)",800,-0.04,0.04); |
222 |
< |
h["deltaz"] = subDir.make<TH1D>("deltaz","z-distance (Rec - Sim)",800,-0.04,0.04); |
223 |
< |
h["pullx"] = subDir.make<TH1D>("pullx","x-pull (Rec - Sim)",1000,-25.,25.); |
224 |
< |
h["pully"] = subDir.make<TH1D>("pully","y-pull (Rec - Sim)",1000,-25.,25.); |
225 |
< |
h["pullz"] = subDir.make<TH1D>("pullz","z-pull (Rec - Sim)",1000,-25.,25.); |
226 |
< |
h["errPVx"] = subDir.make<TH1D>("errPVx","X vertex error",100,0.,0.02); |
227 |
< |
h["errPVy"] = subDir.make<TH1D>("errPVy","Y vertex error",100,0.,0.02); |
228 |
< |
h["errPVz"] = subDir.make<TH1D>("errPVz","Z vertex error",100,0.,0.02); |
229 |
< |
|
230 |
< |
// Summary of analysis: |
231 |
< |
if (analyze_) { |
232 |
< |
h2["resx_nTrk"]= subDir.make<TH2D>("resx_ntrk","x-resolution (Rec - Sim) vs number of tracks",150,0,150,400,0.,200); |
233 |
< |
h2["resx_nTrk"]->SetMarkerStyle(21); |
234 |
< |
h2["resx_nTrk"]->SetMarkerColor(4); |
235 |
< |
h2["resx_nTrk"]->GetXaxis()->SetTitle("Num of tracks"); |
236 |
< |
h2["resx_nTrk"]->GetYaxis()->SetTitle("#mum"); |
237 |
< |
h2["resy_nTrk"]= subDir.make<TH2D>("resy_ntrk","y-resolution (Rec - Sim) vs number of tracks",150,0,150,400,0.,200); |
238 |
< |
h2["resy_nTrk"]->SetMarkerStyle(21); |
239 |
< |
h2["resy_nTrk"]->SetMarkerColor(4); |
240 |
< |
h2["resy_nTrk"]->GetXaxis()->SetTitle("Num of tracks"); |
241 |
< |
h2["resy_nTrk"]->GetYaxis()->SetTitle("#mum"); |
242 |
< |
h2["resz_nTrk"]= subDir.make<TH2D>("resz_ntrk","z-resolution (Rec - Sim) vs number of tracks",150,0,150,400,0.,200); |
243 |
< |
h2["resz_nTrk"]->SetMarkerStyle(21); |
120 |
< |
h2["resz_nTrk"]->SetMarkerColor(4); |
121 |
< |
h2["resz_nTrk"]->GetXaxis()->SetTitle("Num of tracks"); |
122 |
< |
h2["resz_nTrk"]->GetYaxis()->SetTitle("#mum"); |
123 |
< |
h2["pullx_nTrk"]= subDir.make<TH2D>("pullx_ntrk","x-pull (Rec - Sim) vs number of tracks",150,0,150,100,0.,2.); |
124 |
< |
h2["pullx_nTrk"]->SetMarkerStyle(21); |
125 |
< |
h2["pullx_nTrk"]->SetMarkerColor(4); |
126 |
< |
h2["pullx_nTrk"]->SetBit(TH1::kCanRebin); |
127 |
< |
h2["pullx_nTrk"]->GetXaxis()->SetTitle("Num of tracks"); |
128 |
< |
h2["pully_nTrk"]= subDir.make<TH2D>("pully_ntrk","y-pull (Rec - Sim) vs number of tracks",150,0,150,100,0.,2.); |
129 |
< |
h2["pully_nTrk"]->SetMarkerStyle(21); |
130 |
< |
h2["pully_nTrk"]->SetMarkerColor(4); |
131 |
< |
h2["pully_nTrk"]->SetBit(TH1::kCanRebin); |
132 |
< |
h2["pully_nTrk"]->GetXaxis()->SetTitle("Num of tracks"); |
133 |
< |
h2["pullz_nTrk"]= subDir.make<TH2D>("pullz_ntrk","z-pull (Rec - Sim) vs number of tracks",150,0,150,100,0.,2.); |
134 |
< |
h2["pullz_nTrk"]->SetMarkerStyle(21); |
135 |
< |
h2["pullz_nTrk"]->SetMarkerColor(4); |
136 |
< |
h2["pullz_nTrk"]->SetBit(TH1::kCanRebin); |
137 |
< |
h2["pullz_nTrk"]->GetXaxis()->SetTitle("Num of tracks"); |
213 |
> |
|
214 |
> |
//Book histograms for track and pvtx parameters for each splitted pvtx |
215 |
> |
//i=0 : x (as in unsplit track collection) |
216 |
> |
//i=1 : x1_spl_ |
217 |
> |
//i=2 : x2_spl_ |
218 |
> |
|
219 |
> |
|
220 |
> |
for(int i=0;i<3;i++) |
221 |
> |
{ |
222 |
> |
string suffix; |
223 |
> |
if(i == 0) suffix = ""; |
224 |
> |
else { |
225 |
> |
stringstream ss; |
226 |
> |
ss << i; |
227 |
> |
suffix =ss.str()+"_spl"; |
228 |
> |
} |
229 |
> |
h["nTrk"+suffix] = subDir.make<TH1D>(TString("nTrk"+suffix), TString("Num of rec tracks"+suffix),300,0,300); |
230 |
> |
h["trkPt"+suffix] = subDir.make<TH1D>(TString("trkPt"+suffix), TString("Pt of rec tracks "+suffix),100,0,100); |
231 |
> |
h["trkEta"+suffix] = subDir.make<TH1D>(TString("trkEta"+suffix), TString("#eta of rec tracks "+suffix),100,-3,3); |
232 |
> |
h["trkPhi"+suffix] = subDir.make<TH1D>(TString("trkPhi"+suffix), TString("#Phi of rec tracks "+suffix),100,-3.2,3.2); |
233 |
> |
h["trkDxy"+suffix] = subDir.make<TH1D>(TString("trkDxy"+suffix), TString("Dxy of rec tracks "+suffix),100,-0.5,0.5); |
234 |
> |
h["trkDz"+suffix] = subDir.make<TH1D>(TString("trkDz"+suffix), TString("Dz of rec tracks "+suffix),100,-50,50); |
235 |
> |
|
236 |
> |
h["nTrkPV"+suffix] = subDir.make<TH1D>(TString("nTrkPV"+suffix), TString("Num of rec tracks in PV"+suffix),300,0,300); |
237 |
> |
h["trkPtPV"+suffix] = subDir.make<TH1D>(TString("trkPtPV"+suffix), TString("Pt of rec tracks in "+suffix),100,0,100); |
238 |
> |
h["trkEtaPV"+suffix] = subDir.make<TH1D>(TString("trkEtaPV"+suffix), TString("#eta of rec tracks in PV"+suffix),100,-3,3); |
239 |
> |
h["trkPhiPV"+suffix] = subDir.make<TH1D>(TString("trkPhiPV"+suffix), TString("#Phi of rec tracks in PV"+suffix),100,-3.2,3.2); |
240 |
> |
h["trkDxyPV"+suffix] = subDir.make<TH1D>(TString("trkDxyPV"+suffix), TString("Dxy of rec tracks in PV"+suffix),100,-5,5); |
241 |
> |
h["trkDzPV"+suffix] = subDir.make<TH1D>(TString("trkDzPV"+suffix), TString("Dz of rec tracks "+suffix),100,-50,50); |
242 |
> |
h["nrecPV"+suffix] = subDir.make<TH1D>(TString("nrecPV"+suffix), TString("Num of rec pvtx"+suffix),50,0,50); |
243 |
> |
suffix.clear(); |
244 |
|
} |
245 |
+ |
h["nrecPVDiff"] = subDir.make<TH1D>("nrecPVDiff","nrecPV1-nRecPV2",21,-10.5,10.5); |
246 |
+ |
h["nTrkPVDiff"] = subDir.make<TH1D>("nTrkPVDiff","nTrkPV1-nTrkPV2",41,-20.5,20.5); |
247 |
+ |
h["nTrkPVRelDiff"] = subDir.make<TH1D>("nTrkPVRelDiff","(nTrkPV1-nTrkPV2)/(nTrkPV1+nTrkPV2)",100,-1,1); |
248 |
+ |
|
249 |
+ |
// Histograms on comparing the multi-vertices |
250 |
+ |
// Difference in reconstructed vtx position |
251 |
+ |
h["min_xsep"] = subDir.make<TH1D>("min_xsep", "min x diff of primary and secondary pvtx",300,0,0.1); |
252 |
+ |
h["min_xsep_sign"] = subDir.make<TH1D>("min_xsep_sign", "min x diff in signf of primary and secondary pvtx",300,0,5); |
253 |
+ |
h["min_ysep"] = subDir.make<TH1D>("min_ysep", "min y diff of primary and secondary pvtx",300,0,0.1); |
254 |
+ |
h["min_ysep_sign"] = subDir.make<TH1D>("min_ysep_sign", "min y diff in signf of primary and secondary pvtx",300,0,5); |
255 |
+ |
h["min_zsep"] = subDir.make<TH1D>("min_zsep", "min z diff of primary and secondary pvtx",300,0,5); |
256 |
+ |
h["min_zsep_sign"] = subDir.make<TH1D>("min_zsep_sign", "min z diff in signf of primary and secondary pvtx",300,0,200); |
257 |
+ |
// Difference in reconstructed vtx position |
258 |
+ |
h["min_ntrksep"] = subDir.make<TH1D>("min_ntrksep", "min nTrk diff of primary and secondary pvtx",201,-50.5,150.5); |
259 |
+ |
h["min_sumpt2sep"] = subDir.make<TH1D>("min_sumpt2sep", "min sumpt2 diff of primary and secondary pvtx",300,0,10000); |
260 |
+ |
|
261 |
+ |
//Book histograms sensitive to data/mc |
262 |
+ |
for (vector<int>::const_iterator it= datamode.begin(); it != datamode.end() ; ++it) { |
263 |
+ |
string suffix; |
264 |
+ |
if(verbose_) cout<<"datamode = "<< *it<<endl; |
265 |
+ |
switch(*it) { |
266 |
+ |
case 0: suffix = ""; |
267 |
+ |
break; |
268 |
+ |
case 1: suffix = "_spl1_mct"; |
269 |
+ |
break; |
270 |
+ |
case 2: suffix = "_spl2_mct"; |
271 |
+ |
break; |
272 |
+ |
case 3: suffix = "_mct"; |
273 |
+ |
break; |
274 |
+ |
} |
275 |
+ |
h["deltax"+suffix] = subDir.make<TH1D>(TString("deltax"+suffix), TString("x-residual pvtx"+suffix),800,-0.04,0.04); |
276 |
+ |
h["deltay"+suffix] = subDir.make<TH1D>(TString("deltay"+suffix), TString("y-residual pvtx"+suffix),800,-0.04,0.04); |
277 |
+ |
h["deltaz"+suffix] = subDir.make<TH1D>(TString("deltaz"+suffix), TString("z-residual pvtx"+suffix),800,-0.04,0.04); |
278 |
+ |
h["pullx"+suffix] = subDir.make<TH1D>(TString("pullx"+suffix), TString("x-pull pvtx"+suffix),800,-10,10); |
279 |
+ |
h["pully"+suffix] = subDir.make<TH1D>(TString("pully"+suffix), TString("y-pull pvtx"+suffix),800,-10,10); |
280 |
+ |
h["pullz"+suffix] = subDir.make<TH1D>(TString("pullz"+suffix), TString("z-pull pvtx"+suffix),800,-10,10); |
281 |
+ |
h["errPVx"+suffix] = subDir.make<TH1D>(TString("errPVx"+suffix), TString("X"+suffix+" vertex error"),100,0.,0.02); |
282 |
+ |
h["errPVy"+suffix] = subDir.make<TH1D>(TString("errPVy"+suffix), TString("Y"+suffix+" vertex error"),100,0.,0.02); |
283 |
+ |
h["errPVz"+suffix] = subDir.make<TH1D>(TString("errPVz"+suffix), TString("Z"+suffix+" vertex error"),100,0.,0.02); |
284 |
+ |
|
285 |
+ |
// Book residual, error and pull histograms for each nTrk bin |
286 |
|
for (int ntrk=nTrkMin_;ntrk<=nTrkMax_;++ntrk) { |
287 |
|
stringstream ss; |
288 |
|
ss << ntrk; |
289 |
< |
string suffix = ss.str(); |
290 |
< |
h["resx_"+suffix] = fs->make<TH1D>(TString("deltax_"+suffix),"x-distance (Rec - Sim)",100,-0.02,0.02); |
291 |
< |
h["resx_"+suffix]->GetXaxis()->SetTitle("cm"); |
292 |
< |
h["resy_"+suffix] = fs->make<TH1D>(TString("deltay_"+suffix),"y-distance (Rec - Sim)",100,-0.02,0.02); |
293 |
< |
h["resy_"+suffix]->GetXaxis()->SetTitle("cm"); |
294 |
< |
h["resz_"+suffix] = fs->make<TH1D>(TString("deltaz_"+suffix),"z-distance (Rec - Sim)",100,-0.02,0.02); |
295 |
< |
h["resz_"+suffix]->GetXaxis()->SetTitle("cm"); |
296 |
< |
h["pullx_"+suffix] = fs->make<TH1D>(TString("pullx_"+suffix),"x-pull (Rec - Sim)",100,-10.,10.); |
297 |
< |
h["pully_"+suffix] = fs->make<TH1D>(TString("pully_"+suffix),"y-pull (Rec - Sim)",100,-10.,10.); |
298 |
< |
h["pullz_"+suffix] = fs->make<TH1D>(TString("pullz_"+suffix),"z-pull (Rec - Sim)",100,-10.,10.); |
299 |
< |
h["errPVx_"+suffix] = subDir1.make<TH1D>(TString("errPVx_"+suffix),"X vertex error",100,0.,0.02); |
300 |
< |
h["errPVy_"+suffix] = subDir1.make<TH1D>(TString("errPVy_"+suffix),"Y vertex error",100,0.,0.02); |
301 |
< |
h["errPVz_"+suffix] = subDir1.make<TH1D>(TString("errPVz_"+suffix),"Z vertex error",100,0.,0.02); |
302 |
< |
suffix.clear(); |
303 |
< |
} |
289 |
> |
string suffix2 = suffix+"_"+ss.str(); |
290 |
> |
h["deltax"+suffix2] = subDir1.make<TH1D>(TString("deltax"+suffix2), TString("x-residual of pvtx"+suffix),100,-0.02,0.02); |
291 |
> |
h["deltax"+suffix2]->GetXaxis()->SetTitle("cm"); |
292 |
> |
h["deltay"+suffix2] = subDir1.make<TH1D>(TString("deltay"+suffix2), TString("y-residual of pvtx"+suffix),100,-0.02,0.02); |
293 |
> |
h["deltay"+suffix2]->GetXaxis()->SetTitle("cm"); |
294 |
> |
h["deltaz"+suffix2] = subDir1.make<TH1D>(TString("deltaz"+suffix2), TString("z-residual of pvtx"+suffix),100,-0.02,0.02); |
295 |
> |
h["deltaz"+suffix2]->GetXaxis()->SetTitle("cm"); |
296 |
> |
h["pullx"+suffix2] = subDir1.make<TH1D>(TString("pullx"+suffix2), TString("x-pull of pvtx"+suffix),100,-10.,10.); |
297 |
> |
h["pully"+suffix2] = subDir1.make<TH1D>(TString("pully"+suffix2), TString("y-pull of pvtx"+suffix),100,-10.,10.); |
298 |
> |
h["pullz"+suffix2] = subDir1.make<TH1D>(TString("pullz"+suffix2), TString("z-pull of pvtx"+suffix),100,-10.,10.); |
299 |
> |
h["errPVx"+suffix2] = subDir1.make<TH1D>(TString("errPVx"+suffix2), TString("X"+suffix+" vertex error"),100,0.,0.02); |
300 |
> |
h["errPVy"+suffix2] = subDir1.make<TH1D>(TString("errPVy"+suffix2), TString("Y"+suffix+" vertex error"),100,0.,0.02); |
301 |
> |
h["errPVz"+suffix2] = subDir1.make<TH1D>(TString("errPVz"+suffix2), TString("Z"+suffix+" vertex error"),100,0.,0.02); |
302 |
> |
suffix2.clear(); |
303 |
> |
} // End of for (int ntrk=nTrkMin_;ntrk<=nTrkMax_;++ntrk) { |
304 |
> |
|
305 |
> |
// Book residual and pull histograms only when analyzeOntheFly is enabled |
306 |
> |
if(analyze_) { |
307 |
> |
h2["resx"+suffix+"_nTrk"]= subDir.make<TH2D>(TString("resx"+suffix+"_nTrk"), TString("x-resolution vs number of tracks in pvtx"+suffix),150,0,150,400,0.,200); |
308 |
> |
h2["resx"+suffix+"_nTrk"]->SetMarkerStyle(21); |
309 |
> |
h2["resx"+suffix+"_nTrk"]->SetMarkerColor(4); |
310 |
> |
h2["resx"+suffix+"_nTrk"]->GetXaxis()->SetTitle("Num of tracks"); |
311 |
> |
h2["resx"+suffix+"_nTrk"]->GetYaxis()->SetTitle("#mum"); |
312 |
> |
h2["resy"+suffix+"_nTrk"]= subDir.make<TH2D>(TString("resy"+suffix+"_nTrk"), TString("y-resolution vs number of tracks in pvtx"+suffix),150,0,150,400,0.,200); |
313 |
> |
h2["resy"+suffix+"_nTrk"]->SetMarkerStyle(21); |
314 |
> |
h2["resy"+suffix+"_nTrk"]->SetMarkerColor(4); |
315 |
> |
h2["resy"+suffix+"_nTrk"]->GetXaxis()->SetTitle("Num of tracks"); |
316 |
> |
h2["resy"+suffix+"_nTrk"]->GetYaxis()->SetTitle("#mum"); |
317 |
> |
h2["resz"+suffix+"_nTrk"]= subDir.make<TH2D>(TString("resz"+suffix+"_nTrk"), TString("z-resolution vs number of tracks in pvtx"+suffix),150,0,150,400,0.,200); |
318 |
> |
h2["resz"+suffix+"_nTrk"]->SetMarkerStyle(21); |
319 |
> |
h2["resz"+suffix+"_nTrk"]->SetMarkerColor(4); |
320 |
> |
h2["resz"+suffix+"_nTrk"]->GetXaxis()->SetTitle("Num of tracks"); |
321 |
> |
h2["resz"+suffix+"_nTrk"]->GetYaxis()->SetTitle("#mum"); |
322 |
> |
h2["pullx"+suffix+"_nTrk"]= subDir.make<TH2D>(TString("pullx"+suffix+"_nTrk"), TString("x-pull vs number of tracks"+suffix),150,0,150,100,0.,2.); |
323 |
> |
h2["pullx"+suffix+"_nTrk"]->SetMarkerStyle(21); |
324 |
> |
h2["pullx"+suffix+"_nTrk"]->SetMarkerColor(4); |
325 |
> |
h2["pullx"+suffix+"_nTrk"]->SetBit(TH1::kCanRebin); |
326 |
> |
h2["pullx"+suffix+"_nTrk"]->GetXaxis()->SetTitle("Num of tracks"); |
327 |
> |
h2["pully"+suffix+"_nTrk"]= subDir.make<TH2D>(TString("pully"+suffix+"_nTrk"), TString("y-pull vs number of tracks"+suffix),150,0,150,100,0.,2.); |
328 |
> |
h2["pully"+suffix+"_nTrk"]->SetMarkerStyle(21); |
329 |
> |
h2["pully"+suffix+"_nTrk"]->SetMarkerColor(4); |
330 |
> |
h2["pully"+suffix+"_nTrk"]->SetBit(TH1::kCanRebin); |
331 |
> |
h2["pully"+suffix+"_nTrk"]->GetXaxis()->SetTitle("Num of tracks"); |
332 |
> |
h2["pullz"+suffix+"_nTrk"]= subDir.make<TH2D>(TString("pullz"+suffix+"_nTrk"), TString("x-pull vs number of tracks"+suffix),150,0,150,100,0.,2.); |
333 |
> |
h2["pullz"+suffix+"_nTrk"]->SetMarkerStyle(21); |
334 |
> |
h2["pullz"+suffix+"_nTrk"]->SetMarkerColor(4); |
335 |
> |
h2["pullz"+suffix+"_nTrk"]->SetBit(TH1::kCanRebin); |
336 |
> |
h2["pullz"+suffix+"_nTrk"]->GetXaxis()->SetTitle("Num of tracks"); |
337 |
> |
} // End of if(analyze_) { |
338 |
> |
suffix.clear(); |
339 |
> |
} // End of Book histograms sensitive to data/mc |
340 |
> |
|
341 |
> |
// Book histograms about pixelVertices |
342 |
> |
h["trkdz_pxlpvtxdz"] = subDir.make<TH1D>("trkdz_pxlpvtxdz", "(Track dz - pixelpvtx dz) in cm",300,-0.5,0.5); |
343 |
> |
h["trkdz_pxlpvtxdz_pxlpvtxdzerr"] = subDir.make<TH1D>("trkdz_pxlpvtxdz_pxlpvtxdzerr", "|Track dz - pixelpvtx dz| / pxlpvtxdzErr",300,0,100); |
344 |
> |
h["trkdz_pxlpvtxdz_trkdzerr"] = subDir.make<TH1D>("trkdz_pxlpvtxdz_trkdzerr", "|Track dz - pixelpvtx dz| / trkdzErr",300,0,50); |
345 |
> |
h["trkdzErr_pxlpvtx"] = subDir.make<TH1D>("trkdzErr_pxlpvtxdz", "Track dzErr of leading pixelpvtx ",300,0,0.5); |
346 |
> |
h["trkdzErr_pvtx"] = subDir.make<TH1D>("trkdzErr_pvtx", "Track dzErr of the leading pvtx ",300,0,0.5); |
347 |
> |
h["dzErr_pxlpvtx"] = subDir.make<TH1D>("dzErr_pxlpvtx", "zError of the leading pvtx ",300,0,0.5); |
348 |
> |
|
349 |
> |
// Book MC only plots |
350 |
> |
if (!realData_) { |
351 |
> |
h["genPart_T"] = subDir.make<TH1D>("genPart_T","t component of gen particles",300,-0.5,0.5); |
352 |
> |
h["genPart_T"]->GetXaxis()->SetTitle("t (nanosecond)"); |
353 |
> |
h["genPart_cT"] = subDir.make<TH1D>("genPart_cT","ct component of gen particles",300,-150.,150.); |
354 |
> |
h["genPart_cT"]->GetXaxis()->SetTitle("ct (mm)"); |
355 |
> |
h["nsimPV"] = subDir.make<TH1D>("nsimPV","Num of sim PV",51,-0.5,50.5); |
356 |
|
} |
357 |
|
} |
358 |
|
|
160 |
– |
|
359 |
|
PVStudy::~PVStudy() |
360 |
|
{ |
361 |
|
|
408 |
|
cout << "number of vertices " << evt->vertices_size() << endl; |
409 |
|
} |
410 |
|
|
411 |
< |
int idx=0; |
411 |
> |
int idx=0; int npv=0; |
412 |
|
for(HepMC::GenEvent::vertex_const_iterator vitr= evt->vertices_begin(); |
413 |
< |
vitr != evt->vertices_end(); ++vitr ) |
414 |
< |
{ // loop for vertex ... |
415 |
< |
HepMC::FourVector pos = (*vitr)->position(); |
416 |
< |
//HepLorentzVector pos = (*vitr)->position(); |
417 |
< |
if (pos.t()>0) { continue;} // ? |
418 |
< |
|
419 |
< |
bool hasMotherVertex=false; |
420 |
< |
// if(verbose_) cout << "mothers" << endl; |
421 |
< |
for ( HepMC::GenVertex::particle_iterator mother = (*vitr)->particles_begin(HepMC::parents); |
422 |
< |
mother != (*vitr)->particles_end(HepMC::parents); ++mother ) { |
423 |
< |
HepMC::GenVertex * mv=(*mother)->production_vertex(); |
424 |
< |
if (mv) {hasMotherVertex=true;} |
425 |
< |
// if(verbose_) { |
426 |
< |
// cout << "\t"; |
229 |
< |
// (*mother)->print(); |
230 |
< |
// } |
231 |
< |
} |
232 |
< |
|
233 |
< |
if(hasMotherVertex) {continue;} |
234 |
< |
|
235 |
< |
// could be a new vertex, check all primaries found so far to avoid multiple entries |
236 |
< |
const double mm2cm=0.1; |
237 |
< |
simPrimaryVertex sv(pos.x()*mm2cm,pos.y()*mm2cm,pos.z()*mm2cm); // sim unit mm, rec unit cm |
238 |
< |
simPrimaryVertex *vp=NULL; // will become non-NULL if a vertex is found and then point to it |
239 |
< |
for(vector<simPrimaryVertex>::iterator v0=simpv.begin(); |
240 |
< |
v0!=simpv.end(); v0++){ |
241 |
< |
if( (fabs(sv.x-v0->x)<1e-5) && (fabs(sv.y-v0->y)<1e-5) && (fabs(sv.z-v0->z)<1e-5)){ |
242 |
< |
vp=&(*v0); |
243 |
< |
break; |
413 |
> |
vitr != evt->vertices_end(); ++vitr ) { // loop for vertex ... |
414 |
> |
HepMC::FourVector pos = (*vitr)->position(); |
415 |
> |
//HepLorentzVector pos = (*vitr)->position(); |
416 |
> |
|
417 |
> |
// t component of PV: |
418 |
> |
for ( HepMC::GenVertex::particle_iterator mother = (*vitr)->particles_begin(HepMC::parents); |
419 |
> |
mother != (*vitr)->particles_end(HepMC::parents); ++mother ) { |
420 |
> |
// std::cout << "Status = " << (*mother)->status() << std::endl; |
421 |
> |
HepMC::GenVertex * mv=(*mother)->production_vertex(); |
422 |
> |
if( ((*mother)->status() == 3) && (!mv)) { |
423 |
> |
// std::cout << "npv= " << npv << std::endl; |
424 |
> |
if (npv == 0) { |
425 |
> |
h["genPart_cT"]->Fill(pos.t()); // mm |
426 |
> |
h["genPart_T"]->Fill(pos.t()/299.792458); // ns |
427 |
|
} |
428 |
+ |
npv++; |
429 |
+ |
} |
430 |
+ |
} |
431 |
+ |
// if (pos.t()>0) { continue;} // for 22X when t of PV was not smeared |
432 |
+ |
|
433 |
+ |
bool hasMotherVertex=false; |
434 |
+ |
if(verbose_) cout << "mothers of vertex[" << ++idx << "]: " << endl; |
435 |
+ |
for ( HepMC::GenVertex::particle_iterator mother = (*vitr)->particles_begin(HepMC::parents); |
436 |
+ |
mother != (*vitr)->particles_end(HepMC::parents); ++mother ) { |
437 |
+ |
HepMC::GenVertex * mv=(*mother)->production_vertex(); |
438 |
+ |
// std::cout << "Status = " << (*mother)->status() << std::endl; |
439 |
+ |
if (mv) { |
440 |
+ |
hasMotherVertex=true; |
441 |
+ |
if(!verbose_) break; //if verbose_, print all particles of gen vertices |
442 |
+ |
} |
443 |
+ |
if(verbose_) { |
444 |
+ |
cout << "\t"; |
445 |
+ |
(*mother)->print(); |
446 |
|
} |
447 |
+ |
} |
448 |
|
|
449 |
< |
if(!vp){ |
450 |
< |
// this is a new vertex |
451 |
< |
if(verbose_) cout << "this is a new vertex " << sv.x << " " << sv.y << " " << sv.z << endl; |
452 |
< |
simpv.push_back(sv); |
453 |
< |
vp=&simpv.back(); |
454 |
< |
}else{ |
455 |
< |
if(verbose_) cout << "this is not a new vertex " << sv.x << " " << sv.y << " " << sv.z << endl; |
456 |
< |
} |
457 |
< |
vp->genVertex.push_back((*vitr)->barcode()); |
458 |
< |
// collect final state descendants |
459 |
< |
for ( HepMC::GenVertex::particle_iterator |
460 |
< |
daughter = (*vitr)->particles_begin(HepMC::descendants); |
461 |
< |
daughter != (*vitr)->particles_end(HepMC::descendants); |
462 |
< |
++daughter ) { |
463 |
< |
if (isFinalstateParticle(*daughter)){ |
464 |
< |
if ( find(vp->finalstateParticles.begin(), vp->finalstateParticles.end(),(*daughter)->barcode()) |
465 |
< |
== vp->finalstateParticles.end()){ |
466 |
< |
vp->finalstateParticles.push_back((*daughter)->barcode()); |
467 |
< |
HepMC::FourVector m=(*daughter)->momentum(); |
468 |
< |
// the next four lines used to be "vp->ptot+=m;" in the days of CLHEP::HepLorentzVector |
469 |
< |
// but adding FourVectors seems not to be foreseen |
470 |
< |
vp->ptot.setPx(vp->ptot.px()+m.px()); |
471 |
< |
vp->ptot.setPy(vp->ptot.py()+m.py()); |
472 |
< |
vp->ptot.setPz(vp->ptot.pz()+m.pz()); |
473 |
< |
vp->ptot.setE(vp->ptot.e()+m.e()); |
474 |
< |
vp->ptsq+=(m.perp())*(m.perp()); |
475 |
< |
if ( (m.perp()>0.8) && (fabs(m.pseudoRapidity())<2.5) && isCharged( *daughter ) ){ |
476 |
< |
vp->nGenTrk++; |
477 |
< |
} |
449 |
> |
if(hasMotherVertex) continue; |
450 |
> |
|
451 |
> |
// could be a new vertex, check all primaries found so far to avoid multiple entries |
452 |
> |
const double mm2cm=0.1; |
453 |
> |
simPrimaryVertex sv(pos.x()*mm2cm,pos.y()*mm2cm,pos.z()*mm2cm); // sim unit mm, rec unit cm |
454 |
> |
simPrimaryVertex *vp=NULL; // will become non-NULL if a vertex is found and then point to it |
455 |
> |
for(vector<simPrimaryVertex>::iterator v0=simpv.begin(); |
456 |
> |
v0!=simpv.end(); v0++){ |
457 |
> |
if( (fabs(sv.x-v0->x)<1e-5) && (fabs(sv.y-v0->y)<1e-5) && (fabs(sv.z-v0->z)<1e-5)){ |
458 |
> |
vp=&(*v0); |
459 |
> |
break; |
460 |
> |
} |
461 |
> |
} |
462 |
> |
|
463 |
> |
if(!vp){ |
464 |
> |
// this is a new vertex |
465 |
> |
if(verbose_) cout << "this is a new vertex " << sv.x << " " << sv.y << " " << sv.z << endl; |
466 |
> |
simpv.push_back(sv); |
467 |
> |
vp=&simpv.back(); |
468 |
> |
}else{ |
469 |
> |
if(verbose_) cout << "this is not a new vertex " << sv.x << " " << sv.y << " " << sv.z << endl; |
470 |
> |
} |
471 |
> |
vp->genVertex.push_back((*vitr)->barcode()); |
472 |
> |
// collect final state descendants |
473 |
> |
for ( HepMC::GenVertex::particle_iterator daughter = (*vitr)->particles_begin(HepMC::descendants); |
474 |
> |
daughter != (*vitr)->particles_end(HepMC::descendants); |
475 |
> |
++daughter ) { |
476 |
> |
if (isFinalstateParticle(*daughter)){ |
477 |
> |
if ( find(vp->finalstateParticles.begin(), vp->finalstateParticles.end(),(*daughter)->barcode()) |
478 |
> |
== vp->finalstateParticles.end()){ |
479 |
> |
vp->finalstateParticles.push_back((*daughter)->barcode()); |
480 |
> |
HepMC::FourVector m=(*daughter)->momentum(); |
481 |
> |
// the next four lines used to be "vp->ptot+=m;" in the days of CLHEP::HepLorentzVector |
482 |
> |
// but adding FourVectors seems not to be foreseen |
483 |
> |
vp->ptot.setPx(vp->ptot.px()+m.px()); |
484 |
> |
vp->ptot.setPy(vp->ptot.py()+m.py()); |
485 |
> |
vp->ptot.setPz(vp->ptot.pz()+m.pz()); |
486 |
> |
vp->ptot.setE(vp->ptot.e()+m.e()); |
487 |
> |
vp->ptsq+=(m.perp())*(m.perp()); |
488 |
> |
if ( (m.perp()>0.8) && (fabs(m.pseudoRapidity())<2.5) && isCharged( *daughter ) ){ |
489 |
> |
vp->nGenTrk++; |
490 |
|
} |
491 |
|
} |
492 |
|
} |
279 |
– |
idx++; |
493 |
|
} |
494 |
+ |
} |
495 |
|
} |
496 |
|
return simpv; |
497 |
|
} |
571 |
|
PVStudy::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) |
572 |
|
{ |
573 |
|
using namespace edm; |
574 |
< |
using reco::TrackCollection; |
574 |
> |
using namespace reco; |
575 |
> |
|
576 |
> |
if (verbose_) |
577 |
> |
cout<<"PVStudy::analyze():"<<endl; |
578 |
> |
//======================================================= |
579 |
> |
// Initialize Root-tuple variables if needed |
580 |
> |
//======================================================= |
581 |
> |
//if(saventuple_) |
582 |
> |
SetVarToZero(); |
583 |
> |
|
584 |
> |
//======================================================= |
585 |
> |
// Track accessors |
586 |
> |
//======================================================= |
587 |
> |
//trackCollection |
588 |
> |
static const reco::TrackCollection s_empty_trackColl; |
589 |
> |
const reco::TrackCollection *trackColl = &s_empty_trackColl; |
590 |
> |
edm::Handle<reco::TrackCollection> trackCollectionHandle; |
591 |
> |
iEvent.getByLabel(trackCollectionTag_, trackCollectionHandle); |
592 |
> |
if( iEvent.getByLabel(trackCollectionTag_, trackCollectionHandle)) { |
593 |
> |
trackColl = trackCollectionHandle.product(); |
594 |
> |
} else { |
595 |
> |
cout << "trackCollection cannot be found -> using empty collection of same type." <<endl; |
596 |
> |
} |
597 |
|
|
598 |
< |
ftree_->SetBranchAddress("residual",&fres); |
599 |
< |
ftree_->SetBranchAddress("error",&ferror); |
600 |
< |
ftree_->SetBranchAddress("nTrk",&fntrk); |
598 |
> |
//splitTrackCollection1 |
599 |
> |
static const reco::TrackCollection s_empty_splitTrackColl1; |
600 |
> |
const reco::TrackCollection *splitTrackColl1 = &s_empty_splitTrackColl1; |
601 |
> |
edm::Handle<reco::TrackCollection> splitTrackCollection1Handle; |
602 |
> |
iEvent.getByLabel(splitTrackCollection1Tag_, splitTrackCollection1Handle); |
603 |
> |
if( iEvent.getByLabel(splitTrackCollection1Tag_, splitTrackCollection1Handle)) { |
604 |
> |
splitTrackColl1 = splitTrackCollection1Handle.product(); |
605 |
> |
} else { |
606 |
> |
cout << "splitTrackCollection1 cannot be found -> using empty collection of same type." <<endl; |
607 |
> |
} |
608 |
|
|
609 |
< |
Handle<TrackCollection> tracks; |
610 |
< |
iEvent.getByLabel(tracksLabel_,tracks); |
609 |
> |
//splitTrackCollection2 |
610 |
> |
static const reco::TrackCollection s_empty_splitTrackColl2; |
611 |
> |
const reco::TrackCollection *splitTrackColl2 = &s_empty_splitTrackColl2; |
612 |
> |
edm::Handle<reco::TrackCollection> splitTrackCollection2Handle; |
613 |
> |
iEvent.getByLabel(splitTrackCollection2Tag_, splitTrackCollection2Handle); |
614 |
> |
if( iEvent.getByLabel(splitTrackCollection2Tag_, splitTrackCollection2Handle)) { |
615 |
> |
splitTrackColl2 = splitTrackCollection2Handle.product(); |
616 |
> |
} else { |
617 |
> |
cout << "splitTrackCollection2 cannot be found -> using empty collection of same type." <<endl; |
618 |
> |
} |
619 |
|
|
369 |
– |
Handle<reco::VertexCollection> recVtxs; |
370 |
– |
iEvent.getByLabel(vtxSample_, recVtxs); |
620 |
|
|
621 |
+ |
//======================================================= |
622 |
+ |
// Fill trackparameters of the input tracks to pvtx fitter |
623 |
+ |
//======================================================= |
624 |
+ |
if(verbose_) |
625 |
+ |
cout<<"Start filling track parameters of the input tracks to pvtx fitter."<<endl; |
626 |
+ |
//fillTrackHisto(const reco::TrackCollection *trackColl, int datatype) |
627 |
+ |
// datatype: unsplittracks (0); splittracks1 (1); splittracks2 (2); |
628 |
+ |
fillTrackHisto(trackColl, 0); |
629 |
+ |
fillTrackHisto(splitTrackColl1, 1); |
630 |
+ |
fillTrackHisto(splitTrackColl2, 2); |
631 |
+ |
if(verbose_) |
632 |
+ |
cout<<"End filling track parameters of the input tracks to pvtx fitter."<<endl; |
633 |
+ |
|
634 |
+ |
//======================================================= |
635 |
+ |
// PVTX accessors |
636 |
+ |
//======================================================= |
637 |
+ |
//vertexCollection |
638 |
+ |
static const reco::VertexCollection s_empty_vertexColl; |
639 |
+ |
const reco::VertexCollection *vertexColl = &s_empty_vertexColl; |
640 |
+ |
edm::Handle<reco::VertexCollection> vertexCollectionHandle; |
641 |
+ |
iEvent.getByLabel(vertexCollectionTag_, vertexCollectionHandle); |
642 |
+ |
if( iEvent.getByLabel(vertexCollectionTag_, vertexCollectionHandle)) { |
643 |
+ |
vertexColl = vertexCollectionHandle.product(); |
644 |
+ |
} else { |
645 |
+ |
cout << "vertexCollection cannot be found -> using empty collection of same type." <<endl; |
646 |
+ |
} |
647 |
+ |
|
648 |
+ |
//splitVertexCollection1 |
649 |
+ |
static const reco::VertexCollection s_empty_splitVertexColl1; |
650 |
+ |
const reco::VertexCollection *splitVertexColl1 = &s_empty_splitVertexColl1; |
651 |
+ |
edm::Handle<reco::VertexCollection> splitVertexCollection1Handle; |
652 |
+ |
iEvent.getByLabel(splitVertexCollection1Tag_, splitVertexCollection1Handle); |
653 |
+ |
if( iEvent.getByLabel(splitVertexCollection1Tag_, splitVertexCollection1Handle)) { |
654 |
+ |
splitVertexColl1 = splitVertexCollection1Handle.product(); |
655 |
+ |
} else { |
656 |
+ |
cout << "splitVertexCollection1 cannot be found -> using empty collection of same type." <<endl; |
657 |
+ |
} |
658 |
+ |
|
659 |
+ |
//splitVertexCollection2 |
660 |
+ |
static const reco::VertexCollection s_empty_splitVertexColl2; |
661 |
+ |
const reco::VertexCollection *splitVertexColl2 = &s_empty_splitVertexColl2; |
662 |
+ |
edm::Handle<reco::VertexCollection> splitVertexCollection2Handle; |
663 |
+ |
iEvent.getByLabel(splitVertexCollection2Tag_, splitVertexCollection2Handle); |
664 |
+ |
if( iEvent.getByLabel(splitVertexCollection2Tag_, splitVertexCollection2Handle)) { |
665 |
+ |
splitVertexColl2 = splitVertexCollection2Handle.product(); |
666 |
+ |
} else { |
667 |
+ |
cout << "splitVertexCollection2 cannot be found -> using empty collection of same type." <<endl; |
668 |
+ |
} |
669 |
+ |
|
670 |
+ |
if(verbose_) cout<<"End accessing the track and vertex collections"<<endl; |
671 |
+ |
|
672 |
+ |
//======================================================= |
673 |
+ |
// MC simvtx accessor |
674 |
+ |
//======================================================= |
675 |
|
if (!realData_) { |
676 |
< |
Handle<SimVertexContainer> simVtxs; |
676 |
> |
edm::Handle<SimVertexContainer> simVtxs; |
677 |
|
iEvent.getByLabel( simG4_, simVtxs); |
678 |
|
|
679 |
< |
Handle<SimTrackContainer> simTrks; |
679 |
> |
edm::Handle<SimTrackContainer> simTrks; |
680 |
|
iEvent.getByLabel( simG4_, simTrks); |
681 |
|
} |
682 |
|
|
683 |
< |
if(verbose_) printRecVtxs(recVtxs); |
684 |
< |
|
683 |
> |
//======================================================= |
684 |
> |
// GET PDT |
685 |
> |
//======================================================= |
686 |
|
try{ |
687 |
|
iSetup.getData(pdt); |
688 |
|
}catch(const Exception&){ |
689 |
|
cout << "Some problem occurred with the particle data table. This may not work !." <<endl; |
690 |
|
} |
691 |
+ |
|
692 |
+ |
//======================================================= |
693 |
+ |
// GET pixelVertices |
694 |
+ |
//======================================================= |
695 |
+ |
static const reco::VertexCollection s_empty_pixelVertexColl; |
696 |
+ |
const reco::VertexCollection *pixelVertexColl = &s_empty_pixelVertexColl; |
697 |
+ |
edm::Handle<reco::VertexCollection> pixelVertexCollectionHandle; |
698 |
+ |
iEvent.getByLabel(pixelVertexCollectionTag_, pixelVertexCollectionHandle); |
699 |
+ |
if( iEvent.getByLabel(pixelVertexCollectionTag_, pixelVertexCollectionHandle)) { |
700 |
+ |
pixelVertexColl = pixelVertexCollectionHandle.product(); |
701 |
+ |
} else { |
702 |
+ |
cout << "pixelVertexCollection cannot be found. -> using empty collection of same type." <<endl; |
703 |
+ |
} |
704 |
|
|
705 |
+ |
//======================================================= |
706 |
+ |
// Fill pixelVertices related histograms |
707 |
+ |
//======================================================= |
708 |
+ |
if(pixelVertexColl->size()>0 && pixelVertexColl->begin()->isValid() && !(pixelVertexColl->begin()->isFake())) { |
709 |
+ |
h["dzErr_pxlpvtx"]->Fill( pixelVertexColl->begin()->zError()); |
710 |
+ |
// Get the dZ error of the tracks in the leading pixelVertexColl |
711 |
+ |
for(reco::Vertex::trackRef_iterator t = (pixelVertexColl->begin())->tracks_begin(); |
712 |
+ |
t!= (pixelVertexColl->begin())->tracks_end(); t++) { |
713 |
+ |
|
714 |
+ |
if ( (**t).charge() < -1 || (**t).charge() > 1 ) { |
715 |
+ |
// h["trkPtPV"]->Fill(0.); |
716 |
+ |
} |
717 |
+ |
else |
718 |
+ |
h["trkdzErr_pxlpvtx"]->Fill((**t).dzError()); |
719 |
+ |
} |
720 |
+ |
// Fill the track->dz() in the PV difference from first pixelpvtx |
721 |
+ |
for(reco::Vertex::trackRef_iterator t = (vertexColl->begin())->tracks_begin(); |
722 |
+ |
t!= (vertexColl->begin())->tracks_end(); t++) { |
723 |
+ |
// illegal charge |
724 |
+ |
if ( (**t).charge() < -1 || (**t).charge() > 1 ) { |
725 |
+ |
// h["trkPtPV"]->Fill(0.); |
726 |
+ |
} |
727 |
+ |
else { |
728 |
+ |
if(pixelVertexColl->size()>0) { |
729 |
+ |
h["trkdz_pxlpvtxdz"]->Fill((**t).dz() - pixelVertexColl->begin()->z()); |
730 |
+ |
h["trkdz_pxlpvtxdz_pxlpvtxdzerr"]->Fill(fabs((**t).dz() - pixelVertexColl->begin()->z())/pixelVertexColl->begin()->zError()); |
731 |
+ |
h["trkdz_pxlpvtxdz_trkdzerr"]->Fill(fabs((**t).dz() - pixelVertexColl->begin()->z())/(**t).dzError()); |
732 |
+ |
h["trkdzErr_pvtx"]->Fill((**t).dzError()); |
733 |
+ |
} |
734 |
+ |
} |
735 |
+ |
} |
736 |
+ |
} |
737 |
+ |
|
738 |
+ |
|
739 |
+ |
//======================================================= |
740 |
+ |
// Fill number of reconstructed vertices ootb |
741 |
+ |
//======================================================= |
742 |
+ |
|
743 |
+ |
if(verbose_) { |
744 |
+ |
cout<<"PVStudy::analyze() Printing vertexCollection: "<<endl; |
745 |
+ |
printRecVtxs(vertexCollectionHandle); |
746 |
+ |
cout<<"PVStudy::analyze() Printing splitVertexCollection1: "<<endl; |
747 |
+ |
printRecVtxs(splitVertexCollection1Handle); |
748 |
+ |
cout<<"PVStudy::analyze() Printing splitVertexCollection2: "<<endl; |
749 |
+ |
printRecVtxs(splitVertexCollection2Handle); |
750 |
+ |
cout<<"Start filling pvtx parameters."<<endl; |
751 |
+ |
} |
752 |
+ |
|
753 |
+ |
nrecPV_ = int (vertexColl->size()); |
754 |
+ |
nrecPV1_spl_ = int (splitVertexColl1->size()); |
755 |
+ |
nrecPV2_spl_ = int (splitVertexColl2->size()); |
756 |
+ |
|
757 |
+ |
h["nrecPV"]->Fill(nrecPV_); |
758 |
+ |
h["nrecPV1_spl"]->Fill(nrecPV1_spl_); |
759 |
+ |
h["nrecPV2_spl"]->Fill(nrecPV2_spl_); |
760 |
+ |
h["nrecPVDiff"]->Fill(double(nrecPV1_spl_)-double(nrecPV2_spl_)); |
761 |
+ |
|
762 |
+ |
//================================================================= |
763 |
+ |
// Fill track parameter ntuple/hist for tracks used in recoVertices |
764 |
+ |
//================================================================= |
765 |
+ |
|
766 |
+ |
//fillTrackHistoInPV(const reco::VertexCollection *vertexColl, int datatype, bool fillHisto, bool fillNtuple) { |
767 |
+ |
if(vertexColl->size() > 0 && vertexColl->begin()->isValid() && !(vertexColl->begin()->isFake())) |
768 |
+ |
fillTrackHistoInPV(vertexColl, 0, true, true); |
769 |
+ |
|
770 |
+ |
if(splitVertexColl1->size() > 0 && splitVertexColl1->begin()->isValid() && !(splitVertexColl1->begin()->isFake())) |
771 |
+ |
fillTrackHistoInPV(splitVertexColl1, 1, false, true); |
772 |
+ |
|
773 |
+ |
if(splitVertexColl1->size() > 0 && splitVertexColl2->begin()->isValid() && !(splitVertexColl2->begin()->isFake())) |
774 |
+ |
fillTrackHistoInPV(splitVertexColl2, 2, false, true); |
775 |
+ |
|
776 |
+ |
//========================================================== |
777 |
+ |
// Fill secondary/primary min separations for multi-vertices |
778 |
+ |
//========================================================== |
779 |
+ |
|
780 |
+ |
if(vertexColl->size()>1 && vertexColl->begin()->isValid() && !(vertexColl->begin()->isFake()) ) { |
781 |
+ |
|
782 |
+ |
double min_xsep = 9999.0; |
783 |
+ |
double min_ysep = 9999.0; |
784 |
+ |
double min_zsep = 9999.0; |
785 |
+ |
double min_xsep_sign = 9999.0; |
786 |
+ |
double min_ysep_sign = 9999.0; |
787 |
+ |
double min_zsep_sign = 9999.0; |
788 |
+ |
double min_ntrksep = 9999.0; |
789 |
+ |
double min_sumpt2sep = 9999999.0; |
790 |
+ |
|
791 |
+ |
if(verbose_) cout<<"leading pvtx z = "<< vertexColl->begin()->z() <<endl; |
792 |
+ |
|
793 |
+ |
// Looping through the secondary vertices to find the mininum separation to the primary |
794 |
+ |
for(reco::VertexCollection::const_iterator v=vertexColl->begin() + 1 ; |
795 |
+ |
v!=vertexColl->end(); ++v) { |
796 |
+ |
if(v->isValid() && ! v->isFake()) { |
797 |
+ |
// xsep |
798 |
+ |
if(fabs(v->x()- vertexColl->begin()->x())<min_xsep) |
799 |
+ |
min_xsep = fabs(v->x()- vertexColl->begin()->x()); |
800 |
+ |
// ysep |
801 |
+ |
if(fabs(v->y()- vertexColl->begin()->y())<min_ysep) |
802 |
+ |
min_ysep = fabs(v->y()- vertexColl->begin()->y()); |
803 |
+ |
// zsep |
804 |
+ |
if(fabs(v->z()- vertexColl->begin()->z())<min_zsep) |
805 |
+ |
min_zsep = fabs(v->z()- vertexColl->begin()->z()); |
806 |
+ |
// xsep_sign |
807 |
+ |
double xsep_sign = fabs(v->x()- vertexColl->begin()->x())/max(v->xError(), vertexColl->begin()->xError()); |
808 |
+ |
if(xsep_sign < min_xsep_sign) |
809 |
+ |
min_xsep_sign = xsep_sign; |
810 |
+ |
// ysep_sign |
811 |
+ |
double ysep_sign = fabs(v->y()- vertexColl->begin()->y())/max(v->yError(), vertexColl->begin()->yError()); |
812 |
+ |
if(ysep_sign < min_ysep_sign) |
813 |
+ |
min_ysep_sign = ysep_sign; |
814 |
+ |
// zsep_sign |
815 |
+ |
double zsep_sign = fabs(v->z()- vertexColl->begin()->z())/max(v->zError(), vertexColl->begin()->zError()); |
816 |
+ |
if(zsep_sign < min_zsep_sign) |
817 |
+ |
min_zsep_sign = zsep_sign; |
818 |
+ |
// ntrksep |
819 |
+ |
if( (double(vertexColl->begin()->tracksSize()) - double(v->tracksSize())) < min_ntrksep) |
820 |
+ |
min_ntrksep = double(vertexColl->begin()->tracksSize()) - double(v->tracksSize()); |
821 |
+ |
// sumpt2sep |
822 |
+ |
if(fabs(sumPtSquared(*v) - sumPtSquared(*(vertexColl->begin()))) < min_sumpt2sep) |
823 |
+ |
min_sumpt2sep = fabs(sumPtSquared(*v) - sumPtSquared(*(vertexColl->begin()))); |
824 |
+ |
} |
825 |
+ |
} |
826 |
+ |
h["min_xsep"]->Fill(min_xsep); |
827 |
+ |
h["min_ysep"]->Fill(min_ysep); |
828 |
+ |
h["min_zsep"]->Fill(min_zsep); |
829 |
+ |
h["min_xsep_sign"]->Fill(min_xsep_sign); |
830 |
+ |
h["min_ysep_sign"]->Fill(min_ysep_sign); |
831 |
+ |
h["min_zsep_sign"]->Fill(min_zsep_sign); |
832 |
+ |
h["min_ntrksep"]->Fill(min_ntrksep); |
833 |
+ |
h["min_sumpt2sep"]->Fill(min_sumpt2sep); |
834 |
+ |
|
835 |
+ |
min_zsep_ = min_zsep; |
836 |
+ |
min_ntrksep_ = min_ntrksep; |
837 |
+ |
min_sumpt2sep_ = min_sumpt2sep; |
838 |
+ |
|
839 |
+ |
|
840 |
+ |
} // End of if(vertexColl->size()>1) { |
841 |
+ |
|
842 |
+ |
if(verbose_) |
843 |
+ |
cout<<"End filling pvtx parameters."<<endl; |
844 |
+ |
|
845 |
+ |
//======================================================= |
846 |
+ |
// PrimaryVertex Matching |
847 |
+ |
// 1. In z |z1-z2|< zsigncut * max(sigmaz1, sigmaz2) |
848 |
+ |
// 2. |(nTrkPV1 - nTrkPV2)/(nTrkPV1+nTrkPV2)|<ntrkdiffcut_ |
849 |
+ |
// Assume the first match is the primary vertex, |
850 |
+ |
// since vertexColl are sorted in decreasing order of sum(pT) |
851 |
+ |
//======================================================= |
852 |
+ |
|
853 |
+ |
if(verbose_) cout<<"PVStudy::analyze(): matching pvtxs "<<endl; |
854 |
+ |
reco::VertexCollection s_empty_matchedVertexColl1; |
855 |
+ |
reco::VertexCollection *matchedVertexColl1 = &s_empty_matchedVertexColl1; |
856 |
+ |
matchedVertexColl1->reserve(splitVertexColl1->size()); |
857 |
+ |
reco::VertexCollection s_empty_matchedVertexColl2; |
858 |
+ |
reco::VertexCollection *matchedVertexColl2 = &s_empty_matchedVertexColl2; |
859 |
+ |
matchedVertexColl2->reserve(splitVertexColl2->size()); |
860 |
+ |
|
861 |
+ |
bool stopmatching = false; |
862 |
+ |
for (size_t ivtx = 0; ivtx<splitVertexCollection1Handle->size() && !stopmatching; ++ivtx) { |
863 |
+ |
reco::VertexRef recvtx1(splitVertexCollection1Handle, ivtx); |
864 |
+ |
if( !(recvtx1->isValid()) || recvtx1->isFake()) break; |
865 |
+ |
for (size_t jvtx = ivtx; jvtx < splitVertexCollection2Handle->size(); ++jvtx) { |
866 |
+ |
//------------------------------------------------------------------------ |
867 |
+ |
//== If only considering matching the first vertex of the splitVertexColl |
868 |
+ |
//------------------------------------------------------------------------ |
869 |
+ |
if (ivtx!=0 || jvtx!=0) { stopmatching = true; break; } |
870 |
+ |
reco::VertexRef recvtx2(splitVertexCollection2Handle, jvtx); |
871 |
+ |
if( !(recvtx2->isValid()) || recvtx2->isFake()) break; |
872 |
+ |
if(verbose_) { |
873 |
+ |
cout<<"Matching splitVertexColl1: # "<< ivtx<< " and splitVertexColl1: # "<<jvtx<<endl; |
874 |
+ |
cout<<"recvtx1->z() = " << recvtx1->z() << "+/- "<< recvtx1->zError() << "." << endl; |
875 |
+ |
cout<<"recvtx2->z() = " << recvtx2->z() << "+/- "<< recvtx2->zError() << "." << endl; |
876 |
+ |
} |
877 |
+ |
if(matchVertex(recvtx1, recvtx2, zsigncut_)) { |
878 |
+ |
if(verbose_) { |
879 |
+ |
cout<<"The two splitted vertices match in Z. "<<endl; |
880 |
+ |
} |
881 |
+ |
int nTrkPV1 = recvtx1->tracksSize(); |
882 |
+ |
int nTrkPV2 = recvtx2->tracksSize(); |
883 |
+ |
double ntrkreldiff = double(nTrkPV1-nTrkPV2)/double(nTrkPV1+nTrkPV2); |
884 |
+ |
h["nTrkPVDiff"]->Fill(nTrkPV1-nTrkPV2); |
885 |
+ |
h["nTrkPVRelDiff"]->Fill(ntrkreldiff); |
886 |
+ |
if(fabs(ntrkreldiff)<ntrkdiffcut_) { |
887 |
+ |
if(verbose_) { |
888 |
+ |
cout<<"(nTrkPV1-nTrkPV2)/(nTrkPV1+nTrkPV2) = " << ntrkreldiff<<endl; |
889 |
+ |
} |
890 |
+ |
matchedVertexColl1->push_back(*recvtx1); |
891 |
+ |
matchedVertexColl2->push_back(*recvtx2); |
892 |
+ |
stopmatching = true; // stop the matching when the first match is found! |
893 |
+ |
break; |
894 |
+ |
} |
895 |
+ |
else |
896 |
+ |
cout<<"WARNING: (nTrkPV1-nTrkPV2)/(nTrkPV1+nTrkPV2) = " << ntrkreldiff<<", exceeding cut "<<ntrkdiffcut_<<endl; |
897 |
+ |
} |
898 |
+ |
else { |
899 |
+ |
cout<<"WARNING: The two reconstructed vertices do not match in z: "<<endl; |
900 |
+ |
cout<<"recvtx1->z() = " << recvtx1->z() << "+/- "<< recvtx1->zError() << "." << endl; |
901 |
+ |
cout<<"recvtx2->z() = " << recvtx2->z() << "+/- "<< recvtx2->zError() << "." << endl; |
902 |
+ |
} |
903 |
+ |
} |
904 |
+ |
} |
905 |
+ |
if(verbose_) cout<<"PVStudy::analyze(): End matching pvtxs"<<endl; |
906 |
+ |
|
907 |
+ |
//======================================================= |
908 |
+ |
// Analyze matchedVertexColls |
909 |
+ |
//======================================================= |
910 |
+ |
if(verbose_) { |
911 |
+ |
cout<<"Begin analyzing the matchedVertexColl with size = "<< matchedVertexColl1->size()<< endl; |
912 |
+ |
} |
913 |
+ |
|
914 |
+ |
// Compare the reconstructed vertex position and calculate resolution/pulls |
915 |
+ |
if(matchedVertexColl1->size() != 0 && matchedVertexColl2->size() != 0) { |
916 |
+ |
//fillPvtxHisto(const reco::VertexCollection *vertexColl, int datatype, bool fillHisto, bool fillNtuple) |
917 |
+ |
fillTrackHistoInPV(matchedVertexColl1, 1, true, false); |
918 |
+ |
fillTrackHistoInPV(matchedVertexColl2, 2, true, false); |
919 |
+ |
|
920 |
+ |
reco::VertexCollection::const_iterator v1; |
921 |
+ |
reco::VertexCollection::const_iterator v2; |
922 |
+ |
nrecPV_twovtx_ = 0; |
923 |
+ |
for(v1 = matchedVertexColl1->begin(), v2 = matchedVertexColl2->begin(); |
924 |
+ |
v1!=matchedVertexColl1->end(), v2 != matchedVertexColl2->end(); |
925 |
+ |
++v1, ++v2) { |
926 |
+ |
fres_[0] = (v1->x()-v2->x())/sqrt(2.0); |
927 |
+ |
fres_[1] = (v1->y()-v2->y())/sqrt(2.0); |
928 |
+ |
fres_[2] = (v1->z()-v2->z())/sqrt(2.0); |
929 |
+ |
ferror_[0] = sqrt(pow(v1->xError(),2)+pow(v2->xError(),2))/sqrt(2); |
930 |
+ |
ferror_[1] = sqrt(pow(v1->yError(),2)+pow(v2->yError(),2))/sqrt(2); |
931 |
+ |
ferror_[2] = sqrt(pow(v1->zError(),2)+pow(v2->zError(),2))/sqrt(2); |
932 |
+ |
fntrk_ = (v1->tracksSize()+v2->tracksSize())/2; |
933 |
+ |
|
934 |
+ |
h["deltax"]->Fill( fres_[0] ); |
935 |
+ |
h["deltay"]->Fill( fres_[1] ); |
936 |
+ |
h["deltaz"]->Fill( fres_[2] ); |
937 |
+ |
h["pullx"]->Fill( fres_[0]/ferror_[0]); |
938 |
+ |
h["pully"]->Fill( fres_[1]/ferror_[1]); |
939 |
+ |
h["pullz"]->Fill( fres_[2]/ferror_[2]); |
940 |
+ |
h["errPVx"]->Fill( ferror_[0] ); |
941 |
+ |
h["errPVy"]->Fill( ferror_[1] ); |
942 |
+ |
h["errPVz"]->Fill( ferror_[2] ); |
943 |
+ |
pvinfo.push_back(PVStudy::PVInfo(res(fres_[0], fres_[1], fres_[2]), |
944 |
+ |
error(ferror_[0], ferror_[1], ferror_[2]), |
945 |
+ |
fntrk_)); |
946 |
+ |
// Fill histo according to its track multiplicity, set datamode = 0 for pvtx using all tracks |
947 |
+ |
fillHisto(res(fres_[0], fres_[1], fres_[2]), |
948 |
+ |
error(ferror_[0], ferror_[1], ferror_[2]), |
949 |
+ |
fntrk_,0); |
950 |
+ |
// Fill the ntuple variables |
951 |
+ |
nTrkPV1_spl_twovtx_[nrecPV_twovtx_] = v1->tracksSize(); |
952 |
+ |
nTrkPV2_spl_twovtx_[nrecPV_twovtx_] = v2->tracksSize(); |
953 |
+ |
sumptsq1_spl_twovtx_[nrecPV_twovtx_] = sumPtSquared(*v1); |
954 |
+ |
sumptsq2_spl_twovtx_[nrecPV_twovtx_] = sumPtSquared(*v2); |
955 |
+ |
nTrkPV_twovtx_[nrecPV_twovtx_] = fntrk_; |
956 |
+ |
deltax_twovtx_[nrecPV_twovtx_] = fres_[0]; |
957 |
+ |
deltay_twovtx_[nrecPV_twovtx_] = fres_[1]; |
958 |
+ |
deltaz_twovtx_[nrecPV_twovtx_] = fres_[2]; |
959 |
+ |
errx_twovtx_[nrecPV_twovtx_] = ferror_[0]; |
960 |
+ |
erry_twovtx_[nrecPV_twovtx_] = ferror_[1]; |
961 |
+ |
errz_twovtx_[nrecPV_twovtx_] = ferror_[2]; |
962 |
+ |
pullx_twovtx_[nrecPV_twovtx_] = fres_[0]/ferror_[0]; |
963 |
+ |
pully_twovtx_[nrecPV_twovtx_] = fres_[1]/ferror_[1]; |
964 |
+ |
pullz_twovtx_[nrecPV_twovtx_] = fres_[2]/ferror_[2]; |
965 |
+ |
nrecPV_twovtx_++; |
966 |
+ |
} // End of analyzing res/pull |
967 |
+ |
} // End of if(matchedVertexColl1->size() == 1 && matchedVertexColl2->size() == 1 ) { |
968 |
+ |
else |
969 |
+ |
cout<<"WARNING: Cannot find matching pvtxs"<<endl; |
970 |
+ |
|
971 |
+ |
if(verbose_) cout<<"End analyzing the matchedVertexColl"<<endl; |
972 |
+ |
|
973 |
+ |
//======================================================= |
974 |
+ |
// Fill simulated vertices |
975 |
+ |
//======================================================= |
976 |
|
if (!realData_) { |
977 |
|
bool MC=false; |
978 |
|
Handle<HepMCProduct> evtMC; |
988 |
|
} |
989 |
|
MC=true; |
990 |
|
} |
991 |
< |
|
991 |
> |
|
992 |
|
if(MC){ |
993 |
|
// make a list of primary vertices: |
994 |
|
std::vector<simPrimaryVertex> simpv; |
995 |
|
simpv=getSimPVs(evtMC,""); |
996 |
|
// simpv=getSimPVs(evtMC, simVtxs, simTrks); |
997 |
< |
|
998 |
< |
int nsimtrk=0; |
411 |
< |
int nrectrk=0; |
412 |
< |
for(std::vector<simPrimaryVertex>::iterator vsim=simpv.begin(); |
413 |
< |
vsim!=simpv.end(); vsim++){ |
414 |
< |
nsimtrk+=vsim->nGenTrk; |
415 |
< |
// look for a matching reconstructed vertex |
416 |
< |
vsim->recVtx=NULL; |
417 |
< |
for(reco::VertexCollection::const_iterator vrec=recVtxs->begin(); |
418 |
< |
vrec!=recVtxs->end(); ++vrec){ |
419 |
< |
nrectrk=vrec->tracksSize(); |
420 |
< |
if(verbose_){ |
421 |
< |
cout << "sim primary vertex x = " << vsim->x << "; y = " << vsim->y << "; z = " << vsim->z << endl; |
422 |
< |
cout << "Is matched? " << (matchVertex(*vsim,*vrec)?"Yes":"No") << endl; |
423 |
< |
} |
424 |
< |
if ( matchVertex(*vsim,*vrec) ){ |
425 |
< |
// if the matching critera are fulfilled, accept the rec-vertex that is closest in z |
426 |
< |
if( ((vsim->recVtx) && (fabs(vsim->recVtx->position().z()-vsim->z)>fabs(vrec->z()-vsim->z))) |
427 |
< |
|| (!vsim->recVtx) ) |
428 |
< |
{ |
429 |
< |
vsim->recVtx=&(*vrec); |
430 |
< |
} |
431 |
< |
} |
432 |
< |
} |
433 |
< |
if (vsim->recVtx){ |
434 |
< |
if(verbose_) { |
435 |
< |
cout <<"primary matched " << vsim->x << " " << vsim->y << " " << vsim->z << endl; |
436 |
< |
} |
437 |
< |
fres[0] = vsim->recVtx->x()-vsim->x; |
438 |
< |
fres[1] = vsim->recVtx->y()-vsim->y; |
439 |
< |
fres[2] = vsim->recVtx->z()-vsim->z; |
440 |
< |
ferror[0] = vsim->recVtx->xError(); |
441 |
< |
ferror[1] = vsim->recVtx->yError(); |
442 |
< |
ferror[2] = vsim->recVtx->zError(); |
443 |
< |
fntrk = nrectrk; |
444 |
< |
|
445 |
< |
h["deltax"]->Fill( fres[0] ); |
446 |
< |
h["deltay"]->Fill( fres[1] ); |
447 |
< |
h["deltaz"]->Fill( fres[2] ); |
448 |
< |
h["pullx"]->Fill( fres[0]/ferror[0] ); |
449 |
< |
h["pully"]->Fill( fres[1]/ferror[1] ); |
450 |
< |
h["pullz"]->Fill( fres[2]/ferror[2] ); |
451 |
< |
h["errPVx"]->Fill( ferror[0] ); |
452 |
< |
h["errPVy"]->Fill( ferror[1] ); |
453 |
< |
h["errPVz"]->Fill( ferror[2] ); |
454 |
< |
pvinfo.push_back(PVStudy::PVInfo(res(fres[0], fres[1], fres[2]), |
455 |
< |
error(ferror[0], ferror[1], ferror[2]), |
456 |
< |
nrectrk)); |
457 |
< |
// Fill histo according to its track multiplicity |
458 |
< |
fillHisto(res(fres[0], fres[1], fres[2]), |
459 |
< |
error(ferror[0], ferror[1], ferror[2]), |
460 |
< |
nrectrk); |
997 |
> |
h["nsimPV"]->Fill(simpv.size()); |
998 |
> |
nsimPV_ = simpv.size(); |
999 |
|
|
1000 |
< |
ftree_->Fill(); |
1001 |
< |
} |
1002 |
< |
else{ // no rec vertex found for this simvertex |
1003 |
< |
if(verbose_) { |
1004 |
< |
cout <<"primary not found " << vsim->x << " " << vsim->y << " " << vsim->z << " nGenTrk=" << vsim->nGenTrk << endl; |
1005 |
< |
} |
1006 |
< |
} |
1007 |
< |
} |
1008 |
< |
} |
1009 |
< |
}// With MC |
1010 |
< |
|
1011 |
< |
// Loop RecVtxs and find matched SimVtxs |
1012 |
< |
for(reco::VertexCollection::const_iterator v=recVtxs->begin(); |
1013 |
< |
v!=recVtxs->end(); ++v){ |
1014 |
< |
try { |
1015 |
< |
for(reco::Vertex::trackRef_iterator t = v->tracks_begin(); |
1016 |
< |
t!=v->tracks_end(); t++) { |
1017 |
< |
// illegal charge |
1018 |
< |
if ( (**t).charge() < -1 || (**t).charge() > 1 ) { |
1019 |
< |
// h["trkPtPV"]->Fill(0.); |
1020 |
< |
} |
483 |
< |
else { |
484 |
< |
h["trkPtPV"]->Fill((**t).pt()); |
485 |
< |
} |
486 |
< |
} |
487 |
< |
} |
488 |
< |
catch (...) { |
489 |
< |
// exception thrown when trying to use linked track |
490 |
< |
// h["trkPtPV"]->Fill(0.); |
491 |
< |
} |
492 |
< |
|
493 |
< |
h["nTrkPV"]->Fill(v->tracksSize()); |
494 |
< |
|
495 |
< |
} |
496 |
< |
|
497 |
< |
h["nTrk"]->Fill(tracks->size()); |
498 |
< |
|
499 |
< |
for(TrackCollection::const_iterator itTrack = tracks->begin(); |
500 |
< |
itTrack != tracks->end(); |
501 |
< |
++itTrack) { |
502 |
< |
int charge = 0; |
503 |
< |
charge = itTrack->charge(); |
504 |
< |
h["trkPt"]->Fill(itTrack->pt()); |
1000 |
> |
int isimpv = 0; |
1001 |
> |
for(std::vector<simPrimaryVertex>::iterator vsim=simpv.begin(); |
1002 |
> |
vsim!=simpv.end(); vsim++, isimpv++){ |
1003 |
> |
nsimTrkPV_[isimpv] =vsim->nGenTrk; |
1004 |
> |
simx_[isimpv] = vsim->x; |
1005 |
> |
simy_[isimpv] = vsim->y; |
1006 |
> |
simz_[isimpv] = vsim->y; |
1007 |
> |
simptsq_[isimpv] = vsim->ptsq; |
1008 |
> |
|
1009 |
> |
//fillMCHisto((std::vector<simPrimaryVertex>::iterator vsim, int isimpv, const reco::VertexCollection *vtxColl, int datatype) { |
1010 |
> |
fillMCHisto(vsim, isimpv, splitVertexColl1, 1); |
1011 |
> |
fillMCHisto(vsim, isimpv, splitVertexColl2, 2); |
1012 |
> |
fillMCHisto(vsim, isimpv, vertexColl, 3); |
1013 |
> |
} |
1014 |
> |
} // End of for(std::vector<simPrimaryVertex>::iterator vsim=simpv.begin() |
1015 |
> |
} // End of if (!realData_) { |
1016 |
> |
|
1017 |
> |
// Finally fill the ftree_ |
1018 |
> |
if(saventuple_) { |
1019 |
> |
ftree_->Fill(); |
1020 |
> |
pvtxtree_->Fill(); |
1021 |
|
} |
506 |
– |
|
1022 |
|
} |
1023 |
|
|
509 |
– |
|
1024 |
|
// ------------ method called once each job just before starting event loop ------------ |
1025 |
|
void |
1026 |
|
PVStudy::beginJob() |
1030 |
|
// ------------ method called once each job just after ending the event loop ------------ |
1031 |
|
void |
1032 |
|
PVStudy::endJob() { |
1033 |
< |
double sqt2 = sqrt(2.); |
1034 |
< |
if (!realData_) { |
1035 |
< |
if (verbose_) cout << "Analyzing PV info" << endl; |
1036 |
< |
for (int ntrk=nTrkMin_;ntrk<=nTrkMax_;++ntrk) { |
1037 |
< |
if (verbose_) cout << "Fill point of ntrk = " << ntrk << endl; |
1038 |
< |
PVStudy::PVAnaInfo ipv = GetPVAnaInfo(ntrk); |
1039 |
< |
if (analyze_) { |
1040 |
< |
// if ( ipv.res_.x() > 0 ) h2["resx_nTrk"]->Fill(ntrk,ipv.res_.x()/sqt2, 1.); |
1041 |
< |
// if ( ipv.res_.y() > 0 ) h2["resy_nTrk"]->Fill(ntrk,ipv.res_.y()/sqt2, 1.); |
1042 |
< |
// if ( ipv.res_.z() > 0 ) h2["resz_nTrk"]->Fill(ntrk,ipv.res_.z()/sqt2, 1.); |
1043 |
< |
if ( ipv.res_.x() > 0 ) h2["resx_nTrk"]->Fill(ntrk,ipv.res_.x(), 1.); |
1044 |
< |
if ( ipv.res_.y() > 0 ) h2["resy_nTrk"]->Fill(ntrk,ipv.res_.y(), 1.); |
1045 |
< |
if ( ipv.res_.z() > 0 ) h2["resz_nTrk"]->Fill(ntrk,ipv.res_.z(), 1.); |
1046 |
< |
if ( ipv.pull_.x() > 0 ) h2["pullx_nTrk"]->Fill(ntrk,ipv.pull_.x(), 1.); |
533 |
< |
if ( ipv.pull_.y() > 0 ) h2["pully_nTrk"]->Fill(ntrk,ipv.pull_.y(), 1.); |
534 |
< |
if ( ipv.pull_.z() > 0 ) h2["pullz_nTrk"]->Fill(ntrk,ipv.pull_.z(), 1.); |
535 |
< |
} |
1033 |
> |
if (verbose_) cout << "Analyzing PV info" << endl; |
1034 |
> |
// Looping through the datamodes available |
1035 |
> |
for (vector<int>::const_iterator it= datamode.begin(); it != datamode.end() ; ++it) { |
1036 |
> |
string suffix; |
1037 |
> |
if(verbose_) cout<<"datamode = "<< *it<<endl; |
1038 |
> |
switch(*it) { |
1039 |
> |
case 0: suffix = ""; |
1040 |
> |
break; |
1041 |
> |
case 1: suffix = "_spl1_mct"; |
1042 |
> |
break; |
1043 |
> |
case 2: suffix = "_spl2_mct"; |
1044 |
> |
break; |
1045 |
> |
case 3: suffix = "_mct"; |
1046 |
> |
break; |
1047 |
|
} |
1048 |
+ |
if(analyze_) { |
1049 |
+ |
for (int ntrk=nTrkMin_;ntrk<=nTrkMax_;++ntrk) { |
1050 |
+ |
PVStudy::PVAnaInfo ipv = GetPVAnaInfo(ntrk,*it); |
1051 |
+ |
if ( ipv.res_.x() > 0 ) h2["resx"+suffix+"_nTrk"]->Fill(ntrk,ipv.res_.x(), 1.); |
1052 |
+ |
if ( ipv.res_.y() > 0 ) h2["resy"+suffix+"_nTrk"]->Fill(ntrk,ipv.res_.y(), 1.); |
1053 |
+ |
if ( ipv.res_.z() > 0 ) h2["resz"+suffix+"_nTrk"]->Fill(ntrk,ipv.res_.z(), 1.); |
1054 |
+ |
if ( ipv.pull_.x() > 0 ) h2["pullx"+suffix+"_nTrk"]->Fill(ntrk,ipv.pull_.x(), 1.); |
1055 |
+ |
if ( ipv.pull_.y() > 0 ) h2["pully"+suffix+"_nTrk"]->Fill(ntrk,ipv.pull_.y(), 1.); |
1056 |
+ |
if ( ipv.pull_.z() > 0 ) h2["pullz"+suffix+"_nTrk"]->Fill(ntrk,ipv.pull_.z(), 1.); |
1057 |
+ |
} |
1058 |
+ |
} |
1059 |
+ |
suffix.clear(); |
1060 |
+ |
} |
1061 |
+ |
if(saventuple_) { |
1062 |
+ |
file_->cd(); |
1063 |
+ |
ftree_->Write(); |
1064 |
+ |
pvtxtree_->Write(); |
1065 |
+ |
file_->Close(); |
1066 |
|
} |
538 |
– |
file_->cd(); |
539 |
– |
ftree_->Write(); |
540 |
– |
file_->Close(); |
1067 |
|
} |
1068 |
|
|
1069 |
+ |
|
1070 |
+ |
|
1071 |
+ |
// Match a recovertex with a simvertex |
1072 |
+ |
// ? Should the cut be parameter dependent? |
1073 |
+ |
// cut can be within n sigma of the vertex.zerror() |
1074 |
|
bool PVStudy::matchVertex(const PVStudy::simPrimaryVertex & vsim, |
1075 |
|
const reco::Vertex & vrec) |
1076 |
|
{ |
1077 |
|
return (fabs(vsim.z-vrec.z())<0.0500); // =500um |
1078 |
|
} |
1079 |
|
|
1080 |
+ |
// Match two reconstructed vertices |
1081 |
+ |
bool PVStudy::matchVertex( const reco::VertexRef & vrec1, |
1082 |
+ |
const reco::VertexRef & vrec2, |
1083 |
+ |
int zsigncut) |
1084 |
+ |
{ |
1085 |
+ |
double cut = zsigncut*max(vrec1->zError(), vrec2->zError()); |
1086 |
+ |
if(verbose_) |
1087 |
+ |
cout<<"The matching criteria in z is "<<cut<<endl; |
1088 |
+ |
return (fabs(vrec1->z()-vrec2->z())<cut); |
1089 |
+ |
} |
1090 |
+ |
|
1091 |
+ |
|
1092 |
|
bool PVStudy::isResonance(const HepMC::GenParticle * p){ |
1093 |
|
double ctau=(pdt->particle( abs(p->pdg_id()) ))->lifetime(); |
1094 |
|
if(verbose_) cout << "isResonance " << p->pdg_id() << " " << ctau << endl; |
1160 |
|
} |
1161 |
|
} |
1162 |
|
|
1163 |
< |
void PVStudy::fillHisto(res r, error er, int ntk){ |
1163 |
> |
void PVStudy::fillHisto(res r, error er, int ntk, int datamode){ |
1164 |
|
stringstream ss; |
1165 |
|
ss << ntk; |
1166 |
|
string suffix = ss.str(); |
1167 |
+ |
if(datamode == 0 ) suffix = "_" + suffix; |
1168 |
+ |
if(datamode == 1 ) suffix = "_spl1_mct_" + suffix; |
1169 |
+ |
if(datamode == 2 ) suffix = "_spl2_mct_" + suffix; |
1170 |
+ |
if(datamode == 3 ) suffix = "_mct_" + suffix; |
1171 |
+ |
|
1172 |
|
if (ntk < nTrkMin_ || ntk > nTrkMax_ ) return; |
1173 |
|
// Fill histograms of res and pull of ntk |
1174 |
< |
h["resx_"+suffix]->Fill(r.x()); |
1175 |
< |
h["resy_"+suffix]->Fill(r.y()); |
1176 |
< |
h["resz_"+suffix]->Fill(r.z()); |
1177 |
< |
h["pullx_"+suffix]->Fill(r.x()/er.x()); |
1178 |
< |
h["pully_"+suffix]->Fill(r.y()/er.y()); |
1179 |
< |
h["pullz_"+suffix]->Fill(r.z()/er.z()); |
1180 |
< |
h["errPVx_"+suffix]->Fill(er.x()); |
1181 |
< |
h["errPVy_"+suffix]->Fill(er.y()); |
1182 |
< |
h["errPVz_"+suffix]->Fill(er.z()); |
1174 |
> |
h["deltax"+suffix]->Fill(r.x()); |
1175 |
> |
h["deltay"+suffix]->Fill(r.y()); |
1176 |
> |
h["deltaz"+suffix]->Fill(r.z()); |
1177 |
> |
h["pullx"+suffix]->Fill(r.x()/er.x()); |
1178 |
> |
h["pully"+suffix]->Fill(r.y()/er.y()); |
1179 |
> |
h["pullz"+suffix]->Fill(r.z()/er.z()); |
1180 |
> |
h["errPVx"+suffix]->Fill(er.x()); |
1181 |
> |
h["errPVy"+suffix]->Fill(er.y()); |
1182 |
> |
h["errPVz"+suffix]->Fill(er.z()); |
1183 |
|
} |
1184 |
|
|
1185 |
< |
PVStudy::PVAnaInfo PVStudy::GetPVAnaInfo(int ntk) { |
1185 |
> |
PVStudy::PVAnaInfo PVStudy::GetPVAnaInfo(int ntk, int datamode) { |
1186 |
|
map<int,double> data; |
1187 |
|
data.clear(); |
1188 |
|
double fpar[2] = {-999,-999}; |
1189 |
|
double cm2um = 10000; |
1190 |
|
stringstream ss; |
1191 |
|
ss << ntk; |
1192 |
< |
string suffix = ss.str(); |
1193 |
< |
|
1192 |
> |
string suffix = ss.str(); |
1193 |
> |
if(datamode == 0 ) suffix = "_" + suffix; |
1194 |
> |
if(datamode == 1 ) suffix = "_spl1_mct_" + suffix; |
1195 |
> |
if(datamode == 2 ) suffix = "_spl2_mct_" + suffix; |
1196 |
> |
if(datamode == 3 ) suffix = "_mct_" + suffix; |
1197 |
> |
|
1198 |
|
if(analyze_) { |
1199 |
|
for ( int i = 0; i < 6; ++i) { |
1200 |
|
switch (i) { |
1201 |
|
case 0: |
1202 |
< |
fit(h["resx_"+suffix], fpar); |
1202 |
> |
fit(h["deltax"+suffix], fpar); |
1203 |
|
data[i] = fpar[0]*cm2um; |
1204 |
|
break; |
1205 |
|
case 1: |
1206 |
< |
fit(h["resy_"+suffix], fpar); |
1206 |
> |
fit(h["deltay"+suffix], fpar); |
1207 |
|
data[i] = fpar[0]*cm2um; |
1208 |
|
break; |
1209 |
|
case 2: |
1210 |
< |
fit(h["resz_"+suffix], fpar); |
1210 |
> |
fit(h["deltaz"+suffix], fpar); |
1211 |
|
data[i] = fpar[0]*cm2um; |
1212 |
|
break; |
1213 |
|
case 3: |
1214 |
< |
fit(h["pullx_"+suffix], fpar); |
1214 |
> |
fit(h["pullx"+suffix], fpar); |
1215 |
|
data[i] = fpar[0]; |
1216 |
|
break; |
1217 |
|
case 4: |
1218 |
< |
fit(h["pully_"+suffix], fpar); |
1218 |
> |
fit(h["pully"+suffix], fpar); |
1219 |
|
data[i] = fpar[0]; |
1220 |
|
break; |
1221 |
|
case 5: |
1222 |
< |
fit(h["pullz_"+suffix], fpar); |
1222 |
> |
fit(h["pullz"+suffix], fpar); |
1223 |
|
data[i] = fpar[0]; |
1224 |
|
break; |
1225 |
|
} |
1285 |
|
fitPars[0] = -999; |
1286 |
|
} |
1287 |
|
|
1288 |
< |
//define this as a plug-in |
1289 |
< |
DEFINE_FWK_MODULE(PVStudy); |
1288 |
> |
void PVStudy::fillTrackHisto(const reco::TrackCollection *trackColl, int datatype) { |
1289 |
> |
string suffix; |
1290 |
> |
suffix = ""; // for unsplit tracks |
1291 |
> |
if(datatype == 1) suffix = "1_spl"; // for splittracks 1 |
1292 |
> |
if(datatype == 2) suffix = "2_spl"; // for splittracks 2 |
1293 |
> |
|
1294 |
> |
h["nTrk"+suffix]->Fill(trackColl->size()); |
1295 |
> |
for(reco::TrackCollection::const_iterator itTrack = trackColl->begin(); |
1296 |
> |
itTrack != trackColl->end(); |
1297 |
> |
++itTrack) { |
1298 |
> |
h["trkPt"+suffix]->Fill(itTrack->pt()); |
1299 |
> |
h["trkDxy"+suffix]->Fill(itTrack->dxy()); |
1300 |
> |
h["trkDz"+suffix]->Fill(itTrack->dz()); |
1301 |
> |
h["trkEta"+suffix]->Fill(itTrack->eta()); |
1302 |
> |
h["trkPhi"+suffix]->Fill(itTrack->phi()); |
1303 |
> |
} |
1304 |
> |
} |
1305 |
> |
|
1306 |
> |
void PVStudy::fillTrackHistoInPV(const reco::VertexCollection *vertexColl, int datatype, bool fillHisto, bool fillNtuple) { |
1307 |
> |
string suffix; |
1308 |
> |
suffix = ""; // for unsplit tracks |
1309 |
> |
if(datatype == 1) suffix = "1_spl"; // for splittracks 1 |
1310 |
> |
if(datatype == 2) suffix = "2_spl"; // for splittracks 2 |
1311 |
> |
int ivtx = 0; |
1312 |
> |
for(reco::VertexCollection::const_iterator v=vertexColl->begin(); |
1313 |
> |
v!=vertexColl->end(); ++v, ++ivtx) { |
1314 |
> |
if(fillNtuple) { |
1315 |
> |
if(datatype == 0) { |
1316 |
> |
nTrkPV_[ivtx] = v->tracksSize(); |
1317 |
> |
sumptsq_[ivtx] = sumPtSquared(*v); |
1318 |
> |
isValid_[ivtx] = v->isValid(); |
1319 |
> |
isFake_[ivtx] = v->isFake(); |
1320 |
> |
recx_[ivtx] = v->x(); |
1321 |
> |
recy_[ivtx] = v->y(); |
1322 |
> |
recz_[ivtx] = v->z(); |
1323 |
> |
recx_err_[ivtx] = v->xError(); |
1324 |
> |
recy_err_[ivtx] = v->yError(); |
1325 |
> |
recz_err_[ivtx] = v->zError(); |
1326 |
> |
|
1327 |
> |
|
1328 |
> |
} |
1329 |
> |
if(datatype == 1) { |
1330 |
> |
nTrkPV1_spl_[ivtx] = v->tracksSize(); |
1331 |
> |
sumptsq1_spl_[ivtx] = sumPtSquared(*v); |
1332 |
> |
isValid1_spl_[ivtx] = v->isValid(); |
1333 |
> |
isFake1_spl_[ivtx] = v->isFake(); |
1334 |
> |
recx1_spl_[ivtx] = v->x(); |
1335 |
> |
recy1_spl_[ivtx] = v->y(); |
1336 |
> |
recz1_spl_[ivtx] = v->z(); |
1337 |
> |
recx1_err_spl_[ivtx] = v->xError(); |
1338 |
> |
recy1_err_spl_[ivtx] = v->yError(); |
1339 |
> |
recz1_err_spl_[ivtx] = v->zError(); |
1340 |
> |
|
1341 |
> |
} |
1342 |
> |
if(datatype == 2) { |
1343 |
> |
nTrkPV2_spl_[ivtx] = v->tracksSize(); |
1344 |
> |
sumptsq2_spl_[ivtx] = sumPtSquared(*v); |
1345 |
> |
isValid2_spl_[ivtx] = v->isValid(); |
1346 |
> |
isFake2_spl_[ivtx] = v->isFake(); |
1347 |
> |
recx2_spl_[ivtx] = v->x(); |
1348 |
> |
recy2_spl_[ivtx] = v->y(); |
1349 |
> |
recz2_spl_[ivtx] = v->z(); |
1350 |
> |
recx2_err_spl_[ivtx] = v->xError(); |
1351 |
> |
recy2_err_spl_[ivtx] = v->yError(); |
1352 |
> |
recz2_err_spl_[ivtx] = v->zError(); |
1353 |
> |
} |
1354 |
> |
} |
1355 |
> |
} |
1356 |
> |
// For histogram only fill the leading pvtx parameters |
1357 |
> |
if(fillHisto) { |
1358 |
> |
h["nTrkPV"+suffix]->Fill(vertexColl->begin()->tracksSize()); |
1359 |
> |
try { |
1360 |
> |
for(reco::Vertex::trackRef_iterator t = vertexColl->begin()->tracks_begin(); |
1361 |
> |
t!=vertexColl->begin()->tracks_end(); t++) { |
1362 |
> |
// illegal charge |
1363 |
> |
if ( (**t).charge() < -1 || (**t).charge() > 1 ) { |
1364 |
> |
// h["trkPtPV"]->Fill(0.); |
1365 |
> |
} |
1366 |
> |
else { |
1367 |
> |
h["trkPtPV"+suffix]->Fill((**t).pt()); |
1368 |
> |
h["trkDxyPV"+suffix]->Fill((**t).dxy()); |
1369 |
> |
h["trkDzPV"+suffix]->Fill((**t).dz()); |
1370 |
> |
h["trkEtaPV"+suffix]->Fill((**t).eta()); |
1371 |
> |
h["trkPhiPV"+suffix]->Fill((**t).phi()); |
1372 |
> |
} |
1373 |
> |
} |
1374 |
> |
} |
1375 |
> |
catch (...) { |
1376 |
> |
// exception thrown when trying to use linked track |
1377 |
> |
// h["trkPtPV"]->Fill(0.); |
1378 |
> |
} |
1379 |
> |
} |
1380 |
> |
|
1381 |
> |
} |
1382 |
> |
|
1383 |
> |
void PVStudy::fillMCHisto(std::vector<simPrimaryVertex>::iterator vsim, int isimpv, const reco::VertexCollection *vtxColl, int datatype) |
1384 |
> |
{ |
1385 |
> |
std::string suffix; |
1386 |
> |
// Set the vertexColl and histogram suffix according to datamode |
1387 |
> |
if (datatype == 1) { |
1388 |
> |
suffix = "_spl1_mct"; |
1389 |
> |
nrecPV_spl1_mct_ = 0; |
1390 |
> |
} |
1391 |
> |
if (datatype == 2) { |
1392 |
> |
suffix = "_spl2_mct"; |
1393 |
> |
nrecPV_spl2_mct_ = 0; |
1394 |
> |
} |
1395 |
> |
if (datatype == 3) { |
1396 |
> |
suffix = "_mct"; |
1397 |
> |
nrecPV_mct_ = 0; |
1398 |
> |
} |
1399 |
> |
|
1400 |
> |
//======================================================== |
1401 |
> |
// look for a matching reconstructed vertex in vertexColl |
1402 |
> |
//======================================================== |
1403 |
> |
|
1404 |
> |
for(reco::VertexCollection::const_iterator vrec=vtxColl->begin(); |
1405 |
> |
vrec!=vtxColl->end(); ++vrec){ |
1406 |
> |
int nrectrk = vrec->tracksSize(); |
1407 |
> |
vsim->recVtx=NULL; |
1408 |
> |
|
1409 |
> |
if(verbose_){ |
1410 |
> |
cout << "sim primary vertex x = " << vsim->x << "; y = " << vsim->y << "; z = " << vsim->z << endl; |
1411 |
> |
cout << "Is matched? " << (matchVertex(*vsim,*vrec)?"Yes":"No") << endl; |
1412 |
> |
} |
1413 |
> |
if ( matchVertex(*vsim,*vrec) ) { |
1414 |
> |
vsim->recVtx=&(*vrec); |
1415 |
> |
|
1416 |
> |
// if the matching critera are fulfilled, accept the rec-vertex that is closest in z |
1417 |
> |
//if( ((vsim->recVtx) && (fabs(vsim->recVtx->position().z()-vsim->z)>fabs(vrec->z()-vsim->z))) |
1418 |
> |
//|| (!vsim->recVtx) ) |
1419 |
> |
//vsim->recVtx=&(*vrec); |
1420 |
> |
//} |
1421 |
> |
if(verbose_) |
1422 |
> |
cout <<"primary matched in vertexColl" << vsim->x << " " << vsim->y << " " << vsim->z << endl; |
1423 |
> |
|
1424 |
> |
double fres_mct[3]; |
1425 |
> |
double ferror_mct[3]; |
1426 |
> |
|
1427 |
> |
fres_mct[0] = vsim->recVtx->x()-vsim->x; |
1428 |
> |
fres_mct[1] = vsim->recVtx->y()-vsim->y; |
1429 |
> |
fres_mct[2] = vsim->recVtx->z()-vsim->z; |
1430 |
> |
ferror_mct[0] = vsim->recVtx->xError(); |
1431 |
> |
ferror_mct[1] = vsim->recVtx->yError(); |
1432 |
> |
ferror_mct[2] = vsim->recVtx->zError(); |
1433 |
> |
|
1434 |
> |
h["deltax"+suffix]->Fill( fres_mct[0] ); |
1435 |
> |
h["deltay"+suffix]->Fill( fres_mct[1] ); |
1436 |
> |
h["deltaz"+suffix]->Fill( fres_mct[2] ); |
1437 |
> |
h["pullx"+suffix]->Fill( fres_mct[0]/ferror_mct[0] ); |
1438 |
> |
h["pully"+suffix]->Fill( fres_mct[1]/ferror_mct[1] ); |
1439 |
> |
h["pullz"+suffix]->Fill( fres_mct[2]/ferror_mct[2] ); |
1440 |
> |
h["errPVx"+suffix]->Fill( ferror_mct[0] ); |
1441 |
> |
h["errPVy"+suffix]->Fill( ferror_mct[1] ); |
1442 |
> |
h["errPVz"+suffix]->Fill( ferror_mct[2] ); |
1443 |
> |
pvinfo.push_back(PVStudy::PVInfo(res(fres_mct[0], fres_mct[1], fres_mct[2]), |
1444 |
> |
error(ferror_mct[0], ferror_mct[1], ferror_mct[2]), |
1445 |
> |
nrectrk)); |
1446 |
> |
// Fill histo according to its track multiplicity |
1447 |
> |
fillHisto(res(fres_mct[0], fres_mct[1], fres_mct[2]), |
1448 |
> |
error(ferror_mct[0], ferror_mct[1], ferror_mct[2]), |
1449 |
> |
nrectrk, datatype); |
1450 |
> |
|
1451 |
> |
if(saventuple_) { |
1452 |
> |
//Fill the values for variables in ftree_ |
1453 |
> |
if(datatype == 1) { |
1454 |
> |
nTrkPV_spl1_mct_[nrecPV_spl1_mct_] = nrectrk; |
1455 |
> |
deltax_spl1_mct_[nrecPV_spl1_mct_] = fres_mct[0]; |
1456 |
> |
deltay_spl1_mct_[nrecPV_spl1_mct_] = fres_mct[0]; |
1457 |
> |
deltaz_spl1_mct_[nrecPV_spl1_mct_] = fres_mct[0]; |
1458 |
> |
pullx_spl1_mct_[nrecPV_spl1_mct_] = fres_mct[0]/ferror_mct[0]; |
1459 |
> |
pully_spl1_mct_[nrecPV_spl1_mct_] = fres_mct[1]/ferror_mct[1]; |
1460 |
> |
pullz_spl1_mct_[nrecPV_spl1_mct_] = fres_mct[2]/ferror_mct[2]; |
1461 |
> |
nrecPV_spl1_mct_++; |
1462 |
> |
} |
1463 |
> |
|
1464 |
> |
if(datatype == 2) { |
1465 |
> |
nTrkPV_spl2_mct_[nrecPV_spl2_mct_] = nrectrk; |
1466 |
> |
deltax_spl2_mct_[nrecPV_spl2_mct_] = fres_mct[0]; |
1467 |
> |
deltay_spl2_mct_[nrecPV_spl2_mct_] = fres_mct[0]; |
1468 |
> |
deltaz_spl2_mct_[nrecPV_spl2_mct_] = fres_mct[0]; |
1469 |
> |
pullx_spl2_mct_[nrecPV_spl2_mct_] = fres_mct[0]/ferror_mct[0]; |
1470 |
> |
pully_spl2_mct_[nrecPV_spl2_mct_] = fres_mct[1]/ferror_mct[1]; |
1471 |
> |
pullz_spl2_mct_[nrecPV_spl2_mct_] = fres_mct[2]/ferror_mct[2]; |
1472 |
> |
nrecPV_spl2_mct_++; |
1473 |
> |
} |
1474 |
> |
if(datatype == 3) { |
1475 |
> |
nTrkPV_mct_[nrecPV_mct_] = nrectrk; |
1476 |
> |
deltax_mct_[nrecPV_mct_] = fres_mct[0]; |
1477 |
> |
deltay_mct_[nrecPV_mct_] = fres_mct[0]; |
1478 |
> |
deltaz_mct_[nrecPV_mct_] = fres_mct[0]; |
1479 |
> |
pullx_mct_[nrecPV_mct_] = fres_mct[0]/ferror_mct[0]; |
1480 |
> |
pully_mct_[nrecPV_mct_] = fres_mct[1]/ferror_mct[1]; |
1481 |
> |
pullz_mct_[nrecPV_mct_] = fres_mct[2]/ferror_mct[2]; |
1482 |
> |
nrecPV_mct_++; |
1483 |
> |
} |
1484 |
> |
} // End of if(saventuple_) { |
1485 |
> |
} // if ( matchVertex(*vsim,*vrec) ) { |
1486 |
> |
else { // no rec vertex found for this simvertex |
1487 |
> |
if(verbose_) |
1488 |
> |
cout <<"primary not found " << vsim->x << " " << vsim->y << " " << vsim->z << " nGenTrk=" << vsim->nGenTrk << endl; |
1489 |
> |
} |
1490 |
> |
} |
1491 |
> |
} |
1492 |
> |
|
1493 |
> |
|
1494 |
> |
void PVStudy::SetVarToZero() { |
1495 |
> |
//Greg's variables |
1496 |
> |
fntrk_ = 0; |
1497 |
> |
//pvtx position (x,y,z) residual and error |
1498 |
> |
for(int i = 0; i<3;i++) { |
1499 |
> |
fres_[i] = 0; |
1500 |
> |
ferror_[i] = 0; |
1501 |
> |
} |
1502 |
> |
|
1503 |
> |
//Yanyan's variables |
1504 |
> |
// Number of reconstructed vertices |
1505 |
> |
nrecPV_ = 0; |
1506 |
> |
nrecPV1_spl_ = 0; |
1507 |
> |
nrecPV2_spl_ = 0; |
1508 |
> |
nrecPV_twovtx_ = 0; |
1509 |
> |
nsimPV_ = 0; |
1510 |
> |
|
1511 |
> |
nrecPV_mct_ = 0; |
1512 |
> |
nrecPV_spl1_mct_ = 0; |
1513 |
> |
nrecPV_spl2_mct_ = 0; |
1514 |
> |
|
1515 |
> |
// Mininum separation between the secondary pvtxes and leading pvtx |
1516 |
> |
min_zsep_ = 9999.0; |
1517 |
> |
min_ntrksep_ = 9999.0; |
1518 |
> |
min_sumpt2sep_ = -9999.0; |
1519 |
> |
|
1520 |
> |
|
1521 |
> |
for (int i = 0; i < nMaxPVs_; i++) { |
1522 |
> |
// recoVertices with all tracks |
1523 |
> |
nTrkPV_[i] = 0; // Number of tracks in the pvtx |
1524 |
> |
sumptsq_[i] = 0; |
1525 |
> |
isValid_[i] = -1; |
1526 |
> |
isFake_[i] = -1; |
1527 |
> |
recx_[i] = 0; |
1528 |
> |
recy_[i] = 0; |
1529 |
> |
recz_[i] = 0; |
1530 |
> |
recx_err_[i] = 0; |
1531 |
> |
recy_err_[i] = 0; |
1532 |
> |
recz_err_[i] = 0; |
1533 |
> |
|
1534 |
> |
|
1535 |
> |
|
1536 |
> |
// recoVertices with splitTrack1 |
1537 |
> |
nTrkPV1_spl_[i] = 0; // Number of tracks in the pvtx |
1538 |
> |
sumptsq1_spl_[i] = 0; |
1539 |
> |
isValid1_spl_[i] = -1; |
1540 |
> |
isFake1_spl_[i] = -1; |
1541 |
> |
recx1_spl_[i] = 0; |
1542 |
> |
recy1_spl_[i] = 0; |
1543 |
> |
recz1_spl_[i] = 0; |
1544 |
> |
recx1_err_spl_[i] = 0; |
1545 |
> |
recy1_err_spl_[i] = 0; |
1546 |
> |
recz1_err_spl_[i] = 0; |
1547 |
> |
|
1548 |
> |
|
1549 |
> |
// recoVertices with splitTrack2 |
1550 |
> |
nTrkPV2_spl_[i] = 0; // Number of tracks in the pvtx |
1551 |
> |
sumptsq2_spl_[i] = 0; |
1552 |
> |
isValid2_spl_[i] = -1; |
1553 |
> |
isFake2_spl_[i] = -1; |
1554 |
> |
recx2_spl_[i] = 0; |
1555 |
> |
recy2_spl_[i] = 0; |
1556 |
> |
recz2_spl_[i] = 0; |
1557 |
> |
recx2_err_spl_[i] = 0; |
1558 |
> |
recy2_err_spl_[i] = 0; |
1559 |
> |
recz2_err_spl_[i] = 0; |
1560 |
> |
|
1561 |
> |
// matched two-vertices |
1562 |
> |
nTrkPV1_spl_twovtx_[i] = 0; |
1563 |
> |
nTrkPV2_spl_twovtx_[i] = 0; |
1564 |
> |
nTrkPV_twovtx_[i] = 0; |
1565 |
> |
sumptsq1_spl_twovtx_[i] = 0; // Sum of pT squred in the pvtx |
1566 |
> |
sumptsq2_spl_twovtx_[i] = 0; // Sum of pT squred in the pvtx |
1567 |
> |
deltax_twovtx_[i] = 0; |
1568 |
> |
deltay_twovtx_[i] = 0; |
1569 |
> |
deltaz_twovtx_[i] = 0; |
1570 |
> |
errx_twovtx_[i] = 0; |
1571 |
> |
erry_twovtx_[i] = 0; |
1572 |
> |
errz_twovtx_[i] = 0; |
1573 |
> |
pullx_twovtx_[i] = 0; |
1574 |
> |
pully_twovtx_[i] = 0; |
1575 |
> |
pullz_twovtx_[i] = 0; |
1576 |
> |
|
1577 |
> |
//simpv |
1578 |
> |
nsimTrkPV_[i] = 0; |
1579 |
> |
simx_[i] = 0; |
1580 |
> |
simy_[i] = 0; |
1581 |
> |
simz_[i] = 0; |
1582 |
> |
simptsq_[i] = 0; |
1583 |
> |
|
1584 |
> |
// residual and pulls with mc truth required |
1585 |
> |
deltax_mct_[i] = 0; |
1586 |
> |
deltay_mct_[i] = 0; |
1587 |
> |
deltaz_mct_[i] = 0; |
1588 |
> |
pullx_mct_[i] = 0; |
1589 |
> |
pully_mct_[i] = 0; |
1590 |
> |
pullz_mct_[i] = 0; |
1591 |
> |
|
1592 |
> |
deltax_spl1_mct_[i] = 0; |
1593 |
> |
deltay_spl1_mct_[i] = 0; |
1594 |
> |
deltaz_spl1_mct_[i] = 0; |
1595 |
> |
pullx_spl1_mct_[i] = 0; |
1596 |
> |
pully_spl1_mct_[i] = 0; |
1597 |
> |
pullz_spl1_mct_[i] = 0; |
1598 |
> |
|
1599 |
> |
deltax_spl2_mct_[i] = 0; |
1600 |
> |
deltay_spl2_mct_[i] = 0; |
1601 |
> |
deltaz_spl2_mct_[i] = 0; |
1602 |
> |
pullx_spl2_mct_[i] = 0; |
1603 |
> |
pully_spl2_mct_[i] = 0; |
1604 |
> |
pullz_spl2_mct_[i] = 0; |
1605 |
> |
} |
1606 |
> |
|
1607 |
> |
} |
1608 |
> |
|
1609 |
> |
double PVStudy::sumPtSquared(const reco::Vertex & v) { |
1610 |
> |
double sum = 0.; |
1611 |
> |
double pT; |
1612 |
> |
for (reco::Vertex::trackRef_iterator it = v.tracks_begin(); it != v.tracks_end(); it++) { |
1613 |
> |
pT = (**it).pt(); |
1614 |
> |
sum += pT*pT; |
1615 |
> |
} |
1616 |
> |
return sum; |
1617 |
> |
} |
1618 |
> |
|