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.1 by jengbou, Thu Sep 3 17:31:08 2009 UTC vs.
Revision 1.2 by jengbou, Thu Sep 3 19:29:38 2009 UTC

# Line 66 | Line 66 | PVStudy::PVStudy(const edm::ParameterSet
66    vtxSample_       = iConfig.getUntrackedParameter<edm::InputTag>("vtxSample");
67    verbose_         = iConfig.getUntrackedParameter<bool>("verbose", false);
68    realData_        = iConfig.getUntrackedParameter<bool>("realData",false);
69 +  analyze_         = iConfig.getUntrackedParameter<bool>("analyzeOnTheFly",false);
70  
71    //now do what ever initialization is needed
72    pvanainfo.clear();
# Line 86 | Line 87 | PVStudy::PVStudy(const edm::ParameterSet
87      h_pullx        = fs->make<TH1D>("pullx","x-pull (Rec - Sim)",1000,-25.,25.);
88      h_pully        = fs->make<TH1D>("pully","y-pull (Rec - Sim)",1000,-25.,25.);
89      h_pullz        = fs->make<TH1D>("pullz","z-pull (Rec - Sim)",1000,-25.,25.);
89    // Summary of analysis:
90    h_resx_nTrk    = fs->make<TH2D>("resx_ntrk","x-resolution (Rec - Sim) vs number of tracks",150,0,150,400,0.,200);
91    h_resx_nTrk->SetMarkerStyle(21);
92    h_resx_nTrk->GetYaxis()->SetTitle("#mum");
93    h_resy_nTrk    = fs->make<TH2D>("resy_ntrk","y-resolution (Rec - Sim) vs number of tracks",150,0,150,400,0.,200);
94    h_resy_nTrk->SetMarkerStyle(21);
95    h_resy_nTrk->GetYaxis()->SetTitle("#mum");
96    h_resz_nTrk    = fs->make<TH2D>("resz_ntrk","z-resolution (Rec - Sim) vs number of tracks",150,0,150,400,0.,200);
97    h_resz_nTrk->SetMarkerStyle(21);
98    h_resz_nTrk->GetYaxis()->SetTitle("#mum");
99    h_pullx_nTrk   = fs->make<TH2D>("pullx_ntrk","x-pull (Rec - Sim) vs number of tracks",150,0,150,100,0.,2.);
100    h_pullx_nTrk->SetMarkerStyle(21);
101    h_pullx_nTrk->SetBit(TH1::kCanRebin);
102    h_pullx_nTrk->GetYaxis()->SetTitle("cm");
103    h_pully_nTrk   = fs->make<TH2D>("pully_ntrk","y-pull (Rec - Sim) vs number of tracks",150,0,150,100,0.,2.);
104    h_pully_nTrk->SetMarkerStyle(21);
105    h_pully_nTrk->SetBit(TH1::kCanRebin);
106    h_pully_nTrk->GetYaxis()->SetTitle("cm");
107    h_pullz_nTrk   = fs->make<TH2D>("pullz_ntrk","z-pull (Rec - Sim) vs number of tracks",150,0,150,100,0.,2.);
108    h_pullz_nTrk->SetMarkerStyle(21);
109    h_pullz_nTrk->SetBit(TH1::kCanRebin);
110    h_pullz_nTrk->GetYaxis()->SetTitle("cm");
90  
91 +    // Summary of analysis:
92 +    if (analyze_) {
93 +      h_resx_nTrk    = fs->make<TH2D>("resx_ntrk","x-resolution (Rec - Sim) vs number of tracks",150,0,150,400,0.,200);
94 +      h_resx_nTrk->SetMarkerStyle(21);
95 +      h_resx_nTrk->GetYaxis()->SetTitle("#mum");
96 +      h_resy_nTrk    = fs->make<TH2D>("resy_ntrk","y-resolution (Rec - Sim) vs number of tracks",150,0,150,400,0.,200);
97 +      h_resy_nTrk->SetMarkerStyle(21);
98 +      h_resy_nTrk->GetYaxis()->SetTitle("#mum");
99 +      h_resz_nTrk    = fs->make<TH2D>("resz_ntrk","z-resolution (Rec - Sim) vs number of tracks",150,0,150,400,0.,200);
100 +      h_resz_nTrk->SetMarkerStyle(21);
101 +      h_resz_nTrk->GetYaxis()->SetTitle("#mum");
102 +      h_pullx_nTrk   = fs->make<TH2D>("pullx_ntrk","x-pull (Rec - Sim) vs number of tracks",150,0,150,100,0.,2.);
103 +      h_pullx_nTrk->SetMarkerStyle(21);
104 +      h_pullx_nTrk->SetBit(TH1::kCanRebin);
105 +      h_pullx_nTrk->GetYaxis()->SetTitle("cm");
106 +      h_pully_nTrk   = fs->make<TH2D>("pully_ntrk","y-pull (Rec - Sim) vs number of tracks",150,0,150,100,0.,2.);
107 +      h_pully_nTrk->SetMarkerStyle(21);
108 +      h_pully_nTrk->SetBit(TH1::kCanRebin);
109 +      h_pully_nTrk->GetYaxis()->SetTitle("cm");
110 +      h_pullz_nTrk   = fs->make<TH2D>("pullz_ntrk","z-pull (Rec - Sim) vs number of tracks",150,0,150,100,0.,2.);
111 +      h_pullz_nTrk->SetMarkerStyle(21);
112 +      h_pullz_nTrk->SetBit(TH1::kCanRebin);
113 +      h_pullz_nTrk->GetYaxis()->SetTitle("cm");
114 +    }
115      for (int ntrk=nTrkMin_;ntrk<=nTrkMax_;++ntrk) {
116        stringstream ss;
117        ss << ntrk;
# Line 452 | Line 455 | PVStudy::endJob() {
455      for (int ntrk=nTrkMin_;ntrk<=nTrkMax_;++ntrk) {
456        if (verbose_) cout << "Fill point of ntrk = " << ntrk << endl;
457        PVStudy::PVAnaInfo ipv = GetPVAnaInfo(ntrk);
458 <      if ( ipv.resx > 0 ) h_resx_nTrk->Fill(ntrk,ipv.resx/sqt2, 1.);
459 <      if ( ipv.resy > 0 ) h_resy_nTrk->Fill(ntrk,ipv.resy/sqt2, 1.);
460 <      if ( ipv.resz > 0 ) h_resz_nTrk->Fill(ntrk,ipv.resz/sqt2, 1.);
461 <      if ( ipv.pullx > 0 ) h_pullx_nTrk->Fill(ntrk,ipv.pullx, 1.);
462 <      if ( ipv.pully > 0 ) h_pully_nTrk->Fill(ntrk,ipv.pully, 1.);
463 <      if ( ipv.pullz > 0 ) h_pullz_nTrk->Fill(ntrk,ipv.pullz, 1.);
458 >      if (analyze_) {
459 >        if ( ipv.resx > 0 ) h_resx_nTrk->Fill(ntrk,ipv.resx/sqt2, 1.);
460 >        if ( ipv.resy > 0 ) h_resy_nTrk->Fill(ntrk,ipv.resy/sqt2, 1.);
461 >        if ( ipv.resz > 0 ) h_resz_nTrk->Fill(ntrk,ipv.resz/sqt2, 1.);
462 >        if ( ipv.pullx > 0 ) h_pullx_nTrk->Fill(ntrk,ipv.pullx, 1.);
463 >        if ( ipv.pully > 0 ) h_pully_nTrk->Fill(ntrk,ipv.pully, 1.);
464 >        if ( ipv.pullz > 0 ) h_pullz_nTrk->Fill(ntrk,ipv.pullz, 1.);
465 >      }
466      }
467    }
468   }
# Line 541 | Line 546 | void PVStudy::printSimTrks(const Handle<
546  
547   PVStudy::PVAnaInfo PVStudy::GetPVAnaInfo(int ntk) {
548    map<int,double> data;
549 +  data.clear();
550    double xmin=0.,xmax=0.;
551    double fpar[2];
552    double cm2um = 10000;
# Line 608 | Line 614 | PVStudy::PVAnaInfo PVStudy::GetPVAnaInfo
614          //      }
615        }
616      }
617 <    TAxis *axis0 = hdist->GetXaxis();
618 <    int nbin = axis0->GetLast();
619 <    double nOF = hdist->GetBinContent(nbin+1);
620 <    double nUF = hdist->GetBinContent(0);
621 <    if ( verbose_ && i==0 ){
622 <      cout << "Last bin = " << nbin;
623 <      cout << "; hdist: Overflow Entries = " << nOF;
624 <      cout << "; Underflow Entries = " << nUF;
625 <      cout << "; hdist->GetEntries() = " << hdist->GetEntries() << endl;
626 <    }
627 <    if (hdist->GetEntries() - nOF - nUF >= 5) { // FIXME: for reasonable Gaussian fit
628 <      if(i<3){
629 <        hdist->Fit("gaus","Q0");
630 <        TF1 *fgaus = hdist->GetFunction("gaus");
631 <        if (verbose_) cout << "got function" << endl;
632 <        fpar[0] = ((fgaus->GetParameter(1))?fgaus->GetParameter(1):-999);
633 <        fpar[1] = ((fgaus->GetParameter(2))?fgaus->GetParameter(2):-999);
634 <        delete fgaus;
617 >    if(analyze_) {
618 >      TAxis *axis0 = hdist->GetXaxis();
619 >      int nbin = axis0->GetLast();
620 >      double nOF = hdist->GetBinContent(nbin+1);
621 >      double nUF = hdist->GetBinContent(0);
622 >      if ( verbose_ && i==0 ){
623 >        cout << "Last bin = " << nbin;
624 >        cout << "; hdist: Overflow Entries = " << nOF;
625 >        cout << "; Underflow Entries = " << nUF;
626 >        cout << "; hdist->GetEntries() = " << hdist->GetEntries() << endl;
627 >      }
628 >      if (hdist->GetEntries() - nOF - nUF >= 5) { // FIXME: for reasonable Gaussian fit
629 >        if(i<3){
630 >          hdist->Fit("gaus","Q0");
631 >          TF1 *fgaus = hdist->GetFunction("gaus");
632 >          if (verbose_) cout << "got function" << endl;
633 >          fpar[0] = ((fgaus->GetParameter(1))?fgaus->GetParameter(1):-999);
634 >          fpar[1] = ((fgaus->GetParameter(2))?fgaus->GetParameter(2):-999);
635 >          delete fgaus;
636 >        }
637 >        else {
638 >          hdist->Fit("gausn","Q0");
639 >          TF1 *fgaus = hdist->GetFunction("gausn");
640 >          if (verbose_) cout << "got function" << endl;
641 >          fpar[0] = ((fgaus->GetParameter(1))?fgaus->GetParameter(1):-999);
642 >          fpar[1] = ((fgaus->GetParameter(2))?fgaus->GetParameter(2):-999);
643 >          delete fgaus;
644 >        }
645 >        if (verbose_) cout << "fpar[2] = (" << fpar[0] << "," << fpar[1] << ")" << endl;
646 >        switch (i) {
647 >        case 0:
648 >          h["resx_"+suffix]->Fit("gaus","Q");
649 >          data[i] = fpar[1]*cm2um;
650 >          break;
651 >        case 1:
652 >          h["resy_"+suffix]->Fit("gaus","Q");
653 >          data[i] = fpar[1]*cm2um;
654 >          break;
655 >        case 2:
656 >          h["resz_"+suffix]->Fit("gaus","Q");
657 >          data[i] = fpar[1]*cm2um;
658 >          break;
659 >        case 3:
660 >          h["pullx_"+suffix]->Fit("gausn","Q");
661 >          data[i] = fpar[1];
662 >          break;
663 >        case 4:
664 >          h["pully_"+suffix]->Fit("gausn","Q");
665 >          data[i] = fpar[1];
666 >          break;
667 >        case 5:
668 >          h["pullz_"+suffix]->Fit("gausn","Q");
669 >          data[i] = fpar[1];
670 >          break;
671 >        }
672 >        if (verbose_ && data[i] > 0) cout << "data[" << i << "] = " << data[i] << (i<3?" micro m":" cm") << endl;
673        }
674        else {
675 <        hdist->Fit("gausn","Q0");
676 <        TF1 *fgaus = hdist->GetFunction("gausn");
633 <        if (verbose_) cout << "got function" << endl;
634 <        fpar[0] = ((fgaus->GetParameter(1))?fgaus->GetParameter(1):-999);
635 <        fpar[1] = ((fgaus->GetParameter(2))?fgaus->GetParameter(2):-999);
636 <        delete fgaus;
637 <      }
638 <      if (verbose_) cout << "fpar[2] = (" << fpar[0] << "," << fpar[1] << ")" << endl;
639 <      switch (i) {
640 <      case 0:
641 <        h["resx_"+suffix]->Fit("gaus","Q");
642 <        data[i] = fpar[1]*cm2um;
643 <        break;
644 <      case 1:
645 <        h["resy_"+suffix]->Fit("gaus","Q");
646 <        data[i] = fpar[1]*cm2um;
647 <        break;
648 <      case 2:
649 <        h["resz_"+suffix]->Fit("gaus","Q");
650 <        data[i] = fpar[1]*cm2um;
651 <        break;
652 <      case 3:
653 <        h["pullx_"+suffix]->Fit("gausn","Q");
654 <        data[i] = fpar[1];
655 <        break;
656 <      case 4:
657 <        h["pully_"+suffix]->Fit("gausn","Q");
658 <        data[i] = fpar[1];
659 <        break;
660 <      case 5:
661 <        h["pullz_"+suffix]->Fit("gausn","Q");
662 <        data[i] = fpar[1];
663 <        break;
675 >        if ( verbose_) cout << "Empty Histo! No Fit!!!" << endl;
676 >        data[i] = -999;
677        }
665      if (verbose_ && data[i] > 0) cout << "data[" << i << "] = " << data[i] << (i<3?" micro m":" cm") << endl;
678      }
679 <    else {
668 <      if ( verbose_) cout << "Empty Histo! No Fit!!!" << endl;
679 >    else
680        data[i] = -999;
670    }
681      delete hdist;
682    }
683  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines