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

UgliStripHandle.cxx

Go to the documentation of this file.
00001 
00002 // $Id: UgliStripHandle.cxx,v 1.10 2005/09/01 08:07:08 rhatcher Exp $
00003 //
00004 // UgliStripHandle
00005 //
00006 // UgliStripHandle is handle to a single strip
00007 //
00008 // Author:  R. Hatcher 2000.11.15
00009 //
00011 
00012 #include "GeoGeometry/GeoScintMdlNode.h"
00013 #include "UgliGeometry/UgliStripHandle.h"
00014 #include "UgliGeometry/UgliStripNode.h"
00015 //#include "UgliGeometry/UgliGeometry.h"
00016 
00017 #include "MessageService/MsgService.h"
00018 CVSID("$Id: UgliStripHandle.cxx,v 1.10 2005/09/01 08:07:08 rhatcher Exp $");
00019 
00020 #include <cassert>
00021 
00022 ClassImp(UgliStripHandle)
00023 
00024 //_____________________________________________________________________________
00025 UgliStripHandle::UgliStripHandle()
00026   : fUgliStripNode(0),fGeoStripNode(0)
00027 {
00028    // Default constructor
00029 
00030    MSG("Ugli",Msg::kDebug) 
00031      << "UgliStripHandle created by default ctor" << endl;
00032 //   assert(0);
00033 }
00034 
00035 //_____________________________________________________________________________
00036 UgliStripHandle::~UgliStripHandle()
00037 {
00038    // handle deletion updates reference count
00039   if (fUgliStripNode) fUgliStripNode->DecrementRef();
00040   if (fGeoStripNode) fGeoStripNode->DecrementRef();
00041   
00042 }
00043 
00044 //_____________________________________________________________________________
00045 UgliStripHandle::UgliStripHandle(UgliStripNode* node)
00046   : fUgliStripNode(node),fGeoStripNode(0)
00047 {
00048    // ctor keeps reference count up-to-date
00049 
00050    if (fUgliStripNode) fUgliStripNode->IncrementRef();
00051 } 
00052 
00053 //_____________________________________________________________________________
00054 UgliStripHandle::UgliStripHandle(GeoStripNode* node)
00055   : fUgliStripNode(0),fGeoStripNode(node)
00056 {
00057    // ctor keeps reference count up-to-date
00058 
00059    if (fGeoStripNode) fGeoStripNode->IncrementRef();
00060 }
00061 
00062 //_____________________________________________________________________________
00063 UgliStripHandle::UgliStripHandle(const UgliStripHandle &that)
00064    : UgliStripABC(),
00065      fUgliStripNode(that.fUgliStripNode),
00066      fGeoStripNode(that.fGeoStripNode)
00067 {
00068    // copy constructor keeps reference counts up-to-date
00069 
00070    if (fUgliStripNode) fUgliStripNode->IncrementRef();
00071    if (fGeoStripNode) fGeoStripNode->IncrementRef();
00072 }
00073 
00074 //_____________________________________________________________________________
00075 UgliStripHandle&  UgliStripHandle::operator=(const UgliStripHandle& that)
00076 {
00077    // assignment keeps reference counts up-to-date
00078 
00079    
00080    if (fUgliStripNode) fUgliStripNode->DecrementRef();
00081    if (fGeoStripNode) fGeoStripNode->DecrementRef();
00082    
00083    fUgliStripNode = that.fUgliStripNode;
00084    fGeoStripNode = that.fGeoStripNode;
00085    
00086    if (fUgliStripNode) fUgliStripNode->IncrementRef();
00087    if (fGeoStripNode) fGeoStripNode->IncrementRef();
00088 
00089    return *this;
00090 }
00091 
00092 //_____________________________________________________________________________
00093 // inlining these causes circular dependencies
00094 
00095 //inline 
00096 UgliScintMdlHandle UgliStripHandle::GetScintMdlHandle(void) const
00097 { if (!IsGeo()) return UgliScintMdlHandle(fUgliStripNode->GetScintMdlNode());
00098   else return UgliScintMdlHandle(fGeoStripNode->GetScintMdlNode()); 
00099 }
00100 
00101 //inline 
00102 UgliScintPlnHandle UgliStripHandle::GetScintPlnHandle(void) const
00103 { if (!IsGeo()) return 
00104   UgliScintPlnHandle(fUgliStripNode->GetScintMdlNode()->GetScintPlnNode()); 
00105  else return 
00106   UgliScintPlnHandle(fGeoStripNode->GetScintMdlNode()->GetScintPlnNode()); 
00107 }
00108 
00109 //_____________________________________________________________________________
00110 Bool_t UgliStripHandle::AttemptSet(const char* what) const
00111 {
00112   if (!IsFrozen()) return true;
00113 
00114   MSG("Ugli",Msg::kError) 
00115     << "AttemptSet " << what << " on Frozen " 
00116     << GetSEId() << " twarted!" << endl;
00117   return false;
00118 }
00119 
00120 void UgliStripHandle::SetZRotRelMdlRad(Float_t radians)
00121 {
00122   if (!AttemptSet("ZRotRelMdlRad")) return;
00123   if (!IsGeo())fUgliStripNode->SetZRotRelMdlRad(radians);
00124   else fGeoStripNode->SetZRotRelMdlRad(radians);
00125   
00126 }
00127 
00128 void UgliStripHandle::SetLTPosRelMdl(Float_t lpos, Float_t tpos)
00129 {
00130   if (!AttemptSet("LTPos")) return;
00131   if (!IsGeo())fUgliStripNode->SetLTPosRelMdl(lpos,tpos);
00132   else fGeoStripNode->SetLTPosRelMdl(lpos/Munits::cm,tpos/Munits::cm);
00133   
00134 }
00135 
00136 //_____________________________________________________________________________
00137 TVector3 UgliStripHandle::GlobalPos(const Float_t alongLength, 
00138                                     const Bool_t onWLS,
00139                                     const Bool_t globalInXYZ) const {
00140   // convert a distance along the strip into global position
00141   // onWLS takes into account the extra waveshifter length in bypass region
00142   // globalInXYZ determines whether result is in XYZ or UVZ
00143   TVector3 globalXYZ;
00144   if ( !IsGeo() ) 
00145       globalXYZ = fUgliStripNode->GlobalPos(alongLength,onWLS);
00146   else {
00147       TVector3 gpos = fGeoStripNode->GlobalPos(alongLength/Munits::cm,onWLS);
00148       globalXYZ = (gpos *= Munits::cm);
00149   }
00150 
00151   if (globalInXYZ ) return globalXYZ;
00152   else              return Ugli::xyz2uvz(GetSEId().GetDetector(),globalXYZ);
00153 }
00154 
00155 //_____________________________________________________________________________
00156 TVector3 UgliStripHandle::GlobalToLocal(const TVector3& global,
00157                                         const Bool_t globalInXYZ) const
00158 { 
00159   // convert a global position into a local (volume) one
00160   // globalInXYZ determines whether result is in XYZ or UVZ
00161   TVector3 globalXYZ = (globalInXYZ) ? 
00162       global : Ugli::uvz2xyz(GetSEId().GetDetector(),global);
00163 
00164   if ( !IsGeo() ) 
00165       return fUgliStripNode->GlobalToLocal(globalXYZ);
00166   else {
00167       TVector3 scaledglobal(globalXYZ); scaledglobal *= 1./Munits::cm;
00168       return (fGeoStripNode->GlobalToLocal(scaledglobal) *= Munits::cm); 
00169   }
00170 }
00171 
00172 //_____________________________________________________________________________
00173 TVector3 UgliStripHandle::LocalToGlobal(const TVector3& local,
00174                                         const Bool_t globalInXYZ) const
00175 { 
00176   // convert a global position into a local (volume) one
00177   // globalInXYZ determines whether result is in XYZ or UVZ
00178   TVector3 globalXYZ;
00179   if ( !IsGeo() ) 
00180       globalXYZ = fUgliStripNode->LocalToGlobal(local); 
00181   else { 
00182       TVector3 scaledlocal(local); scaledlocal *= 1./Munits::cm;
00183       globalXYZ = (fGeoStripNode->LocalToGlobal(scaledlocal) *= Munits::cm); 
00184   }
00185 
00186   if (globalInXYZ ) return globalXYZ;
00187   else              return Ugli::xyz2uvz(GetSEId().GetDetector(),globalXYZ);
00188 }
00189 
00190 //_____________________________________________________________________________

Generated on Mon Feb 15 11:07:49 2010 for loon by  doxygen 1.3.9.1