Re: small change in BrRawDataInput

From: Kris Hagel (hagel@CyclotronMail.tamu.edu)
Date: Tue Jul 25 2000 - 17:08:36 EDT

  • Next message: Peter H. L. Christiansen: "few cvs changes"

    I think Alv\'s suggestion of implementing the
    BrDetectorList class is the thing to do.  I had
    discussed with Christian when the BrDetectorList was
    coming into being the possibility of doing just that,
    but as with many things it got away.  I think if someone
    is going to go to the trouble of making a change, it
    ought to be done the right way, ie with BrDetectorList. 
    That will put BrRawDataInput on a consistent footing
    with other objects that use it.
    
    Of course if it breaks applications, they need to be
    fixed before this is reintroduced into the repository.
    
    Kris
    
    Quoting Alv Kjetil Holme <a.k.holme@fys.uio.no>:
    
    > On Tue, 25 Jul 2000, Djamel Ouerdane wrote:
    > 
    > > Hi Alv,
    > > 
    > > I\'m a bit suprised by what you described but I
    understand your point: it
    > > is due to the fact that the SetxxxOff methods are
    based on the SetxxxOn
    > > methods. So I can see 2 ways to remedy to that:
    > > 
    > > 1- one way is to decouple these methods and have the
    set of SetxxxOff
    > > completly independant from the SetxxxOn
    > > 
    > > 2- the second is to keep fAllOn, fFSOn or fMRSOn
    kTRUE (instead of the 
    > > passed value) when you set off a
    > > particular detector, that\'s to say:
    > > 
    > > for instance MTP1: 
    > > void SetMTP1On(const Bool_t val = kTRUE) { fMTP1On =
    val; fMRSOn =
    > > kTRUE; fAllOn = kTRUE;} instead of val all the time.
    > > 
    > > Does it sound reasonable?
    > > Djamel
    > 
    >   There is one more possibility, to rewrite the code
    and take advantage of
    > the  BrDetectorList class. For fun, I implemented the
    following changes:
    > 
    >  In BrRawDataInput.h:
    > 
    >    a) Add include statement
    >       #ifndef BRAT_BrDetectorList_h
    >       #include \"BrDetectorList.h\"
    >       #endif
    > 
    >    b) Replace all the members
    >         Bool_t fXXXOn
    >       by one member
    >         BrDetectorList fDetectors
    > 
    >    c) Introduce methods to set, clear and test the
    state
    > 
    >       void SetOn(EBrDetectorBit bit)  {
    fDetectors.SetDetectorOn(bit);  }
    >       void SetOff(EBrDetectorBit bit) {
    fDetectors.SetDetectorOff(bit); }
    > 
    >       void SetOn(EBrSectorBit mask=kBrAll)
    >         { fDetectors.AddToDetectorMask(mask); }
    >       void SetOff(EBrSectorBit mask=kBrAll)
    >         { fDetectors.StripDetectorMask(mask); }
    > 
    >       Bool_t IsOn(EBrDetectorBit bit) const
    >         { return fDetectors.IsOn(bit); }
    >       Bool_t IsOn(EBrSectorBit mask)  const
    >         { return (fDetectors.GetDetectorMask() & mask)
    != 0; }
    > 
    >       Since fDetector is a private member, there is no
    need for these to
    >       be virtual methods.
    > 
    >    d) Remove the old SetXXXOn() and SetXXXOff()
    methods. This is OK with
    >       BRAT. However, it could break applications. In
    that case one could
    >       reimplement the old SetXXXOn() using the new
    methods, but I think it
    >       would be better to change the applications to
    use the new methods.
    > 
    >       void SetAllOn(Bool_t val=kTRUE)
    >          { if (val) SetOn(kBrAll); else
    SetOff(kBrAll); }
    > 
    >       void SetC1On(Bool_t val=kTRUE)
    >          { if (val) SetOn(kBrC1); else SetOff(kBrC1);
    }
    > 
    >       void SetH1On(Bool_t val=kTRUE)
    >          { if (val) SetOn(kBrTOF1); else
    SetOff(kBrTOF1); }
    > 
    >  In BrRawDataInput.cxx:
    > 
    >    a) Remove the three SetXXXOn() in Init()
    > 
    >    b) Replace the tests
    >         if (fXXXOn)
    >       by
    >         if (IsOn(kBrXXX))
    > 
    >       e.g.
    >         fAllOn    -> IsOn(kBrAll)
    >                   :
    >         fC1On     -> IsOn(kBrC1)
    >         fH1On     -> IsOn(kBrTOF1)       
    >                   :
    >         fMultOn   -> IsOn(kBrTile) OR IsOn(kBrSi)
    > 
    > 
    >   Note that BrDetectorList used different names for
    hodoscopes and MRS TPCs
    >     Old name          Name in BrDetectorList
    >       H1                TOF1
    >       H2                TOF2
    >       MTP1              TPM1
    >       MTP2              TPM2
    > 
    >   I have used these modifications in a test version of
    tpc3d and it works
    > well.
    > 
    >   -Alv Kjetil
    > 
    



    This archive was generated by hypermail 2b29 : Tue Jul 25 2000 - 17:09:24 EDT