212{
213 MsgStream log(
msgSvc(), name());
214 log<<MSG::INFO<<"DedxCalibEAng::WriteHists()"<<endreq;
215
221
222 double Norm(0), trunc_Norm(0);
225 {
226 Ip_eangle[ip] = ip;
228
229 entryNo[ip]= m_eangle[ip]->Integral();
230 trunc_mean[ip] = m_trunc_eangle[ip]->GetMean();
231 trunc_sigma[ip] = m_trunc_eangle[ip]->GetRMS();
232 pos_entryNo[ip]= m_pos_eangle[ip]->Integral();
233 pos_mean[ip] = m_pos_eangle[ip]->GetMean();
234 pos_sigma[ip] = m_pos_eangle[ip]->GetRMS();
235 neg_entryNo[ip]= m_neg_eangle[ip]->Integral();
236 neg_mean[ip] = m_neg_eangle[ip]->GetMean();
237 neg_sigma[ip] = m_neg_eangle[ip]->GetRMS();
238 if(entryNo[ip]<10 || pos_entryNo[ip]<10 || neg_entryNo[ip]<10) continue;
239
241 {
242 fitmean[ip] = m_eangle[ip]->GetFunction("mylan")->GetParameter(1);
243 fitmeanerr[ip] = m_eangle[ip]->GetFunction("mylan")->GetParError(1);
244 fitsigma[ip] = m_eangle[ip]->GetFunction("mylan")->GetParameter(2);
245 chisq[ip] = (m_eangle[ip]->GetFunction("mylan")-> GetChisquare())/(m_eangle[ip]->GetFunction("mylan")-> GetNDF());
246
247 pos_fitmean[ip] = m_pos_eangle[ip]->GetFunction("mylan")->GetParameter(1);
248 pos_fitmeanerr[ip] = m_pos_eangle[ip]->GetFunction("mylan")->GetParError(1);
249 pos_fitsigma[ip] = m_pos_eangle[ip]->GetFunction("mylan")->GetParameter(2);
250 pos_chisq[ip] = (m_pos_eangle[ip]->GetFunction("mylan")-> GetChisquare())/(m_pos_eangle[ip]->GetFunction("mylan")-> GetNDF());
251
252 neg_fitmean[ip] = m_neg_eangle[ip]->GetFunction("mylan")->GetParameter(1);
253 neg_fitmeanerr[ip] = m_neg_eangle[ip]->GetFunction("mylan")->GetParError(1);
254 neg_fitsigma[ip] = m_neg_eangle[ip]->GetFunction("mylan")->GetParameter(2);
255 neg_chisq[ip] = (m_neg_eangle[ip]->GetFunction("mylan")-> GetChisquare())/(m_neg_eangle[ip]->GetFunction("mylan")-> GetNDF());
256 }
258 {
259 fitmean[ip] = m_eangle[ip]->GetFunction("landaun")->GetParameter(1);
260 fitmeanerr[ip] = m_eangle[ip]->GetFunction("landaun")->GetParError(1);
261 fitsigma[ip] = m_eangle[ip]->GetFunction("landaun")->GetParameter(2);
262 chisq[ip] = (m_eangle[ip]->GetFunction("landaun")-> GetChisquare())/(m_eangle[ip]->GetFunction("mylan")-> GetNDF());
263
264 pos_fitmean[ip] = m_pos_eangle[ip]->GetFunction("landaun")->GetParameter(1);
265 pos_fitmeanerr[ip] = m_pos_eangle[ip]->GetFunction("landaun")->GetParError(1);
266 pos_fitsigma[ip] = m_pos_eangle[ip]->GetFunction("landaun")->GetParameter(2);
267 pos_chisq[ip] = (m_pos_eangle[ip]->GetFunction("landaun")-> GetChisquare())/(m_pos_eangle[ip]->GetFunction("landaun")-> GetNDF());
268
269 neg_fitmean[ip] = m_neg_eangle[ip]->GetFunction("landaun")->GetParameter(1);
270 neg_fitmeanerr[ip] = m_neg_eangle[ip]->GetFunction("landaun")->GetParError(1);
271 neg_fitsigma[ip] = m_neg_eangle[ip]->GetFunction("landaun")->GetParameter(2);
272 neg_chisq[ip] = (m_neg_eangle[ip]->GetFunction("landaun")-> GetChisquare())/(m_neg_eangle[ip]->GetFunction("landaun")-> GetNDF());
273 }
275 {
276 fitmean[ip] = m_eangle[ip]->GetFunction("Landau")->GetParameter(1);
277 fitmeanerr[ip] = m_eangle[ip]->GetFunction("Landau")->GetParError(1);
278 fitsigma[ip] = m_eangle[ip]->GetFunction("Landau")->GetParameter(2);
279 chisq[ip] = (m_eangle[ip]->GetFunction("Landau")-> GetChisquare())/(m_eangle[ip]->GetFunction("Landau")-> GetNDF());
280
281 pos_fitmean[ip] = m_pos_eangle[ip]->GetFunction("Landau")->GetParameter(1);
282 pos_fitmeanerr[ip] = m_pos_eangle[ip]->GetFunction("Landau")->GetParError(1);
283 pos_fitsigma[ip] = m_pos_eangle[ip]->GetFunction("Landau")->GetParameter(2);
284 pos_chisq[ip] = (m_pos_eangle[ip]->GetFunction("Landau")-> GetChisquare())/(m_pos_eangle[ip]->GetFunction("Landau")-> GetNDF());
285
286 neg_fitmean[ip] = m_neg_eangle[ip]->GetFunction("Landau")->GetParameter(1);
287 neg_fitmeanerr[ip] = m_neg_eangle[ip]->GetFunction("Landau")->GetParError(1);
288 neg_fitsigma[ip] = m_neg_eangle[ip]->GetFunction("Landau")->GetParameter(2);
289 neg_chisq[ip] = (m_neg_eangle[ip]->GetFunction("Landau")-> GetChisquare())/(m_neg_eangle[ip]->GetFunction("Landau")-> GetNDF());
290 }
292 {
293 fitmean[ip] = m_eangle[ip]->GetFunction("Vavilov")->GetParameter(1);
294 fitmeanerr[ip] = m_eangle[ip]->GetFunction("Vavilov")->GetParError(1);
295 fitsigma[ip] = m_eangle[ip]->GetFunction("Vavilov")->GetParameter(2);
296 chisq[ip] = (m_eangle[ip]->GetFunction("Vavilov")-> GetChisquare())/(m_eangle[ip]->GetFunction("Vavilov")-> GetNDF());
297
298 pos_fitmean[ip] = m_pos_eangle[ip]->GetFunction("Vavilov")->GetParameter(1);
299 pos_fitmeanerr[ip] = m_pos_eangle[ip]->GetFunction("Vavilov")->GetParError(1);
300 pos_fitsigma[ip] = m_pos_eangle[ip]->GetFunction("Vavilov")->GetParameter(2);
301 pos_chisq[ip] = (m_pos_eangle[ip]->GetFunction("Vavilov")-> GetChisquare())/(m_pos_eangle[ip]->GetFunction("Vavilov")-> GetNDF());
302
303 neg_fitmean[ip] = m_neg_eangle[ip]->GetFunction("Vavilov")->GetParameter(1);
304 neg_fitmeanerr[ip] = m_neg_eangle[ip]->GetFunction("Vavilov")->GetParError(1);
305 neg_fitsigma[ip] = m_neg_eangle[ip]->GetFunction("Vavilov")->GetParameter(2);
306 neg_chisq[ip] = (m_neg_eangle[ip]->GetFunction("Vavilov")-> GetChisquare())/(m_neg_eangle[ip]->GetFunction("Vavilov")-> GetNDF());
307 }
309 {
310 fitmean[ip] = m_eangle[ip]->GetFunction("AsymGauss")->GetParameter(1);
311 fitmeanerr[ip] = m_eangle[ip]->GetFunction("AsymGauss")->GetParError(1);
312 fitsigma[ip] = m_eangle[ip]->GetFunction("AsymGauss")->GetParameter(2);
313 chisq[ip] = (m_eangle[ip]->GetFunction("AsymGauss")-> GetChisquare())/(m_eangle[ip]->GetFunction("AsymGauss")-> GetNDF());
314
315 pos_fitmean[ip] = m_pos_eangle[ip]->GetFunction("AsymGauss")->GetParameter(1);
316 pos_fitmeanerr[ip] = m_pos_eangle[ip]->GetFunction("AsymGauss")->GetParError(1);
317 pos_fitsigma[ip] = m_pos_eangle[ip]->GetFunction("AsymGauss")->GetParameter(2);
318 pos_chisq[ip] = (m_pos_eangle[ip]->GetFunction("AsymGauss")-> GetChisquare())/(m_pos_eangle[ip]->GetFunction("AsymGauss")-> GetNDF());
319
320 neg_fitmean[ip] = m_neg_eangle[ip]->GetFunction("AsymGauss")->GetParameter(1);
321 neg_fitmeanerr[ip] = m_neg_eangle[ip]->GetFunction("AsymGauss")->GetParError(1);
322 neg_fitsigma[ip] = m_neg_eangle[ip]->GetFunction("AsymGauss")->GetParameter(2);
323 neg_chisq[ip] = (m_neg_eangle[ip]->GetFunction("AsymGauss")-> GetChisquare())/(m_neg_eangle[ip]->GetFunction("AsymGauss")-> GetNDF());
324 }
325 if(entryNo[ip]>1500 && fitmean[ip]>0 && fitmeanerr[ip]>0 && fitmeanerr[ip]<10 && fitsigma[ip]>0 && fitsigma[ip]<200){
326 Norm += fitmean[ip];
327 trunc_Norm += trunc_mean[ip];
329 }
330 }
332 trunc_Norm = trunc_Norm/
count;
333
334 cout<<
"count= "<<
count<<
" average value: "<< Norm <<
" truncted: " << trunc_Norm << endl;
336 {
337 if(entryNo[i]>10 && fitmean[i]>0 && fitsigma[i]>0) gain[i]=fitmean[i]/Norm;
338 else gain[i] = 1;
339 if(entryNo[i]>10) trunc_gain[i]=trunc_mean[i]/trunc_Norm;
340 else trunc_mean[i] = 1;
341 if(pos_entryNo[i]>10 && pos_fitmean[i]>0 && pos_fitsigma[i]>0) pos_gain[i]=pos_fitmean[i]/Norm;
342 else pos_gain[i] = 1;
343 if(neg_entryNo[i]>10 && neg_fitmean[i]>0 && neg_fitsigma[i]>0) neg_gain[i]=neg_fitmean[i]/Norm;
344 else neg_gain[i] = 1;
345 if(gain[i] != 1){
346 m_EAngAverdE -> SetBinContent(i+1, gain[i]);
347 m_EAngAverdE->SetBinError(i+1, fitmeanerr[i]/Norm);
348 }
349 if(trunc_gain[i] != 1){
350 m_trunc_EAngAverdE -> SetBinContent(i+1, trunc_gain[i]);
351 m_trunc_EAngAverdE->SetBinError(i+1, trunc_sigma[i]/trunc_Norm);
352 }
353 if(pos_gain[i] != 1){
354 m_pos_EAngAverdE -> SetBinContent(i+1, pos_gain[i]);
355 m_pos_EAngAverdE->SetBinError(i+1, pos_fitmeanerr[i]/Norm);
356 }
357 if(neg_gain[i] != 1){
358 m_neg_EAngAverdE -> SetBinContent(i+1, neg_gain[i]);
359 m_neg_EAngAverdE->SetBinError(i+1, neg_fitmeanerr[i]/Norm);
360 }
361 }
362
363 log<<MSG::INFO<<"begin getting calibration constant!!! "<<endreq;
365 int denangle_entry[1] = {100};
366 m_EAngAverdE->Fit("pol1","r","",-0.25,0.25);
367 double par0 = m_EAngAverdE->GetFunction("pol1")->GetParameter(0);
368 double par1 = m_EAngAverdE->GetFunction("pol1")->GetParameter(1);
369
370
371
372 for(
int i=0;i<
NumSlices;i++) denangle[i] = gain[i];
373
374 log<<MSG::INFO<<"begin generating root file!!! "<<endreq;
375 TFile*
f =
new TFile(
m_rootfile.c_str(),
"recreate");
377 m_eangle[ip]->Write();
378 m_trunc_eangle[ip]->Write();
379 m_pos_eangle[ip]->Write();
380 m_neg_eangle[ip]->Write();
381 }
382 m_EAngAverdE->Write();
383 m_trunc_EAngAverdE->Write();
384 m_pos_EAngAverdE->Write();
385 m_neg_EAngAverdE->Write();
386
387 TTree* entracalib = new TTree("entracalib","entracalib");
388 entracalib->Branch("1denangle", denangle, "denangle[100]/D");
389 entracalib->Branch("1denangle_entry", denangle_entry, "denangle_entry[1]/I");
390 entracalib->Fill();
391 entracalib->
Write();
392
393 TTree* ddgcalib = new TTree("ddgcalib", "ddgcalib");
394 ddgcalib ->
Branch(
"hits", entryNo,
"entryNo[100]/D");
395 ddgcalib ->
Branch(
"truncmean", trunc_mean,
"trunc_mean[100]/D");
396 ddgcalib ->
Branch(
"truncsigma", trunc_sigma,
"trunc_sigma[100]/D");
397 ddgcalib ->
Branch(
"fitmean", fitmean,
"fitmean[100]/D");
398 ddgcalib ->
Branch(
"fitmeanerr", fitmeanerr,
"fitmeanerr[100]/D");
399 ddgcalib ->
Branch(
"chi", fitsigma,
"fitsigma[100]/D");
400 ddgcalib ->
Branch(
"gain", gain,
"gain[100]/D");
401 ddgcalib ->
Branch(
"truncgain", trunc_gain,
"trunc_gain[100]/D");
402 ddgcalib ->
Branch(
"chisq", chisq,
"chisq[100]/D");
403 ddgcalib ->
Branch(
"pos_hits", pos_entryNo,
"pos_entryNo[100]/D");
404 ddgcalib ->
Branch(
"pos_mean", pos_mean,
"pos_mean[100]/D");
405 ddgcalib ->
Branch(
"pos_sigma", pos_sigma,
"pos_sigma[100]/D");
406 ddgcalib ->
Branch(
"pos_fitmean", pos_fitmean,
"pos_fitmean[100]/D");
407 ddgcalib ->
Branch(
"pos_fitmeanerr", pos_fitmeanerr,
"pos_fitmeanerr[100]/D");
408 ddgcalib ->
Branch(
"pos_chi", pos_fitsigma,
"pos_fitsigma[100]/D");
409 ddgcalib ->
Branch(
"pos_gain", pos_gain,
"pos_gain[100]/D");
410 ddgcalib ->
Branch(
"pos_chisq", pos_chisq,
"pos_chisq[100]/D");
411 ddgcalib ->
Branch(
"neg_hits", neg_entryNo,
"neg_entryNo[100]/D");
412 ddgcalib ->
Branch(
"neg_mean", neg_mean,
"neg_mean[100]/D");
413 ddgcalib ->
Branch(
"neg_sigma", neg_sigma,
"neg_sigma[100]/D");
414 ddgcalib ->
Branch(
"neg_fitmean", neg_fitmean,
"neg_fitmean[100]/D");
415 ddgcalib ->
Branch(
"neg_fitmeanerr", neg_fitmeanerr,
"neg_fitmeanerr[100]/D");
416 ddgcalib ->
Branch(
"neg_chi", neg_fitsigma,
"neg_fitsigma[100]/D");
417 ddgcalib ->
Branch(
"neg_gain", neg_gain,
"neg_gain[100]/D");
418 ddgcalib ->
Branch(
"neg_chisq", neg_chisq,
"neg_chisq[100]/D");
419 ddgcalib ->
Branch(
"Ip_eangle", Ip_eangle,
"Ip_eangle[100]/D");
420 ddgcalib ->
Branch(
"eangle", eangle,
"eangle[100]/D");
424
425 TCanvas c1("c1", "canvas", 500, 400);
427 m_EAngAverdE->Draw();
429 m_trunc_EAngAverdE->Draw();
431 m_pos_EAngAverdE->Draw();
433 m_neg_EAngAverdE->Draw();
436 {
437 m_eangle[ip]->Draw();
439 }
441 {
442 m_trunc_eangle[ip]->Draw();
444 }
446 {
447 m_pos_eangle[ip]->Draw();
449 }
451 {
452 m_neg_eangle[ip]->Draw();
454 }
456
458 {
459 delete m_eangle[ip];
460 delete m_trunc_eangle[ip];
461 delete m_pos_eangle[ip];
462 delete m_neg_eangle[ip];
463 }
464 delete m_EAngAverdE;
465 delete m_trunc_EAngAverdE;
466 delete m_pos_EAngAverdE;
467 delete m_neg_EAngAverdE;
468
469}
curve Branch("CurveSize",&CurveSize,"CurveSize/I")
DOUBLE_PRECISION count[3]