194{
195 MsgStream log(
msgSvc(), name());
196 log<<MSG::INFO<<"DedxCalibLayerGain::WriteHists()"<<endreq;
197
198
200 double fitmean_gaus[
layNo]={0},fitmeanerr_gaus[
layNo]={0},fitsigma_gaus[
layNo]={0},layerg_gaus[
layNo]={0};
201 for(
int i=0; i<
layNo; i++)
202 {
203 fitmean_gaus[i] = m_laygain_gaus[i]->GetFunction("gaus")->GetParameter(1);
204 fitmeanerr_gaus[i] = m_laygain_gaus[i]->GetFunction("gaus")->GetParError(1);
205 fitsigma_gaus[i] = m_laygain_gaus[i]->GetFunction("gaus")->GetParameter(2);
206
207 entryNo[i] = m_laygain[i]->GetEntries();
208 mean[i] = m_laygain[i]->GetMean();
209 sigma[i] = m_laygain[i]->GetRMS();
210 proper[i] = m_laygain[i]->GetBinCenter(m_laygain[i]->GetMaximumBin());
211 if(entryNo[i]<10) continue;
212
214 {
215 fitmean[i] = m_laygain[i]->GetFunction("mylan")->GetParameter(1);
216 fitmeanerr[i] = m_laygain[i]->GetFunction("mylan")->GetParError(1);
217 fitsigma[i] = m_laygain[i]->GetFunction("mylan")->GetParameter(2);
218 chisq[i] = (m_laygain[i]->GetFunction("mylan")-> GetChisquare())/(m_laygain[i]->GetFunction("mylan")-> GetNDF());
219 }
221 {
222 fitmean[i] = m_laygain[i]->GetFunction("landaun")->GetParameter(1);
223 fitmeanerr[i] = m_laygain[i]->GetFunction("landaun")->GetParError(1);
224 fitsigma[i] = m_laygain[i]->GetFunction("landaun")->GetParameter(2);
225 chisq[i] = (m_laygain[i]->GetFunction("landaun")-> GetChisquare())/(m_laygain[i]->GetFunction("landaun")-> GetNDF());
226 }
228 {
229 fitmean[i] = m_laygain[i]->GetFunction("Landau")->GetParameter(1);
230 fitmeanerr[i] = m_laygain[i]->GetFunction("Landau")->GetParError(1);
231 fitsigma[i] = m_laygain[i]->GetFunction("Landau")->GetParameter(2);
232 chisq[i] = (m_laygain[i]->GetFunction("Landau")-> GetChisquare())/(m_laygain[i]->GetFunction("Landau")-> GetNDF());
233 }
235 {
236 fitmean[i] = m_laygain[i]->GetFunction("Vavilov")->GetParameter(1);
237 fitmeanerr[i] = m_laygain[i]->GetFunction("Vavilov")->GetParError(1);
238 fitsigma[i] = m_laygain[i]->GetFunction("Vavilov")->GetParameter(2);
239 chisq[i] = (m_laygain[i]->GetFunction("Vavilov")-> GetChisquare())/(m_laygain[i]->GetFunction("Vavilov")-> GetNDF());
240 }
242 {
243 fitmean[i] = m_laygain[i]->GetFunction("AsymGauss")->GetParameter(1);
244 fitmeanerr[i] = m_laygain[i]->GetFunction("AsymGauss")->GetParError(1);
245 fitsigma[i] = m_laygain[i]->GetFunction("AsymGauss")->GetParameter(2);
246 chisq[i] = (m_laygain[i]->GetFunction("AsymGauss")-> GetChisquare())/(m_laygain[i]->GetFunction("AsymGauss")-> GetNDF());
247 }
248
249 }
250
251 double sum=0, sum_gaus=0,
n=0;
252 for(
int i=4; i<
layNo; i++)
253 {
254 if(fitmean[i]>0 && fitmeanerr[i]>0 && fitmeanerr[i]<10 && fitsigma[i]>0 && fitsigma[i]<200 && entryNo[i]>1500)
255 {
256 sum += fitmean[i];
257 sum_gaus+= fitmean_gaus[i];
259 }
260 }
263 cout<<"average value of good layer: "<<sum<<endl;
264
265 for(
int i=0;i<
layNo;i++)
266 {
267 layerg[i] = fitmean[i]/sum;
268 layerg_gaus[i] = fitmean_gaus[i]/sum_gaus;
269 layer[i] = i;
270 }
271
272
273 log<<MSG::INFO<<"begin generating root file!!! "<<endreq;
274 TFile*
f =
new TFile(
m_rootfile.c_str(),
"recreate");
275 for(
int i=0;i<
layNo;i++)
276 {
277 m_laygain[i]->Write();
278 m_laygain_gaus[i]->Write();
279 }
280
281 TTree* layergcalib = new TTree("layergcalib", "layergcalib");
282 layergcalib->Branch("layerg_gaus", layerg_gaus, "layerg_gaus[43]/D");
283 layergcalib->Branch("layerg", layerg, "layerg[43]/D");
284 layergcalib->Branch("layer", layer, "layer[43]/D");
285 layergcalib->Branch("entryNo", entryNo, "entryNo[43]/D");
286 layergcalib->Branch("mean", mean, "mean[43]/D");
287 layergcalib->Branch("sigma", sigma, "sigma[43]/D");
288 layergcalib->Branch("fitmean", fitmean, "fitmean[43]/D");
289 layergcalib->Branch("fitmeanerr", fitmeanerr, "fitmeanerr[43]/D");
290 layergcalib->Branch("fitsigma", fitsigma, "fitsigma[43]/D");
291 layergcalib->Branch("chisq", chisq, "chisq[43]/D");
292 layergcalib->Branch("fitmean_gaus", fitmean_gaus, "fitmean_gaus[43]/D");
293 layergcalib->Branch("fitmeanerr_gaus", fitmeanerr_gaus, "fitmeanerr_gaus[43]/D");
294 layergcalib->Branch("fitsigma_gaus", fitsigma_gaus, "fitsigma_gaus[43]/D");
295 layergcalib->Fill();
296 layergcalib->Write();
297
299
300 TCanvas c1("c1", "canvas", 500, 400);
302 for(
int i=0;i<
layNo;i++)
303 {
304 m_laygain[i]->Draw();
306 }
308
309 for(
int i=0;i<
layNo;i++)
310 {
311 delete m_laygain[i];
312 delete m_laygain_gaus[i];
313 }
314}