Ignore:
Timestamp:
08/02/02 15:20:53 (22 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars/mhist
Files:
6 edited

Legend:

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

    r1476 r1477  
    5050
    5151    SetEdges(10, 0, 1);
     52
     53    fType = kIsDefault;
    5254}
    5355
     56// --------------------------------------------------------------------------
     57//
     58// Specify the number of bins (not the number of edges), the lowest and
     59// highest Edge.
     60//
     61void MBinning::SetEdges(const Int_t nbins, const Axis_t lo, Axis_t up)
     62{
     63    const Double_t binsize = (up-lo)/nbins;
     64    fEdges.Set(nbins+1);
     65    for (int i=0; i<=nbins; i++)
     66            fEdges[i] = binsize*i + lo;
     67
     68    fType = kIsLinear;
     69}
     70
     71// --------------------------------------------------------------------------
     72//
     73// Specify the number of bins (not the number of edges), the lowest and
     74// highest Edge.
     75//
     76void MBinning::SetEdgesLog(const Int_t nbins, const Axis_t lo, Axis_t up)
     77{
     78    // if (lo==0) ...
     79
     80    const Double_t binsize = log10(up/lo)/nbins;
     81    fEdges.Set(nbins+1);
     82    for (int i=0; i<=nbins; i++)
     83        fEdges[i] = pow(10, binsize*i) * lo;
     84
     85    fType = kIsLogarithmic;
     86}
    5487
    5588// --------------------------------------------------------------------------
     
    70103// gui elements to a macro-file.
    71104//
    72 void MBinning::SavePrimitive(ofstream &out, Option_t *o)
     105void MBinning::StreamPrimitive(ofstream &out) const
    73106{
    74     out << "   TArrayD dummy;" << endl;
    75     for (int i=0; i<fEdges.GetSize(); i++)
    76         out << "   dummy[" << i << "]=" << fEdges[i] << ";" << endl;
    77107    out << "   MBinning " << ToLower(fName) << "(\"";
    78108    out << fName << "\", \"" << fTitle << "\");" << endl;
    79     out << "   " << ToLower(fName) << ".SetEdges(dummy);" << endl;
     109
     110    if (IsDefault())
     111        return;
     112
     113    if (IsLinear() || IsLogarithmic())
     114    {
     115        out << "   " << ToLower(fName) << ".SetEdges";
     116        if (IsLogarithmic())
     117            out << "Log";
     118        out << "(" << GetNumBins() << ", " << GetEdgeLo() << ", " << GetEdgeHi() << ");" << endl;
     119        return;
     120    }
     121
     122    out << "   {" << endl;
     123    out << "      TArrayD dummy;" << endl;
     124    for (int i=0; i<GetNumEdges(); i++)
     125        out << "      dummy[" << i << "]=" << GetEdges()[i] << ";" << endl;
     126    out << "      " << ToLower(fName) << ".SetEdges(dummy);" << endl;
     127    out << "   }" << endl;
    80128}
  • trunk/MagicSoft/Mars/mhist/MBinning.h

    r1474 r1477  
    1717    TArrayD fEdges;
    1818
     19    Byte_t  fType;
     20
     21    void StreamPrimitive(ofstream &out) const;
     22
     23    enum {
     24        kIsDefault,
     25        kIsLinear,
     26        kIsLogarithmic,
     27        kIsUserArray
     28    };
     29
    1930public:
    2031    MBinning(const char *name=NULL, const char *title=NULL);
     
    2334    {
    2435        fEdges = arr;
     36        fType = kIsUserArray;
    2537    }
    2638
    27     void SetEdges(const Int_t nbins, const Axis_t lo, Axis_t up)
    28     {
    29         const Double_t binsize = (up-lo)/nbins;
    30         fEdges.Set(nbins+1);
    31         for (int i=0; i<=nbins; i++)
    32             fEdges[i] = binsize*i + lo;
    33     }
    34 
    35     void SetEdgesLog(const Int_t nbins, const Axis_t lo, Axis_t up)
    36     {
    37         // if (lo==0) ...
    38 
    39         const Double_t binsize = log10(up/lo)/nbins;
    40         fEdges.Set(nbins+1);
    41         for (int i=0; i<=nbins; i++)
    42             fEdges[i] = pow(10, binsize*i) * lo;
    43     }
     39    void SetEdges(const Int_t nbins, const Axis_t lo, Axis_t up);
     40    void SetEdgesLog(const Int_t nbins, const Axis_t lo, Axis_t up);
    4441
    4542    // FIXME: ROOT workaround: "operator[] const" missing
    46     Double_t GetEdgeLo() const { return (*(TArrayD*)(&fEdges))[0]; }
    47     Double_t GetEdgeHi() const { return (*(TArrayD*)(&fEdges))[fEdges.GetSize()-1]; }
     43    Double_t GetEdgeLo() const { return ((TArrayD)fEdges)[0]; }
     44    Double_t GetEdgeHi() const { return ((TArrayD)fEdges)[fEdges.GetSize()-1]; }
    4845
    4946    Int_t GetNumEdges() const { return fEdges.GetSize(); }
     
    5249    Double_t *GetEdges() const { return fEdges.GetArray(); }
    5350
     51    Bool_t IsLinear() const { return fType==kIsLinear; }
     52    Bool_t IsLogarithmic() const { return fType==kIsLogarithmic; }
     53    Bool_t IsDefault() const { return fType==kIsDefault; }
     54    Bool_t IsUserArray() const { return fType==kIsUserArray; }
     55
    5456    void Apply(TH1 &);
    55 
    56     void SavePrimitive(ofstream &out, Option_t *o="");
    5757
    5858    ClassDef(MBinning, 1) //Container to store the binning of a histogram
  • trunk/MagicSoft/Mars/mhist/MFillH.cc

    r1476 r1477  
    156156//
    157157//
    158 MFillH::MFillH(const char *hist, const MParContainer *par, const char *name, const char *title)
     158MFillH::MFillH(const char *hist, MParContainer *par, const char *name, const char *title)
    159159{
    160160    Init(name, title);
     
    192192//   derived from MH)
    193193//
    194 MFillH::MFillH(MH *hist, const MParContainer *par, const char *name, const char *title)
     194MFillH::MFillH(MH *hist, MParContainer *par, const char *name, const char *title)
    195195{
    196196    Init(name, title);
     
    350350// gui elements to a macro-file.
    351351//
    352 void MFillH::SavePrimitive(ofstream &out, Option_t *o)
    353 {
    354     out << "   MFillH " << ToLower(fName) << "(\"";
    355     out << fHName << "\", \"" << fParContainerName << "\");" << endl;
    356 }
     352void MFillH::StreamPrimitive(ofstream &out) const
     353{
     354    if (fH)
     355        fH->SavePrimitive(out);
     356
     357    if (fParContainer)
     358        fParContainer->SavePrimitive(out);
     359
     360    out << "   MFillH " << ToLower(fName) << "(";
     361
     362    if (fH)
     363        out << "&" << ToLower(fH->GetName());
     364    else
     365        out << "\"" << fHName << "\"";
     366    out << ", ";
     367
     368    if (fParContainer)
     369        out << "&" << ToLower(fParContainer->GetName());
     370    else
     371        out << "\"" << fParContainerName << "\"";
     372
     373    out << ");" << endl;
     374}
  • trunk/MagicSoft/Mars/mhist/MFillH.h

    r1472 r1477  
    1212{
    1313private:
    14     const MParContainer *fParContainer; //!
     14    MParContainer *fParContainer;
    1515    TString fParContainerName;
    1616
    17     MH* fH;                             //!
     17    MH* fH;                   
    1818    TString fHName;
    1919
     
    2323    void Init(const char *name, const char *title);
    2424
     25    void StreamPrimitive(ofstream &out) const;
     26
    2527public:
    2628    MFillH();
    27     MFillH(const char *hist, const char *par=NULL,     const char *name=NULL, const char *title=NULL);
    28     MFillH(const char *hist, const MParContainer *par, const char *name=NULL, const char *title=NULL);
    29     MFillH(MH *hist,         const char *par=NULL,     const char *name=NULL, const char *title=NULL);
    30     MFillH(MH *hist,         const MParContainer *par, const char *name=NULL, const char *title=NULL);
     29    MFillH(const char *hist, const char *par=NULL, const char *name=NULL, const char *title=NULL);
     30    MFillH(const char *hist, MParContainer *par,  const char *name=NULL, const char *title=NULL);
     31    MFillH(MH *hist,         const char *par=NULL, const char *name=NULL, const char *title=NULL);
     32    MFillH(MH *hist,         MParContainer *par,  const char *name=NULL, const char *title=NULL);
    3133
    3234    Bool_t PreProcess(MParList *pList);
    3335    Bool_t Process();
    3436    Bool_t PostProcess();
    35 
    36     void SavePrimitive(ofstream &out, Option_t *o="");
    3737
    3838    ClassDef(MFillH, 1) // Task to fill a histogram with data from a parameter container
  • trunk/MagicSoft/Mars/mhist/MH3.cc

    r1476 r1477  
    384384// gui elements to a macro-file.
    385385//
    386 void MH3::SavePrimitive(ofstream &out, Option_t *o)
     386void MH3::StreamPrimitive(ofstream &out)
    387387{
    388388    TString name = ToLower(fName);
  • trunk/MagicSoft/Mars/mhist/MH3.h

    r1474 r1477  
    2323    MDataChain *fData[3];        // Object from which the data is filled
    2424    Double_t    fScale[3];
     25
     26    void StreamPrimitive(ofstream &out);
    2527
    2628public:
     
    4951    TObject *DrawClone(Option_t *opt=NULL) const;
    5052
    51     void SavePrimitive(ofstream &out, Option_t *o="");
    52 
    5353    ClassDef(MH3, 1) // Generalized 1/2/3D-histogram for Mars variables
    5454};
Note: See TracChangeset for help on using the changeset viewer.