239 cout <<
"//------------------------------ CbmRichCorrection: Projection "
240 "Producer ------------------------------//"
245 Int_t NofRingsInEvent =
fRichRings->GetEntriesFast();
248 Int_t NofPMTPoints =
fRichPoints->GetEntriesFast();
251 Double_t sphereRadius = 300., constantePMT = 0.;
252 vector<Double_t> ptM(3), ptMNew(3), ptC(3), ptCNew(3), ptR1(3), momR1(3), normalPMT(3), ptR2Mirr(3), ptR2Center(3),
253 ptPMirr(3), ptPR2(3), ptTileCenter(3);
254 vector<Double_t> ptCIdeal(3), ptR2CenterUnCorr(3), ptR2CenterIdeal(3), ptR2MirrUnCorr(3), ptR2MirrIdeal(3),
255 ptPMirrUnCorr(3), ptPMirrIdeal(3), ptPR2UnCorr(3), ptPR2Ideal(3);
256 Double_t reflectedPtCooVectSphereUnity[] = {0., 0., 0.};
257 TVector3 outPos, outPosUnCorr, outPosIdeal;
259 Double_t ringCenter[] = {0., 0., 0.}, distToExtrapTrackHit = 0., distToExtrapTrackHitInPlane = 0.;
261 Int_t mirrTrackID = -1, pmtTrackID = -1, refPlaneTrackID = -1, motherID = -100, pmtMotherID = -100;
265 TGeoMatrix *mirrMatrix, *pmtMatrix, *richMatrix;
274 cout <<
"Calculated normal vector to PMT plane = {" << normalPMT.at(0) <<
", " << normalPMT.at(1) <<
", "
275 << normalPMT.at(2) <<
"} and constante d = " << constantePMT << endl
278 for (Int_t iMirr = 0; iMirr < NofMirrorPoints; iMirr++) {
281 mirrTrackID = mirrPoint->GetTrackID();
283 if (mirrTrackID <= -1) {
284 cout <<
"Mirror track ID <= 1 !!!" << endl;
285 cout <<
"----------------------------------- End of loop N°" << iMirr + 1
286 <<
" on the mirror points. -----------------------------------" << endl
292 if (motherID == -1) {
294 ptM.at(0) = mirrPoint->GetX(), ptM.at(1) = mirrPoint->GetY(), ptM.at(2) = mirrPoint->GetZ();
296 mirrNode = gGeoManager->FindNode(ptM.at(0), ptM.at(1), ptM.at(2));
299 navi = gGeoManager->GetCurrentNavigator();
300 cout <<
"Navigator path: " << navi->GetPath() << endl;
301 cout <<
"Coordinates of sphere center: " << endl;
302 navi->GetCurrentMatrix()->Print();
307 ptCIdeal.at(0) = navi->GetCurrentMatrix()->GetTranslation()[0];
308 ptCIdeal.at(1) = navi->GetCurrentMatrix()->GetTranslation()[1];
309 ptCIdeal.at(2) = navi->GetCurrentMatrix()->GetTranslation()[2];
311 cout <<
"Coordinates of tile center: " << endl;
312 navi->GetMotherMatrix()->Print();
313 ptC.at(0) = 0., ptC.at(1) = 132.594000, ptC.at(2) = 54.267226;
314 cout <<
"Sphere center coordinates of the aligned mirror tile, ideal = {" << ptCIdeal.at(0) <<
", "
315 << ptCIdeal.at(1) <<
", " << ptCIdeal.at(2) <<
"}" << endl;
316 cout <<
"Sphere center coordinates of the rotated mirror tile, w/ "
318 << ptC.at(0) <<
", " << ptC.at(1) <<
", " << ptC.at(2) <<
"} and sphere inner radius = " << sphereRadius
323 for (Int_t iRefl = 0; iRefl < NofRefPlanePoints; iRefl++) {
326 refPlaneTrackID = refPlanePoint->GetTrackID();
328 if (mirrTrackID == refPlaneTrackID) {
330 ptR1.at(0) = refPlanePoint->GetX(), ptR1.at(1) = refPlanePoint->GetY(), ptR1.at(2) = refPlanePoint->GetZ();
331 momR1.at(0) = refPlanePoint->GetPx(), momR1.at(1) = refPlanePoint->GetPy(),
332 momR1.at(2) = refPlanePoint->GetPz();
333 cout <<
"Reflective Plane Point coordinates = {" << ptR1.at(0) <<
", " << ptR1.at(1) <<
", " << ptR1.at(2)
335 cout <<
"And reflective Plane Point momenta = {" << momR1.at(0) <<
", " << momR1.at(1) <<
", "
336 << momR1.at(2) <<
"}" << endl;
337 cout <<
"Mirror Point coordinates = {" << ptM.at(0) <<
", " << ptM.at(1) <<
", " << ptM.at(2) <<
"}"
347 ComputeR2(ptR2CenterUnCorr, ptR2MirrUnCorr, ptM, ptC, ptR1, navi,
"Uncorrected");
348 ComputeR2(ptR2Center, ptR2Mirr, ptM, ptC, ptR1, navi,
"Corrected");
349 ComputeR2(ptR2CenterIdeal, ptR2MirrIdeal, ptM, ptCIdeal, ptR1, navi,
"Uncorrected");
351 ComputeP(ptPMirrUnCorr, ptPR2UnCorr, normalPMT, ptM, ptR2MirrUnCorr, constantePMT);
352 ComputeP(ptPMirr, ptPR2, normalPMT, ptM, ptR2Mirr, constantePMT);
353 ComputeP(ptPMirrIdeal, ptPR2Ideal, normalPMT, ptM, ptR2MirrIdeal, constantePMT);
355 TVector3 inPosUnCorr(ptPMirrUnCorr.at(0), ptPMirrUnCorr.at(1), ptPMirrUnCorr.at(2));
358 <<
"New mirror points coordinates = {" << outPosUnCorr.x() <<
", " << outPosUnCorr.y() <<
", "
359 << outPosUnCorr.z() <<
"}" << endl;
360 TVector3 inPos(ptPMirr.at(0), ptPMirr.at(1), ptPMirr.at(2));
362 cout <<
"New mirror points coordinates = {" << outPos.x() <<
", " << outPos.y() <<
", " << outPos.z() <<
"}"
364 TVector3 inPosIdeal(ptPMirrIdeal.at(0), ptPMirrIdeal.at(1), ptPMirrIdeal.at(2));
366 cout <<
"New mirror points coordinates = {" << outPosIdeal.x() <<
", " << outPosIdeal.y() <<
", "
367 << outPosIdeal.z() <<
"}" << endl
397 FillHistProjection(outPosIdeal, outPosUnCorr, outPos, NofGTracks, normalPMT, constantePMT);
400 cout <<
"Not a mother particle ..." << endl;
402 cout <<
"----------------------------------- "
403 <<
"End of loop N°" << iMirr + 1 <<
" on the mirror points."
404 <<
" -----------------------------------" << endl
414 Int_t pmtTrackID, pmtMotherID;
415 Double_t buffNormX = 0., buffNormY = 0., buffNormZ = 0., k = 0., scalarProd = 0.;
416 Double_t pmtPt[] = {0., 0., 0.};
417 Double_t a[] = {0., 0., 0.}, b[] = {0., 0., 0.}, c[] = {0., 0., 0.};
425 for (Int_t iPmt = 0; iPmt < NofPMTPoints; iPmt++) {
427 pmtTrackID = pmtPoint->GetTrackID();
430 a[0] = pmtPoint->GetX(), a[1] = pmtPoint->GetY(), a[2] = pmtPoint->GetZ();
434 for (Int_t iPmt = 0; iPmt < NofPMTPoints; iPmt++) {
436 pmtTrackID = pmtPoint->GetTrackID();
440 if (TMath::Sqrt(TMath::Power(a[0] - pmtPoint->GetX(), 2) + TMath::Power(a[1] - pmtPoint->GetY(), 2)
441 + TMath::Power(a[2] - pmtPoint->GetZ(), 2))
443 b[0] = pmtPoint->GetX(), b[1] = pmtPoint->GetY(), b[2] = pmtPoint->GetZ();
448 for (Int_t iPmt = 0; iPmt < NofPMTPoints; iPmt++) {
450 pmtTrackID = pmtPoint->GetTrackID();
454 if (TMath::Sqrt(TMath::Power(a[0] - pmtPoint->GetX(), 2) + TMath::Power(a[1] - pmtPoint->GetY(), 2)
455 + TMath::Power(a[2] - pmtPoint->GetZ(), 2))
457 && TMath::Sqrt(TMath::Power(b[0] - pmtPoint->GetX(), 2) + TMath::Power(b[1] - pmtPoint->GetY(), 2)
458 + TMath::Power(b[2] - pmtPoint->GetZ(), 2))
460 c[0] = pmtPoint->GetX(), c[1] = pmtPoint->GetY(), c[2] = pmtPoint->GetZ();
466 k = (b[0] - a[0]) / (c[0] - a[0]);
467 if ((b[1] - a[1]) - (k * (c[1] - a[1])) == 0 || (b[2] - a[2]) - (k * (c[2] - a[2])) == 0) {
468 cout <<
"Error in normal calculation, vect_AB and vect_AC are collinear." << endl;
471 buffNormX = (b[1] - a[1]) * (c[2] - a[2]) - (b[2] - a[2]) * (c[1] - a[1]);
472 buffNormY = (b[2] - a[2]) * (c[0] - a[0]) - (b[0] - a[0]) * (c[2] - a[2]);
473 buffNormZ = (b[0] - a[0]) * (c[1] - a[1]) - (b[1] - a[1]) * (c[0] - a[0]);
475 buffNormX / TMath::Sqrt(TMath::Power(buffNormX, 2) + TMath::Power(buffNormY, 2) + TMath::Power(buffNormZ, 2));
477 buffNormY / TMath::Sqrt(TMath::Power(buffNormX, 2) + TMath::Power(buffNormY, 2) + TMath::Power(buffNormZ, 2));
479 buffNormZ / TMath::Sqrt(TMath::Power(buffNormX, 2) + TMath::Power(buffNormY, 2) + TMath::Power(buffNormZ, 2));
483 scalarProd = normalPMT.at(0) * (pmtPoint1->GetX() - a[0]) + normalPMT.at(1) * (pmtPoint1->GetY() - a[1])
484 + normalPMT.at(2) * (pmtPoint1->GetZ() - a[2]);
489 * (normalPMT.at(0) * pmtPoint1->GetX() + normalPMT.at(1) * pmtPoint1->GetY() + normalPMT.at(2) * pmtPoint1->GetZ());
491 scalarProd = normalPMT.at(0) * (pmtPoint2->GetX() - a[0]) + normalPMT.at(1) * (pmtPoint2->GetY() - a[1])
492 + normalPMT.at(2) * (pmtPoint2->GetZ() - a[2]);
495 scalarProd = normalPMT.at(0) * (pmtPoint3->GetX() - a[0]) + normalPMT.at(1) * (pmtPoint3->GetY() - a[1])
496 + normalPMT.at(2) * (pmtPoint3->GetZ() - a[2]);
502 const Char_t* topNodePath;
503 topNodePath = gGeoManager->GetTopNode()->GetName();
504 cout <<
"Top node path: " << topNodePath << endl;
506 rootTop = gGeoManager->GetTopVolume();
509 TGeoIterator nextNode(rootTop);
511 const TGeoMatrix* curMatrix;
512 const Double_t* curNodeTranslation;
513 const Double_t* curNodeRotationM;
514 TString filterName0(
"mirror_tile_type0");
515 TString filterName1(
"mirror_tile_type1");
516 TString filterName2(
"mirror_tile_type2");
517 TString filterName3(
"mirror_tile_type3");
518 TString filterName4(
"mirror_tile_type4");
519 TString filterName5(
"mirror_tile_type5");
521 Double_t sphereXTot = 0., sphereYTot = 0., sphereZTot = 0.;
523 while ((curNode = nextNode())) {
524 TString nodeName(curNode->GetName());
529 if (curNode->GetVolume()->GetName() == filterName0 || curNode->GetVolume()->GetName() == filterName1
530 || curNode->GetVolume()->GetName() == filterName2 || curNode->GetVolume()->GetName() == filterName3
531 || curNode->GetVolume()->GetName() == filterName4 || curNode->GetVolume()->GetName() == filterName5) {
532 if (curNode->GetNdaughters() == 0) {
535 nextNode.GetPath(nodePath);
536 curMatrix = nextNode.GetCurrentMatrix();
537 curNodeTranslation = curMatrix->GetTranslation();
538 curNodeRotationM = curMatrix->GetRotationMatrix();
539 printf(
"%s tr:\t", nodePath.Data());
540 printf(
"%08f\t%08f\t%08f\t\n", curNodeTranslation[0], curNodeTranslation[1], curNodeTranslation[2]);
541 if (curNodeTranslation[1] > 0) {
542 sphereXTot += curNodeTranslation[0];
543 sphereYTot += curNodeTranslation[1];
544 sphereZTot += curNodeTranslation[2];
550 ptC.at(0) = sphereXTot /
counter;
551 ptC.at(1) = sphereYTot /
counter;
552 ptC.at(2) = sphereZTot /
counter;
559 vector<Double_t> ptC, Double_t sphereRadius)
561 Double_t a = 0., b = 0., c = 0., d = 0., k0 = 0., k1 = 0., k2 = 0.;
563 a = TMath::Power(momR1.at(0), 2) + TMath::Power(momR1.at(1), 2) + TMath::Power(momR1.at(2), 2);
565 * (momR1.at(0) * (ptR1.at(0) - ptC.at(0)) + momR1.at(1) * (ptR1.at(1) - ptC.at(1))
566 + momR1.at(2) * (ptR1.at(2) - ptC.at(2)));
567 c = TMath::Power(ptR1.at(0) - ptC.at(0), 2) + TMath::Power(ptR1.at(1) - ptC.at(1), 2)
568 + TMath::Power(ptR1.at(2) - ptC.at(2), 2) - TMath::Power(sphereRadius, 2);
569 d = b * b - 4 * a * c;
570 cout <<
"d = " << d << endl;
573 cout <<
"Error no solution to degree 2 equation found ; discriminant below 0." << endl;
574 ptM.at(0) = 0., ptM.at(1) = 0., ptM.at(2) = 0.;
577 cout <<
"One solution to degree 2 equation found." << endl;
579 ptM.at(0) = ptR1.at(0) + k0 * momR1.at(0);
580 ptM.at(1) = ptR1.at(1) + k0 * momR1.at(1);
581 ptM.at(2) = ptR1.at(2) + k0 * momR1.at(2);
584 cout <<
"Two solutions to degree 2 equation found." << endl;
585 k1 = ((-b - TMath::Sqrt(d)) / (2 * a));
586 k2 = ((-b + TMath::Sqrt(d)) / (2 * a));
588 if (ptR1.at(2) + k1 * momR1.at(2) > ptR1.at(2) + k2 * momR1.at(2)) {
589 ptM.at(0) = ptR1.at(0) + k1 * momR1.at(0);
590 ptM.at(1) = ptR1.at(1) + k1 * momR1.at(1);
591 ptM.at(2) = ptR1.at(2) + k1 * momR1.at(2);
593 else if (ptR1.at(2) + k1 * momR1.at(2) < ptR1.at(2) + k2 * momR1.at(2)) {
594 ptM.at(0) = ptR1.at(0) + k2 * momR1.at(0);
595 ptM.at(1) = ptR1.at(1) + k2 * momR1.at(1);
596 ptM.at(2) = ptR1.at(2) + k2 * momR1.at(2);
603 vector<Double_t> ptCNew(3), ptCNew2(3), ptCNew3(3);
604 Double_t cosPhi = 0., sinPhi = 0., cosTheta = 0., sinTheta = 0., phi2 = 0., theta2 = 0.;
605 Double_t diff[3], transfoMat[3][3], invMat[3][3], corrMat[3][3], buff1[3][3], buff2[3][3], buff3[3][3], buff4[3][3],
606 buff5[3][3], RotX[3][3], RotY[3][3];
607 Double_t corrMat2[3][3], RotX2[3][3], RotY2[3][3];
617 vector<Double_t> outputFit(4);
619 corr_file.open(
"correction_param.txt");
620 if (corr_file.is_open()) {
621 for (Int_t i = 0; i < 4; i++) {
622 corr_file >> outputFit.at(i);
627 cout <<
"Error in CbmRichCorrection: unable to open parameter file!" << endl << endl;
630 cout <<
"Misalignment parameters read from file = [" << outputFit.at(0) <<
" ; " << outputFit.at(1) <<
" ; "
631 << outputFit.at(2) <<
" ; " << outputFit.at(3) <<
"]" << endl;
634 for (Int_t i = 0; i < 3; i++) {
635 for (Int_t j = 0; j < 3; j++) {
654 cosPhi = TMath::Cos(outputFit.at(0));
655 sinPhi = TMath::Sin(outputFit.at(0));
656 cosTheta = TMath::Cos(outputFit.at(1));
657 sinTheta = TMath::Sin(outputFit.at(1));
669 RotX[1][2] = -1 * sinPhi;
677 RotY[0][0] = cosTheta;
679 RotY[0][2] = sinTheta;
683 RotY[2][0] = -1 * sinTheta;
685 RotY[2][2] = cosTheta;
688 for (Int_t i = 0; i < 3; i++) {
689 diff[i] = ptC.at(i) - ptM.at(i);
693 for (Int_t i = 0; i < 3; i++) {
694 for (Int_t j = 0; j < 3; j++) {
696 for (Int_t k = 0; k < 3; k++) {
697 corrMat[i][j] = RotY[i][k] * RotX[k][j] + corrMat[i][j];
702 for (Int_t i = 0; i < 3; i++) {
703 for (Int_t j = 0; j < 3; j++) {
704 for (Int_t k = 0; k < 3; k++) {
705 buff1[i][j] = corrMat[i][k] * invMat[k][j] + buff1[i][j];
709 for (Int_t i = 0; i < 3; i++) {
710 for (Int_t j = 0; j < 3; j++) {
711 for (Int_t k = 0; k < 3; k++) {
712 buff2[i][j] = transfoMat[i][k] * buff1[k][j] + buff2[i][j];
716 for (Int_t i = 0; i < 3; i++) {
717 for (Int_t j = 0; j < 3; j++) {
718 ptCNew.at(i) = buff2[i][j] * diff[j] + ptCNew.at(i);
724 phi2 = TMath::ATan2(diff[1], -1 * diff[2]);
725 theta2 = TMath::ATan2(diff[0], -1 * diff[2]);
726 cout <<
"Calculated Phi (= arctan(y/-z)), in degrees: " << TMath::RadToDeg() * phi2
727 <<
" and calculated Theta (= arctan(x/-z)), in degrees: " << TMath::RadToDeg() * theta2 << endl;
734 RotX2[1][1] = TMath::Cos(phi2);
735 RotX2[1][2] = TMath::Sin(phi2);
737 RotX2[2][1] = -1 * TMath::Sin(phi2);
738 RotX2[2][2] = TMath::Cos(phi2);
740 RotY2[0][0] = TMath::Cos(theta2);
742 RotY2[0][2] = TMath::Sin(theta2);
746 RotY2[2][0] = -1 * TMath::Sin(theta2);
748 RotY2[2][2] = TMath::Cos(theta2);
751 for (Int_t i = 0; i < 3; i++) {
752 for (Int_t j = 0; j < 3; j++) {
753 for (Int_t k = 0; k < 3; k++) {
754 corrMat2[i][j] = RotY2[i][k] * RotX2[k][j] + corrMat2[i][j];
759 for (Int_t i = 0; i < 3; i++) {
760 for (Int_t j = 0; j < 3; j++) {
761 for (Int_t k = 0; k < 3; k++) {
762 buff3[i][j] = corrMat2[i][k] * invMat[k][j] + buff3[i][j];
766 for (Int_t i = 0; i < 3; i++) {
767 for (Int_t j = 0; j < 3; j++) {
768 for (Int_t k = 0; k < 3; k++) {
769 buff4[i][j] = transfoMat[i][k] * buff3[k][j] + buff4[i][j];
773 for (Int_t i = 0; i < 3; i++) {
774 for (Int_t j = 0; j < 3; j++) {
775 for (Int_t k = 0; k < 3; k++) {
776 buff5[i][j] = RotX[i][k] * invMat[k][j] + buff5[i][j];
781 for (Int_t i = 0; i < 3; i++) {
782 for (Int_t j = 0; j < 3; j++) {
783 ptCNew2.at(i) = buff4[i][j] * diff[j] + ptCNew2.at(i);
785 ptCNew3.at(i) = buff5[i][j] * diff[j] + ptCNew3.at(i);
789 for (Int_t i = 0; i < 3; i++) {
790 ptCNew.at(i) += ptM.at(i);
791 ptCNew2.at(i) += ptM.at(i);
792 ptCNew3.at(i) += ptM.at(i);
794 cout <<
"diff = {" << diff[0] <<
", " << diff[1] <<
", " << diff[2] <<
"}" << endl;
795 cout <<
"New coordinates of the rotated tile sphere center (using angles "
796 "from text file) = {"
797 << ptCNew.at(0) <<
", " << ptCNew.at(1) <<
", " << ptCNew.at(2) <<
"}" << endl;
798 cout <<
"New coordinates of the rotated tile sphere center (using calculated "
800 << ptCNew2.at(0) <<
", " << ptCNew2.at(1) <<
", " << ptCNew2.at(2) <<
"}" << endl;
801 cout <<
"Tile coordinates after translation, invMat and rotations around X "
803 << ptCNew3.at(0) <<
", " << ptCNew3.at(1) <<
", " << ptCNew3.at(2) <<
"}" << endl
811 Double_t deter = 0., det11 = 0., det12 = 0., det13 = 0., det21 = 0., det22 = 0., det23 = 0., det31 = 0., det32 = 0.,
812 det33 = 0., buff[3][3], prodMat[3][3];
816 mat[0][0] = navi->GetMotherMatrix()->GetRotationMatrix()[0];
817 mat[0][1] = navi->GetMotherMatrix()->GetRotationMatrix()[1];
818 mat[0][2] = navi->GetMotherMatrix()->GetRotationMatrix()[2];
819 mat[1][0] = navi->GetMotherMatrix()->GetRotationMatrix()[3];
820 mat[1][1] = navi->GetMotherMatrix()->GetRotationMatrix()[4];
821 mat[1][2] = navi->GetMotherMatrix()->GetRotationMatrix()[5];
822 mat[2][0] = navi->GetMotherMatrix()->GetRotationMatrix()[6];
823 mat[2][1] = navi->GetMotherMatrix()->GetRotationMatrix()[7];
824 mat[2][2] = navi->GetMotherMatrix()->GetRotationMatrix()[8];
845 deter = mat[0][0] * (mat[1][1] * mat[2][2] - mat[1][2] * mat[2][1])
846 - mat[0][1] * (mat[1][0] * mat[2][2] - mat[1][2] * mat[2][0])
847 + mat[0][2] * (mat[1][0] * mat[2][1] - mat[1][1] * mat[2][0]);
849 cout <<
"Error in CbmRichCorrection::InvertMatrix; determinant of input "
850 "matrix equals to zero !!!"
853 for (Int_t i = 0; i < 3; i++) {
854 for (Int_t j = 0; j < 3; j++) {
860 buff[0][0] = TMath::Power(-1, 2) * (mat[1][1] * mat[2][2] - mat[1][2] * mat[2][1]);
861 buff[0][1] = TMath::Power(-1, 3) * (mat[0][1] * mat[2][2] - mat[0][2] * mat[2][1]);
862 buff[0][2] = TMath::Power(-1, 4) * (mat[0][1] * mat[1][2] - mat[0][2] * mat[1][1]);
863 buff[1][0] = TMath::Power(-1, 3) * (mat[1][0] * mat[2][2] - mat[1][2] * mat[2][0]);
864 buff[1][1] = TMath::Power(-1, 4) * (mat[0][0] * mat[2][2] - mat[0][2] * mat[2][0]);
865 buff[1][2] = TMath::Power(-1, 5) * (mat[0][0] * mat[1][2] - mat[0][2] * mat[1][0]);
866 buff[2][0] = TMath::Power(-1, 4) * (mat[1][0] * mat[2][1] - mat[1][1] * mat[2][0]);
867 buff[2][1] = TMath::Power(-1, 5) * (mat[0][0] * mat[2][1] - mat[0][1] * mat[2][0]);
868 buff[2][2] = TMath::Power(-1, 6) * (mat[0][0] * mat[1][1] - mat[0][1] * mat[1][0]);
870 for (Int_t i = 0; i < 3; i++) {
871 for (Int_t j = 0; j < 3; j++) {
872 invMat[i][j] = buff[i][j] / deter;
912 vector<Double_t> ptC, vector<Double_t> ptR1, TGeoNavigator* navi, TString s)
915 <<
"//------------------------------ CbmRichCorrection: ComputeR2 "
916 "------------------------------//"
920 vector<Double_t> normalMirr(3), ptCNew(3), ptTileCenter(3);
921 Double_t t1 = 0., t2 = 0., t3 = 0.;
923 if (s ==
"Corrected") {
926 vector<Double_t> outputFit(4);
930 if (corr_file.is_open()) {
931 for (Int_t i = 0; i < 4; i++) {
932 corr_file >> outputFit.at(i);
938 cout <<
"Error in CbmRichCorrection: unable to open parameter file!" << endl;
939 cout <<
"Parameter file path = " << str << endl << endl;
942 cout <<
"Misalignment parameters read from file = [" << outputFit.at(0) <<
" ; " << outputFit.at(1) <<
" ; "
943 << outputFit.at(2) <<
" ; " << outputFit.at(3) <<
"]" << endl;
947 ptCNew.at(0) = ptC.at(0) + outputFit.at(3);
948 ptCNew.at(1) = ptC.at(1) + outputFit.at(2);
949 ptCNew.at(2) = ptC.at(2);
950 ptTileCenter.at(0) = navi->GetMotherMatrix()->GetTranslation()[0];
951 ptTileCenter.at(1) = navi->GetMotherMatrix()->GetTranslation()[1];
952 ptTileCenter.at(2) = navi->GetMotherMatrix()->GetTranslation()[2];
953 cout <<
"Mirror tile center coordinates = {" << ptTileCenter.at(0) <<
", " << ptTileCenter.at(1) <<
", "
954 << ptTileCenter.at(2) <<
"}" << endl;
955 Double_t
x = 0.,
y = 0., z = 0., dist = 0., dist2 = 0., z2 = 0.;
956 x = TMath::Power(ptCNew.at(0) - ptTileCenter.at(0), 2);
957 y = TMath::Power(ptCNew.at(1) - ptTileCenter.at(1), 2);
958 z = TMath::Power(ptCNew.at(2) - ptTileCenter.at(2), 2);
959 dist = TMath::Sqrt(
x +
y + z);
960 z2 = ptTileCenter.at(2) - TMath::Sqrt(TMath::Power(300, 2) -
x -
y) - ptCNew.at(2);
961 cout <<
"{x, y, z} = {" <<
x <<
", " <<
y <<
", " << z <<
"}, dist = " << dist <<
" and z2 = " << z2 << endl;
962 dist2 = TMath::Sqrt(
x +
y + TMath::Power(z2 - ptTileCenter.at(2), 2));
963 cout <<
"dist2 = " << dist2 << endl;
965 cout <<
"Sphere center coordinates of the rotated mirror tile, after "
967 << ptCNew.at(0) <<
", " << ptCNew.at(1) <<
", " << ptCNew.at(2) <<
"}" << endl;
969 else if (s ==
"Uncorrected") {
972 cout <<
"Sphere center coordinates of the rotated mirror tile, without "
974 << ptCNew.at(0) <<
", " << ptCNew.at(1) <<
", " << ptCNew.at(2) <<
"}" << endl;
977 cout <<
"No input given in function ComputeR2! Uncorrected parameters for "
978 "the sphere center of the tile will be used!"
981 cout <<
"Sphere center coordinates of the rotated mirror tile, without "
983 << ptCNew.at(0) <<
", " << ptCNew.at(1) <<
", " << ptCNew.at(2) <<
"}" << endl;
986 normalMirr.at(0) = (ptCNew.at(0) - ptM.at(0))
987 / TMath::Sqrt(TMath::Power(ptCNew.at(0) - ptM.at(0), 2) + TMath::Power(ptCNew.at(1) - ptM.at(1), 2)
988 + TMath::Power(ptCNew.at(2) - ptM.at(2), 2));
989 normalMirr.at(1) = (ptCNew.at(1) - ptM.at(1))
990 / TMath::Sqrt(TMath::Power(ptCNew.at(0) - ptM.at(0), 2) + TMath::Power(ptCNew.at(1) - ptM.at(1), 2)
991 + TMath::Power(ptCNew.at(2) - ptM.at(2), 2));
992 normalMirr.at(2) = (ptCNew.at(2) - ptM.at(2))
993 / TMath::Sqrt(TMath::Power(ptCNew.at(0) - ptM.at(0), 2) + TMath::Power(ptCNew.at(1) - ptM.at(1), 2)
994 + TMath::Power(ptCNew.at(2) - ptM.at(2), 2));
997 t1 = ((ptR1.at(0) - ptM.at(0)) * (ptCNew.at(0) - ptM.at(0)) + (ptR1.at(1) - ptM.at(1)) * (ptCNew.at(1) - ptM.at(1))
998 + (ptR1.at(2) - ptM.at(2)) * (ptCNew.at(2) - ptM.at(2)))
999 / (TMath::Power(ptCNew.at(0) - ptM.at(0), 2) + TMath::Power(ptCNew.at(1) - ptM.at(1), 2)
1000 + TMath::Power(ptCNew.at(2) - ptM.at(2), 2));
1001 ptR2Center.at(0) = 2 * (ptM.at(0) + t1 * (ptCNew.at(0) - ptM.at(0))) - ptR1.at(0);
1002 ptR2Center.at(1) = 2 * (ptM.at(1) + t1 * (ptCNew.at(1) - ptM.at(1))) - ptR1.at(1);
1003 ptR2Center.at(2) = 2 * (ptM.at(2) + t1 * (ptCNew.at(2) - ptM.at(2))) - ptR1.at(2);
1005 ((ptR1.at(0) - ptCNew.at(0)) * (ptCNew.at(0) - ptM.at(0)) + (ptR1.at(1) - ptCNew.at(1)) * (ptCNew.at(1) - ptM.at(1))
1006 + (ptR1.at(2) - ptCNew.at(2)) * (ptCNew.at(2) - ptM.at(2)))
1007 / (TMath::Power(ptCNew.at(0) - ptM.at(0), 2) + TMath::Power(ptCNew.at(1) - ptM.at(1), 2)
1008 + TMath::Power(ptCNew.at(2) - ptM.at(2), 2));
1009 ptR2Mirr.at(0) = 2 * (ptCNew.at(0) + t2 * (ptCNew.at(0) - ptM.at(0))) - ptR1.at(0);
1010 ptR2Mirr.at(1) = 2 * (ptCNew.at(1) + t2 * (ptCNew.at(1) - ptM.at(1))) - ptR1.at(1);
1011 ptR2Mirr.at(2) = 2 * (ptCNew.at(2) + t2 * (ptCNew.at(2) - ptM.at(2))) - ptR1.at(2);
1017 cout <<
"Coordinates of point R2 on reflective plane after reflection on the "
1021 cout <<
"* using sphere center C to define \U00000394: {" << ptR2Mirr.at(0) <<
", " << ptR2Mirr.at(1) <<
", "
1022 << ptR2Mirr.at(2) <<
"}" << endl;
1028 vector<Double_t> ptM, vector<Double_t> ptR2Mirr, Double_t constantePMT)
1031 <<
"//------------------------------ CbmRichCorrection: ComputeP "
1032 "------------------------------//"
1036 Double_t k1 = 0., k2 = 0., checkCalc1 = 0., checkCalc2 = 0.;
1039 * ((normalPMT.at(0) * ptM.at(0) + normalPMT.at(1) * ptM.at(1) + normalPMT.at(2) * ptM.at(2) + constantePMT)
1040 / (normalPMT.at(0) * (ptR2Mirr.at(0) - ptM.at(0)) + normalPMT.at(1) * (ptR2Mirr.at(1) - ptM.at(1))
1041 + normalPMT.at(2) * (ptR2Mirr.at(2) - ptM.at(2))));
1042 ptPMirr.at(0) = ptM.at(0) + k1 * (ptR2Mirr.at(0) - ptM.at(0));
1043 ptPMirr.at(1) = ptM.at(1) + k1 * (ptR2Mirr.at(1) - ptM.at(1));
1044 ptPMirr.at(2) = ptM.at(2) + k1 * (ptR2Mirr.at(2) - ptM.at(2));
1046 * ((normalPMT.at(0) * ptR2Mirr.at(0) + normalPMT.at(1) * ptR2Mirr.at(1) + normalPMT.at(2) * ptR2Mirr.at(2)
1048 / (normalPMT.at(0) * (ptR2Mirr.at(0) - ptM.at(0)) + normalPMT.at(1) * (ptR2Mirr.at(1) - ptM.at(1))
1049 + normalPMT.at(2) * (ptR2Mirr.at(2) - ptM.at(2))));
1050 ptPR2.at(0) = ptR2Mirr.at(0) + k2 * (ptR2Mirr.at(0) - ptM.at(0));
1051 ptPR2.at(1) = ptR2Mirr.at(1) + k2 * (ptR2Mirr.at(1) - ptM.at(1));
1052 ptPR2.at(2) = ptR2Mirr.at(2) + k2 * (ptR2Mirr.at(2) - ptM.at(2));
1053 cout <<
"Coordinates of point P on PMT plane, after reflection on the mirror "
1054 "tile and extrapolation to the PMT plane:"
1056 cout <<
"* using mirror point M to define \U0001D49F ': {" << ptPMirr.at(0) <<
", " << ptPMirr.at(1) <<
", "
1057 << ptPMirr.at(2) <<
"}" << endl;
1060 ptPMirr.at(0) * normalPMT.at(0) + ptPMirr.at(1) * normalPMT.at(1) + ptPMirr.at(2) * normalPMT.at(2) + constantePMT;
1061 cout <<
"Check whether extrapolated track point on PMT plane verifies its "
1062 "equation (value should be 0.):"
1064 cout <<
"* using mirror point M, checkCalc = " << checkCalc1 << endl;
1066 ptPR2.at(0) * normalPMT.at(0) + ptPR2.at(1) * normalPMT.at(1) + ptPR2.at(2) * normalPMT.at(2) + constantePMT;
1071 Int_t NofGTracks, vector<Double_t> normalPMT, Double_t constantePMT)
1074 Double_t ringCenter[] = {0, 0, 0}, distToExtrapTrackHit = 0, distToExtrapTrackHitInPlane = 0,
1075 distToExtrapTrackHitInPlaneUnCorr = 0, distToExtrapTrackHitInPlaneIdeal = 0;
1077 for (Int_t iGlobalTrack = 0; iGlobalTrack < NofGTracks; iGlobalTrack++) {
1080 if (NULL == gTrack)
continue;
1090 Int_t ringTrackID = ring->GetTrackID();
1101 -1 * ((normalPMT.at(0) * ringCenter[0] + normalPMT.at(1) * ringCenter[1] + constantePMT) / normalPMT.at(2));
1103 vector<Double_t> r(3),
1105 r.at(0) = TMath::Abs(ringCenter[0]), r.at(1) = TMath::Abs(ringCenter[1]), r.at(2) = TMath::Abs(ringCenter[2]);
1106 p.at(0) = TMath::Abs(outPos.x()), p.at(1) = TMath::Abs(outPos.y()), p.at(2) = TMath::Abs(outPos.z());
1107 cout <<
"Ring center coordinates = {" << ringCenter[0] <<
", " << ringCenter[1] <<
", " << ringCenter[2] <<
"}"
1109 cout <<
"Difference in X = " << TMath::Abs(r.at(0) - p.at(0)) <<
"; \t"
1110 <<
"Difference in Y = " << TMath::Abs(r.at(1) - p.at(1)) <<
"; \t"
1111 <<
"Difference in Z = " << TMath::Abs(r.at(2) - p.at(2)) << endl;
1112 fHM->
H1(
"fhDifferenceX")->Fill(TMath::Abs(r.at(0) - p.at(0)));
1113 fHM->
H1(
"fhDifferenceY")->Fill(TMath::Abs(r.at(1) - p.at(1)));
1114 distToExtrapTrackHit = TMath::Sqrt(TMath::Power(r.at(0) - p.at(0), 2) + TMath::Power(r.at(1) - p.at(1), 2)
1115 + TMath::Power(r.at(2) - p.at(2), 2));
1116 distToExtrapTrackHitInPlane = TMath::Sqrt(TMath::Power(r.at(0) - p.at(0), 2) + TMath::Power(r.at(1) - p.at(1), 2));
1117 fHM->
H1(
"fhDistanceCenterToExtrapolatedTrack")->Fill(distToExtrapTrackHit);
1118 fHM->
H1(
"fhDistanceCorrected")->Fill(distToExtrapTrackHitInPlane);
1120 cout <<
"Distance between fitted ring center and extrapolated track hit in "
1122 << distToExtrapTrackHitInPlane << endl;
1124 vector<Double_t> pUnCorr(3);
1125 pUnCorr.at(0) = TMath::Abs(outPosUnCorr.x()), pUnCorr.at(1) = TMath::Abs(outPosUnCorr.y()),
1126 pUnCorr.at(2) = TMath::Abs(outPosUnCorr.z());
1128 cout <<
"Difference in X = " << TMath::Abs(r.at(0) - pUnCorr.at(0)) <<
"; \t"
1129 <<
"Difference in Y = " << TMath::Abs(r.at(1) - pUnCorr.at(1)) <<
"; \t"
1130 <<
"Difference in Z = " << TMath::Abs(r.at(2) - pUnCorr.at(2)) << endl;
1131 fHM->
H1(
"fhDifferenceXUncorrected")->Fill(TMath::Abs(r.at(0) - pUnCorr.at(0)));
1132 fHM->
H1(
"fhDifferenceYUncorrected")->Fill(TMath::Abs(r.at(1) - pUnCorr.at(1)));
1133 distToExtrapTrackHitInPlaneUnCorr =
1134 TMath::Sqrt(TMath::Power(r.at(0) - pUnCorr.at(0), 2) + TMath::Power(r.at(1) - pUnCorr.at(1), 2));
1135 fHM->
H1(
"fhDistanceUncorrected")->Fill(distToExtrapTrackHitInPlaneUnCorr);
1136 cout <<
"Distance between fitted ring center and extrapolated track hit in "
1138 << distToExtrapTrackHitInPlaneUnCorr << endl;
1140 vector<Double_t> pIdeal(3);
1141 pIdeal.at(0) = TMath::Abs(outPosIdeal.x()), pIdeal.at(1) = TMath::Abs(outPosIdeal.y()),
1142 pIdeal.at(2) = TMath::Abs(outPosIdeal.z());
1144 cout <<
"Difference in X = " << TMath::Abs(r.at(0) - pIdeal.at(0)) <<
"; \t"
1145 <<
"Difference in Y = " << TMath::Abs(r.at(1) - pIdeal.at(1)) <<
"; \t"
1146 <<
"Difference in Z = " << TMath::Abs(r.at(2) - pIdeal.at(2)) << endl;
1147 fHM->
H1(
"fhDifferenceXIdeal")->Fill(TMath::Abs(r.at(0) - pIdeal.at(0)));
1148 fHM->
H1(
"fhDifferenceYIdeal")->Fill(TMath::Abs(r.at(1) - pIdeal.at(1)));
1149 distToExtrapTrackHitInPlaneIdeal =
1150 TMath::Sqrt(TMath::Power(r.at(0) - pIdeal.at(0), 2) + TMath::Power(r.at(1) - pIdeal.at(1), 2));
1151 fHM->
H1(
"fhDistanceIdeal")->Fill(distToExtrapTrackHitInPlaneIdeal);
1152 cout <<
"Distance between fitted ring center and extrapolated track hit in "
1154 << distToExtrapTrackHitInPlaneIdeal << endl
1159 cout <<
"End of loop on global tracks;" << endl;
1169 can3->SetGrid(1, 1);
1171 can3->cd(1)->SetGrid(1, 1);
1172 can3->cd(2)->SetGrid(1, 1);
1174 TH1D* Clone1 = (TH1D*)
fHM->
H1(
"fhDifferenceXIdeal")->Clone();
1175 Clone1->GetXaxis()->SetTitleSize(0.04);
1176 Clone1->GetYaxis()->SetTitleSize(0.04);
1177 Clone1->GetXaxis()->SetLabelSize(0.03);
1178 Clone1->GetYaxis()->SetLabelSize(0.03);
1179 Clone1->GetXaxis()->CenterTitle();
1180 Clone1->GetYaxis()->CenterTitle();
1181 Clone1->SetTitle(
"Difference in X");
1182 Clone1->SetLineColor(kBlue);
1183 Clone1->SetLineWidth(2);
1186 TH1D* Clone2 = (TH1D*)
fHM->
H1(
"fhDifferenceX")->Clone();
1187 Clone2->SetTitleSize(0.04);
1188 Clone2->SetLabelSize(0.03);
1189 Clone2->SetLineColor(kGreen);
1190 Clone2->SetLineWidth(2);
1192 Clone2->Draw(
"same");
1193 TH1D* Clone3 = (TH1D*)
fHM->
H1(
"fhDifferenceXUncorrected")->Clone();
1194 Clone3->SetTitleSize(0.04);
1195 Clone3->SetLabelSize(0.03);
1196 Clone3->SetLineColor(kRed);
1197 Clone3->SetLineWidth(2);
1199 Clone3->Draw(
"same");
1202 TLegend* LEG =
new TLegend(0.3, 0.78, 0.5, 0.88);
1203 LEG->SetBorderSize(1);
1204 LEG->SetFillColor(0);
1205 LEG->SetMargin(0.2);
1206 LEG->SetTextSize(0.02);
1207 sprintf(leg,
"X diff uncorr");
1208 LEG->AddEntry(Clone3, leg,
"l");
1209 sprintf(leg,
"X diff corr");
1210 LEG->AddEntry(Clone2, leg,
"l");
1211 sprintf(leg,
"X diff ideal");
1212 LEG->AddEntry(Clone1, leg,
"l");
1216 can3->SetGrid(1, 1);
1217 TH1D* Clone4 = (TH1D*)
fHM->
H1(
"fhDifferenceYIdeal")->Clone();
1218 Clone4->GetXaxis()->SetTitleSize(0.04);
1219 Clone4->GetYaxis()->SetTitleSize(0.04);
1220 Clone4->GetXaxis()->SetLabelSize(0.03);
1221 Clone4->GetYaxis()->SetLabelSize(0.03);
1222 Clone4->GetXaxis()->CenterTitle();
1223 Clone4->GetYaxis()->CenterTitle();
1224 Clone4->SetTitle(
"Difference in Y");
1225 Clone4->SetLineColor(kBlue);
1226 Clone4->SetLineWidth(2);
1229 TH1D* Clone5 = (TH1D*)
fHM->
H1(
"fhDifferenceY")->Clone();
1230 Clone5->SetTitleSize(0.04);
1231 Clone5->SetLabelSize(0.03);
1232 Clone5->SetLineColor(kGreen);
1233 Clone5->SetLineWidth(2);
1235 Clone5->Draw(
"same");
1236 TH1D* Clone6 = (TH1D*)
fHM->
H1(
"fhDifferenceYUncorrected")->Clone();
1237 Clone6->SetTitleSize(0.04);
1238 Clone6->SetLabelSize(0.03);
1239 Clone6->SetLineColor(kRed);
1240 Clone6->SetLineWidth(2);
1242 Clone6->Draw(
"same");
1244 TLegend* LEG1 =
new TLegend(0.3, 0.78, 0.5, 0.88);
1245 LEG1->SetBorderSize(1);
1246 LEG1->SetFillColor(0);
1247 LEG1->SetMargin(0.2);
1248 LEG1->SetTextSize(0.02);
1249 sprintf(leg,
"Y diff uncorr");
1250 LEG1->AddEntry(Clone6, leg,
"l");
1251 sprintf(leg,
"Y diff corr");
1252 LEG1->AddEntry(Clone5, leg,
"l");
1253 sprintf(leg,
"Y diff ideal");
1254 LEG1->AddEntry(Clone4, leg,
"l");
1298 gStyle->SetOptStat(000000);