00001
00002
00003
00004
00005
00006
00007
00008
00009
00011
00012 #include "UgliGeometry/UgliScintMdlNode.h"
00013
00014 #include "UgliGeometry/UgliGeometry.h"
00015 #include "UgliGeometry/TGeometryX.h"
00016 #include "TXTRU.h"
00017 #include "UgliGeometry/UgliScintPlnNode.h"
00018
00019 #include "UgliGeometry/MinosOutline.h"
00020 #include "UgliGeometry/UgliDbiTables.h"
00021
00022 #include "Conventions/Munits.h"
00023
00024 #include "TBRIK.h"
00025
00026 #include "MessageService/MsgService.h"
00027 CVSID("$Id: UgliScintMdlNode.cxx,v 1.14 2005/02/17 15:27:45 rhatcher Exp $");
00028
00029 #include <cassert>
00030
00031 ClassImp(UgliScintMdlNode)
00032
00033
00034 UgliScintMdlNode::UgliScintMdlNode()
00035 : fUgliGeometry(0)
00036 {
00037
00038 }
00039
00040
00041 UgliScintMdlNode::~UgliScintMdlNode()
00042 {
00043
00044 if (CountRef()) {
00045 MSG("Ugli",Msg::kWarning)
00046 << "~UgliScintMdlNode still had " << CountRef()
00047 << " outstanding references " << endl;
00048 }
00049 }
00050
00051
00052 UgliScintMdlNode::UgliScintMdlNode(const PlexScintMdlId scintmdlid,
00053 UgliScintPlnNode* plnNode,
00054 const UgliDbiTables& ugliTables)
00055 : TNodeX(scintmdlid.AsString(),scintmdlid.AsString(),"noshape"),
00056 fUgliGeometry(plnNode->GetUgliGeometry()),
00057 fScintMdlId(scintmdlid)
00058 {
00059
00060
00061 unsigned int mdlstruct_indx =
00062 UgliDbiStructHash(fScintMdlId).HashAsScintMdl();
00063 const UgliDbiScintMdlStruct* mdlStructRow =
00064 ugliTables.fScintMdlStructTbl.GetRowByIndex(mdlstruct_indx);
00065
00066 const UgliDbiScintMdl *mdlRow = ugliTables.GetDbiScintMdlById(fScintMdlId);
00067 if (!mdlRow) {
00068 MSG("Ugli",Msg::kError)
00069 << "no UgliDbiScintMdl for " << fScintMdlId << endl;
00070 return;
00071 }
00072 fClearLenEast = mdlRow->GetClearLenEast();
00073 fClearLenWest = mdlRow->GetClearLenWest();
00074 fWlsLenEast = mdlRow->GetWlsLenEast();
00075 fWlsLenWest = mdlRow->GetWlsLenWest();
00076
00077
00078
00079 TXTRU* mdlshape =
00080 new TXTRU(GetName(),mdlStructRow->GetTypeName().c_str(),
00081 "void",8,2);
00082 TXTRU* plnshape = dynamic_cast<TXTRU*>(plnNode->GetShape());
00083 if (!plnshape)
00084 MSG("Ugli",Msg::kWarning)
00085 << "UgliScintPlnNode isn't a TXTRU" << endl;
00086 mdlshape->DefineSection(0,plnshape->GetSectionZ(0));
00087 mdlshape->DefineSection(1,plnshape->GetSectionZ(1));
00088 Float_t width = mdlRow->GetWidth();
00089 SetDefaultModuleOutline(mdlshape,mdlStructRow->GetTypeName(),width);
00090
00091 SetParent(plnNode);
00092 fShape = mdlshape;
00093
00094
00095 Float_t tpos = mdlRow->GetTPosRelPln();
00096 Float_t lpos = mdlRow->GetLPosRelPln();
00097 SetLTPosRelPln(lpos,tpos);
00098
00099
00100
00101
00102
00103 const Double_t deg90 = 90;
00104 Double_t zrot = mdlRow->GetZRotRelPlnDeg();
00105 fMatrix = new TRotMatrix(GetName(),GetName(),
00106 deg90,zrot,deg90,zrot+deg90,0,0);
00107
00108 SetLineColor(41);
00109
00110 SetVisibility(0);
00111
00112
00113
00114 }
00115
00116
00117 Float_t UgliScintMdlNode::GetClearFiber(const StripEnd::StripEnd_t end) const
00118 {
00119 if (end == StripEnd::kEast) return fClearLenEast;
00120 else if (end == StripEnd::kWest) return fClearLenWest;
00121 else return 0;
00122 }
00123
00124 Float_t UgliScintMdlNode::GetExtraWlsFiber(const StripEnd::StripEnd_t end) const
00125 {
00126 if (end == StripEnd::kEast) return fWlsLenEast;
00127 else if (end == StripEnd::kWest) return fWlsLenWest;
00128 else return 0;
00129 }
00130
00131
00132
00133 void UgliScintMdlNode::IncrementRef()
00134 {
00135 fRef++;
00136 fUgliGeometry->IncrementRef();
00137 SetVisibility(1);
00138 }
00139
00140 void UgliScintMdlNode::DecrementRef()
00141 {
00142 fRef--;
00143 fUgliGeometry->DecrementRef();
00144 if (!fRef) SetVisibility(0);
00145 }
00146
00147
00148 Int_t UgliScintMdlNode::NumberOfStrips() const
00149 {
00150
00151 if (!fNodes) return 0;
00152 return fNodes->GetSize();
00153 }
00154
00155
00156 TVector3 UgliScintMdlNode::GlobalToLocal(const TVector3& global) const
00157 {
00158
00159
00160 Double_t gxyz[3], lxyz[3];
00161
00162 gxyz[0] = global.X();
00163 gxyz[1] = global.Y();
00164 gxyz[2] = global.Z();
00165
00166
00167 UgliScintMdlNode* self = const_cast<UgliScintMdlNode*>(this);
00168 self->cd();
00169 self->UpdateMatrix();
00170 self->Master2Local(gxyz,lxyz);
00171
00172 return TVector3(lxyz[0],lxyz[1],lxyz[2]);
00173 }
00174
00175
00176 TVector3 UgliScintMdlNode::LocalToGlobal(const TVector3& local) const
00177 {
00178
00179
00180 Double_t gxyz[3], lxyz[3];
00181
00182 lxyz[0] = local.X();
00183 lxyz[1] = local.Y();
00184 lxyz[2] = local.Z();
00185
00186
00187 UgliScintMdlNode* self = const_cast<UgliScintMdlNode*>(this);
00188 self->cd();
00189 self->UpdateMatrix();
00190 self->Local2Master(lxyz,gxyz);
00191
00192 return TVector3(gxyz[0],gxyz[1],gxyz[2]);
00193 }
00194
00195
00196 void UgliScintMdlNode::SetDefaultModuleOutline(TXTRU* mdlShape,
00197 const string& typeName,
00198 const Float_t width)
00199 {
00200
00201 typedef struct basic_mdl_shape {
00202 string mdl_name;
00203 Int_t n_vtx;
00204 Float_t xvtx_abs[8];
00205 Float_t yvtx_rel[8];
00206 } MdlShape;
00207
00208 const Float_t half = 0.5;
00209
00210 const Float_t far = half * 8.000 * Munits::m;
00211 const Float_t as = half * 3.464 * Munits::m;
00212 const Float_t al = half * 5.738 * Munits::m;
00213 const Float_t bs = half * 5.735 * Munits::m;
00214 const Float_t byfc = 25 * Munits::cm;
00215 const Float_t byft = 16 * Munits::cm;
00216 const Float_t byff = 6./20.;
00217
00218 const Float_t swidth = 4.1 * Munits::cm;
00219 const Float_t glw = 109.764 * Munits::inch;
00220 const Float_t gsw = glw - 28*swidth;
00221 const Float_t g0 = swidth + half*10*swidth;
00222 const Float_t hw = 103.307 * Munits::inch;
00223 const Float_t notch = (103.307-85.551) * Munits::inch;
00224 const Float_t iff = 11./20.;
00225
00226 const Float_t caldet = half * 1.0 * Munits::m;
00227
00228 MdlShape shapelist[] = {
00229
00230 { "aU", 4,
00231 {-as,as,al,-al,0,0,0,0},
00232 {-half,-half,half,half,0,0,0,0}
00233 },
00234 { "aV", 4,
00235 {-as,as,al,-al,0,0,0,0},
00236 {-half,-half,half,half,0,0,0,0}
00237 },
00238 { "AU", 4,
00239 {-al,al,as,-as,0,0,0,0},
00240 {-half,-half,half,half,0,0,0,0}
00241 },
00242 { "AV", 4,
00243 {-al,al,as,-as,0,0,0,0},
00244 {-half,-half,half,half,0,0,0,0}
00245 },
00246
00247 { "bU", 4,
00248 {-bs,bs,far,-far,0,0,0,0},
00249 {-half,-half,half,half,0,0,0,0}
00250 },
00251 { "bV", 4,
00252 {-bs,bs,far,-far,0,0,0,0},
00253 {-half,-half,half,half,0,0,0,0}
00254 },
00255 { "BU", 4,
00256 {-far,far,bs,-bs,0,0,0,0},
00257 {-half,-half,half,half,0,0,0,0}
00258 },
00259 { "BV", 4,
00260 {-far,far,bs,-bs,0,0,0,0},
00261 {-half,-half,half,half,0,0,0,0}
00262 },
00263
00264 { "eU", 4,
00265 {-far,far,far,-far,0,0,0,0},
00266 {-half,-half,half,half,0,0,0,0}
00267 },
00268 { "EU", 4,
00269 {-far,far,far,-far,0,0,0,0},
00270 {-half,-half,half,half,0,0,0,0}
00271 },
00272 { "cV", 4,
00273 {-far,far,far,-far,0,0,0,0},
00274 {-half,-half,half,half,0,0,0,0}
00275 },
00276 { "CV", 4,
00277 {-far,far,far,-far,0,0,0,0},
00278 {-half,-half,half,half,0,0,0,0}
00279 },
00280
00281 { "fU", 8,
00282 {-far,far,far,byfc,byft,-byft,-byfc,-far},
00283 {-half,-half,half,half,half-byff,half-byff,half,half}
00284 },
00285 { "FU", 8,
00286 {-far,-byfc,-byft,byft,byfc,far,far,-far},
00287 {-half,-half,-half+byff,-half+byff,-half,-half,half,half}
00288 },
00289
00290 { "dV", 8,
00291 {-far,far,far,byfc,byft,-byft,-byfc,-far},
00292 {-half,-half,half,half,half-byff,half-byff,half,half}
00293 },
00294 { "DV", 8,
00295 {-far,-byfc,-byft,byft,byfc,far,far,-far},
00296 {-half,-half,-half+byff,-half+byff,-half,-half,half,half}
00297 },
00298
00299 { "GU", 4,
00300 {glw-g0,-g0,-g0,gsw-g0,0,0,0,0},
00301 {-half,-half,half,half,0,0,0,0}
00302 },
00303 { "HU", 4,
00304 {hw-g0,-g0,-g0,hw-g0,0,0,0,0},
00305 {-half,-half,half,half,0,0,0,0}
00306 },
00307 { "IU", 6,
00308 {hw-g0,-g0+notch,-g0+notch,-g0,hw-g0,0,0},
00309 {-half,-half,-half+iff,-half+iff,half,half,0,0}
00310 },
00311
00312 { "GV", 4,
00313 {glw-g0,-g0,-g0,gsw-g0,0,0,0,0},
00314 {half,half,-half,-half,0,0,0,0}
00315 },
00316 { "HV", 4,
00317 {hw-g0,-g0,-g0,hw-g0,0,0,0,0},
00318 {half,half,-half,-half,0,0,0,0}
00319 },
00320 { "IV", 6,
00321 {hw-g0,-g0+notch,-g0+notch,-g0,hw-g0,0,0},
00322 {half,half,half-iff,half-iff,-half,-half,0,0}
00323 },
00324
00325 { "XU", 4,
00326 {-caldet,caldet,caldet,-caldet,0,0,0,0},
00327 {-half,-half,half,half,0,0,0,0}
00328 },
00329 { "XV", 4,
00330 {-caldet,caldet,caldet,-caldet,0,0,0,0},
00331 {-half,-half,half,half,0,0,0,0}
00332 },
00333 { "XA", 4,
00334 {-caldet,caldet,caldet,-caldet,0,0,0,0},
00335 {-half,-half,half,half,0,0,0,0}
00336 },
00337 { "XB", 4,
00338 {-caldet,caldet,caldet,-caldet,0,0,0,0},
00339 {-half,-half,half,half,0,0,0,0}
00340 },
00341 #ifdef NOPE
00342 { "default", 4,
00343 {-4,4,4,-4,0,0,0,0},
00344 {-half,-half,half,half,0,0,0,0}
00345 },
00346 #endif
00347
00348 { "default",4, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0} }
00349 };
00350
00351 Int_t listsize = sizeof(shapelist)/sizeof(MdlShape);
00352
00353 Bool_t hitdefault = false;
00354 for (int indx=0; indx<listsize; indx++) {
00355 MdlShape* shapeptr = shapelist + indx;
00356 hitdefault = (shapeptr->mdl_name == "default");
00357
00358
00359
00360
00361 if (shapeptr->mdl_name == typeName || hitdefault ) {
00362
00363 mdlShape->TruncateNxy(shapeptr->n_vtx);
00364 for (int i=0; i<shapeptr->n_vtx; i++) {
00365 mdlShape->DefineVertex(i,shapeptr->xvtx_abs[i],
00366 shapeptr->yvtx_rel[i]*width);
00367 }
00368 break;
00369 }
00370 }
00371
00372 }
00373
00374
00375
00376
00377 UgliScintPlnNode* UgliScintMdlNode::GetScintPlnNode(void) const
00378 { return dynamic_cast<UgliScintPlnNode*>(fParent); }
00379
00380
00381 void UgliScintMdlNode::SetZRotRelPlnRad(Float_t radians)
00382 {
00383
00384
00385 Float_t zrotdeg = radians * Ugli::rad2deg;
00386 fMatrix->SetAngles(90,zrotdeg,90,zrotdeg+90,0,0);
00387 }
00388
00389