Changeset 8281
- Timestamp:
- 02/01/07 11:24:19 (18 years ago)
- Location:
- trunk/MagicSoft/Mars
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/Changelog
r8280 r8281 18 18 19 19 -*-*- END OF LINE -*-*- 20 21 2007/02/01 Thomas Bretz 22 23 * mhist/MHCamEvent.[h,cc]: 24 - allow to set a histogram for display from external 25 26 * mhist/MHCamera.[h,cc]: 27 - added functions to calc Median/Dev 28 - fixed adding a MHCamera with AddCamContent. It now takes also 29 the errors and binentries correctly into account 30 - simplified Reset() using TArray::Reset() 31 32 * mhvstime/MHSectorVsTime.[h,cc]: 33 - added option to use median/dev instead of mean/rms 34 - switched Grid on 35 36 20 37 21 38 2007/01/30 Thomas Bretz -
trunk/MagicSoft/Mars/mhist/MHCamEvent.cc
r8279 r8281 214 214 } 215 215 216 void MHCamEvent::SetHist(const MHCamera &cam) 217 { 218 if (fSum) 219 delete fSum; 220 221 fSum = static_cast<MHCamera*>(cam.Clone()); 222 } 223 216 224 void MHCamEvent::Paint(Option_t *) 217 225 { -
trunk/MagicSoft/Mars/mhist/MHCamEvent.h
r8279 r8281 44 44 void SetType(Int_t type) { fType = type; } 45 45 46 void SetHist(const MHCamera &cam); 47 46 48 TH1 *GetHistByName(const TString name="") const; 47 49 -
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 -
trunk/MagicSoft/Mars/mhist/MHCamera.h
r8280 r8281 1 1 /* ======================================================================== *\ 2 ! $Name: not supported by cvs2svn $:$Id: MHCamera.h,v 1.6 1 2007-01-30 14:16:45tbretz Exp $2 ! $Name: not supported by cvs2svn $:$Id: MHCamera.h,v 1.62 2007-02-01 11:24:18 tbretz Exp $ 3 3 \* ======================================================================== */ 4 4 #ifndef MARS_MHCamera … … 156 156 virtual void AddCamContent(const TArrayD &arr, const TArrayC *used=NULL); 157 157 virtual void AddCamContent(const MArrayD &arr, const TArrayC *used=NULL); 158 virtual void SetCamContent(const MCamEvent &evt, Int_t type=0) { Reset(); AddCamContent(evt, type); }159 virtual void SetCamContent(const MHCamera & d, Int_t type=0) { Reset(); AddCamContent(d, type); fEntries=d.fEntries; }158 virtual void SetCamContent(const MCamEvent &evt, Int_t type=0) { Reset(); AddCamContent(evt, type); } 159 virtual void SetCamContent(const MHCamera &cam, Int_t type=0) { Reset(); AddCamContent(cam, type); } 160 160 virtual void SetCamContent(const TArrayD &evt, const TArrayC *used=NULL) { Reset(); AddCamContent(evt, used); } 161 161 virtual void SetCamContent(const MArrayD &evt, const TArrayC *used=NULL) { Reset(); AddCamContent(evt, used); } … … 243 243 void AddNotify(TObject *event); 244 244 245 Stat_t GetMean(Bool_t ball) const { return GetMeanSectors(TArrayI(), TArrayI(), ball); } 246 Stat_t GetRMS(Bool_t ball) const { return GetRmsSectors(TArrayI(), TArrayI(), ball); } 247 248 Stat_t GetMean(Int_t=0) const { return GetMeanSectors(TArrayI(), TArrayI(), kFALSE); } 249 Stat_t GetRMS(Int_t=0) const { return GetRmsSectors(TArrayI(), TArrayI(), kFALSE); } 250 251 Stat_t GetMedian() const; 252 Stat_t GetMedianDev() const; 245 Stat_t GetMean(Bool_t ball) const { return GetMeanSectors(TArrayI(), TArrayI(), ball); } 246 Stat_t GetMedian(Bool_t ball) const { return GetMedianSectors(TArrayI(), TArrayI(), ball); } 247 Stat_t GetRMS(Bool_t ball) const { return GetRmsSectors(TArrayI(), TArrayI(), ball); } 248 Stat_t GetDev(Bool_t ball) const { return GetDevSectors(TArrayI(), TArrayI(), ball); } 249 250 Stat_t GetMean(Int_t=0) const { return GetMeanSectors(TArrayI(), TArrayI(), kFALSE); } 251 Stat_t GetMedian(Int_t=0) const { return GetMedianSectors(TArrayI(), TArrayI(), kFALSE); } 252 Stat_t GetRMS(Int_t=0) const { return GetRmsSectors(TArrayI(), TArrayI(), kFALSE); } 253 Stat_t GetDev(Int_t=0) const { return GetRmsSectors(TArrayI(), TArrayI(), kFALSE); } 253 254 254 255 Stat_t GetMeanSector(Int_t sector, Int_t aidx, Bool_t ball=kFALSE) const … … 256 257 return GetMeanSectors(TArrayI(1, §or), TArrayI(1, &aidx), ball); 257 258 } 259 Stat_t GetMedianSector(Int_t sector, Int_t aidx, Bool_t ball=kFALSE) const 260 { 261 return GetMedianSectors(TArrayI(1, §or), TArrayI(1, &aidx), ball); 262 } 258 263 Stat_t GetRmsSector(Int_t sector, Int_t aidx, Bool_t ball=kFALSE) const 259 264 { 260 265 return GetRmsSectors(TArrayI(1, §or), TArrayI(1, &aidx), ball); 261 266 } 267 Stat_t GetDevSector(Int_t sector, Int_t aidx, Bool_t ball=kFALSE) const 268 { 269 return GetDevSectors(TArrayI(1, §or), TArrayI(1, &aidx), ball); 270 } 262 271 263 272 Stat_t GetMeanSectors(const TArrayI §or, const TArrayI &aidx, Bool_t all=kFALSE) const; 273 Stat_t GetMedianSectors(const TArrayI §or, const TArrayI &aidx, Bool_t all=kFALSE) const; 264 274 Stat_t GetRmsSectors(const TArrayI §or, const TArrayI &aidx, Bool_t all=kFALSE) const; 275 Stat_t GetDevSectors(const TArrayI §or, const TArrayI &aidx, Bool_t all=kFALSE) const; 265 276 266 277 UInt_t GetNumPixels() const; -
trunk/MagicSoft/Mars/mhvstime/MHSectorVsTime.cc
r8022 r8281 1 1 /* ======================================================================== *\ 2 ! $Name: not supported by cvs2svn $:$Id: MHSectorVsTime.cc,v 1.13 2007-02-01 11:24:19 tbretz Exp $ 3 ! -------------------------------------------------------------------------- 2 4 ! 3 5 ! * … … 18 20 ! Author(s): Thomas Bretz, 3/2004 <mailto:tbretz@astro.uni-wuerzburg.de> 19 21 ! 20 ! Copyright: MAGIC Software Development, 2000-200 422 ! Copyright: MAGIC Software Development, 2000-2006 21 23 ! 22 24 ! … … 70 72 // + Double_t fMaximum; // User defined maximum 71 73 // 74 // Class Version 3: 75 // ---------------- 76 // + Bool_t fUseMedian; 77 // 72 78 // 73 79 ///////////////////////////////////////////////////////////////////////////// … … 101 107 // 102 108 MHSectorVsTime::MHSectorVsTime(const char *name, const char *title) 103 : fGraph(0), fEvt(NULL), fMinimum(-1111), fMaximum(-1111), 109 : fGraph(0), fEvt(NULL), fMinimum(-1111), fMaximum(-1111), fUseMedian(kFALSE), 104 110 fType(0), fTypeErr(-1) 105 111 { … … 226 232 fHCamera.SetCamContent(*evt, fType); 227 233 228 const Double_t val0 = fHCamera.GetMeanSectors(fSectors, fAreaIndex); 234 const Double_t val0 = fUseMedian ? 235 fHCamera.GetMedianSectors(fSectors, fAreaIndex) : 236 fHCamera.GetMeanSectors(fSectors, fAreaIndex); 229 237 230 238 if (!TMath::Finite(val0)) … … 235 243 if (fTypeErr>=0) 236 244 { 237 const Double_t rms0 = fHCamera.GetRmsSectors(fSectors, fAreaIndex); 245 const Double_t rms0 = fUseMedian ? 246 fHCamera.GetDevSectors(fSectors, fAreaIndex) : 247 248 fHCamera.GetRmsSectors(fSectors, fAreaIndex); 238 249 if (!TMath::Finite(rms0)) 239 250 return kTRUE; 251 240 252 ((TGraphErrors*)fGraph)->SetPointError(fGraph->GetN()-1, 0, rms0); 241 253 } … … 334 346 TVirtualPad *pad = gPad ? gPad : MakeDefCanvas(fGraph); 335 347 pad->SetBorderMode(0); 348 pad->SetGridx(); 349 pad->SetGridy(); 336 350 AppendPad(opt); 337 351 } -
trunk/MagicSoft/Mars/mhvstime/MHSectorVsTime.h
r7358 r8281 1 /* ======================================================================== *\ 2 ! $Name: not supported by cvs2svn $:$Id: MHSectorVsTime.h,v 1.7 2007-02-01 11:24:19 tbretz Exp $ 3 \* ======================================================================== */ 1 4 #ifndef MARS_MHSectorVsTime 2 5 #define MARS_MHSectorVsTime … … 25 28 26 29 private: 27 TGraph *fGraph; 30 TGraph *fGraph; // The TGraph output to the display 28 31 29 MCamEvent *fEvt; //! the current event30 MGeomCam *fCam; //! the camera geometry32 MCamEvent *fEvt; //! pointer to the current event 33 MGeomCam *fCam; //! pointer the camera geometry 31 34 32 MRawEvtHeader *fHeader; //! 33 MTime *fTime; //! 35 MRawEvtHeader *fHeader; //! pointer to the event header (DAQ Evt number instead of counter) 36 MTime *fTime; //! pointer to event time (time instead of number) 34 37 35 MHCamera fHCamera; //! 38 MHCamera fHCamera; //! The camera to be used for calculation 36 39 37 40 Double_t fMin; //! Calculation of minimum … … 41 44 Double_t fMaximum; // User defined maximum 42 45 43 TString fNameEvt; 44 TString fNameTime; 46 Bool_t fUseMedian; // Whether to display median/dev instead of mean/rms 45 47 46 Int_t fType;47 Int_t fTypeErr;48 TString fNameEvt; // Name of MCamEvent to be displayed 49 TString fNameTime; // Name of MTime container to be used 48 50 49 TArrayI fSectors; 50 TArrayI fAreaIndex; 51 Int_t fType; // Type for mean used in GetPixelContent 52 Int_t fTypeErr; // Type for error used in GetPixelContent (-1 = no error) 53 54 TArrayI fSectors; // Which sectors shell be displayed 55 TArrayI fAreaIndex; // Which pixel sized should be displayed 51 56 52 57 // MH … … 69 74 void SetMaximum(Double_t max=-1111) { fMaximum = max; } 70 75 76 void SetUseMedian(Bool_t b=kTRUE) { fUseMedian=b; } 77 71 78 // Getter 72 79 TH1 *GetHistByName(const TString name="") const; … … 80 87 void Paint(Option_t *o=NULL); 81 88 82 ClassDef(MHSectorVsTime, 2) // Histogram to sum camera events89 ClassDef(MHSectorVsTime, 3) // Histogram to sum camera events 83 90 }; 84 91
Note:
See TracChangeset
for help on using the changeset viewer.