105 TGeoIterator geoIterator(gGeoManager->GetTopNode()->GetVolume());
106 geoIterator.SetTopName(
"/cave_1");
109 vector<Double_t> xCoord;
111 while ((curNode = geoIterator())) {
112 TString nodeName(curNode->GetName());
115 if (curNode->GetVolume()->GetName() == TString(
"camera_strip")) {
116 geoIterator.GetPath(nodePath);
118 const TGeoMatrix* curMatrix = geoIterator.GetCurrentMatrix();
119 const Double_t* curNodeTr = curMatrix->GetTranslation();
120 const Double_t* curNodeRot = curMatrix->GetRotationMatrix();
124 double pmtX = curNodeTr[0];
125 double pmtY = curNodeTr[1];
126 double pmtZ = curNodeTr[2];
128 double rotY = TMath::ASin(-curNodeRot[2]);
131 double rotX = TMath::ACos(curNodeRot[8] / TMath::Cos(TMath::ASin(-curNodeRot[2])));
138 string nodePathStr = string(nodePath.Data()) +
"/";
142 const TGeoBBox*
shape = (
const TGeoBBox*) (curNode->GetVolume()->GetShape());
150 if (pmtX >= 0 && pmtY >= 0) { xCoord.push_back(pmtX); }
153 std::sort(xCoord.begin(), xCoord.end());
155 for (map<string, CbmRichRecGeoParPmt>::iterator it =
fGP->
fPmtMap.begin(); it !=
fGP->
fPmtMap.end(); it++) {
156 Double_t curX = TMath::Abs(it->second.fX);
159 for (
unsigned int i = 0; i < xCoord.size(); i++) {
160 if (TMath::Abs(curX - xCoord[i]) < 0.1) {
165 it->second.fPmtPositionIndexX =
pos;
169 map<string, CbmRichPmtPlaneMinMax> mapPmtPlaneMinMax;
170 TString filterNamePixel(
"pmt_pixel");
174 while ((curNode = geoIterator())) {
175 TString nodeName(curNode->GetName());
177 if (curNode->GetVolume()->GetName() == filterNamePixel) {
179 geoIterator.GetPath(nodePath);
182 string nodePathStr = string(nodePath.Data());
184 size_t foundIndex1 = nodePathStr.find(
"camera_strip");
186 if (foundIndex1 == string::npos)
continue;
187 size_t foundIndex2 = nodePathStr.find(
"/", foundIndex1 + 1);
188 if (foundIndex2 == string::npos)
continue;
190 string mapKey = nodePathStr.substr(0, foundIndex2) +
"/";
192 const TGeoMatrix* curMatrix = geoIterator.GetCurrentMatrix();
193 const Double_t* curNodeTr = curMatrix->GetTranslation();
195 double pmtX = curNodeTr[0];
196 double pmtY = curNodeTr[1];
197 double pmtZ = curNodeTr[2];
199 mapPmtPlaneMinMax[mapKey].AddPoint(pmtX, pmtY, pmtZ);
203 for (map<string, CbmRichRecGeoParPmt>::iterator it =
fGP->
fPmtMap.begin(); it !=
fGP->
fPmtMap.end(); it++) {
204 it->second.fPlaneX = mapPmtPlaneMinMax[it->first].GetMeanX();
205 it->second.fPlaneY = mapPmtPlaneMinMax[it->first].GetMeanY();
206 it->second.fPlaneZ = mapPmtPlaneMinMax[it->first].GetMeanZ();
215 double master1[3], master2[3];
216 while ((curNode = geoIterator())) {
217 TString nodeName(curNode->GetName());
219 if (curNode->GetVolume()->GetName() == TString(
"camera_strip")) {
221 geoIterator.GetPath(nodePath);
222 string nodePathStr = string(nodePath.Data()) +
"/";
223 const TGeoMatrix* curMatrix = geoIterator.GetCurrentMatrix();
224 const Double_t* curNodeTr = curMatrix->GetTranslation();
227 double pmtX = curNodeTr[0];
228 double pmtY = curNodeTr[1];
231 if (pmtX < 0 || pmtY < 0)
continue;
232 const TGeoBBox*
shape = (
const TGeoBBox*) (curNode->GetVolume()->GetShape());
236 if (
fGP->
fPmtMap[nodePathStr].fPmtPositionIndexX == 1) {
237 loc[0] =
shape->GetDX() +
shape->GetOrigin()[0];
238 loc[1] =
shape->GetDY() +
shape->GetOrigin()[1];
239 loc[2] =
shape->GetDZ() +
shape->GetOrigin()[2];
240 curMatrix->LocalToMaster(loc, master1);
242 else if (
fGP->
fPmtMap[nodePathStr].fPmtPositionIndexX == 2) {
243 loc[0] = -
shape->GetDX() +
shape->GetOrigin()[0];
244 loc[1] =
shape->GetDY() +
shape->GetOrigin()[1];
245 loc[2] =
shape->GetDZ() +
shape->GetOrigin()[2];
246 curMatrix->LocalToMaster(loc, master2);
252 double dist = TMath::Sqrt((master1[0] - master2[0]) * (master1[0] - master2[0])
253 + (master1[1] - master2[1]) * (master1[1] - master2[1])
254 + (master1[2] - master2[2]) * (master1[2] - master2[2]));
261 TGeoIterator geoIterator(gGeoManager->GetTopNode()->GetVolume());
265 TString filterName_pixel(
"pmt_pixel");
268 while ((curNode = geoIterator())) {
269 TString nodeName(curNode->GetName());
271 if (curNode->GetVolume()->GetName() == filterName_pixel) {
273 geoIterator.GetPath(nodePath);
274 const TGeoMatrix* curMatrix = geoIterator.GetCurrentMatrix();
275 const Double_t* curNodeTr = curMatrix->GetTranslation();
276 const Double_t* curNodeRot = curMatrix->GetRotationMatrix();
278 double pmtX = curNodeTr[0];
279 double pmtY = curNodeTr[1];
280 double pmtZ = curNodeTr[2];
282 if (pmtX > 0. && pmtY > 0) {
284 double rotY = TMath::ASin(-curNodeRot[2]);
287 double rotX = TMath::ACos(curNodeRot[8] / TMath::Cos(TMath::ASin(-curNodeRot[2])));
292 pmtPlaneMinMax.
AddPoint(pmtX, pmtY, pmtZ);
302 while ((curNode = geoIterator())) {
303 TString nodeName(curNode->GetName());
305 if (curNode->GetVolume()->GetName() == TString(
"camera_quarter")) {
307 geoIterator.GetPath(nodePath);
308 const TGeoMatrix* curMatrix = geoIterator.GetCurrentMatrix();
309 const Double_t* curNodeTr = curMatrix->GetTranslation();
313 double pmtX = curNodeTr[0];
314 double pmtY = curNodeTr[1];
315 double pmtZ = curNodeTr[2];
317 if (pmtX > 0. && pmtY > 0) {
318 const TGeoBBox*
shape = (
const TGeoBBox*) (curNode->GetVolume()->GetShape());
332 TGeoIterator geoIterator(gGeoManager->GetTopNode()->GetVolume());
337 TString mirrorName0(
"mirror_tile_type0");
338 TString mirrorName1(
"mirror_tile_type1");
339 TString mirrorName2(
"mirror_tile_type2");
340 TString mirrorName3(
"mirror_tile_type3");
345 TString mirrorMisAlignName0(
"mirror_tile_0");
346 TString mirrorMisAlignName1(
"mirror_tile_1");
347 TString mirrorMisAlignName2(
"mirror_tile_2");
348 TString mirrorMisAlignName3(
"mirror_tile_3");
349 TString mirrorMisAlignName4(
"mirror_tile_4");
350 TString mirrorMisAlignName5(
"mirror_tile_5");
351 TString mirrorMisAlignName6(
"mirror_tile_6");
352 TString mirrorMisAlignName7(
"mirror_tile_7");
355 double maxTheta = 0.;
356 double minTheta = 999999999.;
360 double mirrorRadius = 0.;
361 while ((curNode = geoIterator())) {
362 TString nodeName(curNode->GetName());
365 if (nodeName.Contains(mirrorName0) || nodeName.Contains(mirrorName1) || nodeName.Contains(mirrorName2)
366 || nodeName.Contains(mirrorName3) || nodeName.Contains(mirrorMisAlignName0)
367 || nodeName.Contains(mirrorMisAlignName1) || nodeName.Contains(mirrorMisAlignName2)
368 || nodeName.Contains(mirrorMisAlignName3) || nodeName.Contains(mirrorMisAlignName4)
369 || nodeName.Contains(mirrorMisAlignName5) || nodeName.Contains(mirrorMisAlignName6)
370 || nodeName.Contains(mirrorMisAlignName7)) {
371 geoIterator.GetPath(nodePath);
372 const TGeoMatrix* curMatrix = geoIterator.GetCurrentMatrix();
373 const Double_t* curNodeTr = curMatrix->GetTranslation();
374 mirrorX = TMath::Abs(curNodeTr[0]);
375 mirrorY = TMath::Abs(curNodeTr[1]);
376 mirrorZ = TMath::Abs(curNodeTr[2]);
378 const TGeoSphere*
shape =
dynamic_cast<const TGeoSphere*
>(curNode->GetVolume()->GetShape());
380 if (
shape !=
nullptr) {
381 mirrorRadius =
shape->GetRmin();
383 double theta1 =
shape->GetTheta1();
384 double theta2 =
shape->GetTheta2();
385 if (maxTheta < theta1 || maxTheta < theta2) { maxTheta = TMath::Max(theta1, theta2); }
386 if (minTheta > theta1 || minTheta > theta2) { minTheta = TMath::Min(theta1, theta2); }
391 fGP->
fMirrorTheta = -((maxTheta + minTheta) / 2. - 90.) * TMath::DegToRad();
428 if (noTilting ==
false) {
430 gGeoManager->FindNode(inPos->X(), inPos->Y(), inPos->Z());
431 string path(gGeoManager->GetPath());
437 TMath::Abs(pmtPar.
fY), TMath::Abs(pmtPar.
fZ));
443 Double_t baseLineY = (outPos->Y() >= 0) ? 160. : -160.;
444 Double_t dY = pmtPar.
fY - baseLineY;
445 outPos->SetY(outPos->Y() - dY);
448 TVector3 inPosPmt(pmtPar.
fX, pmtPar.
fY, pmtPar.
fZ);
451 TMath::Abs(pmtPar.
fY), TMath::Abs(pmtPar.
fZ));
457 Double_t padding = gap / 2.;
459 if (outPos->X() < 0) idealX = -idealX;
460 Double_t dX = idealX - outPosPmt.X();
462 outPos->SetX(outPos->X() + dX);
466 outPos->SetXYZ(inPos->X(), inPos->Y(), inPos->Z());
472 Double_t pmtY, Double_t pmtZ)
474 Double_t xDet = 0., yDet = 0., zDet = 0.;
475 Double_t
x = inPos->X();
476 Double_t
y = inPos->Y();
477 Double_t z = inPos->Z();
479 Double_t sinTheta = TMath::Sin(theta);
480 Double_t cosTheta = TMath::Cos(theta);
481 Double_t sinPhi = TMath::Sin(phi);
482 Double_t cosPhi = TMath::Cos(phi);
484 if (
x > 0 &&
y > 0) {
492 xDet =
x * cosPhi -
y * sinPhi * sinTheta + z * cosTheta * sinPhi;
493 yDet =
y * cosTheta + z * sinTheta;
494 zDet = -
x * sinPhi -
y * sinTheta * cosPhi + z * cosTheta * cosPhi;
500 else if (
x > 0 &&
y < 0) {
508 xDet =
x * cosPhi +
y * sinPhi * sinTheta + z * cosTheta * sinPhi;
509 yDet =
y * cosTheta - z * sinTheta;
510 zDet = -
x * sinPhi +
y * sinTheta * cosPhi + z * cosTheta * cosPhi;
516 else if (
x < 0 &&
y < 0) {
524 xDet =
x * cosPhi -
y * sinPhi * sinTheta - z * cosTheta * sinPhi;
525 yDet =
y * cosTheta - z * sinTheta;
526 zDet =
x * sinPhi +
y * sinTheta * cosPhi + z * cosTheta * cosPhi;
540 xDet =
x * cosPhi +
y * sinPhi * sinTheta - z * cosTheta * sinPhi;
541 yDet =
y * cosTheta + z * sinTheta;
542 zDet =
x * sinPhi -
y * sinTheta * cosPhi + z * cosTheta * cosPhi;
550 outPos->SetXYZ(
x,
y, z);
552 outPos->SetXYZ(xDet, yDet, zDet);
564 Double_t marginX = 2.;
565 Double_t marginY = 2.;
567 Double_t pmtYTop = TMath::Abs(pmtPlaneY) + pmtHeight + marginY;
568 Double_t pmtYBottom = TMath::Abs(pmtPlaneY) - pmtHeight - marginY;
569 Double_t absYDet = TMath::Abs(rotatedPoint->y());
570 Bool_t isYOk = (absYDet <= pmtYTop && absYDet >= pmtYBottom);
572 Double_t pmtXMin = -TMath::Abs(pmtPlaneX) - pmtWidth - marginX;
573 Double_t pmtXMax = TMath::Abs(pmtPlaneX) + pmtWidth + marginX;
574 Bool_t isXOk = (rotatedPoint->x() >= pmtXMin && rotatedPoint->x() <= pmtXMax);
576 return (isXOk && isYOk);
580 map<string, CbmRichRecGeoParPmt> pmtMap = gp->
fPmtMap;
584 for (
auto const& entPmt : pmtMap) {
585 if (maxIndex < entPmt.second.fPmtPositionIndexX && entPmt.second.fX > 0 && entPmt.second.fY > 0) {
586 maxKey = entPmt.first;
587 maxIndex = entPmt.second.fPmtPositionIndexX;
591 Double_t pmtPlaneX = pmtPar.
fPlaneX;
592 Double_t pmtPlaneY = pmtPar.
fPlaneY;
593 Double_t pmtPlaneZ = pmtPar.
fPlaneZ;
594 Double_t pmtWidth = pmtPar.
fWidth;
595 Double_t pmtHeight = pmtPar.
fHeight;
600 TVector3 inPmt(pmtPlaneX, pmtPlaneY, pmtPlaneZ), outPmt(0., 0., 0.);
604 Double_t marginX = 2.;
605 Double_t marginY = 2.;
607 Double_t pmtYTop = TMath::Abs(outPmt.Y()) + 0.5 * pmtHeight + marginY;
608 Double_t pmtYBottom = TMath::Abs(outPmt.Y()) - 0.5 * pmtHeight - marginY;
610 Double_t absYDet = TMath::Abs(rotatedPoint->y());
611 Bool_t isYOk = (absYDet <= pmtYTop && absYDet >= pmtYBottom);
613 Double_t pmtXMin = -TMath::Abs(outPmt.X()) - 0.5 * pmtWidth - marginX;
614 Double_t pmtXMax = TMath::Abs(outPmt.X()) + 0.5 * pmtWidth + marginX;
616 Bool_t isXOk = (rotatedPoint->x() >= pmtXMin && rotatedPoint->x() <= pmtXMax);
618 return (isXOk && isYOk);