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

UgliLoanPool.h

Go to the documentation of this file.
00001 
00002 // $Id: UgliLoanPool.h,v 1.22 2009/05/18 14:59:06 kasahara Exp $
00003 //
00004 // UgliLoanPool
00005 //
00006 // UgliLoanPool is Singleton for managing the "active" Ugliii
00007 //
00008 // Author:  R. Hatcher 2000.05.15
00009 //
00011 
00012 #ifndef UgliLOANPOOL_H
00013 #define UgliLOANPOOL_H
00014 
00015 #include "Util/UtilMCFlag.h"
00016 #include "UgliGeometry/Ugli.h"
00017 #include "GeoGeometry/Geo.h"
00018 #include "Configurable/CfgConfigurable.h"
00019 
00020 class UgliGeomHandle;
00021 class UgliGeometry;
00022 class GeoGeometry;
00023 class VldContext;
00024 class VldRange;
00025 
00026 #include "TObjArray.h"
00027 
00028 class UgliLoanPool : public TObject, public CfgConfigurable {
00029 
00030    friend class UgliGeomHandle;  // need to call private GetUgliGeometry
00031 
00032  public:
00033 
00034    // setting this bypasses using the REROOT file info
00035    static void   SetAlwaysUseDbi(Bool_t flag = kTRUE);
00036    static Bool_t GetAlwaysUseDbi();
00037 
00038    static UgliLoanPool*    Instance();
00039    virtual void            Config();
00040    virtual const Registry& DefaultConfig() const;
00041    virtual void            SetConfigFromEnvironment();
00042 
00043    bool   DoesValidGeomExist(const VldContext& vldc,
00044                              Ugli::EModifyMode mmode = Ugli::kUseGlobal,
00045                              Geo::EAppType = Geo::kRecons);
00046 
00047    void   ClearPool(Bool_t frozen, Bool_t modifiable);
00048    bool   PurgeDbiTableCache() const;
00049 
00050    // Configure geometry to use alternative geometrical modeller
00051    void   SetUseGeo(Bool_t flag = kTRUE);
00052    bool   UseGeo() const { return fUseGeo; }
00053 
00054    // Configure to specify use of newer cavern modeling
00055    void SetUseNewCavern(Bool_t flag = kTRUE);
00056    bool GetUseNewCavern() const;
00057        
00058    // Configure to specify swim method in lo/hi field regions
00059    Geo::ESwimMethod GetSwimMethodLowField() const;
00060    Geo::ESwimMethod GetSwimMethodHighField() const;
00061    void   SetSwimMethodLowField(Geo::ESwimMethod swimmethod);
00062    void   SetSwimMethodHighField(Geo::ESwimMethod swimmethod);
00063 
00064    // Configure to specify medium associated with a given detector component
00065    void SetMedium(Geo::EDetComponent detcomp,const char* medName);
00066    const char* GetMedium(Geo::EDetComponent detcomp) const;
00067 
00068    // Configure geometry to turn off build of veto shield
00069    void SetShieldOff(Bool_t flag = kTRUE);
00070    bool GetShieldOff() const;
00071  
00072    // Set a medium specific process value
00073    void SetProcess(UtilMCFlag::EProcess process,Int_t processvalue,
00074                    const char* medname);
00075    // Set a medium specific cut value
00076    void SetCut(UtilMCFlag::ECut cut, Double_t cutvalue, const char* medname);
00077    // Set a medium specific tracking parameter value
00078    void SetTracking(UtilMCFlag::ETracking trk, Double_t trkvalue,
00079                     const char* medname);
00080 
00081    Registry GetMediumRegistry(const char* medName) const;
00082    
00083    //use Cfg:Int_t  GetMaxUnref() const { return fMaxUnref; }
00084    //use Cfg:void   SetMaxUnref(Int_t mx) { fMaxUnref = mx; }
00085 
00086    virtual void Print(Option_t *option = "") const;
00087 
00088  public:
00089 
00090    // to make this i/o-able we need a public default ctor
00091    UgliLoanPool();   // ctor - singleton class should make this private
00092 
00093    static void SaveToFile(const char* filename, bool recreate = true);
00094    static void ReadFromFile(const char* filename);
00095 
00096  private:
00097 
00098    UgliLoanPool(const UgliLoanPool &plp); // don't write this, but hide it
00099    virtual ~UgliLoanPool();
00100 
00101    // Helper class to handle deletion of singleton
00102    struct Cleaner {
00103       void ClassIsUsed() { }; // dummy method to keep compilers quiet
00104       ~Cleaner() {
00105          if (UgliLoanPool::fgInstance!=0) {
00106             delete UgliLoanPool::fgInstance;
00107             UgliLoanPool::fgInstance = 0;
00108          }
00109       }
00110    };
00111    friend struct Cleaner;
00112 
00113    // only UgliHandle should need call this ... and it is a "friend"
00114    UgliGeometry      *GetUgliGeometry(const VldContext& vldc, Bool_t frozen);
00115    UgliGeometry      *GetExistingUgliGeometry(const VldContext& vldc, Bool_t frozen);
00116    UgliGeometry      *BuildUgliGeometry(const VldContext& vldc, Bool_t frozen);
00117 
00118    GeoGeometry       *GetGeoGeometry(const VldContext& vldc, Bool_t frozen,
00119                                      Geo::EAppType apptype);
00120    GeoGeometry       *GetExistingGeoGeometry(const VldContext& vldc, 
00121                                          Bool_t frozen, Geo::EAppType apptype);
00122    GeoGeometry       *BuildGeoGeometry(const VldContext& vldc, Bool_t frozen,
00123                                        Geo::EAppType apptype);
00124 
00125    static UgliLoanPool *fgInstance;     // only copy of self
00126 
00127    // These structures are _owned_ by UgliLoanPool and it is responsible
00128    // for deleting them as necessary
00129    // Initially there will be just one, but later one could start
00130    // managing a more complex list
00131 
00132    TObjArray fFrozenUgliGeomList;     // UgliGeometry's from DB
00133    TObjArray fModifiableUgliGeomList; // UgliGeometry's that can be modifiable
00134 
00135    TObjArray fFrozenGeoGeomList;     // GeoGeometry's from DB
00136    TObjArray fModifiableGeoGeomList; // GeoGeometry's that can be modifiable
00137 
00138    Int_t     fMaxUnref;               // maximum unreferenced share geoms
00139    bool      fUseGeo; // config param to specify use of alternative GeoGeometry
00140 
00141    ClassDef(UgliLoanPool,2)
00142 
00143 };
00144 #endif // UGLILOANPOOL_H

Generated on Mon Nov 23 05:28:45 2009 for loon by  doxygen 1.3.9.1