18 #include "StTofrGeometry.h"
21 #include "TDataSetIter.h"
24 #include "StMessMgr.h"
49 Bool_t StTofrNode::mDebug = kFALSE;
50 Double_t
const StTofrGeomSensor::mSensorDy = 10.35;
52 const char*
const StTofrGeometry::trayPref =
"BTRA";
53 const char*
const StTofrGeometry::senPref =
"BRMD";
57 : fView(element), pView(element->GetPosition()), mMasterNode(top), mTransFlag(kFALSE)
64 StTofrNode::~StTofrNode()
73 void StTofrNode::UpdateMatrix()
83 CalcMatrix(
this, mTransMRS, mRotMRS);
90 Double_t* trans, Double_t* rot,
StTofrNode* mother)
123 Double_t xl[3], xm[3];
129 xl[0] = 0; xl[1] = 0; xl[2] = 0;
130 ConvertPos(son,xl, mother,xm);
135 xl[0] = 1; xl[1] = 0; xl[2] = 0;
136 ConvertPos(son,xl, mother,xm);
137 rot[0] = xm[0]-trans[0];
138 rot[1] = xm[1]-trans[1];
139 rot[2] = xm[2]-trans[2];
141 xl[0] = 0; xl[1] = 1; xl[2] = 0;
142 ConvertPos(son,xl, mother,xm);
143 rot[3] = xm[0]-trans[0];
144 rot[4] = xm[1]-trans[1];
145 rot[5] = xm[2]-trans[2];
147 xl[0] = 0; xl[1] = 0; xl[2] = 1;
148 ConvertPos(son,xl, mother,xm);
149 rot[6] = xm[0]-trans[0];
150 rot[7] = xm[1]-trans[1];
151 rot[8] = xm[2]-trans[2];
157 void StTofrNode::ConvertPos(
161 if (to==0) from->Local2Master(pos_from,pos_to);
164 from->Local2Master(pos_from,xg);
165 to->Master2Local(xg,pos_to);
172 void StTofrNode::BuildMembers()
180 TBRIK *brik =
dynamic_cast<TBRIK*
>(GetShape());
182 if(!brik) { LOG_INFO <<
" no brik " << endm;
return; }
184 Double_t dy = brik->GetDy();
185 Double_t dz = brik->GetDz();
200 xl[0] = 0; xl[1] = 0; xl[2] = -dz;
201 Local2Master(xl, xg);
205 xl[0] = 0; xl[1] = 0; xl[2] = dz;
206 Local2Master(xl, xg);
210 xl[0] = 0; xl[1] = -dy; xl[2] = 0;
211 Local2Master(xl, xg);
215 xl[0] = 0; xl[1] = dy; xl[2] = 0;
216 Local2Master(xl, xg);
219 if (mEtaMin>mEtaMax) {
220 Double_t tmp = mEtaMin;
225 if (mPhiMin>mPhiMax) {
226 Double_t tmp = mPhiMin;
235 void StTofrNode::Local2Master(
const Double_t* local, Double_t* master)
242 if (!mMasterNode) { LOG_INFO <<
" no Master! " << endm;
return;}
259 master[0] = mTransMRS[0] + mRotMRS[0]*x + mRotMRS[3]*y + mRotMRS[6]*z;
260 master[1] = mTransMRS[1] + mRotMRS[1]*x + mRotMRS[4]*y + mRotMRS[7]*z;
261 master[2] = mTransMRS[2] + mRotMRS[2]*x + mRotMRS[5]*y + mRotMRS[8]*z;
266 void StTofrNode::Master2Local(
const Double_t* master, Double_t* local)
274 LOG_INFO <<
" and No TVolumePosition::Master2Local is wrong, so do nothing" << endm;
280 x = master[0] - mTransMRS[0];
281 y = master[1] - mTransMRS[1];
282 z = master[2] - mTransMRS[2];
284 local[0] = mRotMRS[0]*x + mRotMRS[1]*y + mRotMRS[2]*z;
285 local[1] = mRotMRS[3]*x + mRotMRS[4]*y + mRotMRS[5]*z;
286 local[2] = mRotMRS[6]*x + mRotMRS[7]*y + mRotMRS[8]*z;
297 Double_t ux[3], nx[3];
299 ux[0] = 1; ux[1] = 0; ux[2] = 0;
302 nx[0] -= mTransMRS[0];
303 nx[1] -= mTransMRS[1];
304 nx[2] -= mTransMRS[2];
318 xg[0] = mTransMRS[0];
319 xg[1] = mTransMRS[1];
320 xg[2] = mTransMRS[2];
326 Bool_t StTofrNode::IsLocalPointIn(
const Double_t x,
const Double_t y,
329 TBRIK *brik =
dynamic_cast<TBRIK*
> (GetShape());
330 Double_t dx = brik->GetDx();
331 Double_t dy = brik->GetDy();
332 Double_t dz = brik->GetDz();
333 Bool_t ret = -dx<x && x<dx && -dy<y && y<dy && -dz<z && z<dz;
341 Double_t xl[3], xg[3];
345 Master2Local(xg, xl);
346 Bool_t ret = IsLocalPointIn(xl[0], xl[1], xl[2]);
352 Bool_t StTofrNode::HelixCross(
const StHelixD &helix, Double_t &pathLen,
360 Float_t MaxPathLength = 1000.;
378 pathLen = helix.
pathLength(centerPos,planeNormal);
379 if ( pathLen>0 && pathLen<MaxPathLength ) {
380 cross = helix.at(pathLen);
384 ret = IsGlobalPointIn(cross);
390 void StTofrNode::Print(Option_t *opt)
const
392 TBRIK *brik =
dynamic_cast<TBRIK*
> (GetShape());
393 LOG_INFO <<
"Name=" << GetName() <<
"\t TBRIK-dimension=" << brik->GetDx()
394 <<
" : " << brik->GetDy() <<
" : " << brik->GetDz()
397 <<
"\n EtaRange=" << mEtaMin <<
" : " << mEtaMax
398 <<
"\t PhiRange=" << mPhiMin <<
" : " << mPhiMax
400 LOG_INFO <<
"trans[0-2]=" << mTransMRS[0] <<
" " <<mTransMRS[1]
402 <<
"\nmRotMRS[0-2]=" <<mRotMRS[0] <<
" " <<mRotMRS[1] <<
" " <<mRotMRS[2]
403 <<
"\nmRotMRS[3-5]=" <<mRotMRS[3] <<
" " <<mRotMRS[4] <<
" " <<mRotMRS[5]
404 <<
"\nmRotMRS[6-8]=" <<mRotMRS[6] <<
" " <<mRotMRS[7] <<
" " <<mRotMRS[8]
427 Bool_t StTofrGeomNode::mDebug = kFALSE;
434 StTofrGeomNode::StTofrGeomNode(
const char* name,
const char* title,
435 TBRIK* brik,
const Double_t x,
const Double_t y,
const Double_t z,
437 : TNode(name, title, brik, x, y, z, matrix), mTransFlag(kFALSE)
444 StTofrGeomNode::~StTofrGeomNode()
449 void StTofrGeomNode::UpdateMatrix()
459 CalcMatrix(
this, mTransMRS, mRotMRS);
464 void StTofrGeomNode::CalcMatrix(TNode* son,
465 Double_t* trans, Double_t* rot, StTofrGeomNode* mother)
497 Double_t xl[3], xm[3];
499 son->TNode::UpdateMatrix();
501 xl[0] = 0; xl[1] = 0; xl[2] = 0;
502 ConvertPos(son,xl, mother,xm);
507 xl[0] = 1; xl[1] = 0; xl[2] = 0;
508 ConvertPos(son,xl, mother,xm);
509 rot[0] = xm[0]-trans[0];
510 rot[1] = xm[1]-trans[1];
511 rot[2] = xm[2]-trans[2];
513 xl[0] = 0; xl[1] = 1; xl[2] = 0;
514 ConvertPos(son,xl, mother,xm);
515 rot[3] = xm[0]-trans[0];
516 rot[4] = xm[1]-trans[1];
517 rot[5] = xm[2]-trans[2];
519 xl[0] = 0; xl[1] = 0; xl[2] = 1;
520 ConvertPos(son,xl, mother,xm);
521 rot[6] = xm[0]-trans[0];
522 rot[7] = xm[1]-trans[1];
523 rot[8] = xm[2]-trans[2];
529 void StTofrGeomNode::ConvertPos(
530 TNode* from,
const Double_t* pos_from,
531 StTofrGeomNode* to, Double_t* pos_to)
538 if (to==0) from->Local2Master(pos_from,pos_to);
541 from->Local2Master(pos_from,xg);
542 to->Master2Local(xg,pos_to);
549 void StTofrGeomNode::BuildMembers()
557 TBRIK *brik =
dynamic_cast<TBRIK*
> (GetShape());
559 Double_t dy = brik->GetDy();
560 Double_t dz = brik->GetDz();
574 xl[0] = 0; xl[1] = 0; xl[2] = -dz;
575 Local2Master(xl, xg);
579 xl[0] = 0; xl[1] = 0; xl[2] = dz;
580 Local2Master(xl, xg);
584 xl[0] = 0; xl[1] = -dy; xl[2] = 0;
585 Local2Master(xl, xg);
589 xl[0] = 0; xl[1] = dy; xl[2] = 0;
590 Local2Master(xl, xg);
593 if (mEtaMin>mEtaMax) {
594 Double_t tmp = mEtaMin;
599 if (mPhiMin>mPhiMax) {
600 Double_t tmp = mPhiMin;
608 void StTofrGeomNode::Local2Master(
const Double_t* local, Double_t* master)
616 TNode::Local2Master(local,master);
626 master[0] = mTransMRS[0] + mRotMRS[0]*x + mRotMRS[3]*y + mRotMRS[6]*z;
627 master[1] = mTransMRS[1] + mRotMRS[1]*x + mRotMRS[4]*y + mRotMRS[7]*z;
628 master[2] = mTransMRS[2] + mRotMRS[2]*x + mRotMRS[5]*y + mRotMRS[8]*z;
633 void StTofrGeomNode::Master2Local(
const Double_t* master, Double_t* local)
641 LOG_INFO <<
"Warning in StTofrGeomNode::Master2Local\n"
642 <<
" StTofrGeomNode::UpdateMatrix not yet invoked\n"
643 <<
" and TNode::Master2Local is wrong, so do nothing" << endm;
649 x = master[0] - mTransMRS[0];
650 y = master[1] - mTransMRS[1];
651 z = master[2] - mTransMRS[2];
653 local[0] = mRotMRS[0]*x + mRotMRS[1]*y + mRotMRS[2]*z;
654 local[1] = mRotMRS[3]*x + mRotMRS[4]*y + mRotMRS[5]*z;
655 local[2] = mRotMRS[6]*x + mRotMRS[7]*y + mRotMRS[8]*z;
667 Double_t ux[3], nx[3];
669 ux[0] = 1; ux[1] = 0; ux[2] = 0;
672 nx[0] -= mTransMRS[0];
673 nx[1] -= mTransMRS[1];
674 nx[2] -= mTransMRS[2];
688 xg[0] = mTransMRS[0];
689 xg[1] = mTransMRS[1];
690 xg[2] = mTransMRS[2];
696 Bool_t StTofrGeomNode::IsLocalPointIn(
const Double_t x,
const Double_t y,
700 TBRIK *brik =
dynamic_cast<TBRIK*
> (GetShape());
701 Double_t dx = brik->GetDx();
702 Double_t dy = brik->GetDy();
703 Double_t dz = brik->GetDz();
704 Bool_t ret = -dx<x && x<dx && -dy<y && y<dy && -dz<z && z<dz;
710 Bool_t StTofrGeomNode::IsGlobalPointIn(
const StThreeVectorD &global)
712 Double_t xl[3], xg[3];
716 Master2Local(xg, xl);
717 Bool_t ret = IsLocalPointIn(xl[0], xl[1], xl[2]);
723 Bool_t StTofrGeomNode::HelixCross(
const StHelixD &helix, Double_t &pathLen,
731 static const Float_t MaxPathLength = 1000.;
749 pathLen = helix.
pathLength(centerPos,planeNormal);
750 if ( pathLen>0 && pathLen<MaxPathLength ) {
751 cross = helix.at(pathLen);
755 ret = IsGlobalPointIn(cross);
762 void StTofrGeomNode::Print(Option_t *opt)
const
765 TBRIK *brik =
dynamic_cast<TBRIK*
> (GetShape());
766 LOG_INFO <<
"Name=" << GetName() <<
"\t TBRIK-dimension=" << brik->GetDx()
767 <<
" : " << brik->GetDy() <<
" : " << brik->GetDz()
770 <<
"\n EtaRange=" << mEtaMin <<
" : " << mEtaMax
771 <<
"\t PhiRange=" << mPhiMin <<
" : " << mPhiMax
773 LOG_INFO <<
"trans[0-2]=" << mTransMRS[0] <<
" " <<mTransMRS[1]
775 <<
"\nmRotMRS[0-2]=" <<mRotMRS[0] <<
" " <<mRotMRS[1] <<
" " <<mRotMRS[2]
776 <<
"\nmRotMRS[3-5]=" <<mRotMRS[3] <<
" " <<mRotMRS[4] <<
" " <<mRotMRS[5]
777 <<
"\nmRotMRS[6-8]=" <<mRotMRS[6] <<
" " <<mRotMRS[7] <<
" " <<mRotMRS[8]
791 Bool_t StTofrGeomTray::mDebug = kFALSE;
797 mSectorsInBTOH = top->GetListSize()/2;
798 mBTOHIndex = ibtoh + 1;
799 mTrayIndex = ibtoh * mSectorsInBTOH + sector->GetPosition()->GetId();
803 StTofrGeomTray::~StTofrGeomTray()
939 if ( !(volume->GetListSize()) ) {
940 LOG_INFO <<
" No Modules in this tray " << endm;
949 while ( (sensorVolume = (
TVolumeView *)nextSensor()) )
951 if ( sensorVolume && (
int)(sensorVolume->GetPosition()->GetId()) == imodule ) {
960 void StTofrGeomTray::Print(
const Option_t *opt)
const
962 LOG_INFO <<
"StTofrGeomTray, tray#=" << mTrayIndex << endm;
963 StTofrNode::Print(opt);
975 Bool_t StTofrGeomSensor::mDebug = kFALSE;
981 mModuleIndex = element->GetPosition()->GetId();
986 StTofrGeomSensor::~StTofrGeomSensor()
1019 Double_t sensor_dy = mSensorDy;
1020 Double_t cell_width = 2*sensor_dy/mCells;
1022 for (
int i=0; i<=mCells; i++) mCellY[i] = cell_width*i - sensor_dy;
1027 Double_t StTofrGeomSensor::GetCellYMin(
const Int_t icell)
1031 if (icell<=0 || icell>mCells) {
1032 LOG_INFO <<
"cell#=" << icell <<
" is out range=[0," << mCells <<
"]"
1034 }
else ret = mCellY[icell-1];
1040 Double_t StTofrGeomSensor::GetCellYMax(
const Int_t icell)
1044 if (icell<=0 || icell>mCells) {
1045 LOG_INFO <<
"cell#=" << icell <<
" is out range=[0," << mCells <<
"]"
1047 }
else ret = mCellY[icell];
1053 StThreeVectorD StTofrGeomSensor::GetCellPosition(
const Int_t icell)
1059 static const char* where =
"StTofrGeomSensor::GetCellPosition";
1066 Double_t sensor_dy = mSensorDy;
1067 Double_t cell_dy = 2*sensor_dy/mCells;
1069 Double_t xl[3], xg[3];
1070 if (icell>=1 && icell<=mCells) {
1072 xl[1] = (icell*2-1)*cell_dy - sensor_dy;
1074 Local2Master(xl,xg);
1076 LOG_INFO <<
"Warning in " << where <<
" Invalid cell# =" << icell << endm;
1087 Int_t StTofrGeomSensor::FindCellIndex(
const Double_t* local)
1094 if ( IsLocalPointIn(local[0],local[1],local[2]) ) {
1096 for (Int_t i=0; i<mCells; i++) {
1097 if (mCellY[i]<= local[1] && local[1]<=mCellY[i+1]) {
1109 void StTofrGeomSensor::Print(
const Option_t *opt)
const
1111 LOG_INFO <<
"StTofrGeomSensor, module#=" << mModuleIndex << endm;
1112 StTofrNode::Print(opt);
1114 LOG_INFO <<
" Cells=" << mCells <<
"\t Y range for cells=\n";
1115 for (Int_t i=0; i<=mCells; i++) LOG_INFO <<
" : " << mCellY[i];
1128 static const Int_t CELLSINMODULE = 6;
1131 Bool_t StTofrGeometry::mDebug = kFALSE;
1134 StTofrGeometry::StTofrGeometry(
const char* name,
const char* title)
1135 : TNamed(name,title)
1137 mCellsInModule = StTofrGeomSensor::GetCells();
1145 for(
int i=0;i<mNTrays;i++) {
1147 for(
int j=0;j<mNModules;j++) {
1148 mTofrSensor[i][j] = 0;
1155 if (gTofrGeometry) {
1156 LOG_INFO <<
"Warning !! There is already StTofrGeometry at pointer="
1157 << (
void*)gTofrGeometry <<
", so it is deleted"
1159 delete gTofrGeometry;
1161 gTofrGeometry =
this;
1165 StTofrGeometry::~StTofrGeometry()
1167 LOG_INFO <<
"Warning !! StTofrGeometry at pointer =" << (
void*)gTofrGeometry
1168 <<
" is deleted" << endm;
1171 for(
int i=0;i<mNTrays;i++) {
1172 if(mTofrTray[i])
delete mTofrTray[i];
1174 for(
int j=0;j<mNModules;j++) {
1175 if(mTofrSensor[i][j])
delete mTofrSensor[i][j];
1176 mTofrSensor[i][j] = 0;
1185 void StTofrGeometry::Init(
TVolume *starHall)
1193 InitFromStar(starHall);
1194 mStarHall = starHall;
1235 void StTofrGeometry::InitFromStar(
TVolume *starHall)
1255 TVolume *starDetectorElement = 0;
1256 while ( (starDetectorElement = (
TVolume *)volume()) )
1260 Bool_t found = ( IsBSEC(starDetectorElement) || IsBTRA(starDetectorElement) || IsBRMD(starDetectorElement) );
1264 starDetectorElement->Mark();
1265 if (starDetectorElement->GetLineColor()==1 || starDetectorElement->GetLineColor()==7)
1266 starDetectorElement->SetLineColor(14);
1270 starDetectorElement->UnMark();
1271 starDetectorElement->
SetVisibility(TVolume::kThisUnvisible);
1288 while ( (secVolume = (
TVolumeView *)nextSector()) ) {
1290 if ( trayVolume->GetListSize() ) {
1292 mModulesInTray = trayVolume->GetListSize();
1296 if (mTrays==120) mTofrConf = 1;
1302 gMessMgr->Info(
"",
"OS") <<
" # of trays = " << mTopNode->GetListSize() << endm;
1303 TList *list = mTopNode->Nodes();
1308 for(Int_t i=0;i<list->GetSize();i++) {
1309 sectorVolume =
dynamic_cast<TVolumeView*
> (list->At(i));
1311 if( !trayVolume->GetListSize() )
continue;
1312 if ( i>=60 ) ibtoh = 1;
1314 mTofrTray[mNValidTrays] =
new StTofrGeomTray(ibtoh, sectorVolume, mTopNode);
1315 TList *list1 = trayVolume->Nodes();
1317 if (!list1 )
continue;
1319 if(list1->GetSize()>mNValidModules) mNValidModules=list1->GetSize();
1320 for(Int_t j=0;j<list1->GetSize();j++) {
1321 sensorVolume =
dynamic_cast<TVolumeView*
> (list1->At(j));
1322 mTofrSensor[mNValidTrays][j] =
new StTofrGeomSensor(sensorVolume, mTopNode);
1326 gMessMgr->Info(
"",
"OS") <<
"\n-------------------------------------------\n"
1327 <<
" Summary of initialization: "
1328 <<
" NValidTrays = " << mNValidTrays <<
" NValidModules = " << mNValidModules << endm;
1355 Bool_t StTofrGeometry::ContainOthers(
TVolume *element)
1358 TList *list = elementView->GetListOfShapes();
1360 LOG_INFO <<
" yes list in " << element->GetName() << endm;
1363 LOG_INFO <<
" no list in " << element->GetName() << endm;
1548 Bool_t StTofrGeometry::LackThis(
const char* fromWhere)
1550 if (gTofrGeometry == 0) {
1551 LOG_INFO <<
" !! Warning from " << fromWhere
1552 <<
"\n no StTofrGeometry existing, create one instance first"
1555 }
else return kFALSE;
1567 Int_t StTofrGeometry::CalcCellId(
const Int_t volumeId,
const Float_t* local)
1571 dlocal[0] = local[0];
1572 dlocal[1] = local[1];
1573 dlocal[2] = local[2];
1574 return CalcCellId(volumeId,dlocal);
1578 Int_t StTofrGeometry::CalcCellId(
const Int_t volumeId,
const Double_t* local)
1585 Int_t icell, imodule, itray;
1586 DecodeVolumeId(volumeId, imodule, itray);
1588 if (!sensor)
return -1;
1589 icell = sensor->FindCellIndex(local);
1590 Int_t ret = CalcCellId(icell, imodule, itray);
1596 Bool_t StTofrGeometry::IsCellValid(
const Int_t icell)
1602 return (icell>=1 && icell<=mCellsInModule);
1606 Bool_t StTofrGeometry::IsSensorValid(
const Int_t imodule)
1612 return (imodule>=1 && imodule<=mModulesInTray);
1616 Bool_t StTofrGeometry::IsTrayValid(
const Int_t itray)
1624 Bool_t ret = kFALSE;
1628 Int_t ibtoh = 0, i = 0;
1630 while ( (sectorVolume = (
TVolumeView *)nextSector()) ) {
1633 int trayIndex = ibtoh *
mSectorsInBTOH + sectorVolume->GetPosition()->GetId();
1636 if (trayIndex == itray) {
1660 Int_t StTofrGeometry::CalcSensorId(
const Int_t imodule,
const Int_t itray)
1667 Int_t sensorId = -1;
1668 if (!IsSensorValid(imodule))
return sensorId;
1670 Int_t idx = GetAtOfTray(itray);
1672 if (idx<0)
return sensorId;
1674 sensorId = imodule-1 + mModulesInTray*idx;
1680 Int_t StTofrGeometry::PrevCellId(
const Int_t cellId)
1689 Int_t icell, imodule, itray;
1690 DecodeCellId(cellId,icell,imodule,itray);
1692 Int_t icell_p = sensor->PrevCellIndex(icell);
1694 found = CalcCellId(icell_p,imodule,itray);
1700 Int_t StTofrGeometry::NextCellId(
const Int_t cellId)
1709 Int_t icell, imodule, itray;
1710 DecodeCellId(cellId,icell,imodule,itray);
1712 Int_t icell_p = sensor->NextCellIndex(icell);
1714 found = CalcCellId(icell_p,imodule,itray);
1720 Int_t StTofrGeometry::CalcCellId(
const Int_t icell,
const Int_t imodule,
1729 if (!IsCellValid(icell))
return cellId;
1731 Int_t sensorId = CalcSensorId(imodule,itray);
1732 if (sensorId<0)
return cellId;
1734 cellId = icell-1 + mCellsInModule*sensorId;
1740 Bool_t StTofrGeometry::DecodeSensorId(
const Int_t sensorId,
1741 Int_t &imodule, Int_t &itray)
1748 imodule = sensorId%mModulesInTray + 1;
1749 if (!IsSensorValid(imodule))
return kFALSE;
1751 Int_t idx = sensorId/mModulesInTray;
1753 if (!tray)
return kFALSE;
1754 itray = tray->Index();
1760 Bool_t StTofrGeometry::DecodeCellId(
const Int_t cellId, Int_t &icell,
1761 Int_t &imodule, Int_t &itray)
1768 Int_t sensorId = cellId/mCellsInModule;
1769 if (!DecodeSensorId(sensorId,imodule,itray))
return kFALSE;
1771 icell = cellId%mCellsInModule + 1;
1773 return IsCellValid(icell);
1777 Int_t StTofrGeometry::GetCellIndex(
const Int_t cellId)
1784 Int_t icell = cellId%mCellsInModule + 1;
1790 void StTofrGeometry::DecodeVolumeId(
const Int_t volumeId,
1791 Int_t &imodule, Int_t &itray)
1799 Int_t ires = volumeId;
1801 Int_t rileft = int(ires/10/100/100);
1802 ires = ires-rileft*100*100*10;
1804 itray = int(ires/10/100);
1805 ires = ires-itray*100*10;
1807 imodule = int(ires/10);
1823 Int_t icell, imodule, itray;
1824 DecodeCellId(cellId, icell, imodule, itray);
1841 if (tray) sensor = tray->GetSensor(imodule);
1858 Int_t ibtoh = 0, i = 0;
1859 while ( (sectorVolume = (
TVolumeView *)nextSector()) ) {
1862 int trayIndex = ibtoh *
mSectorsInBTOH + sectorVolume->GetPosition()->GetId();
1865 if (trayIndex == itray) {
1914 Int_t ibtoh = 0, i = 0;
1915 while ( (sectorVolume = (
TVolumeView *)nextSector()) ) {
1939 Int_t StTofrGeometry::GetAtOfTray(
const Int_t itray)
1954 Int_t ibtoh = 0, i = 0;
1955 while ( (sectorVolume = (
TVolumeView *)nextSector()) ) {
1958 int trayIndex = ibtoh *
mSectorsInBTOH + sectorVolume->GetPosition()->GetId();
1961 if (trayIndex == itray) {
1995 void StTofrGeometry::Print(Option_t *opt)
const
1997 LOG_INFO <<
"Trays=" << mTrays <<
"\t ModulesInTray=" << mModulesInTray
1998 <<
"\t CellsInModule=" << mCellsInModule << endm;
2010 Double_t xl[3], xg[3];
2018 Int_t itray = -1, imodule = -1, icell = -1;
2019 for(
int i=0;i<mNValidTrays;i++) {
2020 if(!mTofrTray[i])
continue;
2021 if ( mTofrTray[i]->IsGlobalPointIn(point) ) {
2022 itray = mTofrTray[i]->Index();
2023 if ( !(mTofrTray[i]->GetfView()->GetListSize()) ) {
2024 LOG_INFO <<
" No sensors in tray " << itray << endm;
2028 for(
int j=0;j<mNValidModules;j++) {
2029 if(!mTofrSensor[i][j])
continue;
2030 if ( mTofrSensor[i][j]->IsGlobalPointIn(point) ) {
2031 imodule = mTofrSensor[i][j]->Index();
2032 mTofrSensor[i][j]->Master2Local(xg,xl);
2033 icell = mTofrSensor[i][j]->FindCellIndex(xl);
2076 if ( itray <= 0 || imodule <= 0 )
return cellId;
2077 cellId = CalcCellId(icell, imodule, itray);
2119 Bool_t StTofrGeometry::HelixCross(
const StHelixD &helix)
2130 Bool_t crossed = HelixCrossCellIds(helix,idVec,pathVec,crossVec);
2136 Bool_t StTofrGeometry::HelixCrossCellIds(
const StHelixD &helix,
2137 IntVec &idVec, DoubleVec &pathVec, PointVec &crossVec)
2153 for(
int i=0;i<mNValidTrays;i++) {
2154 if(!mTofrTray[i])
continue;
2155 int trayId = mTofrTray[i]->Index();
2157 for(
int j=0;j<mNValidModules;j++) {
2158 if(!mTofrSensor[i][j])
continue;
2159 int moduleId = mTofrSensor[i][j]->Index();
2160 if ( mTofrSensor[i][j]->HelixCross(helix,pathLen,cross) ) {
2161 Double_t global[3], local[3];
2162 global[0] = cross.x();
2163 global[1] = cross.y();
2164 global[2] = cross.z();
2165 mTofrSensor[i][j]->Master2Local(global,local);
2166 Int_t icell = mTofrSensor[i][j]->FindCellIndex(local);
2167 cellId = CalcCellId(icell, moduleId, trayId);
2169 pathVec.push_back(pathLen);
2170 idVec.push_back(cellId);
2171 crossVec.push_back(cross);
2286 if (idVec.size()>0) {
2298 Bool_t StTofrGeometry::HelixCross(
const StHelixD &helix, IntVec validModuleVec, IntVec projTrayVec)
2309 Bool_t crossed = HelixCrossCellIds(helix,validModuleVec, projTrayVec, idVec,pathVec,crossVec);
2316 Bool_t StTofrGeometry::HelixCrossCellIds(
const StHelixD &helix, IntVec validModuleVec, IntVec projTrayVec, IntVec &idVec, DoubleVec &pathVec, PointVec &crossVec)
2331 if(validModuleVec.size()==0)
return kFALSE;
2332 if(projTrayVec.size()==0)
return kFALSE;
2341 for(
int i=0;i<mNValidTrays;i++) {
2342 if(!mTofrTray[i])
continue;
2343 int trayId = mTofrTray[i]->Index();
2344 bool itrayFind = kFALSE;
2346 for(
size_t it=0;it<projTrayVec.size();it++) {
2347 int validtrayId = projTrayVec[it];
2348 if(validtrayId==trayId) {
2353 if(!itrayFind)
continue;
2357 for(
int j=0;j<mNValidModules;j++) {
2358 if(!mTofrSensor[i][j])
continue;
2359 int moduleId = mTofrSensor[i][j]->Index();
2360 for(
size_t iv=0;iv<validModuleVec.size();iv++) {
2361 int validtrayId = validModuleVec[iv]/100;
2362 int validmoduleId = validModuleVec[iv]%100;
2363 if(validtrayId==trayId&&validmoduleId==moduleId) {
2364 if ( mTofrSensor[i][j]->HelixCross(helix,pathLen,cross) ) {
2365 Double_t global[3], local[3];
2366 global[0] = cross.x();
2367 global[1] = cross.y();
2368 global[2] = cross.z();
2369 mTofrSensor[i][j]->Master2Local(global,local);
2370 Int_t icell = mTofrSensor[i][j]->FindCellIndex(local);
2371 cellId = CalcCellId(icell, moduleId, trayId);
2373 pathVec.push_back(pathLen);
2374 idVec.push_back(cellId);
2375 crossVec.push_back(cross);
2491 if (idVec.size()>0) {
2503 Bool_t StTofrGeometry::projTrayVector(
const StHelixD &helix, IntVec &trayVec)
const {
2506 double R_tof = 215.;
2509 if(s1<0.) s1 = helix.
pathLength(R_tof).second;
2511 double phi = point.phi()*180/3.14159;
2514 int itray_east = (255+(int)phi)%360/6+61;
2515 trayVec.push_back(itray_east);
2517 int itray_east1 = (255+(int)(phi+res))%360/6+61;
2518 int itray_east2 = (255+(int)(phi-res))%360/6+61;
2519 if(itray_east1!=itray_east) {
2520 trayVec.push_back(itray_east1);
2522 if(itray_east2!=itray_east&&itray_east2!=itray_east1) {
2523 trayVec.push_back(itray_east2);
2527 int itray_west = (435-(int)phi)%360/6+1;
2528 trayVec.push_back(itray_west);
2530 int itray_west1 = (435-(int)(phi+res))%360/6+1;
2531 int itray_west2 = (435-(int)(phi-res))%360/6+1;
2532 if(itray_west1!=itray_west) {
2533 trayVec.push_back(itray_west1);
2535 if(itray_west2!=itray_west&&itray_west2!=itray_west1) {
2536 trayVec.push_back(itray_west2);
2545 if(trayVec.size()>0)
return kTRUE;
virtual TDataSet * First() const
Return the first object in the list. Returns 0 when list is empty.
static const char *const sectorPref
Control message printing of this class.
StTofrGeomTray(const Int_t ibtoh, TVolumeView *sector, TVolumeView *top)
Control message printing of this class.
void CreateGeomCells()
Control message printing of this class.
virtual void SetVisibility(ENodeSEEN vis=TVolume::kBothVisible)
virtual TVolumePosition * Local2Master(const TVolumeView *localNode, const TVolumeView *masterNode=0)
to be documented
virtual Double_t * Local2Master(const Double_t *local, Double_t *master, Int_t nPoints=1) const
pair< double, double > pathLength(double r) const
path length at given r (cylindrical r)
Int_t mSectorsInBTOH
the root file of geometry
StTofrNode(TVolumeView *element, TVolumeView *top)
Control message printing of this class.