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.3 by jengbou, Tue Sep 8 07:15:38 2009 UTC vs.
Revision 1.5 by jengbou, Wed Sep 9 05:56:50 2009 UTC

# Line 50 | Line 50 | Implementation:
50   #include <SimDataFormats/Track/interface/SimTrackContainer.h>
51  
52   //root
53 < #include "TROOT.h"
54 < #include "TF1.h"
55 < #include "TString.h"
56 < #include "TStyle.h"
57 <
53 > #include <TROOT.h>
54 > #include <TF1.h>
55 > #include <TString.h>
56 > #include <TStyle.h>
57 > #include <TPaveStats.h>
58 > #include <TPad.h>
59  
60   using namespace std;
61  
# Line 80 | Line 81 | PVStudy::PVStudy(const edm::ParameterSet
81    ftree_->Branch("nTrk",&fntrk,"fntrk/I");
82    
83    edm::Service<TFileService> fs;
84 < //   TFileDirectory subDir = fs->mkdir( "Summary" );
85 < //   TFileDirectory subSubDir = subDir.mkdir( "mySubSubDirectory" );
86 <
87 <  h_nTrk           = fs->make<TH1F>("nTrk","Num of total tracks",300,0,300);
88 <  h_nTrkPV         = fs->make<TH1F>("nTrkPV","Num of Tracks from PV",300,0,300);
89 <  h_trkPt          = fs->make<TH1D>("trkPt","Pt of all tracks",100,0,100);
90 <  h_trkPtPV        = fs->make<TH1D>("trkPtPV","Pt dist of tracks from PV",100,0,100);
84 >  TFileDirectory subDir = fs->mkdir( "Summary" );
85 >  TFileDirectory subDir1 = fs->mkdir( "Others" );
86 >  //   TFileDirectory subSubDir = subDir.mkdir( "mySubSubDirectory" );
87 >
88 >  setRootStyle();
89 >
90 >  h["nTrk"]           = subDir.make<TH1F>("nTrk","Num of total tracks",300,0,300);
91 >  h["nTrkPV"]         = subDir.make<TH1F>("nTrkPV","Num of Tracks from PV",300,0,300);
92 >  h["trkPt"]          = subDir.make<TH1D>("trkPt","Pt of all tracks",100,0,100);
93 >  h["trkPtPV"]        = subDir.make<TH1D>("trkPtPV","Pt dist of tracks from PV",100,0,100);
94  
95    if (!realData_) {
96 <    h_deltax       = fs->make<TH1D>("deltax","x-distance (Rec - Sim)",800,-0.04,0.04);
97 <    h_deltay       = fs->make<TH1D>("deltay","y-distance (Rec - Sim)",800,-0.04,0.04);
98 <    h_deltaz       = fs->make<TH1D>("deltaz","z-distance (Rec - Sim)",800,-0.04,0.04);
99 <    h_pullx        = fs->make<TH1D>("pullx","x-pull (Rec - Sim)",1000,-25.,25.);
100 <    h_pully        = fs->make<TH1D>("pully","y-pull (Rec - Sim)",1000,-25.,25.);
101 <    h_pullz        = fs->make<TH1D>("pullz","z-pull (Rec - Sim)",1000,-25.,25.);
96 >    h["deltax"]       = subDir.make<TH1D>("deltax","x-distance (Rec - Sim)",800,-0.04,0.04);
97 >    h["deltay"]       = subDir.make<TH1D>("deltay","y-distance (Rec - Sim)",800,-0.04,0.04);
98 >    h["deltaz"]       = subDir.make<TH1D>("deltaz","z-distance (Rec - Sim)",800,-0.04,0.04);
99 >    h["pullx"]        = subDir.make<TH1D>("pullx","x-pull (Rec - Sim)",1000,-25.,25.);
100 >    h["pully"]        = subDir.make<TH1D>("pully","y-pull (Rec - Sim)",1000,-25.,25.);
101 >    h["pullz"]        = subDir.make<TH1D>("pullz","z-pull (Rec - Sim)",1000,-25.,25.);
102 >    h["errPVx"]       = subDir.make<TH1D>("errPVx","X vertex error",100,0.,0.02);
103 >    h["errPVy"]       = subDir.make<TH1D>("errPVy","Y vertex error",100,0.,0.02);
104 >    h["errPVz"]       = subDir.make<TH1D>("errPVz","Z vertex error",100,0.,0.02);
105  
106      // Summary of analysis:
107      if (analyze_) {
108 <      h_resx_nTrk    = fs->make<TH2D>("resx_ntrk","x-resolution (Rec - Sim) vs number of tracks",150,0,150,400,0.,200);
109 <      h_resx_nTrk->SetMarkerStyle(21);
110 <      h_resx_nTrk->SetMarkerColor(4);
111 <      h_resx_nTrk->GetXaxis()->SetTitle("Num of tracks");
112 <      h_resx_nTrk->GetYaxis()->SetTitle("#mum");
113 <      h_resy_nTrk    = fs->make<TH2D>("resy_ntrk","y-resolution (Rec - Sim) vs number of tracks",150,0,150,400,0.,200);
114 <      h_resy_nTrk->SetMarkerStyle(21);
115 <      h_resy_nTrk->SetMarkerColor(4);
116 <      h_resy_nTrk->GetXaxis()->SetTitle("Num of tracks");
117 <      h_resy_nTrk->GetYaxis()->SetTitle("#mum");
118 <      h_resz_nTrk    = fs->make<TH2D>("resz_ntrk","z-resolution (Rec - Sim) vs number of tracks",150,0,150,400,0.,200);
119 <      h_resz_nTrk->SetMarkerStyle(21);
120 <      h_resz_nTrk->SetMarkerColor(4);
121 <      h_resz_nTrk->GetXaxis()->SetTitle("Num of tracks");
122 <      h_resz_nTrk->GetYaxis()->SetTitle("#mum");
123 <      h_pullx_nTrk   = fs->make<TH2D>("pullx_ntrk","x-pull (Rec - Sim) vs number of tracks",150,0,150,100,0.,2.);
124 <      h_pullx_nTrk->SetMarkerStyle(21);
125 <      h_pullx_nTrk->SetMarkerColor(4);
126 <      h_pullx_nTrk->SetBit(TH1::kCanRebin);
127 <      h_pullx_nTrk->GetXaxis()->SetTitle("Num of tracks");
128 <      h_pully_nTrk   = fs->make<TH2D>("pully_ntrk","y-pull (Rec - Sim) vs number of tracks",150,0,150,100,0.,2.);
129 <      h_pully_nTrk->SetMarkerStyle(21);
130 <      h_pully_nTrk->SetMarkerColor(4);
131 <      h_pully_nTrk->SetBit(TH1::kCanRebin);
132 <      h_pully_nTrk->GetXaxis()->SetTitle("Num of tracks");
133 <      h_pullz_nTrk   = fs->make<TH2D>("pullz_ntrk","z-pull (Rec - Sim) vs number of tracks",150,0,150,100,0.,2.);
134 <      h_pullz_nTrk->SetMarkerStyle(21);
135 <      h_pullz_nTrk->SetMarkerColor(4);
136 <      h_pullz_nTrk->SetBit(TH1::kCanRebin);
137 <      h_pullz_nTrk->GetXaxis()->SetTitle("Num of tracks");
108 >      h2["resx_nTrk"]= subDir.make<TH2D>("resx_ntrk","x-resolution (Rec - Sim) vs number of tracks",150,0,150,400,0.,200);
109 >      h2["resx_nTrk"]->SetMarkerStyle(21);
110 >      h2["resx_nTrk"]->SetMarkerColor(4);
111 >      h2["resx_nTrk"]->GetXaxis()->SetTitle("Num of tracks");
112 >      h2["resx_nTrk"]->GetYaxis()->SetTitle("#mum");
113 >      h2["resy_nTrk"]= subDir.make<TH2D>("resy_ntrk","y-resolution (Rec - Sim) vs number of tracks",150,0,150,400,0.,200);
114 >      h2["resy_nTrk"]->SetMarkerStyle(21);
115 >      h2["resy_nTrk"]->SetMarkerColor(4);
116 >      h2["resy_nTrk"]->GetXaxis()->SetTitle("Num of tracks");
117 >      h2["resy_nTrk"]->GetYaxis()->SetTitle("#mum");
118 >      h2["resz_nTrk"]= subDir.make<TH2D>("resz_ntrk","z-resolution (Rec - Sim) vs number of tracks",150,0,150,400,0.,200);
119 >      h2["resz_nTrk"]->SetMarkerStyle(21);
120 >      h2["resz_nTrk"]->SetMarkerColor(4);
121 >      h2["resz_nTrk"]->GetXaxis()->SetTitle("Num of tracks");
122 >      h2["resz_nTrk"]->GetYaxis()->SetTitle("#mum");
123 >      h2["pullx_nTrk"]= subDir.make<TH2D>("pullx_ntrk","x-pull (Rec - Sim) vs number of tracks",150,0,150,100,0.,2.);
124 >      h2["pullx_nTrk"]->SetMarkerStyle(21);
125 >      h2["pullx_nTrk"]->SetMarkerColor(4);
126 >      h2["pullx_nTrk"]->SetBit(TH1::kCanRebin);
127 >      h2["pullx_nTrk"]->GetXaxis()->SetTitle("Num of tracks");
128 >      h2["pully_nTrk"]= subDir.make<TH2D>("pully_ntrk","y-pull (Rec - Sim) vs number of tracks",150,0,150,100,0.,2.);
129 >      h2["pully_nTrk"]->SetMarkerStyle(21);
130 >      h2["pully_nTrk"]->SetMarkerColor(4);
131 >      h2["pully_nTrk"]->SetBit(TH1::kCanRebin);
132 >      h2["pully_nTrk"]->GetXaxis()->SetTitle("Num of tracks");
133 >      h2["pullz_nTrk"]= subDir.make<TH2D>("pullz_ntrk","z-pull (Rec - Sim) vs number of tracks",150,0,150,100,0.,2.);
134 >      h2["pullz_nTrk"]->SetMarkerStyle(21);
135 >      h2["pullz_nTrk"]->SetMarkerColor(4);
136 >      h2["pullz_nTrk"]->SetBit(TH1::kCanRebin);
137 >      h2["pullz_nTrk"]->GetXaxis()->SetTitle("Num of tracks");
138      }
139      for (int ntrk=nTrkMin_;ntrk<=nTrkMax_;++ntrk) {
140        stringstream ss;
141        ss << ntrk;
142        string suffix = ss.str();
143 <      h["resx_"+suffix]  = fs->make<TH1D> (TString("deltax_"+suffix),"x-distance (Rec - Sim)",100,-0.02,0.02);
143 >      h["resx_"+suffix]  = fs->make<TH1D>(TString("deltax_"+suffix),"x-distance (Rec - Sim)",100,-0.02,0.02);
144        h["resx_"+suffix]->GetXaxis()->SetTitle("cm");
145 <      h["resy_"+suffix]  = fs->make<TH1D> (TString("deltay_"+suffix),"y-distance (Rec - Sim)",100,-0.02,0.02);
145 >      h["resy_"+suffix]  = fs->make<TH1D>(TString("deltay_"+suffix),"y-distance (Rec - Sim)",100,-0.02,0.02);
146        h["resy_"+suffix]->GetXaxis()->SetTitle("cm");
147 <      h["resz_"+suffix]  = fs->make<TH1D> (TString("deltaz_"+suffix),"z-distance (Rec - Sim)",100,-0.02,0.02);
147 >      h["resz_"+suffix]  = fs->make<TH1D>(TString("deltaz_"+suffix),"z-distance (Rec - Sim)",100,-0.02,0.02);
148        h["resz_"+suffix]->GetXaxis()->SetTitle("cm");
149 <      h["pullx_"+suffix] = fs->make<TH1D> (TString("pullx_"+suffix),"x-pull (Rec - Sim)",100,-10.,10.);
150 <      h["pully_"+suffix] = fs->make<TH1D> (TString("pully_"+suffix),"y-pull (Rec - Sim)",100,-10.,10.);
151 <      h["pullz_"+suffix] = fs->make<TH1D> (TString("pullz_"+suffix),"z-pull (Rec - Sim)",100,-10.,10.);
149 >      h["pullx_"+suffix] = fs->make<TH1D>(TString("pullx_"+suffix),"x-pull (Rec - Sim)",100,-10.,10.);
150 >      h["pully_"+suffix] = fs->make<TH1D>(TString("pully_"+suffix),"y-pull (Rec - Sim)",100,-10.,10.);
151 >      h["pullz_"+suffix] = fs->make<TH1D>(TString("pullz_"+suffix),"z-pull (Rec - Sim)",100,-10.,10.);
152 >      h["errPVx_"+suffix]  = subDir1.make<TH1D>(TString("errPVx_"+suffix),"X vertex error",100,0.,0.02);
153 >      h["errPVy_"+suffix]  = subDir1.make<TH1D>(TString("errPVy_"+suffix),"Y vertex error",100,0.,0.02);
154 >      h["errPVz_"+suffix]  = subDir1.make<TH1D>(TString("errPVz_"+suffix),"Z vertex error",100,0.,0.02);
155        suffix.clear();
156      }
157    }
# Line 156 | Line 166 | PVStudy::~PVStudy()
166  
167   }
168  
169 <
169 > void PVStudy::setRootStyle() {
170 >  //
171 >  gROOT->SetStyle("Plain");
172 >  gStyle->SetFillColor(1);
173 >  gStyle->SetOptDate();
174 >  //   gStyle->SetOptStat(1111110);
175 >  //   gStyle->SetOptFit(0111);
176 >  //   gStyle->SetPadTickX(1);
177 >  //   gStyle->SetPadTickY(1);
178 >  gStyle->SetMarkerSize(0.5);
179 >  gStyle->SetMarkerStyle(8);
180 >  gStyle->SetGridStyle(3);
181 >  //gStyle->SetPadGridX(1);
182 >  //gStyle->SetPadGridY(1);
183 >  gStyle->SetPaperSize(TStyle::kA4);
184 >  gStyle->SetStatW(0.25);             // width of statistics box; default is 0.19
185 >  //   gStyle->SetStatH(0.10);             // height of statistics box; default is 0.1
186 >  gStyle->SetStatFormat("6.4g");      // leave default format for now
187 >  gStyle->SetTitleSize(0.055, "");    // size for pad title; default is 0.02
188 >  gStyle->SetLabelSize(0.03, "XYZ");  // size for axis labels; default is 0.04
189 >  gStyle->SetStatFontSize(0.08);      // size for stat. box
190 >  gStyle->SetTitleFont(32, "XYZ");    // times-bold-italic font (p. 153) for axes
191 >  gStyle->SetTitleFont(32, "");       // same for pad title
192 >  gStyle->SetLabelFont(32, "XYZ");    // same for axis labels
193 >  gStyle->SetStatFont(32);            // same for stat. box
194 >  gStyle->SetLabelOffset(0.006, "Y"); // default is 0.005
195 >  //
196 >  return;
197 > }
198   //
199   // member functions
200   //
# Line 403 | Line 441 | PVStudy::analyze(const edm::Event& iEven
441            ferror[1] = vsim->recVtx->yError();
442            ferror[2] = vsim->recVtx->zError();
443            fntrk = nrectrk;
406          ftree_->Fill();
444  
445 <          h_deltax->Fill( vsim->recVtx->x()-vsim->x );
446 <          h_deltay->Fill( vsim->recVtx->y()-vsim->y );
447 <          h_deltaz->Fill( vsim->recVtx->z()-vsim->z );
448 <          h_pullx->Fill( (vsim->recVtx->x()-vsim->x )/vsim->recVtx->xError() );
449 <          h_pully->Fill( (vsim->recVtx->y()-vsim->y )/vsim->recVtx->yError() );
450 <          h_pullz->Fill( (vsim->recVtx->z()-vsim->z )/vsim->recVtx->zError() );
451 <          pvinfo.push_back(PVStudy::PVInfo(res(vsim->recVtx->x()-vsim->x,
452 <                                               vsim->recVtx->y()-vsim->y,
453 <                                               vsim->recVtx->z()-vsim->z),
454 <                                           error(vsim->recVtx->xError(),
455 <                                                 vsim->recVtx->yError(),
419 <                                                 vsim->recVtx->zError()),
445 >          h["deltax"]->Fill( fres[0] );
446 >          h["deltay"]->Fill( fres[1] );
447 >          h["deltaz"]->Fill( fres[2] );
448 >          h["pullx"]->Fill( fres[0]/ferror[0] );
449 >          h["pully"]->Fill( fres[1]/ferror[1] );
450 >          h["pullz"]->Fill( fres[2]/ferror[2] );
451 >          h["errPVx"]->Fill( ferror[0] );
452 >          h["errPVy"]->Fill( ferror[1] );
453 >          h["errPVz"]->Fill( ferror[2] );
454 >          pvinfo.push_back(PVStudy::PVInfo(res(fres[0], fres[1], fres[2]),
455 >                                           error(ferror[0], ferror[1], ferror[2]),
456                                             nrectrk));
457            // Fill histo according to its track multiplicity
458 <          fillHisto(res(vsim->recVtx->x()-vsim->x,
459 <                        vsim->recVtx->y()-vsim->y,
424 <                        vsim->recVtx->z()-vsim->z),
425 <                    pull((vsim->recVtx->x()-vsim->x )/vsim->recVtx->xError(),
426 <                         (vsim->recVtx->y()-vsim->y )/vsim->recVtx->yError(),
427 <                         (vsim->recVtx->z()-vsim->z )/vsim->recVtx->zError()),
458 >          fillHisto(res(fres[0], fres[1], fres[2]),
459 >                    error(ferror[0], ferror[1], ferror[2]),
460                      nrectrk);
461 +
462 +          ftree_->Fill();
463          }
464          else{  // no rec vertex found for this simvertex
465            if(verbose_) {
# Line 444 | Line 478 | PVStudy::analyze(const edm::Event& iEven
478            t!=v->tracks_end(); t++) {
479          // illegal charge
480          if ( (**t).charge() < -1 || (**t).charge() > 1 ) {
481 <          //      h_trkPtPV->Fill(0.);
481 >          //      h["trkPtPV"]->Fill(0.);
482          }
483          else {
484 <          h_trkPtPV->Fill((**t).pt());
484 >          h["trkPtPV"]->Fill((**t).pt());
485          }
486        }
487      }
488      catch (...) {
489        // exception thrown when trying to use linked track
490 <      //          h_trkPtPV->Fill(0.);
490 >      //          h["trkPtPV"]->Fill(0.);
491      }
492      
493 <    h_nTrkPV->Fill(v->tracksSize());
493 >    h["nTrkPV"]->Fill(v->tracksSize());
494      
495    }
496    
497 <  h_nTrk->Fill(tracks->size());
497 >  h["nTrk"]->Fill(tracks->size());
498    
499    for(TrackCollection::const_iterator itTrack = tracks->begin();
500        itTrack != tracks->end();                      
501        ++itTrack) {
502      int charge = 0;
503      charge = itTrack->charge();
504 <    h_trkPt->Fill(itTrack->pt());
504 >    h["trkPt"]->Fill(itTrack->pt());
505    }
506    
507   }
# Line 489 | Line 523 | PVStudy::endJob() {
523        if (verbose_) cout << "Fill point of ntrk = " << ntrk << endl;
524        PVStudy::PVAnaInfo ipv = GetPVAnaInfo(ntrk);
525        if (analyze_) {
526 < //      if ( ipv.res_.x() > 0 ) h_resx_nTrk->Fill(ntrk,ipv.res_.x()/sqt2, 1.);
527 < //      if ( ipv.res_.y() > 0 ) h_resy_nTrk->Fill(ntrk,ipv.res_.y()/sqt2, 1.);
528 < //      if ( ipv.res_.z() > 0 ) h_resz_nTrk->Fill(ntrk,ipv.res_.z()/sqt2, 1.);
529 <        if ( ipv.res_.x() > 0 ) h_resx_nTrk->Fill(ntrk,ipv.res_.x(), 1.);
530 <        if ( ipv.res_.y() > 0 ) h_resy_nTrk->Fill(ntrk,ipv.res_.y(), 1.);
531 <        if ( ipv.res_.z() > 0 ) h_resz_nTrk->Fill(ntrk,ipv.res_.z(), 1.);
532 <        if ( ipv.pull_.x() > 0 ) h_pullx_nTrk->Fill(ntrk,ipv.pull_.x(), 1.);
533 <        if ( ipv.pull_.y() > 0 ) h_pully_nTrk->Fill(ntrk,ipv.pull_.y(), 1.);
534 <        if ( ipv.pull_.z() > 0 ) h_pullz_nTrk->Fill(ntrk,ipv.pull_.z(), 1.);
526 > //      if ( ipv.res_.x() > 0 ) h2["resx_nTrk"]->Fill(ntrk,ipv.res_.x()/sqt2, 1.);
527 > //      if ( ipv.res_.y() > 0 ) h2["resy_nTrk"]->Fill(ntrk,ipv.res_.y()/sqt2, 1.);
528 > //      if ( ipv.res_.z() > 0 ) h2["resz_nTrk"]->Fill(ntrk,ipv.res_.z()/sqt2, 1.);
529 >        if ( ipv.res_.x() > 0 ) h2["resx_nTrk"]->Fill(ntrk,ipv.res_.x(), 1.);
530 >        if ( ipv.res_.y() > 0 ) h2["resy_nTrk"]->Fill(ntrk,ipv.res_.y(), 1.);
531 >        if ( ipv.res_.z() > 0 ) h2["resz_nTrk"]->Fill(ntrk,ipv.res_.z(), 1.);
532 >        if ( ipv.pull_.x() > 0 ) h2["pullx_nTrk"]->Fill(ntrk,ipv.pull_.x(), 1.);
533 >        if ( ipv.pull_.y() > 0 ) h2["pully_nTrk"]->Fill(ntrk,ipv.pull_.y(), 1.);
534 >        if ( ipv.pull_.z() > 0 ) h2["pullz_nTrk"]->Fill(ntrk,ipv.pull_.z(), 1.);
535        }
536      }
537    }
# Line 583 | Line 617 | void PVStudy::printSimTrks(const Handle<
617    }
618   }
619  
620 < void PVStudy::fillHisto(res r, pull p, int ntk){
620 > void PVStudy::fillHisto(res r, error er, int ntk){
621    stringstream ss;
622    ss << ntk;
623    string suffix = ss.str();
# Line 592 | Line 626 | void PVStudy::fillHisto(res r, pull p, i
626    h["resx_"+suffix]->Fill(r.x());
627    h["resy_"+suffix]->Fill(r.y());
628    h["resz_"+suffix]->Fill(r.z());
629 <  h["pullx_"+suffix]->Fill(p.x());
630 <  h["pully_"+suffix]->Fill(p.y());
631 <  h["pullz_"+suffix]->Fill(p.z());
629 >  h["pullx_"+suffix]->Fill(r.x()/er.x());
630 >  h["pully_"+suffix]->Fill(r.y()/er.y());
631 >  h["pullz_"+suffix]->Fill(r.z()/er.z());
632 >  h["errPVx_"+suffix]->Fill(er.x());
633 >  h["errPVy_"+suffix]->Fill(er.y());
634 >  h["errPVz_"+suffix]->Fill(er.z());
635   }
636  
637   PVStudy::PVAnaInfo PVStudy::GetPVAnaInfo(int ntk) {
638    map<int,double> data;
639    data.clear();
640 <  double fpar[2];
640 >  double fpar[2] = {-999,-999};
641    double cm2um = 10000;
642    stringstream ss;
643    ss << ntk;
# Line 608 | Line 645 | PVStudy::PVAnaInfo PVStudy::GetPVAnaInfo
645  
646    if(analyze_) {
647      for ( int i = 0; i < 6; ++i) {
611      cout << "Here" << endl;
648        switch (i) {
649        case 0:
650          fit(h["resx_"+suffix], fpar);
# Line 650 | Line 686 | PVStudy::PVAnaInfo PVStudy::GetPVAnaInfo
686                              ntk);
687   }
688  
689 < void PVStudy::fit(TH1 *&hdist, double data[]){
689 > void PVStudy::fit(TH1 *&hdist, double fitPars[]){
690    TAxis *axis0 = hdist->GetXaxis();
691    int nbin = axis0->GetLast();
692    double nOF = hdist->GetBinContent(nbin+1);
693    double nUF = hdist->GetBinContent(0);
694 +  //   double fitRange = axis0->GetBinUpEdge(nbin);
695 +  double fitRange = axis0->GetXmax();
696 +  double sigMax[2] = {0.,0.};
697 +
698    if ( verbose_ ){
699      cout << "Last bin = " << nbin;
700      cout << "; hdist: Overflow Entries = " << nOF;
701      cout << "; Underflow Entries = " << nUF;
702 <    cout << "; hdist->GetEntries() = " << hdist->GetEntries() << endl;
702 >    cout << "; hdist->GetEntries() = " << hdist->GetEntries();
703 >    cout << "; fitting range = " << -fitRange << " to " << fitRange << endl;
704    }
705 <  if (hdist->GetEntries() - nOF - nUF >= 5) { // FIXME: for reasonable Gaussian fit
706 <    hdist->Fit("gaus","Q");
707 <    TF1 *fgaus = hdist->GetFunction("gaus");
705 >  if (hdist->GetEntries() - nOF - nUF >= 10) { // FIXME: for reasonable Gaussian fit
706 >    for (int bi = 0; bi < nbin; bi++) {
707 >      if ( (axis0->GetBinLowEdge(bi) < 0) && (hdist->GetBinContent(bi) > 0) ) {
708 >        sigMax[0] = axis0->GetBinLowEdge(bi);
709 >        if ( abs(sigMax[0]) > abs(sigMax[1]) ) sigMax[1] = abs(sigMax[0]);
710 >      }
711 >      if ( (axis0->GetBinLowEdge(bi) >= 0) && (hdist->GetBinContent(bi) > 0) ) {
712 >        sigMax[0] = axis0->GetBinUpEdge(bi);
713 >        if ( abs(sigMax[0]) > abs(sigMax[1]) ) sigMax[1] = abs(sigMax[0]);
714 >      }
715 >    }
716 >    if (verbose_) cout << "Fit sigMax = " << sqrt(2.)*sigMax[1] << endl;
717 >
718 >    TF1 *fgaus = new TF1("fgaus","gaus",-fitRange, fitRange);
719 >    fgaus->SetParameter(1, 0.);
720 >    fgaus->SetParLimits(1, -fitRange/40., fitRange/40.);
721 >    fgaus->SetParLimits(2, 0., sqrt(2.)*sigMax[1]);
722 >    fgaus->SetLineColor(4);
723 >    hdist->Fit(fgaus,"Q");
724 >    gPad->Update();
725 >    TPaveStats *s = (TPaveStats*) hdist->GetListOfFunctions()->FindObject("stats");
726 >    s->SetOptStat(1111111);
727 >    s->SetOptFit(0111);
728 >    gPad->Update();
729      if (verbose_) cout << "got function" << endl;
730 <    data[0] = ((fgaus->GetParameter(2))?fgaus->GetParameter(2):-999);
730 >    fitPars[0] = ((fgaus->GetParameter(2))?fgaus->GetParameter(2):-999);
731    }
732 +  else
733 +    fitPars[0] = -999;
734   }
735  
736   //define this as a plug-in

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines