Ignore:
Timestamp:
03/07/02 15:28:30 (23 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars/mbase
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/mbase/MParContainer.cc

    r1229 r1235  
    217217//  Write out a data member given as a TDataMember object to an output stream.
    218218//
    219 Bool_t MParContainer::WriteDataMember(ostream &out, const TDataMember *member) const
     219Bool_t MParContainer::WriteDataMember(ostream &out, const TDataMember *member, Double_t scale) const
    220220{
    221221    if (!member)
     
    245245        Double_t d;
    246246        call->Execute((void*)this, d); // FIXME: const, root
    247         out << d << " ";
     247        out << (scale*d) << " ";
    248248        return kTRUE;
    249249
     
    260260//  Write out a data member given by name to an output stream.
    261261//
    262 Bool_t MParContainer::WriteDataMember(ostream &out, const char *member) const
     262Bool_t MParContainer::WriteDataMember(ostream &out, const char *member, Double_t scale) const
    263263{
    264264    /*const*/ TClass *cls = IsA()->GetBaseDataMember(member);
     
    266266        return kFALSE;
    267267
    268     return WriteDataMember(out, cls->GetDataMember(member));
     268    return WriteDataMember(out, cls->GetDataMember(member), scale);
    269269}
    270270
  • trunk/MagicSoft/Mars/mbase/MParContainer.h

    r1222 r1235  
    6666    virtual void   SetReadyToSave(Bool_t flag=kTRUE) { fReadyToSave=flag; }
    6767
    68     Bool_t WriteDataMember(ostream &out, const char *member) const;
    69     Bool_t WriteDataMember(ostream &out, const TDataMember *member) const;
     68    Bool_t WriteDataMember(ostream &out, const char *member, Double_t scale=1) const;
     69    Bool_t WriteDataMember(ostream &out, const TDataMember *member, Double_t scale=1) const;
    7070    Bool_t WriteDataMember(ostream &out, const TList *list) const;
    7171
  • trunk/MagicSoft/Mars/mbase/MWriteAsciiFile.cc

    r1222 r1235  
    148148    while ((cont=(MParContainer*)NextCont()))
    149149    {
    150         const TObject *memb = NextMemb();
     150        const MScale *memb = (MScale*)NextMemb();
    151151
    152152        if (!cont->IsReadyToSave())
     
    160160        else
    161161        {
    162             if (!cont->WriteDataMember(*fOut, memb->GetName()))
     162            if (!cont->WriteDataMember(*fOut, memb->GetName(), memb->GetScale()))
    163163                continue;
    164164        }
     
    196196Bool_t MWriteAsciiFile::GetContainer(MParList *pList)
    197197{
    198     TObject *obj = NULL;
     198    MScale *obj = NULL;
    199199
    200200    TIter Next(&fContNames);
    201201
    202     while ((obj=Next()))
     202    while ((obj=(MScale*)Next()))
    203203    {
    204204        const char *name = obj->GetName();
     
    211211        }
    212212
    213         AddContainer(cont, obj->GetTitle());
     213        AddContainer(cont, obj->GetTitle(), obj->GetScale());
    214214    }
    215215
     
    223223// If you want to write only one data member of the container
    224224// specify the name of the data member (eg. fAlpha) Make sure,
    225 // that a "GetteMethod" for this data type exists (strif the f and
     225// that a "GetteMethod" for this data type exists (strip the f and
    226226// replace it by Get)
    227 //
    228 void MWriteAsciiFile::AddContainer(const char *cname, const char *member)
    229 {
    230     TNamed *named = new TNamed(cname, member);
    231     fContNames.AddLast(named);
     227// If you specify a single data member you can add a scale-factor which
     228// is (in case of the data member being a floating point value) multiplied
     229// with the data member value. This is usefull if you are want to
     230// change the scale (unit) of a data member for writing (eg.
     231// writing degrees for the hillas parameters instead of the internally
     232// used millimeters)
     233//
     234void MWriteAsciiFile::AddContainer(const char *cname, const char *member, Double_t scale)
     235{
     236    MScale *name = new MScale(cname, member, scale);
     237    fContNames.AddLast(name);
    232238}
    233239
     
    238244// If you want to write only one data member of the container
    239245// specify the name of the data member (eg. fAlpha) Make sure,
    240 // that a "GetteMethod" for this data type exists (strif the f and
     246// that a "GetteMethod" for this data type exists (strip the f and
    241247// replace it by Get)
    242 //
    243 void MWriteAsciiFile::AddContainer(MParContainer *cont, const char *member)
     248// If you specify a single data member you can add a scale-factor which
     249// is (in case of the data member being a floating point value) multiplied
     250// with the data member value. This is usefull if you are want to
     251// change the scale (unit) of a data member for writing (eg.
     252// writing degrees for the hillas parameters instead of the internally
     253// used millimeters)
     254//
     255void MWriteAsciiFile::AddContainer(MParContainer *cont, const char *member, Double_t scale)
    244256{
    245257    fContainer.AddLast(cont);
    246258
    247     TNamed *named = new TNamed(member, "");
    248     fMembers.AddLast(named);
    249 }
    250 
     259    MScale *name = new MScale(member, "", scale);
     260    fMembers.AddLast(name);
     261}
     262
  • trunk/MagicSoft/Mars/mbase/MWriteAsciiFile.h

    r1219 r1235  
    1212{
    1313private:
     14    class MScale : public TNamed
     15    {
     16    private:
     17        Double_t fScale;
     18    public:
     19        MScale(const char *name, const char *title, Double_t scale)
     20            : TNamed(name, title), fScale(scale) {}
     21        Double_t GetScale() const { return fScale; }
     22    };
     23
    1424    ofstream *fOut;
    1525
     
    1727    TObjArray fContainer;
    1828    TObjArray fMembers;
     29    TObjArray fScale;
    1930
    2031    TString fNameFile;
     
    3445    ~MWriteAsciiFile();
    3546
    36     void AddContainer(const char *cname, const char *member="");
    37     void AddContainer(MParContainer *cont, const char *member="");
     47    void AddContainer(const char *cname, const char *member="", Double_t scale=1);
     48    void AddContainer(MParContainer *cont, const char *member="", Double_t scale=1);
    3849
    3950    ClassDef(MWriteAsciiFile, 0) // Class to write one container to an ascii file
Note: See TracChangeset for help on using the changeset viewer.