Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

CandBase.h

Go to the documentation of this file.
00001 
00002 // $Id: CandBase.h,v 1.28 2006/06/21 00:47:01 rhatcher Exp $
00003 //
00004 // CandBase.h
00005 //
00006 // CandBase is a virtual base class for Reconstruction Candidates.
00007 //
00008 // Each concrete CandBase must define a Dup function.
00009 // CandBase must grant friendship to class CandRefer.
00010 //
00011 // Adapted from Babar's BtaCandBase (written by Gautier Hamel de
00012 // Monchenault and Bob Jacobsen).
00013 //
00014 // Author:  G. Irwin 1/2000
00016 
00017 #ifndef CANDBASE_H
00018 #define CANDBASE_H
00019 
00020 #include "TNamed.h"
00021 #include "TObjArray.h"                            // Needed for Root I/O
00022 #include "TRef.h"
00023 
00024 #include "CandData/CandRecord.h"                  // Needed for Root I/O
00025 #include "Candidate/CandRefCounted.h"
00026 
00027 class AlgConfig;
00028 class AlgHandle;
00029 class CandHandle;
00030 class CandRefer;
00031 class CandUid;
00032 class VldContext;
00033 
00034 class CandBase : public TNamed, public CandRefCounted
00035 {
00036 
00037    friend class CandHandle;
00038    friend class CandRefer;
00039    friend class CandUid;
00040 
00041 public:
00042    static Int_t GetNAlloc() {return fsNAlloc;}
00043    CandBase();                                         // Public for I/O
00044 
00045    virtual void Trace(const char *c = "") const;
00046 
00047    virtual std::ostream& FormatToOStream(std::ostream& os,
00048                                              Option_t *option="") const;
00049    virtual std::ostream& FormatDaughtersToOStream(std::ostream& os,
00050                                              Option_t *option="") const;
00051 
00052 protected:
00053    TRef fAlgConfigRef;                              // TRef to AlgConfig
00054    CandRecord *fCandRecord;             // Associated CandRecord pointer
00055    TObjArray fDaughters;            // TObjArray of daughter CandHandles
00056    CandHandle *fLocalHandle;            // Endpoint of daughter pointers
00057 
00058    CandBase(const AlgHandle &ah);
00059    CandBase(const CandBase &cb);
00060    virtual ~CandBase();
00061 
00062    const CandHandle *AddDaughterLink(const CandHandle &ch);
00063    virtual void CreateLocalHandle() = 0;
00064    virtual CandBase *Dup() const = 0;
00065    AlgConfig *GetAlgConfig() const;
00066    UInt_t GetArchUidInt() const;
00067    const CandUid &GetCandUid() const {return *fCandUid;}
00068    const CandHandle *GetDaughter(Int_t ndau) const;
00069    TIter GetDaughterIterator() const;
00070    const CandHandle *GetLocalHandle() const {return fLocalHandle;}
00071    Int_t GetNDaughters() const;
00072    UInt_t GetUidInt() const;
00073    Bool_t HasOverlapWith(const CandBase &cb) const;
00074    Bool_t IsComposite() const;
00075    virtual Bool_t IsEquivalent(const TObject* rhs) const;
00076    Bool_t RemoveDaughter(CandHandle *ch);
00077    void SetCandRecord(CandRecord *cr);
00078    void SetLocalHandle(CandHandle *ch); // Called from CreateLocalHandle
00079 
00080 // Test methods called from IsEquivalent methods of CandBase derived
00081 // classes.  For Candidate Validation suite by Paul Echevarria, Oct 2003
00082 template<class mType>
00083 Bool_t TestArrayEquality(const char* mbrName, int arrLen,
00084                          const mType& thisMbr,
00085                          const mType& rhsMbr) const;
00086 
00087 template<class chType>
00088 Bool_t TestCandHandleDup(const char* chName,
00089                          const chType* thisCH,
00090                          const chType* rCndCH ) const;
00091 
00092 template<class _char>
00093   void TestDisplayCandBanner(_char* mName) const;
00094 
00095 template<class mType>
00096 Bool_t TestEquality(const char* mbrName,
00097                     const mType& thisMbr,
00098                     const mType& rhsMbr) const;
00099 
00100 template<class mType>
00101 Bool_t TestEquivalence(const char* mName,
00102                        const mType& thisMbr,
00103                        const mType& rhsMbr) const;
00104 
00105 template<class elemType>
00106 Bool_t TestGenericElemPtrTObjArrayPtrEquality(const char* arrName,
00107                                                const TObjArray* thisTOA,
00108                                         const TObjArray* rCndTOA) const;
00109 
00110 template<class elemType>
00111 Bool_t TestGenericElemPtrTObjArrayPtrEquivalence(const char* arrName,
00112                                                const TObjArray* thisTOA,
00113                                                const TObjArray* rCndTOA,
00114                                      Bool_t testEquivalence=true) const;
00115 
00116 template<class _char>
00117 void TestNothing(_char* mName = "Candidate") const;
00118 
00119 template<class mType>
00120 Bool_t TestPtrEquivalence(const char* mName,
00121                           const mType* thisMbr,
00122                           const mType* rhsMbr) const;
00123 
00124 template<class toaType>
00125 Bool_t TestTObjArrayCandHandleDup(const char* arrName,
00126                                   const toaType& thisTOA,
00127                                   const toaType& rCndTOA) const;
00128 
00129 template<class toaType>
00130 Bool_t TestTObjArrayEquality(const char* arrName,
00131                              const toaType& thisTOA,
00132                              const toaType& rCndTOA) const;
00133 
00134 template<class toaType>
00135 Bool_t TestTObjArrayPtrEquality(const char* arrName,
00136                                 const toaType* thisTOA,
00137                                 const toaType* rCndTOA) const;
00138 
00139 template<class toaType>
00140 Bool_t TestTObjArrayPtrEquivalence(const char* arrName,
00141                                    const toaType* thisTOA,
00142                                    const toaType* rCndTOA,
00143                                    Bool_t testEquivalence=true) const;
00144 
00145 // Indentation levels for FormatToOStream
00146  static const TString& GetIndentString() { return fgIndentString; } 
00147  static const TString& GetDataIndent()   { return fgDataIndentString; }
00148  static void           SetDataIndent(const TString& distr) 
00149    { fgDataIndentString=distr;}
00150  static Int_t    DecIndent() 
00151    { --fgIndentLevel; return ResizeIndent(); }
00152  static Int_t    IncIndent() 
00153    { ++fgIndentLevel; return ResizeIndent(); }
00154 
00155 
00156 private:
00157    UInt_t fArchUidInt;                
00158    CandUid *fCandUid;                          
00159    static Int_t fsNAlloc;        // Current number of CandBase instances
00160    CandBase &operator=(const CandBase &);          // Should not be used
00161 
00162 
00163    static Int_t   fgIndentLevel;                 // current indent level
00164    static TString fgIndentString;         // current indent level string
00165    static TString fgDataIndentString;  // additnl indent for data values
00166 
00167    static Int_t   ResizeIndent();
00168 
00169 ClassDef(CandBase,2)              // Reconstruction Candidate Base Class
00170 
00171 };
00172 
00173 #if defined(MACOSX) && (__GNUC__ <= 3)
00174   #include "Candidate/CandBase.tpl"
00175 #endif
00176 
00177 #endif                                                     // CANDBASE_H

Generated on Mon Feb 15 11:06:27 2010 for loon by  doxygen 1.3.9.1