00001
00002
00003
00004
00005
00006
00007
00008
00009
00011
00012 #include "GeoGeometry/GeoScintMdlNode.h"
00013 #include "UgliGeometry/UgliStripHandle.h"
00014 #include "UgliGeometry/UgliStripNode.h"
00015
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
00029
00030 MSG("Ugli",Msg::kDebug)
00031 << "UgliStripHandle created by default ctor" << endl;
00032
00033 }
00034
00035
00036 UgliStripHandle::~UgliStripHandle()
00037 {
00038
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
00049
00050 if (fUgliStripNode) fUgliStripNode->IncrementRef();
00051 }
00052
00053
00054 UgliStripHandle::UgliStripHandle(GeoStripNode* node)
00055 : fUgliStripNode(0),fGeoStripNode(node)
00056 {
00057
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
00069
00070 if (fUgliStripNode) fUgliStripNode->IncrementRef();
00071 if (fGeoStripNode) fGeoStripNode->IncrementRef();
00072 }
00073
00074
00075 UgliStripHandle& UgliStripHandle::operator=(const UgliStripHandle& that)
00076 {
00077
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
00094
00095
00096 UgliScintMdlHandle UgliStripHandle::GetScintMdlHandle(void) const
00097 { if (!IsGeo()) return UgliScintMdlHandle(fUgliStripNode->GetScintMdlNode());
00098 else return UgliScintMdlHandle(fGeoStripNode->GetScintMdlNode());
00099 }
00100
00101
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
00141
00142
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
00160
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
00177
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