Changeset 8281 for trunk/MagicSoft/Mars/mhist/MHCamera.cc
- Timestamp:
- 02/01/07 11:24:19 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/mhist/MHCamera.cc
r8280 r8281 1 1 /* ======================================================================== *\ 2 ! $Name: not supported by cvs2svn $:$Id: MHCamera.cc,v 1.9 7 2007-01-30 14:20:47tbretz Exp $2 ! $Name: not supported by cvs2svn $:$Id: MHCamera.cc,v 1.98 2007-02-01 11:24:18 tbretz Exp $ 3 3 ! -------------------------------------------------------------------------- 4 4 ! … … 319 319 // ------------------------------------------------------------------------ 320 320 // 321 // Return the median value on the y-axis (profile option is correctly taken322 // into account)323 //324 Stat_t MHCamera::GetMedian() const325 {326 // Just for speed reasons327 if (!TestBit(kProfile))328 return TMath::Median(GetSize()-2, GetArray()+1);329 330 // Copy profiled data into new array (FIXME: Should we take errors into account?)331 TArrayD arr(fNcells-2);332 for (int i=1; i<fNcells-1; i++)333 arr[i-1] = GetBinContent(i);334 335 // return Median of the profile data336 return TMath::Median(arr.GetSize(), arr.GetArray());337 }338 339 // ------------------------------------------------------------------------340 //341 // Return the median value (divided by MMath::GausProb(1.0)) of the342 // distribution of abs(y[i]-Median). This is my Median equivalent of the RMS343 //344 Stat_t MHCamera::GetMedianDev() const345 {346 // Just for speed reasons347 if (!TestBit(kProfile))348 return MMath::MedianDev(GetSize()-2, GetArray()+1);349 350 // Copy profiled data into new array (FIXME: Should we take errors into account?)351 TArrayD arr(fNcells-2);352 for (int i=1; i<fNcells-1; i++)353 arr[i-1] = GetBinContent(i);354 355 // return MedianDev of the profile data356 return MMath::MedianDev(arr.GetSize(), arr.GetArray());357 }358 359 // ------------------------------------------------------------------------360 //361 321 // Return the mean value of all entries which are used if all=kFALSE and 362 322 // of all entries if all=kTRUE if sector<0. If sector>=0 only … … 388 348 // ------------------------------------------------------------------------ 389 349 // 390 // Return the sqrt variance of all entries which are used if all=kFALSE and350 // Return the median value of all entries which are used if all=kFALSE and 391 351 // of all entries if all=kTRUE if sector<0. If sector>=0 only 392 352 // entries with match the given sector are taken into account. 393 353 // 394 Stat_t MHCamera::Get RmsSectors(const TArrayI §or, const TArrayI &aidx, Bool_t ball) const354 Stat_t MHCamera::GetMedianSectors(const TArrayI §or, const TArrayI &aidx, Bool_t ball) const 395 355 { 396 356 if (fNcells<=1) 397 return -1; 398 357 return 0; 358 359 TArrayD arr(fNcells-2); 399 360 Int_t n=0; 400 401 Stat_t sum = 0; 402 Stat_t sq = 0; 361 403 362 for (int i=0; i<fNcells-2; i++) 404 363 { … … 408 367 continue; 409 368 369 arr[n++] = TestBit(kProfile) ? fArray[i+1]/fBinEntries[i+1] : fArray[i+1]; 370 } 371 } 372 373 // return Median of the profile data 374 return TMath::Median(n, arr.GetArray()); 375 } 376 377 // ------------------------------------------------------------------------ 378 // 379 // Return the sqrt variance of all entries which are used if all=kFALSE and 380 // of all entries if all=kTRUE if sector<0. If sector>=0 only 381 // entries with match the given sector are taken into account. 382 // 383 Stat_t MHCamera::GetRmsSectors(const TArrayI §or, const TArrayI &aidx, Bool_t ball) const 384 { 385 if (fNcells<=1) 386 return -1; 387 388 Int_t n=0; 389 390 Stat_t sum = 0; 391 Stat_t sq = 0; 392 for (int i=0; i<fNcells-2; i++) 393 { 394 if ((ball || IsUsed(i)) && MatchSector(i, sector, aidx)) 395 { 396 if (TestBit(kProfile) && fBinEntries[i+1]==0) 397 continue; 398 410 399 const Double_t val = TestBit(kProfile) ? fArray[i+1]/fBinEntries[i+1] : fArray[i+1]; 411 400 … … 423 412 424 413 return TMath::Sqrt(sq-sum*sum); 414 } 415 416 // ------------------------------------------------------------------------ 417 // 418 // Return the median value (divided by MMath::GausProb(1.0)=68.3%) of the 419 // distribution of abs(y[i]-Median). This is my Median equivalent of the RMS. 420 // Return the deviation of all entries which are used if all=kFALSE and 421 // of all entries if all=kTRUE if sector<0. If sector>=0 only 422 // entries with match the given sector are taken into account. 423 // 424 Stat_t MHCamera::GetDevSectors(const TArrayI §or, const TArrayI &aidx, Bool_t ball) const 425 { 426 if (fNcells<=1) 427 return 0; 428 429 TArrayD arr(fNcells-2); 430 Int_t n=0; 431 432 for (int i=0; i<fNcells-2; i++) 433 { 434 if ((ball || IsUsed(i)) && MatchSector(i, sector, aidx)) 435 { 436 if (TestBit(kProfile) && fBinEntries[i+1]==0) 437 continue; 438 439 arr[n++] = TestBit(kProfile) ? fArray[i+1]/fBinEntries[i+1] : fArray[i+1]; 440 } 441 } 442 443 // return Median of the profile data 444 return MMath::MedianDev(n, arr.GetArray()); 425 445 } 426 446 … … 1391 1411 { 1392 1412 case 1: 1413 // Under-/Overflow bins not handled! 1393 1414 for (Int_t idx=0; idx<fNcells-2; idx++) 1394 Fill(idx, d.GetBinError(idx+1)); 1415 if (d.IsUsed(idx)) 1416 Fill(idx, d.GetBinError(idx+1)); 1417 fEntries++; 1395 1418 break; 1396 1419 case 2: 1420 // Under-/Overflow bins not handled! 1397 1421 for (Int_t idx=0; idx<fNcells-2; idx++) 1398 if (d.GetBinContent(idx+1)!=0 )1422 if (d.GetBinContent(idx+1)!=0 && d.IsUsed(idx)) 1399 1423 Fill(idx, TMath::Abs(d.GetBinError(idx+1)/d.GetBinContent(idx+1))); 1424 fEntries++; 1400 1425 break; 1401 1426 default: 1427 if (TestBit(kProfile)!=d.TestBit(kProfile)) 1428 gLog << warn << "WARNING - You have tried to call AddCamContent for two different kind of histograms (kProfile set or not)." << endl; 1429 1430 // environment 1431 fEntries += d.fEntries; 1432 fTsumw += d.fTsumw; 1433 fTsumw2 += d.fTsumw2; 1434 fTsumwx += d.fTsumwx; 1435 fTsumwx2 += d.fTsumwx2; 1436 // Bin contents 1437 for (Int_t idx=1; idx<fNcells-1; idx++) 1438 { 1439 if (!d.IsUsed(idx-1)) 1440 continue; 1441 1442 fArray[idx] += d.fArray[idx]; 1443 fBinEntries[idx] += d.fBinEntries[idx]; 1444 fSumw2.fArray[idx] += d.fSumw2.fArray[idx]; 1445 } 1446 // Underflow bin 1447 fArray[0] += d.fArray[0]; 1448 fBinEntries[0] += d.fBinEntries[0]; 1449 fSumw2.fArray[0] += d.fSumw2.fArray[0]; 1450 // Overflow bin 1451 fArray[fNcells-1] += d.fArray[fNcells-1]; 1452 fBinEntries[fNcells-1] += d.fBinEntries[fNcells-1]; 1453 fSumw2.fArray[fNcells-1] += d.fSumw2.fArray[fNcells-1]; 1454 break; 1455 /* default: 1456 if (TestBit(kProfile)!=d.TestBit(kProfile)) 1457 gLog << warn << "WARNING - You have tried to call AddCamContent for two different kind of histograms (kProfile set or not)." << endl; 1458 1402 1459 for (Int_t idx=0; idx<fNcells-2; idx++) 1403 1460 Fill(idx, d.GetBinContent(idx+1)); 1404 break; 1461 break;*/ 1405 1462 } 1406 1463 fEntries++; … … 1629 1686 TH1::Reset(opt); 1630 1687 1631 for (Int_t i=0; i<fNcells-2; i++) 1632 { 1633 fArray[i+1]=0; 1634 fBinEntries[i]=0; 1635 ResetUsed(i); 1636 } 1637 1638 fArray[0] = 0; 1639 fArray[fNcells-1] = 0; 1688 fUsed.Reset(); 1689 fBinEntries.Reset(); 1690 1691 for (Int_t i=0; i<fNcells; i++) 1692 fArray[i] = 0; 1640 1693 } 1641 1694
Note:
See TracChangeset
for help on using the changeset viewer.