Changeset 1474


Ignore:
Timestamp:
08/02/02 09:32:34 (22 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars
Files:
32 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/Changelog

    r1472 r1474  
    11                                                                  -*-*- END -*-*-
     2
     3 2002/08/02: Thomas Bretz
     4
     5   * manalysis/MHillasSrcCalc.[h,cc], manalysis/MImgCleanStd.cc,
     6     manalysis/MSrcPosCam.cc, mbase/MParContainer.[h,cc],
     7     mfileio/MReadTree.cc, mfileio/MWriteRootFile.cc, mhist/MBinning.cc:
     8     - added comments
     9
     10   * manalysis/MSrcPosCam.cc, mfileio/MWriteRootFile.cc, mhist/MFillH.cc:
     11     - fixed a missing " in SavePrimitive
     12
     13   * mbase/MTask.[h,cc], mhist/MBinning.[h,cc], mhist/MH3.[h,cc]:
     14     - implemented SavePrimitive
     15
     16   * mbase/MEvtLoop.[h,cc]:
     17     - added MakeMacro
     18     - added Read and Write
     19
     20   * mbase/MParContainer.[h,cc], mbase/MParList.[h,cc],
     21     mbase/MTaskList.[h,cc]:
     22     - added GetNames, SetNames virtual functions
     23
     24   * mdata/MData.[h,cc], mdata/MDataChain.[h,cc], mdata/MDataList.[h,cc],
     25     mdata/MDataValue.[h,cc], mdata/MDataMember.[h,cc]:
     26     - implemented GetRule
     27     - move Code from Print to GetRule
     28     - removed Print
     29
     30   * mhist/MH3.[h,cc]:
     31     - implemented default constructor
     32
     33
    234
    335 2002/08/01: Thomas Bretz
  • trunk/MagicSoft/Mars/manalysis/MHillasSrcCalc.cc

    r1471 r1474  
    9797
    9898
     99// --------------------------------------------------------------------------
     100//
     101// Implementation of SavePrimitive. Used to write the call to a constructor
     102// to a macro. In the original root implementation it is used to write
     103// gui elements to a macro-file.
     104//
    99105void MHillasSrcCalc::SavePrimitive(ofstream &out, Option_t *o="")
    100106{
  • trunk/MagicSoft/Mars/manalysis/MHillasSrcCalc.h

    r1471 r1474  
    1313{
    1414private:
    15     MHillas    *fHillas;
    16     MSrcPosCam *fSrcPos;
    17     MHillasSrc *fHillasSrc;
     15    MHillas    *fHillas;     //! Pointer to the source independant hillas parameters
     16    MSrcPosCam *fSrcPos;     //! Pointer to the source position
     17    MHillasSrc *fHillasSrc;  //! Pointer to the output container for the source dependant parameters
    1818
    1919    TString     fSrcName;
     
    2929    void SavePrimitive(ofstream &out, Option_t *o="");
    3030
    31     ClassDef(MHillasSrcCalc, 0) // task to calculate the source position depandant hillas parameters
     31    ClassDef(MHillasSrcCalc, 1) // task to calculate the source position depandant hillas parameters
    3232};
    3333
  • trunk/MagicSoft/Mars/manalysis/MImgCleanStd.cc

    r1471 r1474  
    408408}
    409409
     410// --------------------------------------------------------------------------
     411//
     412// Implementation of SavePrimitive. Used to write the call to a constructor
     413// to a macro. In the original root implementation it is used to write
     414// gui elements to a macro-file.
     415//
    410416void MImgCleanStd::SavePrimitive(ofstream &out, Option_t *o="")
    411417{
  • trunk/MagicSoft/Mars/manalysis/MSrcPosCam.cc

    r1471 r1474  
    8282*/
    8383
     84// --------------------------------------------------------------------------
     85//
     86// Implementation of SavePrimitive. Used to write the call to a constructor
     87// to a macro. In the original root implementation it is used to write
     88// gui elements to a macro-file.
     89//
    8490void MSrcPosCam::SavePrimitive(ofstream &out, Option_t *o="")
    8591{
    8692    out << "   MSrcPosCam " << ToLower(fName) << "(\"";
    87     out << fName << "\", " << fTitle << "\");" << endl;
     93    out << fName << "\", \"" << fTitle << "\");" << endl;
    8894
    8995    out << "   " << ToLower(fName) << ".SetXY(" << fX << ", " << fY << ");" << endl;}
  • trunk/MagicSoft/Mars/mbase/MEvtLoop.cc

    r1473 r1474  
    5252//                                                                          //
    5353// You can create a macro from a completely setup eventloop by:             //
    54 //   ofstream fout("mymacro.C");                                            //
    55 //   evtloop.SavePrimitive(fout);                                           //
     54//   evtloop.MakeMacro("mymacro.C");                                        //
    5655//                                                                          //
    5756// You will always need to check the macro, it will not run, but it         //
     
    6665//   evtloop.Read("MyEvtloopKey");                                          //
    6766//                                                                          //
    68 // To lookup the information write it to a file using SavePrimite           //
     67// To lookup the information write it to a file using MakeMacro             //
    6968//                                                                          //
    7069//////////////////////////////////////////////////////////////////////////////
    7170#include "MEvtLoop.h"
    7271
     72#include <time.h>
    7373#include <fstream.h>     // ofstream, SavePrimitive
    7474#include <iostream.h>
     
    292292}
    293293
     294void MEvtLoop::MakeMacro(const char *filename="evtloop.C")
     295{
     296    TString name(filename);
     297
     298    if (!name.EndsWith(".C"))
     299        name += ".C";
     300
     301    time_t t = time(NULL);
     302
     303    ofstream fout(name);
     304    fout <<
     305        "/* ======================================================================== *\\" << endl <<
     306        "!" << endl <<
     307        "! *" << endl <<
     308        "! * This file is part of MARS, the MAGIC Analysis and Reconstruction" << endl <<
     309        "! * Software. It is distributed to you in the hope that it can be a useful" << endl <<
     310        "! * and timesaving tool in analysing Data of imaging Cerenkov telescopes." << endl <<
     311        "! * It is distributed WITHOUT ANY WARRANTY." << endl <<
     312        "! *" << endl <<
     313        "! * Permission to use, copy, modify and distribute this software and its" << endl <<
     314        "! * documentation for any purpose is hereby granted without fee," << endl <<
     315        "! * provided that the above copyright notice appear in all copies and" << endl <<
     316        "! * that both that copyright notice and this permission notice appear" << endl <<
     317        "! * in supporting documentation. It is provided \"as is\" without express" << endl <<
     318        "! * or implied warranty." << endl <<
     319        "! *" << endl <<
     320        "!" << endl <<
     321        "!" << endl <<
     322        "!   Author(s): Thomas Bretz et al. <mailto:tbretz@astro.uni-wuerzburg.de>" << endl <<
     323        "!" << endl <<
     324        "!   Copyright: MAGIC Software Development, 2000-2002" << endl <<
     325        "!" << endl <<
     326        "!" << endl <<
     327        "\\* ======================================================================== */" << endl << endl <<
     328        "// ------------------------------------------------------------------------" << endl <<
     329        "//" << endl <<
     330        "//     This macro was automatically created on" << endl<<
     331        "//             " << ctime(&t) <<
     332        "//        with the MEvtLoop::MakeMacro tool." << endl <<
     333        "//" << endl <<
     334        "// ------------------------------------------------------------------------" << endl << endl <<
     335        "void " << name(0, name.Length()-2) << "()" << endl <<
     336        "{" << endl;
     337
     338    SavePrimitive(fout);
     339
     340    fout << "}" << endl;
     341}
     342
     343// --------------------------------------------------------------------------
     344//
     345// Implementation of SavePrimitive. Used to write the call to a constructor
     346// to a macro. In the original root implementation it is used to write
     347// gui elements to a macro-file.
     348
     349//
    294350void MEvtLoop::SavePrimitive(ofstream &out, Option_t *)
    295351{
     
    297353
    298354    out << "   MEvtLoop evtloop;" << endl;
    299     out << "   evtloop.SetParList(&" << ToLower(fParList->GetName()) << ")" << endl;
     355    out << "   evtloop.SetParList(&" << ToLower(fParList->GetName()) << ");" << endl;
    300356    out << "   if (!evtloop.Eventloop())" << endl;
    301357    out << "      return;" << endl;
    302358}
     359
     360Int_t MEvtLoop::Read(const char *name)
     361{
     362    Int_t n = 0;
     363    TObjArray list;
     364
     365    n += TObject::Read(name);
     366    n += list.Read((TString)name+"_names");
     367
     368    fParList->SetNames(list);
     369
     370    return n;
     371}
     372
     373Int_t MEvtLoop::Write(const char *name, Int_t option, Int_t bufsize)
     374{
     375    Int_t n = 0;
     376
     377    TObjArray list;
     378    list.SetOwner();
     379
     380    fParList->GetNames(list);
     381
     382    n += list.Write((TString)name+"_names", kSingleKey);
     383    n += TObject::Write(name, option, bufsize);
     384
     385    return n;
     386}
  • trunk/MagicSoft/Mars/mbase/MEvtLoop.h

    r1472 r1474  
    4646    Bool_t Eventloop(Int_t maxcnt=-1, const char *tlist="MTaskList");
    4747
     48    void MakeMacro(const char *filename="evtloop.C");
     49
    4850    void SavePrimitive(ofstream &out, Option_t *o="");
     51
     52    Int_t Read(const char *name);
     53    Int_t Write(const char *name=0, Int_t option=0, Int_t bufsize=0);
    4954
    5055    ClassDef(MEvtLoop, 1) // Class to execute the tasks in a tasklist
  • trunk/MagicSoft/Mars/mbase/MParContainer.cc

    r1471 r1474  
    3939#include <fstream.h>     // ofstream, AsciiWrite
    4040
     41#include <TROOT.h>       // TROOT::Identlevel
    4142#include <TClass.h>      // IsA
     43#include <TObjArray.h>   // TObjArray
    4244#include <TBaseClass.h>  // GetClassPointer
    43 #include <TROOT.h>       // TROOT::Identlevel
    4445#include <TMethodCall.h> // TMethodCall, AsciiWrite
    4546#include <TDataMember.h> // TDataMember, AsciiWrite
     
    347348}
    348349
     350// --------------------------------------------------------------------------
     351//
     352// Implementation of SavePrimitive. Used to write the call to a constructor
     353// to a macro. In the original root implementation it is used to write
     354// gui elements to a macro-file.
     355//
    349356void MParContainer::SavePrimitive(ofstream &out, Option_t *o="")
    350357{
     
    354361}
    355362
     363void MParContainer::GetNames(TObjArray &arr) const
     364{
     365    arr.AddLast(new TNamed(fName, fTitle));
     366}
     367
     368void MParContainer::SetNames(TObjArray &arr)
     369{
     370    TNamed *name = (TNamed*)arr.First();
     371
     372    fName  = name->GetName();
     373    fTitle = name->GetTitle();
     374
     375    delete arr.Remove(name);
     376    arr.Compress();
     377}
  • trunk/MagicSoft/Mars/mbase/MParContainer.h

    r1471 r1474  
    7777    virtual Bool_t AsciiWrite(ostream &out) const;
    7878
     79    virtual void GetNames(TObjArray &arr) const;
     80    virtual void SetNames(TObjArray &arr);
     81
    7982    ClassDef(MParContainer, 0)  //The basis for all parameter containers
    8083};
  • trunk/MagicSoft/Mars/mbase/MParList.cc

    r1471 r1474  
    660660}
    661661
     662// --------------------------------------------------------------------------
     663//
     664// Implementation of SavePrimitive. Used to write the call to a constructor
     665// to a macro. In the original root implementation it is used to write
     666// gui elements to a macro-file.
     667//
    662668void MParList::SavePrimitive(ofstream &out, Option_t *o="")
    663669{
    664     out << "   MParList " << ToLower(fName) << ";" << endl << endl;
     670    out << "   MParList " << ToLower(fName) << "(\"";
     671    out << fName << "\", \"" << fTitle << "\");" << endl << endl;
    665672
    666673    TIter Next(fContainer);
     
    674681    }
    675682}
     683
     684void MParList::GetNames(TObjArray &arr) const
     685{
     686    MParContainer::GetNames(arr);
     687    fContainer->ForEach(MParContainer, GetNames)(arr);
     688}
     689
     690void MParList::SetNames(TObjArray &arr)
     691{
     692    MParContainer::SetNames(arr);
     693    cout << fContainer << endl;
     694    //    fContainer->ForEach(MParContainer, SetNames)(arr);
     695    TIter Next(fContainer);
     696
     697    MParContainer *cont = NULL;
     698    while ((cont=(MParContainer*)Next()))
     699    {
     700        cout << cont << " " << cont->GetName() << endl;
     701        cont->SetNames(arr);
     702    }
     703
     704}
     705
  • trunk/MagicSoft/Mars/mbase/MParList.h

    r1472 r1474  
    8080    void SavePrimitive(ofstream &out, Option_t *o="");
    8181
     82    void GetNames(TObjArray &arr) const;
     83    void SetNames(TObjArray &arr);
     84
    8285    ClassDef(MParList, 1) // list of parameter containers (MParContainer)
    8386};
  • trunk/MagicSoft/Mars/mbase/MTask.cc

    r1118 r1474  
    6060//   - PostProcess():  executed after the eventloop. Here you can close    //
    6161//                     output files, start display of the run parameter,   //
    62 //                     etc. PostProcess should be executed only if         //
     62//                     etc. PostProcess is only executed in case of        //
    6363//                     PreProcess was successfull (returned kTRUE)         //
    6464//                                                                         //
    6565/////////////////////////////////////////////////////////////////////////////
    66 
    6766#include "MTask.h"
     67
     68#include <fstream.h>
    6869
    6970#include "MLog.h"
     
    262263}
    263264
     265// --------------------------------------------------------------------------
     266//
     267// Implementation of SavePrimitive. Used to write the call to a constructor
     268// to a macro. In the original root implementation it is used to write
     269// gui elements to a macro-file.
     270//
     271void MTask::SavePrimitive(ofstream &out, Option_t *o="")
     272{
     273    MParContainer::SavePrimitive(out);
     274    if (fFilter)
     275        out << "   " << ToLower(fName) << ".SetFilter(&" << ToLower(fFilter->GetName()) <<");" << endl;
     276}
  • trunk/MagicSoft/Mars/mbase/MTask.h

    r1108 r1474  
    7171    const MFilter *GetFilter() const      { return fFilter; }
    7272    virtual void PrintStatistics(const Int_t lvl=0) const;
     73    virtual void SavePrimitive(ofstream &out, Option_t *o="");
    7374
    7475    UInt_t GetNumExecutions() { return fNumExecutions; }
  • trunk/MagicSoft/Mars/mbase/MTaskList.cc

    r1471 r1474  
    514514}
    515515
    516 
     516// --------------------------------------------------------------------------
     517//
     518// Implementation of SavePrimitive. Used to write the call to a constructor
     519// to a macro. In the original root implementation it is used to write
     520// gui elements to a macro-file.
     521//
    517522void MTaskList::SavePrimitive(ofstream &out, Option_t *o="")
    518523{
    519     out << "   MTaskList " << ToLower(fName) << ";" << endl << endl;
     524    out << "   MTaskList " << ToLower(fName) << "(\"";
     525    out << fName << "\", \"" << fTitle << "\");" << endl << endl;
    520526
    521527    TIter Next(fTasks);
     
    529535    }
    530536}
     537
     538void MTaskList::GetNames(TObjArray &arr) const
     539{
     540    MParContainer::GetNames(arr);
     541    fTasks->ForEach(MParContainer, GetNames)(arr);
     542}
     543
     544void MTaskList::SetNames(TObjArray &arr)
     545{
     546    MParContainer::SetNames(arr);
     547    fTasks->ForEach(MParContainer, SetNames)(arr);
     548}
     549
  • trunk/MagicSoft/Mars/mbase/MTaskList.h

    r1472 r1474  
    6060    const TList *GetList() const { return fTasks; }
    6161
     62    void GetNames(TObjArray &arr) const;
     63    void SetNames(TObjArray &arr);
     64
    6265    ClassDef(MTaskList, 1) //collection of tasks to be performed in the eventloop
    6366};
  • trunk/MagicSoft/Mars/mdata/MData.cc

    r1361 r1474  
    5050#include <fstream.h>
    5151
     52#include "MLog.h"
     53
    5254ClassImp(MData);
    5355
     
    5860}
    5961
     62void MData::Print(Option_t *opt = "") const
     63{
     64    *fLog << GetRule() << flush;
     65}
  • trunk/MagicSoft/Mars/mdata/MData.h

    r1348 r1474  
    1818public:
    1919    virtual Double_t GetValue() const = 0;
    20     virtual Bool_t IsValid() const = 0;
    21     virtual Bool_t PreProcess(const MParList *plist) = 0;
     20    virtual Bool_t   IsValid() const = 0;
     21    virtual Bool_t   PreProcess(const MParList *plist) = 0;
     22    virtual TString  GetRule() const = 0;
    2223
    2324    Double_t operator()() { return GetValue(); }
    2425
     26    void Print(Option_t *opt = "") const;
    2527    Bool_t AsciiWrite(ostream &out) const;
    2628
  • trunk/MagicSoft/Mars/mdata/MDataChain.cc

    r1465 r1474  
    448448}
    449449
     450    /*
    450451void MDataChain::Print(Option_t *opt) const
    451452{
     453    *fLog << GetRule() << flush;
    452454    Bool_t bracket = fOperatorType!=kENoop && !fMember->InheritsFrom(MDataList::Class());
    453455
     
    483485    if (bracket)
    484486        *fLog << ")" << flush;
    485 }
     487        }
     488        */
     489
     490TString MDataChain::GetRule() const
     491{
     492    TString str;
     493
     494    Bool_t bracket = fOperatorType!=kENoop && !fMember->InheritsFrom(MDataList::Class());
     495
     496    switch (fOperatorType)
     497    {
     498    case kEAbs:      str += "abs"   ; break;
     499    case kELog:      str += "log"   ; break;
     500    case kELog10:    str += "log10" ; break;
     501    case kESin:      str += "sin"   ; break;
     502    case kECos:      str += "cos"   ; break;
     503    case kETan:      str += "tan"   ; break;
     504    case kESinH:     str += "sinh"  ; break;
     505    case kECosH:     str += "cosh"  ; break;
     506    case kETanH:     str += "tanh"  ; break;
     507    case kEASin:     str += "asin"  ; break;
     508    case kEACos:     str += "acos"  ; break;
     509    case kEATan:     str += "atan"  ; break;
     510    case kESqrt:     str += "sqrt"  ; break;
     511    case kEExp:      str += "exp"   ; break;
     512    case kEPow10:    str += "pow10" ; break;
     513    case kESgn:      str += "sgn"   ; break;
     514    case kENegative: str += "-"     ; break;
     515    case kEPositive: str += "+"     ; break;
     516    case kENoop:
     517        break;
     518    }
     519
     520    if (bracket)
     521        str += "(";
     522
     523    str += fMember->GetRule();
     524
     525    if (bracket)
     526        str += ")";
     527
     528    return str;
     529}
  • trunk/MagicSoft/Mars/mdata/MDataChain.h

    r1465 r1474  
    6363    Bool_t IsReadyToSave() const;
    6464
    65     void Print(Option_t *opt = "") const;
     65//    void Print(Option_t *opt = "") const;
     66
     67    TString GetRule() const;
    6668
    6769    ClassDef(MDataChain, 0) // A chain/concatenation of MData objects
  • trunk/MagicSoft/Mars/mdata/MDataList.cc

    r1348 r1474  
    204204// one the option string must conatin a "v"
    205205//
     206/*
    206207void MDataList::Print(Option_t *opt) const
    207208{
     
    251252
    252253    *fLog << ")" << flush;
    253 }
    254 
     254    }
     255    */
     256
     257TString MDataList::GetRule() const
     258{
     259    TIter Next(&fMembers);
     260
     261    MData *member=(MData*)Next();
     262
     263    //
     264    // loop over all members
     265    //
     266    if (!member)
     267        return "(<empty>)";
     268
     269    TString str = "(";
     270
     271    str += member->GetRule();
     272
     273    while ((member=(MData*)Next()))
     274    {
     275        switch (fSign)
     276        {
     277        case kENone:
     278            break;
     279
     280        case kEPlus:
     281            str += "+";
     282            break;
     283
     284        case kEMinus:
     285            str += "-";
     286            break;
     287
     288        case kEMult:
     289            str += "*";
     290            break;
     291
     292        case kEDiv:
     293            str += "/";
     294            break;
     295        }
     296
     297        str += member->GetRule();
     298    }
     299
     300    str += ")";
     301
     302    return str;
     303}
  • trunk/MagicSoft/Mars/mdata/MDataList.h

    r1348 r1474  
    4646    Bool_t PreProcess(const MParList *plist);
    4747
    48     void Print(Option_t *opt = "") const;
     48//    void Print(Option_t *opt = "") const;
     49    TString GetRule() const;
    4950
    5051    ClassDef(MDataList, 0) // A concatenation of MData objects by one operator
  • trunk/MagicSoft/Mars/mdata/MDataMember.cc

    r1348 r1474  
    158158// Print the name of the data member without an CR.
    159159//
     160/*
    160161void MDataMember::Print(Option_t *opt) const
    161162{
    162163    *fLog << fName << flush;
    163164}
     165*/
    164166
     167TString MDataMember::GetRule() const
     168{
     169    return fName;
     170}
  • trunk/MagicSoft/Mars/mdata/MDataMember.h

    r1348 r1474  
    3232    Bool_t IsReadyToSave() const;
    3333
    34     void Print(Option_t *opt = "") const;
     34    //void Print(Option_t *opt = "") const;
     35    TString GetRule() const;
    3536
    3637    ClassDef(MDataMember, 0) // MData object corresponding to a single data member of a Mars container
  • trunk/MagicSoft/Mars/mdata/MDataValue.cc

    r1327 r1474  
    1616!
    1717!
    18 !   Author(s): Thomas Bretz  04/2002 <mailto:tbretz@uni-sw.gwdg.de>
     18!   Author(s): Thomas Bretz  04/2002 <mailto:tbretz@astro.uni-wuerzburg.de>
    1919!
    2020!   Copyright: MAGIC Software Development, 2000-2002
     
    4040// --------------------------------------------------------------------------
    4141//
    42 // Print the value
     42// Return the value as a string
    4343//
    44 void MDataValue::Print(Option_t *opt) const
     44TString MDataValue::GetRule() const
    4545{
    46     *fLog << fValue << flush;
     46    TString str;
     47    str += fValue;
     48    return str.Strip(TString::kBoth);
    4749}
    4850
  • trunk/MagicSoft/Mars/mdata/MDataValue.h

    r1348 r1474  
    2828    Bool_t IsReadyToSave() const { return kFALSE; }
    2929
    30     void Print(Option_t *opt = "") const;
     30    //void Print(Option_t *opt = "") const;
     31    TString GetRule() const;
    3132
    3233    ClassDef(MDataValue, 0) // MData object corresponding to a single value
  • trunk/MagicSoft/Mars/mfileio/MReadTree.cc

    r1472 r1474  
    777777}
    778778
     779// --------------------------------------------------------------------------
     780//
     781// Implementation of SavePrimitive. Used to write the call to a constructor
     782// to a macro. In the original root implementation it is used to write
     783// gui elements to a macro-file.
     784//
    779785void MReadTree::SavePrimitive(ofstream &out, Option_t *o="")
    780786{
  • trunk/MagicSoft/Mars/mfileio/MWriteRootFile.cc

    r1472 r1474  
    397397}
    398398
     399// --------------------------------------------------------------------------
     400//
     401// Implementation of SavePrimitive. Used to write the call to a constructor
     402// to a macro. In the original root implementation it is used to write
     403// gui elements to a macro-file.
     404//
    399405void MWriteRootFile::SavePrimitive(ofstream &out, Option_t *o="")
    400406{
     
    413419        out << entry->GetContName() << "\", \"";
    414420        out << entry->GetName() << "\", \"";
    415         out << entry->GetTitle() << "\")" << endl;
     421        out << entry->GetTitle() << "\");" << endl;
    416422    }
    417423}
  • trunk/MagicSoft/Mars/mhist/MBinning.cc

    r1465 r1474  
    2828//                                                                          //
    2929//////////////////////////////////////////////////////////////////////////////
     30#include "MBinning.h"
    3031
    31 #include "MBinning.h"
     32#include <fstream.h>
    3233
    3334#include "MH.h"
     
    5253
    5354
     55// --------------------------------------------------------------------------
     56//
     57// Apply this binning to the given histogram.
     58// (By definition this works only for 1D-histograms. For 2D- and 3D-
     59//  histograms use MH::SetBinning directly)
     60//
    5461void MBinning::Apply(TH1 &h)
    5562{
    5663    MH::SetBinning(&h, this);
    5764}
     65
     66// --------------------------------------------------------------------------
     67//
     68// Implementation of SavePrimitive. Used to write the call to a constructor
     69// to a macro. In the original root implementation it is used to write
     70// gui elements to a macro-file.
     71//
     72void MBinning::SavePrimitive(ofstream &out, Option_t *o="")
     73{
     74    out << "   TArrayD dummy;" << endl;
     75    for (int i=0; i<fEdges.GetSize(); i++)
     76        out << "   dummy[" << i << "]=" << fEdges[i] << ";" << endl;
     77    out << "   MBinning " << ToLower(fName) << "(\"";
     78    out << fName << "\", \"" << fTitle << "\");" << endl;
     79    out << "   " << ToLower(fName) << ".SetEdges(dummy);" << endl;
     80}
  • trunk/MagicSoft/Mars/mhist/MBinning.h

    r1465 r1474  
    5454    void Apply(TH1 &);
    5555
     56    void SavePrimitive(ofstream &out, Option_t *o="");
     57
    5658    ClassDef(MBinning, 1) //Container to store the binning of a histogram
    5759};
  • trunk/MagicSoft/Mars/mhist/MFillH.cc

    r1472 r1474  
    344344}
    345345
     346// --------------------------------------------------------------------------
     347//
     348// Implementation of SavePrimitive. Used to write the call to a constructor
     349// to a macro. In the original root implementation it is used to write
     350// gui elements to a macro-file.
     351//
    346352void MFillH::SavePrimitive(ofstream &out, Option_t *o="")
    347353{
    348354    out << "   MFillH " << ToLower(fName) << "(\"";
    349     out << fHName << "\", \"" << fParContainerName << "\")" << endl;
    350 }
     355    out << fHName << "\", \"" << fParContainerName << "\");" << endl;
     356}
  • trunk/MagicSoft/Mars/mhist/MH3.cc

    r1336 r1474  
    5858//
    5959/////////////////////////////////////////////////////////////////////////////
    60 
    6160#include "MH3.h"
     61
     62#include <fstream.h>
    6263
    6364#include <TH2.h>
     
    7778ClassImp(MH3);
    7879
     80MH3::MH3() : fDimension(0), fHist(NULL)
     81{
     82    fName  = "MH3";
     83    fTitle = "Container for a 1D Mars Histogram";
     84
     85    fData[0]  = fData[1]  = fData[2]  = NULL;
     86    fScale[0] = fScale[1] = fScale[2] = 1;
     87}
     88
    7989// --------------------------------------------------------------------------
    8090//
     
    367377    gPad->Update();
    368378}
     379
     380// --------------------------------------------------------------------------
     381//
     382// Implementation of SavePrimitive. Used to write the call to a constructor
     383// to a macro. In the original root implementation it is used to write
     384// gui elements to a macro-file.
     385//
     386void MH3::SavePrimitive(ofstream &out, Option_t *o="")
     387{
     388    TString name = ToLower(fName);
     389
     390    out << "   MH3 " << name << "(\"";
     391    out << fData[0]->GetRule() << "\"";
     392    if (fDimension>1)
     393        out << ", \"" << fData[1]->GetRule() << "\"";
     394    if (fDimension>2)
     395        out << ", \"" << fData[2]->GetRule() << "\"";
     396
     397    out << ");" << endl;
     398
     399    out << "   " << name << ".SetName(\"" << fName << "\");" << endl;
     400    out << "   " << name << ".SetTitle(\"" << fTitle << "\");" << endl;
     401
     402    switch (fDimension)
     403    {
     404    case 3:
     405        if (fScale[2]!=1)
     406            out << "   " << name << ".SetScaleZ(" << fScale[2] << ");" << endl;
     407    case 2:
     408        if (fScale[1]!=1)
     409            out << "   " << name << ".SetScaleY(" << fScale[1] << ");" << endl;
     410    case 1:
     411        if (fScale[0]!=1)
     412            out << "   " << name << ".SetScaleX(" << fScale[0] << ");" << endl;
     413    }
     414}
  • trunk/MagicSoft/Mars/mhist/MH3.h

    r1326 r1474  
    2525
    2626public:
     27    MH3();
    2728    MH3(const char *memberx);
    2829    MH3(const char *memberx, const char *membery);
     
    4849    TObject *DrawClone(Option_t *opt=NULL) const;
    4950
     51    void SavePrimitive(ofstream &out, Option_t *o="");
     52
    5053    ClassDef(MH3, 1) // Generalized 1/2/3D-histogram for Mars variables
    5154};
Note: See TracChangeset for help on using the changeset viewer.