104 TGeoIterator geoIterator(gGeoManager->GetTopNode()->GetVolume());
105 geoIterator.SetTopName(
"/cave_1");
108 vector<Double_t> xCoord;
110 while ((curNode = geoIterator())) {
111 TString nodeName(curNode->GetName());
114 if (curNode->GetVolume()->GetName() == TString(
"camera_strip")) {
115 geoIterator.GetPath(nodePath);
117 const TGeoMatrix* curMatrix = geoIterator.GetCurrentMatrix();
118 const Double_t* curNodeTr = curMatrix->GetTranslation();
119 const Double_t* curNodeRot = curMatrix->GetRotationMatrix();
123 double pmtX = curNodeTr[0];
124 double pmtY = curNodeTr[1];
125 double pmtZ = curNodeTr[2];
127 double rotY = TMath::ASin(-curNodeRot[2]);
130 double rotX = TMath::ACos(curNodeRot[8] / TMath::Cos(TMath::ASin(-curNodeRot[2])));
137 string nodePathStr = string(nodePath.Data()) +
"/";
139 fGP->fPmtMap[nodePathStr].fTheta = rotX;
140 fGP->fPmtMap[nodePathStr].fPhi = rotY;
141 const TGeoBBox*
shape = (
const TGeoBBox*) (curNode->GetVolume()->GetShape());
143 fGP->fPmtMap[nodePathStr].fWidth = 2. *
shape->GetDX();
144 fGP->fPmtMap[nodePathStr].fHeight = 2. *
shape->GetDY();
145 fGP->fPmtMap[nodePathStr].fZ = pmtZ;
146 fGP->fPmtMap[nodePathStr].fX = pmtX;
147 fGP->fPmtMap[nodePathStr].fY = pmtY;
149 if (pmtX >= 0 && pmtY >= 0) { xCoord.push_back(pmtX); }
152 std::sort(xCoord.begin(), xCoord.end());
154 for (map<string, CbmRichRecGeoParPmt>::iterator it =
fGP->fPmtMap.begin(); it !=
fGP->fPmtMap.end(); it++) {
155 Double_t curX = TMath::Abs(it->second.fX);
158 for (
unsigned int i = 0; i < xCoord.size(); i++) {
159 if (TMath::Abs(curX - xCoord[i]) < 0.1) {
164 it->second.fPmtPositionIndexX =
pos;
168 map<string, CbmRichPmtPlaneMinMax> mapPmtPlaneMinMax;
169 TString filterNamePixel(
"pmt_pixel");
173 while ((curNode = geoIterator())) {
174 TString nodeName(curNode->GetName());
176 if (curNode->GetVolume()->GetName() == filterNamePixel) {
178 geoIterator.GetPath(nodePath);
181 string nodePathStr = string(nodePath.Data());
183 size_t foundIndex1 = nodePathStr.find(
"camera_strip");
185 if (foundIndex1 == string::npos)
continue;
186 size_t foundIndex2 = nodePathStr.find(
"/", foundIndex1 + 1);
187 if (foundIndex2 == string::npos)
continue;
189 string mapKey = nodePathStr.substr(0, foundIndex2) +
"/";
191 const TGeoMatrix* curMatrix = geoIterator.GetCurrentMatrix();
192 const Double_t* curNodeTr = curMatrix->GetTranslation();
194 double pmtX = curNodeTr[0];
195 double pmtY = curNodeTr[1];
196 double pmtZ = curNodeTr[2];
198 mapPmtPlaneMinMax[mapKey].AddPoint(pmtX, pmtY, pmtZ);
202 for (map<string, CbmRichRecGeoParPmt>::iterator it =
fGP->fPmtMap.begin(); it !=
fGP->fPmtMap.end();) {
203 it->second.fPlaneX = mapPmtPlaneMinMax[it->first].GetMeanX();
204 it->second.fPlaneY = mapPmtPlaneMinMax[it->first].GetMeanY();
205 it->second.fPlaneZ = mapPmtPlaneMinMax[it->first].GetMeanZ();
211 if (!mapPmtPlaneMinMax[it->first].fPointAdded) {
212 it =
fGP->fPmtMap.erase(it);
221 double master1[3], master2[3];
222 while ((curNode = geoIterator())) {
223 TString nodeName(curNode->GetName());
225 if (curNode->GetVolume()->GetName() == TString(
"camera_strip")) {
227 geoIterator.GetPath(nodePath);
228 string nodePathStr = string(nodePath.Data()) +
"/";
229 if (
fGP->fPmtMap.find(nodePathStr) ==
fGP->fPmtMap.end())
continue;
230 const TGeoMatrix* curMatrix = geoIterator.GetCurrentMatrix();
231 const Double_t* curNodeTr = curMatrix->GetTranslation();
234 double pmtX = curNodeTr[0];
235 double pmtY = curNodeTr[1];
238 if (pmtX < 0 || pmtY < 0)
continue;
239 const TGeoBBox*
shape = (
const TGeoBBox*) (curNode->GetVolume()->GetShape());
243 if (
fGP->fPmtMap[nodePathStr].fPmtPositionIndexX == 1) {
244 loc[0] =
shape->GetDX() +
shape->GetOrigin()[0];
245 loc[1] =
shape->GetDY() +
shape->GetOrigin()[1];
246 loc[2] =
shape->GetDZ() +
shape->GetOrigin()[2];
247 curMatrix->LocalToMaster(loc, master1);
249 else if (
fGP->fPmtMap[nodePathStr].fPmtPositionIndexX == 2) {
250 loc[0] = -
shape->GetDX() +
shape->GetOrigin()[0];
251 loc[1] =
shape->GetDY() +
shape->GetOrigin()[1];
252 loc[2] =
shape->GetDZ() +
shape->GetOrigin()[2];
253 curMatrix->LocalToMaster(loc, master2);
259 double dist = TMath::Sqrt((master1[0] - master2[0]) * (master1[0] - master2[0])
260 + (master1[1] - master2[1]) * (master1[1] - master2[1])
261 + (master1[2] - master2[2]) * (master1[2] - master2[2]));
263 fGP->fPmtStripGap = dist;
268 TGeoIterator geoIterator(gGeoManager->GetTopNode()->GetVolume());
272 TString filterName_pixel(
"pmt_pixel");
275 while ((curNode = geoIterator())) {
276 TString nodeName(curNode->GetName());
278 if (curNode->GetVolume()->GetName() == filterName_pixel) {
280 geoIterator.GetPath(nodePath);
281 const TGeoMatrix* curMatrix = geoIterator.GetCurrentMatrix();
282 const Double_t* curNodeTr = curMatrix->GetTranslation();
283 const Double_t* curNodeRot = curMatrix->GetRotationMatrix();
285 double pmtX = curNodeTr[0];
286 double pmtY = curNodeTr[1];
287 double pmtZ = curNodeTr[2];
289 if (pmtX > 0. && pmtY > 0) {
291 double rotY = TMath::ASin(-curNodeRot[2]);
294 double rotX = TMath::ACos(curNodeRot[8] / TMath::Cos(TMath::ASin(-curNodeRot[2])));
296 fGP->fPmt.fTheta = rotX;
297 fGP->fPmt.fPhi = rotY;
299 pmtPlaneMinMax.
AddPoint(pmtX, pmtY, pmtZ);
309 while ((curNode = geoIterator())) {
310 TString nodeName(curNode->GetName());
312 if (curNode->GetVolume()->GetName() == TString(
"camera_quarter")) {
314 geoIterator.GetPath(nodePath);
315 const TGeoMatrix* curMatrix = geoIterator.GetCurrentMatrix();
316 const Double_t* curNodeTr = curMatrix->GetTranslation();
320 double pmtX = curNodeTr[0];
321 double pmtY = curNodeTr[1];
322 double pmtZ = curNodeTr[2];
324 if (pmtX > 0. && pmtY > 0) {
325 const TGeoBBox*
shape = (
const TGeoBBox*) (curNode->GetVolume()->GetShape());
339 TGeoIterator geoIterator(gGeoManager->GetTopNode()->GetVolume());
344 TString mirrorName0(
"mirror_tile_type0");
345 TString mirrorName1(
"mirror_tile_type1");
346 TString mirrorName2(
"mirror_tile_type2");
347 TString mirrorName3(
"mirror_tile_type3");
352 TString mirrorMisAlignName0(
"mirror_tile_0");
353 TString mirrorMisAlignName1(
"mirror_tile_1");
354 TString mirrorMisAlignName2(
"mirror_tile_2");
355 TString mirrorMisAlignName3(
"mirror_tile_3");
356 TString mirrorMisAlignName4(
"mirror_tile_4");
357 TString mirrorMisAlignName5(
"mirror_tile_5");
358 TString mirrorMisAlignName6(
"mirror_tile_6");
359 TString mirrorMisAlignName7(
"mirror_tile_7");
362 double maxTheta = 0.;
363 double minTheta = 999999999.;
367 double mirrorRadius = 0.;
368 while ((curNode = geoIterator())) {
369 TString nodeName(curNode->GetName());
372 if (nodeName.Contains(mirrorName0) || nodeName.Contains(mirrorName1) || nodeName.Contains(mirrorName2)
373 || nodeName.Contains(mirrorName3) || nodeName.Contains(mirrorMisAlignName0)
374 || nodeName.Contains(mirrorMisAlignName1) || nodeName.Contains(mirrorMisAlignName2)
375 || nodeName.Contains(mirrorMisAlignName3) || nodeName.Contains(mirrorMisAlignName4)
376 || nodeName.Contains(mirrorMisAlignName5) || nodeName.Contains(mirrorMisAlignName6)
377 || nodeName.Contains(mirrorMisAlignName7)) {
378 geoIterator.GetPath(nodePath);
379 const TGeoMatrix* curMatrix = geoIterator.GetCurrentMatrix();
380 const Double_t* curNodeTr = curMatrix->GetTranslation();
381 mirrorX = TMath::Abs(curNodeTr[0]);
382 mirrorY = TMath::Abs(curNodeTr[1]);
383 mirrorZ = TMath::Abs(curNodeTr[2]);
385 const TGeoSphere*
shape =
dynamic_cast<const TGeoSphere*
>(curNode->GetVolume()->GetShape());
387 if (
shape !=
nullptr) {
388 mirrorRadius =
shape->GetRmin();
390 double theta1 =
shape->GetTheta1();
391 double theta2 =
shape->GetTheta2();
392 if (maxTheta < theta1 || maxTheta < theta2) { maxTheta = TMath::Max(theta1, theta2); }
393 if (minTheta > theta1 || minTheta > theta2) { minTheta = TMath::Min(theta1, theta2); }
398 fGP->fMirrorTheta = -((maxTheta + minTheta) / 2. - 90.) * TMath::DegToRad();
399 fGP->fMirrorX = mirrorX;
400 fGP->fMirrorY = mirrorY;
401 fGP->fMirrorZ = mirrorZ;
402 fGP->fMirrorR = mirrorRadius;
435 if (noTilting ==
false) {
437 gGeoManager->FindNode(inPos->X(), inPos->Y(), inPos->Z());
438 string path(gGeoManager->GetPath());
444 TMath::Abs(pmtPar.
fY), TMath::Abs(pmtPar.
fZ));
450 Double_t baseLineY = (outPos->Y() >= 0) ? 160. : -160.;
451 Double_t dY = pmtPar.
fY - baseLineY;
452 outPos->SetY(outPos->Y() - dY);
455 TVector3 inPosPmt(pmtPar.
fX, pmtPar.
fY, pmtPar.
fZ);
458 TMath::Abs(pmtPar.
fY), TMath::Abs(pmtPar.
fZ));
463 Double_t gap =
fGP->fPmtStripGap;
464 Double_t padding = gap / 2.;
466 if (outPos->X() < 0) idealX = -idealX;
467 Double_t dX = idealX - outPosPmt.X();
469 outPos->SetX(outPos->X() + dX);
473 outPos->SetXYZ(inPos->X(), inPos->Y(), inPos->Z());
479 Double_t pmtY, Double_t pmtZ)
481 Double_t xDet = 0., yDet = 0., zDet = 0.;
482 Double_t
x = inPos->X();
483 Double_t
y = inPos->Y();
484 Double_t z = inPos->Z();
486 Double_t sinTheta = TMath::Sin(theta);
487 Double_t cosTheta = TMath::Cos(theta);
488 Double_t sinPhi = TMath::Sin(phi);
489 Double_t cosPhi = TMath::Cos(phi);
491 if (
x > 0 &&
y > 0) {
499 xDet =
x * cosPhi -
y * sinPhi * sinTheta + z * cosTheta * sinPhi;
500 yDet =
y * cosTheta + z * sinTheta;
501 zDet = -
x * sinPhi -
y * sinTheta * cosPhi + z * cosTheta * cosPhi;
507 else if (
x > 0 &&
y < 0) {
515 xDet =
x * cosPhi +
y * sinPhi * sinTheta + z * cosTheta * sinPhi;
516 yDet =
y * cosTheta - z * sinTheta;
517 zDet = -
x * sinPhi +
y * sinTheta * cosPhi + z * cosTheta * cosPhi;
523 else if (
x < 0 &&
y < 0) {
531 xDet =
x * cosPhi -
y * sinPhi * sinTheta - z * cosTheta * sinPhi;
532 yDet =
y * cosTheta - z * sinTheta;
533 zDet =
x * sinPhi +
y * sinTheta * cosPhi + z * cosTheta * cosPhi;
547 xDet =
x * cosPhi +
y * sinPhi * sinTheta - z * cosTheta * sinPhi;
548 yDet =
y * cosTheta + z * sinTheta;
549 zDet =
x * sinPhi -
y * sinTheta * cosPhi + z * cosTheta * cosPhi;
557 outPos->SetXYZ(
x,
y, z);
559 outPos->SetXYZ(xDet, yDet, zDet);
571 Double_t marginX = 2.;
572 Double_t marginY = 2.;
574 Double_t pmtYTop = TMath::Abs(pmtPlaneY) + pmtHeight + marginY;
575 Double_t pmtYBottom = TMath::Abs(pmtPlaneY) - pmtHeight - marginY;
576 Double_t absYDet = TMath::Abs(rotatedPoint->y());
577 Bool_t isYOk = (absYDet <= pmtYTop && absYDet >= pmtYBottom);
579 Double_t pmtXMin = -TMath::Abs(pmtPlaneX) - pmtWidth - marginX;
580 Double_t pmtXMax = TMath::Abs(pmtPlaneX) + pmtWidth + marginX;
581 Bool_t isXOk = (rotatedPoint->x() >= pmtXMin && rotatedPoint->x() <= pmtXMax);
583 return (isXOk && isYOk);
587 map<string, CbmRichRecGeoParPmt> pmtMap = gp->
fPmtMap;
591 for (
auto const& entPmt : pmtMap) {
592 if (maxIndex < entPmt.second.fPmtPositionIndexX && entPmt.second.fX > 0 && entPmt.second.fY > 0) {
593 maxKey = entPmt.first;
594 maxIndex = entPmt.second.fPmtPositionIndexX;
598 Double_t pmtPlaneX = pmtPar.
fPlaneX;
599 Double_t pmtPlaneY = pmtPar.
fPlaneY;
600 Double_t pmtPlaneZ = pmtPar.
fPlaneZ;
601 Double_t pmtWidth = pmtPar.
fWidth;
602 Double_t pmtHeight = pmtPar.
fHeight;
607 TVector3 inPmt(pmtPlaneX, pmtPlaneY, pmtPlaneZ), outPmt(0., 0., 0.);
611 Double_t marginX = 2.;
612 Double_t marginY = 2.;
614 Double_t pmtYTop = TMath::Abs(outPmt.Y()) + 0.5 * pmtHeight + marginY;
615 Double_t pmtYBottom = TMath::Abs(outPmt.Y()) - 0.5 * pmtHeight - marginY;
617 Double_t absYDet = TMath::Abs(rotatedPoint->y());
618 Bool_t isYOk = (absYDet <= pmtYTop && absYDet >= pmtYBottom);
620 Double_t pmtXMin = -TMath::Abs(outPmt.X()) - 0.5 * pmtWidth - marginX;
621 Double_t pmtXMax = TMath::Abs(outPmt.X()) + 0.5 * pmtWidth + marginX;
623 Bool_t isXOk = (rotatedPoint->x() >= pmtXMin && rotatedPoint->x() <= pmtXMax);
625 return (isXOk && isYOk);