Changeset 1218 for trunk/MagicSoft/Mars


Ignore:
Timestamp:
02/21/02 12:08:03 (23 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/Changelog

    r1217 r1218  
    11                                                                  -*-*- END -*-*-
     2
     3 2002/02/21: Thomas Bretz
     4 
     5   * manalysis/MHillas.[h,cc]:
     6     - changed fMeanx and fMeany to fMeanX and fMeanY to match the names
     7       of the getter functions, needed by TDataMember::GetterMethod
     8     - commented out WriteAscii (replaced by more general in MParContainer
     9       and MWriteAsciiFile)
     10
     11    * manalysis/MHillasSrc.[h,cc], mmc/MMcEvt.[hxx, cxx]:
     12      - commented out WriteAscii (replaced by more general in MParContainer
     13        and MWriteAsciiFile)
     14     
     15    * mbase/MFilterList.cc:
     16      - removed a nonsens comment
     17   
     18    * mbase/MGList.cc:
     19      - relay on the bugfix for DynamicCast
     20   
     21    * mbase/MParContainer.[h,cc]:
     22      - implemented WriteDataMember to have a more general interface
     23        for readable output.
     24      - changed ofstream to a more general ostream
     25 
     26    * mbase/MWriteAsciiFile.[cc,h]:
     27      - generalized ascii writer to be able to write single data members
     28
     29
    230
    331 2002/02/13: Thomas Bretz
  • trunk/MagicSoft/Mars/macros/MagicHillas.C

    r1216 r1218  
    104104    MFillH hfill2s("HistSource  [MHHillasSrc]", "HillasSource");
    105105    MFillH hfill2a("HistAntiSrc [MHHillasSrc]", "HillasAntiSrc");
    106 
     106/*
    107107    MWriteRootFile write("hillas.root");
    108108    write.AddContainer("MHillas",       "Hillas");
     
    110110    write.AddContainer("HillasAntiSrc", "Hillas");
    111111    write.AddContainer("MHStarMap");
     112*/
     113    MWriteAsciiFile write("hillas.txt");
     114    write.AddContainer("MHillas", "fLength");
     115    write.AddContainer("MHillas", "fWidth");
     116    write.AddContainer("MHillas");
    112117
    113118    tlist.AddToList(&read);
     
    135140    // Execute your analysis
    136141    //
    137     if (!evtloop.Eventloop())
     142    if (!evtloop.Eventloop(5))
    138143        return;
     144
     145    return;
    139146
    140147    tlist.PrintStatistics();
  • trunk/MagicSoft/Mars/manalysis/MHillas.cc

    r1211 r1218  
    3636// fDelta    angle of major axis wrt x-axis
    3737// fSize     total sum of pixels
    38 // fMeanx    x of center of ellipse
    39 // fMeany    y of center of ellipse
     38// fMeanX    x of center of ellipse
     39// fMeanY    y of center of ellipse
    4040//
    4141/////////////////////////////////////////////////////////////////////////////
     
    8989    fDelta  = 0;
    9090    fSize   = 0;
    91     fMeanx  = 0;
    92     fMeany  = 0;
     91    fMeanX  = 0;
     92    fMeanY  = 0;
    9393
    9494    Clear();
     
    101101void MHillas::Print(Option_t *) const
    102102{
    103     Double_t atg = atan2(fMeany, fMeanx)*kRad2Deg;
     103    Double_t atg = atan2(fMeanY, fMeanX)*kRad2Deg;
    104104
    105105    if (atg<0)
     
    110110    *fLog << " - Length   [mm]  = " << fLength << endl;
    111111    *fLog << " - Width    [mm]  = " << fWidth  << endl;
    112     *fLog << " - Meanx    [mm]  = " << fMeanx  << endl;
    113     *fLog << " - Meany    [mm]  = " << fMeany  << endl;
     112    *fLog << " - Meanx    [mm]  = " << fMeanX  << endl;
     113    *fLog << " - Meany    [mm]  = " << fMeanY  << endl;
    114114    *fLog << " - Delta    [deg] = " << fDelta*kRad2Deg << endl;
    115115    *fLog << " - atg(y/x) [deg] = " << atg     << endl;
     
    125125{
    126126     fEllipse->SetLineWidth(2);
    127      fEllipse->PaintEllipse(fMeanx, fMeany, fLength, fWidth,
     127     fEllipse->PaintEllipse(fMeanX, fMeanY, fLength, fWidth,
    128128                            0, 360, fDelta*kRad2Deg+180);
    129129}
     
    143143    Clear();
    144144
    145     fEllipse = new TEllipse(fMeanx, fMeany, fLength, fWidth,
     145    fEllipse = new TEllipse(fMeanX, fMeanY, fLength, fWidth,
    146146                            0, 360, fDelta*kRad2Deg+180);
    147147
     
    155155     fEllipse->SetR2(fWidth);
    156156     fEllipse->SetTheta(fDelta*kRad2Deg+180);
    157      fEllipse->SetX1(fMeanx);
    158      fEllipse->SetY1(fMeany);
     157     fEllipse->SetX1(fMeanX);
     158     fEllipse->SetY1(fMeanY);
    159159
    160160     fEllipse->SetLineWidth(2);
    161      fEllipse->PaintEllipse(fMeanx, fMeany, fLength, fWidth,
     161     fEllipse->PaintEllipse(fMeanX, fMeanY, fLength, fWidth,
    162162                            0, 360, fDelta*kRad2Deg+180);
    163163
     
    216216    // -----------------------------------------------------
    217217    //
    218     fMeanx = 0;
    219     fMeany = 0;
     218    fMeanX = 0;
     219    fMeanY = 0;
    220220    fSize  = 0;
    221221
     
    236236
    237237        fSize  += nphot;                             // [counter]
    238         fMeanx += nphot * gpix.GetX();               // [mm]
    239         fMeany += nphot * gpix.GetY();               // [mm]
     238        fMeanX += nphot * gpix.GetX();               // [mm]
     239        fMeanY += nphot * gpix.GetY();               // [mm]
    240240
    241241        npix++;
     
    248248        return kFALSE;
    249249
    250     fMeanx /= fSize;                                 // [mm]
    251     fMeany /= fSize;                                 // [mm]
     250    fMeanX /= fSize;                                 // [mm]
     251    fMeanY /= fSize;                                 // [mm]
    252252
    253253    //
     
    267267
    268268        const MGeomPix &gpix = geom[pix.GetPixId()];
    269         const float dx = gpix.GetX() - fMeanx;       // [mm]
    270         const float dy = gpix.GetY() - fMeany;       // [mm]
     269        const float dx = gpix.GetX() - fMeanX;       // [mm]
     270        const float dy = gpix.GetY() - fMeanY;       // [mm]
    271271
    272272        const float nphot = pix.GetNumPhotons();     // [#phot]
     
    311311    fin >> fDelta;
    312312    fin >> fSize;
    313     fin >> fMeanx;
    314     fin >> fMeany;
    315 }
    316 
    317 // --------------------------------------------------------------------------
    318 //
     313    fin >> fMeanX;
     314    fin >> fMeanY;
     315}
     316
     317// --------------------------------------------------------------------------
     318/*
    319319void MHillas::AsciiWrite(ofstream &fout) const
    320320{
     
    323323    fout << fDelta  << " ";
    324324    fout << fSize   << " ";
    325     fout << fMeanx  << " ";
    326     fout << fMeany;
    327 }
     325    fout << fMeanX  << " ";
     326    fout << fMeanY;
     327}
     328*/
  • trunk/MagicSoft/Mars/manalysis/MHillas.h

    r1203 r1218  
    1919    Float_t   fDelta;    // [rad]       angle of major axis with x-axis
    2020    Float_t   fSize;     // [#CerPhot]  sum of content of all pixels (number of Cherenkov photons)
    21     Float_t   fMeanx;    // [mm]        x-coordinate of center of ellipse
    22     Float_t   fMeany;    // [mm]        y-coordinate of center of ellipse
     21    Float_t   fMeanX;    // [mm]        x-coordinate of center of ellipse
     22    Float_t   fMeanY;    // [mm]        y-coordinate of center of ellipse
    2323
    2424    Float_t   fSinDelta; //! [1] sin of Delta (to be used in derived classes)
     
    5353    Float_t GetDelta() const  { return fDelta; }
    5454    Float_t GetSize() const   { return fSize; }
    55     Float_t GetMeanX() const  { return fMeanx; }
    56     Float_t GetMeanY() const  { return fMeany; }
     55    Float_t GetMeanX() const  { return fMeanX; }
     56    Float_t GetMeanY() const  { return fMeanY; }
    5757
    5858    virtual void AsciiRead(ifstream &fin);
    59     virtual void AsciiWrite(ofstream &fout) const;
     59    //virtual void AsciiWrite(ofstream &fout) const;
    6060
    6161    ClassDef(MHillas, 1) // Storage Container for Hillas Parameter
  • trunk/MagicSoft/Mars/manalysis/MHillasSrc.cc

    r1211 r1218  
    101101//
    102102// overloaded MParContainer to write MHillasSrc to an ascii file
    103 //
     103/*
    104104void MHillasSrc::AsciiWrite(ofstream &fout) const
    105105{
    106106    fout << fAlpha << " " << fDist;
    107107}
     108*/
  • trunk/MagicSoft/Mars/manalysis/MHillasSrc.h

    r1203 r1218  
    3737
    3838    virtual void AsciiRead(ifstream &fin);
    39     virtual void AsciiWrite(ofstream &fout) const;
     39    //virtual void AsciiWrite(ofstream &fout) const;
    4040
    4141    ClassDef(MHillasSrc, 1) // Container to hold source position dependant parameters
  • trunk/MagicSoft/Mars/mbase/MFilterList.cc

    r1080 r1218  
    143143    const char *name = filter->GetName();
    144144
    145     // FIXME: We agreed to put the task into list in an ordered way.
    146 
    147145    if (fFilters.FindObject(filter))
    148146    {
  • trunk/MagicSoft/Mars/mbase/MGList.cc

    r1116 r1218  
    9898    //      Is this another bug in root?
    9999    //
     100#if ROOT_VERSION_CODE < ROOT_VERSION(3,02,07)
    100101    if (!obj->IsA()->InheritsFrom(TGWidget::Class()))
    101102        return NULL;
     103#endif
    102104
    103105    return (TGWidget*)obj->IsA()->DynamicCast(TGWidget::Class(), obj);
  • trunk/MagicSoft/Mars/mbase/MParContainer.cc

    r1211 r1218  
    214214// --------------------------------------------------------------------------
    215215//
     216//  Write out a data member given as a TDataMember object to an output stream.
     217//
     218Bool_t MParContainer::WriteDataMember(ostream &out, TDataMember *member) const
     219{
     220    if (!member)
     221        return kFALSE;
     222
     223    if (!member->IsPersistent())
     224        return kFALSE;
     225
     226    /*const*/ TMethodCall *call = member->GetterMethod(); //FIXME: Root
     227    if (!call)
     228        return kFALSE;
     229
     230    switch (call->ReturnType())
     231    {
     232    case TMethodCall::kLong:
     233        Long_t l;
     234        call->Execute((void*)this, l); // FIXME: const, root
     235        out << l << " ";
     236        return kTRUE;
     237
     238    case TMethodCall::kDouble:
     239        Double_t d;
     240        call->Execute((void*)this, d); // FIXME: const, root
     241        out << d << " ";
     242        return kTRUE;
     243
     244    case TMethodCall::kOther:
     245        /* someone may want to enhance this? */
     246        return kFALSE;
     247    }
     248
     249    return kFALSE;
     250}
     251
     252// --------------------------------------------------------------------------
     253//
     254//  Write out a data member given by name to an output stream.
     255//
     256Bool_t MParContainer::WriteDataMember(ostream &out, const char *member) const
     257{
     258    return WriteDataMember(out, IsA()->GetDataMember(member));
     259}
     260
     261// --------------------------------------------------------------------------
     262//
    216263//  If you want to use Ascii-Input/-Output (eg. MWriteAsciiFile) of a
    217264//  container, you may overload this function. If you don't overload it
     
    221268//  floating point (Float_t, Double_t, ...) type are written.
    222269//
    223 void MParContainer::AsciiWrite(ofstream &fout) const
     270void MParContainer::AsciiWrite(ostream &out) const
    224271{
    225272    // *fLog << warn << "To use the the ascii output of " << GetName();
     
    230277    TIter Next(IsA()->GetListOfDataMembers());
    231278    while ((data=(TDataMember*)Next()))
    232     {
    233         if (!data->IsPersistent())
    234             continue;
    235 
    236         /*const*/ TMethodCall *call = data->GetterMethod(); //FIXME: Root
    237         if (!call)
    238             continue;
    239 
    240         switch (call->ReturnType())
    241         {
    242         case TMethodCall::kLong:
    243             Long_t l;
    244             call->Execute((void*)this, l); // FIXME: const, root
    245             fout << l << " ";
    246             continue;
    247 
    248         case TMethodCall::kDouble:
    249             Double_t d;
    250             call->Execute((void*)this, d); // FIXME: const, root
    251             fout << d << " ";
    252             continue;
    253 
    254         case TMethodCall::kOther:
    255             /* someone may want to enhance this? */
    256             continue;
    257         }
    258     }
    259 }
     279        WriteDataMember(out, data);
     280}
  • trunk/MagicSoft/Mars/mbase/MParContainer.h

    r1086 r1218  
    2222class ofstream;
    2323class ifstream;
     24
     25class TDataMember;
    2426
    2527class MParContainer : public TObject
     
    6466    virtual void   SetReadyToSave(Bool_t flag=kTRUE) { fReadyToSave=flag; }
    6567
     68    Bool_t WriteDataMember(ostream &out, const char *member) const;
     69    Bool_t WriteDataMember(ostream &out, TDataMember *member) const;
     70
    6671    virtual void AsciiRead(ifstream &fin);
    67     virtual void AsciiWrite(ofstream &fout) const;
     72    virtual void AsciiWrite(ostream &out) const;
    6873
    6974    ClassDef(MParContainer, 0)  //The basis for all parameter containers
  • trunk/MagicSoft/Mars/mbase/MWriteAsciiFile.cc

    r1192 r1218  
    4444#include <fstream.h>
    4545
     46#include <TClass.h>      // IsA
     47#include <TMethodCall.h> // TMethodCall, AsciiWrite
     48#include <TDataMember.h> // TDataMember, AsciiWrite
     49
    4650#include "MLog.h"
    4751#include "MLogManip.h"
     
    8185    Init(filename, name, title);
    8286
    83     AddContainer(contname);
     87    if (contname)
     88        AddContainer(contname);
    8489}
    8590
     
    100105    Init(filename, name, title);
    101106
    102     AddContainer(cont);
     107    if (cont)
     108        AddContainer(cont);
    103109}
    104110
     
    111117{
    112118    fContNames.SetOwner();
     119    fMembers.SetOwner();
    113120
    114121    delete fOut;
     
    130137    Int_t num = fContainer.GetEntries();
    131138
    132     TIter Next(&fContainer);
    133 
    134     while ((cont=(MParContainer*)Next()))
     139    TIter NextCont(&fContainer);
     140    TIter NextMemb(&fMembers);
     141
     142    while ((cont=(MParContainer*)NextCont()))
    135143    {
     144        const TObject *memb = NextMemb();
     145
    136146        if (!cont->IsReadyToSave())
    137147            continue;
    138148
    139         cont->AsciiWrite(*fOut);
     149        if (memb->GetName()[0]=='\0')
     150            cont->AsciiWrite(*fOut);
     151        else
     152        {
     153            if (!cont->WriteDataMember(*fOut, memb->GetName()))
     154                continue;
     155        }
     156
    140157        *fOut << " ";
    141158        written = kTRUE;
     
    183200        }
    184201
    185         AddContainer(cont);
     202        AddContainer(cont, obj->GetTitle());
    186203    }
    187204
     
    193210// Add another container (by name) to be written to the ascii file.
    194211// The container will be output one after each other in one line.
    195 //
    196 void MWriteAsciiFile::AddContainer(const char *cname)
    197 {
    198     TNamed *named = new TNamed(cname, "");
     212// If you want to write only one data member of the container
     213// specify the name of the data member (eg. fAlpha) Make sure,
     214// that a "GetteMethod" for this data type exists (strif the f and
     215// replace it by Get)
     216//
     217void MWriteAsciiFile::AddContainer(const char *cname, const char *member)
     218{
     219    TNamed *named = new TNamed(cname, member);
    199220    fContNames.AddLast(named);
    200221}
     
    204225// Add another container (by pointer) to be written to the ascii file.
    205226// The container will be output one after each other in one line.
    206 //
    207 void MWriteAsciiFile::AddContainer(MParContainer *cont)
     227// If you want to write only one data member of the container
     228// specify the name of the data member (eg. fAlpha) Make sure,
     229// that a "GetteMethod" for this data type exists (strif the f and
     230// replace it by Get)
     231//
     232void MWriteAsciiFile::AddContainer(MParContainer *cont, const char *member)
    208233{
    209234    fContainer.AddLast(cont);
    210 }
    211 
     235
     236    TNamed *named = new TNamed(member, "");
     237    fMembers.AddLast(named);
     238}
     239
Note: See TracChangeset for help on using the changeset viewer.