00001
00002
00003
00004
00005
00006
00007
00008
00009
00011
00012 #ifndef UGLIGEOMHANDLE_H
00013 #define UGLIGEOMHANDLE_H
00014 class UgliGeomHandle;
00015
00016 #include "Plex/PlexStripEndId.h"
00017
00018 #include "UgliGeometry/Ugli.h"
00019 #include "UgliGeometry/UgliGeometry.h"
00020 #include "GeoGeometry/GeoGeometry.h"
00021
00022 #include "UgliGeometry/UgliStripNode.h"
00023 #include "UgliGeometry/UgliScintMdlNode.h"
00024 #include "UgliGeometry/UgliScintPlnNode.h"
00025 #include "UgliGeometry/UgliSteelPlnNode.h"
00026
00027 #include "UgliGeometry/UgliStripHandle.h"
00028 #include "UgliGeometry/UgliScintMdlHandle.h"
00029 #include "UgliGeometry/UgliScintPlnHandle.h"
00030 #include "UgliGeometry/UgliSteelPlnHandle.h"
00031
00032 #include <vector>
00033 #include "TVector3.h"
00034
00035 class UgliGeomHandle : public UgliGeomABC {
00036
00037 public:
00038
00039 UgliGeomHandle(const VldContext& vldc,
00040 Ugli::EModifyMode mmode = Ugli::kUseGlobal,
00041 Geo::EAppType apptype = Geo::kRecons);
00042 UgliGeomHandle(const UgliGeomHandle& that);
00043
00044 UgliGeomHandle& operator=(const UgliGeomHandle& ugh);
00045
00046
00047
00048 UgliGeomHandle();
00049
00050 virtual ~UgliGeomHandle();
00051
00052 virtual void ResetVldContext(const VldContext& vldc);
00053
00054 virtual Bool_t IsGeo() const { return (fGeoGeometry != 0 ); }
00055 virtual Bool_t IsValid() const;
00056 virtual Bool_t IsFrozen() const;
00057 virtual Bool_t IsAlgorithmic() const;
00058
00059 virtual UgliScintPlnHandle GetScintPlnHandle(PlexPlaneId planeid);
00060 virtual UgliSteelPlnHandle GetSteelPlnHandle(PlexPlaneId planeid);
00061 virtual UgliStripHandle GetStripHandle(PlexStripEndId seid);
00062
00063 std::vector<UgliScintPlnHandle> GetScintPlnHandleVector();
00064 std::vector<UgliSteelPlnHandle> GetSteelPlnHandleVector();
00065 std::vector<UgliPlnHandle> GetPlnHandleVector();
00066
00067 virtual PlexPlaneId GetPlaneIdFromZ(Double_t z) const
00068 { if ( !IsGeo() ) return fUgliGeometry->GetPlaneIdFromZ(z);
00069 else return fGeoGeometry->GetPlaneIdFromZ(z/Munits::cm); }
00070
00071 virtual UgliSteelPlnHandle GetNearestSteelPlnHandle(Double_t z) const;
00072
00073 virtual void GetTransverseExtent(PlaneView::PlaneView_t view,
00074 Float_t& tmin, Float_t& tmax) const;
00075 virtual void GetTransverseExtent(PlaneView::PlaneView_t view,
00076 Double_t& tmin, Double_t& tmax) const;
00077 virtual void GetZExtent(Float_t& zmin, Float_t& zmax, Int_t isuper=-1) const;
00078 virtual void GetZExtent(Double_t& zmin, Double_t& zmax, Int_t isuper=-1) const;
00079 virtual TVector3 GetHallExtentMin() const;
00080 virtual TVector3 GetHallExtentMax() const;
00081
00082 virtual const VldRange& GetVldRange() const
00083 { if ( !IsGeo() ) return fUgliGeometry->GetVldRange();
00084 else return fGeoGeometry->GetVldRange(); }
00085 virtual Detector::Detector_t GetDetector() const
00086 { return (Detector::Detector_t)GetVldRange().GetDetectorMask(); }
00087
00088 virtual void Draw(Option_t *option="");
00089 virtual void Print(Option_t *option="") const;
00090 virtual void ls(Option_t *option="rsn5") const;
00091
00092 virtual void uv2xy(Float_t u, Float_t v, Float_t &x, Float_t &y) const;
00093 virtual void uv2xy(Double_t u, Double_t v, Double_t &x, Double_t &y) const;
00094 virtual void xy2uv(Float_t x, Float_t y, Float_t &u, Float_t &v) const;
00095 virtual void xy2uv(Double_t x, Double_t y, Double_t &u, Double_t &v) const;
00096
00097 virtual TVector3 uvz2xyz(const TVector3& uvz) const;
00098 virtual TVector3 xyz2uvz(const TVector3& xyz) const;
00099
00100 virtual void UpdateGlobalManager() const {
00101 if ( !IsGeo() ) gGeoManager = 0;
00102 else fGeoGeometry->UpdateGlobalManager(); }
00103
00104 static bool DoesValidGeomExist(const VldContext& vldc,
00105 Ugli::EModifyMode mmode = Ugli::kUseGlobal);
00106
00107 void SwitchMedia(bool toswim);
00108
00109 protected:
00110
00111 UgliGeometry *fUgliGeometry;
00112 GeoGeometry* fGeoGeometry;
00113
00114 private:
00115
00116
00117 void Copy(TObject &that) const;
00118
00119 ClassDef(UgliGeomHandle,2)
00120 };
00121
00122 #ifndef __CINT__
00123
00124
00125
00126
00127 inline Bool_t UgliGeomHandle::IsValid() const
00128 {
00129 if ( ( fUgliGeometry || fGeoGeometry ) &&
00130 ( GetVldRange().GetDetectorMask() != Detector::kUnknown ) )
00131 return kTRUE;
00132 return kFALSE;
00133 }
00134
00135 inline Bool_t UgliGeomHandle::IsFrozen() const
00136 { if ( !IsGeo() ) return fUgliGeometry->IsFrozen();
00137 else return fGeoGeometry->IsFrozen(); }
00138
00139 inline Bool_t UgliGeomHandle::IsAlgorithmic() const
00140 { if ( !IsGeo() ) return fUgliGeometry->IsAlgorithmic();
00141 else return fGeoGeometry->IsAlgorithmic(); }
00142
00143 inline UgliSteelPlnHandle UgliGeomHandle::GetSteelPlnHandle(PlexPlaneId planeid)
00144 { if ( !IsGeo() )
00145 return UgliSteelPlnHandle(fUgliGeometry->GetSteelPlnNode(planeid));
00146 else return UgliSteelPlnHandle(fGeoGeometry->GetSteelPlnNode(planeid)); }
00147
00148 inline void UgliGeomHandle::GetTransverseExtent(PlaneView::PlaneView_t view,
00149 Float_t& tmin,
00150 Float_t& tmax) const
00151 { if ( !IsGeo() ) fUgliGeometry->GetTransverseExtent(view,tmin,tmax);
00152 else { fGeoGeometry->GetTransverseExtent(view,tmin, tmax);
00153 tmin *= Munits::cm; tmax *= Munits::cm; }
00154 }
00155
00156 inline void UgliGeomHandle::GetTransverseExtent(PlaneView::PlaneView_t view,
00157 Double_t& tmin,
00158 Double_t& tmax) const
00159 { if ( !IsGeo() ) fUgliGeometry->GetTransverseExtent(view,tmin,tmax);
00160 else { fGeoGeometry->GetTransverseExtent(view,tmin,tmax);
00161 tmin *= Munits::cm; tmax *= Munits::cm; }
00162 }
00163
00164
00165
00166 inline void UgliGeomHandle::GetZExtent(Float_t& zmin, Float_t& zmax,
00167 Int_t isuper) const {
00168 if ( !IsGeo() ) fUgliGeometry->GetZExtent(zmin,zmax,isuper);
00169 else {
00170 fGeoGeometry->GetZExtent(zmin,zmax,isuper);
00171 zmin *= Munits::cm; zmax *= Munits::cm;
00172 }
00173 }
00174
00175 inline void UgliGeomHandle::GetZExtent(Double_t& zmin, Double_t& zmax,
00176 Int_t isuper) const {
00177 if ( !IsGeo() ) fUgliGeometry->GetZExtent(zmin,zmax,isuper);
00178 else {
00179 fGeoGeometry->GetZExtent(zmin,zmax,isuper);
00180 zmin *= Munits::cm; zmax *= Munits::cm;
00181 }
00182
00183 }
00184
00185
00186 inline TVector3 UgliGeomHandle::GetHallExtentMin() const
00187 { if ( !IsGeo() ) return fUgliGeometry->GetHallExtentMin();
00188 else return (fGeoGeometry->GetHallExtentMin())*Munits::cm; }
00189
00190 inline TVector3 UgliGeomHandle::GetHallExtentMax() const
00191 { if ( !IsGeo() ) return fUgliGeometry->GetHallExtentMax();
00192 else return (fGeoGeometry->GetHallExtentMax())*Munits::cm; }
00193
00194 inline UgliSteelPlnHandle
00195 UgliGeomHandle::GetNearestSteelPlnHandle(Double_t z) const
00196 {
00197 if ( !IsGeo() )
00198 return UgliSteelPlnHandle(fUgliGeometry->GetNearestSteelPlnNode(z));
00199 else
00200 return UgliSteelPlnHandle(fGeoGeometry->
00201 GetNearestSteelPlnNode(z/Munits::cm));
00202
00203 }
00204
00205 inline void UgliGeomHandle::Draw(Option_t *option)
00206 { if ( !IsGeo() ) fUgliGeometry->Draw(option);
00207 else fGeoGeometry->Draw(option); }
00208
00209 inline void UgliGeomHandle::Print(Option_t *option) const
00210 { if ( !IsGeo() ) fUgliGeometry->Print(option);
00211 else fGeoGeometry->Print(option); }
00212
00213 inline void UgliGeomHandle::ls(Option_t *option) const
00214 { if ( !IsGeo() ) fUgliGeometry->ls(option);
00215 else fGeoGeometry->ls(option); }
00216
00217 inline void UgliGeomHandle::uv2xy(Float_t u, Float_t v,
00218 Float_t& x, Float_t& y) const
00219 { Ugli::uv2xy(GetDetector(),u,v,x,y); }
00220 inline void UgliGeomHandle::uv2xy(Double_t u, Double_t v,
00221 Double_t& x, Double_t& y) const
00222 { Ugli::uv2xy(GetDetector(),u,v,x,y); }
00223 inline void UgliGeomHandle::xy2uv(Float_t x, Float_t y,
00224 Float_t& u, Float_t& v) const
00225 { Ugli::xy2uv(GetDetector(),x,y,u,v); }
00226 inline void UgliGeomHandle::xy2uv(Double_t x, Double_t y,
00227 Double_t& u, Double_t& v) const
00228 { Ugli::xy2uv(GetDetector(),x,y,u,v); }
00229 inline TVector3 UgliGeomHandle::uvz2xyz(const TVector3& uvz) const
00230 { return Ugli::uvz2xyz(GetDetector(),uvz); }
00231 inline TVector3 UgliGeomHandle::xyz2uvz(const TVector3& xyz) const
00232 { return Ugli::xyz2uvz(GetDetector(),xyz); }
00233
00234 #endif
00235 #endif // UGLIGEOMHANDLE_H