Changeset 1483


Ignore:
Timestamp:
08/05/02 16:12:14 (22 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars
Files:
19 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/Changelog

    r1482 r1483  
    3939   * mhist/MH3.[h,cc]:
    4040     - added the missing const-qualifier of StreamPrimitive
     41
     42   * mbase/MParContainer.[h,cc]:
     43     - implemented setting a unique id in SavePrimitive
     44     - imnplemented GetUniqueID
     45     
     46   * manalysis/MHillasSrcCalc.cc, manalysis/MImgCleanStd.cc,
     47     manalysis/MSrcPosCam.cc, mbase/MEvtLoop.cc, mbase/MParList.cc,
     48     mbase/MTaskList.cc, mfileio/MReadTree.cc, mfileio/MWriteRootFile.cc,
     49     mhist/MF.cc, mfilter/MFAlpha.cc, mfilter/MFDataMember.cc,
     50     mfilter/MFParticleId.cc, mfilter/MFTriggerLvl1.cc, mhist/MBinning.cc,
     51     mhist/MFillH.cc, mhist/MH3.cc:
     52     - changed the 'instance' name to the UniqueName
     53     - in some files: implemented a static constant name and title, which
     54       is used to descide whether the name and/or title should be stream
     55       in the constructor-call in StreamPrimitive
    4156
    4257
  • trunk/MagicSoft/Mars/manalysis/MHillasSrcCalc.cc

    r1477 r1483  
    115115        fHillasSrc->SavePrimitive(out);
    116116
    117     out << "   MHillasSrcCalc " << ToLower(fName) << "(";
     117    out << "   MHillasSrcCalc " << GetUniqueName() << "(";
    118118
    119119    if (fSrcPos)
    120         out << "&" << ToLower(fSrcPos->GetName());
     120        out << "&" << fSrcPos->GetUniqueName();
    121121    else
    122122        out << "\"" << fSrcName << "\"";
    123123
    124124    if (fHillasSrc)
    125         out << "&" << ToLower(fHillasSrc->GetName());
     125        out << "&" << fHillasSrc->GetUniqueName();
    126126    else
    127127        out << "\"" << fHillasName << "\"";
  • trunk/MagicSoft/Mars/manalysis/MImgCleanStd.cc

    r1477 r1483  
    416416void MImgCleanStd::StreamPrimitive(ofstream &out) const
    417417{
    418     out << "   MImgCleanStd " << ToLower(fName) << "(";
     418    out << "   MImgCleanStd " << GetUniqueName() << "(";
    419419    out << fCleanLvl1 << ", " << fCleanLvl2 << ", \"";
    420420    out << fName << "\", \"" << fTitle << "\");" << endl;
  • trunk/MagicSoft/Mars/manalysis/MSrcPosCam.cc

    r1477 r1483  
    9090void MSrcPosCam::StreamPrimitive(ofstream &out) const
    9191{
    92     out << "   MSrcPosCam " << ToLower(fName) << "(\"";
     92    out << "   MSrcPosCam " << GetUniqueName() << "(\"";
    9393    out << fName << "\", \"" << fTitle << "\");" << endl;
    9494
    95     out << "   " << ToLower(fName) << ".SetXY(" << fX << ", " << fY << ");" << endl;}
     95    out << "   " << GetUniqueName() << ".SetXY(" << fX << ", " << fY << ");" << endl;}
  • trunk/MagicSoft/Mars/mbase/MEvtLoop.cc

    r1481 r1483  
    371371    out << "   MEvtLoop evtloop;" << endl;
    372372    if (fParList)
    373         out << "   evtloop.SetParList(&" << ToLower(fParList->GetName()) << ");" << endl;
     373        out << "   evtloop.SetParList(&" << fParList->GetUniqueName() << ");" << endl;
    374374    else
    375375        out << "   // fParList empty..." << endl;
  • trunk/MagicSoft/Mars/mbase/MParContainer.cc

    r1477 r1483  
    3737#include "MParContainer.h"
    3838
     39#include <ctype.h>       // isdigit
    3940#include <fstream.h>     // ofstream, AsciiWrite
    4041
     
    139140// --------------------------------------------------------------------------
    140141//
     142//  Return a unique name for this container. It is created from
     143//  the container name and the unique Id. (This is mostly used
     144//  in the StreamPrimitive member functions)
     145//
     146const TString MParContainer::GetUniqueName() const
     147{
     148    TString ret = ToLower(fName);
     149
     150    if (isdigit(ret[ret.Length()-1]))
     151        ret+="_";
     152
     153    ret+=GetUniqueID();
     154
     155    return ret;
     156}
     157
     158// --------------------------------------------------------------------------
     159//
    141160//  List MParContainer name and title.
    142161//
     
    359378void MParContainer::SavePrimitive(ofstream &out, Option_t *o)
    360379{
     380    static UInt_t uid = 0;
     381
    361382    if (IsSavedAsPrimitive())
    362383        return;
    363384
     385    SetUniqueID(uid++/*gRandom->Uniform(kMaxInt)*/);
    364386    StreamPrimitive(out);
    365387    SetBit(kIsSavedAsPrimitive);
     
    373395{
    374396    out << "   // Using MParContainer::StreamPrimitive" << endl;
    375     out << "   " << ClassName() << " " << ToLower(fName) << "(\"";
     397    out << "   " << ClassName() << " " << GetUniqueName() << "(\"";
    376398    out << fName << "\", \"" << fTitle << "\");" << endl;
    377399}
  • trunk/MagicSoft/Mars/mbase/MParContainer.h

    r1477 r1483  
    5555    virtual void        FillBuffer(char *&buffer);
    5656
    57     virtual const char *GetDescriptor() const { return Form("%s [%s]", fName.Data(), ClassName()); }
    58     virtual const char *GetName() const       { return fName.Data(); }
    59     virtual const char *GetTitle() const      { return fTitle.Data(); }
    60     virtual ULong_t     Hash() const          { return fName.Hash(); }
    61     virtual Bool_t      IsSortable() const    { return kTRUE; }
     57    virtual const char   *GetDescriptor() const { return Form("%s [%s]", fName.Data(), ClassName()); }
     58    virtual const TString GetUniqueName() const;
     59    virtual const char   *GetName() const       { return fName.Data(); }
     60    virtual const char   *GetTitle() const      { return fTitle.Data(); }
     61    virtual ULong_t       Hash() const          { return fName.Hash(); }
     62    virtual Bool_t        IsSortable() const    { return kTRUE; }
    6263
    6364    virtual void        SetName(const char *name); // *MENU*
  • trunk/MagicSoft/Mars/mbase/MParList.cc

    r1477 r1483  
    5252ClassImp(MParList);
    5353
     54static const TString gsDefName  = "MParList";
     55static const TString gsDefTitle = "A list of Parameter Containers";
     56
    5457// --------------------------------------------------------------------------
    5558//
     
    5962MParList::MParList(const char *name, const char *title)
    6063{
    61     fName  = name  ? name  : "MParList";
    62     fTitle = title ? title : "A list of Parameter Containers";
     64    fName  = name  ? name  : gsDefName.Data();
     65    fTitle = title ? title : gsDefTitle.Data();
    6366
    6467    //
     
    668671void MParList::StreamPrimitive(ofstream &out) const
    669672{
    670     out << "   MParList " << ToLower(fName) << "(\"";
    671     out << fName << "\", \"" << fTitle << "\");" << endl << endl;
     673    out << "   MParList " << GetUniqueName();
     674    if (fName!=gsDefName)
     675    {
     676        out << "(\"" << fName << "\"";
     677        if (fTitle!=gsDefTitle)
     678            out << ", \"" << fTitle << "\"";
     679        out <<")";
     680    }
     681    out << ";" << endl << endl;
    672682
    673683    TIter Next(fContainer);
    674684
    675     TObject *cont = NULL;
    676     while ((cont=Next()))
     685    MParContainer *cont = NULL;
     686    while ((cont=(MParContainer*)Next()))
    677687    {
    678688        cont->SavePrimitive(out, "");
    679689
    680         out << "   " << ToLower(fName) << ".AddToList(&";
    681         out << ToLower(cont->GetName()) << ");" << endl << endl;
    682     }
    683 }
    684 
     690        out << "   " << GetUniqueName() << ".AddToList(&";
     691        out << cont->GetUniqueName() << ");" << endl << endl;
     692    }
     693}
     694
     695// --------------------------------------------------------------------------
     696//
     697// Adds one TNamed object per object in the list. The TNamed object must
     698// be deleted by the user.
     699//
    685700void MParList::GetNames(TObjArray &arr) const
    686701{
     
    689704}
    690705
     706// --------------------------------------------------------------------------
     707//
     708// Sets name and title of each object in the list from the objects in
     709// the array.
     710//
    691711void MParList::SetNames(TObjArray &arr)
    692712{
  • trunk/MagicSoft/Mars/mbase/MTaskList.cc

    r1477 r1483  
    7171ClassImp(MTaskList);
    7272
     73static const TString gsDefName  = "MTaskList";
     74static const TString gsDefTitle = "A list for tasks to be executed";
    7375// --------------------------------------------------------------------------
    7476//
     
    7981MTaskList::MTaskList(const char *name, const char *title)
    8082{
    81     fName  = name  ? name  : "MTaskList";
    82     fTitle = title ? title : "A list for tasks to be executed";
     83    fName  = name  ? name  : gsDefName.Data();
     84    fTitle = title ? title : gsDefTitle.Data();
    8385
    8486    fTasks = new TList;
     
    522524void MTaskList::StreamPrimitive(ofstream &out) const
    523525{
    524     out << "   MTaskList " << ToLower(fName) << "(\"";
    525     out << fName << "\", \"" << fTitle << "\");" << endl << endl;
     526    out << "   MTaskList " << GetUniqueName();
     527    if (fName!=gsDefName)
     528    {
     529        out << "(\"" << fName << "\"";
     530        if (fTitle!=gsDefTitle)
     531            out << ", \"" << fTitle << "\"";
     532        out <<")";
     533    }
     534    out << ";" << endl << endl;
    526535
    527536    TIter Next(fTasks);
    528537
    529     TObject *cont = NULL;
    530     while ((cont=Next()))
     538    MParContainer *cont = NULL;
     539    while ((cont=(MParContainer*)Next()))
    531540    {
    532541        cont->SavePrimitive(out, "");
    533         out << "   " << ToLower(fName) << ".AddToList(&";
    534         out << ToLower(cont->GetName()) << ");" << endl << endl;
     542        out << "   " << GetUniqueName() << ".AddToList(&";
     543        out << cont->GetUniqueName() << ");" << endl << endl;
    535544    }
    536545}
  • trunk/MagicSoft/Mars/mfileio/MReadTree.cc

    r1477 r1483  
    785785void MReadTree::StreamPrimitive(ofstream &out) const
    786786{
    787     TString name = ToLower(fName);
    788 
    789     out << "   " << ClassName() << " " << name << "(\"";
     787    out << "   " << ClassName() << " " << GetUniqueName() << "(\"";
    790788    out << fChain->GetName() << "\", \"" << fName << "\", \"" << fTitle << "\");" << endl;
    791789
     
    793791    TObject *obj = NULL;
    794792    while ((obj=Next()))
    795         out << "   " << name << ".AddFile(\"" << obj->GetTitle() << "\");" << endl;
     793        out << "   " << GetUniqueName() << ".AddFile(\"" << obj->GetTitle() << "\");" << endl;
    796794
    797795    if (!fAutoEnable)
    798         out << "   " << name << ".DisableAutoScheme();" << endl;
     796        out << "   " << GetUniqueName() << ".DisableAutoScheme();" << endl;
    799797
    800798    if (fNumEntry!=0)
    801        out << "   " << name << ".SetEventNum(" << fNumEntry << ");" << endl;
    802 
    803 
    804 }
     799       out << "   " << GetUniqueName() << ".SetEventNum(" << fNumEntry << ");" << endl;
     800
     801
     802}
  • trunk/MagicSoft/Mars/mfileio/MWriteRootFile.cc

    r1477 r1483  
    405405void MWriteRootFile::StreamPrimitive(ofstream &out) const
    406406{
    407     out << "   MWriteRootFile " << ToLower(fName) << "(\"";
     407    out << "   MWriteRootFile " << GetUniqueName() << "(\"";
    408408    out << fOut->GetName() << "\", \"";
    409409    out << fOut->GetOption() << "\", \"";
     
    419419        {
    420420            entry->GetContainer()->SavePrimitive(out);
    421             out << "&" << ToLower(entry->GetContainer()->GetName());
     421            out << "&" << entry->GetContainer()->GetUniqueName();
    422422        }
    423423        else
  • trunk/MagicSoft/Mars/mfilter/MF.cc

    r1481 r1483  
    372372void MF::StreamPrimitive(ofstream &out) const
    373373{
    374     out << "   MF " << ToLower(fName) << "";
    375 }
    376 
     374    out << "   MF " << GetUniqueName() << "";
     375}
     376
  • trunk/MagicSoft/Mars/mfilter/MFAlpha.cc

    r1481 r1483  
    117117        fHillas->SavePrimitive(out);
    118118
    119     out << "   MFParticleId " << ToLower(fName) << "(";
     119    out << "   MFParticleId " << GetUniqueName() << "(";
    120120
    121121    if (fHillas)
    122         out << "&" << ToLower(fHillas->GetName());
     122        out << "&" << fHillas->GetUniqueName();
    123123    else
    124124        out << "\"" << fContName << "\"";
  • trunk/MagicSoft/Mars/mfilter/MFDataMember.cc

    r1481 r1483  
    103103void MFDataMember::StreamPrimitive(ofstream &out) const
    104104{
    105     out << "   MFDataMember " << ToLower(fName) << "(\"";
     105    out << "   MFDataMember " << GetUniqueName() << "(\"";
    106106    out << fData.GetRule() << "\", '";
    107107    out << (fFilterType==kELowerThan?"<":">");
  • trunk/MagicSoft/Mars/mfilter/MFParticleId.cc

    r1481 r1483  
    128128        fMcEvt->SavePrimitive(out);
    129129
    130     out << "   MFParticleId " << ToLower(fName) << "(";
     130    out << "   MFParticleId " << GetUniqueName() << "(";
    131131
    132132    if (fMcEvt)
    133         out << "&" << ToLower(fMcEvt->GetName());
     133        out << "&" << fMcEvt->GetUniqueName();
    134134    else
    135135        out << "\"" << fContName << "\"";
  • trunk/MagicSoft/Mars/mfilter/MFTriggerLvl1.cc

    r1481 r1483  
    123123        fMcTrig->SavePrimitive(out);
    124124
    125     out << "   MFTriggerLvl1 " << ToLower(fName) << "(";
     125    out << "   MFTriggerLvl1 " << GetUniqueName() << "(";
    126126
    127127    if (fMcTrig)
    128         out << "&" << ToLower(fMcTrig->GetName());
     128        out << "&" << fMcTrig->GetUniqueName();
    129129    else
    130130        out << "\"" << fContName << "\"";
  • trunk/MagicSoft/Mars/mhist/MBinning.cc

    r1477 r1483  
    3636ClassImp(MBinning);
    3737
     38static const TString gsDefName  = "MBinning";
     39static const TString gsDefTitle = "Container describing the binning of an axis";
     40
    3841// --------------------------------------------------------------------------
    3942//
     
    4649    //   set the name and title of this object
    4750    //
    48     fName  = name  ? name  : "MBinning";
    49     fTitle = title ? title : "Container describing the binning of an axis";
     51    fName  = name  ? name  : gsDefName.Data();
     52    fTitle = title ? title : gsDefTitle.Data();
    5053
    5154    SetEdges(10, 0, 1);
     
    105108void MBinning::StreamPrimitive(ofstream &out) const
    106109{
    107     out << "   MBinning " << ToLower(fName) << "(\"";
    108     out << fName << "\", \"" << fTitle << "\");" << endl;
     110    out << "   MBinning " << GetUniqueName();
     111    if (fName!=gsDefName)
     112    {
     113        out << "(\"" << fName << "\"";
     114        if (fTitle!=gsDefTitle)
     115            out << ", \"" << fTitle << "\"";
     116        out <<")";
     117    }
     118    out << ";" << endl;
    109119
    110120    if (IsDefault())
     
    113123    if (IsLinear() || IsLogarithmic())
    114124    {
    115         out << "   " << ToLower(fName) << ".SetEdges";
     125        out << "   " << GetUniqueName() << ".SetEdges";
    116126        if (IsLogarithmic())
    117127            out << "Log";
     
    124134    for (int i=0; i<GetNumEdges(); i++)
    125135        out << "      dummy[" << i << "]=" << GetEdges()[i] << ";" << endl;
    126     out << "      " << ToLower(fName) << ".SetEdges(dummy);" << endl;
     136    out << "      " << GetUniqueName() << ".SetEdges(dummy);" << endl;
    127137    out << "   }" << endl;
    128138}
  • trunk/MagicSoft/Mars/mhist/MFillH.cc

    r1481 r1483  
    358358        fParContainer->SavePrimitive(out);
    359359
    360     out << "   MFillH " << ToLower(fName) << "(";
     360    out << "   MFillH " << GetUniqueName() << "(";
    361361
    362362    if (fH)
    363         out << "&" << ToLower(fH->GetName());
     363        out << "&" << fH->GetUniqueName();
    364364    else
    365365        out << "\"" << fHName << "\"";
    366366
    367367    if (fParContainer)
    368         out << ", &" << ToLower(fParContainer->GetName());
     368        out << ", &" << fParContainer->GetUniqueName();
    369369    else
    370370        if (!fParContainerName.IsNull())
  • trunk/MagicSoft/Mars/mhist/MH3.cc

    r1481 r1483  
    7878ClassImp(MH3);
    7979
     80static const TString gsDefName  = "MH3";
     81static const TString gsDefTitle = "Container for a %dD Mars Histogram";
     82
    8083MH3::MH3() : fDimension(0), fHist(NULL)
    8184{
    82     fName  = "MH3";
    83     fTitle = "Container for a 1D Mars Histogram";
     85    fName  = gsDefName;
     86    fTitle = Form(gsDefTitle.Data(), 0);
    8487
    8588    fData[0]  = fData[1]  = fData[2]  = NULL;
     
    101104    fData[2] = NULL;
    102105
    103     fName  = "MH3";
    104     fTitle = "Container for a 1D Mars Histogram";
     106    fName  = gsDefName;
     107    fTitle = Form(gsDefTitle.Data(), 1);
    105108
    106109    fHist->SetDirectory(NULL);
     
    127130    fData[2] = NULL;
    128131
    129     fName  = "MH3";
    130     fTitle = "Container for a 2D Mars Histogram";
     132    fName  = gsDefName;
     133    fTitle = Form(gsDefTitle.Data(), 2);
    131134
    132135    fHist->SetDirectory(NULL);
     
    153156    fData[2] = new MDataChain(memberz);
    154157
    155     fName  = "MH3";
    156     fTitle = "Container for a 3D Mars Histogram";
     158    fName  = gsDefName;
     159    fTitle = Form(gsDefTitle.Data(), 3);
    157160
    158161    fHist->SetDirectory(NULL);
     
    386389void MH3::StreamPrimitive(ofstream &out) const
    387390{
    388     TString name = ToLower(fName);
     391    TString name = GetUniqueName();
    389392
    390393    out << "   MH3 " << name << "(\"";
     
    397400    out << ");" << endl;
    398401
    399     out << "   " << name << ".SetName(\"" << fName << "\");" << endl;
    400     out << "   " << name << ".SetTitle(\"" << fTitle << "\");" << endl;
     402    if (fName!=gsDefName)
     403        out << "   " << name << ".SetName(\"" << fName << "\");" << endl;
     404
     405    if (fTitle!=Form(gsDefTitle.Data(), fDimension))
     406        out << "   " << name << ".SetTitle(\"" << fTitle << "\");" << endl;
    401407
    402408    switch (fDimension)
Note: See TracChangeset for help on using the changeset viewer.