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.11 by yygao, Wed Nov 11 19:28:50 2009 UTC vs.
Revision 1.14 by jengbou, Fri Dec 4 20:48:04 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 217 | Line 218 | PVStudy::PVStudy(const edm::ParameterSet
218      }
219    }
220  
220  edm::Service<TFileService> fs;
221  TFileDirectory subDir = fs->mkdir( "Summary" );
222  TFileDirectory subDir1 = fs->mkdir( "Others" );
223  //   TFileDirectory subSubDir = subDir.mkdir( "mySubSubDirectory" );
224
221    setRootStyle();
226  
227  //Book histograms for track and pvtx parameters for each splitted pvtx
228  //i=0 : x (as in unsplit track collection)
229  //i=1 : x1_spl_
230  //i=2 : x2_spl_
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);
253 <      h["trkDxyPV"+suffix] = subDir.make<TH1D>(TString("trkDxyPV"+suffix), TString("Dxy of rec tracks in PV"+suffix),100,-5,5);  
254 <      h["trkDzPV"+suffix] = subDir.make<TH1D>(TString("trkDzPV"+suffix), TString("Dz of rec tracks "+suffix),100,-50,50);
255 <      h["nrecPV"+suffix]   = subDir.make<TH1D>(TString("nrecPV"+suffix), TString("Num of rec pvtx"+suffix),50,0,50);    
256 <      suffix.clear();
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);
268 <  h["min_zsep"]   = subDir.make<TH1D>("min_zsep", "min z diff of primary and secondary pvtx",300,0,5);
269 <  h["min_zsep_sign"]   = subDir.make<TH1D>("min_zsep_sign", "min z diff in signf of primary and secondary pvtx",300,0,200);
270 <  // Difference in reconstructed vtx position
271 <  h["min_ntrksep"]   = subDir.make<TH1D>("min_ntrksep", "min nTrk diff of primary and secondary pvtx",201,-50.5,150.5);
272 <  h["min_sumpt2sep"]   = subDir.make<TH1D>("min_sumpt2sep", "min sumpt2 diff of primary and secondary pvtx",300,0,10000);
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 >  if (analyze_) h_ana = new PVHistograms();
255  
256    //Book histograms sensitive to data/mc
257    for (vector<int>::const_iterator it= datamode.begin(); it != datamode.end() ; ++it) {
258      string suffix;
259 <    if(verbose_)  cout<<"datamode = "<< *it<<endl;
259 >    edm::LogInfo("Debug")<<"datamode = "<< *it<<endl;
260      switch(*it) {
261      case 0: suffix = "";
262        break;
# Line 285 | Line 267 | PVStudy::PVStudy(const edm::ParameterSet
267      case 3: suffix = "_mct";
268        break;
269      }
270 <    h["deltax"+suffix] = subDir.make<TH1D>(TString("deltax"+suffix), TString("x-residual pvtx"+suffix),800,-0.04,0.04);
289 <    h["deltay"+suffix] = subDir.make<TH1D>(TString("deltay"+suffix), TString("y-residual pvtx"+suffix),800,-0.04,0.04);
290 <    h["deltaz"+suffix] = subDir.make<TH1D>(TString("deltaz"+suffix), TString("z-residual pvtx"+suffix),800,-0.04,0.04);
291 <    h["pullx"+suffix]  = subDir.make<TH1D>(TString("pullx"+suffix), TString("x-pull pvtx"+suffix),800,-10,10);
292 <    h["pully"+suffix]  = subDir.make<TH1D>(TString("pully"+suffix), TString("y-pull pvtx"+suffix),800,-10,10);
293 <    h["pullz"+suffix]  = subDir.make<TH1D>(TString("pullz"+suffix), TString("z-pull pvtx"+suffix),800,-10,10);
294 <    h["errPVx"+suffix] = subDir.make<TH1D>(TString("errPVx"+suffix), TString("X"+suffix+" vertex error"),100,0.,0.02);
295 <    h["errPVy"+suffix] = subDir.make<TH1D>(TString("errPVy"+suffix), TString("Y"+suffix+" vertex error"),100,0.,0.02);
296 <    h["errPVz"+suffix] = subDir.make<TH1D>(TString("errPVz"+suffix), TString("Z"+suffix+" vertex error"),100,0.,0.02);
270 >    h_summary->Init("summary",suffix);
271      
272      // Book residual, error and pull histograms for each nTrk bin
273      for (int ntrk=nTrkMin_;ntrk<=nTrkMax_;++ntrk) {
274        stringstream ss;
275        ss << ntrk;
276 <      string suffix2 = suffix+"_"+ss.str();
277 <      h["deltax"+suffix2]  = subDir1.make<TH1D>(TString("deltax"+suffix2), TString("x-residual of pvtx"+suffix),100,-0.02,0.02);
278 <      h["deltax"+suffix2]->GetXaxis()->SetTitle("cm");
305 <      h["deltay"+suffix2]  = subDir1.make<TH1D>(TString("deltay"+suffix2), TString("y-residual of pvtx"+suffix),100,-0.02,0.02);
306 <      h["deltay"+suffix2]->GetXaxis()->SetTitle("cm");
307 <      h["deltaz"+suffix2]  = subDir1.make<TH1D>(TString("deltaz"+suffix2), TString("z-residual of pvtx"+suffix),100,-0.02,0.02);
308 <      h["deltaz"+suffix2]->GetXaxis()->SetTitle("cm");
309 <      h["pullx"+suffix2] = subDir1.make<TH1D>(TString("pullx"+suffix2), TString("x-pull of pvtx"+suffix),100,-10.,10.);
310 <      h["pully"+suffix2] = subDir1.make<TH1D>(TString("pully"+suffix2), TString("y-pull of pvtx"+suffix),100,-10.,10.);
311 <      h["pullz"+suffix2] = subDir1.make<TH1D>(TString("pullz"+suffix2), TString("z-pull of pvtx"+suffix),100,-10.,10.);
312 <      h["errPVx"+suffix2] = subDir1.make<TH1D>(TString("errPVx"+suffix2), TString("X"+suffix+" vertex error"),100,0.,0.02);
313 <      h["errPVy"+suffix2] = subDir1.make<TH1D>(TString("errPVy"+suffix2), TString("Y"+suffix+" vertex error"),100,0.,0.02);
314 <      h["errPVz"+suffix2] = subDir1.make<TH1D>(TString("errPVz"+suffix2), TString("Z"+suffix+" vertex error"),100,0.,0.02);
315 <      suffix2.clear();
316 <    } // End of   for (int ntrk=nTrkMin_;ntrk<=nTrkMax_;++ntrk) {
317 <    
276 >      h_others->Init("others",suffix,ss.str());
277 >    }
278 >
279      // Book residual and pull histograms only when analyzeOntheFly is enabled
280 <    if(analyze_) {
320 <      h2["resx"+suffix+"_nTrk"]= subDir.make<TH2D>(TString("resx"+suffix+"_nTrk"), TString("x-resolution vs number of tracks in pvtx"+suffix),150,0,150,400,0.,200);
321 <      h2["resx"+suffix+"_nTrk"]->SetMarkerStyle(21);
322 <      h2["resx"+suffix+"_nTrk"]->SetMarkerColor(4);
323 <      h2["resx"+suffix+"_nTrk"]->GetXaxis()->SetTitle("Num of tracks");
324 <      h2["resx"+suffix+"_nTrk"]->GetYaxis()->SetTitle("#mum");
325 <      h2["resy"+suffix+"_nTrk"]= subDir.make<TH2D>(TString("resy"+suffix+"_nTrk"), TString("y-resolution vs number of tracks in pvtx"+suffix),150,0,150,400,0.,200);
326 <      h2["resy"+suffix+"_nTrk"]->SetMarkerStyle(21);
327 <      h2["resy"+suffix+"_nTrk"]->SetMarkerColor(4);
328 <      h2["resy"+suffix+"_nTrk"]->GetXaxis()->SetTitle("Num of tracks");
329 <      h2["resy"+suffix+"_nTrk"]->GetYaxis()->SetTitle("#mum");
330 <      h2["resz"+suffix+"_nTrk"]= subDir.make<TH2D>(TString("resz"+suffix+"_nTrk"), TString("z-resolution vs number of tracks in pvtx"+suffix),150,0,150,400,0.,200);
331 <      h2["resz"+suffix+"_nTrk"]->SetMarkerStyle(21);
332 <      h2["resz"+suffix+"_nTrk"]->SetMarkerColor(4);
333 <      h2["resz"+suffix+"_nTrk"]->GetXaxis()->SetTitle("Num of tracks");
334 <      h2["resz"+suffix+"_nTrk"]->GetYaxis()->SetTitle("#mum");
335 <      h2["pullx"+suffix+"_nTrk"]= subDir.make<TH2D>(TString("pullx"+suffix+"_nTrk"), TString("x-pull vs number of tracks"+suffix),150,0,150,100,0.,2.);
336 <      h2["pullx"+suffix+"_nTrk"]->SetMarkerStyle(21);
337 <      h2["pullx"+suffix+"_nTrk"]->SetMarkerColor(4);
338 <      h2["pullx"+suffix+"_nTrk"]->SetBit(TH1::kCanRebin);
339 <      h2["pullx"+suffix+"_nTrk"]->GetXaxis()->SetTitle("Num of tracks");
340 <      h2["pully"+suffix+"_nTrk"]= subDir.make<TH2D>(TString("pully"+suffix+"_nTrk"), TString("y-pull vs number of tracks"+suffix),150,0,150,100,0.,2.);
341 <      h2["pully"+suffix+"_nTrk"]->SetMarkerStyle(21);
342 <      h2["pully"+suffix+"_nTrk"]->SetMarkerColor(4);
343 <      h2["pully"+suffix+"_nTrk"]->SetBit(TH1::kCanRebin);
344 <      h2["pully"+suffix+"_nTrk"]->GetXaxis()->SetTitle("Num of tracks");
345 <      h2["pullz"+suffix+"_nTrk"]= subDir.make<TH2D>(TString("pullz"+suffix+"_nTrk"), TString("x-pull vs number of tracks"+suffix),150,0,150,100,0.,2.);
346 <      h2["pullz"+suffix+"_nTrk"]->SetMarkerStyle(21);
347 <      h2["pullz"+suffix+"_nTrk"]->SetMarkerColor(4);
348 <      h2["pullz"+suffix+"_nTrk"]->SetBit(TH1::kCanRebin);
349 <      h2["pullz"+suffix+"_nTrk"]->GetXaxis()->SetTitle("Num of tracks");
350 <    } // End of   if(analyze_) {
280 >    if(analyze_) h_ana->InitA("analysis",suffix,"nTrk",nTrkMin_,nTrkMax_);
281      suffix.clear();
282    } // End of Book histograms sensitive to data/mc    
353  
354  // Book histograms about pixelVertices
355  h["trkdz_pxlpvtxdz"]   = subDir.make<TH1D>("trkdz_pxlpvtxdz", "(Track dz - pixelpvtx dz) in cm",300,-0.5,0.5);
356  h["trkdz_pxlpvtxdz_pxlpvtxdzerr"]   = subDir.make<TH1D>("trkdz_pxlpvtxdz_pxlpvtxdzerr", "|Track dz - pixelpvtx dz| / pxlpvtxdzErr",300,0,100);  
357  h["trkdz_pxlpvtxdz_trkdzerr"]   = subDir.make<TH1D>("trkdz_pxlpvtxdz_trkdzerr", "|Track dz - pixelpvtx dz| / trkdzErr",300,0,50);
358  h["trkdzErr_pxlpvtx"]   = subDir.make<TH1D>("trkdzErr_pxlpvtxdz", "Track dzErr of leading pixelpvtx ",300,0,0.5);
359  h["trkdzErr_pvtx"]   = subDir.make<TH1D>("trkdzErr_pvtx", "Track dzErr of the leading pvtx ",300,0,0.5);
360  h["dzErr_pxlpvtx"]   = subDir.make<TH1D>("dzErr_pxlpvtx", "zError of the leading pvtx ",300,0,0.5);
361  // Compare offlinePrimaryVertices with pixelVertices
362  h["nrecPV_minus_nrecPxlPV"] =  subDir.make<TH1D>("nrecPV_minus_nrecPxlPV", "nrecPV_minus_nrecPxlPV",21,-10.5,10.5);
363  h["recxPV_minus_recxPxlPV"] =  subDir.make<TH1D>("recxPV_minus_recxPxlPV", "recxPV_minus_recxPxlPV",300,-0.02,0.02);
364  h["recyPV_minus_recyPxlPV"] =  subDir.make<TH1D>("recyPV_minus_recyPxlPV", "recyPV_minus_recyPxlPV",300,-0.02,0.02);
365  h["reczPV_minus_reczPxlPV"] =  subDir.make<TH1D>("reczPV_minus_reczPxlPV", "reczPV_minus_reczPxlPV",300,-0.1,0.1);
283  
367  // Book MC only plots
368  if (!realData_) {  
369    h["genPart_T"]      = subDir.make<TH1D>("genPart_T","t component of gen particles",300,-0.5,0.5);
370    h["genPart_T"]->GetXaxis()->SetTitle("t (nanosecond)");
371    h["genPart_cT"]     = subDir.make<TH1D>("genPart_cT","ct component of gen particles",300,-150.,150.);
372    h["genPart_cT"]->GetXaxis()->SetTitle("ct (mm)");    
373    h["nsimPV"]         = subDir.make<TH1D>("nsimPV","Num of sim PV",51,-0.5,50.5);  
374  }
284   }
285  
286   PVStudy::~PVStudy()
287   {
288 <
289 <  // do anything here that needs to be done at desctruction time
290 <  // (e.g. close files, deallocate resources etc.)
288 >  theFile->cd();
289 >  theFile->cd("Summary");
290 >  h_pvtrk->Save();
291 >  h_pixvtx->Save();
292 >  h_gen->Save();
293 >  h_misc->Save();
294 >  h_summary->Save();
295 >  if (analyze_)
296 >    h_ana->Save();
297 >  theFile->cd();
298 >  theFile->cd("Others");
299 >  h_others->Save();
300  
301 +  theFile->Close();
302   }
303  
304   void PVStudy::setRootStyle() {
# Line 419 | Line 338 | std::vector<PVStudy::simPrimaryVertex> P
338    std::vector<PVStudy::simPrimaryVertex> simpv;
339    const HepMC::GenEvent* evt=evtMC->GetEvent();
340    if (evt) {
341 <    if(verbose_) {
342 <      cout << "process id " << evt->signal_process_id()<<endl;
343 <      cout << "signal process vertex " << ( evt->signal_process_vertex() ?
344 <                                            evt->signal_process_vertex()->barcode() : 0 )   <<endl;
426 <      cout << "number of vertices " << evt->vertices_size() << endl;
427 <    }
341 >    edm::LogInfo("SimPVs") << "[getSimPVs] process id " << evt->signal_process_id()<<endl;
342 >    edm::LogInfo("SimPVs") << "[getSimPVs] signal process vertex " << ( evt->signal_process_vertex() ?
343 >                                                                        evt->signal_process_vertex()->barcode() : 0 ) <<endl;
344 >    edm::LogInfo("SimPVs") << "[getSimPVs] number of vertices " << evt->vertices_size() << endl;
345  
346      int idx=0; int npv=0;
347      for(HepMC::GenEvent::vertex_const_iterator vitr= evt->vertices_begin();
# Line 435 | Line 352 | std::vector<PVStudy::simPrimaryVertex> P
352        // t component of PV:
353        for ( HepMC::GenVertex::particle_iterator mother  = (*vitr)->particles_begin(HepMC::parents);
354              mother != (*vitr)->particles_end(HepMC::parents); ++mother ) {
355 <        //        std::cout << "Status = " << (*mother)->status() << std::endl;
355 >        //        edm::LogInfo("SimPVs") << "Status = " << (*mother)->status() << endl;
356          HepMC::GenVertex * mv=(*mother)->production_vertex();
357          if( ((*mother)->status() == 3) && (!mv)) {
358 <          //        std::cout << "npv= " << npv << std::endl;
358 >          //        edm::LogInfo("SimPVs") << "npv= " << npv << endl;
359            if (npv == 0) {
360 <            h["genPart_cT"]->Fill(pos.t()); // mm
361 <            h["genPart_T"]->Fill(pos.t()/299.792458); // ns
360 >            h_gen->Fill1d("genPart_cT", pos.t()); // mm
361 >            h_gen->Fill1d("genPart_T", pos.t()/299.792458); // ns
362            }
363            npv++;
364          }
# Line 449 | Line 366 | std::vector<PVStudy::simPrimaryVertex> P
366        //       if (pos.t()>0) { continue;} // for 22X when t of PV was not smeared
367          
368        bool hasMotherVertex=false;
369 <      if(verbose_) cout << "mothers of vertex[" << ++idx << "]: " << endl;
369 >      if (verbose_) cout << "[getSimPVs] mothers of vertex[" << ++idx << "]: " << endl;
370        for ( HepMC::GenVertex::particle_iterator mother  = (*vitr)->particles_begin(HepMC::parents);
371              mother != (*vitr)->particles_end(HepMC::parents); ++mother ) {
372          HepMC::GenVertex * mv=(*mother)->production_vertex();
373 <        //        std::cout << "Status = " << (*mother)->status() << std::endl;
373 >        // if (verbose_) cout << "Status = " << (*mother)->status() << endl;
374          if (mv) {
375            hasMotherVertex=true;
376            if(!verbose_) break; //if verbose_, print all particles of gen vertices
# Line 480 | Line 397 | std::vector<PVStudy::simPrimaryVertex> P
397  
398        if(!vp){
399          // this is a new vertex
400 <        if(verbose_) cout << "this is a new vertex " << sv.x << " " << sv.y << " " << sv.z << endl;
400 >        edm::LogInfo("SimPVs") << "[getSimPVs] this is a new vertex " << sv.x << " " << sv.y << " " << sv.z << endl;
401          simpv.push_back(sv);
402          vp=&simpv.back();
403        }else{
404 <        if(verbose_) cout << "this is not a new vertex " << sv.x << " " << sv.y << " " << sv.z << endl;
404 >        edm::LogInfo("SimPVs") << "[getSimPVs] this is not a new vertex " << sv.x << " " << sv.y << " " << sv.z << endl;
405        }
406        vp->genVertex.push_back((*vitr)->barcode());
407        // collect final state descendants
# Line 508 | Line 425 | std::vector<PVStudy::simPrimaryVertex> P
425              }
426            }
427          }
428 <      }
429 <    }
428 >      }//loop MC vertices daughters
429 >    }//loop MC vertices
430    }
431    return simpv;
432   }
# Line 542 | Line 459 | std::vector<PVStudy::simPrimaryVertex> P
459                ptsq+=(*daughter)->momentum().perp()*(*daughter)->momentum().perp();
460              }
461            }
462 <          primary =  ( gv->position().t()==0);
462 >          //primary =  ( gv->position().t()==0 );
463 >          primary = true;
464 >          h_gen->Fill1d("genPart_cT", gv->position().t()); // mm
465 >          h_gen->Fill1d("genPart_T", gv->position().t()/299.792458); // ns
466 >
467            //resonance= ( gp->mother() && isResonance(gp->mother()));  // in CLHEP/HepMC days
468            // no more mother pointer in the improved HepMC GenParticle
469            resonance= ( isResonance(*(gp->production_vertex()->particles_in_const_begin())));
# Line 591 | Line 512 | PVStudy::analyze(const edm::Event& iEven
512    using namespace edm;
513    using namespace reco;
514    
515 <  if (verbose_)
595 <    cout<<"PVStudy::analyze():"<<endl;
515 >  edm::LogInfo("Debug")<<"[PVStudy]"<<endl;
516    //=======================================================
517    // Initialize Root-tuple variables if needed
518    //=======================================================
# Line 610 | Line 530 | PVStudy::analyze(const edm::Event& iEven
530    if( iEvent.getByLabel(trackCollectionTag_, trackCollectionHandle)) {
531      trackColl = trackCollectionHandle.product();
532    } else {
533 <    cout << "trackCollection cannot be found -> using empty collection of same type." <<endl;
533 >    edm::LogInfo("Debug") << "[PVStudy] trackCollection cannot be found -> using empty collection of same type." <<endl;
534    }
535  
536    //splitTrackCollection1
# Line 621 | Line 541 | PVStudy::analyze(const edm::Event& iEven
541    if( iEvent.getByLabel(splitTrackCollection1Tag_, splitTrackCollection1Handle)) {
542      splitTrackColl1 = splitTrackCollection1Handle.product();
543    } else {
544 <    cout << "splitTrackCollection1 cannot be found -> using empty collection of same type." <<endl;
544 >    edm::LogInfo("Debug") << "[PVStudy] splitTrackCollection1 cannot be found -> using empty collection of same type." <<endl;
545    }
546  
547    //splitTrackCollection2
# Line 632 | Line 552 | PVStudy::analyze(const edm::Event& iEven
552    if( iEvent.getByLabel(splitTrackCollection2Tag_, splitTrackCollection2Handle)) {
553      splitTrackColl2 = splitTrackCollection2Handle.product();
554    } else {
555 <    cout << "splitTrackCollection2 cannot be found -> using empty collection of same type." <<endl;
555 >    edm::LogInfo("Debug") << "[PVStudy] splitTrackCollection2 cannot be found -> using empty collection of same type." <<endl;
556    }
557  
558  
559 < //=======================================================
559 >  //=======================================================
560    // Fill trackparameters of the input tracks to pvtx fitter
561    //=======================================================
562 <  if(verbose_)
643 <    cout<<"Start filling track parameters of the input tracks to pvtx fitter."<<endl;
562 >  edm::LogInfo("Debug")<<"[PVStudy] Start filling track parameters of the input tracks to pvtx fitter."<<endl;
563    //fillTrackHisto(const reco::TrackCollection *trackColl, int datatype)
564    // datatype: unsplittracks (0); splittracks1 (1);  splittracks2 (2);
565    fillTrackHisto(trackColl, 0);
566    fillTrackHisto(splitTrackColl1, 1);
567    fillTrackHisto(splitTrackColl2, 2);
568 <  if(verbose_)
650 <    cout<<"End filling track parameters of the input tracks to pvtx fitter."<<endl;
568 >  edm::LogInfo("Debug")<<"[PVStudy] End filling track parameters of the input tracks to pvtx fitter."<<endl;
569  
570    //=======================================================
571    // PVTX accessors
# Line 660 | Line 578 | PVStudy::analyze(const edm::Event& iEven
578    if( iEvent.getByLabel(vertexCollectionTag_, vertexCollectionHandle)) {
579      vertexColl = vertexCollectionHandle.product();
580    } else {
581 <    cout << "vertexCollection cannot be found -> using empty collection of same type." <<endl;
581 >    edm::LogInfo("Debug") << "[PVStudy] vertexCollection cannot be found -> using empty collection of same type." <<endl;
582    }
583  
584    //splitVertexCollection1
# Line 671 | Line 589 | PVStudy::analyze(const edm::Event& iEven
589    if( iEvent.getByLabel(splitVertexCollection1Tag_, splitVertexCollection1Handle)) {
590      splitVertexColl1 = splitVertexCollection1Handle.product();
591    } else {
592 <    cout << "splitVertexCollection1 cannot be found -> using empty collection of same type." <<endl;
592 >    edm::LogInfo("Debug") << "[PVStudy] splitVertexCollection1 cannot be found -> using empty collection of same type." <<endl;
593    }
594  
595    //splitVertexCollection2
# Line 682 | Line 600 | PVStudy::analyze(const edm::Event& iEven
600    if( iEvent.getByLabel(splitVertexCollection2Tag_, splitVertexCollection2Handle)) {
601      splitVertexColl2 = splitVertexCollection2Handle.product();
602    } else {
603 <    cout << "splitVertexCollection2 cannot be found -> using empty collection of same type." <<endl;
603 >    edm::LogInfo("Debug") << "[PVStudy] splitVertexCollection2 cannot be found -> using empty collection of same type." <<endl;
604    }
605    
606 <  if(verbose_) cout<<"End accessing the track and vertex collections"<<endl;
606 >  edm::LogInfo("Debug")<<"[PVStudy] End accessing the track and vertex collections"<<endl;
607    
608    //=======================================================
609    // MC simvtx accessor
# Line 704 | Line 622 | PVStudy::analyze(const edm::Event& iEven
622    try{
623      iSetup.getData(pdt);
624    }catch(const Exception&){
625 <    cout << "Some problem occurred with the particle data table. This may not work !." <<endl;
625 >    edm::LogInfo("Debug") << "[PVStudy] Some problem occurred with the particle data table. This may not work !." <<endl;
626    }
627    
628    //=======================================================
# Line 717 | Line 635 | PVStudy::analyze(const edm::Event& iEven
635    if( iEvent.getByLabel(pixelVertexCollectionTag_, pixelVertexCollectionHandle)) {
636      pixelVertexColl = pixelVertexCollectionHandle.product();
637    } else {
638 <    cout << "pixelVertexCollection cannot be found. -> using empty collection of same type." <<endl;
638 >    edm::LogInfo("Debug") << "[PVStudy] pixelVertexCollection cannot be found. -> using empty collection of same type." <<endl;
639    }
640  
641    //=======================================================
# Line 727 | Line 645 | PVStudy::analyze(const edm::Event& iEven
645    if(pixelVertexColl->size()>0 && pixelVertexColl->begin()->isValid() && !(pixelVertexColl->begin()->isFake())) {
646      //fillTrackHistoInPV(const reco::VertexCollection *vertexColl, int datatype, bool fillHisto, bool fillNtuple) {
647      fillTrackHistoInPV(pixelVertexColl, 4, false, true);
648 <    h["dzErr_pxlpvtx"]->Fill( pixelVertexColl->begin()->zError());    
648 >    h_pixvtx->Fill1d("dzErr_pxlpvtx", pixelVertexColl->begin()->zError());    
649      // Get the dZ error of the tracks in the leading pixelVertexColl
650      for(reco::Vertex::trackRef_iterator t = (pixelVertexColl->begin())->tracks_begin();
651          t!= (pixelVertexColl->begin())->tracks_end(); t++) {
652        
653        if ( (**t).charge() < -1 || (**t).charge() > 1 ) {
654 <        //        h["trkPtPV"]->Fill(0.);
654 >        //        h_pvtrk->Fill1d("trkPtPV", 0.);
655        }
656        else
657 <        h["trkdzErr_pxlpvtx"]->Fill((**t).dzError());
657 >        h_pixvtx->Fill1d("trkdzErr_pxlpvtx", (**t).dzError());
658      }
659      // Fill the track->dz() in the PV difference from first pixelpvtx
660      for(reco::Vertex::trackRef_iterator t = (vertexColl->begin())->tracks_begin();
661          t!= (vertexColl->begin())->tracks_end(); t++) {
662        // illegal charge
663        if ( (**t).charge() < -1 || (**t).charge() > 1 ) {
664 <        //        h["trkPtPV"]->Fill(0.);
664 >        //        h_pvtrk->Fill1d("trkPtPV", 0.);
665        }
666        else {
667          if(pixelVertexColl->size()>0) {
668 <          h["trkdz_pxlpvtxdz"]->Fill((**t).dz() -  pixelVertexColl->begin()->z());
669 <          h["trkdz_pxlpvtxdz_pxlpvtxdzerr"]->Fill(fabs((**t).dz() -  pixelVertexColl->begin()->z())/pixelVertexColl->begin()->zError());
670 <          h["trkdz_pxlpvtxdz_trkdzerr"]->Fill(fabs((**t).dz() -  pixelVertexColl->begin()->z())/(**t).dzError());
671 <          h["trkdzErr_pvtx"]->Fill((**t).dzError());
668 >          h_pixvtx->Fill1d("trkdz_pxlpvtxdz", (**t).dz() -  pixelVertexColl->begin()->z());
669 >          h_pixvtx->Fill1d("trkdz_pxlpvtxdz_pxlpvtxdzerr", fabs((**t).dz() -  pixelVertexColl->begin()->z())/pixelVertexColl->begin()->zError());
670 >          h_pixvtx->Fill1d("trkdz_pxlpvtxdz_trkdzerr", fabs((**t).dz() -  pixelVertexColl->begin()->z())/(**t).dzError());
671 >          h_pixvtx->Fill1d("trkdzErr_pvtx", (**t).dzError());
672          }
673        }
674      }
# Line 760 | Line 678 | PVStudy::analyze(const edm::Event& iEven
678    // Fill number of reconstructed vertices
679    //=======================================================
680  
681 <  if(verbose_)  {
682 <    cout<<"PVStudy::analyze() Printing vertexCollection: "<<endl;
681 >  edm::LogInfo("Debug")<<"[PVStudy] Printing vertexCollection: "<<endl;
682 >  edm::LogInfo("Debug")<<"[PVStudy] Printing splitVertexCollection1: "<<endl;
683 >  edm::LogInfo("Debug")<<"[PVStudy] Printing splitVertexCollection2: "<<endl;
684 >  edm::LogInfo("Debug")<<"[PVStudy] Start filling pvtx parameters."<<endl;
685 >  if (verbose_) {
686      printRecVtxs(vertexCollectionHandle);
766    cout<<"PVStudy::analyze() Printing splitVertexCollection1: "<<endl;
687      printRecVtxs(splitVertexCollection1Handle);
768    cout<<"PVStudy::analyze() Printing splitVertexCollection2: "<<endl;
688      printRecVtxs(splitVertexCollection2Handle);
770    cout<<"Start filling pvtx parameters."<<endl;
689    }
772  
690    nrecPV_ = int (vertexColl->size());
691    nrecPV1_spl_ = int (splitVertexColl1->size());
692    nrecPV2_spl_ = int (splitVertexColl2->size());
693  
694 <  h["nrecPV"]->Fill(nrecPV_);
695 <  h["nrecPV1_spl"]->Fill(nrecPV1_spl_);
696 <  h["nrecPV2_spl"]->Fill(nrecPV2_spl_);
697 <  h["nrecPVDiff"]->Fill(double(nrecPV1_spl_)-double(nrecPV2_spl_));
694 >  h_pvtrk->Fill1d("nrecPV", nrecPV_);
695 >  h_pvtrk->Fill1d("nrecPV1_spl", nrecPV1_spl_);
696 >  h_pvtrk->Fill1d("nrecPV2_spl", nrecPV2_spl_);
697 >  h_misc->Fill1d("nrecPVDiff", double(nrecPV1_spl_)-double(nrecPV2_spl_));
698    
699    //=================================================================
700    // Fill track parameter ntuple/hist for tracks used in recoVertices
# Line 799 | Line 716 | PVStudy::analyze(const edm::Event& iEven
716    //=======================================================
717    if( (pixelVertexColl->size()>0 && pixelVertexColl->begin()->isValid() && !(pixelVertexColl->begin()->isFake()))
718        && (vertexColl->size()>0 && vertexColl->begin()->isValid() && !(vertexColl->begin()->isFake())) ) {    
719 <    h["nrecPV_minus_nrecPxlPV"]->Fill( double (nrecPV_ - nrecPV_pxlpvtx_));
719 >    h_pixvtx->Fill1d("nrecPV_minus_nrecPxlPV", double (nrecPV_ - nrecPV_pxlpvtx_));
720      // difference in reconstructed position of the leading pvtx
721 <    //cout<<"recx_[0] = "<< recx_[0] << "recx_pxlpvtx_[0] = "<< recx_pxlpvtx_[0]<<endl;  
722 <    //cout<<"recy_[0] = "<< recy_[0] << "recy_pxlpvtx_[0] = "<< recy_pxlpvtx_[0]<<endl;
723 <    h["recxPV_minus_recxPxlPV"]->Fill (recx_[0] - recx_pxlpvtx_[0]);
724 <    h["recyPV_minus_recyPxlPV"]->Fill (recy_[0] - recy_pxlpvtx_[0]);
725 <    h["reczPV_minus_reczPxlPV"]->Fill (recz_[0] - recz_pxlpvtx_[0]);
721 >    //edm::LogInfo("Debug")<<"recx_[0] = "<< recx_[0] << "recx_pxlpvtx_[0] = "<< recx_pxlpvtx_[0]<<endl;  
722 >    //edm::LogInfo("Debug")<<"recy_[0] = "<< recy_[0] << "recy_pxlpvtx_[0] = "<< recy_pxlpvtx_[0]<<endl;
723 >    h_pixvtx->Fill1d("recxPV_minus_recxPxlPV", recx_[0] - recx_pxlpvtx_[0]);
724 >    h_pixvtx->Fill1d("recyPV_minus_recyPxlPV", recy_[0] - recy_pxlpvtx_[0]);
725 >    h_pixvtx->Fill1d("reczPV_minus_reczPxlPV", recz_[0] - recz_pxlpvtx_[0]);
726    }
727    
728  
# Line 825 | Line 742 | PVStudy::analyze(const edm::Event& iEven
742      double min_ntrksep = 9999.0;
743      double min_sumpt2sep = 9999999.0;
744      
745 <    if(verbose_) cout<<"leading pvtx z = "<< vertexColl->begin()->z() <<endl;
745 >    edm::LogInfo("Debug")<<"[PVStudy] leading pvtx z = "<< vertexColl->begin()->z() <<endl;
746  
747      // Looping through the secondary vertices to find the mininum separation to the primary
748      for(reco::VertexCollection::const_iterator v=vertexColl->begin() + 1 ;
# Line 860 | Line 777 | PVStudy::analyze(const edm::Event& iEven
777            min_sumpt2sep = fabs(sumPtSquared(*v) - sumPtSquared(*(vertexColl->begin())));
778        }
779      }
780 <    h["min_xsep"]->Fill(min_xsep);
781 <    h["min_ysep"]->Fill(min_ysep);
782 <    h["min_zsep"]->Fill(min_zsep);
783 <    h["min_xsep_sign"]->Fill(min_xsep_sign);
784 <    h["min_ysep_sign"]->Fill(min_ysep_sign);
785 <    h["min_zsep_sign"]->Fill(min_zsep_sign);
786 <    h["min_ntrksep"]->Fill(min_ntrksep);
787 <    h["min_sumpt2sep"]->Fill(min_sumpt2sep);
780 >    h_misc->Fill1d("min_xsep", min_xsep);
781 >    h_misc->Fill1d("min_ysep", min_ysep);
782 >    h_misc->Fill1d("min_zsep", min_zsep);
783 >    h_misc->Fill1d("min_xsep_sign", min_xsep_sign);
784 >    h_misc->Fill1d("min_ysep_sign", min_ysep_sign);
785 >    h_misc->Fill1d("min_zsep_sign", min_zsep_sign);
786 >    h_misc->Fill1d("min_ntrksep", min_ntrksep);
787 >    h_misc->Fill1d("min_sumpt2sep", min_sumpt2sep);
788  
789      min_zsep_ = min_zsep;
790      min_ntrksep_ = min_ntrksep;
# Line 876 | Line 793 | PVStudy::analyze(const edm::Event& iEven
793  
794    } // End of  if(vertexColl->size()>1) {
795    
796 <  if(verbose_)
880 <    cout<<"End filling pvtx parameters."<<endl;
796 >  edm::LogInfo("Debug")<<"[PVStudy] End filling pvtx parameters."<<endl;
797    
798    //=======================================================
799    //           PrimaryVertex Matching
# Line 887 | Line 803 | PVStudy::analyze(const edm::Event& iEven
803    // since vertexColl are sorted in decreasing order of sum(pT)
804    //=======================================================
805  
806 <  if(verbose_)   cout<<"PVStudy::analyze(): matching pvtxs "<<endl;
806 >  edm::LogInfo("Debug")<<"[PVStudy] matching pvtxs "<<endl;
807    reco::VertexCollection s_empty_matchedVertexColl1;
808    reco::VertexCollection *matchedVertexColl1 = &s_empty_matchedVertexColl1;
809    matchedVertexColl1->reserve(splitVertexColl1->size());
# Line 906 | Line 822 | PVStudy::analyze(const edm::Event& iEven
822        if (ivtx!=0 || jvtx!=0) { stopmatching = true; break; }
823        reco::VertexRef recvtx2(splitVertexCollection2Handle, jvtx);
824        if( !(recvtx2->isValid()) || recvtx2->isFake()) break;
825 <      if(verbose_) {
826 <        cout<<"Matching splitVertexColl1: #  "<< ivtx<< " and splitVertexColl1: # "<<jvtx<<endl;
827 <        cout<<"recvtx1->z() = " << recvtx1->z() << "+/- "<< recvtx1->zError() << "." << endl;
828 <        cout<<"recvtx2->z() = " << recvtx2->z() << "+/- "<< recvtx2->zError() << "." << endl;
913 <      }
825 >      edm::LogInfo("Debug")<<"[PVStudy] Matching splitVertexColl1: #  "<< ivtx<< " and splitVertexColl1: # "<<jvtx<<endl;
826 >      edm::LogInfo("Debug")<<"[PVStudy] recvtx1->z() = " << recvtx1->z() << "+/- "<< recvtx1->zError() << "." << endl;
827 >      edm::LogInfo("Debug")<<"[PVStudy] recvtx2->z() = " << recvtx2->z() << "+/- "<< recvtx2->zError() << "." << endl;
828 >
829        if(matchVertex(recvtx1, recvtx2, zsigncut_)) {
830 <        if(verbose_) {
831 <          cout<<"The two splitted vertices match in Z. "<<endl;
917 <        }
830 >        edm::LogInfo("Debug")<<"[PVStudy] The two splitted vertices match in Z. "<<endl;
831 >
832          int nTrkPV1 = recvtx1->tracksSize();
833          int nTrkPV2 = recvtx2->tracksSize();    
834          double ntrkreldiff = double(nTrkPV1-nTrkPV2)/double(nTrkPV1+nTrkPV2);
835 <        h["nTrkPVDiff"]->Fill(nTrkPV1-nTrkPV2);
836 <        h["nTrkPVRelDiff"]->Fill(ntrkreldiff);
835 >        h_misc->Fill1d("nTrkPVDiff", nTrkPV1-nTrkPV2);
836 >        h_misc->Fill1d("nTrkPVRelDiff", ntrkreldiff);
837          if(fabs(ntrkreldiff)<ntrkdiffcut_) {    
838 <          if(verbose_) {
839 <            cout<<"(nTrkPV1-nTrkPV2)/(nTrkPV1+nTrkPV2) = " << ntrkreldiff<<endl;
926 <          }
838 >          edm::LogInfo("Debug")<<"[PVStudy] (nTrkPV1-nTrkPV2)/(nTrkPV1+nTrkPV2) = " << ntrkreldiff<<endl;
839 >
840            matchedVertexColl1->push_back(*recvtx1);
841            matchedVertexColl2->push_back(*recvtx2);
842            stopmatching = true; // stop the matching when the first match is found!
843            break;
844          }
845          else
846 <          cout<<"WARNING: (nTrkPV1-nTrkPV2)/(nTrkPV1+nTrkPV2) = " << ntrkreldiff<<", exceeding cut "<<ntrkdiffcut_<<endl;
846 >          edm::LogInfo("Debug")<<"WARNING: (nTrkPV1-nTrkPV2)/(nTrkPV1+nTrkPV2) = " << ntrkreldiff<<", exceeding cut "<<ntrkdiffcut_<<endl;
847        }
848        else {
849 <        cout<<"WARNING: The two reconstructed vertices do not match in z: "<<endl;
850 <        cout<<"recvtx1->z() = " << recvtx1->z() << "+/- "<< recvtx1->zError() << "." << endl;
851 <        cout<<"recvtx2->z() = " << recvtx2->z() << "+/- "<< recvtx2->zError() << "." << endl;  
849 >        edm::LogInfo("Debug")<<"WARNING: The two reconstructed vertices do not match in z: "<<endl;
850 >        edm::LogInfo("Debug")<<"recvtx1->z() = " << recvtx1->z() << "+/- "<< recvtx1->zError() << "." << endl;
851 >        edm::LogInfo("Debug")<<"recvtx2->z() = " << recvtx2->z() << "+/- "<< recvtx2->zError() << "." << endl;  
852        }
853      }
854    }
855 <  if(verbose_)     cout<<"PVStudy::analyze(): End matching pvtxs"<<endl;
855 >  edm::LogInfo("Debug")<<"[PVStudy] End matching pvtxs"<<endl;
856    
857    //=======================================================
858    //  Analyze matchedVertexColls
859    //=======================================================
860 <  if(verbose_) {
948 <    cout<<"Begin analyzing the matchedVertexColl with size = "<< matchedVertexColl1->size()<< endl;
949 <  }    
860 >  edm::LogInfo("Debug")<<"[PVStudy] Begin analyzing the matchedVertexColl with size = "<< matchedVertexColl1->size()<< endl;
861    
862    // Compare the reconstructed vertex position and calculate resolution/pulls
863    if(matchedVertexColl1->size() != 0 && matchedVertexColl2->size() != 0) {  
# Line 968 | Line 879 | PVStudy::analyze(const edm::Event& iEven
879        ferror_[2] = sqrt(pow(v1->zError(),2)+pow(v2->zError(),2))/sqrt(2);
880        fntrk_ =  (v1->tracksSize()+v2->tracksSize())/2;
881        
882 <      h["deltax"]->Fill( fres_[0] );
883 <      h["deltay"]->Fill( fres_[1] );
884 <      h["deltaz"]->Fill( fres_[2] );
885 <      h["pullx"]->Fill( fres_[0]/ferror_[0]);
886 <      h["pully"]->Fill( fres_[1]/ferror_[1]);
887 <      h["pullz"]->Fill( fres_[2]/ferror_[2]);
888 <      h["errPVx"]->Fill( ferror_[0] );
889 <      h["errPVy"]->Fill( ferror_[1] );
890 <      h["errPVz"]->Fill( ferror_[2] );
882 >      h_summary->Fill1d("deltax", fres_[0] );
883 >      h_summary->Fill1d("deltay", fres_[1] );
884 >      h_summary->Fill1d("deltaz", fres_[2] );
885 >      h_summary->Fill1d("pullx", fres_[0]/ferror_[0]);
886 >      h_summary->Fill1d("pully", fres_[1]/ferror_[1]);
887 >      h_summary->Fill1d("pullz", fres_[2]/ferror_[2]);
888 >      h_summary->Fill1d("errPVx", ferror_[0] );
889 >      h_summary->Fill1d("errPVy", ferror_[1] );
890 >      h_summary->Fill1d("errPVz", ferror_[2] );
891        pvinfo.push_back(PVStudy::PVInfo(res(fres_[0], fres_[1], fres_[2]),
892                                         error(ferror_[0], ferror_[1], ferror_[2]),
893                                         fntrk_));
# Line 1003 | Line 914 | PVStudy::analyze(const edm::Event& iEven
914      } // End of analyzing res/pull
915    } // End of  if(matchedVertexColl1->size() == 1 && matchedVertexColl2->size() == 1 ) {
916    else
917 <    cout<<"WARNING: Cannot find matching pvtxs"<<endl;
917 >    edm::LogInfo("Debug")<<"[PVStudy] WARNING: Cannot find matching pvtxs"<<endl;
918    
919 <  if(verbose_)     cout<<"End analyzing the matchedVertexColl"<<endl;
919 >  edm::LogInfo("Debug")<<"[PVStudy] End analyzing the matchedVertexColl"<<endl;
920  
921    //=======================================================
922    // Fill simulated vertices
# Line 1016 | Line 927 | PVStudy::analyze(const edm::Event& iEven
927      iEvent.getByLabel("generator",evtMC);
928      if (!evtMC.isValid()) {
929        MC=false;
930 <      if(verbose_){
1020 <        cout << "no HepMCProduct found"<< endl;
1021 <      }
930 >      edm::LogInfo("Debug") << "[PVStudy] no HepMCProduct found"<< endl;
931      } else {
932 <      if(verbose_){
1024 <        cout << "generator HepMCProduct found"<< endl;
1025 <      }
932 >      edm::LogInfo("Debug") << "[PVStudy] generator HepMCProduct found"<< endl;
933        MC=true;
934      }
935      
# Line 1031 | Line 938 | PVStudy::analyze(const edm::Event& iEven
938        std::vector<simPrimaryVertex> simpv;
939        simpv=getSimPVs(evtMC,"");
940        //     simpv=getSimPVs(evtMC, simVtxs, simTrks);
941 <      h["nsimPV"]->Fill(simpv.size());
941 >      h_gen->Fill1d("nsimPV", simpv.size());
942        nsimPV_ = simpv.size();
943  
944        int isimpv = 0;
# Line 1067 | Line 974 | PVStudy::beginJob()
974   // ------------ method called once each job just after ending the event loop  ------------
975   void
976   PVStudy::endJob() {
977 <  if (verbose_) cout << "Analyzing PV info" << endl;
977 >  edm::LogInfo("Analysis") << "[endJob] Analyzing PV info" << endl;
978    // Looping through the datamodes available
979    for (vector<int>::const_iterator it= datamode.begin(); it != datamode.end() ; ++it) {  
980      string suffix;
981 <    if(verbose_)  cout<<"datamode = "<< *it<<endl;
981 >    edm::LogInfo("Analysis")<<"[endJob] datamode = "<< *it<<endl;
982      switch(*it) {
983      case 0: suffix = "";
984        break;
# Line 1082 | Line 989 | PVStudy::endJob() {
989      case 3: suffix = "_mct";
990        break;
991      }
992 +    suffix += "_nTrk";
993      if(analyze_) {
994        for (int ntrk=nTrkMin_;ntrk<=nTrkMax_;++ntrk) {
995 +        edm::LogInfo("Analysis") << "[endJob] ntrk = " << ntrk << endl;
996          PVStudy::PVAnaInfo ipv = GetPVAnaInfo(ntrk,*it);
997 <        if ( ipv.res_.x() > 0 ) h2["resx"+suffix+"_nTrk"]->Fill(ntrk,ipv.res_.x(), 1.);
998 <        if ( ipv.res_.y() > 0 ) h2["resy"+suffix+"_nTrk"]->Fill(ntrk,ipv.res_.y(), 1.);
999 <        if ( ipv.res_.z() > 0 ) h2["resz"+suffix+"_nTrk"]->Fill(ntrk,ipv.res_.z(), 1.);
1000 <        if ( ipv.pull_.x() > 0 ) h2["pullx"+suffix+"_nTrk"]->Fill(ntrk,ipv.pull_.x(), 1.);
1001 <        if ( ipv.pull_.y() > 0 ) h2["pully"+suffix+"_nTrk"]->Fill(ntrk,ipv.pull_.y(), 1.);
1002 <        if ( ipv.pull_.z() > 0 ) h2["pullz"+suffix+"_nTrk"]->Fill(ntrk,ipv.pull_.z(), 1.);
997 >        if ( ipv.res_.x() > 0 ) h_ana->Fill2d("resx"+suffix, ntrk,ipv.res_.x());
998 >        if ( ipv.res_.y() > 0 ) h_ana->Fill2d("resy"+suffix, ntrk,ipv.res_.y());
999 >        if ( ipv.res_.z() > 0 ) h_ana->Fill2d("resz"+suffix, ntrk,ipv.res_.z());
1000 >        if ( ipv.pull_.x() > 0 ) h_ana->Fill2d("pullx"+suffix, ntrk,ipv.pull_.x());
1001 >        if ( ipv.pull_.y() > 0 ) h_ana->Fill2d("pully"+suffix, ntrk,ipv.pull_.y());
1002 >        if ( ipv.pull_.z() > 0 ) h_ana->Fill2d("pullz"+suffix, ntrk,ipv.pull_.z());
1003        }
1004 <    }
1004 >    }
1005      suffix.clear();
1006    }
1007    if(saventuple_) {
# Line 1120 | Line 1029 | bool PVStudy::matchVertex( const reco::V
1029                             int zsigncut)
1030   {
1031    double cut = zsigncut*max(vrec1->zError(), vrec2->zError());
1032 <  if(verbose_)
1124 <    cout<<"The matching criteria in z is "<<cut<<endl;
1032 >  edm::LogInfo("Debug")<<"[matchVertex] The matching criteria in z is "<<cut<<endl;
1033    return (fabs(vrec1->z()-vrec2->z())<cut);
1034   }
1035  
1036  
1037   bool PVStudy::isResonance(const HepMC::GenParticle * p){
1038    double ctau=(pdt->particle( abs(p->pdg_id()) ))->lifetime();
1039 <  if(verbose_) cout << "isResonance   " << p->pdg_id() << " " << ctau << endl;
1039 >  edm::LogInfo("Debug") << "[isResonance] isResonance   " << p->pdg_id() << " " << ctau << endl;
1040    return  ctau >0 && ctau <1e-6;
1041   }
1042  
# Line 1200 | Line 1108 | void PVStudy::printSimTrks(const Handle<
1108   void PVStudy::fillHisto(res r, error er, int ntk, int datamode){
1109    stringstream ss;
1110    ss << ntk;
1111 <  string suffix = ss.str();
1112 <  if(datamode == 0 )  suffix = "_" + suffix;
1113 <  if(datamode == 1 )  suffix = "_spl1_mct_" + suffix;
1114 <  if(datamode == 2 )  suffix = "_spl2_mct_" + suffix;
1115 <  if(datamode == 3 )  suffix = "_mct_" + suffix;
1111 >  string suffix;
1112 >  if(datamode == 0 )  suffix = "_" + ss.str();
1113 >  if(datamode == 1 )  suffix = "_spl1_mct_" + ss.str();
1114 >  if(datamode == 2 )  suffix = "_spl2_mct_" + ss.str();
1115 >  if(datamode == 3 )  suffix = "_mct_" + ss.str();
1116    
1117    if (ntk < nTrkMin_ || ntk > nTrkMax_ ) return;
1118    // Fill histograms of res and pull of ntk
1119 <  h["deltax"+suffix]->Fill(r.x());
1120 <  h["deltay"+suffix]->Fill(r.y());
1121 <  h["deltaz"+suffix]->Fill(r.z());
1122 <  h["pullx"+suffix]->Fill(r.x()/er.x());
1123 <  h["pully"+suffix]->Fill(r.y()/er.y());
1124 <  h["pullz"+suffix]->Fill(r.z()/er.z());  
1125 <  h["errPVx"+suffix]->Fill(er.x());
1126 <  h["errPVy"+suffix]->Fill(er.y());
1127 <  h["errPVz"+suffix]->Fill(er.z());
1119 >  h_others->Fill1d("deltax"+suffix, r.x());
1120 >  h_others->Fill1d("deltay"+suffix, r.y());
1121 >  h_others->Fill1d("deltaz"+suffix, r.z());
1122 >  h_others->Fill1d("pullx"+suffix, r.x()/er.x());
1123 >  h_others->Fill1d("pully"+suffix, r.y()/er.y());
1124 >  h_others->Fill1d("pullz"+suffix, r.z()/er.z());  
1125 >  h_others->Fill1d("errPVx"+suffix, er.x());
1126 >  h_others->Fill1d("errPVy"+suffix, er.y());
1127 >  h_others->Fill1d("errPVz"+suffix, er.z());
1128   }
1129  
1130   PVStudy::PVAnaInfo PVStudy::GetPVAnaInfo(int ntk, int datamode) {
# Line 1236 | Line 1144 | PVStudy::PVAnaInfo PVStudy::GetPVAnaInfo
1144      for ( int i = 0; i < 6; ++i) {
1145        switch (i) {
1146        case 0:
1147 <        fit(h["deltax"+suffix], fpar);
1147 >        if (!h_others->ReadHisto1D("deltax"+suffix)) break;
1148 >        fit(h_others->ReadHisto1D("deltax"+suffix), fpar);
1149          data[i] = fpar[0]*cm2um;
1150          break;
1151        case 1:
1152 <        fit(h["deltay"+suffix], fpar);
1152 >        if (!h_others->ReadHisto1D("deltay"+suffix)) break;
1153 >        fit(h_others->ReadHisto1D("deltay"+suffix), fpar);
1154          data[i] = fpar[0]*cm2um;
1155          break;
1156        case 2:
1157 <        fit(h["deltaz"+suffix], fpar);
1157 >        if (!h_others->ReadHisto1D("deltaz"+suffix)) break;
1158 >        fit(h_others->ReadHisto1D("deltaz"+suffix), fpar);
1159          data[i] = fpar[0]*cm2um;
1160          break;
1161        case 3:
1162 <        fit(h["pullx"+suffix], fpar);
1162 >        if (!h_others->ReadHisto1D("pullx"+suffix)) break;
1163 >        fit(h_others->ReadHisto1D("pullx"+suffix), fpar);
1164          data[i] = fpar[0];
1165          break;
1166        case 4:
1167 <        fit(h["pully"+suffix], fpar);
1167 >        if (!h_others->ReadHisto1D("pully"+suffix)) break;
1168 >        fit(h_others->ReadHisto1D("pully"+suffix), fpar);
1169          data[i] = fpar[0];
1170          break;
1171        case 5:
1172 <        fit(h["pullz"+suffix], fpar);
1172 >        if (!h_others->ReadHisto1D("pullz"+suffix)) break;
1173 >        fit(h_others->ReadHisto1D("pullz"+suffix), fpar);
1174          data[i] = fpar[0];
1175          break;
1176        }
1177 <      if (verbose_ && data[i] > 0) cout << "data[" << i << "] = " << data[i] << (i<3?" micro m":" ") << endl;
1177 >      if (data[i] > 0) edm::LogInfo("Analysis") << "[Analysis] data[" << i << "] = " << data[i] << (i<3?" micro m":" ") << endl;
1178      }
1179    }
1180    else
# Line 1275 | Line 1189 | PVStudy::PVAnaInfo PVStudy::GetPVAnaInfo
1189                              ntk);
1190   }
1191  
1192 < void PVStudy::fit(TH1 *&hdist, double fitPars[]){
1192 > void PVStudy::fit(TH1 *hdist, double fitPars[]){
1193    TAxis *axis0 = hdist->GetXaxis();
1194    int nbin = axis0->GetLast();
1195    double nOF = hdist->GetBinContent(nbin+1);
# Line 1284 | Line 1198 | void PVStudy::fit(TH1 *&hdist, double fi
1198    double fitRange = axis0->GetXmax();
1199    double sigMax[2] = {0.,0.};
1200  
1201 <  if ( verbose_ ){
1202 <    cout << "Last bin = " << nbin;
1203 <    cout << "; hdist: Overflow Entries = " << nOF;
1204 <    cout << "; Underflow Entries = " << nUF;
1205 <    cout << "; hdist->GetEntries() = " << hdist->GetEntries();
1206 <    cout << "; fitting range = " << -fitRange << " to " << fitRange << endl;
1293 <  }
1201 >  edm::LogInfo("Analysis") << "[Fit] Last bin = " << nbin
1202 >                           << "; hdist: Overflow Entries = " << nOF
1203 >                           << "; Underflow Entries = " << nUF
1204 >                           << "; hdist->GetEntries() = " << hdist->GetEntries()
1205 >                           << "; fitting range = " << -fitRange << " to " << fitRange << endl;
1206 >
1207    if (hdist->GetEntries() - nOF - nUF >= 10) { // FIXME: for reasonable Gaussian fit
1208      for (int bi = 0; bi < nbin; bi++) {
1209        if ( (axis0->GetBinLowEdge(bi) < 0) && (hdist->GetBinContent(bi) > 0) ) {
# Line 1302 | Line 1215 | void PVStudy::fit(TH1 *&hdist, double fi
1215          if ( abs(sigMax[0]) > abs(sigMax[1]) ) sigMax[1] = abs(sigMax[0]);
1216        }
1217      }
1218 <    if (verbose_) cout << "Fit sigMax = " << sqrt(2.)*sigMax[1] << endl;
1218 >    //edm::LogInfo("Analysis") << "[Fit] Fit sigMax = " << sqrt(2.)*sigMax[1] << endl;
1219  
1220      TF1 *fgaus = new TF1("fgaus","gaus",-fitRange, fitRange);
1221      fgaus->SetParameter(1, 0.);
# Line 1315 | Line 1228 | void PVStudy::fit(TH1 *&hdist, double fi
1228      s->SetOptStat(1111111);
1229      s->SetOptFit(0111);
1230      gPad->Update();
1231 <    if (verbose_) cout << "got function" << endl;
1231 >    //edm::LogInfo("Analysis") << "[Fit] got function" << endl;
1232      fitPars[0] = ((fgaus->GetParameter(2))?fgaus->GetParameter(2):-999);
1233    }
1234    else
# Line 1328 | Line 1241 | void PVStudy::fillTrackHisto(const reco:
1241    if(datatype == 1) suffix = "1_spl"; // for splittracks 1
1242    if(datatype == 2) suffix = "2_spl"; // for splittracks 2
1243    
1244 <  h["nTrk"+suffix]->Fill(trackColl->size());
1244 >  h_pvtrk->Fill1d("nTrk"+suffix, trackColl->size());
1245    for(reco::TrackCollection::const_iterator itTrack = trackColl->begin();
1246        itTrack != trackColl->end();                      
1247        ++itTrack) {
1248 <    h["trkPt"+suffix]->Fill(itTrack->pt());
1249 <    h["trkDxy"+suffix]->Fill(itTrack->dxy());
1250 <    h["trkDz"+suffix]->Fill(itTrack->dz());
1251 <    h["trkEta"+suffix]->Fill(itTrack->eta());
1252 <    h["trkPhi"+suffix]->Fill(itTrack->phi());
1248 >    h_pvtrk->Fill1d("trkPt"+suffix, itTrack->pt());
1249 >    h_pvtrk->Fill1d("trkDxy"+suffix, itTrack->dxy());
1250 >    h_pvtrk->Fill1d("trkDz"+suffix, itTrack->dz());
1251 >    h_pvtrk->Fill1d("trkEta"+suffix, itTrack->eta());
1252 >    h_pvtrk->Fill1d("trkPhi"+suffix, itTrack->phi());
1253    }
1254   }
1255  
# Line 1360 | Line 1273 | void PVStudy::fillTrackHistoInPV(const r
1273          recx_err_[ivtx] = v->xError();
1274          recy_err_[ivtx] = v->yError();
1275          recz_err_[ivtx] = v->zError();
1363
1364        
1276        }
1277        if(datatype == 1) {
1278          nTrkPV1_spl_[ivtx] = v->tracksSize();  
# Line 1404 | Line 1315 | void PVStudy::fillTrackHistoInPV(const r
1315    }
1316    // For histogram only fill the leading pvtx parameters
1317    if(fillHisto) {
1318 <    h["nTrkPV"+suffix]->Fill(vertexColl->begin()->tracksSize());
1318 >    h_pvtrk->Fill1d("nTrkPV"+suffix, vertexColl->begin()->tracksSize());
1319      try {
1320        for(reco::Vertex::trackRef_iterator t = vertexColl->begin()->tracks_begin();
1321            t!=vertexColl->begin()->tracks_end(); t++) {
1322          // illegal charge
1323          if ( (**t).charge() < -1 || (**t).charge() > 1 ) {
1324 <          //      h["trkPtPV"]->Fill(0.);
1324 >          //      h_pvtrk->Fill1d("trkPtPV", 0.);
1325          }
1326          else {
1327 <          h["trkPtPV"+suffix]->Fill((**t).pt());
1328 <          h["trkDxyPV"+suffix]->Fill((**t).dxy());
1329 <          h["trkDzPV"+suffix]->Fill((**t).dz());
1330 <          h["trkEtaPV"+suffix]->Fill((**t).eta());
1331 <          h["trkPhiPV"+suffix]->Fill((**t).phi());
1327 >          h_pvtrk->Fill1d("trkPtPV"+suffix, (**t).pt());
1328 >          h_pvtrk->Fill1d("trkDxyPV"+suffix, (**t).dxy());
1329 >          h_pvtrk->Fill1d("trkDzPV"+suffix, (**t).dz());
1330 >          h_pvtrk->Fill1d("trkEtaPV"+suffix, (**t).eta());
1331 >          h_pvtrk->Fill1d("trkPhiPV"+suffix, (**t).phi());
1332          }
1333        }
1334      }
1335      catch (...) {
1336        // exception thrown when trying to use linked track
1337 <      //          h["trkPtPV"]->Fill(0.);
1337 >      //          h_pvtrk->Fill1d("trkPtPV", 0.);
1338      }
1339    }
1340    
# Line 1455 | Line 1366 | void PVStudy::fillMCHisto(std::vector<si
1366      int nrectrk = vrec->tracksSize();
1367      vsim->recVtx=NULL;  
1368    
1369 <    if(verbose_){
1370 <      cout << "sim primary vertex x = " << vsim->x << "; y = " << vsim->y << "; z = " << vsim->z <<  endl;
1371 <      cout << "Is matched? " << (matchVertex(*vsim,*vrec)?"Yes":"No") << endl;
1372 <    }
1462 <    if ( matchVertex(*vsim,*vrec) ) {
1369 >    edm::LogInfo("Debug") << "[fillMCHisto] sim primary vertex x = " << vsim->x << "; y = " << vsim->y << "; z = " << vsim->z <<  endl;
1370 >    edm::LogInfo("Debug") << "[fillMCHisto] Is matched? " << (matchVertex(*vsim,*vrec)?"Yes":"No") << endl;
1371 >
1372 >    if ( matchVertex(*vsim,*vrec) && vrec->isValid() && !vrec->isFake() ) {
1373        vsim->recVtx=&(*vrec);
1374        
1375        // if the matching critera are fulfilled, accept the rec-vertex that is closest in z
# Line 1467 | Line 1377 | void PVStudy::fillMCHisto(std::vector<si
1377        //|| (!vsim->recVtx) )
1378        //vsim->recVtx=&(*vrec);
1379        //}
1380 <      if(verbose_)
1471 <        cout <<"primary matched in vertexColl" << vsim->x << " " << vsim->y << " " << vsim->z <<  endl;
1380 >      edm::LogInfo("Debug") <<"[fillMCHisto] primary matched in vertexColl" << vsim->x << " " << vsim->y << " " << vsim->z <<  endl;
1381        
1382        double fres_mct[3];
1383        double ferror_mct[3];
# Line 1480 | Line 1389 | void PVStudy::fillMCHisto(std::vector<si
1389        ferror_mct[1] = vsim->recVtx->yError();
1390        ferror_mct[2] = vsim->recVtx->zError();
1391        
1392 <      h["deltax"+suffix]->Fill( fres_mct[0] );
1393 <      h["deltay"+suffix]->Fill( fres_mct[1] );
1394 <      h["deltaz"+suffix]->Fill( fres_mct[2] );
1395 <      h["pullx"+suffix]->Fill( fres_mct[0]/ferror_mct[0] );
1396 <      h["pully"+suffix]->Fill( fres_mct[1]/ferror_mct[1] );
1397 <      h["pullz"+suffix]->Fill( fres_mct[2]/ferror_mct[2] );
1398 <      h["errPVx"+suffix]->Fill( ferror_mct[0] );
1399 <      h["errPVy"+suffix]->Fill( ferror_mct[1] );
1400 <      h["errPVz"+suffix]->Fill( ferror_mct[2] );
1392 >      h_summary->Fill1d("deltax"+suffix, fres_mct[0] );
1393 >      h_summary->Fill1d("deltay"+suffix, fres_mct[1] );
1394 >      h_summary->Fill1d("deltaz"+suffix, fres_mct[2] );
1395 >      h_summary->Fill1d("pullx"+suffix, fres_mct[0]/ferror_mct[0] );
1396 >      h_summary->Fill1d("pully"+suffix, fres_mct[1]/ferror_mct[1] );
1397 >      h_summary->Fill1d("pullz"+suffix, fres_mct[2]/ferror_mct[2] );
1398 >      h_summary->Fill1d("errPVx"+suffix, ferror_mct[0] );
1399 >      h_summary->Fill1d("errPVy"+suffix, ferror_mct[1] );
1400 >      h_summary->Fill1d("errPVz"+suffix, ferror_mct[2] );
1401        pvinfo.push_back(PVStudy::PVInfo(res(fres_mct[0], fres_mct[1], fres_mct[2]),
1402                                         error(ferror_mct[0], ferror_mct[1], ferror_mct[2]),
1403                                         nrectrk));
# Line 1533 | Line 1442 | void PVStudy::fillMCHisto(std::vector<si
1442        } // End of  if(saventuple_) {
1443      } //  if ( matchVertex(*vsim,*vrec) ) {
1444      else {  // no rec vertex found for this simvertex
1445 <      if(verbose_)
1537 <        cout <<"primary not found " << vsim->x << " " << vsim->y << " " << vsim->z << " nGenTrk=" << vsim->nGenTrk << endl;
1445 >      edm::LogInfo("Debug") <<"[fillMCHisto] primary not found " << vsim->x << " " << vsim->y << " " << vsim->z << " nGenTrk=" << vsim->nGenTrk << endl;
1446      }
1447    }
1448   }
# Line 1545 | Line 1453 | void PVStudy::SetVarToZero() {
1453    fntrk_ = 0;
1454    //pvtx position (x,y,z) residual and error
1455    for(int i = 0; i<3;i++)    {
1456 <      fres_[i] = 0;
1457 <      ferror_[i] = 0;
1456 >    fres_[i] = 0;
1457 >    ferror_[i] = 0;
1458    }
1459    
1460    //Yanyan's variables

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines