1#include "GaudiKernel/MsgStream.h"
22 MsgStream log(
msgSvc(), name());
23 log<<MSG::INFO<<
"DedxCalibWireGain::BookHists()"<<endreq;
27 m_wiregain =
new TH1F*[
wireNo];
29 for(
int i=0; i<
wireNo; i++)
32 hlabel<<
"dEdx_Wire_"<<i;
39 MsgStream log(
msgSvc(), name());
40 log<<MSG::INFO<<
"DedxCalibWireGain::FillHists()"<<endreq;
47 float runNO=0,runFlag=0,pathlength=0,wid=0,layid=0,dd_in=0,driftdist=0,eangle=0,zhit=0,costheta=0,tes=0,ptrk=0;
52 cout<<
"runlist: "<<runlist.c_str()<<endl;
53 f =
new TFile(runlist.c_str());
54 n102 = (TTree*)f->Get(
"n102");
67 n102->SetBranchAddress(
"ptrk1",&ptrk);
69 for(
int j=0;j<n102->GetEntries();j++)
72 if(tes>1400)
continue;
73 if (ptrk<0.1)
continue;
78 dedx =
exsvc->
StandardHitCorrec(0,runFlag,2,runNO,pathlength,wid,layid,dedx,dd_in,eangle,costheta);
80 m_wiregain[(int)wid]->Fill(dedx);
87 MsgStream log(
msgSvc(), name());
88 log<<MSG::INFO<<
"DedxCalibWireGain::AnalyseHists()"<<endreq;
91 Double_t entry=0,mean=0,rms=0;
94 gStyle->SetOptFit(1111);
95 for(
int wire=0; wire<
wireNo; wire++)
97 entry = m_wiregain[wire]->Integral();
98 if(entry<10)
continue;
99 mean = m_wiregain[wire]->GetMean();
100 rms = m_wiregain[wire]->GetRMS();
101 binmax = m_wiregain[wire]->GetMaximumBin();
102 lp[1] = m_wiregain[wire]->GetBinCenter(binmax);
104 lp[0] = (m_wiregain[wire]->GetBinContent(binmax)+m_wiregain[wire]->GetBinContent(binmax-1)+m_wiregain[wire]->GetBinContent(binmax+1))/3;
108 func =
new TF1(
"mylan",
mylan,10,3000,4);
109 func->SetParameters(entry, mean, rms, -0.8);
110 func->SetParLimits(0, 0, entry);
111 func->SetParLimits(1, 0, mean);
112 func->SetParLimits(2, 10, rms);
113 func->SetParLimits(3, -3, 3);
117 func =
new TF1(
"landaun",
landaun,10,3000,3);
118 func->SetParameters(lp[0], lp[1], lp[2] );
122 func =
new TF1(
"Landau",
Landau,10,3000,2);
123 func->SetParameters(0.7*mean, rms );
127 func =
new TF1(
"Vavilov",
Vavilov,10,3000,2);
128 func->SetParameters(0.05, 0.6);
132 func =
new TF1(
"AsymGauss",
AsymGauss,10,3000,4);
133 func->SetParameters(entry, mean, rms, 1.0 );
135 func->SetLineWidth(2.1);
136 func->SetLineColor(2);
138 m_wiregain[wire]->Fit(func,
"rq",
"", mean-rms, mean+rms/2 );
144 MsgStream log(
msgSvc(), name());
145 log<<MSG::INFO<<
"DedxCalibWireGain::WriteHists()"<<endreq;
149 for(
int i=0; i<
wireNo; i++)
151 entryNo[i] = m_wiregain[i]->Integral();
152 mean[i] = m_wiregain[i]->GetMean();
153 sigma[i] = m_wiregain[i]->GetRMS();
154 proper[i] = m_wiregain[i]->GetBinCenter(m_wiregain[i]->GetMaximumBin());
155 if(entryNo[i]<10)
continue;
159 fitmean[i] = m_wiregain[i]->GetFunction(
"mylan")->GetParameter(1);
160 fitmeanerr[i] = m_wiregain[i]->GetFunction(
"mylan")->GetParError(1);
161 fitsigma[i] = m_wiregain[i]->GetFunction(
"mylan")->GetParameter(2);
162 chisq[i] = (m_wiregain[i]->GetFunction(
"mylan")-> GetChisquare())/(m_wiregain[i]->GetFunction(
"mylan")-> GetNDF());
166 fitmean[i] = m_wiregain[i]->GetFunction(
"landaun")->GetParameter(1);
167 fitmeanerr[i] = m_wiregain[i]->GetFunction(
"landaun")->GetParError(1);
168 fitsigma[i] = m_wiregain[i]->GetFunction(
"landaun")->GetParameter(2);
169 chisq[i] = (m_wiregain[i]->GetFunction(
"landaun")-> GetChisquare())/(m_wiregain[i]->GetFunction(
"landaun")-> GetNDF());
173 fitmean[i] = m_wiregain[i]->GetFunction(
"Landau")->GetParameter(1);
174 fitmeanerr[i] = m_wiregain[i]->GetFunction(
"Landau")->GetParError(1);
175 fitsigma[i] = m_wiregain[i]->GetFunction(
"Landau")->GetParameter(2);
176 chisq[i] = (m_wiregain[i]->GetFunction(
"Landau")-> GetChisquare())/(m_wiregain[i]->GetFunction(
"Landau")-> GetNDF());
180 fitmean[i] = m_wiregain[i]->GetFunction(
"Vavilov")->GetParameter(1);
181 fitmeanerr[i] = m_wiregain[i]->GetFunction(
"Vavilov")->GetParError(1);
182 fitsigma[i] = m_wiregain[i]->GetFunction(
"Vavilov")->GetParameter(2);
183 chisq[i] = (m_wiregain[i]->GetFunction(
"Vavilov")-> GetChisquare())/(m_wiregain[i]->GetFunction(
"Vavilov")-> GetNDF());
187 fitmean[i] = m_wiregain[i]->GetFunction(
"AsymGauss")->GetParameter(1);
188 fitmeanerr[i] = m_wiregain[i]->GetFunction(
"AsymGauss")->GetParError(1);
189 fitsigma[i] = m_wiregain[i]->GetFunction(
"AsymGauss")->GetParameter(2);
190 chisq[i] = (m_wiregain[i]->GetFunction(
"AsymGauss")-> GetChisquare())/(m_wiregain[i]->GetFunction(
"AsymGauss")-> GetNDF());
195 double Norm=0, count=0;
196 for(
int i=188; i<
wireNo; i++)
198 if(fitmean[i]>0 && fitmeanerr[i]>0 && fitmeanerr[i]<10 && fitsigma[i]>0 && fitsigma[i]<200 && entryNo[i]>1500)
205 cout<<
"count= "<<count<<
" average value of good wire: "<<Norm<<endl;
210 wireg[i] = fitmean[i]/Norm;
215 log<<MSG::INFO<<
"begin generating root file!!! "<<endreq;
216 TFile* f =
new TFile(
m_rootfile.c_str(),
"recreate");
217 for(
int i=0;i<
wireNo;i++) m_wiregain[i]->Write();
219 TTree* wiregcalib =
new TTree(
"wiregcalib",
"wiregcalib");
220 wiregcalib->Branch(
"wireg", wireg,
"wireg[6796]/D");
221 wiregcalib->Branch(
"wire", wire,
"wire[6796]/D");
222 wiregcalib->Branch(
"entryNo", entryNo,
"entryNo[6796]/D");
223 wiregcalib->Branch(
"proper", proper,
"proper[6796]/D");
224 wiregcalib->Branch(
"mean", mean,
"mean[6796]/D");
225 wiregcalib->Branch(
"sigma", sigma,
"sigma[6796]/D");
226 wiregcalib->Branch(
"fitmean", fitmean,
"fitmean[6796]/D");
227 wiregcalib->Branch(
"fitmeanerr", fitmeanerr,
"fitmeanerr[6796]/D");
228 wiregcalib->Branch(
"fitsigma", fitsigma,
"fitsigma[6796]/D");
229 wiregcalib->Branch(
"chisq", chisq,
"chisq[6796]/D");
235 TCanvas
c1(
"c1",
"canvas", 500, 400);
239 m_wiregain[i]->Draw();
244 for(
int i=0;i<
wireNo;i++)
delete m_wiregain[i];
data SetBranchAddress("time",&time)
double Landau(double *x, double *par)
double Vavilov(double *x, double *par)
#define Iner_DriftDistCut
double landaun(double *x, double *par)
double AsymGauss(double *x, double *par)
double mylan(double *x, double *par)
DedxCalibWireGain(const std::string &name, ISvcLocator *pSvcLocator)
vector< string > m_recFileVector
virtual double StandardHitCorrec(int calib_rec_Flag, int runFlag, int ntpFlag, int runNO, double pathl, int wid, int layid, double adc, double dd, double eangle, double costheta) const =0
virtual double StandardTrackCorrec(int calib_rec_Flag, int typFlag, int ntpFlag, int runNO, double ex, double costheta, double t0) const =0