143{
144 MsgStream log(
msgSvc(), name());
145 log<<MSG::INFO<<"DedxCalibWireGain::WriteHists()"<<endreq;
146
147
149 for(
int i=0; i<
wireNo; i++)
150 {
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;
156
158 {
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());
163 }
165 {
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());
170 }
172 {
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());
177 }
179 {
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());
184 }
186 {
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());
191 }
192
193 }
194
195 double Norm=0,
count=0;
196 for(
int i=188; i<
wireNo; i++)
197 {
198 if(fitmean[i]>0 && fitmeanerr[i]>0 && fitmeanerr[i]<10 && fitsigma[i]>0 && fitsigma[i]<200 && entryNo[i]>1500)
199 {
200 Norm += fitmean[i];
202 }
203 }
205 cout<<
"count= "<<
count<<
" average value of good wire: "<<Norm<<endl;
206
207
209 {
210 wireg[i] = fitmean[i]/Norm;
211 wire[i] = i;
212 }
213
214
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();
218
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");
230 wiregcalib->Fill();
231 wiregcalib->Write();
232
233 f->Close();
234
235 TCanvas
c1(
"c1",
"canvas", 500, 400);
238 {
239 m_wiregain[i]->Draw();
241 }
243
244 for(
int i=0;i<
wireNo;i++)
delete m_wiregain[i];
245
246}