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 |
|
|
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 |
|
|
103 |
|
// Summary of analysis: |
104 |
|
if (analyze_) { |
105 |
< |
h_resx_nTrk = fs->make<TH2D>("resx_ntrk","x-resolution (Rec - Sim) vs number of tracks",150,0,150,400,0.,200); |
106 |
< |
h_resx_nTrk->SetMarkerStyle(21); |
107 |
< |
h_resx_nTrk->SetMarkerColor(4); |
108 |
< |
h_resx_nTrk->GetXaxis()->SetTitle("Num of tracks"); |
109 |
< |
h_resx_nTrk->GetYaxis()->SetTitle("#mum"); |
110 |
< |
h_resy_nTrk = fs->make<TH2D>("resy_ntrk","y-resolution (Rec - Sim) vs number of tracks",150,0,150,400,0.,200); |
111 |
< |
h_resy_nTrk->SetMarkerStyle(21); |
112 |
< |
h_resy_nTrk->SetMarkerColor(4); |
113 |
< |
h_resy_nTrk->GetXaxis()->SetTitle("Num of tracks"); |
114 |
< |
h_resy_nTrk->GetYaxis()->SetTitle("#mum"); |
115 |
< |
h_resz_nTrk = fs->make<TH2D>("resz_ntrk","z-resolution (Rec - Sim) vs number of tracks",150,0,150,400,0.,200); |
116 |
< |
h_resz_nTrk->SetMarkerStyle(21); |
117 |
< |
h_resz_nTrk->SetMarkerColor(4); |
118 |
< |
h_resz_nTrk->GetXaxis()->SetTitle("Num of tracks"); |
119 |
< |
h_resz_nTrk->GetYaxis()->SetTitle("#mum"); |
120 |
< |
h_pullx_nTrk = fs->make<TH2D>("pullx_ntrk","x-pull (Rec - Sim) vs number of tracks",150,0,150,100,0.,2.); |
121 |
< |
h_pullx_nTrk->SetMarkerStyle(21); |
122 |
< |
h_pullx_nTrk->SetMarkerColor(4); |
123 |
< |
h_pullx_nTrk->SetBit(TH1::kCanRebin); |
124 |
< |
h_pullx_nTrk->GetXaxis()->SetTitle("Num of tracks"); |
125 |
< |
h_pully_nTrk = fs->make<TH2D>("pully_ntrk","y-pull (Rec - Sim) vs number of tracks",150,0,150,100,0.,2.); |
126 |
< |
h_pully_nTrk->SetMarkerStyle(21); |
127 |
< |
h_pully_nTrk->SetMarkerColor(4); |
128 |
< |
h_pully_nTrk->SetBit(TH1::kCanRebin); |
129 |
< |
h_pully_nTrk->GetXaxis()->SetTitle("Num of tracks"); |
130 |
< |
h_pullz_nTrk = fs->make<TH2D>("pullz_ntrk","z-pull (Rec - Sim) vs number of tracks",150,0,150,100,0.,2.); |
131 |
< |
h_pullz_nTrk->SetMarkerStyle(21); |
132 |
< |
h_pullz_nTrk->SetMarkerColor(4); |
133 |
< |
h_pullz_nTrk->SetBit(TH1::kCanRebin); |
134 |
< |
h_pullz_nTrk->GetXaxis()->SetTitle("Num of tracks"); |
105 |
> |
h2["resx_nTrk"]= subDir.make<TH2D>("resx_ntrk","x-resolution (Rec - Sim) vs number of tracks",150,0,150,400,0.,200); |
106 |
> |
h2["resx_nTrk"]->SetMarkerStyle(21); |
107 |
> |
h2["resx_nTrk"]->SetMarkerColor(4); |
108 |
> |
h2["resx_nTrk"]->GetXaxis()->SetTitle("Num of tracks"); |
109 |
> |
h2["resx_nTrk"]->GetYaxis()->SetTitle("#mum"); |
110 |
> |
h2["resy_nTrk"]= subDir.make<TH2D>("resy_ntrk","y-resolution (Rec - Sim) vs number of tracks",150,0,150,400,0.,200); |
111 |
> |
h2["resy_nTrk"]->SetMarkerStyle(21); |
112 |
> |
h2["resy_nTrk"]->SetMarkerColor(4); |
113 |
> |
h2["resy_nTrk"]->GetXaxis()->SetTitle("Num of tracks"); |
114 |
> |
h2["resy_nTrk"]->GetYaxis()->SetTitle("#mum"); |
115 |
> |
h2["resz_nTrk"]= subDir.make<TH2D>("resz_ntrk","z-resolution (Rec - Sim) vs number of tracks",150,0,150,400,0.,200); |
116 |
> |
h2["resz_nTrk"]->SetMarkerStyle(21); |
117 |
> |
h2["resz_nTrk"]->SetMarkerColor(4); |
118 |
> |
h2["resz_nTrk"]->GetXaxis()->SetTitle("Num of tracks"); |
119 |
> |
h2["resz_nTrk"]->GetYaxis()->SetTitle("#mum"); |
120 |
> |
h2["pullx_nTrk"]= subDir.make<TH2D>("pullx_ntrk","x-pull (Rec - Sim) vs number of tracks",150,0,150,100,0.,2.); |
121 |
> |
h2["pullx_nTrk"]->SetMarkerStyle(21); |
122 |
> |
h2["pullx_nTrk"]->SetMarkerColor(4); |
123 |
> |
h2["pullx_nTrk"]->SetBit(TH1::kCanRebin); |
124 |
> |
h2["pullx_nTrk"]->GetXaxis()->SetTitle("Num of tracks"); |
125 |
> |
h2["pully_nTrk"]= subDir.make<TH2D>("pully_ntrk","y-pull (Rec - Sim) vs number of tracks",150,0,150,100,0.,2.); |
126 |
> |
h2["pully_nTrk"]->SetMarkerStyle(21); |
127 |
> |
h2["pully_nTrk"]->SetMarkerColor(4); |
128 |
> |
h2["pully_nTrk"]->SetBit(TH1::kCanRebin); |
129 |
> |
h2["pully_nTrk"]->GetXaxis()->SetTitle("Num of tracks"); |
130 |
> |
h2["pullz_nTrk"]= subDir.make<TH2D>("pullz_ntrk","z-pull (Rec - Sim) vs number of tracks",150,0,150,100,0.,2.); |
131 |
> |
h2["pullz_nTrk"]->SetMarkerStyle(21); |
132 |
> |
h2["pullz_nTrk"]->SetMarkerColor(4); |
133 |
> |
h2["pullz_nTrk"]->SetBit(TH1::kCanRebin); |
134 |
> |
h2["pullz_nTrk"]->GetXaxis()->SetTitle("Num of tracks"); |
135 |
|
} |
136 |
|
for (int ntrk=nTrkMin_;ntrk<=nTrkMax_;++ntrk) { |
137 |
|
stringstream ss; |
146 |
|
h["pullx_"+suffix] = fs->make<TH1D> (TString("pullx_"+suffix),"x-pull (Rec - Sim)",100,-10.,10.); |
147 |
|
h["pully_"+suffix] = fs->make<TH1D> (TString("pully_"+suffix),"y-pull (Rec - Sim)",100,-10.,10.); |
148 |
|
h["pullz_"+suffix] = fs->make<TH1D> (TString("pullz_"+suffix),"z-pull (Rec - Sim)",100,-10.,10.); |
149 |
+ |
h["errPVx_"+suffix] = subDir1.make<TH1D> (TString("errPVx_"+suffix),"X vertex error",100,0.,0.02); |
150 |
+ |
h["errPVy_"+suffix] = subDir1.make<TH1D> (TString("errPVy_"+suffix),"Y vertex error",100,0.,0.02); |
151 |
+ |
h["errPVz_"+suffix] = subDir1.make<TH1D> (TString("errPVz_"+suffix),"Z vertex error",100,0.,0.02); |
152 |
|
suffix.clear(); |
153 |
|
} |
154 |
|
} |
163 |
|
|
164 |
|
} |
165 |
|
|
166 |
< |
|
166 |
> |
void PVStudy::setRootStyle() { |
167 |
> |
// |
168 |
> |
gROOT->SetStyle("Plain"); |
169 |
> |
gStyle->SetFillColor(1); |
170 |
> |
gStyle->SetOptDate(); |
171 |
> |
// gStyle->SetOptStat(1111110); |
172 |
> |
// gStyle->SetOptFit(0111); |
173 |
> |
// gStyle->SetPadTickX(1); |
174 |
> |
// gStyle->SetPadTickY(1); |
175 |
> |
gStyle->SetMarkerSize(0.5); |
176 |
> |
gStyle->SetMarkerStyle(8); |
177 |
> |
gStyle->SetGridStyle(3); |
178 |
> |
//gStyle->SetPadGridX(1); |
179 |
> |
//gStyle->SetPadGridY(1); |
180 |
> |
gStyle->SetPaperSize(TStyle::kA4); |
181 |
> |
gStyle->SetStatW(0.25); // width of statistics box; default is 0.19 |
182 |
> |
// gStyle->SetStatH(0.10); // height of statistics box; default is 0.1 |
183 |
> |
gStyle->SetStatFormat("6.4g"); // leave default format for now |
184 |
> |
gStyle->SetTitleSize(0.055, ""); // size for pad title; default is 0.02 |
185 |
> |
gStyle->SetLabelSize(0.03, "XYZ"); // size for axis labels; default is 0.04 |
186 |
> |
gStyle->SetStatFontSize(0.08); // size for stat. box |
187 |
> |
gStyle->SetTitleFont(32, "XYZ"); // times-bold-italic font (p. 153) for axes |
188 |
> |
gStyle->SetTitleFont(32, ""); // same for pad title |
189 |
> |
gStyle->SetLabelFont(32, "XYZ"); // same for axis labels |
190 |
> |
gStyle->SetStatFont(32); // same for stat. box |
191 |
> |
gStyle->SetLabelOffset(0.006, "Y"); // default is 0.005 |
192 |
> |
// |
193 |
> |
return; |
194 |
> |
} |
195 |
|
// |
196 |
|
// member functions |
197 |
|
// |
438 |
|
ferror[1] = vsim->recVtx->yError(); |
439 |
|
ferror[2] = vsim->recVtx->zError(); |
440 |
|
fntrk = nrectrk; |
406 |
– |
ftree_->Fill(); |
441 |
|
|
442 |
< |
h_deltax->Fill( vsim->recVtx->x()-vsim->x ); |
443 |
< |
h_deltay->Fill( vsim->recVtx->y()-vsim->y ); |
444 |
< |
h_deltaz->Fill( vsim->recVtx->z()-vsim->z ); |
445 |
< |
h_pullx->Fill( (vsim->recVtx->x()-vsim->x )/vsim->recVtx->xError() ); |
446 |
< |
h_pully->Fill( (vsim->recVtx->y()-vsim->y )/vsim->recVtx->yError() ); |
447 |
< |
h_pullz->Fill( (vsim->recVtx->z()-vsim->z )/vsim->recVtx->zError() ); |
448 |
< |
pvinfo.push_back(PVStudy::PVInfo(res(vsim->recVtx->x()-vsim->x, |
449 |
< |
vsim->recVtx->y()-vsim->y, |
416 |
< |
vsim->recVtx->z()-vsim->z), |
417 |
< |
error(vsim->recVtx->xError(), |
418 |
< |
vsim->recVtx->yError(), |
419 |
< |
vsim->recVtx->zError()), |
442 |
> |
h["deltax"]->Fill( fres[0] ); |
443 |
> |
h["deltay"]->Fill( fres[1] ); |
444 |
> |
h["deltaz"]->Fill( fres[2] ); |
445 |
> |
h["pullx"]->Fill( fres[0]/ferror[0] ); |
446 |
> |
h["pully"]->Fill( fres[1]/ferror[1] ); |
447 |
> |
h["pullz"]->Fill( fres[2]/ferror[2] ); |
448 |
> |
pvinfo.push_back(PVStudy::PVInfo(res(fres[0], fres[1], fres[2]), |
449 |
> |
error(ferror[0], ferror[1], ferror[2]), |
450 |
|
nrectrk)); |
451 |
|
// Fill histo according to its track multiplicity |
452 |
< |
fillHisto(res(vsim->recVtx->x()-vsim->x, |
453 |
< |
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()), |
452 |
> |
fillHisto(res(fres[0], fres[1], fres[2]), |
453 |
> |
error(ferror[0], ferror[1], ferror[2]), |
454 |
|
nrectrk); |
455 |
+ |
|
456 |
+ |
ftree_->Fill(); |
457 |
|
} |
458 |
|
else{ // no rec vertex found for this simvertex |
459 |
|
if(verbose_) { |
472 |
|
t!=v->tracks_end(); t++) { |
473 |
|
// illegal charge |
474 |
|
if ( (**t).charge() < -1 || (**t).charge() > 1 ) { |
475 |
< |
// h_trkPtPV->Fill(0.); |
475 |
> |
// h["trkPtPV"]->Fill(0.); |
476 |
|
} |
477 |
|
else { |
478 |
< |
h_trkPtPV->Fill((**t).pt()); |
478 |
> |
h["trkPtPV"]->Fill((**t).pt()); |
479 |
|
} |
480 |
|
} |
481 |
|
} |
482 |
|
catch (...) { |
483 |
|
// exception thrown when trying to use linked track |
484 |
< |
// h_trkPtPV->Fill(0.); |
484 |
> |
// h["trkPtPV"]->Fill(0.); |
485 |
|
} |
486 |
|
|
487 |
< |
h_nTrkPV->Fill(v->tracksSize()); |
487 |
> |
h["nTrkPV"]->Fill(v->tracksSize()); |
488 |
|
|
489 |
|
} |
490 |
|
|
491 |
< |
h_nTrk->Fill(tracks->size()); |
491 |
> |
h["nTrk"]->Fill(tracks->size()); |
492 |
|
|
493 |
|
for(TrackCollection::const_iterator itTrack = tracks->begin(); |
494 |
|
itTrack != tracks->end(); |
495 |
|
++itTrack) { |
496 |
|
int charge = 0; |
497 |
|
charge = itTrack->charge(); |
498 |
< |
h_trkPt->Fill(itTrack->pt()); |
498 |
> |
h["trkPt"]->Fill(itTrack->pt()); |
499 |
|
} |
500 |
|
|
501 |
|
} |
517 |
|
if (verbose_) cout << "Fill point of ntrk = " << ntrk << endl; |
518 |
|
PVStudy::PVAnaInfo ipv = GetPVAnaInfo(ntrk); |
519 |
|
if (analyze_) { |
520 |
< |
// if ( ipv.res_.x() > 0 ) h_resx_nTrk->Fill(ntrk,ipv.res_.x()/sqt2, 1.); |
521 |
< |
// if ( ipv.res_.y() > 0 ) h_resy_nTrk->Fill(ntrk,ipv.res_.y()/sqt2, 1.); |
522 |
< |
// if ( ipv.res_.z() > 0 ) h_resz_nTrk->Fill(ntrk,ipv.res_.z()/sqt2, 1.); |
523 |
< |
if ( ipv.res_.x() > 0 ) h_resx_nTrk->Fill(ntrk,ipv.res_.x(), 1.); |
524 |
< |
if ( ipv.res_.y() > 0 ) h_resy_nTrk->Fill(ntrk,ipv.res_.y(), 1.); |
525 |
< |
if ( ipv.res_.z() > 0 ) h_resz_nTrk->Fill(ntrk,ipv.res_.z(), 1.); |
526 |
< |
if ( ipv.pull_.x() > 0 ) h_pullx_nTrk->Fill(ntrk,ipv.pull_.x(), 1.); |
527 |
< |
if ( ipv.pull_.y() > 0 ) h_pully_nTrk->Fill(ntrk,ipv.pull_.y(), 1.); |
528 |
< |
if ( ipv.pull_.z() > 0 ) h_pullz_nTrk->Fill(ntrk,ipv.pull_.z(), 1.); |
520 |
> |
// if ( ipv.res_.x() > 0 ) h2["resx_nTrk"]->Fill(ntrk,ipv.res_.x()/sqt2, 1.); |
521 |
> |
// if ( ipv.res_.y() > 0 ) h2["resy_nTrk"]->Fill(ntrk,ipv.res_.y()/sqt2, 1.); |
522 |
> |
// if ( ipv.res_.z() > 0 ) h2["resz_nTrk"]->Fill(ntrk,ipv.res_.z()/sqt2, 1.); |
523 |
> |
if ( ipv.res_.x() > 0 ) h2["resx_nTrk"]->Fill(ntrk,ipv.res_.x(), 1.); |
524 |
> |
if ( ipv.res_.y() > 0 ) h2["resy_nTrk"]->Fill(ntrk,ipv.res_.y(), 1.); |
525 |
> |
if ( ipv.res_.z() > 0 ) h2["resz_nTrk"]->Fill(ntrk,ipv.res_.z(), 1.); |
526 |
> |
if ( ipv.pull_.x() > 0 ) h2["pullx_nTrk"]->Fill(ntrk,ipv.pull_.x(), 1.); |
527 |
> |
if ( ipv.pull_.y() > 0 ) h2["pully_nTrk"]->Fill(ntrk,ipv.pull_.y(), 1.); |
528 |
> |
if ( ipv.pull_.z() > 0 ) h2["pullz_nTrk"]->Fill(ntrk,ipv.pull_.z(), 1.); |
529 |
|
} |
530 |
|
} |
531 |
|
} |
611 |
|
} |
612 |
|
} |
613 |
|
|
614 |
< |
void PVStudy::fillHisto(res r, pull p, int ntk){ |
614 |
> |
void PVStudy::fillHisto(res r, error er, int ntk){ |
615 |
|
stringstream ss; |
616 |
|
ss << ntk; |
617 |
|
string suffix = ss.str(); |
620 |
|
h["resx_"+suffix]->Fill(r.x()); |
621 |
|
h["resy_"+suffix]->Fill(r.y()); |
622 |
|
h["resz_"+suffix]->Fill(r.z()); |
623 |
< |
h["pullx_"+suffix]->Fill(p.x()); |
624 |
< |
h["pully_"+suffix]->Fill(p.y()); |
625 |
< |
h["pullz_"+suffix]->Fill(p.z()); |
623 |
> |
h["pullx_"+suffix]->Fill(r.x()/er.x()); |
624 |
> |
h["pully_"+suffix]->Fill(r.y()/er.y()); |
625 |
> |
h["pullz_"+suffix]->Fill(r.z()/er.z()); |
626 |
> |
h["errPVx_"+suffix]->Fill(er.x()); |
627 |
> |
h["errPVy_"+suffix]->Fill(er.y()); |
628 |
> |
h["errPVz_"+suffix]->Fill(er.z()); |
629 |
|
} |
630 |
|
|
631 |
|
PVStudy::PVAnaInfo PVStudy::GetPVAnaInfo(int ntk) { |
632 |
|
map<int,double> data; |
633 |
|
data.clear(); |
634 |
< |
double fpar[2]; |
634 |
> |
double fpar[2] = {-999,-999}; |
635 |
|
double cm2um = 10000; |
636 |
|
stringstream ss; |
637 |
|
ss << ntk; |
639 |
|
|
640 |
|
if(analyze_) { |
641 |
|
for ( int i = 0; i < 6; ++i) { |
611 |
– |
cout << "Here" << endl; |
642 |
|
switch (i) { |
643 |
|
case 0: |
644 |
|
fit(h["resx_"+suffix], fpar); |
680 |
|
ntk); |
681 |
|
} |
682 |
|
|
683 |
< |
void PVStudy::fit(TH1 *&hdist, double data[]){ |
683 |
> |
void PVStudy::fit(TH1 *&hdist, double fitPars[]){ |
684 |
|
TAxis *axis0 = hdist->GetXaxis(); |
685 |
|
int nbin = axis0->GetLast(); |
686 |
|
double nOF = hdist->GetBinContent(nbin+1); |
687 |
|
double nUF = hdist->GetBinContent(0); |
688 |
+ |
// double fitRange = axis0->GetBinUpEdge(nbin); |
689 |
+ |
double fitRange = axis0->GetXmax(); |
690 |
+ |
double sigMax[3] = {0.,0.,0.}; |
691 |
+ |
|
692 |
|
if ( verbose_ ){ |
693 |
|
cout << "Last bin = " << nbin; |
694 |
|
cout << "; hdist: Overflow Entries = " << nOF; |
695 |
|
cout << "; Underflow Entries = " << nUF; |
696 |
< |
cout << "; hdist->GetEntries() = " << hdist->GetEntries() << endl; |
696 |
> |
cout << "; hdist->GetEntries() = " << hdist->GetEntries(); |
697 |
> |
cout << "; fitting range = " << -fitRange << " to " << fitRange << endl; |
698 |
|
} |
699 |
< |
if (hdist->GetEntries() - nOF - nUF >= 5) { // FIXME: for reasonable Gaussian fit |
700 |
< |
hdist->Fit("gaus","Q"); |
701 |
< |
TF1 *fgaus = hdist->GetFunction("gaus"); |
699 |
> |
if (hdist->GetEntries() - nOF - nUF >= 10) { // FIXME: for reasonable Gaussian fit |
700 |
> |
for (int bi = 0; bi < nbin; bi++) { |
701 |
> |
if ( (axis0->GetBinLowEdge(bi) < 0) && (hdist->GetBinContent(bi) > 0) ) { |
702 |
> |
sigMax[0] = axis0->GetBinLowEdge(bi); |
703 |
> |
if ( abs(sigMax[0]) > abs(sigMax[2]) ) sigMax[2] = abs(sigMax[0]); |
704 |
> |
} |
705 |
> |
if ( (axis0->GetBinLowEdge(bi) >= 0) && (hdist->GetBinContent(bi) > 0) ) { |
706 |
> |
sigMax[1] = axis0->GetBinUpEdge(bi); |
707 |
> |
if ( abs(sigMax[1]) > abs(sigMax[2]) ) sigMax[2] = abs(sigMax[1]); |
708 |
> |
} |
709 |
> |
} |
710 |
> |
if (verbose_) cout << "Fit sigMax = " << sqrt(2.)*sigMax[2] << endl; |
711 |
> |
|
712 |
> |
TF1 *fgaus = new TF1("fgaus","gaus",-fitRange, fitRange); |
713 |
> |
fgaus->SetParameter(1, 0.); |
714 |
> |
fgaus->SetParLimits(1, -fitRange/40., fitRange/40.); |
715 |
> |
fgaus->SetParLimits(2, 0., sqrt(2.)*sigMax[2]); |
716 |
> |
fgaus->SetLineColor(4); |
717 |
> |
hdist->Fit(fgaus,"Q"); |
718 |
> |
gPad->Update(); |
719 |
> |
TPaveStats *s = (TPaveStats*) hdist->GetListOfFunctions()->FindObject("stats"); |
720 |
> |
s->SetOptStat(1111111); |
721 |
> |
s->SetOptFit(0111); |
722 |
> |
gPad->Update(); |
723 |
|
if (verbose_) cout << "got function" << endl; |
724 |
< |
data[0] = ((fgaus->GetParameter(2))?fgaus->GetParameter(2):-999); |
724 |
> |
fitPars[0] = ((fgaus->GetParameter(2))?fgaus->GetParameter(2):-999); |
725 |
|
} |
726 |
+ |
else |
727 |
+ |
fitPars[0] = -999; |
728 |
|
} |
729 |
|
|
730 |
|
//define this as a plug-in |