00001
00002
00003
00004
00005
00006
00007
00008
00010
00011 #include <TGeoVolume.h>
00012 #include <TGeoMatrix.h>
00013 #include <TGeoBBox.h>
00014 #include <TMath.h>
00015
00016 #include "MessageService/MsgService.h"
00017 #include "GeoGeometry/GeoGeometry.h"
00018 #include "GeoGeometry/GeoStripNode.h"
00019 #include "GeoGeometry/GeoScintPlnNode.h"
00020 #include "GeoGeometry/GeoScintMdlNode.h"
00021
00022 ClassImp(GeoStripNode)
00023 CVSID("$Id: GeoStripNode.cxx,v 1.17 2007/11/11 07:28:43 rhatcher Exp $");
00024
00025
00026 GeoStripNode::GeoStripNode(GeoGeometry* geom, TGeoVolume* stpvol,
00027 TGeoMatrix* stpmatrix, GeoScintMdlNode* mdlNode,
00028 std::string nodename,const PlexStripEndId& stripid)
00029 : GeoNode(geom,stpvol,stpmatrix,
00030 mdlNode->GetScintMdlVolume()->GetAirNode()->GetVolume(),
00031 mdlNode->GetGlobalPath()+"/" +
00032 mdlNode->GetScintMdlVolume()->GetAirNode()->GetName() + "/" +
00033 nodename,nodename),fStripEndId(stripid),fScintMdlNode(mdlNode) {
00034
00035
00036
00037
00038
00039 UpdateGlobalManager();
00040
00041 }
00042
00043
00044 GeoStripNode::~GeoStripNode() {
00045
00046
00047 UpdateGlobalManager();
00048
00049 if ( CountRef() ) {
00050 MSG("Geo",Msg::kWarning)
00051 << "GeoStripNode destructor " << GetSEId()
00052 << " still had " << CountRef()
00053 << " outstanding references " << endl;
00054 }
00055 }
00056
00057
00058 Float_t GeoStripNode::GetHalfLength() const {
00059
00060
00061 UpdateGlobalManager();
00062 Float_t halflength = GetStripVolume() -> GetHalfLength();
00063
00064 MSG("Geo",Msg::kDebug) << "GetHalfLength " << fStripEndId.AsString()
00065 << " halflength " << halflength << endl;
00066
00067 return halflength;
00068
00069 }
00070
00071
00072 Float_t GeoStripNode::GetHalfThickness() const {
00073
00074
00075 UpdateGlobalManager();
00076
00077 Float_t halfthickness = GetStripVolume() -> GetHalfThickness();
00078 MSG("Geo",Msg::kDebug) << "GetHalfThickness " << fStripEndId.AsString()
00079 << " halfthickness " << halfthickness << endl;
00080
00081 return halfthickness;
00082
00083 }
00084
00085
00086 Float_t GeoStripNode::GetHalfWidth() const {
00087
00088
00089 UpdateGlobalManager();
00090
00091 Float_t halfwidth = GetStripVolume() -> GetHalfWidth();
00092 MSG("Geo",Msg::kDebug) << "GetHalfWidth " << fStripEndId.AsString()
00093 << " halfwidth " << halfwidth << endl;
00094
00095 return halfwidth;
00096
00097 }
00098
00099
00100 Float_t GeoStripNode::PartialLength(StripEnd::StripEnd_t stripend) const{
00101
00102
00103
00104 UpdateGlobalManager();
00105
00106 Float_t lenpart = GetStripVolume() -> GetLenPart(stripend);
00107 MSG("Geo",Msg::kDebug) << "PartialLength " << fStripEndId.AsString()
00108 << " end " << StripEnd::AsString(stripend)
00109 << " lenpart " << lenpart << endl;
00110
00111 return lenpart;
00112
00113 }
00114
00115
00116 Float_t GeoStripNode::WlsBypass() const {
00117
00118
00119 UpdateGlobalManager();
00120
00121 Float_t wlsbypass = GetStripVolume() -> GetWlsLenBypass();
00122
00123 MSG("Geo",Msg::kDebug) << "WlsBypass " << fStripEndId.AsString()
00124 << " wlsbypass " << wlsbypass << endl;
00125
00126 return wlsbypass;
00127
00128 }
00129
00130
00131 Float_t GeoStripNode::WlsPigtail(StripEnd::StripEnd_t stripend) const {
00132
00133
00134
00135
00136
00137 UpdateGlobalManager();
00138
00139 Float_t wlspigtail = 0;
00140
00141 switch (stripend) {
00142
00143 case StripEnd::kEast:
00144 case StripEnd::kWest:
00145 {
00146 GeoScintMdlNode* mdlNode = GetScintMdlNode();
00147 wlspigtail = GetStripVolume()->GetWlsLen(stripend)
00148 + mdlNode->GetExtraWlsFiber(stripend);
00149 }
00150 break;
00151
00152 default:
00153 MSG("Geo",Msg::kWarning) << "WlsPigtail called with stripend "
00154 << StripEnd::AsString(stripend)
00155 << ". Must specify kEast or kWest." << endl;
00156 }
00157
00158 MSG("Geo",Msg::kDebug) << "WlsPigtail " << fStripEndId.AsString() << " end "
00159 << StripEnd::AsString(stripend)
00160 << " wlspigtail " << wlspigtail << endl;
00161
00162 return wlspigtail;
00163
00164 }
00165
00166
00167 Bool_t GeoStripNode::IsMirrored(StripEnd::StripEnd_t stripend) const {
00168
00169
00170 UpdateGlobalManager();
00171
00172 Bool_t isMirrored = GetStripVolume() -> IsMirrored(stripend);
00173
00174 MSG("Geo",Msg::kDebug) << "IsMirrored " << fStripEndId.AsString() << " end "
00175 << StripEnd::AsString(stripend) << " isMirrored "
00176 << isMirrored << endl;
00177
00178 return isMirrored;
00179
00180 }
00181
00182
00183 Float_t GeoStripNode::GetLPosRelMdl() const {
00184
00185
00186
00187 UpdateGlobalManager();
00188
00189 const Double_t* trans = GetMatrix() -> GetTranslation();
00190
00191 MSG("Geo",Msg::kDebug) << "GetLPosRelMdl " << fStripEndId.AsString()
00192 << " lposrelmdl " << trans[0] << endl;
00193
00194 return trans[0];
00195
00196 }
00197
00198
00199 GeoScintPlnNode* GeoStripNode::GetScintPlnNode(void) const{
00200
00201
00202 UpdateGlobalManager();
00203
00204 MSG("Geo",Msg::kDebug) << "GetScintPlnNode " << fStripEndId.AsString()
00205 << endl;
00206
00207 return (GetScintMdlNode()->GetScintPlnNode());
00208
00209 }
00210
00211
00212 Float_t GeoStripNode::GetTPosRelMdl() const {
00213
00214
00215 MSG("Geo",Msg::kDebug) << fStripEndId.AsString() << endl;
00216
00217 UpdateGlobalManager();
00218
00219 const Double_t* trans = GetMatrix() -> GetTranslation();
00220
00221 return trans[1];
00222
00223 }
00224
00225
00226
00227 Float_t GeoStripNode::GetZRotRelMdlRad() const {
00228
00229
00230 MSG("Geo",Msg::kDebug) << fStripEndId.AsString() << endl;
00231
00232 UpdateGlobalManager();
00233
00234 const Double_t* rotmatrix = GetMatrix() -> GetRotationMatrix();
00235 Float_t zrotrelmdlrad = TMath::ATan2(rotmatrix[3],rotmatrix[0]);
00236
00237 return zrotrelmdlrad;
00238
00239 }
00240
00241
00242 Float_t GeoStripNode::GetTPos(Float_t orthCoord) const {
00243
00244
00245
00246
00247
00248
00249
00250 MSG("Geo",Msg::kDebug) << fStripEndId.AsString() << " orthCoord "
00251 << orthCoord << endl;
00252
00253 UpdateGlobalManager();
00254
00255
00256 Double_t striplxyz[3] = {0};
00257
00258 Double_t modulelxyz[3] = {0};
00259 GetMatrix() -> LocalToMaster(striplxyz,modulelxyz);
00260
00261 Double_t scplanelxyz[3] = {0};
00262 GeoScintMdlNode* mdlNode = GetScintMdlNode();
00263 mdlNode -> GetMatrix() -> LocalToMaster(modulelxyz,scplanelxyz);
00264
00265
00266 Float_t tpos = scplanelxyz[1];
00267 if ( orthCoord > 100000. ) return tpos;
00268
00269
00270 Float_t zrotrelmdlrad = GetZRotRelMdlRad();
00271 Float_t zrotrelplnrad = mdlNode->GetZRotRelPlnRad();
00272 GeoScintPlnNode* scplnNode = GetScintPlnNode();
00273 Float_t zrotrelsteelrad = scplnNode->GetZRotRelSteelRad();
00274
00275
00276 Float_t zrotrelsteelideal = 0;
00277 Float_t lpos = orthCoord;
00278 if ( fStripEndId.GetDetector() == Detector::kFar ||
00279 fStripEndId.GetDetector() == Detector::kNear ) {
00280 if ( fStripEndId.GetPlaneView() == PlaneView::kU ) {
00281 zrotrelsteelideal = -0.785398163;
00282 lpos = -orthCoord;
00283 }
00284 else if ( fStripEndId.GetPlaneView() == PlaneView::kV ) {
00285 zrotrelsteelideal = +0.785398163;
00286 }
00287 }
00288 else if ( fStripEndId.GetDetector() == Detector::kCalDet ) {
00289 if ( fStripEndId.GetPlaneView() == PlaneView::kU ) {
00290 zrotrelsteelideal = -1.570796327;
00291 lpos = -orthCoord;
00292 }
00293 else if ( fStripEndId.GetPlaneView() == PlaneView::kV ) {
00294 zrotrelsteelideal = 0;
00295 }
00296 }
00297
00298 Float_t zrottot = (zrotrelsteelrad - zrotrelsteelideal) + zrotrelplnrad
00299 + zrotrelmdlrad;
00300
00301 Float_t deltatpos = lpos * TMath::Tan(zrottot);
00302 tpos += deltatpos;
00303
00304 return tpos;
00305
00306 }
00307
00308
00309
00310
00311 Float_t GeoStripNode::ClearFiber(StripEnd::StripEnd_t end) const {
00312
00313
00314 UpdateGlobalManager();
00315
00316 Float_t clearfiber = GetScintMdlNode() -> GetClearFiber(end);
00317
00318 MSG("Geo",Msg::kDebug) << "ClearFiber " << fStripEndId.AsString() << " end "
00319 << StripEnd::AsString(end)
00320 << " clearfiber " << clearfiber << endl;
00321
00322 return clearfiber;
00323
00324 }
00325
00326
00327 Float_t GeoStripNode::TotalAttenuation(StripEnd::StripEnd_t ,
00328 const Float_t ) const {
00329
00330
00331 UpdateGlobalManager();
00332
00333 MSG("Geo",Msg::kWarning)
00334 << "GeoStripNode::TotalAttenuation not implemented yet." << endl;
00335 return 0;
00336
00337 }
00338
00339
00340 Float_t GeoStripNode::DistanceAlong(const PlexStripEndId& orthogonalStrip)
00341 const{
00342
00343
00344
00345
00346
00347
00348
00349
00350
00351
00352
00353
00354
00355
00356
00357
00358
00359
00360
00361
00362
00363 UpdateGlobalManager();
00364
00365 const Double_t farAway = 1.0e25;
00366
00367 GeoStripNode* otherNode = GetGeoGeometry()->GetStripNode(orthogonalStrip);
00368
00369 if ( !otherNode ) {
00370 MSG("Geo",Msg::kError)
00371 << "GeoStripNode::DistanceAlong(), other strip "
00372 << orthogonalStrip << " does not exist." << endl;
00373 return farAway;
00374 }
00375
00376
00377 TVector3 baseThis = this -> GlobalPos(0.,false);
00378 TVector3 dirThis = this -> GlobalPos(1.,false) - baseThis;
00379
00380
00381 TVector3 baseOther = otherNode -> GlobalPos(0.,false);
00382 TVector3 dirOther = otherNode -> GlobalPos(1.,false) - baseOther;
00383
00384 TVector3 dirCross = dirThis.Cross(dirOther);
00385 Double_t dirCrossMag2 = dirCross.Mag2();
00386 if ( dirCrossMag2 == 0.0 ) {
00387
00388 return farAway;
00389 }
00390
00391 TVector3 dp = baseOther - baseThis;
00392 TVector3 dpxv = dp.Cross(dirOther);
00393 Double_t s = dpxv.Dot(dirCross)/dirCrossMag2;
00394
00395 return s;
00396
00397 }
00398
00399
00400 TVector3 GeoStripNode::Intersection(const PlexStripEndId& orthogonalStrip)
00401 const {
00402
00403
00404
00405
00406
00407
00408
00409
00410
00411
00412
00413
00414
00415
00416
00417
00418
00419
00420
00421
00422
00423
00424
00425
00426 UpdateGlobalManager();
00427
00428 const Double_t farAway = 1.0e25;
00429 const TVector3 farAway3(farAway,farAway,farAway);
00430
00431 GeoStripNode* otherNode = GetGeoGeometry()->GetStripNode(orthogonalStrip);
00432
00433 if ( !otherNode ) {
00434 MSG("Geo",Msg::kError)
00435 << "GeoStripNode::DistanceAlong() other strip "
00436 << orthogonalStrip << " does not exist." << endl;
00437 return farAway3;
00438 }
00439
00440
00441 TVector3 baseThis = this -> GlobalPos(0.,false);
00442 TVector3 dirThis = this -> GlobalPos(1.,false) - baseThis;
00443
00444
00445 TVector3 baseOther = otherNode -> GlobalPos(0.,false);
00446 TVector3 dirOther = otherNode -> GlobalPos(1.,false) - baseOther;
00447
00448 TVector3 dirCross = dirThis.Cross(dirOther);
00449 Double_t dirCrossMag2 = dirCross.Mag2();
00450 if ( dirCrossMag2 == 0.0 ) {
00451
00452 return 0.5*(baseThis+baseOther) + farAway*dirThis;
00453 }
00454
00455 TVector3 dp = baseOther - baseThis;
00456 TVector3 dpxvThis = dp.Cross(dirOther);
00457 Double_t s0 = dpxvThis.Dot(dirCross)/dirCrossMag2;
00458
00459 TVector3 xyz_s0 = baseThis + s0*dirThis;
00460
00461 dirCross *= -1;
00462 dp *= -1;
00463 TVector3 dpxvOther = dp.Cross(dirThis);
00464 Double_t t0 = dpxvOther.Dot(dirCross)/dirCrossMag2;
00465
00466 TVector3 xyz_t0 = baseOther + t0*dirOther;
00467
00468 return 0.5*(xyz_s0 + xyz_t0);
00469
00470 }
00471
00472
00473 TVector3 GeoStripNode::GlobalPos(const Float_t alongLength,
00474 const Bool_t onWLS) const {
00475
00476
00477
00478
00479 MSG("Geo",Msg::kDebug) << fStripEndId.AsString()
00480 << " alongLength " << alongLength << endl;
00481
00482 UpdateGlobalManager();
00483
00484 if ( onWLS ) {
00485 MSG("Geo",Msg::kWarning)
00486 << "GeoStripNode::GlobalPos not implemented yet with onWLS = kTRUE."
00487 << " Ignored." << endl;
00488 }
00489
00490 return LocalToGlobal(TVector3(alongLength,0.,0.));
00491
00492 }
00493
00494
00495 void GeoStripNode::SetZRotRelMdlRad(Float_t ) {
00496
00497
00498 UpdateGlobalManager();
00499
00500 MSG("Geo",Msg::kWarning)
00501 << "GeoStripNode::SetZRotRelMdlRad not implemented yet." << endl;
00502 return;
00503
00504 }
00505
00506
00507 void GeoStripNode::SetLTPosRelMdl(Float_t , Float_t ) {
00508
00509
00510 UpdateGlobalManager();
00511
00512 MSG("Geo",Msg::kWarning)
00513 << "GeoStripNode::SetLTPosRelMdl not implemented yet." << endl;
00514 return;
00515
00516 }
00517
00518
00519
00520
00521
00522
00523