00001
00035 #include "Stiostream.h"
00036 #include "EEmcSmdGeom.h"
00037 #include "EEmcStripGeom.h"
00038 #include <assert.h>
00039 #include <TMath.h>
00040
00041
00042
00043 #ifndef HEP_SYSTEM_OF_UNITS_H
00044 static const double radian = 1.;
00045 static const double pi = M_PI;
00046 static const double degree = (M_PI/180.0)*radian;
00047 #endif
00048
00049
00050 #include "StMessMgr.h"
00051
00052
00054 ClassImp(EEmcSmdGeom)
00055
00056 EEmcSmdGeom::EEmcSmdGeom()
00057 : TObject()
00058 {
00059 for(int iSec = 0; iSec < kEEmcNumSectors; iSec++) mIsSectorIn[iSec] = true;
00060 };
00062 EEmcSmdGeom::~EEmcSmdGeom(){
00063 delete sInstance;
00064 sInstance = 0;
00065 }
00066
00068 void EEmcSmdGeom::init(){
00069 buildSmdGeom();
00070 }
00071
00072 EEmcSmdGeom* EEmcSmdGeom::sInstance = 0;
00073
00074 EEmcSmdGeom* EEmcSmdGeom::instance() {
00075 if(!sInstance){
00076 sInstance = new EEmcSmdGeom();
00077 sInstance->init();
00078 }
00079 return sInstance;
00080 }
00081
00082
00083 EEmcSmdGeom* EEmcSmdGeom::instance(intVec sectorIdVec) {
00084 if(!sInstance){
00085 sInstance = new EEmcSmdGeom();
00086 sInstance->setSectors(sectorIdVec);
00087 sInstance->init();
00088 }
00089 return sInstance;
00090 }
00091
00092
00093 void EEmcSmdGeom::buildSmdGeom(){
00094 mEEmcSmdParam.stripWidth = 0.5;
00095 for(int iPlane=0; iPlane<kEEmcNumSmdPlanes; iPlane++)
00096 mEEmcSmdParam.rOffset[iPlane] = kEEmcSmdROffset[iPlane];
00097
00098 float x0[kEEmcNumStrips];
00099 float y1[kEEmcNumStrips];
00100 float y2[kEEmcNumStrips];
00101 float length[kEEmcNumStrips];
00102 float x0Edge[kEEmcNumEdgeStrips];
00103 float y1Edge[kEEmcNumEdgeStrips];
00104 float y2Edge[kEEmcNumEdgeStrips];
00105 float lengthEdge[kEEmcNumEdgeStrips];
00106
00107
00108 for (int i = 0; i < kEEmcNumStrips; i++) {
00109 x0[i] = EEmcStripGeomData[i].x0;
00110 y1[i] = EEmcStripGeomData[i].y1;
00111 y2[i] = EEmcStripGeomData[i].y2;
00112 length[i] = EEmcStripGeomData[i].length;
00113 }
00114 for (int i = 0; i < kEEmcNumEdgeStrips; i++) {
00115 x0Edge[i] = EEmcEdgeStripGeomData[i].x0;
00116 y1Edge[i] = EEmcEdgeStripGeomData[i].y1;
00117 y2Edge[i] = EEmcEdgeStripGeomData[i].y2;
00118 lengthEdge[i] = EEmcEdgeStripGeomData[i].length;
00119 }
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136 float delPhi = 2*pi/degree/kEEmcNumSectors;
00137 float PhiRotation[kEEmcNumSmdUVs][kEEmcNumSectors];
00138
00139
00140 for(int iUV = 0; iUV < kEEmcNumSmdUVs; iUV++) {
00141 for(int iSec=0; iSec<kEEmcNumSectors; iSec++){
00142 PhiRotation[iUV][iSec]=(-15.0 + iSec*delPhi)*degree;
00143 if(iUV == 1) PhiRotation[iUV][iSec] = -1.0*PhiRotation[iUV][iSec];
00144 }
00145 }
00146
00147
00148 for (int iPlane = 0; iPlane < kEEmcNumSmdPlanes; iPlane++) {
00149 float globalX1, globalY1, globalX2, globalY2;
00150 float x0Corr, y1Corr, y2Corr, lengthCorr;
00151 float phi1, phi2, phiMin, phiMax;
00152 float r, rMin, rMax;
00153
00154 mEEmcSmdParam.zPlane[iPlane] = kEEmcZSMD +
00155 (iPlane - kEEmcNumSmdPlanes + 2) * kEEmcSmdZPlaneShift ;
00156
00157 for(int iUV = 0; iUV < kEEmcNumSmdUVs; iUV++) {
00158
00159
00160 for(int iUVSec=iPlane+1-iUV; iUVSec<kEEmcNumSectors+1-iUV;
00161 iUVSec=iUVSec+kEEmcNumSmdPlanes) {
00162 int iSec;
00163 if(iUVSec == 12) iSec = 0;
00164 else iSec = iUVSec;
00165
00166 if(IsSectorIn(iSec)) {
00167
00168 rMin = 1000.0;
00169 rMax = 0.0;
00170 phiMin = pi;
00171 phiMax = -pi;
00172
00173
00174 for (int iStrip = 0; iStrip < kEEmcNumStrips; iStrip++) {
00175 if(kEEmcSmdMapEdge[iPlane][iSec] && iStrip > kEEmcNumEdgeStrips-1)
00176 break;
00177
00178 StructEEmcStripId stripStructId;
00179 stripStructId.sectorId = iSec+1;
00180 stripStructId.UVId = iUV+1;
00181 stripStructId.stripId = iStrip + 1;
00182 stripStructId.planeId = iPlane + 1;
00183
00184 StructEEmcStrip* stripPtr = new StructEEmcStrip;
00185 stripPtr->stripStructId = stripStructId;
00186
00187
00188 x0Corr = x0[iStrip] - kEEmcSmdROffset[iPlane]*::sqrt(0.5);
00189 y2Corr = y2[iStrip] - kEEmcSmdROffset[iPlane]*::sqrt(0.5);
00190 if(kEEmcSmdMapEdge[iPlane][iSec]) {
00191 y1Corr = y1Edge[iStrip] - kEEmcSmdROffset[iPlane]*::sqrt(0.5);
00192 lengthCorr = lengthEdge[iStrip];
00193 }
00194 else {
00195 y1Corr = y1[iStrip] - kEEmcSmdROffset[iPlane]*::sqrt(0.5);
00196 lengthCorr = length[iStrip];
00197 }
00198
00199
00200
00201 if(iUV == 0) {
00202 globalX1 = x0Corr*cos(PhiRotation[iUV][iSec])+
00203 y1Corr*sin(PhiRotation[iUV][iSec]);
00204 globalY1 = y1Corr*cos(PhiRotation[iUV][iSec]) -
00205 x0Corr*sin(PhiRotation[iUV][iSec]);
00206 globalX2 = x0Corr*cos(PhiRotation[iUV][iSec]) +
00207 y2Corr*sin(PhiRotation[iUV][iSec]);
00208 globalY2 = y2Corr*cos(PhiRotation[iUV][iSec]) -
00209 x0Corr*sin(PhiRotation[iUV][iSec]);
00210 }
00211 else {
00212 globalX1 = y1Corr*cos(PhiRotation[iUV][iSec]) -
00213 x0Corr*sin(PhiRotation[iUV][iSec]);
00214 globalY1 = x0Corr*cos(PhiRotation[iUV][iSec]) +
00215 y1Corr*sin(PhiRotation[iUV][iSec]);
00216 globalX2 = y2Corr*cos(PhiRotation[iUV][iSec]) -
00217 x0Corr*sin(PhiRotation[iUV][iSec]);
00218 globalY2 = x0Corr*cos(PhiRotation[iUV][iSec]) +
00219 y2Corr*sin(PhiRotation[iUV][iSec]);
00220 }
00221 r = ::sqrt(globalX1*globalX1 + globalY1*globalY1);
00222 if(r < rMin) rMin = r;
00223 r = ::sqrt(globalX2*globalX2 + globalY2*globalY2);
00224 if(r > rMax) rMax = r;
00225
00226
00227 stripPtr->end1.SetX(globalX1) ;
00228 stripPtr->end1.SetY(globalY1) ;
00229 stripPtr->end1.SetZ(mEEmcSmdParam.zPlane[iPlane]);
00230 stripPtr->end2.SetX(globalX2) ;
00231 stripPtr->end2.SetY(globalY2) ;
00232 stripPtr->end2.SetZ(mEEmcSmdParam.zPlane[iPlane]);
00233 stripPtr->length = lengthCorr;
00234
00235 phi1 = stripPtr->end1.Phi();
00236 phi2 = stripPtr->end2.Phi();
00237
00238 if(iSec != kEEmcSmdSectorIdPhiCrossPi - 1) {
00239 if(phi1 < phiMin) phiMin = phi1;
00240 if(phi1 > phiMax) phiMax = phi1;
00241 if(phi2 < phiMin) phiMin = phi2;
00242 if(phi2 > phiMax) phiMax = phi2;
00243 }
00244 else {
00245 if(phi1 > 0) if(phi1 < phiMin) phiMin = phi1;
00246 if(phi1 < 0 ) if(phi1 > phiMax) phiMax = phi1;
00247 if(phi2 > 0) if(phi2 < phiMin) phiMin = phi2;
00248 if(phi2 < 0) if(phi2 > phiMax) phiMax = phi2;
00249 }
00250 mEEmcSector[iUV][iSec].stripPtrVec.push_back(stripPtr);
00251 }
00252
00253
00254 mEEmcSector[iUV][iSec].sectorId = iSec+1;
00255 mEEmcSector[iUV][iSec].planeId = iPlane+1;
00256 mEEmcSector[iUV][iSec].phiMin = phiMin;
00257 mEEmcSector[iUV][iSec].phiMax = phiMax;
00258 mEEmcSector[iUV][iSec].rMin = rMin;
00259 mEEmcSector[iUV][iSec].rMax = rMax;
00260
00261 }
00262 }
00263 }
00264 }
00265
00266
00267
00268 memset(kEEmcSmdMap_iPlane,0,sizeof(kEEmcSmdMap_iPlane));
00269 for (int iPlane = 0; iPlane < kEEmcNumSmdPlanes; iPlane++)
00270 for(int iSec=0; iSec<kEEmcNumSectors; iSec++) {
00271 int iuv=kEEmcSmdMapUV[iPlane][iSec];
00272 if(iuv<0 ) continue;
00273 assert(iuv<kEEmcNumSmdUVs);
00274 kEEmcSmdMap_iPlane[iuv][iSec]=iPlane;
00275 }
00276
00277 buildStripPtrVector();
00278
00279 }
00280
00281
00282
00283
00284 void EEmcSmdGeom::buildStripPtrVector() {
00285 StructEEmcStrip *dummyStripPtr = new StructEEmcStrip;
00286 *dummyStripPtr = initStrip();
00287 EEmcStripPtrVec stripPtrVec;
00288 EEmcStripPtrVecIter p;
00289 for(int iSec = 0; iSec < kEEmcNumSectors; iSec++) {
00290 if(mIsSectorIn[iSec]) {
00291 for(int iUV = 0; iUV < kEEmcNumSmdUVs; iUV++) {
00292 stripPtrVec = getEEmcSector(iUV,iSec).stripPtrVec;
00293 p = stripPtrVec.begin();
00294 int PlaneId = getEEmcSector(iUV,iSec).planeId;
00295 while(p !=stripPtrVec.end()) {
00296 mStripPtrVector.push_back(*p);
00297 p++;
00298
00299 }
00300 if(kEEmcSmdMapEdge[PlaneId-1][iSec]) {
00301 for(int i=0; i < kEEmcNumStrips - kEEmcNumEdgeStrips; i++)
00302 mStripPtrVector.push_back(dummyStripPtr);
00303 }
00304 }
00305 }
00306 else {
00307 for(int iUV = 0; iUV < kEEmcNumSmdUVs; iUV++) {
00308 for(int iStrip = 0; iStrip < kEEmcNumStrips; iStrip++)
00309 mStripPtrVector.push_back(dummyStripPtr);
00310 }
00311 }
00312 }
00313 }
00314
00315
00316 void EEmcSmdGeom::setSectors(const intVec sectorIdVec) {
00317 for(int iSec = 0; iSec< kEEmcNumSectors; iSec++)
00318 mIsSectorIn[iSec] = false;
00319 for(unsigned int i = 0; i < sectorIdVec.size(); i++) {
00320 for(int iSec = 0; iSec< kEEmcNumSectors; iSec++) {
00321 if (sectorIdVec[i] == iSec+1) mIsSectorIn[iSec] = true;
00322 }
00323 }
00324 }
00325
00326
00327 StructEEmcStrip EEmcSmdGeom::initStrip() const {
00328 TVector3 zero = 0.0;
00329 StructEEmcStrip strip;
00330 strip.stripStructId.stripId = 0;
00331 strip.stripStructId.UVId = 0;
00332 strip.stripStructId.sectorId = 0;
00333 strip.stripStructId.planeId = 0;
00334 strip.end1 = zero;
00335 strip.end2 = zero;
00336 strip.length = 0.0;
00337 return strip;
00338 }
00339
00340
00341 Int_t EEmcSmdGeom::getEEmcISec(const Int_t iPlane,
00342 const TVector3& point) const {
00343 Int_t indexSec = -1;
00344 float phiMin, phiMax, rMin, rMax;
00345 float phi = point.Phi();
00346 float r = ::sqrt(point.x()*point.x() + point.y()*point.y());
00347
00348 for (int iSec = 0; iSec < kEEmcNumSectors; iSec++) {
00349 int iUV = kEEmcSmdMapUV[iPlane][iSec];
00350 if(iUV >= 0 && IsSectorIn(iSec)) {
00351 phiMin = mEEmcSector[iUV][iSec].phiMin;
00352 phiMax = mEEmcSector[iUV][iSec].phiMax;
00353 rMin = mEEmcSector[iUV][iSec].rMin;
00354 rMax = mEEmcSector[iUV][iSec].rMax;
00355 if(iSec != kEEmcSmdSectorIdPhiCrossPi - 1) {
00356 if (phi >= phiMin && phi < phiMax && r > rMin && r < rMax) {
00357 indexSec = iSec;
00358 break;
00359 }
00360 }
00361
00362 else {
00363 if(((phi > 0.0 && phi >= phiMin) || (phi < 0.0 && phi < phiMax))
00364 && r > rMin && r < rMax){
00365 indexSec = iSec;
00366 break;
00367 }
00368 }
00369 }
00370 }
00371 return indexSec;
00372 }
00373
00374
00375 StructEEmcStrip* EEmcSmdGeom::getStripPtr(const Int_t iStrip, const Int_t iUV, const Int_t iSec) {
00376 int i = iStrip + iUV*kEEmcNumStrips + iSec*kEEmcNumStrips*kEEmcNumSmdUVs;
00377 return mStripPtrVector[i];
00378 }
00379
00380
00381 const StructEEmcStrip* EEmcSmdGeom::getStripPtr(const Int_t iStrip, const Int_t iUV, const Int_t iSec) const {
00382 int i = iStrip + iUV*kEEmcNumStrips + iSec*kEEmcNumStrips*kEEmcNumSmdUVs;
00383 return mStripPtrVector[i];
00384 }
00385
00386
00387
00388
00389
00390 const StructEEmcStrip* EEmcSmdGeom::getDcaStripPtr(const Int_t iPlane,
00391 const Int_t iSec, const TVector3& point, Float_t* dca) const
00392 {
00393
00394
00395 *dca = 1000.0;
00396 int iStrip = -1;
00397
00398 float x1,y1,x2,y2,mu,d;
00399 EEmcStripPtrVec stripPtrVec;
00400 EEmcStripPtrVecIter p;
00401
00402
00403 Int_t iUV = kEEmcSmdMapUV[iPlane][iSec];
00404
00405
00406
00407 if(iSec >= 0 && IsSectorIn(iSec)) {
00408
00409 stripPtrVec = getEEmcSector(iUV,iSec).stripPtrVec;
00410 p = stripPtrVec.begin();
00411 while(p != stripPtrVec.end()) {
00412 x1 = (*p)->end1.x();
00413 y1 = (*p)->end1.y();
00414 x2 = (*p)->end2.x();
00415 y2 = (*p)->end2.y();
00416 mu = -1.0/::sqrt((y2-y1)*(y2-y1) + (x2-x1)*(x2-x1)) *
00417 ((x2*y1-x1*y2)/fabs(x2*y1-x1*y2));
00418
00419 d = ((y2-y1)*point.x() + (x1-x2)*point.y() + (x2*y1-x1*y2))*mu;
00420
00421 if(fabs(d) < fabs(*dca)) {
00422 *dca = d;
00423 iStrip = (*p)->stripStructId.stripId - 1;
00424 }
00425 if(d < 0) break;
00426 p++;
00427 }
00428 }
00429 if(iStrip >=0) {
00430
00431
00432 return getStripPtr(iStrip,iUV,iSec);
00433 }
00434 else {
00435 StructEEmcStrip *stripPtr = new StructEEmcStrip;
00436 (*stripPtr) = initStrip();
00437
00438
00439 return stripPtr;
00440 }
00441 }
00442
00443
00444
00445
00446 const StructEEmcStrip* EEmcSmdGeom::getDcaStripPtr(const Int_t iPlane,
00447 const TVector3& point, Float_t* dca) const {
00448 int iSec = getEEmcISec(iPlane, point);
00449 return getDcaStripPtr(iPlane, iSec, point, dca);
00450 }
00451
00452
00453
00454
00455
00456
00457 const StructEEmcStrip* EEmcSmdGeom::getDca2Strip(const Int_t iUV,
00458 const TVector3& point, Float_t* dca) const {
00459 assert(iUV>=0 || iUV<kEEmcNumSmdUVs);
00460 float phiDeg=atan2(point.y(),point.x())/3.1316*180.;
00461
00462 int iSec= ((int) ( 12.-(phiDeg-75.)/30.) )%12;
00463 assert(iSec>=0);
00464 assert( iSec<kEEmcNumSectors);
00465 int iPlane= kEEmcSmdMap_iPlane[iUV][iSec];
00466 assert(iPlane>=0 && iPlane<kEEmcNumSmdPlanes);
00467 return getDcaStripPtr(iPlane, iSec, point, dca);
00468 }
00469
00470
00471
00472
00473 bool EEmcSmdGeom::matchStrips(const StructEEmcStripId &stripStructId1,
00474 const StructEEmcStripId &stripStructId2,
00475 Int_t nTolerance) const {
00476 bool match = false;
00477 if(stripStructId1.UVId == stripStructId2.UVId &&
00478 stripStructId1.sectorId == stripStructId2.sectorId) {
00479 if((TMath::Abs(stripStructId1.stripId - stripStructId2.stripId) <= nTolerance))
00480 match = true;
00481 }
00482 return match;
00483 }
00484
00485
00486
00487 TVector3 EEmcSmdGeom::getstripEnd(const StructEEmcStrip &strip,
00488 const Int_t endId) const {
00489 TVector3 end;
00490 if(endId == 1) end = strip.end1;
00491 else end = strip.end2;
00492
00493 return end;
00494 }
00495
00496
00498 void EEmcSmdGeom::printGeom(ostream& os) const {
00499 os << "------EEmcSmdGeom::printGeom()------" << endl;
00500 os << " " << "z[3] = "
00501 << " " << getEEmcSmdParam().zPlane[0]
00502 << " " << getEEmcSmdParam().zPlane[1]
00503 << " " << getEEmcSmdParam().zPlane[2] << endl;
00504 os << " " << "rOffset[3] = "
00505 << " " << getEEmcSmdParam().rOffset[0]
00506 << " " << getEEmcSmdParam().rOffset[1]
00507 << " " << getEEmcSmdParam().rOffset[2] << endl;
00508 os << " " << "stripWidth = "
00509 << " " << getEEmcSmdParam().stripWidth << endl;
00510 os << "---------------------------------------" << endl;
00511 }
00512
00514 void EEmcSmdGeom::printSector(const StructEEmcSmdSector sector, ostream& os) const {
00515 float delPhi;
00516 int iUV = kEEmcSmdMapUV[sector.planeId-1][sector.sectorId-1];
00517 delPhi = (sector.phiMax - sector.phiMin)/degree;
00518 if(sector.sectorId == kEEmcSmdSectorIdPhiCrossPi)
00519 delPhi = 2*pi/degree + delPhi;
00520
00521 os << "------EEmcSmdGeom::printSector()------" << endl;
00522 os << kEEmcSmdUVChar[iUV] << " Sector: sectorId, planeId, nStrips = "
00523 << " " << sector.sectorId
00524 << " " << sector.planeId
00525 << " " << sector.stripPtrVec.size() << endl;
00526 os << " phiMin, phiMax, delPhi = "
00527 << " " << sector.phiMin/degree
00528 << " " << sector.phiMax/degree
00529 << " " << delPhi << endl;
00530 os << " rMin, rMax delR = "
00531 << " " << sector.rMin
00532 << " " << sector.rMax
00533 << " " << sector.rMax - sector.rMin << endl;
00534 os << "------------------------------------" << endl;
00535 }
00536
00538 void EEmcSmdGeom::printStrip(const StructEEmcStrip strip, ostream& os) const {
00539 char UVChar;
00540 if(strip.stripStructId.sectorId == 0) UVChar = 'X';
00541 else
00542 UVChar = kEEmcSmdUVChar[strip.stripStructId.UVId - 1];
00543
00544 os << "------EEmcSmdGeom::printStrip()------" << endl;
00545
00546 os << "Strip: sectorId, planeUV, stripId, planeId = "
00547 << " " << strip.stripStructId.sectorId
00548 << " " << UVChar
00549 << " " << strip.stripStructId.stripId
00550 << " " << strip.stripStructId.planeId << endl;
00551 os << " x1, y1, x2, y2, z = "
00552 << " " << strip.end1.x()
00553 << " " << strip.end1.y()
00554 << " " << strip.end2.x()
00555 << " " << strip.end2.y()
00556 << " " << strip.end2.z() << endl;
00557 os << " phi1, phi2, length = "
00558 << " " << strip.end1.Phi()/degree
00559 << " " << strip.end2.Phi()/degree
00560 << " " << strip.length << endl;
00561 os << "------------------------------------" << endl;
00562 }
00563
00565 void EEmcSmdGeom::printStripId(const StructEEmcStripId stripStructId, ostream& os) const {
00566 char UVChar;
00567 if(stripStructId.sectorId == 0) UVChar = 'X';
00568 else
00569 UVChar = kEEmcSmdUVChar[stripStructId.UVId - 1];
00570
00571 os << "------EEmcSmdGeom::printStripId()------" << endl;
00572 os << "Strip: sectorId, stripId, planeId = "
00573 << " " << stripStructId.sectorId
00574 << UVChar
00575 << " " << stripStructId.stripId
00576 << " " << stripStructId.planeId << endl;
00577 os << "------------------------------------" << endl;
00578 }
00579
00580
00581
00582
00583 #if 0
00584
00585 void EEmcSmdGeom::printSectorPhis(const Int_t iPlane, const Int_t iSec,
00586 ostream& os ) {
00587 int iUV;
00588 iUV = kEEmcSmdMapUV[iPlane][iSec];
00589
00590 os << "------EEmcSmdGeom::printPhis()------" << endl;
00591 os << " planeId = " << iPlane + 1 << " sectorId = " << iSec + 1 << endl;
00592 if(iUV >= 0)
00593 os << " " << kEEmcSmdUVChar[iUV] << " Sector" << endl;
00594 else
00595 os << " Empty" << endl;
00596 os << " delPhi = " << getEEmcSmdDelPhi(iPlane, iSec)/degree <<
00597 " " << "centerPhi = " << getEEmcSmdCenterPhi(iPlane, iSec)/degree
00598 << endl;
00599
00600 }
00601 #endif
00602
00603
00605
00606
00607
00608
00609
00610
00611
00612
00613 TVector3 EEmcSmdGeom::getIntersection ( Int_t sector, Int_t uId, Int_t vId ) const {
00614
00615 Int_t nU = getNStrips( sector, 0 );
00616 Int_t nV = getNStrips( sector, 1 );
00617 if ( uId >= nU || vId >= nV ) {
00618 LOG_DEBUG<<"::getIntersection(...) passed invalid strip ID sector="<<sector<<" uId="<<uId<<" vId="<<vId<<std::endl;
00619 return TVector3(1.,1.,-999.0);
00620 }
00621
00622 return getIntersection ( getStripPtr( uId, 0, sector ),
00623 getStripPtr( vId, 1, sector ) );
00624
00625 }
00626
00627
00628 TVector3 EEmcSmdGeom::getIntersection ( Int_t sector, Int_t uId, Int_t vId, const TVector3 &vert ) const {
00629
00630 Int_t nU = getNStrips( sector, 0 );
00631 Int_t nV = getNStrips( sector, 1 );
00632 if ( uId >= nU || vId >= nV ) {
00633 LOG_DEBUG<<"::getIntersection(...) passed invalid strip ID sector="<<sector<<" uId="<<uId<<" vId="<<vId<<std::endl;
00634 return TVector3(1.,1.,-999.0);
00635 }
00636
00637 return getIntersection ( getStripPtr( uId, 0, sector ),
00638 getStripPtr( vId, 1, sector ), vert );
00639
00640 }
00641
00642
00643
00644 TVector3 EEmcSmdGeom::getIntersection ( const StructEEmcStrip *u,
00645 const StructEEmcStrip *v,
00646 const TVector3 &vertex ) const
00647 {
00648
00649
00650
00651
00652 Int_t uSectorId = u -> stripStructId.sectorId;
00653 Int_t vSectorId = v -> stripStructId.sectorId;
00654
00655
00656
00657 Int_t uId = u -> stripStructId.stripId;
00658 Int_t vId = v -> stripStructId.stripId;
00659
00660
00661
00662
00663
00664
00665
00666 TVector3 u0 = getStripPtr ( uId-1, 0, uSectorId-1 ) -> end1;
00667 TVector3 v0 = getStripPtr ( vId-1, 1, vSectorId-1 ) -> end1;
00668
00669
00670 TVector3 uF = getStripPtr ( uId-1, 0, uSectorId-1 ) -> end2;
00671 TVector3 vF = getStripPtr ( vId-1, 1, vSectorId-1 ) -> end2;
00672
00673
00674 TVector3 u0p=(u0-vertex);
00675 TVector3 uFp=(uF-vertex);
00676 TVector3 v0p=(v0-vertex);
00677 TVector3 vFp=(vF-vertex);
00678
00680
00682
00683
00684 TVector3 Nv = u0p.Cross(uFp);
00685
00686
00687 Float_t Dv = (Nv.X()*vertex.X() + Nv.Y()*vertex.Y() + Nv.Z()*vertex.Z());
00688
00689
00690
00691
00692
00693 Float_t scale_numerv = (Nv.X()*v0.X() + Nv.Y()*v0.Y() + Nv.Z()*v0.Z() - Dv);
00694 Float_t scale_denomv = (Nv.X()*(v0.X()-vF.X()) + Nv.Y()*(v0.Y()-vF.Y()) + Nv.Z()*(v0.Z()-vF.Z()));
00695 Float_t scalev=scale_numerv/scale_denomv;
00696 if (scalev < 0 || scalev > 1) {
00697 TVector3 ErrorVector(1.,1.,-999.);
00698 LOG_DEBUG<<GetName()<<"::getIntersection( ) passed non-intersecting SMD strips " << *u << " " << *v << endm;
00699 return ErrorVector;
00700 }
00701
00702
00703
00704 TVector3 Rv = (v0 + scalev*(vF-v0));
00705
00706
00707
00708
00709
00710
00712
00714
00715 TVector3 Nu = v0p.Cross(vFp);
00716
00717
00718 Float_t Du = (Nu.X()*vertex.X() + Nu.Y()*vertex.Y() + Nu.Z()*vertex.Z());
00719
00720
00721 Float_t scale_numeru = (Nu.X()*u0.X() + Nu.Y()*u0.Y() + Nu.Z()*u0.Z() - Du);
00722 Float_t scale_denomu = (Nu.X()*(u0.X()-uF.X()) + Nu.Y()*(u0.Y()-uF.Y()) + Nu.Z()*(u0.Z()-uF.Z()));
00723 Float_t scaleu=scale_numeru/scale_denomu;
00724 if (scaleu < 0 || scaleu > 1) {
00725 TVector3 ErrorVector(1.,1.,-999.);
00726 return ErrorVector;
00727 }
00728
00729
00730
00731 TVector3 Ru = (u0 + scaleu*(uF-u0));
00732
00733
00734
00735 TVector3 R = ((Rv+Ru)*0.5);
00736
00737 return R;
00738
00739
00740
00741 }
00742
00743
00744
00745
00746 TVector3 EEmcSmdGeom::getIntersection ( const StructEEmcStrip *u,
00747 const StructEEmcStrip *v
00748 ) const {
00749
00750 return getIntersection( u, v, TVector3(0,0,0) );
00751
00752 }
00753
00754
00755
00756
00757
00758 ostream& operator<<(ostream &os, const StructEEmcStrip &strip)
00759 {
00760 const Char_t *nameUV[]={"U","V"};
00761 TString stripname="";
00762 if ( strip.stripStructId.sectorId < 10 ) stripname+="0"; stripname+=strip.stripStructId.sectorId;
00763 stripname += nameUV[ strip.stripStructId.UVId-1 ];
00764 if ( strip.stripStructId.stripId < 10 ) stripname+="0";
00765 if ( strip.stripStructId.stripId < 100 ) stripname+="0";
00766 stripname+=strip.stripStructId.stripId;
00767 os << stripname << " depth=" << strip.stripStructId.planeId;
00768 return os;
00769 }
00770
00771
00773
00774
00775
00776
00777
00778
00779
00780
00781
00782
00783
00784
00785
00786
00787
00788
00789
00790
00791
00792
00793
00794
00795
00796
00797
00798
00799
00800
00801
00802
00803
00804
00805
00806
00807
00808
00809
00810
00811
00812
00813
00814
00815
00816
00817
00818
00819
00820
00821
00822
00823
00824
00825
00826
00827
00828
00829
00830
00831
00832
00833
00834
00835
00836
00837
00838
00839
00840
00841
00842
00843
00844
00845
00846
00847
00848
00849
00850
00851
00852
00853
00854
00855
00856
00857
00858
00859