Changeset 2904 for trunk/MagicSoft/Mars/mcalib/MHCalibrationPixel.cc
- Timestamp:
- 01/24/04 01:52:51 (21 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/mcalib/MHCalibrationPixel.cc
r2885 r2904 41 41 #include <TCanvas.h> 42 42 #include <TPaveText.h> 43 #include <TText.h> 43 44 44 45 #include "MLog.h" … … 56 57 : fPixId(-1), 57 58 fTotalEntries(0), 58 fHiGains(NULL), 59 fLoGains(NULL), 59 fHChargeHiGain(NULL), 60 fHTimeHiGain(NULL), 61 fHChargevsNHiGain(NULL), 62 fHChargeLoGain(NULL), 63 fHTimeLoGain(NULL), 64 fHChargevsNLoGain(NULL), 60 65 fChargeGausFit(NULL), 61 66 fTimeGausFit(NULL), 62 67 fHivsLoGain(NULL), 63 68 fFitLegend(NULL), 64 fLowerFitRange(- 2000.),65 fChargeFirstHiGain(- 2000.5),66 fChargeLastHiGain( 9999.5),67 fChargeNbinsHiGain( 12000),68 fChargeFirstLoGain(- 2000.5),69 fLowerFitRange(-100.), 70 fChargeFirstHiGain(-100.5), 71 fChargeLastHiGain(1999.5), 72 fChargeNbinsHiGain(2100), 73 fChargeFirstLoGain(-100.5), 69 74 fChargeLastLoGain(9999.5), 70 fChargeNbinsLoGain(1 200),75 fChargeNbinsLoGain(1010), 71 76 fChargeChisquare(-1.), 72 77 fChargeProb(-1.), … … 81 86 fTimeLowerFitRangeLoGain(0), 82 87 fTimeUpperFitRangeLoGain(0), 83 fUseLoGain(kFALSE),84 fFitOK(kFALSE),85 88 fOffset(0.), 86 89 fSlope(0.) … … 111 114 Int_t ntbins = 16; 112 115 113 fHTimeHiGain = new TH1 I("HTimeHiGain","Distribution of Mean Arrival Hi Gain Times Pixel ",116 fHTimeHiGain = new TH1F("HTimeHiGain","Distribution of Mean Arrival Hi Gain Times Pixel ", 114 117 ntbins,tfirst,tlast); 115 118 fHTimeHiGain->SetXTitle("Mean Arrival Times [Hi Gain FADC slice nr]"); … … 117 120 fHTimeHiGain->SetDirectory(NULL); 118 121 119 fHTimeLoGain = new TH1 I("HTimeLoGain","Distribution of Mean Arrival Lo Gain Times Pixel ",122 fHTimeLoGain = new TH1F("HTimeLoGain","Distribution of Mean Arrival Lo Gain Times Pixel ", 120 123 ntbins,tfirst,tlast); 121 124 fHTimeLoGain->SetXTitle("Mean Arrival Times [Lo Gain FADC slice nr]"); … … 170 173 delete fHivsLoGain; 171 174 172 173 } 174 175 const Double_t MHCalibrationPixel::GetArea() const 176 { 177 return fChargeGausFit->GetParameter(0); 178 } 179 180 const Double_t MHCalibrationPixel::GetAreaErr() const 181 { 182 return fChargeGausFit->GetParError(0); 183 } 184 185 Bool_t MHCalibrationPixel::IsEmpty() 175 } 176 177 Bool_t MHCalibrationPixel::IsEmpty() const 186 178 { 187 179 return !(fHChargeHiGain->GetEntries() || fHChargeLoGain->GetEntries()); 188 180 } 189 181 182 Bool_t MHCalibrationPixel::IsUseLoGain() const 183 { 184 return TESTBIT(fFlags,kUseLoGain); 185 } 186 187 Bool_t MHCalibrationPixel::IsFitOK() const 188 { 189 return TESTBIT(fFlags,kFitOK); 190 } 191 190 192 Bool_t MHCalibrationPixel::FillChargeLoGain(Float_t q) 191 193 { … … 193 195 } 194 196 195 Bool_t MHCalibrationPixel::FillTimeLoGain( Int_t t)197 Bool_t MHCalibrationPixel::FillTimeLoGain(Float_t t) 196 198 { 197 199 return (fHTimeLoGain->Fill(t) > -1); … … 205 207 Bool_t MHCalibrationPixel::FillChargeHiGain(Float_t q) 206 208 { 207 return (fHChargeHiGain->Fill(q) 208 } 209 210 Bool_t MHCalibrationPixel::FillTimeHiGain( Int_t t)211 { 212 return (fHTimeHiGain->Fill(t) 209 return (fHChargeHiGain->Fill(q) > -1); 210 } 211 212 Bool_t MHCalibrationPixel::FillTimeHiGain(Float_t t) 213 { 214 return (fHTimeHiGain->Fill(t) > -1); 213 215 } 214 216 … … 285 287 286 288 289 Bool_t MHCalibrationPixel::SetupFill(const MParList *plist) 290 { 291 292 fHChargeHiGain->Reset(); 293 fHTimeHiGain->Reset(); 294 fHChargeLoGain->Reset(); 295 fHTimeLoGain->Reset(); 296 297 return kTRUE; 298 } 299 300 287 301 void MHCalibrationPixel::Reset() 288 302 { … … 293 307 294 308 for (Int_t i = 0; i < 16; i++) 295 fHTimeHiGain->SetBinContent(i, 1.e-20); 296 297 fChargeLastHiGain = 9999.5; 298 299 fHChargeHiGain->GetXaxis()->SetRangeUser(0.,fChargeLastHiGain); 309 fHTimeHiGain->SetBinContent(i, 1.e-20); 310 311 fChargeFirstHiGain = -100.5; 312 fChargeLastHiGain = 1999.5; 313 314 fHChargeHiGain->GetXaxis()->UnZoom(); 300 315 301 316 for (Int_t i = fHChargeLoGain->FindBin(fChargeFirstLoGain); … … 306 321 fHTimeLoGain->SetBinContent(i, 1.e-20); 307 322 323 fChargeFirstLoGain = -100.5; 308 324 fChargeLastLoGain = 9999.5; 309 325 310 fHChargeLoGain->GetXaxis()-> SetRangeUser(0.,fChargeLastLoGain);326 fHChargeLoGain->GetXaxis()->UnZoom(); 311 327 312 328 return; … … 319 335 if (fHChargeHiGain->Integral() > fHChargeLoGain->Integral()) 320 336 { 321 fUseLoGain = kFALSE;337 CLRBIT(fFlags,kUseLoGain); 322 338 return kFALSE; 323 339 } 324 340 else 325 341 { 326 fUseLoGain = kTRUE;342 SETBIT(fFlags,kUseLoGain); 327 343 return kTRUE; 328 344 } 329 345 } 330 346 331 void MHCalibrationPixel::SetPointInGraph(Float_t qhi,Float_t qlo)347 Bool_t MHCalibrationPixel::FillPointInGraph(Float_t qhi,Float_t qlo) 332 348 { 333 349 … … 337 353 fHiGains->AddAt(qhi,fTotalEntries-1); 338 354 fLoGains->AddAt(qlo,fTotalEntries-1); 355 356 return kTRUE; 339 357 340 358 } … … 350 368 fFitLegend = new TPaveText(0.05,0.05,0.95,0.95); 351 369 352 if ( fFitOK)370 if (IsFitOK()) 353 371 fFitLegend->SetFillColor(80); 354 372 else … … 360 378 const TString line1 = 361 379 Form("Mean: Q_{#mu} = %2.2f #pm %2.2f",fChargeMean,fChargeMeanErr); 362 363 fFitLegend->AddText(line1); 364 380 TText *t1 = fFitLegend->AddText(line1); 381 t1->SetBit(kCanDelete); 365 382 366 383 const TString line4 = 367 384 Form("Sigma: #sigma_{Q} = %2.2f #pm %2.2f",fChargeSigma,fChargeSigmaErr); 368 369 fFitLegend->AddText(line4); 370 385 TText *t2 = fFitLegend->AddText(line4); 386 t2->SetBit(kCanDelete); 371 387 372 388 const TString line7 = 373 389 Form("#chi^{2} / N_{dof}: %4.2f / %3i",fChargeChisquare,fChargeNdf); 374 375 fFitLegend->AddText(line7); 376 390 TText *t3 = fFitLegend->AddText(line7); 391 t3->SetBit(kCanDelete); 377 392 378 393 const TString line8 = 379 394 Form("Probability: %4.3f ",fChargeProb); 380 381 fFitLegend->AddText(line8); 382 383 if (fFitOK) 384 fFitLegend->AddText("Result of the Fit: OK"); 395 TText *t4 = fFitLegend->AddText(line8); 396 t4->SetBit(kCanDelete); 397 398 if (IsFitOK()) 399 { 400 TText *t5 = fFitLegend->AddText("Result of the Fit: OK"); 401 t5->SetBit(kCanDelete); 402 } 385 403 else 386 fFitLegend->AddText("Result of the Fit: NOT OK"); 387 404 { 405 TText *t6 = fFitLegend->AddText("Result of the Fit: NOT OK"); 406 t6->SetBit(kCanDelete); 407 } 408 388 409 fFitLegend->SetBit(kCanDelete); 389 410 fFitLegend->Draw(); 390 411 391 412 } 413 414 415 TObject *MHCalibrationPixel::DrawClone(Option_t *option) const 416 { 417 418 gROOT->SetSelectedPad(NULL); 419 420 MHCalibrationPixel *newobj = (MHCalibrationPixel*)Clone(); 421 422 if (!newobj) 423 return 0; 424 newobj->SetBit(kCanDelete); 425 426 427 if (strlen(option)) 428 newobj->Draw(option); 429 else 430 newobj->Draw(GetDrawOption()); 431 432 return newobj; 433 } 434 392 435 393 436 … … 400 443 401 444 if (!fHivsLoGain) 402 445 FitHiGainvsLoGain(); 403 446 404 447 gStyle->SetOptFit(0); 405 gStyle->SetOptStat(1111111); 448 gStyle->SetOptStat(111111); 449 450 gROOT->SetSelectedPad(NULL); 406 451 407 452 TCanvas *c = MakeDefCanvas(this,600,900); 408 409 gROOT->SetSelectedPad(NULL);410 453 411 454 c->Divide(2,4); … … 420 463 gPad->SetLogy(0); 421 464 422 fHChargeHiGain->Draw Copy(opt);465 fHChargeHiGain->Draw(opt); 423 466 424 467 c->Modified(); 425 468 c->Update(); 426 469 427 if ( fUseLoGain)470 if (IsUseLoGain()) 428 471 { 429 472 … … 436 479 gPad->SetLogy(0); 437 480 438 fHChargeLoGain->Draw Copy(opt);481 fHChargeLoGain->Draw(opt); 439 482 440 483 if (fChargeGausFit) 441 484 { 442 if ( fFitOK)485 if (IsFitOK()) 443 486 fChargeGausFit->SetLineColor(kGreen); 444 487 else 445 488 fChargeGausFit->SetLineColor(kRed); 446 489 447 fChargeGausFit->Draw Copy("same");490 fChargeGausFit->Draw("same"); 448 491 } 449 492 c->Modified(); … … 453 496 gROOT->SetSelectedPad(NULL); 454 497 gStyle->SetOptFit(); 455 fHivsLoGain->Draw("prof");456 498 if (fHivsLoGain) 499 fHivsLoGain->Draw("prof"); 457 500 gPad->Modified(); 458 501 gPad->Update(); … … 466 509 if (fChargeGausFit) 467 510 { 468 if ( fFitOK)511 if (IsFitOK()) 469 512 fChargeGausFit->SetLineColor(kGreen); 470 513 else 471 514 fChargeGausFit->SetLineColor(kRed); 472 515 473 fChargeGausFit->Draw Copy("same");516 fChargeGausFit->Draw("same"); 474 517 } 475 518 … … 482 525 gPad->SetLogy(0); 483 526 484 fHChargeLoGain->Draw Copy(opt);527 fHChargeLoGain->Draw(opt); 485 528 c->Modified(); 486 529 c->Update(); … … 493 536 gROOT->SetSelectedPad(NULL); 494 537 gStyle->SetOptFit(); 495 fHivsLoGain->Draw("prof"); 538 if (fHivsLoGain) 539 fHivsLoGain->Draw("prof"); 496 540 gPad->Modified(); 497 541 gPad->Update(); … … 506 550 gPad->SetTicks(); 507 551 gPad->SetLogy(0); 508 fHTimeHiGain->Draw Copy(opt);552 fHTimeHiGain->Draw(opt); 509 553 c->Modified(); 510 554 c->Update(); 511 555 512 if ( fUseLoGain)556 if (IsUseLoGain()) 513 557 { 514 558 … … 516 560 gPad->SetTicks(); 517 561 gPad->SetLogy(0); 518 fHTimeLoGain->Draw Copy(opt);562 fHTimeLoGain->Draw(opt); 519 563 c->Modified(); 520 564 c->Update(); … … 527 571 fTimeGausFit->SetLineColor(kGreen); 528 572 529 fTimeGausFit->Draw Copy("same");573 fTimeGausFit->Draw("same"); 530 574 c->Modified(); 531 575 c->Update(); … … 541 585 fTimeGausFit->SetLineColor(kGreen); 542 586 543 fTimeGausFit->Draw Copy("same");587 fTimeGausFit->Draw("same"); 544 588 c->Modified(); 545 589 c->Update(); … … 549 593 gPad->SetTicks(); 550 594 gPad->SetLogy(0); 551 fHTimeLoGain->Draw Copy(opt);595 fHTimeLoGain->Draw(opt); 552 596 c->Modified(); 553 597 c->Update(); … … 559 603 c->cd(7); 560 604 gPad->SetTicks(); 561 fHChargevsNHiGain->Draw Copy(opt);605 fHChargevsNHiGain->Draw(opt); 562 606 c->Modified(); 563 607 c->Update(); … … 565 609 c->cd(8); 566 610 gPad->SetTicks(); 567 fHChargevsNLoGain->Draw Copy(opt);611 fHChargevsNLoGain->Draw(opt); 568 612 c->Modified(); 569 613 c->Update(); 570 614 571 615 return; 572 616 } 573 617 … … 575 619 { 576 620 621 *fLog << inf << "Fit Hi Gain vs Lo Gain " << endl; 622 577 623 if (fHivsLoGain) 624 return; 625 626 if ((!fHiGains) || (!fLoGains) || (fHiGains->GetSize() == 0) || (fLoGains->GetSize() == 0)) 578 627 return; 579 628 … … 587 636 titleHiLoGain += fPixId; 588 637 fHivsLoGain->SetName(titleHiLoGain.Data()); 589 590 638 591 639 for (Int_t i=0;i<fTotalEntries;i++) 592 640 fHivsLoGain->Fill(fHiGains->At(i),fLoGains->At(i),1); 593 641 594 fHivsLoGain->Fit("pol1","rq","",fHivsLoGain->GetMean()-2.5*fHivsLoGain->GetRMS(),fHivsLoGain->GetMean()+2.*fHivsLoGain->GetRMS()); 642 fHivsLoGain->Fit("pol1","rq","",fHivsLoGain->GetMean()-2.5*fHivsLoGain->GetRMS(), 643 fHivsLoGain->GetMean()+2.0*fHivsLoGain->GetRMS()); 595 644 596 645 fOffset = fHivsLoGain->GetFunction("pol1")->GetParameter(0); … … 772 821 if (fChargeProb < gkProbLimit) 773 822 { 774 *fLog << warn << "WARNING: Fit Probability " << fChargeProb775 << " is smaller than the allowed value: " << gkProbLimit << endl;776 fFitOK = kFALSE;823 // *fLog << warn << "WARNING: Fit Probability " << fChargeProb 824 // << " is smaller than the allowed value: " << gkProbLimit << endl; 825 CLRBIT(fFlags,kFitOK); 777 826 return kFALSE; 778 827 } 779 828 780 fFitOK = kTRUE;829 SETBIT(fFlags,kFitOK); 781 830 return kTRUE; 782 831 } … … 852 901 if (fChargeProb < gkProbLimit) 853 902 { 854 *fLog << warn << "WARNING: Fit Probability " << fChargeProb855 << " is smaller than the allowed value: " << gkProbLimit << endl;856 fFitOK = kFALSE;903 // *fLog << warn << "WARNING: Fit Probability " << fChargeProb 904 // << " is smaller than the allowed value: " << gkProbLimit << endl; 905 CLRBIT(fFlags,kFitOK); 857 906 return kFALSE; 858 907 } 859 908 860 861 fFitOK = kTRUE; 909 SETBIT(fFlags,kFitOK); 862 910 863 911 return kTRUE;
Note:
See TracChangeset
for help on using the changeset viewer.