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.12 by yygao, Fri Nov 27 12:31:05 2009 UTC

# Line 120 | Line 120 | PVStudy::PVStudy(const edm::ParameterSet
120      pvtxtree_->Branch("recx_err",&recx_err_,"recx_err[nrecPV]/D");
121      pvtxtree_->Branch("recy_err",&recy_err_,"recy_err[nrecPV]/D");
122      pvtxtree_->Branch("recz_err",&recz_err_,"recz_err[nrecPV]/D");
123 <    
123 >
124      pvtxtree_->Branch("min_zsep",&min_zsep_,"min_zsep/D");
125      pvtxtree_->Branch("min_ntrksep",&min_ntrksep_,"min_ntrksep/D");
126      pvtxtree_->Branch("min_sumpt2sep",&min_sumpt2sep_,"min_sumpt2sep/D");
# Line 150 | Line 150 | PVStudy::PVStudy(const edm::ParameterSet
150      pvtxtree_->Branch("recx2_err_spl",&recx2_err_spl_,"recx2_err_spl[nrecPV2_spl]/D");
151      pvtxtree_->Branch("recy2_err_spl",&recy2_err_spl_,"recy2_err_spl[nrecPV2_spl]/D");
152      pvtxtree_->Branch("recz2_err_spl",&recz2_err_spl_,"recz2_err_spl[nrecPV2_spl]/D");  
153 <        
153 >    
154 >    //pixeVertices
155 >    pvtxtree_->Branch("nrecPV_pxlpvtx",&nrecPV_pxlpvtx_,"nrecPV_pxlpvtx/I");
156 >    pvtxtree_->Branch("nTrkPV_pxlpvtx",&nTrkPV_pxlpvtx_,"nTrkPV_pxlpvtx[nrecPV_pxlpvtx]/I");    
157 >    pvtxtree_->Branch("sumptsq_pxlpvtx",&sumptsq_pxlpvtx_,"sumptsq_pxlpvtx[nrecPV_pxlpvtx]/D");  
158 >    pvtxtree_->Branch("isValid_pxlpvtx",&isValid_pxlpvtx_,"isValid_pxlpvtx/I");
159 >    pvtxtree_->Branch("isFake_pxlpvtx",&isFake_pxlpvtx_,"isFake_pxlpvtx/I");
160 >    pvtxtree_->Branch("recx_pxlpvtx",&recx_pxlpvtx_,"recx_pxlpvtx[nrecPV_pxlpvtx]/D");
161 >    pvtxtree_->Branch("recy_pxlpvtx",&recy_pxlpvtx_,"recy_pxlpvtx[nrecPV_pxlpvtx]/D");
162 >    pvtxtree_->Branch("recz_pxlpvtx",&recz_pxlpvtx_,"recz_pxlpvtx[nrecPV_pxlpvtx]/D");
163 >    pvtxtree_->Branch("recx_err_pxlpvtx",&recx_err_pxlpvtx_,"recx_err_pxlpvtx[nrecPV_pxlpvtx]/D");
164 >    pvtxtree_->Branch("recy_err_pxlpvtx",&recy_err_pxlpvtx_,"recy_err_pxlpvtx[nrecPV_pxlpvtx]/D");
165 >    pvtxtree_->Branch("recz_err_pxlpvtx",&recz_err_pxlpvtx_,"recz_err_pxlpvtx[nrecPV_pxlpvtx]/D");  
166 >
167      //Fill the variables in the twovtx pair (recvtx1, recvtx2)
168      pvtxtree_->Branch("nrecPV_twovtx",&nrecPV_twovtx_,"nrecPV_twovtx/I");
169      pvtxtree_->Branch("nTrkPV1_spl_twovtx",&nTrkPV1_spl_twovtx_,"nTrkPV1_spl_twovtx[nrecPV_twovtx]/I");
# Line 304 | Line 317 | PVStudy::PVStudy(const edm::ParameterSet
317      
318      // Book residual and pull histograms only when analyzeOntheFly is enabled
319      if(analyze_) {
320 <      h2["resx"+suffix+"_nTrk"]= subDir.make<TH2D>(TString("resx"+suffix+"_nTrk"), TString("x-resolution vs number of tracks in pvtx"+suffix),150,0,150,400,0.,200);
320 >      h2["resx"+suffix+"_nTrk"]= subDir.make<TH2D>(TString("resx"+suffix+"_nTrk"), TString("x-resolution vs number of tracks in pvtx"+suffix),nTrkMax_-nTrkMin_,nTrkMin_-0.5,nTrkMax_-0.5,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);
325 >      h2["resy"+suffix+"_nTrk"]= subDir.make<TH2D>(TString("resy"+suffix+"_nTrk"), TString("y-resolution vs number of tracks in pvtx"+suffix),nTrkMax_-nTrkMin_,nTrkMin_-0.5,nTrkMax_-0.5,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);
330 >      h2["resz"+suffix+"_nTrk"]= subDir.make<TH2D>(TString("resz"+suffix+"_nTrk"), TString("z-resolution vs number of tracks in pvtx"+suffix),nTrkMax_-nTrkMin_,nTrkMin_-0.5,nTrkMax_-0.5,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.);
335 >      h2["pullx"+suffix+"_nTrk"]= subDir.make<TH2D>(TString("pullx"+suffix+"_nTrk"), TString("x-pull vs number of tracks"+suffix),nTrkMax_-nTrkMin_,nTrkMin_-0.5,nTrkMax_-0.5,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.);
340 >      h2["pully"+suffix+"_nTrk"]= subDir.make<TH2D>(TString("pully"+suffix+"_nTrk"), TString("y-pull vs number of tracks"+suffix),nTrkMax_-nTrkMin_,nTrkMin_-0.5,nTrkMax_-0.5,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.);
345 >      h2["pullz"+suffix+"_nTrk"]= subDir.make<TH2D>(TString("pullz"+suffix+"_nTrk"), TString("z-pull vs number of tracks"+suffix),nTrkMax_-nTrkMin_,nTrkMin_-0.5,nTrkMax_-0.5,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);
# Line 340 | Line 353 | PVStudy::PVStudy(const edm::ParameterSet
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);
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 <
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);
366 >
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);
# Line 705 | Line 723 | PVStudy::analyze(const edm::Event& iEven
723    //=======================================================
724    // Fill pixelVertices related histograms
725    //=======================================================
726 +  nrecPV_pxlpvtx_ = int (pixelVertexColl->size());
727    if(pixelVertexColl->size()>0 && pixelVertexColl->begin()->isValid() && !(pixelVertexColl->begin()->isFake())) {
728 +    //fillTrackHistoInPV(const reco::VertexCollection *vertexColl, int datatype, bool fillHisto, bool fillNtuple) {
729 +    fillTrackHistoInPV(pixelVertexColl, 4, false, true);
730      h["dzErr_pxlpvtx"]->Fill( pixelVertexColl->begin()->zError());    
731      // Get the dZ error of the tracks in the leading pixelVertexColl
732      for(reco::Vertex::trackRef_iterator t = (pixelVertexColl->begin())->tracks_begin();
# Line 734 | Line 755 | PVStudy::analyze(const edm::Event& iEven
755        }
756      }
757    }
737  
758  
759    //=======================================================
760 <  // Fill number of reconstructed vertices ootb
760 >  // Fill number of reconstructed vertices
761    //=======================================================
762  
763    if(verbose_)  {
# Line 758 | Line 778 | PVStudy::analyze(const edm::Event& iEven
778    h["nrecPV1_spl"]->Fill(nrecPV1_spl_);
779    h["nrecPV2_spl"]->Fill(nrecPV2_spl_);
780    h["nrecPVDiff"]->Fill(double(nrecPV1_spl_)-double(nrecPV2_spl_));
781 <
781 >  
782    //=================================================================
783    // Fill track parameter ntuple/hist for tracks used in recoVertices
784    //=================================================================
# Line 773 | Line 793 | PVStudy::analyze(const edm::Event& iEven
793    if(splitVertexColl1->size() > 0 && splitVertexColl2->begin()->isValid() && !(splitVertexColl2->begin()->isFake()))
794      fillTrackHistoInPV(splitVertexColl2, 2, false, true);
795  
796 +
797 +  //=======================================================
798 +  // Compare offlinePrimaryVertices with pixelVertices
799 +  //=======================================================
800 +  if( (pixelVertexColl->size()>0 && pixelVertexColl->begin()->isValid() && !(pixelVertexColl->begin()->isFake()))
801 +      && (vertexColl->size()>0 && vertexColl->begin()->isValid() && !(vertexColl->begin()->isFake())) ) {    
802 +    h["nrecPV_minus_nrecPxlPV"]->Fill( double (nrecPV_ - nrecPV_pxlpvtx_));
803 +    // difference in reconstructed position of the leading pvtx
804 +    //cout<<"recx_[0] = "<< recx_[0] << "recx_pxlpvtx_[0] = "<< recx_pxlpvtx_[0]<<endl;  
805 +    //cout<<"recy_[0] = "<< recy_[0] << "recy_pxlpvtx_[0] = "<< recy_pxlpvtx_[0]<<endl;
806 +    h["recxPV_minus_recxPxlPV"]->Fill (recx_[0] - recx_pxlpvtx_[0]);
807 +    h["recyPV_minus_recyPxlPV"]->Fill (recy_[0] - recy_pxlpvtx_[0]);
808 +    h["reczPV_minus_reczPxlPV"]->Fill (recz_[0] - recz_pxlpvtx_[0]);
809 +  }
810 +  
811 +
812 +
813    //==========================================================
814    // Fill secondary/primary min separations for multi-vertices
815    //==========================================================
# Line 1053 | Line 1090 | PVStudy::endJob() {
1090          if ( ipv.res_.z() > 0 ) h2["resz"+suffix+"_nTrk"]->Fill(ntrk,ipv.res_.z(), 1.);
1091          if ( ipv.pull_.x() > 0 ) h2["pullx"+suffix+"_nTrk"]->Fill(ntrk,ipv.pull_.x(), 1.);
1092          if ( ipv.pull_.y() > 0 ) h2["pully"+suffix+"_nTrk"]->Fill(ntrk,ipv.pull_.y(), 1.);
1093 <        if ( ipv.pull_.z() > 0 ) h2["pullz"+suffix+"_nTrk"]->Fill(ntrk,ipv.pull_.z(), 1.);
1093 >        if ( ipv.pull_.z() > 0 ) h2["pullz"+suffix+"_nTrk"]->Fill(ntrk,ipv.pull_.z());//, 1.);
1094        }
1095      }
1096      suffix.clear();
# Line 1351 | Line 1388 | void PVStudy::fillTrackHistoInPV(const r
1388          recy2_err_spl_[ivtx] = v->yError();
1389          recz2_err_spl_[ivtx] = v->zError();
1390        }
1391 +      if(datatype == 4) { // for pixelVertices
1392 +        nTrkPV_pxlpvtx_[ivtx] = v->tracksSize();        
1393 +        sumptsq_pxlpvtx_[ivtx] = sumPtSquared(*v);      
1394 +        isValid_pxlpvtx_[ivtx] = v->isValid();
1395 +        isFake_pxlpvtx_[ivtx] = v->isFake();
1396 +        recx_pxlpvtx_[ivtx] = v->x();
1397 +        recy_pxlpvtx_[ivtx] = v->y();
1398 +        recz_pxlpvtx_[ivtx] = v->z();
1399 +        recx_err_pxlpvtx_[ivtx] = v->xError();
1400 +        recy_err_pxlpvtx_[ivtx] = v->yError();
1401 +        recz_err_pxlpvtx_[ivtx] = v->zError();
1402 +      }
1403      }
1404    }
1405    // For histogram only fill the leading pvtx parameters
# Line 1410 | Line 1459 | void PVStudy::fillMCHisto(std::vector<si
1459        cout << "sim primary vertex x = " << vsim->x << "; y = " << vsim->y << "; z = " << vsim->z <<  endl;
1460        cout << "Is matched? " << (matchVertex(*vsim,*vrec)?"Yes":"No") << endl;
1461      }
1462 <    if ( matchVertex(*vsim,*vrec) ) {
1462 >    if ( matchVertex(*vsim,*vrec) && vrec->isValid() && !vrec->isFake() ) {
1463        vsim->recVtx=&(*vrec);
1464        
1465        // if the matching critera are fulfilled, accept the rec-vertex that is closest in z
# Line 1531 | Line 1580 | void PVStudy::SetVarToZero() {
1580      recy_err_[i] = 0;
1581      recz_err_[i] = 0;
1582      
1534    
1535
1583      // recoVertices with splitTrack1
1584      nTrkPV1_spl_[i] = 0; // Number of tracks in the pvtx    
1585      sumptsq1_spl_[i] = 0;
# Line 1545 | Line 1592 | void PVStudy::SetVarToZero() {
1592      recy1_err_spl_[i] = 0;
1593      recz1_err_spl_[i] = 0;
1594    
1548    
1595      // recoVertices with splitTrack2
1596      nTrkPV2_spl_[i] = 0; // Number of tracks in the pvtx  
1597      sumptsq2_spl_[i] = 0;
# Line 1558 | Line 1604 | void PVStudy::SetVarToZero() {
1604      recy2_err_spl_[i] = 0;
1605      recz2_err_spl_[i] = 0;
1606      
1607 +    //pixelVertices
1608 +    nTrkPV_pxlpvtx_[i] = 0; // Number of tracks in the pvtx  
1609 +    sumptsq_pxlpvtx_[i] = 0;
1610 +    isValid_pxlpvtx_[i] = -1;
1611 +    isFake_pxlpvtx_[i] = -1;
1612 +    recx_pxlpvtx_[i] = 0;
1613 +    recy_pxlpvtx_[i] = 0;
1614 +    recz_pxlpvtx_[i] = 0;
1615 +    recx_err_pxlpvtx_[i] = 0;
1616 +    recy_err_pxlpvtx_[i] = 0;
1617 +    recz_err_pxlpvtx_[i] = 0;
1618 +
1619      // matched two-vertices
1620      nTrkPV1_spl_twovtx_[i] = 0;
1621      nTrkPV2_spl_twovtx_[i] = 0;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines