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