1 |
jengbou |
1.1 |
// -*- C++ -*-
|
2 |
|
|
//
|
3 |
|
|
// Package: PVStudy
|
4 |
|
|
// Class: PVStudy
|
5 |
|
|
//
|
6 |
|
|
/**\class PVStudy PVStudy.cc UserCode/PVStudy/plugins/PVStudy.cc
|
7 |
|
|
|
8 |
|
|
Description: <one line class summary>
|
9 |
|
|
|
10 |
|
|
Implementation:
|
11 |
|
|
<Notes on implementation>
|
12 |
|
|
*/
|
13 |
|
|
//
|
14 |
|
|
// Original Author: "Geng-yuan Jeng/UC Riverside"
|
15 |
yygao |
1.7 |
// "Yanyan Gao/Fermilab ygao@fnal.gov"
|
16 |
jengbou |
1.1 |
// Created: Thu Aug 20 11:55:40 CDT 2009
|
17 |
yygao |
1.11 |
// $Id: PVStudy.cc,v 1.10 2009/11/08 02:56:57 yygao Exp $
|
18 |
jengbou |
1.1 |
//
|
19 |
|
|
//
|
20 |
|
|
|
21 |
|
|
|
22 |
|
|
// system include files
|
23 |
|
|
#include <memory>
|
24 |
|
|
#include <string>
|
25 |
|
|
#include <vector>
|
26 |
|
|
#include <iostream>
|
27 |
|
|
#include <sstream>
|
28 |
yygao |
1.9 |
#include <algorithm>
|
29 |
jengbou |
1.1 |
|
30 |
|
|
// user include files
|
31 |
|
|
#include "FWCore/Framework/interface/Frameworkfwd.h"
|
32 |
|
|
#include "FWCore/Framework/interface/EDAnalyzer.h"
|
33 |
|
|
|
34 |
|
|
#include "FWCore/Framework/interface/Event.h"
|
35 |
|
|
#include "FWCore/Framework/interface/MakerMacros.h"
|
36 |
|
|
|
37 |
|
|
#include "FWCore/ParameterSet/interface/ParameterSet.h"
|
38 |
|
|
#include "FWCore/Utilities/interface/InputTag.h"
|
39 |
|
|
#include "DataFormats/TrackReco/interface/Track.h"
|
40 |
|
|
#include "DataFormats/TrackReco/interface/TrackFwd.h"
|
41 |
|
|
#include "FWCore/ServiceRegistry/interface/Service.h"
|
42 |
|
|
#include "PhysicsTools/UtilAlgos/interface/TFileService.h"
|
43 |
|
|
#include "UserCode/PVStudy/interface/PVStudy.h"
|
44 |
|
|
//
|
45 |
|
|
#include "DataFormats/VertexReco/interface/Vertex.h"
|
46 |
|
|
#include "RecoVertex/VertexPrimitives/interface/TransientVertex.h"
|
47 |
|
|
|
48 |
|
|
// simulated vertices,..., add <use name=SimDataFormats/Vertex> and <../Track>
|
49 |
|
|
#include <SimDataFormats/Vertex/interface/SimVertex.h>
|
50 |
|
|
#include <SimDataFormats/Vertex/interface/SimVertexContainer.h>
|
51 |
|
|
#include <SimDataFormats/Track/interface/SimTrack.h>
|
52 |
|
|
#include <SimDataFormats/Track/interface/SimTrackContainer.h>
|
53 |
|
|
|
54 |
|
|
//root
|
55 |
jengbou |
1.4 |
#include <TROOT.h>
|
56 |
|
|
#include <TF1.h>
|
57 |
|
|
#include <TString.h>
|
58 |
|
|
#include <TStyle.h>
|
59 |
|
|
#include <TPaveStats.h>
|
60 |
|
|
#include <TPad.h>
|
61 |
jengbou |
1.1 |
|
62 |
|
|
using namespace std;
|
63 |
|
|
|
64 |
yygao |
1.7 |
PVStudy::PVStudy(const edm::ParameterSet& iConfig)
|
65 |
jengbou |
1.1 |
{
|
66 |
yygao |
1.7 |
//=======================================================================
|
67 |
|
|
// Get configuration for TrackTupleMaker
|
68 |
|
|
//=======================================================================
|
69 |
yygao |
1.9 |
simG4_ = iConfig.getParameter<edm::InputTag>( "simG4" );
|
70 |
|
|
trackCollectionTag_ = iConfig.getUntrackedParameter<edm::InputTag>("trackCollection");
|
71 |
|
|
splitTrackCollection1Tag_ = iConfig.getUntrackedParameter<edm::InputTag>("splitTrackCollection1");
|
72 |
|
|
splitTrackCollection2Tag_ = iConfig.getUntrackedParameter<edm::InputTag>("splitTrackCollection2");
|
73 |
yygao |
1.7 |
vertexCollectionTag_ = iConfig.getUntrackedParameter<edm::InputTag>("vertexCollection");
|
74 |
yygao |
1.9 |
splitVertexCollection1Tag_ = iConfig.getUntrackedParameter<edm::InputTag>("splitVertexCollection1");
|
75 |
yygao |
1.10 |
splitVertexCollection2Tag_ = iConfig.getUntrackedParameter<edm::InputTag>("splitVertexCollection2");
|
76 |
|
|
pixelVertexCollectionTag_ = iConfig.getParameter<edm::InputTag>("pixelVertexCollectionTag");
|
77 |
yygao |
1.9 |
verbose_ = iConfig.getUntrackedParameter<bool>("verbose",false);
|
78 |
|
|
realData_ = iConfig.getUntrackedParameter<bool>("realData",false);
|
79 |
|
|
analyze_ = iConfig.getUntrackedParameter<bool>("analyzeOnTheFly",false);
|
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 |
jengbou |
1.1 |
|
87 |
|
|
//now do what ever initialization is needed
|
88 |
jengbou |
1.3 |
pvinfo.clear();
|
89 |
jengbou |
1.1 |
|
90 |
yygao |
1.9 |
|
91 |
yygao |
1.7 |
// 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 |
yygao |
1.9 |
|
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 |
yygao |
1.10 |
pvtxtree_->Branch("sumptsq",&sumptsq_,"sumptsq[nrecPV]/D");
|
115 |
|
|
pvtxtree_->Branch("isValid",&isValid_,"isValid/I");
|
116 |
|
|
pvtxtree_->Branch("isFake",&isFake_,"isFake/I");
|
117 |
yygao |
1.9 |
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 |
yygao |
1.11 |
|
124 |
yygao |
1.10 |
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 |
yygao |
1.9 |
//pvtx using splittracks1
|
129 |
|
|
pvtxtree_->Branch("nrecPV1_spl",&nrecPV1_spl_,"nrecPV1_spl/I");
|
130 |
yygao |
1.10 |
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 |
yygao |
1.9 |
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 |
yygao |
1.10 |
pvtxtree_->Branch("recz1_err_spl",&recz1_err_spl_,"recz1_err_spl[nrecPV1_spl]/D");
|
140 |
|
|
|
141 |
yygao |
1.9 |
//pvtx using splittracks2
|
142 |
|
|
pvtxtree_->Branch("nrecPV2_spl",&nrecPV2_spl_,"nrecPV2_spl/I");
|
143 |
yygao |
1.10 |
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 |
yygao |
1.9 |
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 |
yygao |
1.10 |
pvtxtree_->Branch("recz2_err_spl",&recz2_err_spl_,"recz2_err_spl[nrecPV2_spl]/D");
|
153 |
yygao |
1.11 |
|
154 |
|
|
//pixeVertices
|
155 |
|
|
pvtxtree_->Branch("nrecPV_pxlpvtx",&nrecPV_pxlpvtx_,"nrecPV_pxlpvtx/I");
|
156 |
|
|
pvtxtree_->Branch("nTrkPV_pxlpvtx",&nTrkPV_pxlpvtx_,"nTrkPV_pxlpvtx[nrecPV_pxlpvtx]/I");
|
157 |
|
|
pvtxtree_->Branch("sumptsq_pxlpvtx",&sumptsq_pxlpvtx_,"sumptsq_pxlpvtx[nrecPV_pxlpvtx]/D");
|
158 |
|
|
pvtxtree_->Branch("isValid_pxlpvtx",&isValid_pxlpvtx_,"isValid_pxlpvtx/I");
|
159 |
|
|
pvtxtree_->Branch("isFake_pxlpvtx",&isFake_pxlpvtx_,"isFake_pxlpvtx/I");
|
160 |
|
|
pvtxtree_->Branch("recx_pxlpvtx",&recx_pxlpvtx_,"recx_pxlpvtx[nrecPV_pxlpvtx]/D");
|
161 |
|
|
pvtxtree_->Branch("recy_pxlpvtx",&recy_pxlpvtx_,"recy_pxlpvtx[nrecPV_pxlpvtx]/D");
|
162 |
|
|
pvtxtree_->Branch("recz_pxlpvtx",&recz_pxlpvtx_,"recz_pxlpvtx[nrecPV_pxlpvtx]/D");
|
163 |
|
|
pvtxtree_->Branch("recx_err_pxlpvtx",&recx_err_pxlpvtx_,"recx_err_pxlpvtx[nrecPV_pxlpvtx]/D");
|
164 |
|
|
pvtxtree_->Branch("recy_err_pxlpvtx",&recy_err_pxlpvtx_,"recy_err_pxlpvtx[nrecPV_pxlpvtx]/D");
|
165 |
|
|
pvtxtree_->Branch("recz_err_pxlpvtx",&recz_err_pxlpvtx_,"recz_err_pxlpvtx[nrecPV_pxlpvtx]/D");
|
166 |
|
|
|
167 |
yygao |
1.9 |
//Fill the variables in the twovtx pair (recvtx1, recvtx2)
|
168 |
|
|
pvtxtree_->Branch("nrecPV_twovtx",&nrecPV_twovtx_,"nrecPV_twovtx/I");
|
169 |
|
|
pvtxtree_->Branch("nTrkPV1_spl_twovtx",&nTrkPV1_spl_twovtx_,"nTrkPV1_spl_twovtx[nrecPV_twovtx]/I");
|
170 |
|
|
pvtxtree_->Branch("nTrkPV2_spl_twovtx",&nTrkPV2_spl_twovtx_,"nTrkPV2_spl_twovtx[nrecPV_twovtx]/I");
|
171 |
|
|
pvtxtree_->Branch("sumptsq1_spl_twovtx",&sumptsq1_spl_twovtx_,"sumptsq1_spl_twovtx[nrecPV_twovtx]/D");
|
172 |
|
|
pvtxtree_->Branch("sumptsq2_spl_twovtx",&sumptsq2_spl_twovtx_,"sumptsq2_spl_twovtx[nrecPV_twovtx]/D");
|
173 |
|
|
pvtxtree_->Branch("nTrkPV_twovtx",&nTrkPV_twovtx_,"nTrkPV_twovtx[nrecPV_twovtx]/I");
|
174 |
|
|
pvtxtree_->Branch("deltax_twovtx",&deltax_twovtx_,"deltax_twovtx[nrecPV_twovtx]/D");
|
175 |
|
|
pvtxtree_->Branch("deltay_twovtx",&deltay_twovtx_,"deltay_twovtx[nrecPV_twovtx]/D");
|
176 |
|
|
pvtxtree_->Branch("deltaz_twovtx",&deltaz_twovtx_,"deltaz_twovtx[nrecPV_twovtx]/D");
|
177 |
|
|
pvtxtree_->Branch("errx_twovtx",&errx_twovtx_,"errx_twovtx[nrecPV_twovtx]/D");
|
178 |
|
|
pvtxtree_->Branch("erry_twovtx",&erry_twovtx_,"erry_twovtx[nrecPV_twovtx]/D");
|
179 |
|
|
pvtxtree_->Branch("errz_twovtx",&errz_twovtx_,"errz_twovtx[nrecPV_twovtx]/D");
|
180 |
|
|
pvtxtree_->Branch("pullx_twovtx",&pullx_twovtx_,"pullx_twovtx[nrecPV_twovtx]/D");
|
181 |
|
|
pvtxtree_->Branch("pully_twovtx",&pully_twovtx_,"pully_twovtx[nrecPV_twovtx]/D");
|
182 |
|
|
pvtxtree_->Branch("pullz_twovtx",&pullz_twovtx_,"pullz_twovtx[nrecPV_twovtx]/D");
|
183 |
|
|
|
184 |
|
|
// MC variables
|
185 |
|
|
if(!realData_) {
|
186 |
|
|
pvtxtree_->Branch("nsimPV",&nsimPV_,"nsimPV/I");
|
187 |
|
|
pvtxtree_->Branch("nsimTrkPV",&nsimTrkPV_,"nsimTrkPV[nsimPV]/I");
|
188 |
|
|
pvtxtree_->Branch("simx",&simx_,"simx[nsimPV]/D");
|
189 |
|
|
pvtxtree_->Branch("simy",&simy_,"simy[nsimPV]/D");
|
190 |
|
|
pvtxtree_->Branch("simz",&simz_,"simz[nsimPV]/D");
|
191 |
|
|
pvtxtree_->Branch("simptsq",&simptsq_,"simptsq[nsimPV]/D");
|
192 |
|
|
|
193 |
|
|
// For pvtxs with all the tracks
|
194 |
|
|
pvtxtree_->Branch("nrecPV_mct",&nrecPV_mct_,"nrecPV_mct/I");
|
195 |
|
|
pvtxtree_->Branch("deltax_mct",&deltax_mct_,"deltax_mct[nrecPV_mct]/D");
|
196 |
|
|
pvtxtree_->Branch("deltay_mct",&deltay_mct_,"deltay_mct[nrecPV_mct]/D");
|
197 |
|
|
pvtxtree_->Branch("deltaz_mct",&deltaz_mct_,"deltaz_mct[nrecPV_mct]/D");
|
198 |
|
|
pvtxtree_->Branch("pullx_mct",&pullx_mct_,"pullx_mct[nrecPV_mct]/D");
|
199 |
|
|
pvtxtree_->Branch("pully_mct",&pully_mct_,"pully_mct[nrecPV_mct]/D");
|
200 |
|
|
pvtxtree_->Branch("pullz_mct",&pullz_mct_,"pullz_mct[nrecPV_mct]/D");
|
201 |
|
|
// For pvtxs with splittracks1
|
202 |
|
|
pvtxtree_->Branch("nrecPV_spl1_mct",&nrecPV_spl1_mct_,"nrecPV_spl1_mct/I");
|
203 |
|
|
pvtxtree_->Branch("deltax_spl1_mct",&deltax_spl1_mct_,"deltax_spl1_mct[nrecPV_spl1_mct]/D");
|
204 |
|
|
pvtxtree_->Branch("deltay_spl1_mct",&deltay_spl1_mct_,"deltay_spl1_mct[nrecPV_spl1_mct]/D");
|
205 |
|
|
pvtxtree_->Branch("deltaz_spl1_mct",&deltaz_spl1_mct_,"deltaz_spl1_mct[nrecPV_spl1_mct]/D");
|
206 |
|
|
pvtxtree_->Branch("pullx_spl1_mct",&pullx_spl1_mct_,"pullx_spl1_mct[nrecPV_spl1_mct]/D");
|
207 |
|
|
pvtxtree_->Branch("pully_spl1_mct",&pully_spl1_mct_,"pully_spl1_mct[nrecPV_spl1_mct]/D");
|
208 |
|
|
pvtxtree_->Branch("pullz_spl1_mct",&pullz_spl1_mct_,"pullz_spl1_mct[nrecPV_spl1_mct]/D");
|
209 |
|
|
// For pvtxs with splittracks1
|
210 |
|
|
pvtxtree_->Branch("nrecPV_spl2_mct",&nrecPV_spl2_mct_,"nrecPV_spl2_mct/I");
|
211 |
|
|
pvtxtree_->Branch("deltax_spl2_mct",&deltax_spl2_mct_,"deltax_spl2_mct[nrecPV_spl2_mct]/D");
|
212 |
|
|
pvtxtree_->Branch("deltay_spl2_mct",&deltay_spl2_mct_,"deltay_spl2_mct[nrecPV_spl2_mct]/D");
|
213 |
|
|
pvtxtree_->Branch("deltaz_spl2_mct",&deltaz_spl2_mct_,"deltaz_spl2_mct[nrecPV_spl2_mct]/D");
|
214 |
|
|
pvtxtree_->Branch("pullx_spl2_mct",&pullx_spl2_mct_,"pullx_spl2_mct[nrecPV_spl2_mct]/D");
|
215 |
|
|
pvtxtree_->Branch("pully_spl2_mct",&pully_spl2_mct_,"pully_spl2_mct[nrecPV_spl2_mct]/D");
|
216 |
|
|
pvtxtree_->Branch("pullz_spl2_mct",&pullz_spl2_mct_,"pullz_spl2_mct[nrecPV_spl2_mct]/D");
|
217 |
yygao |
1.7 |
}
|
218 |
|
|
}
|
219 |
|
|
|
220 |
jengbou |
1.1 |
edm::Service<TFileService> fs;
|
221 |
jengbou |
1.4 |
TFileDirectory subDir = fs->mkdir( "Summary" );
|
222 |
|
|
TFileDirectory subDir1 = fs->mkdir( "Others" );
|
223 |
|
|
// TFileDirectory subSubDir = subDir.mkdir( "mySubSubDirectory" );
|
224 |
|
|
|
225 |
|
|
setRootStyle();
|
226 |
yygao |
1.7 |
|
227 |
|
|
//Book histograms for track and pvtx parameters for each splitted pvtx
|
228 |
|
|
//i=0 : x (as in unsplit track collection)
|
229 |
|
|
//i=1 : x1_spl_
|
230 |
|
|
//i=2 : x2_spl_
|
231 |
yygao |
1.10 |
|
232 |
|
|
|
233 |
yygao |
1.7 |
for(int i=0;i<3;i++)
|
234 |
|
|
{
|
235 |
|
|
string suffix;
|
236 |
|
|
if(i == 0) suffix = "";
|
237 |
|
|
else {
|
238 |
|
|
stringstream ss;
|
239 |
|
|
ss << i;
|
240 |
|
|
suffix =ss.str()+"_spl";
|
241 |
|
|
}
|
242 |
|
|
h["nTrk"+suffix] = subDir.make<TH1D>(TString("nTrk"+suffix), TString("Num of rec tracks"+suffix),300,0,300);
|
243 |
|
|
h["trkPt"+suffix] = subDir.make<TH1D>(TString("trkPt"+suffix), TString("Pt of rec tracks "+suffix),100,0,100);
|
244 |
yygao |
1.9 |
h["trkEta"+suffix] = subDir.make<TH1D>(TString("trkEta"+suffix), TString("#eta of rec tracks "+suffix),100,-3,3);
|
245 |
yygao |
1.7 |
h["trkPhi"+suffix] = subDir.make<TH1D>(TString("trkPhi"+suffix), TString("#Phi of rec tracks "+suffix),100,-3.2,3.2);
|
246 |
yygao |
1.10 |
h["trkDxy"+suffix] = subDir.make<TH1D>(TString("trkDxy"+suffix), TString("Dxy of rec tracks "+suffix),100,-0.5,0.5);
|
247 |
yygao |
1.7 |
h["trkDz"+suffix] = subDir.make<TH1D>(TString("trkDz"+suffix), TString("Dz of rec tracks "+suffix),100,-50,50);
|
248 |
|
|
|
249 |
|
|
h["nTrkPV"+suffix] = subDir.make<TH1D>(TString("nTrkPV"+suffix), TString("Num of rec tracks in PV"+suffix),300,0,300);
|
250 |
|
|
h["trkPtPV"+suffix] = subDir.make<TH1D>(TString("trkPtPV"+suffix), TString("Pt of rec tracks in "+suffix),100,0,100);
|
251 |
yygao |
1.9 |
h["trkEtaPV"+suffix] = subDir.make<TH1D>(TString("trkEtaPV"+suffix), TString("#eta of rec tracks in PV"+suffix),100,-3,3);
|
252 |
yygao |
1.7 |
h["trkPhiPV"+suffix] = subDir.make<TH1D>(TString("trkPhiPV"+suffix), TString("#Phi of rec tracks in PV"+suffix),100,-3.2,3.2);
|
253 |
|
|
h["trkDxyPV"+suffix] = subDir.make<TH1D>(TString("trkDxyPV"+suffix), TString("Dxy of rec tracks in PV"+suffix),100,-5,5);
|
254 |
|
|
h["trkDzPV"+suffix] = subDir.make<TH1D>(TString("trkDzPV"+suffix), TString("Dz of rec tracks "+suffix),100,-50,50);
|
255 |
|
|
h["nrecPV"+suffix] = subDir.make<TH1D>(TString("nrecPV"+suffix), TString("Num of rec pvtx"+suffix),50,0,50);
|
256 |
|
|
suffix.clear();
|
257 |
|
|
}
|
258 |
|
|
h["nrecPVDiff"] = subDir.make<TH1D>("nrecPVDiff","nrecPV1-nRecPV2",21,-10.5,10.5);
|
259 |
|
|
h["nTrkPVDiff"] = subDir.make<TH1D>("nTrkPVDiff","nTrkPV1-nTrkPV2",41,-20.5,20.5);
|
260 |
|
|
h["nTrkPVRelDiff"] = subDir.make<TH1D>("nTrkPVRelDiff","(nTrkPV1-nTrkPV2)/(nTrkPV1+nTrkPV2)",100,-1,1);
|
261 |
yygao |
1.10 |
|
262 |
|
|
// Histograms on comparing the multi-vertices
|
263 |
|
|
// Difference in reconstructed vtx position
|
264 |
|
|
h["min_xsep"] = subDir.make<TH1D>("min_xsep", "min x diff of primary and secondary pvtx",300,0,0.1);
|
265 |
|
|
h["min_xsep_sign"] = subDir.make<TH1D>("min_xsep_sign", "min x diff in signf of primary and secondary pvtx",300,0,5);
|
266 |
|
|
h["min_ysep"] = subDir.make<TH1D>("min_ysep", "min y diff of primary and secondary pvtx",300,0,0.1);
|
267 |
|
|
h["min_ysep_sign"] = subDir.make<TH1D>("min_ysep_sign", "min y diff in signf of primary and secondary pvtx",300,0,5);
|
268 |
|
|
h["min_zsep"] = subDir.make<TH1D>("min_zsep", "min z diff of primary and secondary pvtx",300,0,5);
|
269 |
|
|
h["min_zsep_sign"] = subDir.make<TH1D>("min_zsep_sign", "min z diff in signf of primary and secondary pvtx",300,0,200);
|
270 |
|
|
// Difference in reconstructed vtx position
|
271 |
|
|
h["min_ntrksep"] = subDir.make<TH1D>("min_ntrksep", "min nTrk diff of primary and secondary pvtx",201,-50.5,150.5);
|
272 |
|
|
h["min_sumpt2sep"] = subDir.make<TH1D>("min_sumpt2sep", "min sumpt2 diff of primary and secondary pvtx",300,0,10000);
|
273 |
|
|
|
274 |
yygao |
1.7 |
//Book histograms sensitive to data/mc
|
275 |
|
|
for (vector<int>::const_iterator it= datamode.begin(); it != datamode.end() ; ++it) {
|
276 |
|
|
string suffix;
|
277 |
|
|
if(verbose_) cout<<"datamode = "<< *it<<endl;
|
278 |
|
|
switch(*it) {
|
279 |
|
|
case 0: suffix = "";
|
280 |
|
|
break;
|
281 |
|
|
case 1: suffix = "_spl1_mct";
|
282 |
|
|
break;
|
283 |
|
|
case 2: suffix = "_spl2_mct";
|
284 |
|
|
break;
|
285 |
|
|
case 3: suffix = "_mct";
|
286 |
|
|
break;
|
287 |
jengbou |
1.2 |
}
|
288 |
yygao |
1.7 |
h["deltax"+suffix] = subDir.make<TH1D>(TString("deltax"+suffix), TString("x-residual pvtx"+suffix),800,-0.04,0.04);
|
289 |
|
|
h["deltay"+suffix] = subDir.make<TH1D>(TString("deltay"+suffix), TString("y-residual pvtx"+suffix),800,-0.04,0.04);
|
290 |
|
|
h["deltaz"+suffix] = subDir.make<TH1D>(TString("deltaz"+suffix), TString("z-residual pvtx"+suffix),800,-0.04,0.04);
|
291 |
|
|
h["pullx"+suffix] = subDir.make<TH1D>(TString("pullx"+suffix), TString("x-pull pvtx"+suffix),800,-10,10);
|
292 |
|
|
h["pully"+suffix] = subDir.make<TH1D>(TString("pully"+suffix), TString("y-pull pvtx"+suffix),800,-10,10);
|
293 |
|
|
h["pullz"+suffix] = subDir.make<TH1D>(TString("pullz"+suffix), TString("z-pull pvtx"+suffix),800,-10,10);
|
294 |
|
|
h["errPVx"+suffix] = subDir.make<TH1D>(TString("errPVx"+suffix), TString("X"+suffix+" vertex error"),100,0.,0.02);
|
295 |
|
|
h["errPVy"+suffix] = subDir.make<TH1D>(TString("errPVy"+suffix), TString("Y"+suffix+" vertex error"),100,0.,0.02);
|
296 |
|
|
h["errPVz"+suffix] = subDir.make<TH1D>(TString("errPVz"+suffix), TString("Z"+suffix+" vertex error"),100,0.,0.02);
|
297 |
|
|
|
298 |
|
|
// Book residual, error and pull histograms for each nTrk bin
|
299 |
jengbou |
1.1 |
for (int ntrk=nTrkMin_;ntrk<=nTrkMax_;++ntrk) {
|
300 |
|
|
stringstream ss;
|
301 |
|
|
ss << ntrk;
|
302 |
yygao |
1.7 |
string suffix2 = suffix+"_"+ss.str();
|
303 |
|
|
h["deltax"+suffix2] = subDir1.make<TH1D>(TString("deltax"+suffix2), TString("x-residual of pvtx"+suffix),100,-0.02,0.02);
|
304 |
|
|
h["deltax"+suffix2]->GetXaxis()->SetTitle("cm");
|
305 |
|
|
h["deltay"+suffix2] = subDir1.make<TH1D>(TString("deltay"+suffix2), TString("y-residual of pvtx"+suffix),100,-0.02,0.02);
|
306 |
|
|
h["deltay"+suffix2]->GetXaxis()->SetTitle("cm");
|
307 |
|
|
h["deltaz"+suffix2] = subDir1.make<TH1D>(TString("deltaz"+suffix2), TString("z-residual of pvtx"+suffix),100,-0.02,0.02);
|
308 |
|
|
h["deltaz"+suffix2]->GetXaxis()->SetTitle("cm");
|
309 |
|
|
h["pullx"+suffix2] = subDir1.make<TH1D>(TString("pullx"+suffix2), TString("x-pull of pvtx"+suffix),100,-10.,10.);
|
310 |
|
|
h["pully"+suffix2] = subDir1.make<TH1D>(TString("pully"+suffix2), TString("y-pull of pvtx"+suffix),100,-10.,10.);
|
311 |
|
|
h["pullz"+suffix2] = subDir1.make<TH1D>(TString("pullz"+suffix2), TString("z-pull of pvtx"+suffix),100,-10.,10.);
|
312 |
|
|
h["errPVx"+suffix2] = subDir1.make<TH1D>(TString("errPVx"+suffix2), TString("X"+suffix+" vertex error"),100,0.,0.02);
|
313 |
|
|
h["errPVy"+suffix2] = subDir1.make<TH1D>(TString("errPVy"+suffix2), TString("Y"+suffix+" vertex error"),100,0.,0.02);
|
314 |
|
|
h["errPVz"+suffix2] = subDir1.make<TH1D>(TString("errPVz"+suffix2), TString("Z"+suffix+" vertex error"),100,0.,0.02);
|
315 |
|
|
suffix2.clear();
|
316 |
|
|
} // End of for (int ntrk=nTrkMin_;ntrk<=nTrkMax_;++ntrk) {
|
317 |
|
|
|
318 |
|
|
// Book residual and pull histograms only when analyzeOntheFly is enabled
|
319 |
|
|
if(analyze_) {
|
320 |
|
|
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);
|
321 |
|
|
h2["resx"+suffix+"_nTrk"]->SetMarkerStyle(21);
|
322 |
|
|
h2["resx"+suffix+"_nTrk"]->SetMarkerColor(4);
|
323 |
|
|
h2["resx"+suffix+"_nTrk"]->GetXaxis()->SetTitle("Num of tracks");
|
324 |
|
|
h2["resx"+suffix+"_nTrk"]->GetYaxis()->SetTitle("#mum");
|
325 |
|
|
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);
|
326 |
|
|
h2["resy"+suffix+"_nTrk"]->SetMarkerStyle(21);
|
327 |
|
|
h2["resy"+suffix+"_nTrk"]->SetMarkerColor(4);
|
328 |
|
|
h2["resy"+suffix+"_nTrk"]->GetXaxis()->SetTitle("Num of tracks");
|
329 |
|
|
h2["resy"+suffix+"_nTrk"]->GetYaxis()->SetTitle("#mum");
|
330 |
|
|
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);
|
331 |
|
|
h2["resz"+suffix+"_nTrk"]->SetMarkerStyle(21);
|
332 |
|
|
h2["resz"+suffix+"_nTrk"]->SetMarkerColor(4);
|
333 |
|
|
h2["resz"+suffix+"_nTrk"]->GetXaxis()->SetTitle("Num of tracks");
|
334 |
|
|
h2["resz"+suffix+"_nTrk"]->GetYaxis()->SetTitle("#mum");
|
335 |
|
|
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.);
|
336 |
|
|
h2["pullx"+suffix+"_nTrk"]->SetMarkerStyle(21);
|
337 |
|
|
h2["pullx"+suffix+"_nTrk"]->SetMarkerColor(4);
|
338 |
|
|
h2["pullx"+suffix+"_nTrk"]->SetBit(TH1::kCanRebin);
|
339 |
|
|
h2["pullx"+suffix+"_nTrk"]->GetXaxis()->SetTitle("Num of tracks");
|
340 |
|
|
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.);
|
341 |
|
|
h2["pully"+suffix+"_nTrk"]->SetMarkerStyle(21);
|
342 |
|
|
h2["pully"+suffix+"_nTrk"]->SetMarkerColor(4);
|
343 |
|
|
h2["pully"+suffix+"_nTrk"]->SetBit(TH1::kCanRebin);
|
344 |
|
|
h2["pully"+suffix+"_nTrk"]->GetXaxis()->SetTitle("Num of tracks");
|
345 |
|
|
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.);
|
346 |
|
|
h2["pullz"+suffix+"_nTrk"]->SetMarkerStyle(21);
|
347 |
|
|
h2["pullz"+suffix+"_nTrk"]->SetMarkerColor(4);
|
348 |
|
|
h2["pullz"+suffix+"_nTrk"]->SetBit(TH1::kCanRebin);
|
349 |
|
|
h2["pullz"+suffix+"_nTrk"]->GetXaxis()->SetTitle("Num of tracks");
|
350 |
|
|
} // End of if(analyze_) {
|
351 |
|
|
suffix.clear();
|
352 |
yygao |
1.10 |
} // End of Book histograms sensitive to data/mc
|
353 |
|
|
|
354 |
|
|
// Book histograms about pixelVertices
|
355 |
|
|
h["trkdz_pxlpvtxdz"] = subDir.make<TH1D>("trkdz_pxlpvtxdz", "(Track dz - pixelpvtx dz) in cm",300,-0.5,0.5);
|
356 |
yygao |
1.11 |
h["trkdz_pxlpvtxdz_pxlpvtxdzerr"] = subDir.make<TH1D>("trkdz_pxlpvtxdz_pxlpvtxdzerr", "|Track dz - pixelpvtx dz| / pxlpvtxdzErr",300,0,100);
|
357 |
yygao |
1.10 |
h["trkdz_pxlpvtxdz_trkdzerr"] = subDir.make<TH1D>("trkdz_pxlpvtxdz_trkdzerr", "|Track dz - pixelpvtx dz| / trkdzErr",300,0,50);
|
358 |
|
|
h["trkdzErr_pxlpvtx"] = subDir.make<TH1D>("trkdzErr_pxlpvtxdz", "Track dzErr of leading pixelpvtx ",300,0,0.5);
|
359 |
|
|
h["trkdzErr_pvtx"] = subDir.make<TH1D>("trkdzErr_pvtx", "Track dzErr of the leading pvtx ",300,0,0.5);
|
360 |
|
|
h["dzErr_pxlpvtx"] = subDir.make<TH1D>("dzErr_pxlpvtx", "zError of the leading pvtx ",300,0,0.5);
|
361 |
yygao |
1.11 |
// Compare offlinePrimaryVertices with pixelVertices
|
362 |
|
|
h["nrecPV_minus_nrecPxlPV"] = subDir.make<TH1D>("nrecPV_minus_nrecPxlPV", "nrecPV_minus_nrecPxlPV",21,-10.5,10.5);
|
363 |
|
|
h["recxPV_minus_recxPxlPV"] = subDir.make<TH1D>("recxPV_minus_recxPxlPV", "recxPV_minus_recxPxlPV",300,-0.02,0.02);
|
364 |
|
|
h["recyPV_minus_recyPxlPV"] = subDir.make<TH1D>("recyPV_minus_recyPxlPV", "recyPV_minus_recyPxlPV",300,-0.02,0.02);
|
365 |
|
|
h["reczPV_minus_reczPxlPV"] = subDir.make<TH1D>("reczPV_minus_reczPxlPV", "reczPV_minus_reczPxlPV",300,-0.1,0.1);
|
366 |
|
|
|
367 |
yygao |
1.7 |
// Book MC only plots
|
368 |
|
|
if (!realData_) {
|
369 |
|
|
h["genPart_T"] = subDir.make<TH1D>("genPart_T","t component of gen particles",300,-0.5,0.5);
|
370 |
|
|
h["genPart_T"]->GetXaxis()->SetTitle("t (nanosecond)");
|
371 |
|
|
h["genPart_cT"] = subDir.make<TH1D>("genPart_cT","ct component of gen particles",300,-150.,150.);
|
372 |
|
|
h["genPart_cT"]->GetXaxis()->SetTitle("ct (mm)");
|
373 |
|
|
h["nsimPV"] = subDir.make<TH1D>("nsimPV","Num of sim PV",51,-0.5,50.5);
|
374 |
jengbou |
1.1 |
}
|
375 |
|
|
}
|
376 |
|
|
|
377 |
|
|
PVStudy::~PVStudy()
|
378 |
|
|
{
|
379 |
|
|
|
380 |
|
|
// do anything here that needs to be done at desctruction time
|
381 |
|
|
// (e.g. close files, deallocate resources etc.)
|
382 |
|
|
|
383 |
|
|
}
|
384 |
|
|
|
385 |
jengbou |
1.4 |
void PVStudy::setRootStyle() {
|
386 |
|
|
//
|
387 |
|
|
gROOT->SetStyle("Plain");
|
388 |
|
|
gStyle->SetFillColor(1);
|
389 |
|
|
gStyle->SetOptDate();
|
390 |
|
|
// gStyle->SetOptStat(1111110);
|
391 |
|
|
// gStyle->SetOptFit(0111);
|
392 |
|
|
// gStyle->SetPadTickX(1);
|
393 |
|
|
// gStyle->SetPadTickY(1);
|
394 |
|
|
gStyle->SetMarkerSize(0.5);
|
395 |
|
|
gStyle->SetMarkerStyle(8);
|
396 |
|
|
gStyle->SetGridStyle(3);
|
397 |
|
|
//gStyle->SetPadGridX(1);
|
398 |
|
|
//gStyle->SetPadGridY(1);
|
399 |
|
|
gStyle->SetPaperSize(TStyle::kA4);
|
400 |
|
|
gStyle->SetStatW(0.25); // width of statistics box; default is 0.19
|
401 |
|
|
// gStyle->SetStatH(0.10); // height of statistics box; default is 0.1
|
402 |
|
|
gStyle->SetStatFormat("6.4g"); // leave default format for now
|
403 |
|
|
gStyle->SetTitleSize(0.055, ""); // size for pad title; default is 0.02
|
404 |
|
|
gStyle->SetLabelSize(0.03, "XYZ"); // size for axis labels; default is 0.04
|
405 |
|
|
gStyle->SetStatFontSize(0.08); // size for stat. box
|
406 |
|
|
gStyle->SetTitleFont(32, "XYZ"); // times-bold-italic font (p. 153) for axes
|
407 |
|
|
gStyle->SetTitleFont(32, ""); // same for pad title
|
408 |
|
|
gStyle->SetLabelFont(32, "XYZ"); // same for axis labels
|
409 |
|
|
gStyle->SetStatFont(32); // same for stat. box
|
410 |
|
|
gStyle->SetLabelOffset(0.006, "Y"); // default is 0.005
|
411 |
|
|
//
|
412 |
|
|
return;
|
413 |
|
|
}
|
414 |
jengbou |
1.1 |
//
|
415 |
|
|
// member functions
|
416 |
|
|
//
|
417 |
|
|
std::vector<PVStudy::simPrimaryVertex> PVStudy::getSimPVs(const Handle<HepMCProduct> evtMC, std::string suffix="")
|
418 |
|
|
{
|
419 |
|
|
std::vector<PVStudy::simPrimaryVertex> simpv;
|
420 |
|
|
const HepMC::GenEvent* evt=evtMC->GetEvent();
|
421 |
|
|
if (evt) {
|
422 |
|
|
if(verbose_) {
|
423 |
|
|
cout << "process id " << evt->signal_process_id()<<endl;
|
424 |
|
|
cout << "signal process vertex " << ( evt->signal_process_vertex() ?
|
425 |
|
|
evt->signal_process_vertex()->barcode() : 0 ) <<endl;
|
426 |
|
|
cout << "number of vertices " << evt->vertices_size() << endl;
|
427 |
|
|
}
|
428 |
|
|
|
429 |
jengbou |
1.6 |
int idx=0; int npv=0;
|
430 |
jengbou |
1.1 |
for(HepMC::GenEvent::vertex_const_iterator vitr= evt->vertices_begin();
|
431 |
jengbou |
1.6 |
vitr != evt->vertices_end(); ++vitr ) { // loop for vertex ...
|
432 |
|
|
HepMC::FourVector pos = (*vitr)->position();
|
433 |
|
|
//HepLorentzVector pos = (*vitr)->position();
|
434 |
|
|
|
435 |
|
|
// t component of PV:
|
436 |
|
|
for ( HepMC::GenVertex::particle_iterator mother = (*vitr)->particles_begin(HepMC::parents);
|
437 |
|
|
mother != (*vitr)->particles_end(HepMC::parents); ++mother ) {
|
438 |
|
|
// std::cout << "Status = " << (*mother)->status() << std::endl;
|
439 |
|
|
HepMC::GenVertex * mv=(*mother)->production_vertex();
|
440 |
|
|
if( ((*mother)->status() == 3) && (!mv)) {
|
441 |
|
|
// std::cout << "npv= " << npv << std::endl;
|
442 |
|
|
if (npv == 0) {
|
443 |
|
|
h["genPart_cT"]->Fill(pos.t()); // mm
|
444 |
|
|
h["genPart_T"]->Fill(pos.t()/299.792458); // ns
|
445 |
|
|
}
|
446 |
|
|
npv++;
|
447 |
|
|
}
|
448 |
|
|
}
|
449 |
|
|
// if (pos.t()>0) { continue;} // for 22X when t of PV was not smeared
|
450 |
jengbou |
1.1 |
|
451 |
jengbou |
1.6 |
bool hasMotherVertex=false;
|
452 |
|
|
if(verbose_) cout << "mothers of vertex[" << ++idx << "]: " << endl;
|
453 |
|
|
for ( HepMC::GenVertex::particle_iterator mother = (*vitr)->particles_begin(HepMC::parents);
|
454 |
|
|
mother != (*vitr)->particles_end(HepMC::parents); ++mother ) {
|
455 |
|
|
HepMC::GenVertex * mv=(*mother)->production_vertex();
|
456 |
|
|
// std::cout << "Status = " << (*mother)->status() << std::endl;
|
457 |
|
|
if (mv) {
|
458 |
|
|
hasMotherVertex=true;
|
459 |
|
|
if(!verbose_) break; //if verbose_, print all particles of gen vertices
|
460 |
|
|
}
|
461 |
|
|
if(verbose_) {
|
462 |
|
|
cout << "\t";
|
463 |
|
|
(*mother)->print();
|
464 |
|
|
}
|
465 |
|
|
}
|
466 |
|
|
|
467 |
|
|
if(hasMotherVertex) continue;
|
468 |
|
|
|
469 |
|
|
// could be a new vertex, check all primaries found so far to avoid multiple entries
|
470 |
|
|
const double mm2cm=0.1;
|
471 |
|
|
simPrimaryVertex sv(pos.x()*mm2cm,pos.y()*mm2cm,pos.z()*mm2cm); // sim unit mm, rec unit cm
|
472 |
|
|
simPrimaryVertex *vp=NULL; // will become non-NULL if a vertex is found and then point to it
|
473 |
|
|
for(vector<simPrimaryVertex>::iterator v0=simpv.begin();
|
474 |
|
|
v0!=simpv.end(); v0++){
|
475 |
|
|
if( (fabs(sv.x-v0->x)<1e-5) && (fabs(sv.y-v0->y)<1e-5) && (fabs(sv.z-v0->z)<1e-5)){
|
476 |
|
|
vp=&(*v0);
|
477 |
|
|
break;
|
478 |
jengbou |
1.1 |
}
|
479 |
jengbou |
1.6 |
}
|
480 |
jengbou |
1.1 |
|
481 |
jengbou |
1.6 |
if(!vp){
|
482 |
|
|
// this is a new vertex
|
483 |
|
|
if(verbose_) cout << "this is a new vertex " << sv.x << " " << sv.y << " " << sv.z << endl;
|
484 |
|
|
simpv.push_back(sv);
|
485 |
|
|
vp=&simpv.back();
|
486 |
|
|
}else{
|
487 |
|
|
if(verbose_) cout << "this is not a new vertex " << sv.x << " " << sv.y << " " << sv.z << endl;
|
488 |
|
|
}
|
489 |
|
|
vp->genVertex.push_back((*vitr)->barcode());
|
490 |
|
|
// collect final state descendants
|
491 |
|
|
for ( HepMC::GenVertex::particle_iterator daughter = (*vitr)->particles_begin(HepMC::descendants);
|
492 |
|
|
daughter != (*vitr)->particles_end(HepMC::descendants);
|
493 |
|
|
++daughter ) {
|
494 |
|
|
if (isFinalstateParticle(*daughter)){
|
495 |
|
|
if ( find(vp->finalstateParticles.begin(), vp->finalstateParticles.end(),(*daughter)->barcode())
|
496 |
|
|
== vp->finalstateParticles.end()){
|
497 |
|
|
vp->finalstateParticles.push_back((*daughter)->barcode());
|
498 |
|
|
HepMC::FourVector m=(*daughter)->momentum();
|
499 |
|
|
// the next four lines used to be "vp->ptot+=m;" in the days of CLHEP::HepLorentzVector
|
500 |
|
|
// but adding FourVectors seems not to be foreseen
|
501 |
|
|
vp->ptot.setPx(vp->ptot.px()+m.px());
|
502 |
|
|
vp->ptot.setPy(vp->ptot.py()+m.py());
|
503 |
|
|
vp->ptot.setPz(vp->ptot.pz()+m.pz());
|
504 |
|
|
vp->ptot.setE(vp->ptot.e()+m.e());
|
505 |
|
|
vp->ptsq+=(m.perp())*(m.perp());
|
506 |
|
|
if ( (m.perp()>0.8) && (fabs(m.pseudoRapidity())<2.5) && isCharged( *daughter ) ){
|
507 |
|
|
vp->nGenTrk++;
|
508 |
jengbou |
1.1 |
}
|
509 |
|
|
}
|
510 |
|
|
}
|
511 |
|
|
}
|
512 |
jengbou |
1.6 |
}
|
513 |
jengbou |
1.1 |
}
|
514 |
|
|
return simpv;
|
515 |
|
|
}
|
516 |
|
|
|
517 |
|
|
std::vector<PVStudy::simPrimaryVertex> PVStudy::getSimPVs(const Handle<HepMCProduct> evtMC,
|
518 |
|
|
const Handle<SimVertexContainer> simVtxs,
|
519 |
|
|
const Handle<SimTrackContainer> simTrks)
|
520 |
|
|
{
|
521 |
|
|
// simvertices don't have enough information to decide,
|
522 |
|
|
// genVertices don't have the simulated coordinates ( with VtxSmeared they might)
|
523 |
|
|
// go through simtracks to get the link between simulated and generated vertices
|
524 |
|
|
std::vector<PVStudy::simPrimaryVertex> simpv;
|
525 |
|
|
int idx=0;
|
526 |
|
|
for(SimTrackContainer::const_iterator t=simTrks->begin();
|
527 |
|
|
t!=simTrks->end(); ++t){
|
528 |
|
|
if ( !(t->noVertex()) && !(t->type()==-99) ){
|
529 |
|
|
double ptsq=0;
|
530 |
|
|
bool primary=false; // something coming directly from the primary vertex
|
531 |
|
|
bool resonance=false; // resonance
|
532 |
|
|
bool track=false; // undecayed, charged particle
|
533 |
|
|
HepMC::GenParticle* gp=evtMC->GetEvent()->barcode_to_particle( (*t).genpartIndex() );
|
534 |
|
|
if (gp) {
|
535 |
|
|
HepMC::GenVertex * gv=gp->production_vertex();
|
536 |
|
|
if (gv) {
|
537 |
|
|
for ( HepMC::GenVertex::particle_iterator
|
538 |
|
|
daughter = gv->particles_begin(HepMC::descendants);
|
539 |
|
|
daughter != gv->particles_end(HepMC::descendants);
|
540 |
|
|
++daughter ) {
|
541 |
|
|
if (isFinalstateParticle(*daughter)){
|
542 |
|
|
ptsq+=(*daughter)->momentum().perp()*(*daughter)->momentum().perp();
|
543 |
|
|
}
|
544 |
|
|
}
|
545 |
|
|
primary = ( gv->position().t()==0);
|
546 |
|
|
//resonance= ( gp->mother() && isResonance(gp->mother())); // in CLHEP/HepMC days
|
547 |
|
|
// no more mother pointer in the improved HepMC GenParticle
|
548 |
|
|
resonance= ( isResonance(*(gp->production_vertex()->particles_in_const_begin())));
|
549 |
|
|
if (gp->status()==1){
|
550 |
|
|
//track=((pdt->particle(gp->pdg_id()))->charge() != 0);
|
551 |
|
|
track=not isCharged(gp);
|
552 |
|
|
}
|
553 |
|
|
}
|
554 |
|
|
}
|
555 |
|
|
|
556 |
|
|
const HepMC::FourVector & v=(*simVtxs)[t->vertIndex()].position();
|
557 |
|
|
//const HepLorentzVector & v=(*simVtxs)[t->vertIndex()].position();
|
558 |
|
|
if(primary or resonance){
|
559 |
|
|
{
|
560 |
|
|
// check all primaries found so far to avoid multiple entries
|
561 |
|
|
bool newVertex=true;
|
562 |
|
|
for(std::vector<PVStudy::simPrimaryVertex>::iterator v0=simpv.begin();
|
563 |
|
|
v0!=simpv.end(); v0++){
|
564 |
|
|
if( (fabs(v0->x-v.x())<0.001) && (fabs(v0->y-v.y())<0.001) && (fabs(v0->z-v.z())<0.001) ){
|
565 |
|
|
if (track) {
|
566 |
|
|
v0->simTrackIndex.push_back(idx);
|
567 |
|
|
if (ptsq>(*v0).ptsq){(*v0).ptsq=ptsq;}
|
568 |
|
|
}
|
569 |
|
|
newVertex=false;
|
570 |
|
|
}
|
571 |
|
|
}
|
572 |
|
|
if(newVertex && !resonance){
|
573 |
|
|
PVStudy::simPrimaryVertex anotherVertex(v.x(),v.y(),v.z());
|
574 |
|
|
if (track) anotherVertex.simTrackIndex.push_back(idx);
|
575 |
|
|
anotherVertex.ptsq=ptsq;
|
576 |
|
|
simpv.push_back(anotherVertex);
|
577 |
|
|
}
|
578 |
|
|
}//
|
579 |
|
|
}
|
580 |
|
|
|
581 |
|
|
}// simtrack has vertex and valid type
|
582 |
|
|
idx++;
|
583 |
|
|
}//simTrack loop
|
584 |
|
|
return simpv;
|
585 |
|
|
}
|
586 |
|
|
|
587 |
|
|
// ------------ method called to for each event ------------
|
588 |
|
|
void
|
589 |
|
|
PVStudy::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup)
|
590 |
|
|
{
|
591 |
|
|
using namespace edm;
|
592 |
yygao |
1.7 |
using namespace reco;
|
593 |
|
|
|
594 |
|
|
if (verbose_)
|
595 |
|
|
cout<<"PVStudy::analyze():"<<endl;
|
596 |
|
|
//=======================================================
|
597 |
|
|
// Initialize Root-tuple variables if needed
|
598 |
|
|
//=======================================================
|
599 |
jengbou |
1.8 |
//if(saventuple_)
|
600 |
yygao |
1.9 |
SetVarToZero();
|
601 |
yygao |
1.7 |
|
602 |
|
|
//=======================================================
|
603 |
|
|
// Track accessors
|
604 |
|
|
//=======================================================
|
605 |
|
|
//trackCollection
|
606 |
|
|
static const reco::TrackCollection s_empty_trackColl;
|
607 |
|
|
const reco::TrackCollection *trackColl = &s_empty_trackColl;
|
608 |
|
|
edm::Handle<reco::TrackCollection> trackCollectionHandle;
|
609 |
|
|
iEvent.getByLabel(trackCollectionTag_, trackCollectionHandle);
|
610 |
|
|
if( iEvent.getByLabel(trackCollectionTag_, trackCollectionHandle)) {
|
611 |
|
|
trackColl = trackCollectionHandle.product();
|
612 |
|
|
} else {
|
613 |
|
|
cout << "trackCollection cannot be found -> using empty collection of same type." <<endl;
|
614 |
|
|
}
|
615 |
yygao |
1.10 |
|
616 |
yygao |
1.7 |
//splitTrackCollection1
|
617 |
|
|
static const reco::TrackCollection s_empty_splitTrackColl1;
|
618 |
|
|
const reco::TrackCollection *splitTrackColl1 = &s_empty_splitTrackColl1;
|
619 |
|
|
edm::Handle<reco::TrackCollection> splitTrackCollection1Handle;
|
620 |
|
|
iEvent.getByLabel(splitTrackCollection1Tag_, splitTrackCollection1Handle);
|
621 |
|
|
if( iEvent.getByLabel(splitTrackCollection1Tag_, splitTrackCollection1Handle)) {
|
622 |
|
|
splitTrackColl1 = splitTrackCollection1Handle.product();
|
623 |
|
|
} else {
|
624 |
|
|
cout << "splitTrackCollection1 cannot be found -> using empty collection of same type." <<endl;
|
625 |
|
|
}
|
626 |
yygao |
1.10 |
|
627 |
yygao |
1.7 |
//splitTrackCollection2
|
628 |
|
|
static const reco::TrackCollection s_empty_splitTrackColl2;
|
629 |
|
|
const reco::TrackCollection *splitTrackColl2 = &s_empty_splitTrackColl2;
|
630 |
|
|
edm::Handle<reco::TrackCollection> splitTrackCollection2Handle;
|
631 |
|
|
iEvent.getByLabel(splitTrackCollection2Tag_, splitTrackCollection2Handle);
|
632 |
|
|
if( iEvent.getByLabel(splitTrackCollection2Tag_, splitTrackCollection2Handle)) {
|
633 |
|
|
splitTrackColl2 = splitTrackCollection2Handle.product();
|
634 |
|
|
} else {
|
635 |
|
|
cout << "splitTrackCollection2 cannot be found -> using empty collection of same type." <<endl;
|
636 |
|
|
}
|
637 |
yygao |
1.10 |
|
638 |
|
|
|
639 |
|
|
//=======================================================
|
640 |
|
|
// Fill trackparameters of the input tracks to pvtx fitter
|
641 |
|
|
//=======================================================
|
642 |
|
|
if(verbose_)
|
643 |
|
|
cout<<"Start filling track parameters of the input tracks to pvtx fitter."<<endl;
|
644 |
|
|
//fillTrackHisto(const reco::TrackCollection *trackColl, int datatype)
|
645 |
|
|
// datatype: unsplittracks (0); splittracks1 (1); splittracks2 (2);
|
646 |
|
|
fillTrackHisto(trackColl, 0);
|
647 |
|
|
fillTrackHisto(splitTrackColl1, 1);
|
648 |
|
|
fillTrackHisto(splitTrackColl2, 2);
|
649 |
|
|
if(verbose_)
|
650 |
|
|
cout<<"End filling track parameters of the input tracks to pvtx fitter."<<endl;
|
651 |
|
|
|
652 |
yygao |
1.7 |
//=======================================================
|
653 |
|
|
// PVTX accessors
|
654 |
|
|
//=======================================================
|
655 |
|
|
//vertexCollection
|
656 |
|
|
static const reco::VertexCollection s_empty_vertexColl;
|
657 |
|
|
const reco::VertexCollection *vertexColl = &s_empty_vertexColl;
|
658 |
|
|
edm::Handle<reco::VertexCollection> vertexCollectionHandle;
|
659 |
|
|
iEvent.getByLabel(vertexCollectionTag_, vertexCollectionHandle);
|
660 |
|
|
if( iEvent.getByLabel(vertexCollectionTag_, vertexCollectionHandle)) {
|
661 |
|
|
vertexColl = vertexCollectionHandle.product();
|
662 |
|
|
} else {
|
663 |
|
|
cout << "vertexCollection cannot be found -> using empty collection of same type." <<endl;
|
664 |
|
|
}
|
665 |
yygao |
1.10 |
|
666 |
yygao |
1.7 |
//splitVertexCollection1
|
667 |
|
|
static const reco::VertexCollection s_empty_splitVertexColl1;
|
668 |
|
|
const reco::VertexCollection *splitVertexColl1 = &s_empty_splitVertexColl1;
|
669 |
|
|
edm::Handle<reco::VertexCollection> splitVertexCollection1Handle;
|
670 |
|
|
iEvent.getByLabel(splitVertexCollection1Tag_, splitVertexCollection1Handle);
|
671 |
|
|
if( iEvent.getByLabel(splitVertexCollection1Tag_, splitVertexCollection1Handle)) {
|
672 |
|
|
splitVertexColl1 = splitVertexCollection1Handle.product();
|
673 |
|
|
} else {
|
674 |
|
|
cout << "splitVertexCollection1 cannot be found -> using empty collection of same type." <<endl;
|
675 |
yygao |
1.10 |
}
|
676 |
|
|
|
677 |
yygao |
1.7 |
//splitVertexCollection2
|
678 |
|
|
static const reco::VertexCollection s_empty_splitVertexColl2;
|
679 |
|
|
const reco::VertexCollection *splitVertexColl2 = &s_empty_splitVertexColl2;
|
680 |
|
|
edm::Handle<reco::VertexCollection> splitVertexCollection2Handle;
|
681 |
|
|
iEvent.getByLabel(splitVertexCollection2Tag_, splitVertexCollection2Handle);
|
682 |
|
|
if( iEvent.getByLabel(splitVertexCollection2Tag_, splitVertexCollection2Handle)) {
|
683 |
|
|
splitVertexColl2 = splitVertexCollection2Handle.product();
|
684 |
|
|
} else {
|
685 |
|
|
cout << "splitVertexCollection2 cannot be found -> using empty collection of same type." <<endl;
|
686 |
|
|
}
|
687 |
yygao |
1.10 |
|
688 |
yygao |
1.9 |
if(verbose_) cout<<"End accessing the track and vertex collections"<<endl;
|
689 |
yygao |
1.7 |
|
690 |
|
|
//=======================================================
|
691 |
|
|
// MC simvtx accessor
|
692 |
|
|
//=======================================================
|
693 |
jengbou |
1.1 |
if (!realData_) {
|
694 |
yygao |
1.7 |
edm::Handle<SimVertexContainer> simVtxs;
|
695 |
jengbou |
1.1 |
iEvent.getByLabel( simG4_, simVtxs);
|
696 |
|
|
|
697 |
yygao |
1.7 |
edm::Handle<SimTrackContainer> simTrks;
|
698 |
jengbou |
1.1 |
iEvent.getByLabel( simG4_, simTrks);
|
699 |
|
|
}
|
700 |
|
|
|
701 |
yygao |
1.7 |
//=======================================================
|
702 |
|
|
// GET PDT
|
703 |
|
|
//=======================================================
|
704 |
jengbou |
1.1 |
try{
|
705 |
|
|
iSetup.getData(pdt);
|
706 |
|
|
}catch(const Exception&){
|
707 |
|
|
cout << "Some problem occurred with the particle data table. This may not work !." <<endl;
|
708 |
|
|
}
|
709 |
yygao |
1.10 |
|
710 |
|
|
//=======================================================
|
711 |
|
|
// GET pixelVertices
|
712 |
|
|
//=======================================================
|
713 |
|
|
static const reco::VertexCollection s_empty_pixelVertexColl;
|
714 |
|
|
const reco::VertexCollection *pixelVertexColl = &s_empty_pixelVertexColl;
|
715 |
|
|
edm::Handle<reco::VertexCollection> pixelVertexCollectionHandle;
|
716 |
|
|
iEvent.getByLabel(pixelVertexCollectionTag_, pixelVertexCollectionHandle);
|
717 |
|
|
if( iEvent.getByLabel(pixelVertexCollectionTag_, pixelVertexCollectionHandle)) {
|
718 |
|
|
pixelVertexColl = pixelVertexCollectionHandle.product();
|
719 |
|
|
} else {
|
720 |
|
|
cout << "pixelVertexCollection cannot be found. -> using empty collection of same type." <<endl;
|
721 |
|
|
}
|
722 |
jengbou |
1.1 |
|
723 |
yygao |
1.7 |
//=======================================================
|
724 |
yygao |
1.10 |
// Fill pixelVertices related histograms
|
725 |
yygao |
1.7 |
//=======================================================
|
726 |
yygao |
1.11 |
nrecPV_pxlpvtx_ = int (pixelVertexColl->size());
|
727 |
yygao |
1.10 |
if(pixelVertexColl->size()>0 && pixelVertexColl->begin()->isValid() && !(pixelVertexColl->begin()->isFake())) {
|
728 |
yygao |
1.11 |
//fillTrackHistoInPV(const reco::VertexCollection *vertexColl, int datatype, bool fillHisto, bool fillNtuple) {
|
729 |
|
|
fillTrackHistoInPV(pixelVertexColl, 4, false, true);
|
730 |
yygao |
1.10 |
h["dzErr_pxlpvtx"]->Fill( pixelVertexColl->begin()->zError());
|
731 |
|
|
// Get the dZ error of the tracks in the leading pixelVertexColl
|
732 |
|
|
for(reco::Vertex::trackRef_iterator t = (pixelVertexColl->begin())->tracks_begin();
|
733 |
|
|
t!= (pixelVertexColl->begin())->tracks_end(); t++) {
|
734 |
|
|
|
735 |
|
|
if ( (**t).charge() < -1 || (**t).charge() > 1 ) {
|
736 |
|
|
// h["trkPtPV"]->Fill(0.);
|
737 |
|
|
}
|
738 |
|
|
else
|
739 |
|
|
h["trkdzErr_pxlpvtx"]->Fill((**t).dzError());
|
740 |
|
|
}
|
741 |
|
|
// Fill the track->dz() in the PV difference from first pixelpvtx
|
742 |
|
|
for(reco::Vertex::trackRef_iterator t = (vertexColl->begin())->tracks_begin();
|
743 |
|
|
t!= (vertexColl->begin())->tracks_end(); t++) {
|
744 |
|
|
// illegal charge
|
745 |
|
|
if ( (**t).charge() < -1 || (**t).charge() > 1 ) {
|
746 |
|
|
// h["trkPtPV"]->Fill(0.);
|
747 |
|
|
}
|
748 |
|
|
else {
|
749 |
|
|
if(pixelVertexColl->size()>0) {
|
750 |
|
|
h["trkdz_pxlpvtxdz"]->Fill((**t).dz() - pixelVertexColl->begin()->z());
|
751 |
|
|
h["trkdz_pxlpvtxdz_pxlpvtxdzerr"]->Fill(fabs((**t).dz() - pixelVertexColl->begin()->z())/pixelVertexColl->begin()->zError());
|
752 |
|
|
h["trkdz_pxlpvtxdz_trkdzerr"]->Fill(fabs((**t).dz() - pixelVertexColl->begin()->z())/(**t).dzError());
|
753 |
|
|
h["trkdzErr_pvtx"]->Fill((**t).dzError());
|
754 |
|
|
}
|
755 |
|
|
}
|
756 |
|
|
}
|
757 |
|
|
}
|
758 |
yygao |
1.7 |
|
759 |
|
|
//=======================================================
|
760 |
yygao |
1.11 |
// Fill number of reconstructed vertices
|
761 |
yygao |
1.7 |
//=======================================================
|
762 |
yygao |
1.10 |
|
763 |
yygao |
1.7 |
if(verbose_) {
|
764 |
|
|
cout<<"PVStudy::analyze() Printing vertexCollection: "<<endl;
|
765 |
|
|
printRecVtxs(vertexCollectionHandle);
|
766 |
|
|
cout<<"PVStudy::analyze() Printing splitVertexCollection1: "<<endl;
|
767 |
|
|
printRecVtxs(splitVertexCollection1Handle);
|
768 |
|
|
cout<<"PVStudy::analyze() Printing splitVertexCollection2: "<<endl;
|
769 |
|
|
printRecVtxs(splitVertexCollection2Handle);
|
770 |
yygao |
1.9 |
cout<<"Start filling pvtx parameters."<<endl;
|
771 |
yygao |
1.7 |
}
|
772 |
yygao |
1.10 |
|
773 |
yygao |
1.9 |
nrecPV_ = int (vertexColl->size());
|
774 |
|
|
nrecPV1_spl_ = int (splitVertexColl1->size());
|
775 |
|
|
nrecPV2_spl_ = int (splitVertexColl2->size());
|
776 |
jengbou |
1.8 |
|
777 |
|
|
h["nrecPV"]->Fill(nrecPV_);
|
778 |
|
|
h["nrecPV1_spl"]->Fill(nrecPV1_spl_);
|
779 |
|
|
h["nrecPV2_spl"]->Fill(nrecPV2_spl_);
|
780 |
|
|
h["nrecPVDiff"]->Fill(double(nrecPV1_spl_)-double(nrecPV2_spl_));
|
781 |
yygao |
1.11 |
|
782 |
yygao |
1.10 |
//=================================================================
|
783 |
|
|
// Fill track parameter ntuple/hist for tracks used in recoVertices
|
784 |
|
|
//=================================================================
|
785 |
|
|
|
786 |
|
|
//fillTrackHistoInPV(const reco::VertexCollection *vertexColl, int datatype, bool fillHisto, bool fillNtuple) {
|
787 |
|
|
if(vertexColl->size() > 0 && vertexColl->begin()->isValid() && !(vertexColl->begin()->isFake()))
|
788 |
|
|
fillTrackHistoInPV(vertexColl, 0, true, true);
|
789 |
|
|
|
790 |
|
|
if(splitVertexColl1->size() > 0 && splitVertexColl1->begin()->isValid() && !(splitVertexColl1->begin()->isFake()))
|
791 |
|
|
fillTrackHistoInPV(splitVertexColl1, 1, false, true);
|
792 |
|
|
|
793 |
|
|
if(splitVertexColl1->size() > 0 && splitVertexColl2->begin()->isValid() && !(splitVertexColl2->begin()->isFake()))
|
794 |
|
|
fillTrackHistoInPV(splitVertexColl2, 2, false, true);
|
795 |
|
|
|
796 |
yygao |
1.11 |
|
797 |
|
|
//=======================================================
|
798 |
|
|
// Compare offlinePrimaryVertices with pixelVertices
|
799 |
|
|
//=======================================================
|
800 |
|
|
if( (pixelVertexColl->size()>0 && pixelVertexColl->begin()->isValid() && !(pixelVertexColl->begin()->isFake()))
|
801 |
|
|
&& (vertexColl->size()>0 && vertexColl->begin()->isValid() && !(vertexColl->begin()->isFake())) ) {
|
802 |
|
|
h["nrecPV_minus_nrecPxlPV"]->Fill( double (nrecPV_ - nrecPV_pxlpvtx_));
|
803 |
|
|
// difference in reconstructed position of the leading pvtx
|
804 |
|
|
//cout<<"recx_[0] = "<< recx_[0] << "recx_pxlpvtx_[0] = "<< recx_pxlpvtx_[0]<<endl;
|
805 |
|
|
//cout<<"recy_[0] = "<< recy_[0] << "recy_pxlpvtx_[0] = "<< recy_pxlpvtx_[0]<<endl;
|
806 |
|
|
h["recxPV_minus_recxPxlPV"]->Fill (recx_[0] - recx_pxlpvtx_[0]);
|
807 |
|
|
h["recyPV_minus_recyPxlPV"]->Fill (recy_[0] - recy_pxlpvtx_[0]);
|
808 |
|
|
h["reczPV_minus_reczPxlPV"]->Fill (recz_[0] - recz_pxlpvtx_[0]);
|
809 |
|
|
}
|
810 |
|
|
|
811 |
|
|
|
812 |
|
|
|
813 |
yygao |
1.10 |
//==========================================================
|
814 |
|
|
// Fill secondary/primary min separations for multi-vertices
|
815 |
|
|
//==========================================================
|
816 |
|
|
|
817 |
|
|
if(vertexColl->size()>1 && vertexColl->begin()->isValid() && !(vertexColl->begin()->isFake()) ) {
|
818 |
|
|
|
819 |
|
|
double min_xsep = 9999.0;
|
820 |
|
|
double min_ysep = 9999.0;
|
821 |
|
|
double min_zsep = 9999.0;
|
822 |
|
|
double min_xsep_sign = 9999.0;
|
823 |
|
|
double min_ysep_sign = 9999.0;
|
824 |
|
|
double min_zsep_sign = 9999.0;
|
825 |
|
|
double min_ntrksep = 9999.0;
|
826 |
|
|
double min_sumpt2sep = 9999999.0;
|
827 |
yygao |
1.9 |
|
828 |
yygao |
1.10 |
if(verbose_) cout<<"leading pvtx z = "<< vertexColl->begin()->z() <<endl;
|
829 |
|
|
|
830 |
|
|
// Looping through the secondary vertices to find the mininum separation to the primary
|
831 |
|
|
for(reco::VertexCollection::const_iterator v=vertexColl->begin() + 1 ;
|
832 |
|
|
v!=vertexColl->end(); ++v) {
|
833 |
|
|
if(v->isValid() && ! v->isFake()) {
|
834 |
|
|
// xsep
|
835 |
|
|
if(fabs(v->x()- vertexColl->begin()->x())<min_xsep)
|
836 |
|
|
min_xsep = fabs(v->x()- vertexColl->begin()->x());
|
837 |
|
|
// ysep
|
838 |
|
|
if(fabs(v->y()- vertexColl->begin()->y())<min_ysep)
|
839 |
|
|
min_ysep = fabs(v->y()- vertexColl->begin()->y());
|
840 |
|
|
// zsep
|
841 |
|
|
if(fabs(v->z()- vertexColl->begin()->z())<min_zsep)
|
842 |
|
|
min_zsep = fabs(v->z()- vertexColl->begin()->z());
|
843 |
|
|
// xsep_sign
|
844 |
|
|
double xsep_sign = fabs(v->x()- vertexColl->begin()->x())/max(v->xError(), vertexColl->begin()->xError());
|
845 |
|
|
if(xsep_sign < min_xsep_sign)
|
846 |
|
|
min_xsep_sign = xsep_sign;
|
847 |
|
|
// ysep_sign
|
848 |
|
|
double ysep_sign = fabs(v->y()- vertexColl->begin()->y())/max(v->yError(), vertexColl->begin()->yError());
|
849 |
|
|
if(ysep_sign < min_ysep_sign)
|
850 |
|
|
min_ysep_sign = ysep_sign;
|
851 |
|
|
// zsep_sign
|
852 |
|
|
double zsep_sign = fabs(v->z()- vertexColl->begin()->z())/max(v->zError(), vertexColl->begin()->zError());
|
853 |
|
|
if(zsep_sign < min_zsep_sign)
|
854 |
|
|
min_zsep_sign = zsep_sign;
|
855 |
|
|
// ntrksep
|
856 |
|
|
if( (double(vertexColl->begin()->tracksSize()) - double(v->tracksSize())) < min_ntrksep)
|
857 |
|
|
min_ntrksep = double(vertexColl->begin()->tracksSize()) - double(v->tracksSize());
|
858 |
|
|
// sumpt2sep
|
859 |
|
|
if(fabs(sumPtSquared(*v) - sumPtSquared(*(vertexColl->begin()))) < min_sumpt2sep)
|
860 |
|
|
min_sumpt2sep = fabs(sumPtSquared(*v) - sumPtSquared(*(vertexColl->begin())));
|
861 |
|
|
}
|
862 |
|
|
}
|
863 |
|
|
h["min_xsep"]->Fill(min_xsep);
|
864 |
|
|
h["min_ysep"]->Fill(min_ysep);
|
865 |
|
|
h["min_zsep"]->Fill(min_zsep);
|
866 |
|
|
h["min_xsep_sign"]->Fill(min_xsep_sign);
|
867 |
|
|
h["min_ysep_sign"]->Fill(min_ysep_sign);
|
868 |
|
|
h["min_zsep_sign"]->Fill(min_zsep_sign);
|
869 |
|
|
h["min_ntrksep"]->Fill(min_ntrksep);
|
870 |
|
|
h["min_sumpt2sep"]->Fill(min_sumpt2sep);
|
871 |
|
|
|
872 |
|
|
min_zsep_ = min_zsep;
|
873 |
|
|
min_ntrksep_ = min_ntrksep;
|
874 |
|
|
min_sumpt2sep_ = min_sumpt2sep;
|
875 |
|
|
|
876 |
|
|
|
877 |
|
|
} // End of if(vertexColl->size()>1) {
|
878 |
|
|
|
879 |
yygao |
1.9 |
if(verbose_)
|
880 |
|
|
cout<<"End filling pvtx parameters."<<endl;
|
881 |
yygao |
1.7 |
|
882 |
yygao |
1.9 |
//=======================================================
|
883 |
|
|
// PrimaryVertex Matching
|
884 |
|
|
// 1. In z |z1-z2|< zsigncut * max(sigmaz1, sigmaz2)
|
885 |
|
|
// 2. |(nTrkPV1 - nTrkPV2)/(nTrkPV1+nTrkPV2)|<ntrkdiffcut_
|
886 |
|
|
// Assume the first match is the primary vertex,
|
887 |
|
|
// since vertexColl are sorted in decreasing order of sum(pT)
|
888 |
|
|
//=======================================================
|
889 |
|
|
|
890 |
|
|
if(verbose_) cout<<"PVStudy::analyze(): matching pvtxs "<<endl;
|
891 |
|
|
reco::VertexCollection s_empty_matchedVertexColl1;
|
892 |
|
|
reco::VertexCollection *matchedVertexColl1 = &s_empty_matchedVertexColl1;
|
893 |
|
|
matchedVertexColl1->reserve(splitVertexColl1->size());
|
894 |
|
|
reco::VertexCollection s_empty_matchedVertexColl2;
|
895 |
|
|
reco::VertexCollection *matchedVertexColl2 = &s_empty_matchedVertexColl2;
|
896 |
|
|
matchedVertexColl2->reserve(splitVertexColl2->size());
|
897 |
yygao |
1.7 |
|
898 |
yygao |
1.10 |
bool stopmatching = false;
|
899 |
|
|
for (size_t ivtx = 0; ivtx<splitVertexCollection1Handle->size() && !stopmatching; ++ivtx) {
|
900 |
yygao |
1.9 |
reco::VertexRef recvtx1(splitVertexCollection1Handle, ivtx);
|
901 |
yygao |
1.10 |
if( !(recvtx1->isValid()) || recvtx1->isFake()) break;
|
902 |
|
|
for (size_t jvtx = ivtx; jvtx < splitVertexCollection2Handle->size(); ++jvtx) {
|
903 |
|
|
//------------------------------------------------------------------------
|
904 |
|
|
//== If only considering matching the first vertex of the splitVertexColl
|
905 |
|
|
//------------------------------------------------------------------------
|
906 |
|
|
if (ivtx!=0 || jvtx!=0) { stopmatching = true; break; }
|
907 |
yygao |
1.9 |
reco::VertexRef recvtx2(splitVertexCollection2Handle, jvtx);
|
908 |
yygao |
1.10 |
if( !(recvtx2->isValid()) || recvtx2->isFake()) break;
|
909 |
|
|
if(verbose_) {
|
910 |
|
|
cout<<"Matching splitVertexColl1: # "<< ivtx<< " and splitVertexColl1: # "<<jvtx<<endl;
|
911 |
|
|
cout<<"recvtx1->z() = " << recvtx1->z() << "+/- "<< recvtx1->zError() << "." << endl;
|
912 |
|
|
cout<<"recvtx2->z() = " << recvtx2->z() << "+/- "<< recvtx2->zError() << "." << endl;
|
913 |
|
|
}
|
914 |
yygao |
1.9 |
if(matchVertex(recvtx1, recvtx2, zsigncut_)) {
|
915 |
|
|
if(verbose_) {
|
916 |
yygao |
1.10 |
cout<<"The two splitted vertices match in Z. "<<endl;
|
917 |
yygao |
1.7 |
}
|
918 |
yygao |
1.9 |
int nTrkPV1 = recvtx1->tracksSize();
|
919 |
|
|
int nTrkPV2 = recvtx2->tracksSize();
|
920 |
|
|
double ntrkreldiff = double(nTrkPV1-nTrkPV2)/double(nTrkPV1+nTrkPV2);
|
921 |
|
|
h["nTrkPVDiff"]->Fill(nTrkPV1-nTrkPV2);
|
922 |
|
|
h["nTrkPVRelDiff"]->Fill(ntrkreldiff);
|
923 |
|
|
if(fabs(ntrkreldiff)<ntrkdiffcut_) {
|
924 |
|
|
if(verbose_) {
|
925 |
|
|
cout<<"(nTrkPV1-nTrkPV2)/(nTrkPV1+nTrkPV2) = " << ntrkreldiff<<endl;
|
926 |
yygao |
1.7 |
}
|
927 |
yygao |
1.9 |
matchedVertexColl1->push_back(*recvtx1);
|
928 |
|
|
matchedVertexColl2->push_back(*recvtx2);
|
929 |
yygao |
1.10 |
stopmatching = true; // stop the matching when the first match is found!
|
930 |
|
|
break;
|
931 |
yygao |
1.7 |
}
|
932 |
yygao |
1.9 |
else
|
933 |
|
|
cout<<"WARNING: (nTrkPV1-nTrkPV2)/(nTrkPV1+nTrkPV2) = " << ntrkreldiff<<", exceeding cut "<<ntrkdiffcut_<<endl;
|
934 |
yygao |
1.7 |
}
|
935 |
yygao |
1.9 |
else {
|
936 |
|
|
cout<<"WARNING: The two reconstructed vertices do not match in z: "<<endl;
|
937 |
|
|
cout<<"recvtx1->z() = " << recvtx1->z() << "+/- "<< recvtx1->zError() << "." << endl;
|
938 |
|
|
cout<<"recvtx2->z() = " << recvtx2->z() << "+/- "<< recvtx2->zError() << "." << endl;
|
939 |
yygao |
1.7 |
}
|
940 |
|
|
}
|
941 |
yygao |
1.9 |
}
|
942 |
|
|
if(verbose_) cout<<"PVStudy::analyze(): End matching pvtxs"<<endl;
|
943 |
|
|
|
944 |
|
|
//=======================================================
|
945 |
|
|
// Analyze matchedVertexColls
|
946 |
|
|
//=======================================================
|
947 |
|
|
if(verbose_) {
|
948 |
|
|
cout<<"Begin analyzing the matchedVertexColl with size = "<< matchedVertexColl1->size()<< endl;
|
949 |
|
|
}
|
950 |
|
|
|
951 |
|
|
// Compare the reconstructed vertex position and calculate resolution/pulls
|
952 |
|
|
if(matchedVertexColl1->size() != 0 && matchedVertexColl2->size() != 0) {
|
953 |
|
|
//fillPvtxHisto(const reco::VertexCollection *vertexColl, int datatype, bool fillHisto, bool fillNtuple)
|
954 |
|
|
fillTrackHistoInPV(matchedVertexColl1, 1, true, false);
|
955 |
|
|
fillTrackHistoInPV(matchedVertexColl2, 2, true, false);
|
956 |
|
|
|
957 |
|
|
reco::VertexCollection::const_iterator v1;
|
958 |
|
|
reco::VertexCollection::const_iterator v2;
|
959 |
|
|
nrecPV_twovtx_ = 0;
|
960 |
|
|
for(v1 = matchedVertexColl1->begin(), v2 = matchedVertexColl2->begin();
|
961 |
|
|
v1!=matchedVertexColl1->end(), v2 != matchedVertexColl2->end();
|
962 |
|
|
++v1, ++v2) {
|
963 |
|
|
fres_[0] = (v1->x()-v2->x())/sqrt(2.0);
|
964 |
|
|
fres_[1] = (v1->y()-v2->y())/sqrt(2.0);
|
965 |
|
|
fres_[2] = (v1->z()-v2->z())/sqrt(2.0);
|
966 |
|
|
ferror_[0] = sqrt(pow(v1->xError(),2)+pow(v2->xError(),2))/sqrt(2);
|
967 |
|
|
ferror_[1] = sqrt(pow(v1->yError(),2)+pow(v2->yError(),2))/sqrt(2);
|
968 |
|
|
ferror_[2] = sqrt(pow(v1->zError(),2)+pow(v2->zError(),2))/sqrt(2);
|
969 |
|
|
fntrk_ = (v1->tracksSize()+v2->tracksSize())/2;
|
970 |
|
|
|
971 |
|
|
h["deltax"]->Fill( fres_[0] );
|
972 |
|
|
h["deltay"]->Fill( fres_[1] );
|
973 |
|
|
h["deltaz"]->Fill( fres_[2] );
|
974 |
|
|
h["pullx"]->Fill( fres_[0]/ferror_[0]);
|
975 |
|
|
h["pully"]->Fill( fres_[1]/ferror_[1]);
|
976 |
|
|
h["pullz"]->Fill( fres_[2]/ferror_[2]);
|
977 |
|
|
h["errPVx"]->Fill( ferror_[0] );
|
978 |
|
|
h["errPVy"]->Fill( ferror_[1] );
|
979 |
|
|
h["errPVz"]->Fill( ferror_[2] );
|
980 |
|
|
pvinfo.push_back(PVStudy::PVInfo(res(fres_[0], fres_[1], fres_[2]),
|
981 |
|
|
error(ferror_[0], ferror_[1], ferror_[2]),
|
982 |
|
|
fntrk_));
|
983 |
|
|
// Fill histo according to its track multiplicity, set datamode = 0 for pvtx using all tracks
|
984 |
|
|
fillHisto(res(fres_[0], fres_[1], fres_[2]),
|
985 |
|
|
error(ferror_[0], ferror_[1], ferror_[2]),
|
986 |
|
|
fntrk_,0);
|
987 |
|
|
// Fill the ntuple variables
|
988 |
|
|
nTrkPV1_spl_twovtx_[nrecPV_twovtx_] = v1->tracksSize();
|
989 |
|
|
nTrkPV2_spl_twovtx_[nrecPV_twovtx_] = v2->tracksSize();
|
990 |
|
|
sumptsq1_spl_twovtx_[nrecPV_twovtx_] = sumPtSquared(*v1);
|
991 |
|
|
sumptsq2_spl_twovtx_[nrecPV_twovtx_] = sumPtSquared(*v2);
|
992 |
|
|
nTrkPV_twovtx_[nrecPV_twovtx_] = fntrk_;
|
993 |
|
|
deltax_twovtx_[nrecPV_twovtx_] = fres_[0];
|
994 |
|
|
deltay_twovtx_[nrecPV_twovtx_] = fres_[1];
|
995 |
|
|
deltaz_twovtx_[nrecPV_twovtx_] = fres_[2];
|
996 |
|
|
errx_twovtx_[nrecPV_twovtx_] = ferror_[0];
|
997 |
|
|
erry_twovtx_[nrecPV_twovtx_] = ferror_[1];
|
998 |
|
|
errz_twovtx_[nrecPV_twovtx_] = ferror_[2];
|
999 |
|
|
pullx_twovtx_[nrecPV_twovtx_] = fres_[0]/ferror_[0];
|
1000 |
|
|
pully_twovtx_[nrecPV_twovtx_] = fres_[1]/ferror_[1];
|
1001 |
|
|
pullz_twovtx_[nrecPV_twovtx_] = fres_[2]/ferror_[2];
|
1002 |
|
|
nrecPV_twovtx_++;
|
1003 |
|
|
} // End of analyzing res/pull
|
1004 |
|
|
} // End of if(matchedVertexColl1->size() == 1 && matchedVertexColl2->size() == 1 ) {
|
1005 |
|
|
else
|
1006 |
|
|
cout<<"WARNING: Cannot find matching pvtxs"<<endl;
|
1007 |
|
|
|
1008 |
|
|
if(verbose_) cout<<"End analyzing the matchedVertexColl"<<endl;
|
1009 |
yygao |
1.7 |
|
1010 |
|
|
//=======================================================
|
1011 |
|
|
// Fill simulated vertices
|
1012 |
|
|
//=======================================================
|
1013 |
jengbou |
1.1 |
if (!realData_) {
|
1014 |
|
|
bool MC=false;
|
1015 |
|
|
Handle<HepMCProduct> evtMC;
|
1016 |
|
|
iEvent.getByLabel("generator",evtMC);
|
1017 |
|
|
if (!evtMC.isValid()) {
|
1018 |
|
|
MC=false;
|
1019 |
|
|
if(verbose_){
|
1020 |
|
|
cout << "no HepMCProduct found"<< endl;
|
1021 |
|
|
}
|
1022 |
|
|
} else {
|
1023 |
|
|
if(verbose_){
|
1024 |
|
|
cout << "generator HepMCProduct found"<< endl;
|
1025 |
|
|
}
|
1026 |
|
|
MC=true;
|
1027 |
|
|
}
|
1028 |
yygao |
1.7 |
|
1029 |
jengbou |
1.1 |
if(MC){
|
1030 |
|
|
// make a list of primary vertices:
|
1031 |
|
|
std::vector<simPrimaryVertex> simpv;
|
1032 |
|
|
simpv=getSimPVs(evtMC,"");
|
1033 |
|
|
// simpv=getSimPVs(evtMC, simVtxs, simTrks);
|
1034 |
yygao |
1.7 |
h["nsimPV"]->Fill(simpv.size());
|
1035 |
yygao |
1.9 |
nsimPV_ = simpv.size();
|
1036 |
|
|
|
1037 |
|
|
int isimpv = 0;
|
1038 |
jengbou |
1.1 |
for(std::vector<simPrimaryVertex>::iterator vsim=simpv.begin();
|
1039 |
yygao |
1.9 |
vsim!=simpv.end(); vsim++, isimpv++){
|
1040 |
|
|
nsimTrkPV_[isimpv] =vsim->nGenTrk;
|
1041 |
|
|
simx_[isimpv] = vsim->x;
|
1042 |
|
|
simy_[isimpv] = vsim->y;
|
1043 |
|
|
simz_[isimpv] = vsim->y;
|
1044 |
|
|
simptsq_[isimpv] = vsim->ptsq;
|
1045 |
|
|
|
1046 |
|
|
//fillMCHisto((std::vector<simPrimaryVertex>::iterator vsim, int isimpv, const reco::VertexCollection *vtxColl, int datatype) {
|
1047 |
|
|
fillMCHisto(vsim, isimpv, splitVertexColl1, 1);
|
1048 |
|
|
fillMCHisto(vsim, isimpv, splitVertexColl2, 2);
|
1049 |
|
|
fillMCHisto(vsim, isimpv, vertexColl, 3);
|
1050 |
yygao |
1.7 |
}
|
1051 |
|
|
} // End of for(std::vector<simPrimaryVertex>::iterator vsim=simpv.begin()
|
1052 |
yygao |
1.9 |
} // End of if (!realData_) {
|
1053 |
|
|
|
1054 |
|
|
// Finally fill the ftree_
|
1055 |
|
|
if(saventuple_) {
|
1056 |
|
|
ftree_->Fill();
|
1057 |
|
|
pvtxtree_->Fill();
|
1058 |
|
|
}
|
1059 |
jengbou |
1.1 |
}
|
1060 |
|
|
|
1061 |
|
|
// ------------ method called once each job just before starting event loop ------------
|
1062 |
|
|
void
|
1063 |
|
|
PVStudy::beginJob()
|
1064 |
|
|
{
|
1065 |
|
|
}
|
1066 |
|
|
|
1067 |
|
|
// ------------ method called once each job just after ending the event loop ------------
|
1068 |
|
|
void
|
1069 |
|
|
PVStudy::endJob() {
|
1070 |
yygao |
1.7 |
if (verbose_) cout << "Analyzing PV info" << endl;
|
1071 |
|
|
// Looping through the datamodes available
|
1072 |
|
|
for (vector<int>::const_iterator it= datamode.begin(); it != datamode.end() ; ++it) {
|
1073 |
|
|
string suffix;
|
1074 |
|
|
if(verbose_) cout<<"datamode = "<< *it<<endl;
|
1075 |
|
|
switch(*it) {
|
1076 |
|
|
case 0: suffix = "";
|
1077 |
|
|
break;
|
1078 |
|
|
case 1: suffix = "_spl1_mct";
|
1079 |
|
|
break;
|
1080 |
|
|
case 2: suffix = "_spl2_mct";
|
1081 |
|
|
break;
|
1082 |
|
|
case 3: suffix = "_mct";
|
1083 |
|
|
break;
|
1084 |
|
|
}
|
1085 |
yygao |
1.9 |
if(analyze_) {
|
1086 |
jengbou |
1.8 |
for (int ntrk=nTrkMin_;ntrk<=nTrkMax_;++ntrk) {
|
1087 |
|
|
PVStudy::PVAnaInfo ipv = GetPVAnaInfo(ntrk,*it);
|
1088 |
yygao |
1.7 |
if ( ipv.res_.x() > 0 ) h2["resx"+suffix+"_nTrk"]->Fill(ntrk,ipv.res_.x(), 1.);
|
1089 |
|
|
if ( ipv.res_.y() > 0 ) h2["resy"+suffix+"_nTrk"]->Fill(ntrk,ipv.res_.y(), 1.);
|
1090 |
|
|
if ( ipv.res_.z() > 0 ) h2["resz"+suffix+"_nTrk"]->Fill(ntrk,ipv.res_.z(), 1.);
|
1091 |
|
|
if ( ipv.pull_.x() > 0 ) h2["pullx"+suffix+"_nTrk"]->Fill(ntrk,ipv.pull_.x(), 1.);
|
1092 |
|
|
if ( ipv.pull_.y() > 0 ) h2["pully"+suffix+"_nTrk"]->Fill(ntrk,ipv.pull_.y(), 1.);
|
1093 |
|
|
if ( ipv.pull_.z() > 0 ) h2["pullz"+suffix+"_nTrk"]->Fill(ntrk,ipv.pull_.z(), 1.);
|
1094 |
jengbou |
1.2 |
}
|
1095 |
yygao |
1.9 |
}
|
1096 |
yygao |
1.7 |
suffix.clear();
|
1097 |
jengbou |
1.1 |
}
|
1098 |
jengbou |
1.8 |
if(saventuple_) {
|
1099 |
|
|
file_->cd();
|
1100 |
|
|
ftree_->Write();
|
1101 |
yygao |
1.9 |
pvtxtree_->Write();
|
1102 |
jengbou |
1.8 |
file_->Close();
|
1103 |
|
|
}
|
1104 |
jengbou |
1.1 |
}
|
1105 |
|
|
|
1106 |
yygao |
1.7 |
|
1107 |
|
|
|
1108 |
|
|
// Match a recovertex with a simvertex
|
1109 |
|
|
// ? Should the cut be parameter dependent?
|
1110 |
|
|
// cut can be within n sigma of the vertex.zerror()
|
1111 |
jengbou |
1.1 |
bool PVStudy::matchVertex(const PVStudy::simPrimaryVertex & vsim,
|
1112 |
|
|
const reco::Vertex & vrec)
|
1113 |
|
|
{
|
1114 |
|
|
return (fabs(vsim.z-vrec.z())<0.0500); // =500um
|
1115 |
|
|
}
|
1116 |
|
|
|
1117 |
yygao |
1.7 |
// Match two reconstructed vertices
|
1118 |
yygao |
1.9 |
bool PVStudy::matchVertex( const reco::VertexRef & vrec1,
|
1119 |
|
|
const reco::VertexRef & vrec2,
|
1120 |
|
|
int zsigncut)
|
1121 |
yygao |
1.7 |
{
|
1122 |
yygao |
1.9 |
double cut = zsigncut*max(vrec1->zError(), vrec2->zError());
|
1123 |
|
|
if(verbose_)
|
1124 |
|
|
cout<<"The matching criteria in z is "<<cut<<endl;
|
1125 |
|
|
return (fabs(vrec1->z()-vrec2->z())<cut);
|
1126 |
yygao |
1.7 |
}
|
1127 |
|
|
|
1128 |
|
|
|
1129 |
jengbou |
1.1 |
bool PVStudy::isResonance(const HepMC::GenParticle * p){
|
1130 |
|
|
double ctau=(pdt->particle( abs(p->pdg_id()) ))->lifetime();
|
1131 |
|
|
if(verbose_) cout << "isResonance " << p->pdg_id() << " " << ctau << endl;
|
1132 |
|
|
return ctau >0 && ctau <1e-6;
|
1133 |
|
|
}
|
1134 |
|
|
|
1135 |
|
|
bool PVStudy::isFinalstateParticle(const HepMC::GenParticle * p){
|
1136 |
|
|
return ( !p->end_vertex() && p->status()==1 );
|
1137 |
|
|
}
|
1138 |
|
|
|
1139 |
|
|
bool PVStudy::isCharged(const HepMC::GenParticle * p){
|
1140 |
|
|
const ParticleData * part = pdt->particle( p->pdg_id() );
|
1141 |
|
|
if (part){
|
1142 |
|
|
return part->charge()!=0;
|
1143 |
|
|
}else{
|
1144 |
|
|
// the new/improved particle table doesn't know anti-particles
|
1145 |
|
|
return pdt->particle( -p->pdg_id() )!=0;
|
1146 |
|
|
}
|
1147 |
|
|
}
|
1148 |
|
|
|
1149 |
|
|
void PVStudy::printSimVtxs(const Handle<SimVertexContainer> simVtxs){
|
1150 |
|
|
int i=0;
|
1151 |
|
|
for(SimVertexContainer::const_iterator vsim=simVtxs->begin();
|
1152 |
|
|
vsim!=simVtxs->end(); ++vsim){
|
1153 |
|
|
cout << i++ << ")" << scientific
|
1154 |
|
|
<< " evtid=" << vsim->eventId().event()
|
1155 |
|
|
<< " sim x=" << vsim->position().x()
|
1156 |
|
|
<< " sim y=" << vsim->position().y()
|
1157 |
|
|
<< " sim z=" << vsim->position().z()
|
1158 |
|
|
<< " sim t=" << vsim->position().t()
|
1159 |
|
|
<< " parent=" << vsim->parentIndex()
|
1160 |
|
|
<< endl;
|
1161 |
|
|
}
|
1162 |
|
|
}
|
1163 |
|
|
|
1164 |
|
|
void PVStudy::printRecVtxs(const Handle<reco::VertexCollection> recVtxs){
|
1165 |
|
|
int ivtx=0;
|
1166 |
|
|
for(reco::VertexCollection::const_iterator v=recVtxs->begin();
|
1167 |
|
|
v!=recVtxs->end(); ++v){
|
1168 |
|
|
cout << "Recvtx "<< std::setw(3) << std::setfill(' ')<<ivtx++
|
1169 |
|
|
<< "#trk " << std::setw(3) << v->tracksSize()
|
1170 |
|
|
<< " chi2 " << std::setw(4) << v->chi2()
|
1171 |
|
|
<< " ndof " << std::setw(3) << v->ndof() << endl
|
1172 |
|
|
<< " x " << std::setw(8) <<std::fixed << std::setprecision(4) << v->x()
|
1173 |
|
|
<< " dx " << std::setw(8) << v->xError()<< endl
|
1174 |
|
|
<< " y " << std::setw(8) << v->y()
|
1175 |
|
|
<< " dy " << std::setw(8) << v->yError()<< endl
|
1176 |
|
|
<< " z " << std::setw(8) << v->z()
|
1177 |
|
|
<< " dz " << std::setw(8) << v->zError()
|
1178 |
|
|
<< endl;
|
1179 |
|
|
}
|
1180 |
|
|
}
|
1181 |
|
|
|
1182 |
|
|
void PVStudy::printSimTrks(const Handle<SimTrackContainer> simTrks){
|
1183 |
|
|
cout << " simTrks type, (momentum), vertIndex, genpartIndex" << endl;
|
1184 |
|
|
int i=1;
|
1185 |
|
|
for(SimTrackContainer::const_iterator t=simTrks->begin();
|
1186 |
|
|
t!=simTrks->end(); ++t){
|
1187 |
|
|
//HepMC::GenParticle* gp=evtMC->GetEvent()->particle( (*t).genpartIndex() );
|
1188 |
|
|
cout << i++ << ")"
|
1189 |
|
|
<< (*t)
|
1190 |
|
|
<< " index="
|
1191 |
|
|
<< (*t).genpartIndex();
|
1192 |
|
|
//if (gp) {
|
1193 |
|
|
// HepMC::GenVertex *gv=gp->production_vertex();
|
1194 |
|
|
// cout << " genvertex =" << (*gv);
|
1195 |
|
|
//}
|
1196 |
|
|
cout << endl;
|
1197 |
|
|
}
|
1198 |
|
|
}
|
1199 |
|
|
|
1200 |
yygao |
1.7 |
void PVStudy::fillHisto(res r, error er, int ntk, int datamode){
|
1201 |
jengbou |
1.3 |
stringstream ss;
|
1202 |
|
|
ss << ntk;
|
1203 |
|
|
string suffix = ss.str();
|
1204 |
yygao |
1.7 |
if(datamode == 0 ) suffix = "_" + suffix;
|
1205 |
|
|
if(datamode == 1 ) suffix = "_spl1_mct_" + suffix;
|
1206 |
|
|
if(datamode == 2 ) suffix = "_spl2_mct_" + suffix;
|
1207 |
|
|
if(datamode == 3 ) suffix = "_mct_" + suffix;
|
1208 |
|
|
|
1209 |
jengbou |
1.3 |
if (ntk < nTrkMin_ || ntk > nTrkMax_ ) return;
|
1210 |
|
|
// Fill histograms of res and pull of ntk
|
1211 |
yygao |
1.7 |
h["deltax"+suffix]->Fill(r.x());
|
1212 |
|
|
h["deltay"+suffix]->Fill(r.y());
|
1213 |
|
|
h["deltaz"+suffix]->Fill(r.z());
|
1214 |
|
|
h["pullx"+suffix]->Fill(r.x()/er.x());
|
1215 |
|
|
h["pully"+suffix]->Fill(r.y()/er.y());
|
1216 |
|
|
h["pullz"+suffix]->Fill(r.z()/er.z());
|
1217 |
|
|
h["errPVx"+suffix]->Fill(er.x());
|
1218 |
|
|
h["errPVy"+suffix]->Fill(er.y());
|
1219 |
|
|
h["errPVz"+suffix]->Fill(er.z());
|
1220 |
jengbou |
1.3 |
}
|
1221 |
|
|
|
1222 |
yygao |
1.7 |
PVStudy::PVAnaInfo PVStudy::GetPVAnaInfo(int ntk, int datamode) {
|
1223 |
jengbou |
1.1 |
map<int,double> data;
|
1224 |
jengbou |
1.2 |
data.clear();
|
1225 |
jengbou |
1.4 |
double fpar[2] = {-999,-999};
|
1226 |
jengbou |
1.1 |
double cm2um = 10000;
|
1227 |
|
|
stringstream ss;
|
1228 |
|
|
ss << ntk;
|
1229 |
yygao |
1.7 |
string suffix = ss.str();
|
1230 |
|
|
if(datamode == 0 ) suffix = "_" + suffix;
|
1231 |
|
|
if(datamode == 1 ) suffix = "_spl1_mct_" + suffix;
|
1232 |
|
|
if(datamode == 2 ) suffix = "_spl2_mct_" + suffix;
|
1233 |
|
|
if(datamode == 3 ) suffix = "_mct_" + suffix;
|
1234 |
|
|
|
1235 |
jengbou |
1.3 |
if(analyze_) {
|
1236 |
|
|
for ( int i = 0; i < 6; ++i) {
|
1237 |
|
|
switch (i) {
|
1238 |
|
|
case 0:
|
1239 |
yygao |
1.7 |
fit(h["deltax"+suffix], fpar);
|
1240 |
jengbou |
1.3 |
data[i] = fpar[0]*cm2um;
|
1241 |
|
|
break;
|
1242 |
|
|
case 1:
|
1243 |
yygao |
1.7 |
fit(h["deltay"+suffix], fpar);
|
1244 |
jengbou |
1.3 |
data[i] = fpar[0]*cm2um;
|
1245 |
|
|
break;
|
1246 |
|
|
case 2:
|
1247 |
yygao |
1.7 |
fit(h["deltaz"+suffix], fpar);
|
1248 |
jengbou |
1.3 |
data[i] = fpar[0]*cm2um;
|
1249 |
|
|
break;
|
1250 |
|
|
case 3:
|
1251 |
yygao |
1.7 |
fit(h["pullx"+suffix], fpar);
|
1252 |
jengbou |
1.3 |
data[i] = fpar[0];
|
1253 |
|
|
break;
|
1254 |
|
|
case 4:
|
1255 |
yygao |
1.7 |
fit(h["pully"+suffix], fpar);
|
1256 |
jengbou |
1.3 |
data[i] = fpar[0];
|
1257 |
|
|
break;
|
1258 |
|
|
case 5:
|
1259 |
yygao |
1.7 |
fit(h["pullz"+suffix], fpar);
|
1260 |
jengbou |
1.3 |
data[i] = fpar[0];
|
1261 |
|
|
break;
|
1262 |
jengbou |
1.1 |
}
|
1263 |
jengbou |
1.3 |
if (verbose_ && data[i] > 0) cout << "data[" << i << "] = " << data[i] << (i<3?" micro m":" ") << endl;
|
1264 |
jengbou |
1.1 |
}
|
1265 |
jengbou |
1.3 |
}
|
1266 |
|
|
else
|
1267 |
|
|
for ( int i = 0; i < 6; ++i) {
|
1268 |
|
|
data[i] = -999;
|
1269 |
jengbou |
1.1 |
}
|
1270 |
|
|
|
1271 |
jengbou |
1.3 |
return PVStudy::PVAnaInfo(res(data[0], data[1], data[2]),
|
1272 |
|
|
error(0.,0.,0.),
|
1273 |
|
|
pull(data[3], data[4], data[5]),
|
1274 |
|
|
error(0.,0.,0.),
|
1275 |
jengbou |
1.1 |
ntk);
|
1276 |
|
|
}
|
1277 |
|
|
|
1278 |
jengbou |
1.4 |
void PVStudy::fit(TH1 *&hdist, double fitPars[]){
|
1279 |
jengbou |
1.3 |
TAxis *axis0 = hdist->GetXaxis();
|
1280 |
|
|
int nbin = axis0->GetLast();
|
1281 |
|
|
double nOF = hdist->GetBinContent(nbin+1);
|
1282 |
|
|
double nUF = hdist->GetBinContent(0);
|
1283 |
jengbou |
1.4 |
// double fitRange = axis0->GetBinUpEdge(nbin);
|
1284 |
|
|
double fitRange = axis0->GetXmax();
|
1285 |
jengbou |
1.5 |
double sigMax[2] = {0.,0.};
|
1286 |
jengbou |
1.4 |
|
1287 |
jengbou |
1.3 |
if ( verbose_ ){
|
1288 |
|
|
cout << "Last bin = " << nbin;
|
1289 |
|
|
cout << "; hdist: Overflow Entries = " << nOF;
|
1290 |
|
|
cout << "; Underflow Entries = " << nUF;
|
1291 |
jengbou |
1.4 |
cout << "; hdist->GetEntries() = " << hdist->GetEntries();
|
1292 |
|
|
cout << "; fitting range = " << -fitRange << " to " << fitRange << endl;
|
1293 |
jengbou |
1.3 |
}
|
1294 |
jengbou |
1.4 |
if (hdist->GetEntries() - nOF - nUF >= 10) { // FIXME: for reasonable Gaussian fit
|
1295 |
|
|
for (int bi = 0; bi < nbin; bi++) {
|
1296 |
|
|
if ( (axis0->GetBinLowEdge(bi) < 0) && (hdist->GetBinContent(bi) > 0) ) {
|
1297 |
|
|
sigMax[0] = axis0->GetBinLowEdge(bi);
|
1298 |
jengbou |
1.5 |
if ( abs(sigMax[0]) > abs(sigMax[1]) ) sigMax[1] = abs(sigMax[0]);
|
1299 |
jengbou |
1.4 |
}
|
1300 |
|
|
if ( (axis0->GetBinLowEdge(bi) >= 0) && (hdist->GetBinContent(bi) > 0) ) {
|
1301 |
jengbou |
1.5 |
sigMax[0] = axis0->GetBinUpEdge(bi);
|
1302 |
|
|
if ( abs(sigMax[0]) > abs(sigMax[1]) ) sigMax[1] = abs(sigMax[0]);
|
1303 |
jengbou |
1.4 |
}
|
1304 |
|
|
}
|
1305 |
jengbou |
1.5 |
if (verbose_) cout << "Fit sigMax = " << sqrt(2.)*sigMax[1] << endl;
|
1306 |
jengbou |
1.4 |
|
1307 |
|
|
TF1 *fgaus = new TF1("fgaus","gaus",-fitRange, fitRange);
|
1308 |
|
|
fgaus->SetParameter(1, 0.);
|
1309 |
|
|
fgaus->SetParLimits(1, -fitRange/40., fitRange/40.);
|
1310 |
jengbou |
1.5 |
fgaus->SetParLimits(2, 0., sqrt(2.)*sigMax[1]);
|
1311 |
jengbou |
1.4 |
fgaus->SetLineColor(4);
|
1312 |
|
|
hdist->Fit(fgaus,"Q");
|
1313 |
|
|
gPad->Update();
|
1314 |
|
|
TPaveStats *s = (TPaveStats*) hdist->GetListOfFunctions()->FindObject("stats");
|
1315 |
|
|
s->SetOptStat(1111111);
|
1316 |
|
|
s->SetOptFit(0111);
|
1317 |
|
|
gPad->Update();
|
1318 |
jengbou |
1.3 |
if (verbose_) cout << "got function" << endl;
|
1319 |
jengbou |
1.4 |
fitPars[0] = ((fgaus->GetParameter(2))?fgaus->GetParameter(2):-999);
|
1320 |
jengbou |
1.3 |
}
|
1321 |
jengbou |
1.4 |
else
|
1322 |
|
|
fitPars[0] = -999;
|
1323 |
jengbou |
1.3 |
}
|
1324 |
|
|
|
1325 |
yygao |
1.9 |
void PVStudy::fillTrackHisto(const reco::TrackCollection *trackColl, int datatype) {
|
1326 |
|
|
string suffix;
|
1327 |
|
|
suffix = ""; // for unsplit tracks
|
1328 |
|
|
if(datatype == 1) suffix = "1_spl"; // for splittracks 1
|
1329 |
|
|
if(datatype == 2) suffix = "2_spl"; // for splittracks 2
|
1330 |
|
|
|
1331 |
|
|
h["nTrk"+suffix]->Fill(trackColl->size());
|
1332 |
|
|
for(reco::TrackCollection::const_iterator itTrack = trackColl->begin();
|
1333 |
|
|
itTrack != trackColl->end();
|
1334 |
|
|
++itTrack) {
|
1335 |
|
|
h["trkPt"+suffix]->Fill(itTrack->pt());
|
1336 |
|
|
h["trkDxy"+suffix]->Fill(itTrack->dxy());
|
1337 |
|
|
h["trkDz"+suffix]->Fill(itTrack->dz());
|
1338 |
|
|
h["trkEta"+suffix]->Fill(itTrack->eta());
|
1339 |
|
|
h["trkPhi"+suffix]->Fill(itTrack->phi());
|
1340 |
|
|
}
|
1341 |
|
|
}
|
1342 |
|
|
|
1343 |
|
|
void PVStudy::fillTrackHistoInPV(const reco::VertexCollection *vertexColl, int datatype, bool fillHisto, bool fillNtuple) {
|
1344 |
|
|
string suffix;
|
1345 |
|
|
suffix = ""; // for unsplit tracks
|
1346 |
|
|
if(datatype == 1) suffix = "1_spl"; // for splittracks 1
|
1347 |
|
|
if(datatype == 2) suffix = "2_spl"; // for splittracks 2
|
1348 |
|
|
int ivtx = 0;
|
1349 |
|
|
for(reco::VertexCollection::const_iterator v=vertexColl->begin();
|
1350 |
|
|
v!=vertexColl->end(); ++v, ++ivtx) {
|
1351 |
|
|
if(fillNtuple) {
|
1352 |
|
|
if(datatype == 0) {
|
1353 |
yygao |
1.10 |
nTrkPV_[ivtx] = v->tracksSize();
|
1354 |
|
|
sumptsq_[ivtx] = sumPtSquared(*v);
|
1355 |
|
|
isValid_[ivtx] = v->isValid();
|
1356 |
|
|
isFake_[ivtx] = v->isFake();
|
1357 |
yygao |
1.9 |
recx_[ivtx] = v->x();
|
1358 |
|
|
recy_[ivtx] = v->y();
|
1359 |
|
|
recz_[ivtx] = v->z();
|
1360 |
|
|
recx_err_[ivtx] = v->xError();
|
1361 |
|
|
recy_err_[ivtx] = v->yError();
|
1362 |
|
|
recz_err_[ivtx] = v->zError();
|
1363 |
yygao |
1.10 |
|
1364 |
|
|
|
1365 |
yygao |
1.9 |
}
|
1366 |
|
|
if(datatype == 1) {
|
1367 |
yygao |
1.10 |
nTrkPV1_spl_[ivtx] = v->tracksSize();
|
1368 |
|
|
sumptsq1_spl_[ivtx] = sumPtSquared(*v);
|
1369 |
|
|
isValid1_spl_[ivtx] = v->isValid();
|
1370 |
|
|
isFake1_spl_[ivtx] = v->isFake();
|
1371 |
yygao |
1.9 |
recx1_spl_[ivtx] = v->x();
|
1372 |
|
|
recy1_spl_[ivtx] = v->y();
|
1373 |
|
|
recz1_spl_[ivtx] = v->z();
|
1374 |
|
|
recx1_err_spl_[ivtx] = v->xError();
|
1375 |
|
|
recy1_err_spl_[ivtx] = v->yError();
|
1376 |
|
|
recz1_err_spl_[ivtx] = v->zError();
|
1377 |
yygao |
1.10 |
|
1378 |
yygao |
1.9 |
}
|
1379 |
|
|
if(datatype == 2) {
|
1380 |
yygao |
1.10 |
nTrkPV2_spl_[ivtx] = v->tracksSize();
|
1381 |
|
|
sumptsq2_spl_[ivtx] = sumPtSquared(*v);
|
1382 |
|
|
isValid2_spl_[ivtx] = v->isValid();
|
1383 |
|
|
isFake2_spl_[ivtx] = v->isFake();
|
1384 |
yygao |
1.9 |
recx2_spl_[ivtx] = v->x();
|
1385 |
|
|
recy2_spl_[ivtx] = v->y();
|
1386 |
|
|
recz2_spl_[ivtx] = v->z();
|
1387 |
|
|
recx2_err_spl_[ivtx] = v->xError();
|
1388 |
|
|
recy2_err_spl_[ivtx] = v->yError();
|
1389 |
|
|
recz2_err_spl_[ivtx] = v->zError();
|
1390 |
|
|
}
|
1391 |
yygao |
1.11 |
if(datatype == 4) { // for pixelVertices
|
1392 |
|
|
nTrkPV_pxlpvtx_[ivtx] = v->tracksSize();
|
1393 |
|
|
sumptsq_pxlpvtx_[ivtx] = sumPtSquared(*v);
|
1394 |
|
|
isValid_pxlpvtx_[ivtx] = v->isValid();
|
1395 |
|
|
isFake_pxlpvtx_[ivtx] = v->isFake();
|
1396 |
|
|
recx_pxlpvtx_[ivtx] = v->x();
|
1397 |
|
|
recy_pxlpvtx_[ivtx] = v->y();
|
1398 |
|
|
recz_pxlpvtx_[ivtx] = v->z();
|
1399 |
|
|
recx_err_pxlpvtx_[ivtx] = v->xError();
|
1400 |
|
|
recy_err_pxlpvtx_[ivtx] = v->yError();
|
1401 |
|
|
recz_err_pxlpvtx_[ivtx] = v->zError();
|
1402 |
|
|
}
|
1403 |
yygao |
1.9 |
}
|
1404 |
yygao |
1.10 |
}
|
1405 |
|
|
// For histogram only fill the leading pvtx parameters
|
1406 |
|
|
if(fillHisto) {
|
1407 |
|
|
h["nTrkPV"+suffix]->Fill(vertexColl->begin()->tracksSize());
|
1408 |
|
|
try {
|
1409 |
|
|
for(reco::Vertex::trackRef_iterator t = vertexColl->begin()->tracks_begin();
|
1410 |
|
|
t!=vertexColl->begin()->tracks_end(); t++) {
|
1411 |
|
|
// illegal charge
|
1412 |
|
|
if ( (**t).charge() < -1 || (**t).charge() > 1 ) {
|
1413 |
|
|
// h["trkPtPV"]->Fill(0.);
|
1414 |
|
|
}
|
1415 |
|
|
else {
|
1416 |
|
|
h["trkPtPV"+suffix]->Fill((**t).pt());
|
1417 |
|
|
h["trkDxyPV"+suffix]->Fill((**t).dxy());
|
1418 |
|
|
h["trkDzPV"+suffix]->Fill((**t).dz());
|
1419 |
|
|
h["trkEtaPV"+suffix]->Fill((**t).eta());
|
1420 |
|
|
h["trkPhiPV"+suffix]->Fill((**t).phi());
|
1421 |
yygao |
1.9 |
}
|
1422 |
|
|
}
|
1423 |
yygao |
1.10 |
}
|
1424 |
|
|
catch (...) {
|
1425 |
|
|
// exception thrown when trying to use linked track
|
1426 |
|
|
// h["trkPtPV"]->Fill(0.);
|
1427 |
yygao |
1.9 |
}
|
1428 |
|
|
}
|
1429 |
yygao |
1.10 |
|
1430 |
yygao |
1.9 |
}
|
1431 |
|
|
|
1432 |
|
|
void PVStudy::fillMCHisto(std::vector<simPrimaryVertex>::iterator vsim, int isimpv, const reco::VertexCollection *vtxColl, int datatype)
|
1433 |
|
|
{
|
1434 |
|
|
std::string suffix;
|
1435 |
|
|
// Set the vertexColl and histogram suffix according to datamode
|
1436 |
|
|
if (datatype == 1) {
|
1437 |
|
|
suffix = "_spl1_mct";
|
1438 |
|
|
nrecPV_spl1_mct_ = 0;
|
1439 |
|
|
}
|
1440 |
|
|
if (datatype == 2) {
|
1441 |
|
|
suffix = "_spl2_mct";
|
1442 |
|
|
nrecPV_spl2_mct_ = 0;
|
1443 |
|
|
}
|
1444 |
|
|
if (datatype == 3) {
|
1445 |
|
|
suffix = "_mct";
|
1446 |
|
|
nrecPV_mct_ = 0;
|
1447 |
|
|
}
|
1448 |
|
|
|
1449 |
|
|
//========================================================
|
1450 |
|
|
// look for a matching reconstructed vertex in vertexColl
|
1451 |
|
|
//========================================================
|
1452 |
|
|
|
1453 |
|
|
for(reco::VertexCollection::const_iterator vrec=vtxColl->begin();
|
1454 |
|
|
vrec!=vtxColl->end(); ++vrec){
|
1455 |
|
|
int nrectrk = vrec->tracksSize();
|
1456 |
|
|
vsim->recVtx=NULL;
|
1457 |
|
|
|
1458 |
|
|
if(verbose_){
|
1459 |
|
|
cout << "sim primary vertex x = " << vsim->x << "; y = " << vsim->y << "; z = " << vsim->z << endl;
|
1460 |
|
|
cout << "Is matched? " << (matchVertex(*vsim,*vrec)?"Yes":"No") << endl;
|
1461 |
|
|
}
|
1462 |
|
|
if ( matchVertex(*vsim,*vrec) ) {
|
1463 |
|
|
vsim->recVtx=&(*vrec);
|
1464 |
|
|
|
1465 |
|
|
// if the matching critera are fulfilled, accept the rec-vertex that is closest in z
|
1466 |
|
|
//if( ((vsim->recVtx) && (fabs(vsim->recVtx->position().z()-vsim->z)>fabs(vrec->z()-vsim->z)))
|
1467 |
|
|
//|| (!vsim->recVtx) )
|
1468 |
|
|
//vsim->recVtx=&(*vrec);
|
1469 |
|
|
//}
|
1470 |
|
|
if(verbose_)
|
1471 |
|
|
cout <<"primary matched in vertexColl" << vsim->x << " " << vsim->y << " " << vsim->z << endl;
|
1472 |
|
|
|
1473 |
|
|
double fres_mct[3];
|
1474 |
|
|
double ferror_mct[3];
|
1475 |
|
|
|
1476 |
|
|
fres_mct[0] = vsim->recVtx->x()-vsim->x;
|
1477 |
|
|
fres_mct[1] = vsim->recVtx->y()-vsim->y;
|
1478 |
|
|
fres_mct[2] = vsim->recVtx->z()-vsim->z;
|
1479 |
|
|
ferror_mct[0] = vsim->recVtx->xError();
|
1480 |
|
|
ferror_mct[1] = vsim->recVtx->yError();
|
1481 |
|
|
ferror_mct[2] = vsim->recVtx->zError();
|
1482 |
|
|
|
1483 |
|
|
h["deltax"+suffix]->Fill( fres_mct[0] );
|
1484 |
|
|
h["deltay"+suffix]->Fill( fres_mct[1] );
|
1485 |
|
|
h["deltaz"+suffix]->Fill( fres_mct[2] );
|
1486 |
|
|
h["pullx"+suffix]->Fill( fres_mct[0]/ferror_mct[0] );
|
1487 |
|
|
h["pully"+suffix]->Fill( fres_mct[1]/ferror_mct[1] );
|
1488 |
|
|
h["pullz"+suffix]->Fill( fres_mct[2]/ferror_mct[2] );
|
1489 |
|
|
h["errPVx"+suffix]->Fill( ferror_mct[0] );
|
1490 |
|
|
h["errPVy"+suffix]->Fill( ferror_mct[1] );
|
1491 |
|
|
h["errPVz"+suffix]->Fill( ferror_mct[2] );
|
1492 |
|
|
pvinfo.push_back(PVStudy::PVInfo(res(fres_mct[0], fres_mct[1], fres_mct[2]),
|
1493 |
|
|
error(ferror_mct[0], ferror_mct[1], ferror_mct[2]),
|
1494 |
|
|
nrectrk));
|
1495 |
|
|
// Fill histo according to its track multiplicity
|
1496 |
|
|
fillHisto(res(fres_mct[0], fres_mct[1], fres_mct[2]),
|
1497 |
|
|
error(ferror_mct[0], ferror_mct[1], ferror_mct[2]),
|
1498 |
|
|
nrectrk, datatype);
|
1499 |
|
|
|
1500 |
|
|
if(saventuple_) {
|
1501 |
|
|
//Fill the values for variables in ftree_
|
1502 |
|
|
if(datatype == 1) {
|
1503 |
|
|
nTrkPV_spl1_mct_[nrecPV_spl1_mct_] = nrectrk;
|
1504 |
|
|
deltax_spl1_mct_[nrecPV_spl1_mct_] = fres_mct[0];
|
1505 |
|
|
deltay_spl1_mct_[nrecPV_spl1_mct_] = fres_mct[0];
|
1506 |
|
|
deltaz_spl1_mct_[nrecPV_spl1_mct_] = fres_mct[0];
|
1507 |
|
|
pullx_spl1_mct_[nrecPV_spl1_mct_] = fres_mct[0]/ferror_mct[0];
|
1508 |
|
|
pully_spl1_mct_[nrecPV_spl1_mct_] = fres_mct[1]/ferror_mct[1];
|
1509 |
|
|
pullz_spl1_mct_[nrecPV_spl1_mct_] = fres_mct[2]/ferror_mct[2];
|
1510 |
|
|
nrecPV_spl1_mct_++;
|
1511 |
|
|
}
|
1512 |
|
|
|
1513 |
|
|
if(datatype == 2) {
|
1514 |
|
|
nTrkPV_spl2_mct_[nrecPV_spl2_mct_] = nrectrk;
|
1515 |
|
|
deltax_spl2_mct_[nrecPV_spl2_mct_] = fres_mct[0];
|
1516 |
|
|
deltay_spl2_mct_[nrecPV_spl2_mct_] = fres_mct[0];
|
1517 |
|
|
deltaz_spl2_mct_[nrecPV_spl2_mct_] = fres_mct[0];
|
1518 |
|
|
pullx_spl2_mct_[nrecPV_spl2_mct_] = fres_mct[0]/ferror_mct[0];
|
1519 |
|
|
pully_spl2_mct_[nrecPV_spl2_mct_] = fres_mct[1]/ferror_mct[1];
|
1520 |
|
|
pullz_spl2_mct_[nrecPV_spl2_mct_] = fres_mct[2]/ferror_mct[2];
|
1521 |
|
|
nrecPV_spl2_mct_++;
|
1522 |
|
|
}
|
1523 |
|
|
if(datatype == 3) {
|
1524 |
|
|
nTrkPV_mct_[nrecPV_mct_] = nrectrk;
|
1525 |
|
|
deltax_mct_[nrecPV_mct_] = fres_mct[0];
|
1526 |
|
|
deltay_mct_[nrecPV_mct_] = fres_mct[0];
|
1527 |
|
|
deltaz_mct_[nrecPV_mct_] = fres_mct[0];
|
1528 |
|
|
pullx_mct_[nrecPV_mct_] = fres_mct[0]/ferror_mct[0];
|
1529 |
|
|
pully_mct_[nrecPV_mct_] = fres_mct[1]/ferror_mct[1];
|
1530 |
|
|
pullz_mct_[nrecPV_mct_] = fres_mct[2]/ferror_mct[2];
|
1531 |
|
|
nrecPV_mct_++;
|
1532 |
|
|
}
|
1533 |
|
|
} // End of if(saventuple_) {
|
1534 |
|
|
} // if ( matchVertex(*vsim,*vrec) ) {
|
1535 |
|
|
else { // no rec vertex found for this simvertex
|
1536 |
|
|
if(verbose_)
|
1537 |
|
|
cout <<"primary not found " << vsim->x << " " << vsim->y << " " << vsim->z << " nGenTrk=" << vsim->nGenTrk << endl;
|
1538 |
|
|
}
|
1539 |
|
|
}
|
1540 |
|
|
}
|
1541 |
|
|
|
1542 |
|
|
|
1543 |
yygao |
1.7 |
void PVStudy::SetVarToZero() {
|
1544 |
yygao |
1.9 |
//Greg's variables
|
1545 |
yygao |
1.7 |
fntrk_ = 0;
|
1546 |
|
|
//pvtx position (x,y,z) residual and error
|
1547 |
yygao |
1.9 |
for(int i = 0; i<3;i++) {
|
1548 |
yygao |
1.7 |
fres_[i] = 0;
|
1549 |
|
|
ferror_[i] = 0;
|
1550 |
yygao |
1.9 |
}
|
1551 |
|
|
|
1552 |
|
|
//Yanyan's variables
|
1553 |
yygao |
1.10 |
// Number of reconstructed vertices
|
1554 |
yygao |
1.9 |
nrecPV_ = 0;
|
1555 |
|
|
nrecPV1_spl_ = 0;
|
1556 |
|
|
nrecPV2_spl_ = 0;
|
1557 |
|
|
nrecPV_twovtx_ = 0;
|
1558 |
|
|
nsimPV_ = 0;
|
1559 |
yygao |
1.10 |
|
1560 |
yygao |
1.9 |
nrecPV_mct_ = 0;
|
1561 |
|
|
nrecPV_spl1_mct_ = 0;
|
1562 |
|
|
nrecPV_spl2_mct_ = 0;
|
1563 |
|
|
|
1564 |
yygao |
1.10 |
// Mininum separation between the secondary pvtxes and leading pvtx
|
1565 |
|
|
min_zsep_ = 9999.0;
|
1566 |
|
|
min_ntrksep_ = 9999.0;
|
1567 |
|
|
min_sumpt2sep_ = -9999.0;
|
1568 |
|
|
|
1569 |
|
|
|
1570 |
yygao |
1.9 |
for (int i = 0; i < nMaxPVs_; i++) {
|
1571 |
yygao |
1.10 |
// recoVertices with all tracks
|
1572 |
|
|
nTrkPV_[i] = 0; // Number of tracks in the pvtx
|
1573 |
|
|
sumptsq_[i] = 0;
|
1574 |
|
|
isValid_[i] = -1;
|
1575 |
|
|
isFake_[i] = -1;
|
1576 |
yygao |
1.9 |
recx_[i] = 0;
|
1577 |
|
|
recy_[i] = 0;
|
1578 |
|
|
recz_[i] = 0;
|
1579 |
|
|
recx_err_[i] = 0;
|
1580 |
|
|
recy_err_[i] = 0;
|
1581 |
|
|
recz_err_[i] = 0;
|
1582 |
yygao |
1.10 |
|
1583 |
|
|
// recoVertices with splitTrack1
|
1584 |
|
|
nTrkPV1_spl_[i] = 0; // Number of tracks in the pvtx
|
1585 |
|
|
sumptsq1_spl_[i] = 0;
|
1586 |
|
|
isValid1_spl_[i] = -1;
|
1587 |
|
|
isFake1_spl_[i] = -1;
|
1588 |
yygao |
1.9 |
recx1_spl_[i] = 0;
|
1589 |
|
|
recy1_spl_[i] = 0;
|
1590 |
|
|
recz1_spl_[i] = 0;
|
1591 |
|
|
recx1_err_spl_[i] = 0;
|
1592 |
|
|
recy1_err_spl_[i] = 0;
|
1593 |
|
|
recz1_err_spl_[i] = 0;
|
1594 |
|
|
|
1595 |
yygao |
1.10 |
// recoVertices with splitTrack2
|
1596 |
|
|
nTrkPV2_spl_[i] = 0; // Number of tracks in the pvtx
|
1597 |
|
|
sumptsq2_spl_[i] = 0;
|
1598 |
|
|
isValid2_spl_[i] = -1;
|
1599 |
|
|
isFake2_spl_[i] = -1;
|
1600 |
yygao |
1.9 |
recx2_spl_[i] = 0;
|
1601 |
|
|
recy2_spl_[i] = 0;
|
1602 |
|
|
recz2_spl_[i] = 0;
|
1603 |
|
|
recx2_err_spl_[i] = 0;
|
1604 |
|
|
recy2_err_spl_[i] = 0;
|
1605 |
|
|
recz2_err_spl_[i] = 0;
|
1606 |
|
|
|
1607 |
yygao |
1.11 |
//pixelVertices
|
1608 |
|
|
nTrkPV_pxlpvtx_[i] = 0; // Number of tracks in the pvtx
|
1609 |
|
|
sumptsq_pxlpvtx_[i] = 0;
|
1610 |
|
|
isValid_pxlpvtx_[i] = -1;
|
1611 |
|
|
isFake_pxlpvtx_[i] = -1;
|
1612 |
|
|
recx_pxlpvtx_[i] = 0;
|
1613 |
|
|
recy_pxlpvtx_[i] = 0;
|
1614 |
|
|
recz_pxlpvtx_[i] = 0;
|
1615 |
|
|
recx_err_pxlpvtx_[i] = 0;
|
1616 |
|
|
recy_err_pxlpvtx_[i] = 0;
|
1617 |
|
|
recz_err_pxlpvtx_[i] = 0;
|
1618 |
|
|
|
1619 |
yygao |
1.10 |
// matched two-vertices
|
1620 |
yygao |
1.9 |
nTrkPV1_spl_twovtx_[i] = 0;
|
1621 |
|
|
nTrkPV2_spl_twovtx_[i] = 0;
|
1622 |
|
|
nTrkPV_twovtx_[i] = 0;
|
1623 |
|
|
sumptsq1_spl_twovtx_[i] = 0; // Sum of pT squred in the pvtx
|
1624 |
|
|
sumptsq2_spl_twovtx_[i] = 0; // Sum of pT squred in the pvtx
|
1625 |
|
|
deltax_twovtx_[i] = 0;
|
1626 |
|
|
deltay_twovtx_[i] = 0;
|
1627 |
|
|
deltaz_twovtx_[i] = 0;
|
1628 |
|
|
errx_twovtx_[i] = 0;
|
1629 |
|
|
erry_twovtx_[i] = 0;
|
1630 |
|
|
errz_twovtx_[i] = 0;
|
1631 |
|
|
pullx_twovtx_[i] = 0;
|
1632 |
|
|
pully_twovtx_[i] = 0;
|
1633 |
|
|
pullz_twovtx_[i] = 0;
|
1634 |
|
|
|
1635 |
yygao |
1.10 |
//simpv
|
1636 |
yygao |
1.9 |
nsimTrkPV_[i] = 0;
|
1637 |
|
|
simx_[i] = 0;
|
1638 |
|
|
simy_[i] = 0;
|
1639 |
|
|
simz_[i] = 0;
|
1640 |
|
|
simptsq_[i] = 0;
|
1641 |
|
|
|
1642 |
yygao |
1.10 |
// residual and pulls with mc truth required
|
1643 |
yygao |
1.9 |
deltax_mct_[i] = 0;
|
1644 |
|
|
deltay_mct_[i] = 0;
|
1645 |
|
|
deltaz_mct_[i] = 0;
|
1646 |
|
|
pullx_mct_[i] = 0;
|
1647 |
|
|
pully_mct_[i] = 0;
|
1648 |
|
|
pullz_mct_[i] = 0;
|
1649 |
|
|
|
1650 |
|
|
deltax_spl1_mct_[i] = 0;
|
1651 |
|
|
deltay_spl1_mct_[i] = 0;
|
1652 |
|
|
deltaz_spl1_mct_[i] = 0;
|
1653 |
|
|
pullx_spl1_mct_[i] = 0;
|
1654 |
|
|
pully_spl1_mct_[i] = 0;
|
1655 |
|
|
pullz_spl1_mct_[i] = 0;
|
1656 |
|
|
|
1657 |
|
|
deltax_spl2_mct_[i] = 0;
|
1658 |
|
|
deltay_spl2_mct_[i] = 0;
|
1659 |
|
|
deltaz_spl2_mct_[i] = 0;
|
1660 |
|
|
pullx_spl2_mct_[i] = 0;
|
1661 |
|
|
pully_spl2_mct_[i] = 0;
|
1662 |
|
|
pullz_spl2_mct_[i] = 0;
|
1663 |
|
|
}
|
1664 |
|
|
|
1665 |
yygao |
1.7 |
}
|
1666 |
|
|
|
1667 |
yygao |
1.9 |
double PVStudy::sumPtSquared(const reco::Vertex & v) {
|
1668 |
|
|
double sum = 0.;
|
1669 |
|
|
double pT;
|
1670 |
|
|
for (reco::Vertex::trackRef_iterator it = v.tracks_begin(); it != v.tracks_end(); it++) {
|
1671 |
|
|
pT = (**it).pt();
|
1672 |
|
|
sum += pT*pT;
|
1673 |
|
|
}
|
1674 |
|
|
return sum;
|
1675 |
|
|
}
|
1676 |
yygao |
1.10 |
|