Changeset 3056 for trunk/MagicSoft/Mars/mcalib/MHCalibrationPixel.cc
- Timestamp:
- 02/08/04 20:52:18 (21 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/mcalib/MHCalibrationPixel.cc
r3051 r3056 42 42 #include <TPaveText.h> 43 43 #include <TText.h> 44 #include <TGraph.h> 45 46 #include "MFFT.h" 44 47 45 48 #include "MLog.h" … … 52 55 const Int_t MHCalibrationPixel::fChargeNbinsHiGain = 2100; 53 56 const Int_t MHCalibrationPixel::fChargeNbinsLoGain = 1010; 54 const Int_t MHCalibrationPixel::fChargevsNbins = 5000; 55 const Int_t MHCalibrationPixel::fAbsTimeNbins = 32; 57 const Int_t MHCalibrationPixel::fAbsTimeNbins = 16; 56 58 const Axis_t MHCalibrationPixel::fAbsTimeFirst = - 0.25; 57 59 const Axis_t MHCalibrationPixel::fAbsTimeLast = 15.75; 58 const Int_t MHCalibrationPixel::fRelTimeNbins = 900;59 const Axis_t MHCalibrationPixel::fRelTimeFirst = -13.;60 const Axis_t MHCalibrationPixel::fRelTimeLast = 13.;61 60 const Float_t MHCalibrationPixel::fProbLimit = 0.001; 62 61 const Int_t MHCalibrationPixel::fNDFLimit = 5; 63 62 63 const Axis_t MHCalibrationPixel::fNyquistFreq = 1.0; 64 const Axis_t MHCalibrationPixel::fMinFreq = 0.; 65 const Int_t MHCalibrationPixel::fPSDNbins = 30; 66 64 67 // -------------------------------------------------------------------------- 65 68 // … … 69 72 : fPixId(-1), 70 73 fHivsLoGain(NULL), 74 fPSDHiGain(NULL), 75 fPSDLoGain(NULL), 76 fChargeGausFit(NULL), 71 77 fHPSD(NULL), 72 fChargeGausFit(NULL), 73 fRelTimeGausFit(NULL), 74 fFitLegend(NULL) 78 fPSDExpFit(NULL), 79 fChargeXaxis(NULL), 80 fPSDXaxis(NULL), 81 fFitLegend(NULL), 82 fCurrentSize(1024) 75 83 { 76 84 77 85 fName = name ? name : "MHCalibrationPixel"; 78 fTitle = title ? title : "Fill the accumulated charges and timesof all events and perform fits";86 fTitle = title ? title : "Fill the accumulated charges of all events and perform fits"; 79 87 80 88 fChargeFirstHiGain = -100.5; … … 110 118 fHAbsTimeLoGain->SetYTitle("Nr. of events"); 111 119 112 // Relative Times113 fHRelTimeHiGain = new TH1F("HRelTimeHiGain","Distribution of Relative Arrival Times High Gain Pixel ",114 fRelTimeNbins,fRelTimeFirst,fRelTimeLast);115 fHRelTimeLoGain = new TH1F("HRelTimeLoGain","Distribution of Relative Arrival Time Low Gain Pixel ",116 fRelTimeNbins,fRelTimeFirst,fRelTimeLast);117 118 fHRelTimeHiGain->SetXTitle("Relative Arrival Times [Hi Gain FADC slice nr]");119 fHRelTimeLoGain->SetXTitle("Relative Arrival Times [Lo Gain FADC slice nr]");120 121 fHRelTimeHiGain->SetYTitle("Nr. of events");122 fHRelTimeLoGain->SetYTitle("Nr. of events");123 124 // We define a reasonable number and later enlarge it if necessary125 fHChargevsNHiGain = new TH1I("HChargevsNHiGain","Sum of Hi Gain Charges vs. Event Number Pixel ",126 fChargevsNbins,-0.5,(Axis_t)fChargevsNbins - 0.5);127 fHChargevsNLoGain = new TH1I("HChargevsNLoGain","Sum of Lo Gain Charges vs. Event Number Pixel ",128 fChargevsNbins,-0.5,(Axis_t)fChargevsNbins - 0.5);129 130 fHChargevsNHiGain->SetXTitle("Event Nr.");131 fHChargevsNLoGain->SetXTitle("Event Nr.");132 133 fHChargevsNHiGain->SetYTitle("Sum of Hi Gain FADC slices");134 fHChargevsNLoGain->SetYTitle("Sum of Lo Gain FADC slices");135 120 136 121 fHChargeHiGain->SetDirectory(NULL); … … 138 123 fHAbsTimeHiGain->SetDirectory(NULL); 139 124 fHAbsTimeLoGain->SetDirectory(NULL); 140 fHRelTimeHiGain->SetDirectory(NULL); 141 fHRelTimeLoGain->SetDirectory(NULL); 142 fHChargevsNHiGain->SetDirectory(NULL); 143 fHChargevsNLoGain->SetDirectory(NULL); 144 145 fHiGains = new TArrayF(); 146 fLoGains = new TArrayF(); 125 126 fHiGains = new TArrayF(fCurrentSize); 127 fLoGains = new TArrayF(fCurrentSize); 147 128 148 129 Clear(); … … 155 136 delete fHChargeHiGain; 156 137 delete fHAbsTimeHiGain; 157 delete fHRelTimeHiGain;158 delete fHChargevsNHiGain;159 138 160 139 delete fHChargeLoGain; 161 140 delete fHAbsTimeLoGain; 162 delete fHRelTimeLoGain;163 delete fHChargevsNLoGain;164 141 165 142 delete fHiGains; … … 168 145 if (fChargeGausFit) 169 146 delete fChargeGausFit; 170 if (fRelTimeGausFit) 171 delete fRelTimeGausFit; 147 if (fPSDExpFit) 148 delete fPSDExpFit; 149 if (fHPSD) 150 delete fHPSD; 172 151 if (fFitLegend) 173 152 delete fFitLegend; 174 153 if (fHivsLoGain) 175 154 delete fHivsLoGain; 155 if (fChargeXaxis) 156 delete fChargeXaxis; 157 if (fPSDXaxis) 158 delete fPSDXaxis; 176 159 } 177 160 … … 181 164 182 165 fTotalEntries = 0; 166 fCurrentSize = 1024; 183 167 184 168 fChargeFirstHiGain = -100.5; … … 191 175 fChargeNdf = -1; 192 176 193 fRelTimeChisquare = -1.;194 fRelTimeProb = -1.;195 fRelTimeNdf = -1;196 fRelTimeMean = -1.;197 fRelTimeSigma = -1.;198 199 fRelTimeLowerFitRangeHiGain = -99.;200 fRelTimeUpperFitRangeHiGain = -99.;201 fRelTimeLowerFitRangeLoGain = -99.;202 fRelTimeUpperFitRangeLoGain = -99.;203 204 177 fAbsTimeFirstHiGain = -1.; 205 178 fAbsTimeFirstLoGain = -1.; … … 216 189 if (fChargeGausFit) 217 190 delete fChargeGausFit; 218 if (fRelTimeGausFit) 219 delete fRelTimeGausFit; 191 if (fPSDExpFit) 192 delete fPSDExpFit; 193 if (fHPSD) 194 delete fHPSD; 220 195 if (fFitLegend) 221 196 delete fFitLegend; 222 197 if (fHivsLoGain) 223 198 delete fHivsLoGain; 224 if (fHPSD) 225 delete fHPSD; 199 if (fChargeXaxis) 200 delete fChargeXaxis; 201 if (fPSDXaxis) 202 delete fPSDXaxis; 203 if (fPSDHiGain) 204 delete fPSDHiGain; 205 if (fPSDLoGain) 206 delete fPSDLoGain; 226 207 227 208 CLRBIT(fFlags,kUseLoGain); 228 209 CLRBIT(fFlags,kChargeFitOK); 229 CLRBIT(fFlags,k TimeFitOK);210 CLRBIT(fFlags,kOscillating); 230 211 231 212 return; … … 240 221 fHChargeHiGain->Reset(); 241 222 fHChargeLoGain->Reset(); 223 242 224 fHAbsTimeHiGain->Reset(); 243 225 fHAbsTimeLoGain->Reset(); 244 fHRelTimeHiGain->Reset(); 245 fHRelTimeLoGain->Reset(); 246 fHChargevsNHiGain->Reset(); 247 fHChargevsNLoGain->Reset(); 248 249 fHiGains->Reset(); 250 fLoGains->Reset(); 226 227 fHiGains->Set(1024); 228 fLoGains->Set(1024); 229 230 fHiGains->Reset(0.); 231 fLoGains->Reset(0.); 251 232 252 233 } … … 261 242 262 243 244 Bool_t MHCalibrationPixel::CheckOscillations() 245 { 246 247 if (fPSDExpFit) 248 return IsOscillating(); 249 250 MFFT fourier; 251 252 fPSDLoGain = fourier.PowerSpectrumDensity(fLoGains); 253 fPSDHiGain = fourier.PowerSpectrumDensity(fHiGains); 254 255 Int_t entries; 256 TArrayF *array; 257 258 if (IsUseLoGain()) 259 { 260 fHPSD = new TH1F(Form("%s%d","HPSD",fPixId), 261 Form("%s%s","Power Spectrum Density Projection ","LoGain"), 262 fPSDNbins,fMinFreq,fNyquistFreq); 263 264 array = fPSDLoGain; 265 } 266 else 267 { 268 269 fHPSD = new TH1F(Form("%s%d","HPSD",fPixId), 270 Form("%s%s","Power Spectrum Density Projection ","HiGain"), 271 fPSDNbins,fMinFreq,fNyquistFreq); 272 273 array = fPSDLoGain; 274 } 275 276 entries = array->GetSize(); 277 278 for (Int_t i=0;i<entries;i++) 279 fHPSD->Fill(array->At(i)); 280 281 // 282 // First guesses for the fit (should be as close to reality as possible, 283 // 284 const Double_t area_guess = entries*10.; 285 286 fPSDExpFit = new TF1(Form("%s%d","PSDExpFit",fPixId),"[0]*exp(-[1]*x)",0.,1.); 287 288 fPSDExpFit->SetParameters(entries,10.); 289 fPSDExpFit->SetParNames("Area","slope"); 290 fPSDExpFit->SetParLimits(0,0.,3.*area_guess); 291 fPSDExpFit->SetParLimits(1,5.,20.); 292 fPSDExpFit->SetRange(fMinFreq,fNyquistFreq); 293 294 fHPSD->Fit(fPSDExpFit,"RQL0"); 295 296 fPSDProb = fPSDExpFit->GetProb(); 297 298 if (fPSDProb < gkProbLimit) 299 { 300 SETBIT(fFlags,kOscillating); 301 return kTRUE; 302 } 303 304 CLRBIT(fFlags,kOscillating); 305 306 return kFALSE; 307 } 308 309 void MHCalibrationPixel::CreatePSDXaxis(Int_t n) 310 { 311 312 if (fPSDXaxis) 313 return; 314 315 fPSDXaxis = new TArrayF(n); 316 317 for (Int_t i=0;i<n;i++) 318 fPSDXaxis->AddAt((Float_t)i,i); 319 } 320 321 void MHCalibrationPixel::CreateChargeXaxis(Int_t n) 322 { 323 324 if (!fChargeXaxis) 325 { 326 fChargeXaxis = new TArrayF(n); 327 for (Int_t i=0;i<n;i++) 328 fChargeXaxis->AddAt((Float_t)i,i); 329 return; 330 } 331 332 if (fChargeXaxis->GetSize() == n) 333 return; 334 335 const Int_t diff = fChargeXaxis->GetSize()-n; 336 fChargeXaxis->Set(n); 337 if (diff < 0) 338 for (Int_t i=n;i<n+diff;i++) 339 fChargeXaxis->AddAt((Float_t)i,i); 340 } 341 342 void MHCalibrationPixel::CutArrayBorder(TArrayF *array) 343 { 344 345 Int_t i; 346 347 for (i=array->GetSize()-1;i>=0;i--) 348 if (array->At(i) != 0) 349 { 350 array->Set(i+1); 351 break; 352 } 353 } 354 355 356 263 357 Bool_t MHCalibrationPixel::IsEmpty() const 264 358 { … … 276 370 } 277 371 278 Bool_t MHCalibrationPixel::IsTimeFitOK() const 279 { 280 return TESTBIT(fFlags,kTimeFitOK); 372 Bool_t MHCalibrationPixel::IsOscillating() 373 { 374 375 if (fPSDExpFit) 376 return TESTBIT(fFlags,kOscillating); 377 378 return CheckOscillations(); 379 281 380 } 282 381 … … 291 390 } 292 391 293 Bool_t MHCalibrationPixel::FillRelTimeLoGain(Float_t t)294 {295 return (fHRelTimeLoGain->Fill(t) > -1);296 }297 298 Bool_t MHCalibrationPixel::FillChargevsNLoGain(Float_t q, Int_t n)299 {300 return (fHChargevsNLoGain->Fill(n,q) > -1);301 }302 303 392 Bool_t MHCalibrationPixel::FillChargeHiGain(Float_t q) 304 393 { … … 309 398 { 310 399 return (fHAbsTimeHiGain->Fill(t) > -1); 311 }312 313 Bool_t MHCalibrationPixel::FillRelTimeHiGain(Float_t t)314 {315 return (fHRelTimeHiGain->Fill(t) > -1);316 }317 318 Bool_t MHCalibrationPixel::FillChargevsNHiGain(Float_t q, Int_t n)319 {320 return (fHChargevsNHiGain->Fill(n,q) > -1);321 400 } 322 401 … … 333 412 fHChargeHiGain->SetName( Form("%s%d",fHChargeHiGain->GetName(), id)); 334 413 fHAbsTimeHiGain->SetName( Form("%s%d",fHAbsTimeHiGain->GetName(), id)); 335 fHRelTimeHiGain->SetName( Form("%s%d",fHRelTimeHiGain->GetName(), id));336 fHChargevsNHiGain->SetName(Form("%s%d",fHChargevsNHiGain->GetName(),id));337 414 338 415 // … … 341 418 fHChargeHiGain->SetTitle( Form("%s%d",fHChargeHiGain->GetTitle(), id)); 342 419 fHAbsTimeHiGain->SetTitle( Form("%s%d",fHAbsTimeHiGain->GetTitle(), id)); 343 fHRelTimeHiGain->SetTitle( Form("%s%d",fHRelTimeHiGain->GetTitle(), id));344 fHChargevsNHiGain->SetTitle( Form("%s%d",fHChargevsNHiGain->GetTitle(),id));345 420 346 421 // … … 349 424 fHChargeLoGain->SetName( Form("%s%d",fHChargeLoGain->GetName(),id)); 350 425 fHAbsTimeLoGain->SetName( Form("%s%d",fHAbsTimeLoGain->GetName(),id)); 351 fHRelTimeLoGain->SetName( Form("%s%d",fHRelTimeLoGain->GetName(),id));352 fHChargevsNLoGain->SetName( Form("%s%d",fHChargevsNLoGain->GetName(),id));353 426 354 427 // … … 357 430 fHChargeLoGain->SetTitle( Form("%s%d",fHChargeLoGain->GetTitle(),id)); 358 431 fHAbsTimeLoGain->SetTitle( Form("%s%d",fHAbsTimeLoGain->GetTitle(),id)); 359 fHRelTimeLoGain->SetTitle( Form("%s%d",fHRelTimeLoGain->GetTitle(),id));360 fHChargevsNLoGain->SetTitle( Form("%s%d",fHChargevsNLoGain->GetTitle(),id));361 432 362 433 fPixId = id; 363 434 } 364 435 365 }366 367 368 Bool_t MHCalibrationPixel::SetupFill(const MParList *plist)369 {370 371 Reset();372 373 return kTRUE;374 436 } 375 437 … … 390 452 } 391 453 392 Bool_t MHCalibrationPixel::FillPointInGraph(Float_t qhi,Float_t qlo) 393 { 394 395 fHiGains->Set(++fTotalEntries); 396 fLoGains->Set(fTotalEntries); 397 398 fHiGains->AddAt(qhi,fTotalEntries-1); 399 fLoGains->AddAt(qlo,fTotalEntries-1); 454 Bool_t MHCalibrationPixel::FillGraphs(Float_t qhi,Float_t qlo) 455 { 456 457 if (fTotalEntries >= fCurrentSize) 458 { 459 fCurrentSize *= 2; 460 461 fHiGains->Set(fCurrentSize); 462 fLoGains->Set(fCurrentSize); 463 } 464 465 fHiGains->AddAt(qhi,fTotalEntries); 466 fLoGains->AddAt(qlo,fTotalEntries); 467 468 fTotalEntries++; 400 469 401 470 return kTRUE; … … 508 577 fHChargeHiGain->Draw(opt); 509 578 510 c->Modified();511 c->Update();512 513 579 if (IsUseLoGain()) 514 580 { … … 528 594 } 529 595 530 c->Modified();531 c->Update();532 533 596 c->cd(3); 534 597 gROOT->SetSelectedPad(NULL); … … 536 599 if (fHivsLoGain) 537 600 fHivsLoGain->Draw("prof"); 538 gPad->Modified(); 539 gPad->Update(); 540 601 541 602 c->cd(4); 542 603 DrawLegend(); 543 544 604 } 545 605 else … … 558 618 559 619 fHChargeLoGain->Draw(opt); 560 c->Modified(); 561 c->Update(); 562 620 563 621 c->cd(3); 564 622 DrawLegend(); … … 570 628 if (fHivsLoGain) 571 629 fHivsLoGain->Draw("prof"); 572 gPad->Modified();573 gPad->Update();574 630 } 631 632 c->cd(5); 633 gPad->SetTicks(); 634 fHAbsTimeHiGain->Draw(opt); 635 636 c->cd(6); 637 gPad->SetTicks(); 638 fHAbsTimeLoGain->Draw(opt); 639 640 CutArrayBorder(fHiGains); 641 CreateChargeXaxis(fHiGains->GetSize()); 642 643 c->cd(7); 644 gPad->SetTicks(); 645 TGraph *gr1 = new TGraph(fChargeXaxis->GetSize(), 646 fChargeXaxis->GetArray(), 647 fHiGains->GetArray()); 648 gr1->SetTitle("Evolution of HiGain charges with event number"); 649 gr1->SetBit(kCanDelete); 650 gr1->Draw("AL"); 651 652 CutArrayBorder(fLoGains); 653 CreateChargeXaxis(fHiGains->GetSize()); 654 655 c->cd(8); 656 gPad->SetTicks(); 657 TGraph *gr2 = new TGraph(fChargeXaxis->GetSize(), 658 fChargeXaxis->GetArray(), 659 fLoGains->GetArray()); 660 gr2->SetTitle("Evolution of HiGain charges with event number"); 661 gr2->SetBit(kCanDelete); 662 gr2->Draw("AL"); 575 663 576 664 c->Modified(); 577 665 c->Update(); 578 666 579 c->cd(5); 580 gStyle->SetOptStat(1111111); 581 582 gPad->SetTicks(); 583 gPad->SetLogy(0); 584 fHRelTimeHiGain->Draw(opt); 667 c->cd(9); 668 669 TArrayF *array; 670 671 if(IsUseLoGain()) 672 { 673 if (!fPSDLoGain) 674 return; 675 array = fPSDLoGain; 676 } 677 else 678 { 679 if (!fPSDHiGain) 680 return; 681 array = fPSDHiGain; 682 } 683 684 if (!fPSDXaxis) 685 CreatePSDXaxis(array->GetSize()); 686 687 TGraph *gr3 = new TGraph(fPSDXaxis->GetSize(),fPSDXaxis->GetArray(),array->GetArray()); 688 gr3->SetTitle("Power Spectrum Density"); 689 gr3->SetBit(kCanDelete); 690 gr3->Draw("AL"); 691 585 692 c->Modified(); 586 693 c->Update(); 587 694 588 if (IsUseLoGain()) 589 { 590 591 c->cd(6); 592 gPad->SetTicks(); 593 gPad->SetLogy(0); 594 fHRelTimeLoGain->Draw(opt); 595 c->Modified(); 596 c->Update(); 597 598 if (fRelTimeGausFit) 599 { 600 fRelTimeGausFit->SetLineColor(IsTimeFitOK() ? kGreen : kRed); 601 fRelTimeGausFit->Draw("same"); 602 } 603 604 c->Modified(); 605 c->Update(); 606 } 607 else 608 { 609 if (fRelTimeGausFit) 610 { 611 fRelTimeGausFit->SetLineColor(IsTimeFitOK() ? kGreen : kRed); 612 fRelTimeGausFit->Draw("same"); 613 } 614 615 c->Modified(); 616 c->Update(); 617 618 c->cd(6); 619 gPad->SetTicks(); 620 gPad->SetLogy(0); 621 fHRelTimeLoGain->Draw(opt); 622 c->Modified(); 623 c->Update(); 624 625 } 626 c->Modified(); 627 c->Update(); 628 629 c->cd(7); 630 gPad->SetTicks(); 631 fHAbsTimeHiGain->Draw(opt); 632 c->Modified(); 633 c->Update(); 634 635 c->cd(8); 636 gPad->SetTicks(); 637 fHAbsTimeLoGain->Draw(opt); 638 c->Modified(); 639 c->Update(); 640 641 642 c->cd(9); 643 gPad->SetTicks(); 644 fHChargevsNHiGain->Draw(opt); 645 c->Modified(); 646 c->Update(); 647 648 c->cd(10); 649 gPad->SetTicks(); 650 fHChargevsNLoGain->Draw(opt); 651 c->Modified(); 652 c->Update(); 653 654 return; 695 c->cd(10); 696 697 gStyle->SetOptStat(111111); 698 gPad->SetTicks(); 699 700 if (fHPSD->Integral() > 0) 701 gPad->SetLogy(); 702 703 fHPSD->Draw(opt); 704 705 if (fPSDExpFit) 706 { 707 fPSDExpFit->SetLineColor(IsOscillating() ? kRed : kGreen); 708 fPSDExpFit->Draw("same"); 709 } 710 711 c->Modified(); 712 c->Update(); 713 714 return; 655 715 } 656 716 … … 684 744 } 685 745 686 687 Bool_t MHCalibrationPixel::FitTime(Option_t *option)688 {689 690 if (fRelTimeGausFit)691 return kFALSE;692 693 //694 // From the absolute time, we only take the mean and RMS695 //696 fAbsTimeMean = (Float_t)fHAbsTimeHiGain->GetMean();697 fAbsTimeRms = (Float_t)fHAbsTimeHiGain->GetRMS();698 fAbsTimeMeanErr = (Float_t)fAbsTimeRms / TMath::Sqrt(fHAbsTimeHiGain->GetEntries());699 700 if (TESTBIT(fFlags,kUseLoGain))701 {702 fAbsTimeMean = fHAbsTimeLoGain->GetMean();703 fAbsTimeRms = fHAbsTimeLoGain->GetRMS();704 fAbsTimeMeanErr = fAbsTimeRms / TMath::Sqrt(fHAbsTimeLoGain->GetEntries());705 }706 707 //708 // Get the fitting ranges709 //710 Axis_t rmin = fRelTimeLowerFitRangeHiGain;711 Axis_t rmax = fRelTimeUpperFitRangeHiGain;712 TH1F *hist = fHRelTimeHiGain;713 714 if (TESTBIT(fFlags,kUseLoGain))715 {716 rmin = fRelTimeLowerFitRangeLoGain;717 rmax = fRelTimeUpperFitRangeLoGain;718 hist = fHRelTimeLoGain;719 }720 721 const Stat_t entries = hist->Integral("width");722 const Double_t mu_guess = hist->GetBinCenter(hist->GetMaximumBin());723 const Double_t sigma_guess = (rmax - rmin)/2.;724 const Double_t area_guess = 2.*entries/gkSq2Pi/sigma_guess;725 726 TString name = TString("GausRelTime");727 name += fPixId;728 fRelTimeGausFit = new TF1(name.Data(),"gaus",rmin,rmax);729 730 if (!fRelTimeGausFit)731 {732 *fLog << warn << dbginf << "WARNING: Could not create fit function for RelTime fit" << endl;733 return kFALSE;734 }735 736 fRelTimeGausFit->SetParameters(area_guess,mu_guess,sigma_guess);737 fRelTimeGausFit->SetParNames("Area","#mu","#sigma");738 fRelTimeGausFit->SetParLimits(0,0.,5.*area_guess);739 fRelTimeGausFit->SetParLimits(1,rmin,rmax);740 fRelTimeGausFit->SetParLimits(2,0.,(rmax-rmin));741 fRelTimeGausFit->SetRange(rmin,rmax);742 743 hist->Fit(fRelTimeGausFit,option);744 745 //746 // If the fit does not converge, try another one with smaller bounderies747 //748 if (fRelTimeGausFit->GetProb() < 0.001)749 {750 rmin = fRelTimeGausFit->GetParameter(1) - 1.5*fRelTimeGausFit->GetParameter(2);751 rmax = fRelTimeGausFit->GetParameter(1) + 1.5*fRelTimeGausFit->GetParameter(2);752 fRelTimeGausFit->SetRange(rmin,rmax);753 hist->Fit(fRelTimeGausFit,option);754 }755 756 fRelTimeChisquare = fRelTimeGausFit->GetChisquare();757 fRelTimeNdf = fRelTimeGausFit->GetNDF();758 fRelTimeProb = fRelTimeGausFit->GetProb();759 760 fRelTimeMean = fRelTimeGausFit->GetParameter(1);761 fRelTimeSigma = fRelTimeGausFit->GetParameter(2);762 763 fRelTimeMeanErr = fRelTimeGausFit->GetParError(1);764 765 if (TMath::IsNaN(fRelTimeMean) || TMath::IsNaN(fRelTimeSigma))766 {767 CLRBIT(fFlags,kTimeFitOK);768 return kFALSE;769 }770 771 if (TMath::IsNaN(fRelTimeChisquare) || (fRelTimeProb < fProbLimit))772 {773 CLRBIT(fFlags,kTimeFitOK);774 return kFALSE;775 }776 777 SETBIT(fFlags,kTimeFitOK);778 779 return kTRUE;780 781 }782 746 783 747 … … 850 814 851 815 // 816 // From the absolute time, we only take the mean and RMS 817 // 818 fAbsTimeMean = (Float_t)fHAbsTimeHiGain->GetMean(); 819 fAbsTimeRms = (Float_t)fHAbsTimeHiGain->GetRMS(); 820 fAbsTimeMeanErr = (Float_t)fAbsTimeRms / TMath::Sqrt(fHAbsTimeHiGain->GetEntries()); 821 822 if (TESTBIT(fFlags,kUseLoGain)) 823 { 824 fAbsTimeMean = fHAbsTimeLoGain->GetMean(); 825 fAbsTimeRms = fHAbsTimeLoGain->GetRMS(); 826 fAbsTimeMeanErr = fAbsTimeRms / TMath::Sqrt(fHAbsTimeLoGain->GetEntries()); 827 } 828 829 // 852 830 // The fit result is accepted under condition: 853 831 // 1) The results are not nan's … … 880 858 881 859 882 883 884 860 void MHCalibrationPixel::CutAllEdges() 885 861 { 886 862 887 Int_t nbins = 50;863 Int_t nbins = 30; 888 864 889 865 CutEdges(fHChargeHiGain,nbins); … … 899 875 +fHChargeLoGain->GetBinWidth(0); 900 876 901 CutEdges(fHRelTimeHiGain,0);902 903 fRelTimeLowerFitRangeHiGain = fHRelTimeHiGain->GetBinLowEdge(fHRelTimeHiGain->GetXaxis()->GetFirst());904 fRelTimeUpperFitRangeHiGain = fHRelTimeHiGain->GetBinLowEdge(fHRelTimeHiGain->GetXaxis()->GetLast())905 +fHRelTimeHiGain->GetBinWidth(0);906 907 CutEdges(fHRelTimeLoGain,0);908 909 fRelTimeLowerFitRangeLoGain = fHRelTimeLoGain->GetBinLowEdge(fHRelTimeLoGain->GetXaxis()->GetFirst());910 fRelTimeUpperFitRangeLoGain = fHRelTimeLoGain->GetBinLowEdge(fHRelTimeLoGain->GetXaxis()->GetLast())911 +fHRelTimeLoGain->GetBinWidth(0);912 877 913 878 CutEdges(fHAbsTimeHiGain,0); … … 923 888 +fHAbsTimeLoGain->GetBinWidth(0); 924 889 925 CutEdges(fHChargevsNHiGain,0);926 CutEdges(fHChargevsNLoGain,0);927 890 928 891 } … … 939 902 } 940 903 941 void MHCalibrationPixel::PrintTimeFitResult()942 {943 944 *fLog << all << "Results of the Time Slices Fit: " << endl;945 *fLog << all << "Chisquare: " << fRelTimeChisquare << endl;946 *fLog << all << "Ndf: " << fRelTimeNdf << endl;947 *fLog << all << "Probability: " << fRelTimeProb << endl;948 *fLog << all << endl;949 950 }
Note:
See TracChangeset
for help on using the changeset viewer.