Changeset 1222


Ignore:
Timestamp:
02/21/02 14:46:59 (23 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/macros/MagicHillas.C

    r1221 r1222  
    4040
    4141    //
    42     // Here I create MHillasExt, which replaces the usage of MHillas
     42    // Uncomment this two line if you want to use MHillasExt instead
     43    // of MHillas
    4344    //
    44     MHillasExt hext;
    45     plist.AddToList(&hext);
     45    //MHillasExt hext;
     46    //plist.AddToList(&hext);
    4647
    4748    //
     
    110111    MFillH hfill2s("HistSource  [MHHillasSrc]", "HillasSource");
    111112    MFillH hfill2a("HistAntiSrc [MHHillasSrc]", "HillasAntiSrc");
    112 /*
     113
    113114    MWriteRootFile write("hillas.root");
    114115    write.AddContainer("MHillas",       "Hillas");
     
    116117    write.AddContainer("HillasAntiSrc", "Hillas");
    117118    write.AddContainer("MHStarMap");
    118 */
    119     MWriteAsciiFile write("hillas.txt");
    120     write.AddContainer("MHillas", "fLength");
    121     write.AddContainer("MHillas", "fConc");
    122     write.AddContainer("MHillas");
     119
     120    /*
     121     MWriteAsciiFile write("hillas.txt");
     122     write.AddContainer("MHillas", "fLength");
     123     write.AddContainer("MHillas", "fConc");
     124     write.AddContainer("MHillas");
     125     */
    123126
    124127    tlist.AddToList(&read);
     
    149152        return;
    150153
    151     return;
    152 
    153154    tlist.PrintStatistics();
    154155
  • trunk/MagicSoft/Mars/manalysis/MHillasExt.cc

    r1220 r1222  
    4141
    4242#include <fstream.h>
    43 #include <math.h>
    4443
    4544#include "MGeomPix.h"
     
    162161    m3y /= GetSize();
    163162
    164     fM3Long  = m3x<0 ? -pow(fabs(m3x), 1./3) : pow(fabs(m3x), 1./3); // [mm]
    165     fM3Trans = m3y<0 ? -pow(fabs(m3y), 1./3) : pow(fabs(m3y), 1./3); // [mm]
     163    fM3Long  = m3x<0 ? -pow(-m3x, 1./3) : pow(m3x, 1./3); // [mm]
     164    fM3Trans = m3y<0 ? -pow(-m3y, 1./3) : pow(m3y, 1./3); // [mm]
    166165
    167166    SetReadyToSave();
     
    184183
    185184// -------------------------------------------------------------------------
    186 //
     185/*
    187186void MHillasExt::AsciiWrite(ofstream &fout) const
    188187{
     
    196195    fout << fM3Trans;
    197196}
     197*/
  • trunk/MagicSoft/Mars/manalysis/MHillasExt.h

    r1203 r1222  
    2424    void Reset();
    2525
     26    Float_t GetConc() const    { return fConc; }
     27    Float_t GetConc1() const   { return fConc1; }
     28    Float_t GetAsym() const    { return fAsym; }
     29    Float_t GetM3Long() const  { return fM3Long; }
     30    Float_t GetM3Trans() const { return fM3Trans; }
     31
    2632    Bool_t Calc(const MGeomCam &geom, const MCerPhotEvt &pix);
    2733
     
    2935
    3036    void AsciiRead(ifstream &fin);
    31     void AsciiWrite(ofstream &fout) const;
     37    //void AsciiWrite(ofstream &fout) const;
    3238
    3339    ClassDef(MHillasExt, 1) // Storage Container for extended Hillas Parameter
  • trunk/MagicSoft/Mars/mbase/MParContainer.cc

    r1218 r1222  
    4040
    4141#include <TClass.h>      // IsA
     42#include <TBaseClass.h>  // GetClassPointer
    4243#include <TROOT.h>       // TROOT::Identlevel
    4344#include <TMethodCall.h> // TMethodCall, AsciiWrite
     
    216217//  Write out a data member given as a TDataMember object to an output stream.
    217218//
    218 Bool_t MParContainer::WriteDataMember(ostream &out, TDataMember *member) const
     219Bool_t MParContainer::WriteDataMember(ostream &out, const TDataMember *member) const
    219220{
    220221    if (!member)
    221222        return kFALSE;
    222223
    223     if (!member->IsPersistent())
    224         return kFALSE;
    225 
    226     /*const*/ TMethodCall *call = member->GetterMethod(); //FIXME: Root
     224    if (!member->IsPersistent() || member->Property()&kIsStatic)
     225        return kFALSE;
     226
     227    /*const*/ TMethodCall *call = ((TDataMember*)member)->GetterMethod(); //FIXME: Root
    227228    if (!call)
    228         return kFALSE;
     229    {
     230        *fLog << warn << "Sorry, no getter method found for " << member->GetName() << endl;
     231        return kFALSE;
     232    }
    229233
    230234    switch (call->ReturnType())
     
    256260Bool_t MParContainer::WriteDataMember(ostream &out, const char *member) const
    257261{
    258     return WriteDataMember(out, IsA()->GetDataMember(member));
     262    /*const*/ TClass *cls = IsA()->GetBaseDataMember(member);
     263    if (!cls)
     264        return kFALSE;
     265
     266    return WriteDataMember(out, cls->GetDataMember(member));
     267}
     268
     269// --------------------------------------------------------------------------
     270//
     271//  Write out a data member from a given TList of TDataMembers.
     272//  returns kTRUE when at least one member was successfully written
     273//
     274Bool_t MParContainer::WriteDataMember(ostream &out, const TList *list) const
     275{
     276    Bool_t rc = kFALSE;
     277
     278    TDataMember *data = NULL;
     279
     280    TIter Next(list);
     281    while ((data=(TDataMember*)Next()))
     282        rc |= WriteDataMember(out, data);
     283
     284    return rc;
    259285}
    260286
     
    267293//  Only data members which are of integer (Bool_t, Int_t, ...) or
    268294//  floating point (Float_t, Double_t, ...) type are written.
    269 //
    270 void MParContainer::AsciiWrite(ostream &out) const
     295//  returns kTRUE when at least one member was successfully written
     296//
     297Bool_t MParContainer::AsciiWrite(ostream &out) const
    271298{
    272299    // *fLog << warn << "To use the the ascii output of " << GetName();
    273300    // *fLog << " you have to overload " << ClassName() << "::AsciiWrite." << endl;
    274301
    275     TDataMember *data = NULL;
    276 
    277     TIter Next(IsA()->GetListOfDataMembers());
    278     while ((data=(TDataMember*)Next()))
    279         WriteDataMember(out, data);
    280 }
     302    Bool_t rc = WriteDataMember(out, IsA()->GetListOfDataMembers());
     303
     304    TIter NextBaseClass(IsA()->GetListOfBases());
     305    TBaseClass *base;
     306    while ((base = (TBaseClass*) NextBaseClass()))
     307    {
     308        /*const*/ TClass *cls = base->GetClassPointer();
     309
     310        if (!cls)
     311            continue;
     312
     313        rc |= WriteDataMember(out, cls->GetListOfDataMembers());
     314    }
     315
     316    return rc;
     317}
  • trunk/MagicSoft/Mars/mbase/MParContainer.h

    r1218 r1222  
    6767
    6868    Bool_t WriteDataMember(ostream &out, const char *member) const;
    69     Bool_t WriteDataMember(ostream &out, TDataMember *member) const;
     69    Bool_t WriteDataMember(ostream &out, const TDataMember *member) const;
     70    Bool_t WriteDataMember(ostream &out, const TList *list) const;
    7071
    7172    virtual void AsciiRead(ifstream &fin);
    72     virtual void AsciiWrite(ostream &out) const;
     73    virtual Bool_t AsciiWrite(ostream &out) const;
    7374
    7475    ClassDef(MParContainer, 0)  //The basis for all parameter containers
  • trunk/MagicSoft/Mars/mbase/MWriteAsciiFile.cc

    r1219 r1222  
    154154
    155155        if (memb->GetName()[0]=='\0')
    156             cont->AsciiWrite(*fOut);
     156        {
     157            if (!cont->AsciiWrite(*fOut))
     158                continue;
     159        }
    157160        else
    158161        {
     
    167170    }
    168171
    169     if (written)
    170         *fOut << endl;
     172    if (!written)
     173        return;
     174
     175    *fOut << endl;
    171176
    172177    if (num!=0)
    173       *fLog << warn << "Warning - given number of containers doesn't fit number of written containers." << endl;
     178        *fLog << warn << "Warning - given number of containers doesn't fit number of written containers." << endl;
    174179}
    175180
Note: See TracChangeset for help on using the changeset viewer.