Changeset 2790 for trunk/MagicSoft/Mars
- Timestamp:
- 01/13/04 17:29:27 (21 years ago)
- Location:
- trunk/MagicSoft/Mars
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/Changelog
r2789 r2790 9 9 - make Stat Window in option 'proj' bigger 10 10 - add comment line at beginning of Draw() 11 12 * mcalib/MHCalibrationBlindPixel.[h.cc] 13 - add Function DrawClone() 14 - fix bug in calculation of integral (GetIntegral("width")) 15 - fit now with fixed normalization 16 - restrict parameters tighter 17 - declare fit as not valid, if less than 100 events 18 in single photo-electron peak 11 19 12 20 -
trunk/MagicSoft/Mars/mcalib/MHCalibrationBlindPixel.cc
r2734 r2790 27 27 // MHCalibrationBlindPixel // 28 28 // // 29 // Performs all the necessary fits to extract the mean number of photons // 30 // out of the derived light flux // 29 // Performs all the Single Photo-Electron Fit to extract // 30 // the mean number of photons and to derive the light flux // 31 // // 32 // The fit result is accepted under condition that: // 33 // 1) the Probability is greater than gkProbLimit (default 0.001 == 99.7%) // 34 // 2) at least 100 events are in the single Photo-electron peak // 31 35 // // 32 36 ////////////////////////////////////////////////////////////////////////////// … … 83 87 fHBlindPixelCharge->SetYTitle("Nr. of events"); 84 88 fHBlindPixelCharge->Sumw2(); 89 fHBlindPixelCharge->SetDirectory(NULL); 85 90 86 91 Axis_t tfirst = -0.5; … … 92 97 fHBlindPixelTime->SetYTitle("Nr. of events"); 93 98 fHBlindPixelTime->Sumw2(); 99 fHBlindPixelTime->SetDirectory(NULL); 94 100 95 101 // We define a reasonable number and later enlarge it if necessary … … 101 107 fHBlindPixelChargevsN->SetXTitle("Event Nr."); 102 108 fHBlindPixelChargevsN->SetYTitle("Sum of FADC slices"); 103 104 fgSinglePheFitFunc = &gfKto8; 109 fHBlindPixelChargevsN->SetDirectory(NULL); 110 111 fgSinglePheFitFunc = &gfKto4; 105 112 fgSinglePheFitNPar = 5; 106 113 } … … 187 194 188 195 } 196 197 198 TObject *MHCalibrationBlindPixel::DrawClone(Option_t *opt) const 199 { 200 201 //TVirtualPad *pad = gROOT->GetSelectedPad(); 202 TVirtualPad *padsav = gPad; 203 //if (pad) pad->cd(); 204 205 TObject *newobj = Clone(); 206 207 if (!newobj) 208 return 0; 209 210 newobj->Draw(opt); 211 212 if (padsav) 213 padsav->cd(); 214 215 return newobj; 216 } 217 189 218 190 219 … … 317 346 // otherwise the fit goes gaga because of high number of dimensions ... 318 347 // 319 const Stat_t entries = fHBlindPixelCharge->Integral( );348 const Stat_t entries = fHBlindPixelCharge->Integral("width"); 320 349 const Double_t lambda_guess = 0.5; 321 350 const Double_t mu_0_guess = fHBlindPixelCharge->GetBinCenter(fHBlindPixelCharge->GetMaximumBin()); 322 351 const Double_t si_0_guess = 20.; 323 const Double_t mu_1_guess = mu_0_guess + 100.;352 const Double_t mu_1_guess = mu_0_guess + 50.; 324 353 const Double_t si_1_guess = si_0_guess + si_0_guess; 325 354 326 355 fSinglePheFit = new TF1("SinglePheFit",fgSinglePheFitFunc,rmin,rmax,fgSinglePheFitNPar+1); 356 // fSinglePheFit = new TF1("SinglePheFit",fgSinglePheFitFunc,rmin,rmax,fgSinglePheFitNPar+1); 357 // fSinglePheFit->SetParameters(lambda_guess,mu_0_guess,mu_1_guess,si_0_guess,si_1_guess); 327 358 fSinglePheFit->SetParameters(lambda_guess,mu_0_guess,mu_1_guess,si_0_guess,si_1_guess,entries); 359 // fSinglePheFit->SetParNames("#lambda","#mu_0","#mu_1","#sigma_0","#sigma_1"); 328 360 fSinglePheFit->SetParNames("#lambda","#mu_0","#mu_1","#sigma_0","#sigma_1","area"); 329 fSinglePheFit->SetParLimits(0,0.,3.); 330 fSinglePheFit->SetParLimits(1,rmin,rmax); 331 fSinglePheFit->SetParLimits(2,rmin,rmax); 332 fSinglePheFit->SetParLimits(3,1.0,rmax-rmin); 333 fSinglePheFit->SetParLimits(4,1.7,rmax-rmin); 334 fSinglePheFit->SetParLimits(5,0.,1.5*entries); 361 fSinglePheFit->SetParLimits(0,0.,1.); 362 fSinglePheFit->SetParLimits(1,rmin,(rmax-rmin)/1.5); 363 fSinglePheFit->SetParLimits(2,(rmax-rmin)/2.,(rmax-0.05*(rmax-rmin))); 364 fSinglePheFit->SetParLimits(3,1.0,(rmax-rmin)/2.0); 365 fSinglePheFit->SetParLimits(4,1.0,(rmax-rmin)/2.5); 366 // fSinglePheFit->SetParLimits(5,entries/gkSq2Pi,entries/gkSq2Pi); 367 // fSinglePheFit->SetParLimits(5,0.,1.5*entries); 335 368 // 336 369 // Normalize the histogram to facilitate faster fitting of the area 337 // For speed reasons, FKto8is normalized to Sqrt(2 pi).370 // For speed reasons, gfKto4 is normalized to Sqrt(2 pi). 338 371 // Therefore also normalize the histogram to that value 339 372 // 340 // ROOT gives us another nice example of user-unfriendly behavior:341 // Although the normalization of the function fSinglePhe and the342 // Histogram fHBlindPixelCharge agree (!!), the fit does not normalize correctly INTERNALLY343 // in the fitting procedure !!!344 //345 // This has to do with the fact that the internal function histogramming346 // uses 100 bins and does not adapt to the binning of the fitted histogram, unlike PAW does347 // (very important if you use Sumw2, see e.g. ROOTTALK: Mon May 26 1997 - 09:56:03 MEST)348 //349 // So, WE have to adapt to that internal flaw of ROOT:350 //351 // const Int_t npx = fSinglePheFit->GetNpx();352 // const Int_t bins = fHBlindPixelCharge->GetXaxis()->GetLast()-fHBlindPixelCharge->GetXaxis()->GetFirst();353 373 // fHBlindPixelCharge->Scale(gkSq2Pi*(float)bins/npx/entries); 354 355 // 356 // we need this, otherwise, ROOT does not calculate the area correctly 357 // don't ask me why it does not behave correctly, it's one of the nasty 358 // mysteries of ROOT which takes you a whole day to find out :-) 359 // 360 // fSinglePheFit->SetNpx(fChargenbins); 361 362 fHBlindPixelCharge->Fit(fSinglePheFit,opt); 374 // fHBlindPixelCharge->Scale(gkSq2Pi/entries); 375 Float_t norm = entries/gkSq2Pi; 376 // norm *= (Float_t)fSinglePheFit->GetNpx()/(Float_t)fBlindPixelChargenbins; 377 fSinglePheFit->SetParLimits(5,norm-0.1,norm+0.1); 378 363 379 fHBlindPixelCharge->Fit(fSinglePheFit,opt); 364 380 … … 384 400 385 401 Double_t pedarea = fSinglePhePedFit->GetParameter(0)*gkSq2Pi*fSinglePhePedFit->GetParameter(2); 386 cout << "Parameter0: " << fSinglePhePedFit->GetParameter(0) << endl; 387 cout << "Parameter2: " << fSinglePhePedFit->GetParameter(2) << endl; 388 cout << "Pedarea: " << pedarea << endl; 389 cout << "entries: " << entries << endl; 390 fLambdaCheck = TMath::Log((double)entries/pedarea); 402 fLambdaCheck = TMath::Log(entries/pedarea); 391 403 fLambdaCheckErr = fSinglePhePedFit->GetParError(0)/fSinglePhePedFit->GetParameter(0) 392 404 + fSinglePhePedFit->GetParError(2)/fSinglePhePedFit->GetParameter(2); … … 396 408 *fLog << "DoF: " << fNdf << endl; 397 409 *fLog << "Probability: " << fProb << endl; 398 *fLog << "Integral: " << fSinglePheFit->Integral(rmin,rmax); 399 400 // 401 // The fit result is accepted under condition 402 // The fit result is accepted under condition 403 // The Probability is greater than gkProbLimit (default 0.001 == 99.7%) 410 411 // 412 // The fit result is accepted under condition that: 413 // 1) the Probability is greater than gkProbLimit (default 0.001 == 99.7%) 414 // 2) at least 100 events are in the single Photo-electron peak 404 415 // 405 416 if (fProb < gkProbLimit) 406 417 { 407 *fLog << warn<< "Prob: " << fProb << " is smaller than the allowed value: " << gkProbLimit << endl;418 *fLog << err << "Prob: " << fProb << " is smaller than the allowed value: " << gkProbLimit << endl; 408 419 fFitOK = kFALSE; 409 420 return kFALSE; 410 421 } 411 422 423 Float_t contSinglePhe = TMath::Exp(-1.0*fLambda)*fLambda*entries; 424 425 if (contSinglePhe < 100.) 426 { 427 *fLog << err << "Statistics is too low: Only " << contSinglePhe 428 << " in the first electron peak " << endl; 429 fFitOK = kFALSE; 430 return kFALSE; 431 } 432 else 433 *fLog << GetDescriptor() << ": " << contSinglePhe 434 << " in first electron peak " << endl; 412 435 413 436 fFitOK = kTRUE; … … 420 443 { 421 444 422 Int_t nbins = 50;445 Int_t nbins = 30; 423 446 424 447 CutEdges(fHBlindPixelCharge,nbins); -
trunk/MagicSoft/Mars/mhist/MHCamera.cc
r2781 r2790 375 375 // 'content' Display the relative content aligned to GetMaximum() and 376 376 // GeMinimum() ((val-min)/(max-min)) 377 // 'proj' Display the y-projection of the histogram 377 378 // 378 379 void MHCamera::Draw(Option_t *option) … … 620 621 CreateProjection(); 621 622 opt.ReplaceAll("proj", ""); 623 Float_t he = gStyle->GetStatH(); 624 Float_t wi = gStyle->GetStatH(); 625 gStyle->SetStatH(0.4); 626 gStyle->SetStatW(0.25); 622 627 fYProj->Paint(opt); 628 gStyle->SetStatH(he); 629 gStyle->SetStatW(wi); 623 630 return; 624 631 }
Note:
See TracChangeset
for help on using the changeset viewer.