1#include "GaudiKernel/MsgStream.h"
12#include "DedxCalibAlg/DedxCalibWireGain.h"
17 declareProperty(
"PMin", pMin=0.2);
18 declareProperty(
"PMax", pMax=2.3);
25 MsgStream log(
msgSvc(), name());
26 log<<MSG::INFO<<
"DedxCalibWireGain::BookHists()"<<endreq;
30 m_wiregain =
new TH1F*[
wireNo];
32 for(
int i=0; i<
wireNo; i++)
35 hlabel<<
"dEdx_Wire_"<<i;
42 MsgStream log(
msgSvc(), name());
43 log<<MSG::INFO<<
"DedxCalibWireGain::FillHists()"<<endreq;
48 float runNO=0,evtNO=0,runFlag=0,pathlength=0,wid=0,layid=0,dd_in=0,driftdist=0,eangle=0,zhit=0,
costheta=0,tes=0,
ptrk=0;
53 cout<<
"runlist: "<<runlist.c_str()<<endl;
56 f =
new TFile(runlist.c_str());
57 n102 = (TTree*)
f->Get(
"n102");
73 cout <<
"entries in this file " << n102->GetEntries() << endl;
75 for(
int j=0;j<n102->GetEntries();j++)
78 if(tes>1400)
continue;
84 dedx =
exsvc->
StandardHitCorrec(0,runFlag,2,runNO,evtNO,pathlength,wid,layid,dedx,dd_in,eangle,
costheta);
86 m_wiregain[(int)wid]->
Fill(dedx);
94 MsgStream log(
msgSvc(), name());
95 log<<MSG::INFO<<
"DedxCalibWireGain::AnalyseHists()"<<endreq;
97 TF1* func =
new TF1();
98 Double_t entry=0,mean=0,rms=0;
101 gStyle->SetOptFit(1111);
102 for(
int wire=0; wire<
wireNo; wire++)
104 entry = m_wiregain[wire]->Integral();
105 if(entry<10)
continue;
106 mean = m_wiregain[wire]->GetMean();
107 rms = m_wiregain[wire]->GetRMS();
108 binmax = m_wiregain[wire]->GetMaximumBin();
109 lp[1] = m_wiregain[wire]->GetBinCenter(binmax);
111 lp[0] = (m_wiregain[wire]->GetBinContent(binmax)+m_wiregain[wire]->GetBinContent(binmax-1)+m_wiregain[wire]->GetBinContent(binmax+1))/3;
115 func =
new TF1(
"mylan",
mylan,10,3000,4);
116 func->SetParameters(entry, mean, rms, -0.8);
117 func->SetParLimits(0, 0, entry);
118 func->SetParLimits(1, 0, mean);
119 func->SetParLimits(2, 10, rms);
120 func->SetParLimits(3, -3, 3);
124 func =
new TF1(
"landaun",
landaun,10,3000,3);
125 func->SetParameters(lp[0], lp[1], lp[2] );
129 func =
new TF1(
"Landau",
Landau,10,3000,2);
130 func->SetParameters(0.7*mean, rms );
134 func =
new TF1(
"Vavilov",
Vavilov,10,3000,2);
135 func->SetParameters(0.05, 0.6);
139 func =
new TF1(
"AsymGauss",
AsymGauss,10,3000,4);
140 func->SetParameters(entry, mean, rms, 1.0 );
142 func->SetLineWidth(2.1);
143 func->SetLineColor(2);
145 m_wiregain[wire]->Fit(func,
"rq",
"", mean-rms, mean+rms/2 );
151 MsgStream log(
msgSvc(), name());
152 log<<MSG::INFO<<
"DedxCalibWireGain::WriteHists()"<<endreq;
156 for(
int i=0; i<
wireNo; i++)
158 entryNo[i] = m_wiregain[i]->Integral();
159 mean[i] = m_wiregain[i]->GetMean();
160 sigma[i] = m_wiregain[i]->GetRMS();
161 proper[i] = m_wiregain[i]->GetBinCenter(m_wiregain[i]->GetMaximumBin());
162 if(entryNo[i]<10)
continue;
166 fitmean[i] = m_wiregain[i]->GetFunction(
"mylan")->GetParameter(1);
167 fitmeanerr[i] = m_wiregain[i]->GetFunction(
"mylan")->GetParError(1);
168 fitsigma[i] = m_wiregain[i]->GetFunction(
"mylan")->GetParameter(2);
169 chisq[i] = (m_wiregain[i]->GetFunction(
"mylan")-> GetChisquare())/(m_wiregain[i]->GetFunction(
"mylan")-> GetNDF());
173 fitmean[i] = m_wiregain[i]->GetFunction(
"landaun")->GetParameter(1);
174 fitmeanerr[i] = m_wiregain[i]->GetFunction(
"landaun")->GetParError(1);
175 fitsigma[i] = m_wiregain[i]->GetFunction(
"landaun")->GetParameter(2);
176 chisq[i] = (m_wiregain[i]->GetFunction(
"landaun")-> GetChisquare())/(m_wiregain[i]->GetFunction(
"landaun")-> GetNDF());
180 fitmean[i] = m_wiregain[i]->GetFunction(
"Landau")->GetParameter(1);
181 fitmeanerr[i] = m_wiregain[i]->GetFunction(
"Landau")->GetParError(1);
182 fitsigma[i] = m_wiregain[i]->GetFunction(
"Landau")->GetParameter(2);
183 chisq[i] = (m_wiregain[i]->GetFunction(
"Landau")-> GetChisquare())/(m_wiregain[i]->GetFunction(
"Landau")-> GetNDF());
187 fitmean[i] = m_wiregain[i]->GetFunction(
"Vavilov")->GetParameter(1);
188 fitmeanerr[i] = m_wiregain[i]->GetFunction(
"Vavilov")->GetParError(1);
189 fitsigma[i] = m_wiregain[i]->GetFunction(
"Vavilov")->GetParameter(2);
190 chisq[i] = (m_wiregain[i]->GetFunction(
"Vavilov")-> GetChisquare())/(m_wiregain[i]->GetFunction(
"Vavilov")-> GetNDF());
194 fitmean[i] = m_wiregain[i]->GetFunction(
"AsymGauss")->GetParameter(1);
195 fitmeanerr[i] = m_wiregain[i]->GetFunction(
"AsymGauss")->GetParError(1);
196 fitsigma[i] = m_wiregain[i]->GetFunction(
"AsymGauss")->GetParameter(2);
197 chisq[i] = (m_wiregain[i]->GetFunction(
"AsymGauss")-> GetChisquare())/(m_wiregain[i]->GetFunction(
"AsymGauss")-> GetNDF());
202 double Norm=0,
count=0;
203 for(
int i=188; i<
wireNo; i++)
205 if(fitmean[i]>0 && fitmeanerr[i]>0 && fitmeanerr[i]<10 && fitsigma[i]>0 && fitsigma[i]<200 && entryNo[i]>1500)
212 cout<<
"count= "<<
count<<
" average value of good wire: "<<Norm<<endl;
217 wireg[i] = fitmean[i]/Norm;
222 log<<MSG::INFO<<
"begin generating root file!!! "<<endreq;
223 TFile*
f =
new TFile(
m_rootfile.c_str(),
"recreate");
226 TTree* wiregcalib =
new TTree(
"wiregcalib",
"wiregcalib");
227 wiregcalib->Branch(
"wireg", wireg,
"wireg[6796]/D");
228 wiregcalib->Branch(
"wire", wire,
"wire[6796]/D");
229 wiregcalib->Branch(
"entryNo", entryNo,
"entryNo[6796]/D");
230 wiregcalib->Branch(
"proper", proper,
"proper[6796]/D");
231 wiregcalib->Branch(
"mean", mean,
"mean[6796]/D");
232 wiregcalib->Branch(
"sigma",
sigma,
"sigma[6796]/D");
233 wiregcalib->Branch(
"fitmean", fitmean,
"fitmean[6796]/D");
234 wiregcalib->Branch(
"fitmeanerr", fitmeanerr,
"fitmeanerr[6796]/D");
235 wiregcalib->Branch(
"fitsigma", fitsigma,
"fitsigma[6796]/D");
236 wiregcalib->Branch(
"chisq", chisq,
"chisq[6796]/D");
242 TCanvas c1(
"c1",
"canvas", 500, 400);
246 m_wiregain[i]->Draw();
251 for(
int i=0;i<
wireNo;i++)
delete m_wiregain[i];
data SetBranchAddress("time",&time)
DOUBLE_PRECISION count[3]
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, int evtNO, 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, int evtNO, double ex, double costheta, double t0) const =0
TFile f("ana_bhabha660a_dqa_mcPat_zy_old.root")