36 #include "EEmcSmdGeom.h"
37 #include "EEmcStripGeom.h"
43 #ifndef HEP_SYSTEM_OF_UNITS_H
44 static const double radian = 1.;
45 static const double pi = M_PI;
46 static const double degree = (M_PI/180.0)*radian;
50 #include "StMessMgr.h"
59 for(
int iSec = 0; iSec < kEEmcNumSectors; iSec++) mIsSectorIn[iSec] =
true;
83 EEmcSmdGeom* EEmcSmdGeom::instance(intVec sectorIdVec) {
93 void EEmcSmdGeom::buildSmdGeom(){
94 mEEmcSmdParam.stripWidth = 0.5;
95 for(
int iPlane=0; iPlane<kEEmcNumSmdPlanes; iPlane++)
96 mEEmcSmdParam.rOffset[iPlane] = kEEmcSmdROffset[iPlane];
98 float x0[kEEmcNumStrips];
99 float y1[kEEmcNumStrips];
100 float y2[kEEmcNumStrips];
101 float length[kEEmcNumStrips];
102 float x0Edge[kEEmcNumEdgeStrips];
103 float y1Edge[kEEmcNumEdgeStrips];
104 float y2Edge[kEEmcNumEdgeStrips];
105 float lengthEdge[kEEmcNumEdgeStrips];
108 for (
int i = 0; i < kEEmcNumStrips; i++) {
109 x0[i] = EEmcStripGeomData[i].x0;
110 y1[i] = EEmcStripGeomData[i].y1;
111 y2[i] = EEmcStripGeomData[i].y2;
112 length[i] = EEmcStripGeomData[i].length;
114 for (
int i = 0; i < kEEmcNumEdgeStrips; i++) {
115 x0Edge[i] = EEmcEdgeStripGeomData[i].x0;
116 y1Edge[i] = EEmcEdgeStripGeomData[i].y1;
117 y2Edge[i] = EEmcEdgeStripGeomData[i].y2;
118 lengthEdge[i] = EEmcEdgeStripGeomData[i].length;
136 float delPhi = 2*pi/degree/kEEmcNumSectors;
137 float PhiRotation[kEEmcNumSmdUVs][kEEmcNumSectors];
140 for(
int iUV = 0; iUV < kEEmcNumSmdUVs; iUV++) {
141 for(
int iSec=0; iSec<kEEmcNumSectors; iSec++){
142 PhiRotation[iUV][iSec]=(-15.0 + iSec*delPhi)*degree;
143 if(iUV == 1) PhiRotation[iUV][iSec] = -1.0*PhiRotation[iUV][iSec];
148 for (
int iPlane = 0; iPlane < kEEmcNumSmdPlanes; iPlane++) {
149 float globalX1, globalY1, globalX2, globalY2;
150 float x0Corr, y1Corr, y2Corr, lengthCorr;
151 float phi1, phi2, phiMin, phiMax;
154 mEEmcSmdParam.zPlane[iPlane] = kEEmcZSMD +
155 (iPlane - kEEmcNumSmdPlanes + 2) * kEEmcSmdZPlaneShift ;
157 for(
int iUV = 0; iUV < kEEmcNumSmdUVs; iUV++) {
160 for(
int iUVSec=iPlane+1-iUV; iUVSec<kEEmcNumSectors+1-iUV;
161 iUVSec=iUVSec+kEEmcNumSmdPlanes) {
163 if(iUVSec == 12) iSec = 0;
174 for (
int iStrip = 0; iStrip < kEEmcNumStrips; iStrip++) {
175 if(kEEmcSmdMapEdge[iPlane][iSec] && iStrip > kEEmcNumEdgeStrips-1)
179 stripStructId.sectorId = iSec+1;
180 stripStructId.UVId = iUV+1;
181 stripStructId.stripId = iStrip + 1;
182 stripStructId.planeId = iPlane + 1;
185 stripPtr->stripStructId = stripStructId;
188 x0Corr = x0[iStrip] - kEEmcSmdROffset[iPlane]*::sqrt(0.5);
189 y2Corr = y2[iStrip] - kEEmcSmdROffset[iPlane]*::sqrt(0.5);
190 if(kEEmcSmdMapEdge[iPlane][iSec]) {
191 y1Corr = y1Edge[iStrip] - kEEmcSmdROffset[iPlane]*::sqrt(0.5);
192 lengthCorr = lengthEdge[iStrip];
195 y1Corr = y1[iStrip] - kEEmcSmdROffset[iPlane]*::sqrt(0.5);
196 lengthCorr = length[iStrip];
202 globalX1 = x0Corr*cos(PhiRotation[iUV][iSec])+
203 y1Corr*sin(PhiRotation[iUV][iSec]);
204 globalY1 = y1Corr*cos(PhiRotation[iUV][iSec]) -
205 x0Corr*sin(PhiRotation[iUV][iSec]);
206 globalX2 = x0Corr*cos(PhiRotation[iUV][iSec]) +
207 y2Corr*sin(PhiRotation[iUV][iSec]);
208 globalY2 = y2Corr*cos(PhiRotation[iUV][iSec]) -
209 x0Corr*sin(PhiRotation[iUV][iSec]);
212 globalX1 = y1Corr*cos(PhiRotation[iUV][iSec]) -
213 x0Corr*sin(PhiRotation[iUV][iSec]);
214 globalY1 = x0Corr*cos(PhiRotation[iUV][iSec]) +
215 y1Corr*sin(PhiRotation[iUV][iSec]);
216 globalX2 = y2Corr*cos(PhiRotation[iUV][iSec]) -
217 x0Corr*sin(PhiRotation[iUV][iSec]);
218 globalY2 = x0Corr*cos(PhiRotation[iUV][iSec]) +
219 y2Corr*sin(PhiRotation[iUV][iSec]);
221 r = ::sqrt(globalX1*globalX1 + globalY1*globalY1);
222 if(r < rMin) rMin = r;
223 r = ::sqrt(globalX2*globalX2 + globalY2*globalY2);
224 if(r > rMax) rMax = r;
227 stripPtr->end1.SetX(globalX1) ;
228 stripPtr->end1.SetY(globalY1) ;
229 stripPtr->end1.SetZ(mEEmcSmdParam.zPlane[iPlane]);
230 stripPtr->end2.SetX(globalX2) ;
231 stripPtr->end2.SetY(globalY2) ;
232 stripPtr->end2.SetZ(mEEmcSmdParam.zPlane[iPlane]);
233 stripPtr->length = lengthCorr;
235 phi1 = stripPtr->end1.Phi();
236 phi2 = stripPtr->end2.Phi();
238 if(iSec != kEEmcSmdSectorIdPhiCrossPi - 1) {
239 if(phi1 < phiMin) phiMin = phi1;
240 if(phi1 > phiMax) phiMax = phi1;
241 if(phi2 < phiMin) phiMin = phi2;
242 if(phi2 > phiMax) phiMax = phi2;
245 if(phi1 > 0)
if(phi1 < phiMin) phiMin = phi1;
246 if(phi1 < 0 )
if(phi1 > phiMax) phiMax = phi1;
247 if(phi2 > 0)
if(phi2 < phiMin) phiMin = phi2;
248 if(phi2 < 0)
if(phi2 > phiMax) phiMax = phi2;
250 mEEmcSector[iUV][iSec].stripPtrVec.push_back(stripPtr);
269 for (
int iPlane = 0; iPlane < kEEmcNumSmdPlanes; iPlane++)
270 for(
int iSec=0; iSec<kEEmcNumSectors; iSec++) {
271 int iuv=kEEmcSmdMapUV[iPlane][iSec];
273 assert(iuv<kEEmcNumSmdUVs);
287 EEmcStripPtrVec stripPtrVec;
288 EEmcStripPtrVecIter p;
289 for(
int iSec = 0; iSec < kEEmcNumSectors; iSec++) {
291 for(
int iUV = 0; iUV < kEEmcNumSmdUVs; iUV++) {
293 p = stripPtrVec.begin();
295 while(p !=stripPtrVec.end()) {
300 if(kEEmcSmdMapEdge[PlaneId-1][iSec]) {
301 for(
int i=0; i < kEEmcNumStrips - kEEmcNumEdgeStrips; i++)
307 for(
int iUV = 0; iUV < kEEmcNumSmdUVs; iUV++) {
308 for(
int iStrip = 0; iStrip < kEEmcNumStrips; iStrip++)
317 for(
int iSec = 0; iSec< kEEmcNumSectors; iSec++)
319 for(
unsigned int i = 0; i < sectorIdVec.size(); i++) {
320 for(
int iSec = 0; iSec< kEEmcNumSectors; iSec++) {
321 if (sectorIdVec[i] == iSec+1)
mIsSectorIn[iSec] =
true;
328 TVector3 zero(0,0,0);
330 strip.stripStructId.stripId = 0;
331 strip.stripStructId.UVId = 0;
332 strip.stripStructId.sectorId = 0;
333 strip.stripStructId.planeId = 0;
342 const TVector3& point)
const {
344 float phiMin, phiMax, rMin, rMax;
345 float phi = point.Phi();
346 float r = ::sqrt(point.x()*point.x() + point.y()*point.y());
348 for (
int iSec = 0; iSec < kEEmcNumSectors; iSec++) {
349 int iUV = kEEmcSmdMapUV[iPlane][iSec];
355 if(iSec != kEEmcSmdSectorIdPhiCrossPi - 1) {
356 if (phi >= phiMin && phi < phiMax && r > rMin && r < rMax) {
363 if(((phi > 0.0 && phi >= phiMin) || (phi < 0.0 && phi < phiMax))
364 && r > rMin && r < rMax){
376 int i = iStrip + iUV*kEEmcNumStrips + iSec*kEEmcNumStrips*kEEmcNumSmdUVs;
382 int i = iStrip + iUV*kEEmcNumStrips + iSec*kEEmcNumStrips*kEEmcNumSmdUVs;
391 const Int_t iSec,
const TVector3& point, Float_t* dca)
const
398 float x1,y1,x2,y2,mu,d;
399 EEmcStripPtrVec stripPtrVec;
400 EEmcStripPtrVecIter p;
403 Int_t iUV = kEEmcSmdMapUV[iPlane][iSec];
410 p = stripPtrVec.begin();
411 while(p != stripPtrVec.end()) {
416 mu = -1.0/::sqrt((y2-y1)*(y2-y1) + (x2-x1)*(x2-x1)) *
417 ((x2*y1-x1*y2)/fabs(x2*y1-x1*y2));
419 d = ((y2-y1)*point.x() + (x1-x2)*point.y() + (x2*y1-x1*y2))*mu;
421 if(fabs(d) < fabs(*dca)) {
423 iStrip = (*p)->stripStructId.stripId - 1;
447 const TVector3& point, Float_t* dca)
const {
458 const TVector3& point, Float_t* dca)
const {
459 assert(iUV>=0 || iUV<kEEmcNumSmdUVs);
460 float phiDeg=atan2(point.y(),point.x())/3.1316*180.;
462 int iSec= ((int) ( 12.-(phiDeg-75.)/30.) )%12;
464 assert( iSec<kEEmcNumSectors);
466 assert(iPlane>=0 && iPlane<kEEmcNumSmdPlanes);
475 Int_t nTolerance)
const {
477 if(stripStructId1.UVId == stripStructId2.UVId &&
478 stripStructId1.sectorId == stripStructId2.sectorId) {
479 if((TMath::Abs(stripStructId1.stripId - stripStructId2.stripId) <= nTolerance))
488 const Int_t endId)
const {
490 if(endId == 1) end = strip.end1;
491 else end = strip.end2;
499 os <<
"------EEmcSmdGeom::printGeom()------" << endl;
500 os <<
" " <<
"z[3] = "
504 os <<
" " <<
"rOffset[3] = "
508 os <<
" " <<
"stripWidth = "
510 os <<
"---------------------------------------" << endl;
516 int iUV = kEEmcSmdMapUV[sector.planeId-1][sector.sectorId-1];
517 delPhi = (sector.phiMax - sector.phiMin)/degree;
518 if(sector.sectorId == kEEmcSmdSectorIdPhiCrossPi)
519 delPhi = 2*pi/degree + delPhi;
521 os <<
"------EEmcSmdGeom::printSector()------" << endl;
522 os << kEEmcSmdUVChar[iUV] <<
" Sector: sectorId, planeId, nStrips = "
523 <<
" " << sector.sectorId
524 <<
" " << sector.planeId
525 <<
" " << sector.stripPtrVec.size() << endl;
526 os <<
" phiMin, phiMax, delPhi = "
527 <<
" " << sector.phiMin/degree
528 <<
" " << sector.phiMax/degree
529 <<
" " << delPhi << endl;
530 os <<
" rMin, rMax delR = "
531 <<
" " << sector.rMin
532 <<
" " << sector.rMax
533 <<
" " << sector.rMax - sector.rMin << endl;
534 os <<
"------------------------------------" << endl;
540 if(strip.stripStructId.sectorId == 0) UVChar =
'X';
542 UVChar = kEEmcSmdUVChar[strip.stripStructId.UVId - 1];
544 os <<
"------EEmcSmdGeom::printStrip()------" << endl;
546 os <<
"Strip: sectorId, planeUV, stripId, planeId = "
547 <<
" " << strip.stripStructId.sectorId
549 <<
" " << strip.stripStructId.stripId
550 <<
" " << strip.stripStructId.planeId << endl;
551 os <<
" x1, y1, x2, y2, z = "
552 <<
" " << strip.end1.x()
553 <<
" " << strip.end1.y()
554 <<
" " << strip.end2.x()
555 <<
" " << strip.end2.y()
556 <<
" " << strip.end2.z() << endl;
557 os <<
" phi1, phi2, length = "
558 <<
" " << strip.end1.Phi()/degree
559 <<
" " << strip.end2.Phi()/degree
560 <<
" " << strip.length << endl;
561 os <<
"------------------------------------" << endl;
567 if(stripStructId.sectorId == 0) UVChar =
'X';
569 UVChar = kEEmcSmdUVChar[stripStructId.UVId - 1];
571 os <<
"------EEmcSmdGeom::printStripId()------" << endl;
572 os <<
"Strip: sectorId, stripId, planeId = "
573 <<
" " << stripStructId.sectorId
575 <<
" " << stripStructId.stripId
576 <<
" " << stripStructId.planeId << endl;
577 os <<
"------------------------------------" << endl;
585 void EEmcSmdGeom::printSectorPhis(
const Int_t iPlane,
const Int_t iSec,
588 iUV = kEEmcSmdMapUV[iPlane][iSec];
590 os <<
"------EEmcSmdGeom::printPhis()------" << endl;
591 os <<
" planeId = " << iPlane + 1 <<
" sectorId = " << iSec + 1 << endl;
593 os <<
" " << kEEmcSmdUVChar[iUV] <<
" Sector" << endl;
595 os <<
" Empty" << endl;
596 os <<
" delPhi = " << getEEmcSmdDelPhi(iPlane, iSec)/degree <<
597 " " <<
"centerPhi = " << getEEmcSmdCenterPhi(iPlane, iSec)/degree
617 if ( uId >= nU || vId >= nV ) {
618 LOG_DEBUG<<
"::getIntersection(...) passed invalid strip ID sector="<<sector<<
" uId="<<uId<<
" vId="<<vId<<std::endl;
619 return TVector3(1.,1.,-999.0);
632 if ( uId >= nU || vId >= nV ) {
633 LOG_DEBUG<<
"::getIntersection(...) passed invalid strip ID sector="<<sector<<
" uId="<<uId<<
" vId="<<vId<<std::endl;
634 return TVector3(1.,1.,-999.0);
646 const TVector3 &
vertex )
const
652 Int_t uSectorId = u -> stripStructId.sectorId;
653 Int_t vSectorId = v -> stripStructId.sectorId;
657 Int_t uId = u -> stripStructId.stripId;
658 Int_t vId = v -> stripStructId.stripId;
666 TVector3 u0 =
getStripPtr ( uId-1, 0, uSectorId-1 ) -> end1;
667 TVector3 v0 =
getStripPtr ( vId-1, 1, vSectorId-1 ) -> end1;
670 TVector3 uF =
getStripPtr ( uId-1, 0, uSectorId-1 ) -> end2;
671 TVector3 vF =
getStripPtr ( vId-1, 1, vSectorId-1 ) -> end2;
674 TVector3 u0p=(u0-vertex);
675 TVector3 uFp=(uF-vertex);
676 TVector3 v0p=(v0-vertex);
677 TVector3 vFp=(vF-vertex);
684 TVector3 Nv = u0p.Cross(uFp);
687 Float_t Dv = (Nv.X()*vertex.X() + Nv.Y()*vertex.Y() + Nv.Z()*vertex.Z());
693 Float_t scale_numerv = (Nv.X()*v0.X() + Nv.Y()*v0.Y() + Nv.Z()*v0.Z() - Dv);
694 Float_t scale_denomv = (Nv.X()*(v0.X()-vF.X()) + Nv.Y()*(v0.Y()-vF.Y()) + Nv.Z()*(v0.Z()-vF.Z()));
695 Float_t scalev=scale_numerv/scale_denomv;
696 if (scalev < 0 || scalev > 1) {
697 TVector3 ErrorVector(1.,1.,-999.);
698 LOG_DEBUG<<GetName()<<
"::getIntersection( ) passed non-intersecting SMD strips " << *u <<
" " << *v << endm;
704 TVector3 Rv = (v0 + scalev*(vF-v0));
715 TVector3 Nu = v0p.Cross(vFp);
718 Float_t Du = (Nu.X()*vertex.X() + Nu.Y()*vertex.Y() + Nu.Z()*vertex.Z());
721 Float_t scale_numeru = (Nu.X()*u0.X() + Nu.Y()*u0.Y() + Nu.Z()*u0.Z() - Du);
722 Float_t scale_denomu = (Nu.X()*(u0.X()-uF.X()) + Nu.Y()*(u0.Y()-uF.Y()) + Nu.Z()*(u0.Z()-uF.Z()));
723 Float_t scaleu=scale_numeru/scale_denomu;
724 if (scaleu < 0 || scaleu > 1) {
725 TVector3 ErrorVector(1.,1.,-999.);
731 TVector3 Ru = (u0 + scaleu*(uF-u0));
735 TVector3 R = ((Rv+Ru)*0.5);
760 const Char_t *nameUV[]={
"U",
"V"};
761 TString stripname=
"";
762 if ( strip.stripStructId.sectorId < 10 ) stripname+=
"0"; stripname+=strip.stripStructId.sectorId;
763 stripname += nameUV[ strip.stripStructId.UVId-1 ];
764 if ( strip.stripStructId.stripId < 10 ) stripname+=
"0";
765 if ( strip.stripStructId.stripId < 100 ) stripname+=
"0";
766 stripname+=strip.stripStructId.stripId;
767 os << stripname <<
" depth=" << strip.stripStructId.planeId;
bool IsSectorIn(const Int_t iSec) const
return sector status
StructEEmcSmdSector mEEmcSector[kEEmcNumSmdUVs][kEEmcNumSectors]
general geometry variables
StructEEmcSmdParam & getEEmcSmdParam()
return SMD geometry parameters
int kEEmcSmdMap_iPlane[kEEmcNumSmdUVs][kEEmcNumSectors]
sector status.
Int_t getNStrips(Int_t iSec, Int_t iUV) const
Int_t getEEmcISec(const Int_t iPlane, const TVector3 &point) const
return index of a sector from a point in a plane
StructEEmcSmdSector & getEEmcSector(const Int_t iUV, const Int_t iSec)
return structure-sector from iUV and iSec
const StructEEmcStrip * getDcaStripPtr(const Int_t iPlane, const TVector3 &point, Float_t *dca) const
virtual ~EEmcSmdGeom()
default empty destructor
TVector3 getstripEnd(const StructEEmcStrip &strip, const Int_t endId) const
return strip-end of 3D-vector
bool mIsSectorIn[kEEmcNumSectors]
storage for all strip pointers
void printGeom(ostream &os=cout) const
printout global geometry parameters
void init()
Initialize geometry class.
StructEEmcStrip initStrip() const
instance and initialize a strip
void printSector(const StructEEmcSmdSector Sector, ostream &os=cout) const
printout sector-specific geometry parameters
EEmcStripPtrVec mStripPtrVector
storage for all strip pointers
EEmcSmdGeom()
defaulty constructor
bool matchStrips(const StructEEmcStripId &stripStructId1, const StructEEmcStripId &stripStructId2, Int_t nTolerance) const
match two strips
void buildStripPtrVector()
build mStripPtrVector
TVector3 getIntersection(Int_t iSec, Int_t iUStrip, Int_t iVStrip, const TVector3 &vertex) const
void setSectors(const intVec sectorIdVec)
set sectors for partial EEMC
void printStrip(const StructEEmcStrip Strip, ostream &os=cout) const
printout strip-specific geometry parameters
StructEEmcStrip * getStripPtr(const Int_t iStrip, const Int_t iUV, const Int_t iSec)
return a strip pointer from indices
const StructEEmcStrip * getDca2Strip(const Int_t iUV, const TVector3 &point, Float_t *dca) const
void printStripId(const StructEEmcStripId StripId, ostream &os=cout) const
printout stripStructId