ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/Jeng/PVStudy/plugins/PVStudy.cc
(Generate patch)

Comparing UserCode/Jeng/PVStudy/plugins/PVStudy.cc (file contents):
Revision 1.10 by yygao, Sun Nov 8 02:56:57 2009 UTC vs.
Revision 1.13 by jengbou, Fri Dec 4 08:37:40 2009 UTC

# Line 12 | Line 12 | Implementation:
12   */
13   //
14   // Original Author:  "Geng-yuan Jeng/UC Riverside"
15 < //                    "Yanyan Gao/Fermilab ygao@fnal.gov"
15 > //                   "Yanyan Gao/Fermilab ygao@fnal.gov"
16   //         Created:  Thu Aug 20 11:55:40 CDT 2009
17   // $Id$
18   //
# Line 66 | Line 66 | PVStudy::PVStudy(const edm::ParameterSet
66    //=======================================================================
67    // Get configuration for TrackTupleMaker
68    //=======================================================================
69 <  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");
69 >  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    vertexCollectionTag_       = iConfig.getUntrackedParameter<edm::InputTag>("vertexCollection");
74 <  splitVertexCollection1Tag_       = iConfig.getUntrackedParameter<edm::InputTag>("splitVertexCollection1");
75 <  splitVertexCollection2Tag_       = iConfig.getUntrackedParameter<edm::InputTag>("splitVertexCollection2");  
76 <  pixelVertexCollectionTag_      = iConfig.getParameter<edm::InputTag>("pixelVertexCollectionTag");  
77 <  verbose_         = iConfig.getUntrackedParameter<bool>("verbose",false);
78 <  realData_        = iConfig.getUntrackedParameter<bool>("realData",false);
79 <  analyze_         = iConfig.getUntrackedParameter<bool>("analyzeOnTheFly",false);
80 <  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");
74 >  splitVertexCollection1Tag_ = iConfig.getUntrackedParameter<edm::InputTag>("splitVertexCollection1");
75 >  splitVertexCollection2Tag_ = iConfig.getUntrackedParameter<edm::InputTag>("splitVertexCollection2");  
76 >  pixelVertexCollectionTag_  = iConfig.getParameter<edm::InputTag>("pixelVertexCollectionTag");  
77 >  verbose_                   = iConfig.getUntrackedParameter<bool>("verbose",false);
78 >  realData_                  = iConfig.getUntrackedParameter<bool>("realData",false);
79 >  analyze_                   = iConfig.getUntrackedParameter<bool>("analyzeOnTheFly",false);
80 >  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 >  histoFileName_             = iConfig.getUntrackedParameter<std::string> ("histoFileName");
87  
88    //now do what ever initialization is needed
89    pvinfo.clear();
# Line 120 | Line 121 | PVStudy::PVStudy(const edm::ParameterSet
121      pvtxtree_->Branch("recx_err",&recx_err_,"recx_err[nrecPV]/D");
122      pvtxtree_->Branch("recy_err",&recy_err_,"recy_err[nrecPV]/D");
123      pvtxtree_->Branch("recz_err",&recz_err_,"recz_err[nrecPV]/D");
124 <    
124 >
125      pvtxtree_->Branch("min_zsep",&min_zsep_,"min_zsep/D");
126      pvtxtree_->Branch("min_ntrksep",&min_ntrksep_,"min_ntrksep/D");
127      pvtxtree_->Branch("min_sumpt2sep",&min_sumpt2sep_,"min_sumpt2sep/D");
# Line 150 | Line 151 | PVStudy::PVStudy(const edm::ParameterSet
151      pvtxtree_->Branch("recx2_err_spl",&recx2_err_spl_,"recx2_err_spl[nrecPV2_spl]/D");
152      pvtxtree_->Branch("recy2_err_spl",&recy2_err_spl_,"recy2_err_spl[nrecPV2_spl]/D");
153      pvtxtree_->Branch("recz2_err_spl",&recz2_err_spl_,"recz2_err_spl[nrecPV2_spl]/D");  
154 <        
154 >    
155 >    //pixeVertices
156 >    pvtxtree_->Branch("nrecPV_pxlpvtx",&nrecPV_pxlpvtx_,"nrecPV_pxlpvtx/I");
157 >    pvtxtree_->Branch("nTrkPV_pxlpvtx",&nTrkPV_pxlpvtx_,"nTrkPV_pxlpvtx[nrecPV_pxlpvtx]/I");    
158 >    pvtxtree_->Branch("sumptsq_pxlpvtx",&sumptsq_pxlpvtx_,"sumptsq_pxlpvtx[nrecPV_pxlpvtx]/D");  
159 >    pvtxtree_->Branch("isValid_pxlpvtx",&isValid_pxlpvtx_,"isValid_pxlpvtx/I");
160 >    pvtxtree_->Branch("isFake_pxlpvtx",&isFake_pxlpvtx_,"isFake_pxlpvtx/I");
161 >    pvtxtree_->Branch("recx_pxlpvtx",&recx_pxlpvtx_,"recx_pxlpvtx[nrecPV_pxlpvtx]/D");
162 >    pvtxtree_->Branch("recy_pxlpvtx",&recy_pxlpvtx_,"recy_pxlpvtx[nrecPV_pxlpvtx]/D");
163 >    pvtxtree_->Branch("recz_pxlpvtx",&recz_pxlpvtx_,"recz_pxlpvtx[nrecPV_pxlpvtx]/D");
164 >    pvtxtree_->Branch("recx_err_pxlpvtx",&recx_err_pxlpvtx_,"recx_err_pxlpvtx[nrecPV_pxlpvtx]/D");
165 >    pvtxtree_->Branch("recy_err_pxlpvtx",&recy_err_pxlpvtx_,"recy_err_pxlpvtx[nrecPV_pxlpvtx]/D");
166 >    pvtxtree_->Branch("recz_err_pxlpvtx",&recz_err_pxlpvtx_,"recz_err_pxlpvtx[nrecPV_pxlpvtx]/D");  
167 >
168      //Fill the variables in the twovtx pair (recvtx1, recvtx2)
169      pvtxtree_->Branch("nrecPV_twovtx",&nrecPV_twovtx_,"nrecPV_twovtx/I");
170      pvtxtree_->Branch("nTrkPV1_spl_twovtx",&nTrkPV1_spl_twovtx_,"nTrkPV1_spl_twovtx[nrecPV_twovtx]/I");
# Line 204 | Line 218 | PVStudy::PVStudy(const edm::ParameterSet
218      }
219    }
220  
207  edm::Service<TFileService> fs;
208  TFileDirectory subDir = fs->mkdir( "Summary" );
209  TFileDirectory subDir1 = fs->mkdir( "Others" );
210  //   TFileDirectory subSubDir = subDir.mkdir( "mySubSubDirectory" );
211
221    setRootStyle();
213  
214  //Book histograms for track and pvtx parameters for each splitted pvtx
215  //i=0 : x (as in unsplit track collection)
216  //i=1 : x1_spl_
217  //i=2 : x2_spl_
222  
223 <  
224 <  for(int i=0;i<3;i++)
225 <    {  
226 <      string suffix;
227 <      if(i == 0) suffix = "";
228 <      else {
229 <        stringstream ss;
230 <        ss << i;
231 <        suffix =ss.str()+"_spl";  
232 <      }
233 <      h["nTrk"+suffix]   = subDir.make<TH1D>(TString("nTrk"+suffix), TString("Num of rec tracks"+suffix),300,0,300);
234 <      h["trkPt"+suffix]  = subDir.make<TH1D>(TString("trkPt"+suffix), TString("Pt of rec tracks "+suffix),100,0,100);
235 <      h["trkEta"+suffix] = subDir.make<TH1D>(TString("trkEta"+suffix), TString("#eta of rec tracks "+suffix),100,-3,3);
236 <      h["trkPhi"+suffix] = subDir.make<TH1D>(TString("trkPhi"+suffix), TString("#Phi of rec tracks "+suffix),100,-3.2,3.2);
237 <      h["trkDxy"+suffix] = subDir.make<TH1D>(TString("trkDxy"+suffix), TString("Dxy of rec tracks "+suffix),100,-0.5,0.5);  
238 <      h["trkDz"+suffix] = subDir.make<TH1D>(TString("trkDz"+suffix), TString("Dz of rec tracks "+suffix),100,-50,50);  
239 <      
240 <      h["nTrkPV"+suffix]   = subDir.make<TH1D>(TString("nTrkPV"+suffix), TString("Num of rec tracks in PV"+suffix),300,0,300);
241 <      h["trkPtPV"+suffix]  = subDir.make<TH1D>(TString("trkPtPV"+suffix), TString("Pt of rec tracks in "+suffix),100,0,100);
242 <      h["trkEtaPV"+suffix] = subDir.make<TH1D>(TString("trkEtaPV"+suffix), TString("#eta of rec tracks in PV"+suffix),100,-3,3);
243 <      h["trkPhiPV"+suffix] = subDir.make<TH1D>(TString("trkPhiPV"+suffix), TString("#Phi of rec tracks in PV"+suffix),100,-3.2,3.2);
240 <      h["trkDxyPV"+suffix] = subDir.make<TH1D>(TString("trkDxyPV"+suffix), TString("Dxy of rec tracks in PV"+suffix),100,-5,5);  
241 <      h["trkDzPV"+suffix] = subDir.make<TH1D>(TString("trkDzPV"+suffix), TString("Dz of rec tracks "+suffix),100,-50,50);
242 <      h["nrecPV"+suffix]   = subDir.make<TH1D>(TString("nrecPV"+suffix), TString("Num of rec pvtx"+suffix),50,0,50);    
243 <      suffix.clear();
223 >  // Create a root file for histograms
224 >  theFile = new TFile(histoFileName_.c_str(), "RECREATE");
225 >  // make diretories
226 >  theFile->mkdir("Summary");
227 >  theFile->cd();
228 >  theFile->mkdir("Others");
229 >  theFile->cd();
230 >
231 >  // Book Histograms:
232 >  h_pvtrk   = new PVHistograms();
233 >  h_pixvtx  = new PVHistograms();
234 >  h_misc    = new PVHistograms();
235 >  h_summary = new PVHistograms();
236 >  h_others  = new PVHistograms();
237 >
238 >  for(int i=0;i<3;i++) {  
239 >    if(i == 0) h_pvtrk->Init("pvTrk");
240 >    else {
241 >      stringstream ss;
242 >      ss << i;
243 >      h_pvtrk->Init("pvTrk",ss.str(),"spl");
244      }
245 <  h["nrecPVDiff"]     = subDir.make<TH1D>("nrecPVDiff","nrecPV1-nRecPV2",21,-10.5,10.5);
246 <  h["nTrkPVDiff"]     = subDir.make<TH1D>("nTrkPVDiff","nTrkPV1-nTrkPV2",41,-20.5,20.5);
247 <  h["nTrkPVRelDiff"]  = subDir.make<TH1D>("nTrkPVRelDiff","(nTrkPV1-nTrkPV2)/(nTrkPV1+nTrkPV2)",100,-1,1);
248 <
249 <  // Histograms on comparing the multi-vertices
250 <  // Difference in reconstructed vtx position
251 <  h["min_xsep"]   = subDir.make<TH1D>("min_xsep", "min x diff of primary and secondary pvtx",300,0,0.1);
252 <  h["min_xsep_sign"]   = subDir.make<TH1D>("min_xsep_sign", "min x diff in signf of primary and secondary pvtx",300,0,5);
253 <  h["min_ysep"]   = subDir.make<TH1D>("min_ysep", "min y diff of primary and secondary pvtx",300,0,0.1);
254 <  h["min_ysep_sign"]   = subDir.make<TH1D>("min_ysep_sign", "min y diff in signf of primary and secondary pvtx",300,0,5);
255 <  h["min_zsep"]   = subDir.make<TH1D>("min_zsep", "min z diff of primary and secondary pvtx",300,0,5);
256 <  h["min_zsep_sign"]   = subDir.make<TH1D>("min_zsep_sign", "min z diff in signf of primary and secondary pvtx",300,0,200);
257 <  // Difference in reconstructed vtx position
258 <  h["min_ntrksep"]   = subDir.make<TH1D>("min_ntrksep", "min nTrk diff of primary and secondary pvtx",201,-50.5,150.5);
259 <  h["min_sumpt2sep"]   = subDir.make<TH1D>("min_sumpt2sep", "min sumpt2 diff of primary and secondary pvtx",300,0,10000);
245 >  }
246 >  h_pixvtx->Init("pixVtx");
247 >  h_misc->Init("misc");
248 >
249 >  // Book MC only plots
250 >  if (!realData_) {
251 >    h_gen = new PVHistograms();
252 >    h_gen->Init("generator");
253 >  }
254  
255    //Book histograms sensitive to data/mc
256    for (vector<int>::const_iterator it= datamode.begin(); it != datamode.end() ; ++it) {
# Line 272 | Line 266 | PVStudy::PVStudy(const edm::ParameterSet
266      case 3: suffix = "_mct";
267        break;
268      }
269 <    h["deltax"+suffix] = subDir.make<TH1D>(TString("deltax"+suffix), TString("x-residual pvtx"+suffix),800,-0.04,0.04);
276 <    h["deltay"+suffix] = subDir.make<TH1D>(TString("deltay"+suffix), TString("y-residual pvtx"+suffix),800,-0.04,0.04);
277 <    h["deltaz"+suffix] = subDir.make<TH1D>(TString("deltaz"+suffix), TString("z-residual pvtx"+suffix),800,-0.04,0.04);
278 <    h["pullx"+suffix]  = subDir.make<TH1D>(TString("pullx"+suffix), TString("x-pull pvtx"+suffix),800,-10,10);
279 <    h["pully"+suffix]  = subDir.make<TH1D>(TString("pully"+suffix), TString("y-pull pvtx"+suffix),800,-10,10);
280 <    h["pullz"+suffix]  = subDir.make<TH1D>(TString("pullz"+suffix), TString("z-pull pvtx"+suffix),800,-10,10);
281 <    h["errPVx"+suffix] = subDir.make<TH1D>(TString("errPVx"+suffix), TString("X"+suffix+" vertex error"),100,0.,0.02);
282 <    h["errPVy"+suffix] = subDir.make<TH1D>(TString("errPVy"+suffix), TString("Y"+suffix+" vertex error"),100,0.,0.02);
283 <    h["errPVz"+suffix] = subDir.make<TH1D>(TString("errPVz"+suffix), TString("Z"+suffix+" vertex error"),100,0.,0.02);
269 >    h_summary->Init("summary",suffix);
270      
271      // Book residual, error and pull histograms for each nTrk bin
272      for (int ntrk=nTrkMin_;ntrk<=nTrkMax_;++ntrk) {
273        stringstream ss;
274        ss << ntrk;
275 <      string suffix2 = suffix+"_"+ss.str();
276 <      h["deltax"+suffix2]  = subDir1.make<TH1D>(TString("deltax"+suffix2), TString("x-residual of pvtx"+suffix),100,-0.02,0.02);
277 <      h["deltax"+suffix2]->GetXaxis()->SetTitle("cm");
292 <      h["deltay"+suffix2]  = subDir1.make<TH1D>(TString("deltay"+suffix2), TString("y-residual of pvtx"+suffix),100,-0.02,0.02);
293 <      h["deltay"+suffix2]->GetXaxis()->SetTitle("cm");
294 <      h["deltaz"+suffix2]  = subDir1.make<TH1D>(TString("deltaz"+suffix2), TString("z-residual of pvtx"+suffix),100,-0.02,0.02);
295 <      h["deltaz"+suffix2]->GetXaxis()->SetTitle("cm");
296 <      h["pullx"+suffix2] = subDir1.make<TH1D>(TString("pullx"+suffix2), TString("x-pull of pvtx"+suffix),100,-10.,10.);
297 <      h["pully"+suffix2] = subDir1.make<TH1D>(TString("pully"+suffix2), TString("y-pull of pvtx"+suffix),100,-10.,10.);
298 <      h["pullz"+suffix2] = subDir1.make<TH1D>(TString("pullz"+suffix2), TString("z-pull of pvtx"+suffix),100,-10.,10.);
299 <      h["errPVx"+suffix2] = subDir1.make<TH1D>(TString("errPVx"+suffix2), TString("X"+suffix+" vertex error"),100,0.,0.02);
300 <      h["errPVy"+suffix2] = subDir1.make<TH1D>(TString("errPVy"+suffix2), TString("Y"+suffix+" vertex error"),100,0.,0.02);
301 <      h["errPVz"+suffix2] = subDir1.make<TH1D>(TString("errPVz"+suffix2), TString("Z"+suffix+" vertex error"),100,0.,0.02);
302 <      suffix2.clear();
303 <    } // End of   for (int ntrk=nTrkMin_;ntrk<=nTrkMax_;++ntrk) {
304 <    
275 >      h_others->Init("others",suffix,ss.str());
276 >    }
277 >
278      // Book residual and pull histograms only when analyzeOntheFly is enabled
279      if(analyze_) {
280 <      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);
281 <      h2["resx"+suffix+"_nTrk"]->SetMarkerStyle(21);
282 <      h2["resx"+suffix+"_nTrk"]->SetMarkerColor(4);
310 <      h2["resx"+suffix+"_nTrk"]->GetXaxis()->SetTitle("Num of tracks");
311 <      h2["resx"+suffix+"_nTrk"]->GetYaxis()->SetTitle("#mum");
312 <      h2["resy"+suffix+"_nTrk"]= subDir.make<TH2D>(TString("resy"+suffix+"_nTrk"), TString("y-resolution vs number of tracks in pvtx"+suffix),150,0,150,400,0.,200);
313 <      h2["resy"+suffix+"_nTrk"]->SetMarkerStyle(21);
314 <      h2["resy"+suffix+"_nTrk"]->SetMarkerColor(4);
315 <      h2["resy"+suffix+"_nTrk"]->GetXaxis()->SetTitle("Num of tracks");
316 <      h2["resy"+suffix+"_nTrk"]->GetYaxis()->SetTitle("#mum");
317 <      h2["resz"+suffix+"_nTrk"]= subDir.make<TH2D>(TString("resz"+suffix+"_nTrk"), TString("z-resolution vs number of tracks in pvtx"+suffix),150,0,150,400,0.,200);
318 <      h2["resz"+suffix+"_nTrk"]->SetMarkerStyle(21);
319 <      h2["resz"+suffix+"_nTrk"]->SetMarkerColor(4);
320 <      h2["resz"+suffix+"_nTrk"]->GetXaxis()->SetTitle("Num of tracks");
321 <      h2["resz"+suffix+"_nTrk"]->GetYaxis()->SetTitle("#mum");
322 <      h2["pullx"+suffix+"_nTrk"]= subDir.make<TH2D>(TString("pullx"+suffix+"_nTrk"), TString("x-pull vs number of tracks"+suffix),150,0,150,100,0.,2.);
323 <      h2["pullx"+suffix+"_nTrk"]->SetMarkerStyle(21);
324 <      h2["pullx"+suffix+"_nTrk"]->SetMarkerColor(4);
325 <      h2["pullx"+suffix+"_nTrk"]->SetBit(TH1::kCanRebin);
326 <      h2["pullx"+suffix+"_nTrk"]->GetXaxis()->SetTitle("Num of tracks");
327 <      h2["pully"+suffix+"_nTrk"]= subDir.make<TH2D>(TString("pully"+suffix+"_nTrk"), TString("y-pull vs number of tracks"+suffix),150,0,150,100,0.,2.);
328 <      h2["pully"+suffix+"_nTrk"]->SetMarkerStyle(21);
329 <      h2["pully"+suffix+"_nTrk"]->SetMarkerColor(4);
330 <      h2["pully"+suffix+"_nTrk"]->SetBit(TH1::kCanRebin);
331 <      h2["pully"+suffix+"_nTrk"]->GetXaxis()->SetTitle("Num of tracks");
332 <      h2["pullz"+suffix+"_nTrk"]= subDir.make<TH2D>(TString("pullz"+suffix+"_nTrk"), TString("x-pull vs number of tracks"+suffix),150,0,150,100,0.,2.);
333 <      h2["pullz"+suffix+"_nTrk"]->SetMarkerStyle(21);
334 <      h2["pullz"+suffix+"_nTrk"]->SetMarkerColor(4);
335 <      h2["pullz"+suffix+"_nTrk"]->SetBit(TH1::kCanRebin);
336 <      h2["pullz"+suffix+"_nTrk"]->GetXaxis()->SetTitle("Num of tracks");
337 <    } // End of   if(analyze_) {
280 >      h_ana = new PVHistograms();
281 >      h_ana->InitA("analysis",suffix,"nTrk",nTrkMin_,nTrkMax_);
282 >    }
283      suffix.clear();
284    } // End of Book histograms sensitive to data/mc    
285 <  
341 <  // Book histograms about pixelVertices
342 <  h["trkdz_pxlpvtxdz"]   = subDir.make<TH1D>("trkdz_pxlpvtxdz", "(Track dz - pixelpvtx dz) in cm",300,-0.5,0.5);
343 <  h["trkdz_pxlpvtxdz_pxlpvtxdzerr"]   = subDir.make<TH1D>("trkdz_pxlpvtxdz_pxlpvtxdzerr", "|Track dz - pixelpvtx dz| / pxlpvtxdzErr",300,0,100);
344 <  h["trkdz_pxlpvtxdz_trkdzerr"]   = subDir.make<TH1D>("trkdz_pxlpvtxdz_trkdzerr", "|Track dz - pixelpvtx dz| / trkdzErr",300,0,50);
345 <  h["trkdzErr_pxlpvtx"]   = subDir.make<TH1D>("trkdzErr_pxlpvtxdz", "Track dzErr of leading pixelpvtx ",300,0,0.5);
346 <  h["trkdzErr_pvtx"]   = subDir.make<TH1D>("trkdzErr_pvtx", "Track dzErr of the leading pvtx ",300,0,0.5);
347 <  h["dzErr_pxlpvtx"]   = subDir.make<TH1D>("dzErr_pxlpvtx", "zError of the leading pvtx ",300,0,0.5);
348 <
349 <  // Book MC only plots
350 <  if (!realData_) {  
351 <    h["genPart_T"]      = subDir.make<TH1D>("genPart_T","t component of gen particles",300,-0.5,0.5);
352 <    h["genPart_T"]->GetXaxis()->SetTitle("t (nanosecond)");
353 <    h["genPart_cT"]     = subDir.make<TH1D>("genPart_cT","ct component of gen particles",300,-150.,150.);
354 <    h["genPart_cT"]->GetXaxis()->SetTitle("ct (mm)");    
355 <    h["nsimPV"]         = subDir.make<TH1D>("nsimPV","Num of sim PV",51,-0.5,50.5);  
356 <  }
285 >
286   }
287  
288   PVStudy::~PVStudy()
289   {
290 <
291 <  // do anything here that needs to be done at desctruction time
292 <  // (e.g. close files, deallocate resources etc.)
290 >  theFile->cd();
291 >  theFile->cd("Summary");
292 >  h_pvtrk->Save();
293 >  h_pixvtx->Save();
294 >  h_gen->Save();
295 >  h_misc->Save();
296 >  h_summary->Save();
297 >  if (analyze_)
298 >    h_ana->Save();
299 >  theFile->cd();
300 >  theFile->cd("Others");
301 >  h_others->Save();
302  
303 +  theFile->Close();
304   }
305  
306   void PVStudy::setRootStyle() {
# Line 422 | Line 361 | std::vector<PVStudy::simPrimaryVertex> P
361          if( ((*mother)->status() == 3) && (!mv)) {
362            //        std::cout << "npv= " << npv << std::endl;
363            if (npv == 0) {
364 <            h["genPart_cT"]->Fill(pos.t()); // mm
365 <            h["genPart_T"]->Fill(pos.t()/299.792458); // ns
364 >            h_gen->Fill1d("genPart_cT", pos.t()); // mm
365 >            h_gen->Fill1d("genPart_T", pos.t()/299.792458); // ns
366            }
367            npv++;
368          }
# Line 490 | Line 429 | std::vector<PVStudy::simPrimaryVertex> P
429              }
430            }
431          }
432 <      }
433 <    }
432 >      }//loop MC vertices daughters
433 >    }//loop MC vertices
434    }
435    return simpv;
436   }
# Line 524 | Line 463 | std::vector<PVStudy::simPrimaryVertex> P
463                ptsq+=(*daughter)->momentum().perp()*(*daughter)->momentum().perp();
464              }
465            }
466 <          primary =  ( gv->position().t()==0);
466 >          //primary =  ( gv->position().t()==0 );
467 >          primary = true;
468 >          h_gen->Fill1d("genPart_cT", gv->position().t()); // mm
469 >          h_gen->Fill1d("genPart_T", gv->position().t()/299.792458); // ns
470 >
471            //resonance= ( gp->mother() && isResonance(gp->mother()));  // in CLHEP/HepMC days
472            // no more mother pointer in the improved HepMC GenParticle
473            resonance= ( isResonance(*(gp->production_vertex()->particles_in_const_begin())));
# Line 618 | Line 561 | PVStudy::analyze(const edm::Event& iEven
561    }
562  
563  
564 < //=======================================================
564 >  //=======================================================
565    // Fill trackparameters of the input tracks to pvtx fitter
566    //=======================================================
567    if(verbose_)
# Line 705 | Line 648 | PVStudy::analyze(const edm::Event& iEven
648    //=======================================================
649    // Fill pixelVertices related histograms
650    //=======================================================
651 +  nrecPV_pxlpvtx_ = int (pixelVertexColl->size());
652    if(pixelVertexColl->size()>0 && pixelVertexColl->begin()->isValid() && !(pixelVertexColl->begin()->isFake())) {
653 <    h["dzErr_pxlpvtx"]->Fill( pixelVertexColl->begin()->zError());    
653 >    //fillTrackHistoInPV(const reco::VertexCollection *vertexColl, int datatype, bool fillHisto, bool fillNtuple) {
654 >    fillTrackHistoInPV(pixelVertexColl, 4, false, true);
655 >    h_pixvtx->Fill1d("dzErr_pxlpvtx", pixelVertexColl->begin()->zError());    
656      // Get the dZ error of the tracks in the leading pixelVertexColl
657      for(reco::Vertex::trackRef_iterator t = (pixelVertexColl->begin())->tracks_begin();
658          t!= (pixelVertexColl->begin())->tracks_end(); t++) {
659        
660        if ( (**t).charge() < -1 || (**t).charge() > 1 ) {
661 <        //        h["trkPtPV"]->Fill(0.);
661 >        //        h_pvtrk->Fill1d("trkPtPV", 0.);
662        }
663        else
664 <        h["trkdzErr_pxlpvtx"]->Fill((**t).dzError());
664 >        h_pixvtx->Fill1d("trkdzErr_pxlpvtx", (**t).dzError());
665      }
666      // Fill the track->dz() in the PV difference from first pixelpvtx
667      for(reco::Vertex::trackRef_iterator t = (vertexColl->begin())->tracks_begin();
668          t!= (vertexColl->begin())->tracks_end(); t++) {
669        // illegal charge
670        if ( (**t).charge() < -1 || (**t).charge() > 1 ) {
671 <        //        h["trkPtPV"]->Fill(0.);
671 >        //        h_pvtrk->Fill1d("trkPtPV", 0.);
672        }
673        else {
674          if(pixelVertexColl->size()>0) {
675 <          h["trkdz_pxlpvtxdz"]->Fill((**t).dz() -  pixelVertexColl->begin()->z());
676 <          h["trkdz_pxlpvtxdz_pxlpvtxdzerr"]->Fill(fabs((**t).dz() -  pixelVertexColl->begin()->z())/pixelVertexColl->begin()->zError());
677 <          h["trkdz_pxlpvtxdz_trkdzerr"]->Fill(fabs((**t).dz() -  pixelVertexColl->begin()->z())/(**t).dzError());
678 <          h["trkdzErr_pvtx"]->Fill((**t).dzError());
675 >          h_pixvtx->Fill1d("trkdz_pxlpvtxdz", (**t).dz() -  pixelVertexColl->begin()->z());
676 >          h_pixvtx->Fill1d("trkdz_pxlpvtxdz_pxlpvtxdzerr", fabs((**t).dz() -  pixelVertexColl->begin()->z())/pixelVertexColl->begin()->zError());
677 >          h_pixvtx->Fill1d("trkdz_pxlpvtxdz_trkdzerr", fabs((**t).dz() -  pixelVertexColl->begin()->z())/(**t).dzError());
678 >          h_pixvtx->Fill1d("trkdzErr_pvtx", (**t).dzError());
679          }
680        }
681      }
682    }
737  
683  
684    //=======================================================
685 <  // Fill number of reconstructed vertices ootb
685 >  // Fill number of reconstructed vertices
686    //=======================================================
687  
688    if(verbose_)  {
# Line 754 | Line 699 | PVStudy::analyze(const edm::Event& iEven
699    nrecPV1_spl_ = int (splitVertexColl1->size());
700    nrecPV2_spl_ = int (splitVertexColl2->size());
701  
702 <  h["nrecPV"]->Fill(nrecPV_);
703 <  h["nrecPV1_spl"]->Fill(nrecPV1_spl_);
704 <  h["nrecPV2_spl"]->Fill(nrecPV2_spl_);
705 <  h["nrecPVDiff"]->Fill(double(nrecPV1_spl_)-double(nrecPV2_spl_));
706 <
702 >  h_pvtrk->Fill1d("nrecPV", nrecPV_);
703 >  h_pvtrk->Fill1d("nrecPV1_spl", nrecPV1_spl_);
704 >  h_pvtrk->Fill1d("nrecPV2_spl", nrecPV2_spl_);
705 >  h_misc->Fill1d("nrecPVDiff", double(nrecPV1_spl_)-double(nrecPV2_spl_));
706 >  
707    //=================================================================
708    // Fill track parameter ntuple/hist for tracks used in recoVertices
709    //=================================================================
# Line 773 | Line 718 | PVStudy::analyze(const edm::Event& iEven
718    if(splitVertexColl1->size() > 0 && splitVertexColl2->begin()->isValid() && !(splitVertexColl2->begin()->isFake()))
719      fillTrackHistoInPV(splitVertexColl2, 2, false, true);
720  
721 +
722 +  //=======================================================
723 +  // Compare offlinePrimaryVertices with pixelVertices
724 +  //=======================================================
725 +  if( (pixelVertexColl->size()>0 && pixelVertexColl->begin()->isValid() && !(pixelVertexColl->begin()->isFake()))
726 +      && (vertexColl->size()>0 && vertexColl->begin()->isValid() && !(vertexColl->begin()->isFake())) ) {    
727 +    h_pixvtx->Fill1d("nrecPV_minus_nrecPxlPV", double (nrecPV_ - nrecPV_pxlpvtx_));
728 +    // difference in reconstructed position of the leading pvtx
729 +    //cout<<"recx_[0] = "<< recx_[0] << "recx_pxlpvtx_[0] = "<< recx_pxlpvtx_[0]<<endl;  
730 +    //cout<<"recy_[0] = "<< recy_[0] << "recy_pxlpvtx_[0] = "<< recy_pxlpvtx_[0]<<endl;
731 +    h_pixvtx->Fill1d("recxPV_minus_recxPxlPV", recx_[0] - recx_pxlpvtx_[0]);
732 +    h_pixvtx->Fill1d("recyPV_minus_recyPxlPV", recy_[0] - recy_pxlpvtx_[0]);
733 +    h_pixvtx->Fill1d("reczPV_minus_reczPxlPV", recz_[0] - recz_pxlpvtx_[0]);
734 +  }
735 +  
736 +
737 +
738    //==========================================================
739    // Fill secondary/primary min separations for multi-vertices
740    //==========================================================
# Line 823 | Line 785 | PVStudy::analyze(const edm::Event& iEven
785            min_sumpt2sep = fabs(sumPtSquared(*v) - sumPtSquared(*(vertexColl->begin())));
786        }
787      }
788 <    h["min_xsep"]->Fill(min_xsep);
789 <    h["min_ysep"]->Fill(min_ysep);
790 <    h["min_zsep"]->Fill(min_zsep);
791 <    h["min_xsep_sign"]->Fill(min_xsep_sign);
792 <    h["min_ysep_sign"]->Fill(min_ysep_sign);
793 <    h["min_zsep_sign"]->Fill(min_zsep_sign);
794 <    h["min_ntrksep"]->Fill(min_ntrksep);
795 <    h["min_sumpt2sep"]->Fill(min_sumpt2sep);
788 >    h_misc->Fill1d("min_xsep", min_xsep);
789 >    h_misc->Fill1d("min_ysep", min_ysep);
790 >    h_misc->Fill1d("min_zsep", min_zsep);
791 >    h_misc->Fill1d("min_xsep_sign", min_xsep_sign);
792 >    h_misc->Fill1d("min_ysep_sign", min_ysep_sign);
793 >    h_misc->Fill1d("min_zsep_sign", min_zsep_sign);
794 >    h_misc->Fill1d("min_ntrksep", min_ntrksep);
795 >    h_misc->Fill1d("min_sumpt2sep", min_sumpt2sep);
796  
797      min_zsep_ = min_zsep;
798      min_ntrksep_ = min_ntrksep;
# Line 881 | Line 843 | PVStudy::analyze(const edm::Event& iEven
843          int nTrkPV1 = recvtx1->tracksSize();
844          int nTrkPV2 = recvtx2->tracksSize();    
845          double ntrkreldiff = double(nTrkPV1-nTrkPV2)/double(nTrkPV1+nTrkPV2);
846 <        h["nTrkPVDiff"]->Fill(nTrkPV1-nTrkPV2);
847 <        h["nTrkPVRelDiff"]->Fill(ntrkreldiff);
846 >        h_misc->Fill1d("nTrkPVDiff", nTrkPV1-nTrkPV2);
847 >        h_misc->Fill1d("nTrkPVRelDiff", ntrkreldiff);
848          if(fabs(ntrkreldiff)<ntrkdiffcut_) {    
849            if(verbose_) {
850              cout<<"(nTrkPV1-nTrkPV2)/(nTrkPV1+nTrkPV2) = " << ntrkreldiff<<endl;
# Line 931 | Line 893 | PVStudy::analyze(const edm::Event& iEven
893        ferror_[2] = sqrt(pow(v1->zError(),2)+pow(v2->zError(),2))/sqrt(2);
894        fntrk_ =  (v1->tracksSize()+v2->tracksSize())/2;
895        
896 <      h["deltax"]->Fill( fres_[0] );
897 <      h["deltay"]->Fill( fres_[1] );
898 <      h["deltaz"]->Fill( fres_[2] );
899 <      h["pullx"]->Fill( fres_[0]/ferror_[0]);
900 <      h["pully"]->Fill( fres_[1]/ferror_[1]);
901 <      h["pullz"]->Fill( fres_[2]/ferror_[2]);
902 <      h["errPVx"]->Fill( ferror_[0] );
903 <      h["errPVy"]->Fill( ferror_[1] );
904 <      h["errPVz"]->Fill( ferror_[2] );
896 >      h_summary->Fill1d("deltax", fres_[0] );
897 >      h_summary->Fill1d("deltay", fres_[1] );
898 >      h_summary->Fill1d("deltaz", fres_[2] );
899 >      h_summary->Fill1d("pullx", fres_[0]/ferror_[0]);
900 >      h_summary->Fill1d("pully", fres_[1]/ferror_[1]);
901 >      h_summary->Fill1d("pullz", fres_[2]/ferror_[2]);
902 >      h_summary->Fill1d("errPVx", ferror_[0] );
903 >      h_summary->Fill1d("errPVy", ferror_[1] );
904 >      h_summary->Fill1d("errPVz", ferror_[2] );
905        pvinfo.push_back(PVStudy::PVInfo(res(fres_[0], fres_[1], fres_[2]),
906                                         error(ferror_[0], ferror_[1], ferror_[2]),
907                                         fntrk_));
# Line 994 | Line 956 | PVStudy::analyze(const edm::Event& iEven
956        std::vector<simPrimaryVertex> simpv;
957        simpv=getSimPVs(evtMC,"");
958        //     simpv=getSimPVs(evtMC, simVtxs, simTrks);
959 <      h["nsimPV"]->Fill(simpv.size());
959 >      h_gen->Fill1d("nsimPV", simpv.size());
960        nsimPV_ = simpv.size();
961  
962        int isimpv = 0;
# Line 1047 | Line 1009 | PVStudy::endJob() {
1009      }
1010      if(analyze_) {
1011        for (int ntrk=nTrkMin_;ntrk<=nTrkMax_;++ntrk) {
1012 +        cout << "ntrk = " << ntrk << endl;
1013          PVStudy::PVAnaInfo ipv = GetPVAnaInfo(ntrk,*it);
1014 <        if ( ipv.res_.x() > 0 ) h2["resx"+suffix+"_nTrk"]->Fill(ntrk,ipv.res_.x(), 1.);
1015 <        if ( ipv.res_.y() > 0 ) h2["resy"+suffix+"_nTrk"]->Fill(ntrk,ipv.res_.y(), 1.);
1016 <        if ( ipv.res_.z() > 0 ) h2["resz"+suffix+"_nTrk"]->Fill(ntrk,ipv.res_.z(), 1.);
1017 <        if ( ipv.pull_.x() > 0 ) h2["pullx"+suffix+"_nTrk"]->Fill(ntrk,ipv.pull_.x(), 1.);
1018 <        if ( ipv.pull_.y() > 0 ) h2["pully"+suffix+"_nTrk"]->Fill(ntrk,ipv.pull_.y(), 1.);
1019 <        if ( ipv.pull_.z() > 0 ) h2["pullz"+suffix+"_nTrk"]->Fill(ntrk,ipv.pull_.z(), 1.);
1014 >        if ( ipv.res_.x() > 0 ) h_ana->Fill2d("resx"+suffix+"_nTrk", ntrk,ipv.res_.x(), 1.);
1015 >        if ( ipv.res_.y() > 0 ) h_ana->Fill2d("resy"+suffix+"_nTrk", ntrk,ipv.res_.y(), 1.);
1016 >        if ( ipv.res_.z() > 0 ) h_ana->Fill2d("resz"+suffix+"_nTrk", ntrk,ipv.res_.z(), 1.);
1017 >        if ( ipv.pull_.x() > 0 ) h_ana->Fill2d("pullx"+suffix+"_nTrk", ntrk,ipv.pull_.x(), 1.);
1018 >        if ( ipv.pull_.y() > 0 ) h_ana->Fill2d("pully"+suffix+"_nTrk", ntrk,ipv.pull_.y(), 1.);
1019 >        if ( ipv.pull_.z() > 0 ) h_ana->Fill2d("pullz"+suffix+"_nTrk", ntrk,ipv.pull_.z(), 1.);
1020        }
1021      }
1022      suffix.clear();
# Line 1171 | Line 1134 | void PVStudy::fillHisto(res r, error er,
1134    
1135    if (ntk < nTrkMin_ || ntk > nTrkMax_ ) return;
1136    // Fill histograms of res and pull of ntk
1137 <  h["deltax"+suffix]->Fill(r.x());
1138 <  h["deltay"+suffix]->Fill(r.y());
1139 <  h["deltaz"+suffix]->Fill(r.z());
1140 <  h["pullx"+suffix]->Fill(r.x()/er.x());
1141 <  h["pully"+suffix]->Fill(r.y()/er.y());
1142 <  h["pullz"+suffix]->Fill(r.z()/er.z());  
1143 <  h["errPVx"+suffix]->Fill(er.x());
1144 <  h["errPVy"+suffix]->Fill(er.y());
1145 <  h["errPVz"+suffix]->Fill(er.z());
1137 >  h_others->Fill1d("deltax"+suffix, r.x());
1138 >  h_others->Fill1d("deltay"+suffix, r.y());
1139 >  h_others->Fill1d("deltaz"+suffix, r.z());
1140 >  h_others->Fill1d("pullx"+suffix, r.x()/er.x());
1141 >  h_others->Fill1d("pully"+suffix, r.y()/er.y());
1142 >  h_others->Fill1d("pullz"+suffix, r.z()/er.z());  
1143 >  h_others->Fill1d("errPVx"+suffix, er.x());
1144 >  h_others->Fill1d("errPVy"+suffix, er.y());
1145 >  h_others->Fill1d("errPVz"+suffix, er.z());
1146   }
1147  
1148   PVStudy::PVAnaInfo PVStudy::GetPVAnaInfo(int ntk, int datamode) {
# Line 1199 | Line 1162 | PVStudy::PVAnaInfo PVStudy::GetPVAnaInfo
1162      for ( int i = 0; i < 6; ++i) {
1163        switch (i) {
1164        case 0:
1165 <        fit(h["deltax"+suffix], fpar);
1165 >        if (!h_others->ReadHisto1D("deltax"+suffix)) break;
1166 >        fit(h_others->ReadHisto1D("deltax"+suffix), fpar);
1167          data[i] = fpar[0]*cm2um;
1168          break;
1169        case 1:
1170 <        fit(h["deltay"+suffix], fpar);
1170 >        if (!h_others->ReadHisto1D("deltay"+suffix)) break;
1171 >        fit(h_others->ReadHisto1D("deltay"+suffix), fpar);
1172          data[i] = fpar[0]*cm2um;
1173          break;
1174        case 2:
1175 <        fit(h["deltaz"+suffix], fpar);
1175 >        if (!h_others->ReadHisto1D("deltaz"+suffix)) break;
1176 >        fit(h_others->ReadHisto1D("deltaz"+suffix), fpar);
1177          data[i] = fpar[0]*cm2um;
1178          break;
1179        case 3:
1180 <        fit(h["pullx"+suffix], fpar);
1180 >        if (!h_others->ReadHisto1D("pullx"+suffix)) break;
1181 >        fit(h_others->ReadHisto1D("pullx"+suffix), fpar);
1182          data[i] = fpar[0];
1183          break;
1184        case 4:
1185 <        fit(h["pully"+suffix], fpar);
1185 >        if (!h_others->ReadHisto1D("pully"+suffix)) break;
1186 >        fit(h_others->ReadHisto1D("pully"+suffix), fpar);
1187          data[i] = fpar[0];
1188          break;
1189        case 5:
1190 <        fit(h["pullz"+suffix], fpar);
1190 >        if (!h_others->ReadHisto1D("pullz"+suffix)) break;
1191 >        fit(h_others->ReadHisto1D("pullz"+suffix), fpar);
1192          data[i] = fpar[0];
1193          break;
1194        }
# Line 1238 | Line 1207 | PVStudy::PVAnaInfo PVStudy::GetPVAnaInfo
1207                              ntk);
1208   }
1209  
1210 < void PVStudy::fit(TH1 *&hdist, double fitPars[]){
1210 > void PVStudy::fit(TH1 *hdist, double fitPars[]){
1211    TAxis *axis0 = hdist->GetXaxis();
1212    int nbin = axis0->GetLast();
1213    double nOF = hdist->GetBinContent(nbin+1);
# Line 1291 | Line 1260 | void PVStudy::fillTrackHisto(const reco:
1260    if(datatype == 1) suffix = "1_spl"; // for splittracks 1
1261    if(datatype == 2) suffix = "2_spl"; // for splittracks 2
1262    
1263 <  h["nTrk"+suffix]->Fill(trackColl->size());
1263 >  h_pvtrk->Fill1d("nTrk"+suffix, trackColl->size());
1264    for(reco::TrackCollection::const_iterator itTrack = trackColl->begin();
1265        itTrack != trackColl->end();                      
1266        ++itTrack) {
1267 <    h["trkPt"+suffix]->Fill(itTrack->pt());
1268 <    h["trkDxy"+suffix]->Fill(itTrack->dxy());
1269 <    h["trkDz"+suffix]->Fill(itTrack->dz());
1270 <    h["trkEta"+suffix]->Fill(itTrack->eta());
1271 <    h["trkPhi"+suffix]->Fill(itTrack->phi());
1267 >    h_pvtrk->Fill1d("trkPt"+suffix, itTrack->pt());
1268 >    h_pvtrk->Fill1d("trkDxy"+suffix, itTrack->dxy());
1269 >    h_pvtrk->Fill1d("trkDz"+suffix, itTrack->dz());
1270 >    h_pvtrk->Fill1d("trkEta"+suffix, itTrack->eta());
1271 >    h_pvtrk->Fill1d("trkPhi"+suffix, itTrack->phi());
1272    }
1273   }
1274  
# Line 1323 | Line 1292 | void PVStudy::fillTrackHistoInPV(const r
1292          recx_err_[ivtx] = v->xError();
1293          recy_err_[ivtx] = v->yError();
1294          recz_err_[ivtx] = v->zError();
1326
1327        
1295        }
1296        if(datatype == 1) {
1297          nTrkPV1_spl_[ivtx] = v->tracksSize();  
# Line 1351 | Line 1318 | void PVStudy::fillTrackHistoInPV(const r
1318          recy2_err_spl_[ivtx] = v->yError();
1319          recz2_err_spl_[ivtx] = v->zError();
1320        }
1321 +      if(datatype == 4) { // for pixelVertices
1322 +        nTrkPV_pxlpvtx_[ivtx] = v->tracksSize();        
1323 +        sumptsq_pxlpvtx_[ivtx] = sumPtSquared(*v);      
1324 +        isValid_pxlpvtx_[ivtx] = v->isValid();
1325 +        isFake_pxlpvtx_[ivtx] = v->isFake();
1326 +        recx_pxlpvtx_[ivtx] = v->x();
1327 +        recy_pxlpvtx_[ivtx] = v->y();
1328 +        recz_pxlpvtx_[ivtx] = v->z();
1329 +        recx_err_pxlpvtx_[ivtx] = v->xError();
1330 +        recy_err_pxlpvtx_[ivtx] = v->yError();
1331 +        recz_err_pxlpvtx_[ivtx] = v->zError();
1332 +      }
1333      }
1334    }
1335    // For histogram only fill the leading pvtx parameters
1336    if(fillHisto) {
1337 <    h["nTrkPV"+suffix]->Fill(vertexColl->begin()->tracksSize());
1337 >    h_pvtrk->Fill1d("nTrkPV"+suffix, vertexColl->begin()->tracksSize());
1338      try {
1339        for(reco::Vertex::trackRef_iterator t = vertexColl->begin()->tracks_begin();
1340            t!=vertexColl->begin()->tracks_end(); t++) {
1341          // illegal charge
1342          if ( (**t).charge() < -1 || (**t).charge() > 1 ) {
1343 <          //      h["trkPtPV"]->Fill(0.);
1343 >          //      h_pvtrk->Fill1d("trkPtPV", 0.);
1344          }
1345          else {
1346 <          h["trkPtPV"+suffix]->Fill((**t).pt());
1347 <          h["trkDxyPV"+suffix]->Fill((**t).dxy());
1348 <          h["trkDzPV"+suffix]->Fill((**t).dz());
1349 <          h["trkEtaPV"+suffix]->Fill((**t).eta());
1350 <          h["trkPhiPV"+suffix]->Fill((**t).phi());
1346 >          h_pvtrk->Fill1d("trkPtPV"+suffix, (**t).pt());
1347 >          h_pvtrk->Fill1d("trkDxyPV"+suffix, (**t).dxy());
1348 >          h_pvtrk->Fill1d("trkDzPV"+suffix, (**t).dz());
1349 >          h_pvtrk->Fill1d("trkEtaPV"+suffix, (**t).eta());
1350 >          h_pvtrk->Fill1d("trkPhiPV"+suffix, (**t).phi());
1351          }
1352        }
1353      }
1354      catch (...) {
1355        // exception thrown when trying to use linked track
1356 <      //          h["trkPtPV"]->Fill(0.);
1356 >      //          h_pvtrk->Fill1d("trkPtPV", 0.);
1357      }
1358    }
1359    
# Line 1410 | Line 1389 | void PVStudy::fillMCHisto(std::vector<si
1389        cout << "sim primary vertex x = " << vsim->x << "; y = " << vsim->y << "; z = " << vsim->z <<  endl;
1390        cout << "Is matched? " << (matchVertex(*vsim,*vrec)?"Yes":"No") << endl;
1391      }
1392 <    if ( matchVertex(*vsim,*vrec) ) {
1392 >    if ( matchVertex(*vsim,*vrec) && vrec->isValid() && !vrec->isFake() ) {
1393        vsim->recVtx=&(*vrec);
1394        
1395        // if the matching critera are fulfilled, accept the rec-vertex that is closest in z
# Line 1431 | Line 1410 | void PVStudy::fillMCHisto(std::vector<si
1410        ferror_mct[1] = vsim->recVtx->yError();
1411        ferror_mct[2] = vsim->recVtx->zError();
1412        
1413 <      h["deltax"+suffix]->Fill( fres_mct[0] );
1414 <      h["deltay"+suffix]->Fill( fres_mct[1] );
1415 <      h["deltaz"+suffix]->Fill( fres_mct[2] );
1416 <      h["pullx"+suffix]->Fill( fres_mct[0]/ferror_mct[0] );
1417 <      h["pully"+suffix]->Fill( fres_mct[1]/ferror_mct[1] );
1418 <      h["pullz"+suffix]->Fill( fres_mct[2]/ferror_mct[2] );
1419 <      h["errPVx"+suffix]->Fill( ferror_mct[0] );
1420 <      h["errPVy"+suffix]->Fill( ferror_mct[1] );
1421 <      h["errPVz"+suffix]->Fill( ferror_mct[2] );
1413 >      h_summary->Fill1d("deltax"+suffix, fres_mct[0] );
1414 >      h_summary->Fill1d("deltay"+suffix, fres_mct[1] );
1415 >      h_summary->Fill1d("deltaz"+suffix, fres_mct[2] );
1416 >      h_summary->Fill1d("pullx"+suffix, fres_mct[0]/ferror_mct[0] );
1417 >      h_summary->Fill1d("pully"+suffix, fres_mct[1]/ferror_mct[1] );
1418 >      h_summary->Fill1d("pullz"+suffix, fres_mct[2]/ferror_mct[2] );
1419 >      h_summary->Fill1d("errPVx"+suffix, ferror_mct[0] );
1420 >      h_summary->Fill1d("errPVy"+suffix, ferror_mct[1] );
1421 >      h_summary->Fill1d("errPVz"+suffix, ferror_mct[2] );
1422        pvinfo.push_back(PVStudy::PVInfo(res(fres_mct[0], fres_mct[1], fres_mct[2]),
1423                                         error(ferror_mct[0], ferror_mct[1], ferror_mct[2]),
1424                                         nrectrk));
# Line 1496 | Line 1475 | void PVStudy::SetVarToZero() {
1475    fntrk_ = 0;
1476    //pvtx position (x,y,z) residual and error
1477    for(int i = 0; i<3;i++)    {
1478 <      fres_[i] = 0;
1479 <      ferror_[i] = 0;
1478 >    fres_[i] = 0;
1479 >    ferror_[i] = 0;
1480    }
1481    
1482    //Yanyan's variables
# Line 1531 | Line 1510 | void PVStudy::SetVarToZero() {
1510      recy_err_[i] = 0;
1511      recz_err_[i] = 0;
1512      
1534    
1535
1513      // recoVertices with splitTrack1
1514      nTrkPV1_spl_[i] = 0; // Number of tracks in the pvtx    
1515      sumptsq1_spl_[i] = 0;
# Line 1545 | Line 1522 | void PVStudy::SetVarToZero() {
1522      recy1_err_spl_[i] = 0;
1523      recz1_err_spl_[i] = 0;
1524    
1548    
1525      // recoVertices with splitTrack2
1526      nTrkPV2_spl_[i] = 0; // Number of tracks in the pvtx  
1527      sumptsq2_spl_[i] = 0;
# Line 1558 | Line 1534 | void PVStudy::SetVarToZero() {
1534      recy2_err_spl_[i] = 0;
1535      recz2_err_spl_[i] = 0;
1536      
1537 +    //pixelVertices
1538 +    nTrkPV_pxlpvtx_[i] = 0; // Number of tracks in the pvtx  
1539 +    sumptsq_pxlpvtx_[i] = 0;
1540 +    isValid_pxlpvtx_[i] = -1;
1541 +    isFake_pxlpvtx_[i] = -1;
1542 +    recx_pxlpvtx_[i] = 0;
1543 +    recy_pxlpvtx_[i] = 0;
1544 +    recz_pxlpvtx_[i] = 0;
1545 +    recx_err_pxlpvtx_[i] = 0;
1546 +    recy_err_pxlpvtx_[i] = 0;
1547 +    recz_err_pxlpvtx_[i] = 0;
1548 +
1549      // matched two-vertices
1550      nTrkPV1_spl_twovtx_[i] = 0;
1551      nTrkPV2_spl_twovtx_[i] = 0;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines