Ignore:
Timestamp:
05/16/03 13:11:23 (21 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars/mhist
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/mhist/MBinning.cc

    r2106 r2117  
    1616!
    1717!
    18 !   Author(s): Thomas Bretz  01/2002 <mailto:tbretz@astro.uni-wuerzburg.de>
    19 !
    20 !   Copyright: MAGIC Software Development, 2000-2002
     18!   Author(s): Thomas Bretz, 01/2002 <mailto:tbretz@astro.uni-wuerzburg.de>
     19!
     20!   Copyright: MAGIC Software Development, 2000-2003
    2121!
    2222!
     
    3030#include "MBinning.h"
    3131
     32#include <ctype.h>      // tolower
    3233#include <fstream.h>
    3334
     
    6061
    6162    fType = kIsDefault;
     63}
     64
     65void MBinning::SetEdges(const TAxis &axe)
     66{
     67    const TArrayD &arr = *((TAxis&)axe).GetXbins();
     68    if (arr.GetSize()>0)
     69    {
     70        SetEdges(arr);
     71        return;
     72    }
     73
     74    SetEdges(axe.GetNbins(), axe.GetXmin(), axe.GetXmax());
     75}
     76
     77void MBinning::SetEdges(const TH1 &h, const Char_t axis='x')
     78{
     79    TH1 &hist = (TH1&)h; // get rid of const qualifier
     80    switch (tolower(axis))
     81    {
     82    case 'x':
     83        SetEdges(*hist.GetXaxis());
     84        return;
     85    case 'y':
     86        SetEdges(*hist.GetYaxis());
     87        return;
     88    case 'z':
     89        SetEdges(*hist.GetZaxis());
     90        return;
     91    default:
     92        *fLog << warn << "MBinning::SetEdges: Axis '" << axis << "' unknown... using x." << endl;
     93        SetEdges(*hist.GetXaxis());
     94    }
    6295}
    6396
  • trunk/MagicSoft/Mars/mhist/MBinning.h

    r1962 r2117  
    77
    88#ifndef ROOT_TArrayD
    9 #include "TArrayD.h"
     9#include <TArrayD.h>
    1010#endif
    1111
    1212class TH1;
     13class TAxis;
    1314
    1415class MBinning : public MParContainer
     
    3839    }
    3940
     41    void SetEdges(const TAxis &axe);
     42    void SetEdges(const TH1 &h, const Char_t axis='x');
    4043    void SetEdges(const Int_t nbins, const Axis_t lo, Axis_t up);
    4144    void SetEdgesLog(const Int_t nbins, const Axis_t lo, Axis_t up);
  • trunk/MagicSoft/Mars/mhist/MFillH.cc

    r2015 r2117  
    341341        return kTRUE;
    342342
     343    if (TestBit(kDoNotDisplay))
     344        return kTRUE;
     345
    343346    fCanvas = &fDisplay->AddTab(fH->GetName());
    344347    fH->Draw();
  • trunk/MagicSoft/Mars/mhist/MFillH.h

    r1994 r2117  
    1616class MFillH : public MTask
    1717{
     18public:
     19    enum {
     20        kDoNotDisplay = BIT(17)
     21    };
     22
    1823private:
    1924    MParContainer *fParContainer; // Pointer to the data container storing
  • trunk/MagicSoft/Mars/mhist/MH.h

    r2109 r2117  
    3636    static TCanvas *MakeDefCanvas(const TObject *obj,
    3737                                  const UInt_t w=625, const UInt_t h=440);
     38
     39    // FIXME: * --> & !!!
    3840
    3941    static void SetBinning(TH1 *h, const MBinning *binsx);
  • trunk/MagicSoft/Mars/mhist/MH3.cc

    r2043 r2117  
    6060#include "MH3.h"
    6161
     62#include <ctype.h>   // tolower
    6263#include <fstream.h>
    6364
     
    636637    return h;
    637638}
     639
     640TString MH3::GetRule(const Char_t axis='x') const
     641{
     642    switch (tolower(axis))
     643    {
     644    case 'x':
     645        return fData[0] ? fData[0]->GetRule() : TString("");
     646    case 'y':
     647        return fData[1] ? fData[1]->GetRule() : TString("");
     648    case 'z':
     649        return fData[2] ? fData[2]->GetRule() : TString("");
     650    default:
     651        return "<n/a>";
     652    }
     653}
     654
     655// --------------------------------------------------------------------------
     656//
     657// Returns the total number of bins in a histogram (excluding under- and
     658// overflow bins)
     659//
     660Int_t MH3::GetNbins() const
     661{
     662    Int_t num = 1;
     663
     664    switch (fDimension)
     665    {
     666    case 3:
     667        num *= fHist->GetNbinsZ()+2;
     668    case 2:
     669        num *= fHist->GetNbinsY()+2;
     670    case 1:
     671        num *= fHist->GetNbinsX()+2;
     672    }
     673
     674    return num;
     675}
     676
     677// --------------------------------------------------------------------------
     678//
     679// Returns the total number of bins in a histogram (excluding under- and
     680// overflow bins) Return -1 if bin is underflow or overflow
     681//
     682Int_t MH3::FindFixBin(Double_t x, Double_t y, Double_t z) const
     683{
     684    const TAxis &axex = *fHist->GetXaxis();
     685    const TAxis &axey = *fHist->GetYaxis();
     686    const TAxis &axez = *fHist->GetZaxis();
     687
     688    Int_t binz = 0;
     689    Int_t biny = 0;
     690    Int_t binx = 0;
     691
     692    switch (fDimension)
     693    {
     694    case 3:
     695        binz = axez.FindFixBin(z);
     696        if (binz>axez.GetLast() || binz<axez.GetFirst())
     697            return -1;
     698    case 2:
     699        biny = axey.FindFixBin(y);
     700        if (biny>axey.GetLast() || biny<axey.GetFirst())
     701            return -1;
     702    case 1:
     703        binx = axex.FindFixBin(x);
     704        if (binx<axex.GetFirst() || binx>axex.GetLast())
     705            return -1;
     706    }
     707
     708    const Int_t nx = fHist->GetNbinsX()+2;
     709    const Int_t ny = fHist->GetNbinsY()+2;
     710
     711    return binx + nx*(biny +ny*binz);
     712}
  • trunk/MagicSoft/Mars/mhist/MH3.h

    r2043 r2117  
    1717protected:
    1818    // Could be const but root < 3.02/06 doesn't like this...
    19     Int_t fDimension;            // Number of dimensions of histogram
    20     TH1  *fHist;                 // Histogram to fill
    21 
    22     TString     fDataMember[3];  // Data member which should be filled into the histogram x
     19    Int_t       fDimension;      // Number of dimensions of histogram
     20    TH1        *fHist;           // Histogram to fill
    2321    MDataChain *fData[3];        // Object from which the data is filled
    2422    Double_t    fScale[3];       // Scale for the three axis (eg unit)
     
    4442
    4543    Int_t GetDimension() const { return fDimension; }
     44    Int_t GetNbins() const;
     45    Int_t FindFixBin(Double_t x, Double_t y=0, Double_t z=0) const;
    4646
    4747    void SetName(const char *name);
     
    5252
    5353    TString GetDataMember() const;
     54    TString GetRule(const Char_t axis='x') const;
    5455
    5556    TH1 &GetHist() { return *fHist; }
Note: See TracChangeset for help on using the changeset viewer.