3 #include <boost/gil/extension/io/tiff.hpp>
4 #include <boost/gil/gil_all.hpp>
12 #include "TGeoManager.h"
21 using namespace boost::gil;
32 , fRadiusMirror(3000000)
46 fDistMirrorCCD(3118500)
48 fDistMirrorRuling(fDistMirrorCCD - fDistRulingCCD)
52 fOffsetCCDOptAxisY(-58000)
54 fOffsetLEDOpticalAxisX(0)
56 fOffsetLEDOpticalAxisY(57000)
67 vector<vector<double>> dataV;
68 vector<vector<double>> dataH;
71 Fatal(
"CbmRichRonchiAna::Run:",
"No FileNameV or FileNameH!");
79 int width = dataV.size();
80 int height = dataV[0].size();
85 TH2D* hInitH =
new TH2D(
"hInitH",
86 "hInitH;X [pixel];Y [pixel];Intensity",
93 TH2D* hMeanIntensityH =
94 new TH2D(
"hMeanIntensityH",
95 "hMeanIntensityH;X [pixel];Y [pixel];Intensity",
102 TH2D* hPeakH =
new TH2D(
"hPeakH",
103 "hPeakH;X [pixel];Y [pixel];Intensity",
110 TH2D* hSmoothLinesH =
new TH2D(
"hSmoothLinesH",
111 "hSmoothLinesH;X [pixel];Y [pixel];Intensity",
118 TH2D* hLineSearchH =
new TH2D(
"hLineSearchH",
119 "hLineSearchH;X [pixel];Y [pixel];Intensity",
127 TH2D* hInitV =
new TH2D(
"hInitV",
128 "hInitV;X [pixel];Y [pixel];Intensity",
135 TH2D* hMeanIntensityV =
136 new TH2D(
"hMeanIntensityV",
137 "hMeanIntensityV;X [pixel];Y [pixel];Intensity",
144 TH2D* hPeakV =
new TH2D(
"hPeakV",
145 "hPeakV;X [pixel];Y [pixel];Intensity",
152 TH2D* hSmoothLinesV =
new TH2D(
"hSmoothLinesV",
153 "hSmoothLinesV;X [pixel];Y [pixel];Intensity",
160 TH2D* hLineSearchV =
new TH2D(
"hLineSearchV",
161 "hLineSearchV;X [pixel];Y [pixel];Intensity",
169 TH2D* hSuperpose =
new TH2D(
"hSuperpose",
170 "hSuperpose;X [pixel];Y [pixel];Intensity",
204 vector<CbmRichRonchiIntersectionData> intersections =
206 vector<vector<double>> dataSup =
DoSuperpose(dataH, dataV);
221 new TCanvas(
"ronchi_2d_horizontal",
"ronchi_2d_horizontal", 1500, 1000);
237 new TCanvas(
"ronchi_2d_vertical",
"ronchi_2d_vertical", 1500, 1000);
252 TCanvas* c2 =
new TCanvas(
253 "ronchi_1d_slices_horizontal",
"ronchi_1d_slices_horizontal", 1200, 600);
256 TH1D* h1 = hInitH->ProjectionY(
"_py2", 250, 250);
257 TH1D* h2 = hInitH->ProjectionY(
"_py3", 300, 300);
258 TH1D* hM1 = hMeanIntensityH->ProjectionY(
"_pyM1", 250, 250);
259 TH1D* hM2 = hMeanIntensityH->ProjectionY(
"_pyM2", 300, 300);
260 TH1D* hP1 = hPeakH->ProjectionY(
"_pyP1", 250, 250);
261 TH1D* hP2 = hPeakH->ProjectionY(
"_pyP2", 300, 300);
263 DrawH1({h1, hM1, hP1}, {
"Init",
"Mean",
"Peak"});
265 DrawH1({h2, hM2, hP2}, {
"Init",
"Mean",
"Peak"});
270 TCanvas* c =
new TCanvas(
271 "ronchi_2d_intersection",
"ronchi_2d_intersection", 1000, 1000);
273 for (
size_t i = 0;
i < intersections.size();
i++) {
275 new TEllipse(intersections[
i].fPixelX, intersections[
i].fPixelY, 5);
280 vector<int> colors = {kBlack,
292 TCanvas* c =
new TCanvas(
293 "ronchi_2d_intersection_x",
"ronchi_2d_intersection_x", 1000, 1000);
295 for (
size_t i = 0;
i < intersections.size();
i++) {
297 new TEllipse(intersections[
i].fPixelX, intersections[
i].fPixelY, 5);
298 center->SetFillColor(
299 colors[intersections[
i].fOrderedLineX % colors.size()]);
305 TCanvas* c =
new TCanvas(
306 "ronchi_2d_intersection_y",
"ronchi_2d_intersection_y", 1000, 1000);
308 for (
size_t i = 0;
i < intersections.size();
i++) {
310 new TEllipse(intersections[
i].fPixelX, intersections[
i].fPixelY, 5);
311 center->SetFillColor(
312 colors[intersections[
i].fOrderedLineY % colors.size()]);
319 cout <<
"ReadTiffFile:" << fileName << endl;
320 vector<vector<double>> data;
323 read_and_convert_image(fileName, img, boost::gil::tiff_tag());
325 int height = img.height();
326 int width = img.width();
330 auto view = const_view(img);
331 for (
int x = 0;
x < width; ++
x) {
332 auto it = view.col_begin(
x);
333 data[
x].resize(height);
334 for (
int y = 0;
y < height; ++
y) {
335 int r = boost::gil::at_c<0>(it[
y]);
347 int nX = data.size();
348 int nY = data[0].size();
349 for (
int x = 0;
x < nX;
x++) {
350 for (
int y =
x + 1;
y < nY;
y++) {
351 swap(data[
x][
y], data[
y][
x]);
358 const vector<vector<double>>& data) {
359 int nX = data.size();
360 int nY = data[0].size();
362 for (
int x = 0;
x < nX;
x++) {
363 for (
int y = 0;
y < nY;
y++) {
364 if (data[
x][
y] != 0) { hist->SetBinContent(
x,
y, data[
x][
y]); }
371 int nX = data.size();
372 int nY = data[0].size();
378 vector<double> weightsX = {
385 vector<double> weightsY = {1., 0.75, 0.4, 0.2, 0.08, 0.04};
387 vector<vector<double>> dataNew(nX, std::vector<double>(nY, 0.));
389 for (
int x = 0;
x < nX;
x++) {
390 for (
int y = 0;
y < nY;
y++) {
392 double weightSum = 0.;
394 int xW = -halfAvWindow; xW <= halfAvWindow;
396 for (
int yW = -halfAvWindow; yW <= halfAvWindow; yW++) {
398 int xWAbs = std::abs(xW);
399 int yWAbs = std::abs(yW);
402 (xWAbs < (int) weightsX.size())
408 (yWAbs < (int) weightsY.size())
410 : weightsY[weightsY.size() - 1];
412 double weight = weightX * weightY;
417 if (indX >= nX) indX = nX - 1;
419 if (indY < 0) indY = 0;
420 if (indY >= nY) indY = nY - 1;
422 total += data[indX][indY] * weight;
426 dataNew[
x][
y] = total / weightSum;
427 if (dataNew[
x][
y] <= threshold)
437 int nX = data.size();
438 int nY = data[0].size();
440 int samePeakCounterCut = 5;
442 vector<vector<double>> dataNew(nX, std::vector<double>(nY, 0.));
444 for (
int x = 0;
x < nX;
x++) {
445 for (
int y = halfWindow;
y < nY - halfWindow;
y++) {
447 (data[
x][
y] > 0. && data[
x][
y] >= data[
x][
y - 1])
448 && (data[
x][
y] >= data
452 if (!isPeak)
continue;
455 int samePeakCounter = 0;
456 for (
int yS =
y; yS < nY; yS++) {
457 if (data[
x][
y] == data[
x][yS]) {
464 >= samePeakCounterCut) {
465 y =
y + samePeakCounter + 1;
469 bool isBiggest =
true;
470 for (
int iW = -halfWindow; iW <= halfWindow;
472 if (iW == 0)
continue;
473 if (data[
x][
y + iW] > data[
x][
y]) {
478 bool hasNeighbourPeak =
479 (dataNew[
x][
y - 2] > 0. || dataNew[
x][
y - 1] > 0.
480 || dataNew[
x][
y + 1] > 0. || dataNew[
x][
y + 2] > 0.);
482 if (isBiggest && isPeak && !hasNeighbourPeak)
493 int meanHalfLength = 8;
494 int meanHalfHeight = 3;
495 int nX = data.size();
496 int nY = data[0].size();
498 vector<vector<double>> dataNew(nX, std::vector<double>(nY, 0.));
500 for (
int x = meanHalfLength;
x < nX - meanHalfLength;
502 for (
int y = meanHalfHeight;
y < nY - meanHalfHeight;
y++) {
503 if (data[
x][
y] == 0.)
continue;
507 int x2 = -meanHalfLength; x2 <= meanHalfLength;
509 for (
int y2 = -meanHalfHeight; y2 <= meanHalfHeight; y2++) {
510 if (data[
x + x2][
y + y2] > 0) {
516 int newY = (int) sumY /
counter;
517 dataNew[
x][newY] = data[
x][
y];
525 int nX = data.size();
526 int nY = data[0].size();
528 int missingCounterCut = 15;
529 int missingCounterTotalCut = 25;
532 vector<vector<double>> dataNew(nX, std::vector<double>(nY, 0.));
533 double curIndex = 0.;
535 for (
int x = 0;
x < nX;
x++) {
536 for (
int y = 0;
y < nY;
y++) {
541 dataNew[
x][
y] = curIndex;
542 int missingCounterTotal = 0.;
543 int missingCounter = 0.;
546 int x1 =
x + 1; x1 < nX;
548 bool isFound =
false;
549 for (
int y1 = -halfWindowY; y1 <= halfWindowY; y1++) {
550 if (data[x1][curY + y1] > 0.
551 && dataNew[x1][curY + y1]
553 dataNew[x1][curY + y1] =
562 missingCounterTotal++;
567 if (missingCounterTotal >= missingCounterTotalCut
568 || missingCounter >= missingCounterCut)
574 cout <<
"curIndex:" << curIndex << endl;
580 vector<CbmRichRonchiIntersectionData>
582 const vector<vector<double>>& dataV) {
583 int nX = dataV.size();
584 int nY = dataV[0].size();
586 vector<CbmRichRonchiIntersectionData> intersections;
588 for (
int x = 0;
x < nX;
x++) {
589 for (
int y = 0;
y < nY;
y++) {
601 intersections.push_back(data);
605 cout <<
"intersections.size(): " << intersections.size() << endl;
609 for (
size_t i1 = 0; i1 < intersections.size(); i1++) {
610 for (
size_t i2 = i1 + 1; i2 < intersections.size(); i2++) {
612 intersections[i1].fPixelX
615 double dY = intersections[i1].fPixelY - intersections[i2].fPixelY;
616 double dist =
std::sqrt(dX * dX + dY * dY);
628 set<int>::iterator it;
629 for (it = removeSet.begin(); it != removeSet.end(); ++it) {
633 [intersections.size()
635 intersections.resize(intersections.size() - 1);
637 cout <<
"removeSet.size():" << removeSet.size()
638 <<
" intersections.size(): " << intersections.size() << endl;
640 return intersections;
644 vector<vector<double>>
646 const vector<vector<double>>& dataV) {
647 int nX = dataV.size();
648 int nY = dataV[0].size();
650 vector<vector<double>> dataSup(nX, std::vector<double>(nY, 0.));
651 for (
int x = 0;
x < nX;
x++) {
652 for (
int y = 0;
y < nY;
y++) {
663 vector<CbmRichRonchiIntersectionData>& intersections,
664 const string& option) {
665 map<int, CbmRichRonchiLineData> linesMap;
666 vector<CbmRichRonchiLineData> lines;
669 for (
auto const& curIntr : intersections) {
674 linesMap[lineInd].fMeanPrimary +=
679 linesMap[lineInd].fMeanSecondary +=
680 (option ==
"x") ? curIntr.fPixelY : curIntr.fPixelX;
681 linesMap[lineInd].fNofPoints++;
682 linesMap[lineInd].fLineInd = lineInd;
685 for (
auto& kv : linesMap) {
686 kv.second.fMeanPrimary =
687 (double) kv.second.fMeanPrimary
690 kv.second.fMeanSecondary =
691 (
double) kv.second.fMeanSecondary / kv.second.fNofPoints;
692 lines.push_back(kv.second);
699 return lhs.fMeanPrimary < rhs.fMeanPrimary;
704 for (
size_t i = 0;
i < lines.size() - 1;
i++) {
705 if (lines[
i].fNofPoints >= 35) {
712 for (
int i = lineIndMany - 1;
i >= 1;
i--) {
715 intersections, &lines[
i], &lines[
i - 1], option);
720 for (
size_t i = lineIndMany;
i < lines.size() - 1;
i++) {
723 intersections, &lines[
i], &lines[
i + 1], option);
729 int newLineIndex = 1;
730 set<int> duplicateLines;
731 for (
auto& curLine : lines) {
732 if (duplicateLines.find(curLine.fLineInd) != duplicateLines.end())
continue;
733 duplicateLines.insert(curLine.fLineInd);
734 for (
auto& curIntr : intersections) {
735 if (option ==
"x" && curIntr.fLineX == curLine.fLineInd)
736 curIntr.fOrderedLineX = newLineIndex;
737 if (option ==
"y" && curIntr.fLineY == curLine.fLineInd)
738 curIntr.fOrderedLineY = newLineIndex;
742 cout <<
"newLineIndex:" << newLineIndex << endl;
748 int nofPointsMergeCut = 25;
749 double pixelDistMergeCut = 200.;
750 double pixelDiffMergeCut = 15.;
760 vector<CbmRichRonchiIntersectionData>& intersections,
763 const string& option) {
764 for (
auto& curIntr : intersections) {
765 if (option ==
"x" && curIntr.fLineX == line2->
fLineInd)
767 if (option ==
"y" && curIntr.fLineY == line2->
fLineInd)
774 vector<CbmRichRonchiIntersectionData>& data) {
781 for (
size_t i = 0;
i < data.size();
i++) {
782 if (data[
i].fOrderedLineX < xMin) xMin = data[
i].fOrderedLineX;
783 if (data[
i].fOrderedLineX > xMax) xMax = data[
i].fOrderedLineX;
784 if (data[
i].fOrderedLineY < yMin) yMin = data[
i].fOrderedLineY;
785 if (data[
i].fOrderedLineY > yMax) yMax = data[
i].fOrderedLineY;
788 int centerLineX = (xMax - xMin) / 2;
789 int centerLineY = (yMax - yMin) / 2;
794 for (
size_t i = 0;
i < data.size();
i++) {
795 if (
fCenterCcdX == -1 && data[
i].fOrderedLineX == centerLineX) {
798 if (
fCenterCcdY == -1 && data[
i].fOrderedLineY == centerLineY) {
803 cout <<
"xMin:" << xMin <<
" xMax:" << xMax <<
" yMin:" << yMin
804 <<
" yMax:" << yMax << endl;
805 cout <<
"centerLineX:" << centerLineX <<
" centerLineY:" << centerLineY
810 for (
size_t i = 0;
i < data.size();
i++) {
815 data[
i].fCcdV.SetXYZ(ccdX, ccdY, 0.);
818 data[
i].fRulingV.SetXYZ((data[
i].fOrderedLineX - centerLineX) *
fPitchGrid,
819 (data[
i].fOrderedLineY - centerLineY) *
fPitchGrid,
823 double sRefX = -(data[
i].fRulingV.X() - data[
i].fCcdV.X())
825 double sRefY = -(data[
i].fRulingV.Y() - data[
i].fCcdV.Y()) /
fDistRulingCCD;
835 double mirrorCenterDist =
842 - pow(mirrorCenterDist, 2));
847 double angleIncX = atan(
851 atan((data[
i].fMirrorV.Y()
855 double angleRefX = atan(sRefX);
856 double angleRefY = atan(sRefY);
857 data[
i].fNormalRadX = ((angleIncX + angleRefX) / 2.0);
858 data[
i].fNormalRadY = ((angleIncY + angleRefY) / 2.0);
865 data[
i].fTL.SetXYZ(data[
i].fMirrorV.X() - segmentSize,
866 data[
i].fMirrorV.Y() + segmentSize,
867 data[
i].fMirrorV.Z());
874 data[
i].fTR.SetXYZ(data[
i].fMirrorV.X() + segmentSize,
875 data[
i].fMirrorV.Y() + segmentSize,
876 data[
i].fMirrorV.Z());
883 data[
i].fBL.SetXYZ(data[
i].fMirrorV.X() - segmentSize,
884 data[
i].fMirrorV.Y() - segmentSize,
885 data[
i].fMirrorV.Z());
892 data[
i].fBR.SetXYZ(data[
i].fMirrorV.X() + segmentSize,
893 data[
i].fMirrorV.Y() - segmentSize,
894 data[
i].fMirrorV.Z());
917 new TCanvas(
"ronchi_xz_mum_lineY20",
"ronchi_xz_mum_lineY20", 1800, 900);
936 for (
size_t i = 0;
i < data.size();
i++) {
937 if (data[
i].fOrderedLineX < xMin) xMin = data[
i].fOrderedLineX;
938 if (data[
i].fOrderedLineX > xMax) xMax = data[
i].fOrderedLineX;
939 if (data[
i].fOrderedLineY < yMin) yMin = data[
i].fOrderedLineY;
940 if (data[
i].fOrderedLineY > yMax) yMax = data[
i].fOrderedLineY;
945 for (
int iX = xMin; iX <= xMax; iX++) {
950 if (iPX < 0 || iPX0 < 0)
continue;
952 data[iPX0].fTRRot.X()
955 data[iPX].fTLRot.SetXYZ(data[iPX].fTLRot.X() + shiftX,
956 data[iPX].fTLRot.Y(),
957 data[iPX].fTLRot.Z());
958 data[iPX].fTRRot.SetXYZ(data[iPX].fTRRot.X() + shiftX,
959 data[iPX].fTRRot.Y(),
960 data[iPX].fTRRot.Z());
961 data[iPX].fBLRot.SetXYZ(data[iPX].fBLRot.X() + shiftX,
962 data[iPX].fBLRot.Y(),
963 data[iPX].fBLRot.Z());
964 data[iPX].fBRRot.SetXYZ(data[iPX].fBRRot.X() + shiftX,
965 data[iPX].fBRRot.Y(),
966 data[iPX].fBRRot.Z());
970 for (
int iY = yMin; iY <= yMax; iY++) {
973 if (iPY < 0 || iPY0 < 0)
continue;
974 double shiftY = data[iPY0].fTRRot.Y() - data[iPY].fBRRot.Y();
975 data[iPY].fTLRot.SetXYZ(data[iPY].fTLRot.X(),
976 data[iPY].fTLRot.Y() + shiftY,
977 data[iPY].fTLRot.Z());
978 data[iPY].fTRRot.SetXYZ(data[iPY].fTRRot.X(),
979 data[iPY].fTRRot.Y() + shiftY,
980 data[iPY].fTRRot.Z());
981 data[iPY].fBLRot.SetXYZ(data[iPY].fBLRot.X(),
982 data[iPY].fBLRot.Y() + shiftY,
983 data[iPY].fBLRot.Z());
984 data[iPY].fBRRot.SetXYZ(data[iPY].fBRRot.X(),
985 data[iPY].fBRRot.Y() + shiftY,
986 data[iPY].fBRRot.Z());
992 for (
int iX = xMin; iX <= xMax; iX++) {
994 if (iPX < 0)
continue;
995 for (
int iY = yMin; iY <= yMax; iY++) {
997 if (iC < 0)
continue;
999 if (iPY < 0)
continue;
1001 double shiftX = data[iPX].fTLRot.X() - data[iC].fTLRot.X();
1002 double shiftY = data[iPY].fTLRot.Y() - data[iC].fTLRot.Y();
1004 data[iC].fTLSph.SetXYZ(data[iC].fTLRot.X() + shiftX,
1005 data[iC].fTLRot.Y() + shiftY,
1006 data[iC].fTLRot.Z());
1007 data[iC].fTRSph.SetXYZ(data[iC].fTRRot.X() + shiftX,
1008 data[iC].fTRRot.Y() + shiftY,
1009 data[iC].fTRRot.Z());
1010 data[iC].fBLSph.SetXYZ(data[iC].fBLRot.X() + shiftX,
1011 data[iC].fBLRot.Y() + shiftY,
1012 data[iC].fBLRot.Z());
1013 data[iC].fBRSph.SetXYZ(data[iC].fBRRot.X() + shiftX,
1014 data[iC].fBRRot.Y() + shiftY,
1015 data[iC].fBRRot.Z());
1020 for (
int iX = xMin; iX <= xMax; iX++) {
1021 for (
int iY = yMin; iY <= yMax; iY++) {
1028 if (iC < 0)
continue;
1032 double shiftZ = data[iPY].fTLSph.Z() - data[iC].fBLSph.Z();
1033 data[iC].fTLSph.SetZ(data[iC].fTLSph.Z() + shiftZ);
1034 data[iC].fTRSph.SetZ(data[iC].fTRSph.Z() + shiftZ);
1035 data[iC].fBLSph.SetZ(data[iC].fBLSph.Z() + shiftZ);
1036 data[iC].fBRSph.SetZ(data[iC].fBRSph.Z() + shiftZ);
1042 for (
int iX = xMin; iX <= xMax; iX++) {
1048 if (iPX < 0 || iPX0 < 0)
continue;
1049 double shiftZ = data[iPX0].fTRSph.Z() - data[iPX].fTLSph.Z();
1050 for (
int iY = yMin; iY <= yMax; iY++) {
1052 data[iC].fTLSph.SetZ(data[iC].fTLSph.Z() + shiftZ);
1053 data[iC].fTRSph.SetZ(data[iC].fTRSph.Z() + shiftZ);
1054 data[iC].fBLSph.SetZ(data[iC].fBLSph.Z() + shiftZ);
1055 data[iC].fBRSph.SetZ(data[iC].fBRSph.Z() + shiftZ);
1069 vector<CbmRichRonchiIntersectionData>& data) {
1071 for (
int iY = 0; iY < 2000; iY++) {
1073 if (ind != -1)
return ind;
1081 vector<CbmRichRonchiIntersectionData>& data) {
1083 for (
int iX = 0; iX < 2000; iX++) {
1085 if (ind != -1)
return ind;
1094 vector<CbmRichRonchiIntersectionData>& data) {
1095 for (
size_t i = 0;
i < data.size();
i++) {
1096 if (data[
i].fOrderedLineX == lineX && data[
i].fOrderedLineY == lineY)
1103 vector<CbmRichRonchiIntersectionData>& data) {
1108 int correctionValue = 11800;
1111 for (
size_t i = 0;
i < data.size();
i++) {
1113 * (data[
i].fTLSph.X() + data[
i].fTRSph.X()
1114 + data[
i].fBLSph.X() + data[
i].fBRSph.X());
1116 * (data[
i].fTLSph.Y() + data[
i].fTRSph.Y()
1117 + data[
i].fBLSph.Y() + data[
i].fBRSph.Y());
1119 * (data[
i].fTLSph.Z() + data[
i].fTRSph.Z()
1120 + data[
i].fBLSph.Z() + data[
i].fBRSph.Z());
1121 double dX = mirX - meanX;
1122 double dY = mirY - meanY;
1123 double dZ = mirZ - meanZ;
1124 double d =
sqrt(dZ * dZ);
1130 double mirrorCenterDist =
1137 data[
i].fDeviation =
1140 TH2D* hMirrorHeight =
1141 new TH2D(
"hMirrorDeviation",
1142 "hMirrorDeviation;index X;index Y;Deviation [mum]",
1149 TCanvas* c =
new TCanvas(
"mirror_deviation",
"mirror_deviation", 1000, 1000);
1150 for (
size_t i = 0;
i < data.size();
i++) {
1151 if (data[
i].fDeviation > threshold) {
1152 hMirrorHeight->SetBinContent(data[
i].fOrderedLineX,
1153 data[
i].fOrderedLineY,
1154 data[
i].fDeviation - correctionValue);
1161 vector<int> colors = {kBlack,
1172 TH2D* hCcdXY =
new TH2D(
"hCcdXY",
1173 "hCcdXY;CCD_X [mum];CCD_Y [mum];",
1180 TH2D* hRulingXY =
new TH2D(
"hRulingXY",
1181 "hRulingXY;Ruling_X [mum];Ruling_Y [mum];",
1188 TH2D* hMirrorXY =
new TH2D(
"hMirrorXY",
1189 "hMirrorXY;Mirror_X [mum];Mirror_Y [mum];",
1196 TCanvas* c =
new TCanvas(
"ronchi_xy_mum",
"ronchi_xy_mum", 1800, 600);
1200 gPad->SetRightMargin(0.10);
1201 for (
size_t i = 0;
i < data.size();
i++) {
1202 TEllipse* center =
new TEllipse(data[
i].fCcdV.X(), data[
i].fCcdV.Y(), 50);
1203 center->SetFillColor(colors[data[
i].fOrderedLineX % colors.size()]);
1209 gPad->SetRightMargin(0.10);
1210 for (
size_t i = 0;
i < data.size();
i++) {
1212 new TEllipse(data[
i].fRulingV.X(), data[
i].fRulingV.Y(), 50);
1213 center->SetFillColor(colors[data[
i].fOrderedLineX % colors.size()]);
1219 gPad->SetRightMargin(0.10);
1220 for (
size_t i = 0;
i < data.size();
i++) {
1222 new TEllipse(data[
i].fMirrorV.X(), data[
i].fMirrorV.Y(), 2500);
1223 center->SetFillColor(colors[data[
i].fOrderedLineX % colors.size()]);
1229 vector<CbmRichRonchiIntersectionData>& data,
1233 "hZX_lineY" + to_string(orderedLineY) +
"_scale" + to_string(scale);
1235 TH2D* hZX =
new TH2D(histName.c_str(),
1236 (histName +
";Z [mum];X [mum];").c_str(),
1244 gPad->SetRightMargin(0.10);
1245 for (
size_t i = 0;
i < data.size();
i++) {
1246 if (data[
i].fOrderedLineY != orderedLineY)
continue;
1248 TEllipse* ccdEllipse =
new TEllipse(
1249 data[
i].fCcdV.Z(), data[
i].fCcdV.X(), scale * 20000, scale * 2000);
1250 ccdEllipse->SetFillColor(kRed);
1253 TEllipse* rulingEllipse =
new TEllipse(
1254 data[
i].fRulingV.Z(), data[
i].fRulingV.X(), scale * 20000, scale * 2000);
1255 rulingEllipse->SetFillColor(kBlue);
1256 rulingEllipse->Draw();
1258 TEllipse* mirrorEllipse =
new TEllipse(
1259 data[
i].fMirrorV.Z(), data[
i].fMirrorV.X(), scale * 20000, scale * 2000);
1260 mirrorEllipse->SetFillColor(kGreen);
1261 mirrorEllipse->Draw();
1263 TLine* rulingLine =
new TLine(data[
i].fCcdV.Z(),
1265 data[
i].fRulingV.Z(),
1266 data[
i].fRulingV.X());
1269 TLine* mirrorLine =
new TLine(data[
i].fRulingV.Z(),
1270 data[
i].fRulingV.X(),
1271 data[
i].fMirrorV.Z(),
1272 data[
i].fMirrorV.X());
1277 TLine* mirrorLineNorm =
new TLine(
1279 mirrorLineNorm->SetLineColor(kBlue);
1280 mirrorLineNorm->Draw();
1286 vector<CbmRichRonchiIntersectionData>& data,
1289 string cName =
"ronchi_mirror_segments_rot_lineX" + to_string(orderedLineX)
1290 +
"_lineY" + to_string(orderedLineY);
1291 TCanvas* c =
new TCanvas(cName.c_str(), cName.c_str(), 1800, 900);
1294 string histNameXY =
"hXY_mirror_segments_rot_lineX" + to_string(orderedLineX)
1295 +
"_lineY" + to_string(orderedLineY);
1296 TH2D* hXY =
new TH2D(histNameXY.c_str(),
1297 (histNameXY +
"hXY;X [mum];Y [mum];").c_str(),
1304 vector<int> colors = {kBlack,
1317 gPad->SetRightMargin(0.10);
1318 for (
size_t i = 0;
i < data.size();
i++) {
1319 int color = colors[data[
i].fOrderedLineY % colors.size()];
1321 data[
i].fTLRot, data[
i].fTRRot, data[
i].fBLRot, data[
i].fBRRot, color);
1324 double hSize = 250000;
1325 string histNameZX =
"hZX_mirror_segments_lrot_ineX" + to_string(orderedLineX)
1326 +
"_lineY" + to_string(orderedLineY);
1327 TH2D* hZX =
new TH2D(histNameZX.c_str(),
1328 (histNameZX +
";Z [mum];X [mum];").c_str(),
1337 gPad->SetRightMargin(0.10);
1338 for (
size_t i = 0;
i < data.size();
i++) {
1339 if (data[
i].fOrderedLineY != orderedLineY)
continue;
1341 TEllipse* mirrorEllipse =
1342 new TEllipse(data[
i].fMirrorV.Z(), data[
i].fMirrorV.X(), 2000, 2000);
1343 mirrorEllipse->SetFillColor(kGreen);
1344 mirrorEllipse->Draw();
1346 TLine* rulingLine =
new TLine(data[
i].fCcdV.Z(),
1348 data[
i].fRulingV.Z(),
1349 data[
i].fRulingV.X());
1352 TLine* mirrorLine =
new TLine(data[
i].fRulingV.Z(),
1353 data[
i].fRulingV.X(),
1354 data[
i].fMirrorV.Z(),
1355 data[
i].fMirrorV.X());
1360 TLine* mirrorLineNorm =
new TLine(
1362 mirrorLineNorm->SetLineColor(kBlue);
1363 mirrorLineNorm->Draw();
1365 TLine* mirrorLineSeg =
new TLine(data[
i].fTRRot.Z(),
1368 data[
i].fTLRot.X());
1369 mirrorLineSeg->SetLineColor(kRed);
1370 mirrorLineSeg->Draw();
1375 vector<CbmRichRonchiIntersectionData>& data) {
1376 string cName =
"ronchi_mirror_segments_sphere_all";
1377 TCanvas* c =
new TCanvas(cName.c_str(), cName.c_str(), 900, 900);
1379 string histNameXY =
"hXY_mirror_segments_sphere_all";
1380 TH2D* hXY =
new TH2D(histNameXY.c_str(),
1381 (histNameXY +
"hXY;X [mum];Y [mum];").c_str(),
1388 vector<int> colors = {kBlack,
1400 gPad->SetRightMargin(0.10);
1401 for (
size_t i = 0;
i < data.size();
i++) {
1402 int color = colors[data[
i].fOrderedLineY % colors.size()];
1404 data[
i].fTLSph, data[
i].fTRSph, data[
i].fBLSph, data[
i].fBRSph, color);
1409 vector<CbmRichRonchiIntersectionData>& data,
1412 string cName =
"ronchi_mirror_segments_sphere_lineX" + to_string(orderedLineX)
1413 +
"_lineY" + to_string(orderedLineY);
1414 TCanvas* c =
new TCanvas(cName.c_str(), cName.c_str(), 1800, 900);
1417 string histNameXY =
"hXY_mirror_segments_sphere_lineX"
1418 + to_string(orderedLineX) +
"_lineY"
1419 + to_string(orderedLineY);
1420 TH2D* hXY =
new TH2D(histNameXY.c_str(),
1421 (histNameXY +
"hXY;X [mum];Y [mum];").c_str(),
1428 vector<int> colors = {kBlack,
1441 gPad->SetRightMargin(0.10);
1442 for (
size_t i = 0;
i < data.size();
i++) {
1443 if (data[
i].fOrderedLineX == orderedLineX)
1445 data[
i].fTLSph, data[
i].fTRSph, data[
i].fBLSph, data[
i].fBRSph, kBlue);
1446 if (data[
i].fOrderedLineY == orderedLineY)
1448 data[
i].fTLSph, data[
i].fTRSph, data[
i].fBLSph, data[
i].fBRSph, kRed);
1451 double hSize = 20000;
1452 string histNameZX =
"hZX_mirror_segments_sphere_lineX"
1453 + to_string(orderedLineX) +
"_lineY"
1454 + to_string(orderedLineY);
1455 TH2D* hZX =
new TH2D(histNameZX.c_str(),
1456 (histNameZX +
";Z [mum];X(Y) [mum];").c_str(),
1458 data[0].fBRSph.Z() - 0.25 * hSize,
1459 data[0].fBRSph.Z() + hSize,
1465 gPad->SetRightMargin(0.10);
1466 for (
size_t i = 0;
i < data.size();
i++) {
1467 if (data[
i].fOrderedLineX == orderedLineX) {
1468 TLine* mirrorLineSeg =
new TLine(data[
i].fBRSph.Z(),
1471 data[
i].fTRSph.Y());
1472 mirrorLineSeg->SetLineColor(kBlue);
1473 mirrorLineSeg->Draw();
1476 if (data[
i].fOrderedLineY == orderedLineY) {
1477 TLine* mirrorLineSeg =
new TLine(data[
i].fTRSph.Z(),
1480 data[
i].fTLSph.X());
1481 mirrorLineSeg->SetLineColor(kRed);
1482 mirrorLineSeg->Draw();
1541 TLine* line1 =
new TLine(tl.X(), tl.Y(), tr.X(), tr.Y());
1542 line1->SetLineColor(color);
1545 TLine* line2 =
new TLine(tr.X(), tr.Y(), br.X(), br.Y());
1546 line2->SetLineColor(color);
1549 TLine* line3 =
new TLine(br.X(), br.Y(), bl.X(), bl.Y());
1550 line3->SetLineColor(color);
1553 TLine* line4 =
new TLine(bl.X(), bl.Y(), tl.X(), tl.Y());
1554 line4->SetLineColor(color);
1564 double x = inPos->X() - cV->X();
1565 double y = inPos->Y() - cV->Y();
1566 double z = inPos->Z() - cV->Z();
1568 double sinY =
sin(rotY);
1569 double cosY =
cos(rotY);
1570 double sinX =
sin(rotX);
1571 double cosX =
cos(rotX);
1573 double xNew =
x * cosX -
y * sinX * sinY + z * cosY * sinX + cV->X();
1574 double yNew =
y * cosY + z * sinY + cV->Y();
1575 double zNew = -
x * sinX -
y * sinY * cosX + z * cosY * cosX + cV->Z();
1577 outPos->SetXYZ(xNew, yNew, zNew);