Changeset 9519 for trunk


Ignore:
Timestamp:
10/26/09 15:13:28 (15 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars
Files:
7 edited

Legend:

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

    r9039 r9519  
    7272// --------------------------------------------------------------------------
    7373//
     74// Remove objects matching the id (the first character of their class
     75// name) recuresively
     76//
     77void MStatusArray::RecursiveDelete(TVirtualPad *p, const char id) const
     78{
     79    if (!p)
     80        return;
     81
     82    TIter Next2(p->GetListOfPrimitives());
     83    TObject *o=0;
     84    while ((o=Next2()))
     85    {
     86        if (!dynamic_cast<TVirtualPad*>(o) && (o->ClassName()[0]==id || id==0))
     87            delete p->GetListOfPrimitives()->Remove(o);
     88        else
     89            RecursiveDelete(dynamic_cast<TVirtualPad*>(o), id);
     90    }
     91
     92}
     93
     94// --------------------------------------------------------------------------
     95//
     96// Make sure to set the kMustCleanup for all object in our tree
     97// which will later be deleted when the array is destructed.
     98//
     99void MStatusArray::SetCleanup(TObject *obj) const
     100{
     101    if (!obj)
     102        return;
     103
     104    TVirtualPad *pad = dynamic_cast<TVirtualPad*>(obj);
     105
     106    // Do not set the bit for pads because it would end in
     107    // endless recursions
     108    if (pad && !dynamic_cast<TCanvas*>(obj))
     109        obj->ResetBit(kMustCleanup);
     110    else
     111        obj->SetBit(kMustCleanup);
     112
     113    if (!pad)
     114        return;
     115
     116    TIter Next(pad->GetListOfPrimitives());
     117    TObject *o=0;
     118    while ((o=Next()))
     119        SetCleanup(o);
     120}
     121
     122// --------------------------------------------------------------------------
     123//
     124// Try to do a delete of the whole list in a way which is less vulnarable
     125// to double deletion due to wrongly set bits or other things
     126//
     127void MStatusArray::Delete(Option_t *)
     128{
     129    // Add this to the list of cleanups to ensure as many cleaning
     130    // operations as possible are propagated
     131    gROOT->GetListOfCleanups()->Add(this);
     132
     133    // First make sure that all kMustCleanup bits are se
     134    TIter Next(this);
     135    TObject *o=0;
     136    while ((o=Next()))
     137        SetCleanup(o);
     138
     139    // Now delete the MARS object first because we have full control
     140    // of them
     141    TIter Next2(this);
     142    while ((o=Next2()))
     143        RecursiveDelete(dynamic_cast<TVirtualPad*>(o), 'M');
     144
     145    // Now delete all root objects
     146    TIter Next3(this);
     147    while ((o=Next3()))
     148        RecursiveDelete(dynamic_cast<TVirtualPad*>(o));
     149
     150    // And delete all the rest
     151    TObjArray::Delete();
     152
     153    // Remove it from the list again
     154    gROOT->GetListOfCleanups()->Remove(this);
     155}
     156
     157// --------------------------------------------------------------------------
     158//
    74159// If o==NULL a new status display is created, otherwise the one with name o
    75160// is searched in gROOT->GetListOfSpecials().
     
    335420}
    336421
     422MStatusArray::~MStatusArray()
     423{
     424    // This is the destructor from TObjArray...
     425    // It must be here, because for some reason I don't know it
     426    // is otherwise not correctly executed from the Interpreter
     427    // (root 5.12/00f)
     428    if (IsOwner())
     429        Delete();
     430
     431    TStorage::Dealloc(fCont);
     432
     433    fCont = 0;
     434    fSize = 0;
     435}
     436
    337437// --------------------------------------------------------------------------
    338438//
     
    344444    // It seems that the contents are not properly deleted by TObjArray::Read
    345445    Delete();
     446
     447    SetOwner();
    346448
    347449    const TString keyname = name?name:"MStatusDisplay";
     
    372474            TObject *o2=0;
    373475            while ((o2=Next2()))
    374                 if (o2->InheritsFrom("MParContainer"))
     476                if (o2->InheritsFrom(MParContainer::Class()))
    375477                    o2->SetBit(kCanDelete);
    376478        }
  • trunk/MagicSoft/Mars/mbase/MStatusArray.h

    r9490 r9519  
    1919    };
    2020
     21    void     SetCleanup(TObject *obj) const;
     22    void     RecursiveDelete(TVirtualPad *p, const char id=0) const;
     23
    2124    void     SetCanDelete(const TCollection *list) const;
    2225    void     SetMyCanDelete(const TCollection *list) const;
     
    2831    MStatusArray() : TObjArray() { }
    2932    MStatusArray(const MStatusDisplay &d);
     33    ~MStatusArray();
    3034
    3135    TObject *DisplayIn(Option_t *o=0) const;         // *MENU*
     
    5660
    5761    void EnableTH1Workaround(const TCollection *list=0) const;
     62    void Delete(Option_t *option="");
    5863
    5964    ClassDef(MStatusArray, 0) // Helper class for status display
  • trunk/MagicSoft/Mars/mgeom/MGeomPix.h

    r9441 r9519  
    3838    }
    3939
    40     void SetD(Float_t d=1) { fD=d; fA=d*d*gsTan60/2; }
     40    void SetD(Float_t d=1) { fD=d; fA=d*d*gsSin60; }
    4141    void SetPhi(Double_t phi=0);
    4242
     
    4545    Float_t GetT() const  { return fD/gsTan60; } // Distance between two opposite edges (traverse)
    4646
    47     Float_t GetDx() const { return fD; }           // Distance of two rows in x-direction (without rotation)
    48     Float_t GetDy() const { return fD*gsTan60/2; } // Distance of two rows in y-direction (without rotation)
     47    Float_t GetDx() const { return fD; }         // Distance of two rows in x-direction (without rotation)
     48    Float_t GetDy() const { return fD*gsSin60; } // Distance of two rows in y-direction (without rotation)
    4949
    5050    Bool_t  IsInside(Float_t px, Float_t py) const;
  • trunk/MagicSoft/Mars/mhist/Makefile

    r9379 r9519  
    66#
    77##################################################################
     8include ../Makefile.conf.general
    89include ../Makefile.conf.$(OSTYPE)
    9 include ../Makefile.conf.general
    1010
    1111#------------------------------------------------------------------------------
  • trunk/MagicSoft/Mars/mjobs/MJCalibrateSignal.cc

    r9481 r9519  
    126126//
    127127MJCalibrateSignal::MJCalibrateSignal(const char *name, const char *title)
    128     : fExtractor(0), fIsInterlaced(kTRUE), fIsRelTimesUpdate(kTRUE), fIsMovieMode(kFALSE)
     128    : fExtractor(0), fIsInterlaced(kTRUE), fIsRelTimesUpdate(kTRUE), fIsMovieMode(kFALSE), fIsTestMode(kFALSE)
    129129{
    130130    fName  = name  ? name  : "MJCalibrateSignal";
     
    263263    if (fSequence.IsValid())
    264264    {
    265         if (fSequence.GetRuns(iter, MSequence::kRawDat)<=0)
     265        if (fSequence.GetRuns(iter, fIsTestMode?MSequence::kRawCal:MSequence::kRawDat)<=0)
    266266            return kFALSE;
    267267    }
     
    383383    read->AddFiles(iter);
    384384
    385     const TString fname(Form("s/(([0-9]+_)?(M[12]_)?[0-9.]+)_D_(.*[.])(raw|raw[.]gz|root)$/%s\\/$1_Y_$4root/",
     385    const TString fname(Form("s/(([0-9]+_)?(M[12]_)?[0-9.]+)_[CD]_(.*[.])(raw|raw[.]gz|root)$/%s\\/$1_Y_$4root/",
    386386                             Esc(fPathOut).Data()));
    387387
     
    460460    fcalped.AllowTriggerLvl2();
    461461    fcalped.AllowSumTrigger();
     462    if (fIsTestMode)
     463        fcalped.AllowCalibration();
    462464
    463465    // This will skip interleaved events with a cal- or ped-trigger
     
    810812
    811813    //MFDataPhrase filcalco("MCalibrationConstCam.IsReadyToSave>0.5", "CalibConstFilter");
    812     if (fIsInterlaced)
     814    if (fIsInterlaced && !fIsTestMode)
    813815    {
    814816        // The task list is executed for all events with the calibration
     
    867869    // Check if we have an extremely bright event (remove them,
    868870    // they are presumably errornous events or calibration events)
    869     tlist2.AddToList(&contbright);
     871    if (!fIsTestMode)
     872        tlist2.AddToList(&contbright);
    870873
    871874    /*
  • trunk/MagicSoft/Mars/mjobs/MJCalibrateSignal.h

    r8518 r9519  
    2525    Bool_t fIsRelTimesUpdate;           // Choose to update relative times from interlaced
    2626    Bool_t fIsMovieMode;                // Choose to encode a movie
     27    Bool_t fIsTestMode;                 // Testmode to calibrate the cal run
    2728
    2829    Bool_t CheckEnvLocal();
     
    4647    void SetRelTimesUpdate(const Bool_t b=kTRUE) { fIsRelTimesUpdate = b; }
    4748    void SetMovieMode     (const Bool_t b=kTRUE) { fIsMovieMode      = b; }
     49    void SetTestMode      (const Bool_t b=kTRUE) { fIsTestMode       = b; }
    4850
    4951    void SetExtractor(const MExtractor *ext=NULL);
  • trunk/MagicSoft/Mars/mjtrain/Makefile

    r8643 r9519  
    66#
    77##################################################################
     8include ../Makefile.conf.general
    89include ../Makefile.conf.$(OSTYPE)
    9 include ../Makefile.conf.general
    1010
    1111#------------------------------------------------------------------------------
Note: See TracChangeset for help on using the changeset viewer.