Re: Clustering

From: Christian Holm Christensen (cholm@hehi03.nbi.dk)
Date: Mon Sep 18 2000 - 11:33:19 EDT

  • Next message: videbaek: "Brat updates - BrDetectorVolume updates."

    On Mon, 18 Sep 2000 17:20:11 +0200 (CEST)
    "Peter H. L. Christiansen" <pchristi@nbi.dk> wrote
    concerning ": Clustering":
    > Hi Brahmsers,
    > 
    > Some comments on clustering. None of the stuff has been commited and
    > is in a test state here in Copenhagen.
    > The testing has been done exclusively on TPM1.
    > 
    > *
    > Djam and I found that if there are no clusters the BrTPCClusterFinder
    > code crashes. This is because the TList in BrTPCClusterTable is not
    > created and so the code crashes in RemoveOnePadClusters().
    > The solution implemented was to always create a TList. 
    
    No. The right way to do it, is to set the TList (assume it to be
    fList) pointer equal to ZERO, and then test if the TList exists with  
    
      if (!fList)
        // give up, because no clusters
        return kFALSE; // or some thing similar
    
    That means that you MUST initialize your TList in _any_ constructor
    (even the default one) to be zero, and then later, if needed, you can
    allocate memory for it via new message. 
    
      class MyClass {
      private:
        TList* fList; 
        ...
      public:
        MyClass(void) {
          // Default CTOR
          fList = 0;
          ...
        } 
        MyClass(const Char_t* name, const Char_t* title) {
          // Some CTOR
          fList = 0;
          ...
        }
        Bool_t MyFirstMethod(void) {
          // Some method that wants  TList, or should fail if it's zero
          if (!fList) 
            return kFALSE;
        }
        void MySecondMethod(void) { 
          // Some method that will create the TList if it isn't there
          if (!fList)
            fList = new TList; 
          fList->Add(new MyClass("Hello","World"));
        }
        TList* GetList(void) const { return fList; }
      };
    
     
    > I am open for good suggestion and critics.
    > I will try to check in my changes and a testprogram for some of them
    > before the weekend.  
    
    Consider your self flamed (he he). 
    
    Yours, 
    
    Christian  -----------------------------------------------------------
    Holm Christensen                             Phone:  (+45) 35 35 96 91 
      Sankt Hansgade 23, 1. th.                  Office: (+45) 353  25 305 
      DK-2200 Copenhagen N                       Web:    www.nbi.dk/~cholm    
      Denmark                                    Email:       cholm@nbi.dk
    



    This archive was generated by hypermail 2b29 : Mon Sep 18 2000 - 11:38:51 EDT