CbmRoot
Loading...
Searching...
No Matches
CbmRichProjectionProducer2.cxx
Go to the documentation of this file.
1/* Copyright (C) 2019 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Florian Uhlig [committer] */
4
5// ---------- Original Headers ---------- //
7
8#include "CbmRichHit.h"
9#include "FairRootManager.h"
10#include "TClonesArray.h"
11
12#include <Logger.h>
13
14// ---------- Included Headers ---------- //
15#include "CbmMCTrack.h"
16#include "CbmRichGeoManager.h"
17#include "CbmRichHitProducer.h"
19#include "CbmRichPoint.h"
20#include "CbmTrackMatchNew.h"
21#include "CbmUtils.h"
22#include "FairTrackParam.h"
23#include "TGeoManager.h"
24#include "TMatrixFSym.h"
25
26class TGeoNode;
27class TGeoVolume;
28
30 : fTrackParams(NULL)
31 , fMCTracks(NULL)
32 , fRichPoints(NULL)
33 , fOutputDir("")
34 , fNumbAxis("")
35 , fTile("")
36 , fEventNum(0)
37{
38}
39
41{
42 FairRootManager* fmanager = FairRootManager::Instance();
43 fmanager->Write();
44}
45
47{
48 LOG(info) << "CbmRichProjectionProducerAnalytical::Init()";
49 FairRootManager* manager = FairRootManager::Instance();
50
51 fTrackParams = (TClonesArray*) manager->GetObject("RichTrackParamZ");
52 if (NULL == fTrackParams) {
53 Fatal("CbmRichProjectionProducerAnalytical::Init", "No RichTrackParamZ array !");
54 }
55
56 fMCTracks = (TClonesArray*) manager->GetObject("MCTrack");
57 if (NULL == fMCTracks) {
58 Fatal("CbmRichCorrectionVector::Init", "No MCTracks array !");
59 }
60
61 fRichPoints = (TClonesArray*) manager->GetObject("RichPoint");
62 if (NULL == fRichPoints) {
63 Fatal("CbmRichCorrectionVector::Init", "No RichPoint array !");
64 }
65}
66
67void CbmRichProjectionProducer2::DoProjection(TClonesArray* projectedPoint)
68{
69 cout << endl
70 << "//"
71 "--------------------------------------------------------------------"
72 "------------------------------------------//"
73 << endl;
74 cout << "//-------------------------------- CbmRichProjectionProducer2: Do "
75 "Projection ---------------------------------//"
76 << endl
77 << endl;
78 cout << "//"
79 "--------------------------------------------------------------------"
80 "--------------------------------------------------//"
81 << endl;
82
83 fEventNum++;
84 //LOG(debug2) << "CbmRichProjectionProducer2 : Event #" << fEventNum;
85 cout << "CbmRichProjectionProducer2 : Event #" << fEventNum << endl;
86
88 Double_t pmtPlaneX = gp->fPmt.fPlaneX;
89 Double_t pmtPlaneY = gp->fPmt.fPlaneY;
90 Double_t pmtWidth = gp->fPmt.fWidth;
91 Double_t pmtHeight = gp->fPmt.fHeight;
92
93 projectedPoint->Delete();
94 TMatrixFSym covMat(5);
95 for (Int_t iMatrix = 0; iMatrix < 5; iMatrix++) {
96 for (Int_t jMatrix = 0; jMatrix <= iMatrix; jMatrix++) {
97 covMat(iMatrix, jMatrix) = 0;
98 }
99 }
100 covMat(0, 0) = covMat(1, 1) = covMat(2, 2) = covMat(3, 3) = covMat(4, 4) = 1.e-4;
101
102 for (Int_t j = 0; j < fTrackParams->GetEntriesFast(); j++) {
103 FairTrackParam* point = (FairTrackParam*) fTrackParams->At(j);
104 new ((*projectedPoint)[j]) FairTrackParam(0., 0., 0., 0., 0., 0., covMat);
105
106 // check if Array was filled
107 if (point->GetX() == 0 && point->GetY() == 0 && point->GetZ() == 0 && point->GetTx() == 0 && point->GetTy() == 0)
108 continue;
109 if (point->GetQp() == 0) continue;
110
111 Double_t xDet = 0., yDet = 0., zDet = 0.;
112 Double_t* pmtPt;
113 pmtPt = ProjectionProducer(point);
114 xDet = pmtPt[0];
115 yDet = pmtPt[1];
116 zDet = pmtPt[2];
117
118 //check that crosspoint inside the plane
119 Double_t marginX = 2.; // [cm]
120 Double_t marginY = 2.; // [cm]
121 // upper pmt planes
122 Double_t pmtYTop = TMath::Abs(pmtPlaneY) + pmtHeight + marginY;
123 Double_t pmtYBottom = TMath::Abs(pmtPlaneY) - pmtHeight - marginY;
124 Double_t absYDet = TMath::Abs(yDet);
125 Bool_t isYOk = (absYDet <= pmtYTop && absYDet >= pmtYBottom);
126
127 Double_t pmtXMin = -TMath::Abs(pmtPlaneX) - pmtWidth - marginX;
128 Double_t pmtXMax = TMath::Abs(pmtPlaneX) + pmtWidth + marginX;
130 Bool_t isXOk = (xDet >= pmtXMin && xDet <= pmtXMax);
131
132 if (isYOk && isXOk) {
133 FairTrackParam richtrack(xDet, yDet, zDet, 0., 0., 0., covMat);
134 *(FairTrackParam*) (projectedPoint->At(j)) = richtrack;
135 }
136 }
137}
138
139Double_t* CbmRichProjectionProducer2::ProjectionProducer(FairTrackParam* trackParam)
140{
141 cout << "//------------------------------ CbmRichProjectionProducer2: "
142 "Projection Producer ------------------------------//"
143 << endl
144 << endl;
145
146 static Double_t pmtPt[3];
147
148 Int_t NofPMTPoints = fRichPoints->GetEntriesFast();
149
150 // Declaration of points coordinates.
151 Double_t sphereRadius = 300., constantePMT = 0.;
152 vector<Double_t> ptM(3), ptC(3), ptCNew(3), momR1(3), ptR1(3), normalPMT(3), ptR2Mirr(3), ptR2Center(3), ptPMirr(3),
153 ptPR2(3), ptTileCenter(3);
154 vector<Double_t> ptCIdeal(3), ptR2CenterUnCorr(3), ptR2CenterIdeal(3), ptR2MirrUnCorr(3), ptR2MirrIdeal(3),
155 ptPMirrUnCorr(3), ptPMirrIdeal(3), ptPR2UnCorr(3), ptPR2Ideal(3);
156 TVector3 outPos, outPosUnCorr, outPosIdeal;
157 // Declaration of ring parameters.
158 Double_t ringCenter[] = {0., 0., 0.}, distToExtrapTrackHit = 0., distToExtrapTrackHitInPlane = 0.;
159 //Declarations related to geometry.
160 Int_t pmtTrackID = -1, pmtMotherID = -100;
161 TGeoNavigator* navi;
162
163 ptR1.at(0) = trackParam->GetX();
164 ptR1.at(1) = trackParam->GetY();
165 ptR1.at(2) = trackParam->GetZ();
166 Double_t nx = 0., ny = 0., nz = 0.;
167 CbmRichNavigationUtil2::GetDirCos(trackParam, nx, ny, nz);
168 TVector3 dirCos;
169 dirCos.SetXYZ(nx, ny, nz);
170 GetPmtNormal(NofPMTPoints, normalPMT, constantePMT);
171 cout << "Calculated normal vector to PMT plane = {" << normalPMT.at(0) << ", " << normalPMT.at(1) << ", "
172 << normalPMT.at(2) << "} and constante d = " << constantePMT << endl
173 << endl;
174
175 TVector3 mirrorPoint;
176 TString mirrorIntersection1 =
177 CbmRichNavigationUtil2::FindIntersection(trackParam, mirrorPoint, "mirror_tile_type", navi);
178 ptM.at(0) = mirrorPoint.x();
179 ptM.at(1) = mirrorPoint.y();
180 ptM.at(2) = mirrorPoint.z();
181 cout << "mirrorIntersection1: " << mirrorIntersection1 << endl;
182 cout << "Mirror point coordinates = {" << mirrorPoint.x() << ", " << mirrorPoint.y() << ", " << mirrorPoint.z() << "}"
183 << endl;
184 TString mirrorIntersection = "/cave_1/rich1_0/richContainer_333/rich_gas_329/mirror_full_half_321/"
185 "mirror_tile_2_0_148/mirror_tile_type2"
186 "_inter_108/mirror_tile_type2_94/"
187 + mirrorIntersection1;
188 cout << "mirrorIntersection: " << mirrorIntersection << endl;
189
190 if (mirrorIntersection1) {
191 //navi->cd(mirrorIntersection1);
192 //navi = gGeoManager->GetCurrentNavigator();
193 navi->Dump();
194 cout << "Navigator path: " << navi->GetPath() << endl;
195 cout << "Coordinates of sphere center: " << endl;
196 navi->GetCurrentMatrix()->Print();
197 ptCIdeal.at(0) = navi->GetCurrentMatrix()->GetTranslation()[0];
198 ptCIdeal.at(1) = navi->GetCurrentMatrix()->GetTranslation()[1];
199 ptCIdeal.at(2) = navi->GetCurrentMatrix()->GetTranslation()[2];
200 cout << "Coordinates of tile center: " << endl;
201 navi->GetMotherMatrix()->Print();
202 ptC.at(0) = 0., ptC.at(1) = 132.594000,
203 ptC.at(2) = 54.267226; // Theoretical coordinates of point C.
204 cout << "Sphere center coordinates of the aligned mirror tile, ideal = {" << ptCIdeal.at(0) << ", "
205 << ptCIdeal.at(1) << ", " << ptCIdeal.at(2) << "}" << endl;
206 cout << "Sphere center coordinates of the rotated mirror tile, w/ "
207 "GeoManager, = {"
208 << ptC.at(0) << ", " << ptC.at(1) << ", " << ptC.at(2) << "} and sphere inner radius = " << sphereRadius
209 << endl
210 << endl;
211 //ptCNew = RotateSphereCenter(ptTileCenter, ptC, navi);
212
213 cout << "FairTrackParam Point coordinates = {" << ptR1.at(0) << ", " << ptR1.at(1) << ", " << ptR1.at(2) << "}"
214 << endl;
215 cout << "And FairTrackParam Point direction cosines = {" << ptR1.at(3) << ", " << ptR1.at(4) << ", " << ptR1.at(5)
216 << "}" << endl;
217 cout << "Mirror Point coordinates = {" << ptM.at(0) << ", " << ptM.at(1) << ", " << ptM.at(2) << "}" << endl;
218
219 ComputeR2(ptR2CenterUnCorr, ptR2MirrUnCorr, ptM, ptC, ptR1, navi, "Uncorrected");
220 ComputeR2(ptR2Center, ptR2Mirr, ptM, ptC, ptR1, navi, "Corrected");
221 ComputeR2(ptR2CenterIdeal, ptR2MirrIdeal, ptM, ptCIdeal, ptR1, navi, "Uncorrected");
222
223 ComputeP(ptPMirrUnCorr, ptPR2UnCorr, normalPMT, ptM, ptR2MirrUnCorr, constantePMT);
224 ComputeP(ptPMirr, ptPR2, normalPMT, ptM, ptR2Mirr, constantePMT);
225 ComputeP(ptPMirrIdeal, ptPR2Ideal, normalPMT, ptM, ptR2MirrIdeal, constantePMT);
226
227 TVector3 inPosUnCorr(ptPMirrUnCorr.at(0), ptPMirrUnCorr.at(1), ptPMirrUnCorr.at(2));
228 CbmRichGeoManager::GetInstance().RotatePoint(&inPosUnCorr, &outPosUnCorr);
229 cout << "New mirror points coordinates = {" << outPosUnCorr.x() << ", " << outPosUnCorr.y() << ", "
230 << outPosUnCorr.z() << "}" << endl;
231 TVector3 inPos(ptPMirr.at(0), ptPMirr.at(1), ptPMirr.at(2));
233 cout << "New mirror points coordinates = {" << outPos.x() << ", " << outPos.y() << ", " << outPos.z() << "}"
234 << endl;
235 TVector3 inPosIdeal(ptPMirrIdeal.at(0), ptPMirrIdeal.at(1), ptPMirrIdeal.at(2));
236 CbmRichGeoManager::GetInstance().RotatePoint(&inPosIdeal, &outPosIdeal);
237 cout << endl
238 << "New mirror points coordinates = {" << outPosIdeal.x() << ", " << outPosIdeal.y() << ", " << outPosIdeal.z()
239 << "}" << endl
240 << endl;
241 }
242 else {
243 cout << "No mirror intersection found ..." << endl;
244 outPos.SetXYZ(0, 0, 0);
245 }
246
247 pmtPt[0] = outPos.x();
248 pmtPt[1] = outPos.y();
249 pmtPt[2] = outPos.z();
250 return pmtPt;
251}
252
253void CbmRichProjectionProducer2::GetPmtNormal(Int_t NofPMTPoints, vector<Double_t>& normalPMT, Double_t& normalCste)
254{
255 //cout << endl << "//------------------------------ CbmRichProjectionProducer2: Calculate PMT Normal ------------------------------//" << endl << endl;
256
257 Int_t pmtTrackID, pmtMotherID;
258 Double_t buffNormX = 0., buffNormY = 0., buffNormZ = 0., k = 0., scalarProd = 0.;
259 Double_t pmtPt[] = {0., 0., 0.};
260 Double_t a[] = {0., 0., 0.}, b[] = {0., 0., 0.}, c[] = {0., 0., 0.};
261 CbmMCTrack* track;
262
263 /*
264 * Selection of three points (A, B, C), which form a plan and from which the calculation of the normal of the plan can be computed.
265 * Formula used is: vect(AB) x vect(AC) = normal.
266 * Normalize the normal vector obtained and check with three random points from the PMT plane, whether the scalar product is equal to zero.
267 */
268 for (Int_t iPmt = 0; iPmt < NofPMTPoints; iPmt++) {
269 CbmRichPoint* pmtPoint = (CbmRichPoint*) fRichPoints->At(iPmt);
270 pmtTrackID = pmtPoint->GetTrackID();
271 track = (CbmMCTrack*) fMCTracks->At(pmtTrackID);
272 pmtMotherID = track->GetMotherId();
273 //a[0] = pmtPoint->GetX(), a[1] = pmtPoint->GetY(), a[2] = pmtPoint->GetZ();
274 cout << "a[0] = " << a[0] << ", a[1] = " << a[1] << " et a[2] = " << a[2] << endl;
275 break;
276 }
277 for (Int_t iPmt = 0; iPmt < NofPMTPoints; iPmt++) {
278 CbmRichPoint* pmtPoint = (CbmRichPoint*) fRichPoints->At(iPmt);
279 pmtTrackID = pmtPoint->GetTrackID();
280 track = (CbmMCTrack*) fMCTracks->At(pmtTrackID);
281 pmtMotherID = track->GetMotherId();
282 //cout << "PMT Point coordinates; x = " << pmtPoint->GetX() << ", y = " << pmtPoint->GetY() << " and z = " << pmtPoint->GetZ() << endl;
283 if (TMath::Sqrt(TMath::Power(a[0] - pmtPoint->GetX(), 2) + TMath::Power(a[1] - pmtPoint->GetY(), 2)
284 + TMath::Power(a[2] - pmtPoint->GetZ(), 2))
285 > 7) {
286 //b[0] = pmtPoint->GetX(), b[1] = pmtPoint->GetY(), b[2] = pmtPoint->GetZ();
287 cout << "b[0] = " << b[0] << ", b[1] = " << b[1] << " et b[2] = " << b[2] << endl;
288 break;
289 }
290 }
291 for (Int_t iPmt = 0; iPmt < NofPMTPoints; iPmt++) {
292 CbmRichPoint* pmtPoint = (CbmRichPoint*) fRichPoints->At(iPmt);
293 pmtTrackID = pmtPoint->GetTrackID();
294 track = (CbmMCTrack*) fMCTracks->At(pmtTrackID);
295 pmtMotherID = track->GetMotherId();
296 //cout << "PMT Point coordinates; x = " << pmtPoint->GetX() << ", y = " << pmtPoint->GetY() << " and z = " << pmtPoint->GetZ() << endl;
297 if (TMath::Sqrt(TMath::Power(a[0] - pmtPoint->GetX(), 2) + TMath::Power(a[1] - pmtPoint->GetY(), 2)
298 + TMath::Power(a[2] - pmtPoint->GetZ(), 2))
299 > 7
300 && TMath::Sqrt(TMath::Power(b[0] - pmtPoint->GetX(), 2) + TMath::Power(b[1] - pmtPoint->GetY(), 2)
301 + TMath::Power(b[2] - pmtPoint->GetZ(), 2))
302 > 7) {
303 c[0] = pmtPoint->GetX(), c[1] = pmtPoint->GetY(), c[2] = pmtPoint->GetZ();
304 //cout << "c[0] = " << c[0] << ", c[1] = " << c[1] << " et c[2] = " << c[2] << endl;
305 break;
306 }
307 }
308
309 k = (b[0] - a[0]) / (c[0] - a[0]);
310 if ((b[1] - a[1]) - (k * (c[1] - a[1])) == 0 || (b[2] - a[2]) - (k * (c[2] - a[2])) == 0) {
311 cout << "Error in normal calculation, vect_AB and vect_AC are collinear." << endl;
312 }
313 else {
314 buffNormX = (b[1] - a[1]) * (c[2] - a[2]) - (b[2] - a[2]) * (c[1] - a[1]);
315 buffNormY = (b[2] - a[2]) * (c[0] - a[0]) - (b[0] - a[0]) * (c[2] - a[2]);
316 buffNormZ = (b[0] - a[0]) * (c[1] - a[1]) - (b[1] - a[1]) * (c[0] - a[0]);
317 normalPMT.at(0) =
318 buffNormX / TMath::Sqrt(TMath::Power(buffNormX, 2) + TMath::Power(buffNormY, 2) + TMath::Power(buffNormZ, 2));
319 normalPMT.at(1) =
320 buffNormY / TMath::Sqrt(TMath::Power(buffNormX, 2) + TMath::Power(buffNormY, 2) + TMath::Power(buffNormZ, 2));
321 normalPMT.at(2) =
322 buffNormZ / TMath::Sqrt(TMath::Power(buffNormX, 2) + TMath::Power(buffNormY, 2) + TMath::Power(buffNormZ, 2));
323 }
324
325 CbmRichPoint* pmtPoint1 = (CbmRichPoint*) fRichPoints->At(20);
326 scalarProd = normalPMT.at(0) * (pmtPoint1->GetX() - a[0]) + normalPMT.at(1) * (pmtPoint1->GetY() - a[1])
327 + normalPMT.at(2) * (pmtPoint1->GetZ() - a[2]);
328 //cout << "1st scalar product between vectAM and normale = " << scalarProd << endl;
329 // To determine the constant term of the plane equation, inject the coordinates of a pmt point, which should solve it: a*x+b*y+c*z+d=0.
330 normalCste =
331 -1
332 * (normalPMT.at(0) * pmtPoint1->GetX() + normalPMT.at(1) * pmtPoint1->GetY() + normalPMT.at(2) * pmtPoint1->GetZ());
333 CbmRichPoint* pmtPoint2 = (CbmRichPoint*) fRichPoints->At(15);
334 scalarProd = normalPMT.at(0) * (pmtPoint2->GetX() - a[0]) + normalPMT.at(1) * (pmtPoint2->GetY() - a[1])
335 + normalPMT.at(2) * (pmtPoint2->GetZ() - a[2]);
336 //cout << "2nd scalar product between vectAM and normale = " << scalarProd << endl;
337 CbmRichPoint* pmtPoint3 = (CbmRichPoint*) fRichPoints->At(25);
338 scalarProd = normalPMT.at(0) * (pmtPoint3->GetX() - a[0]) + normalPMT.at(1) * (pmtPoint3->GetY() - a[1])
339 + normalPMT.at(2) * (pmtPoint3->GetZ() - a[2]);
340 //cout << "3nd scalar product between vectAM and normale = " << scalarProd << endl;
341}
342
343void CbmRichProjectionProducer2::ComputeR2(vector<Double_t>& ptR2Center, vector<Double_t>& ptR2Mirr,
344 vector<Double_t> ptM, vector<Double_t> ptC, vector<Double_t> ptR1,
345 TGeoNavigator* navi, TString s)
346{
347 cout << endl
348 << "//------------------------------ CbmRichCorrection: ComputeR2 "
349 "------------------------------//"
350 << endl
351 << endl;
352
353 vector<Double_t> normalMirr(3), ptCNew(3), ptTileCenter(3);
354 Double_t t1 = 0., t2 = 0., t3 = 0.;
355
356 if (s == "Corrected") {
357 // Use the correction information from text file, to the tile sphere center:
358 // Reading misalignment information from correction_param.txt text file.
359 vector<Double_t> outputFit(4);
360 ifstream corr_file;
361 TString str = fOutputDir + "correction_param_" + fNumbAxis + fTile + ".txt";
362 corr_file.open(str);
363 if (corr_file.is_open()) {
364 for (Int_t i = 0; i < 4; i++) {
365 corr_file >> outputFit.at(i);
366 }
367 corr_file.close();
368 }
369 else {
370 cout << "Error in CbmRichCorrection: unable to open parameter file!" << endl << endl;
371 sleep(5);
372 }
373 cout << "Misalignment parameters read from file = [" << outputFit.at(0) << " ; " << outputFit.at(1) << " ; "
374 << outputFit.at(2) << " ; " << outputFit.at(3) << "]" << endl;
375
376 ptCNew.at(0) = TMath::Abs(ptC.at(0) - TMath::Abs(outputFit.at(3)));
377 ptCNew.at(1) = TMath::Abs(ptC.at(1) - TMath::Abs(outputFit.at(2)));
378 //ptCNew.at(0) = ptC.at(0) - outputFit.at(3);
379 //ptCNew.at(1) = ptC.at(1) - outputFit.at(2);
380 ptCNew.at(2) = ptC.at(2);
381 ptTileCenter.at(0) = navi->GetMotherMatrix()->GetTranslation()[0];
382 ptTileCenter.at(1) = navi->GetMotherMatrix()->GetTranslation()[1];
383 ptTileCenter.at(2) = navi->GetMotherMatrix()->GetTranslation()[2];
384 cout << "Mirror tile center coordinates = {" << ptTileCenter.at(0) << ", " << ptTileCenter.at(1) << ", "
385 << ptTileCenter.at(2) << "}" << endl;
386 Double_t x = 0., y = 0., z = 0., dist = 0., dist2 = 0., z2 = 0.;
387 x = TMath::Power(ptCNew.at(0) - ptTileCenter.at(0), 2);
388 y = TMath::Power(ptCNew.at(1) - ptTileCenter.at(1), 2);
389 z = TMath::Power(ptCNew.at(2) - ptTileCenter.at(2), 2);
390 dist = TMath::Sqrt(x + y + z);
391 z2 = ptTileCenter.at(2) - TMath::Sqrt(TMath::Power(300, 2) - x - y) - ptCNew.at(2);
392 cout << "{x, y, z} = {" << x << ", " << y << ", " << z << "}, dist = " << dist << " and z2 = " << z2 << endl;
393 dist2 = TMath::Sqrt(x + y + TMath::Power(z2 - ptTileCenter.at(2), 2));
394 cout << "dist2 = " << dist2 << endl;
395 ptCNew.at(2) += z2;
396 cout << "Sphere center coordinates of the rotated mirror tile, after "
397 "correction, = {"
398 << ptCNew.at(0) << ", " << ptCNew.at(1) << ", " << ptCNew.at(2) << "}" << endl;
399 }
400 else if (s == "Uncorrected") {
401 // Keep the same tile sphere center, with no correction information.
402 ptCNew = ptC;
403 cout << "Sphere center coordinates of the rotated mirror tile, without "
404 "correction = {"
405 << ptCNew.at(0) << ", " << ptCNew.at(1) << ", " << ptCNew.at(2) << "}" << endl;
406 }
407 else {
408 cout << "No input given in function ComputeR2! Uncorrected parameters for "
409 "the sphere center of the tile will be used!"
410 << endl;
411 ptCNew = ptC;
412 cout << "Sphere center coordinates of the rotated mirror tile, without "
413 "correction = {"
414 << ptCNew.at(0) << ", " << ptCNew.at(1) << ", " << ptCNew.at(2) << "}" << endl;
415 }
416
417 normalMirr.at(0) = (ptCNew.at(0) - ptM.at(0))
418 / TMath::Sqrt(TMath::Power(ptCNew.at(0) - ptM.at(0), 2) + TMath::Power(ptCNew.at(1) - ptM.at(1), 2)
419 + TMath::Power(ptCNew.at(2) - ptM.at(2), 2));
420 normalMirr.at(1) = (ptCNew.at(1) - ptM.at(1))
421 / TMath::Sqrt(TMath::Power(ptCNew.at(0) - ptM.at(0), 2) + TMath::Power(ptCNew.at(1) - ptM.at(1), 2)
422 + TMath::Power(ptCNew.at(2) - ptM.at(2), 2));
423 normalMirr.at(2) = (ptCNew.at(2) - ptM.at(2))
424 / TMath::Sqrt(TMath::Power(ptCNew.at(0) - ptM.at(0), 2) + TMath::Power(ptCNew.at(1) - ptM.at(1), 2)
425 + TMath::Power(ptCNew.at(2) - ptM.at(2), 2));
426 //cout << "Calculated and normalized normal of mirror tile = {" << normalMirr.at(0) << ", " << normalMirr.at(1) << ", " << normalMirr.at(2) << "}" << endl;
427
428 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))
429 + (ptR1.at(2) - ptM.at(2)) * (ptCNew.at(2) - ptM.at(2)))
430 / (TMath::Power(ptCNew.at(0) - ptM.at(0), 2) + TMath::Power(ptCNew.at(1) - ptM.at(1), 2)
431 + TMath::Power(ptCNew.at(2) - ptM.at(2), 2));
432 ptR2Center.at(0) = 2 * (ptM.at(0) + t1 * (ptCNew.at(0) - ptM.at(0))) - ptR1.at(0);
433 ptR2Center.at(1) = 2 * (ptM.at(1) + t1 * (ptCNew.at(1) - ptM.at(1))) - ptR1.at(1);
434 ptR2Center.at(2) = 2 * (ptM.at(2) + t1 * (ptCNew.at(2) - ptM.at(2))) - ptR1.at(2);
435 t2 =
436 ((ptR1.at(0) - ptCNew.at(0)) * (ptCNew.at(0) - ptM.at(0)) + (ptR1.at(1) - ptCNew.at(1)) * (ptCNew.at(1) - ptM.at(1))
437 + (ptR1.at(2) - ptCNew.at(2)) * (ptCNew.at(2) - ptM.at(2)))
438 / (TMath::Power(ptCNew.at(0) - ptM.at(0), 2) + TMath::Power(ptCNew.at(1) - ptM.at(1), 2)
439 + TMath::Power(ptCNew.at(2) - ptM.at(2), 2));
440 ptR2Mirr.at(0) = 2 * (ptCNew.at(0) + t2 * (ptCNew.at(0) - ptM.at(0))) - ptR1.at(0);
441 ptR2Mirr.at(1) = 2 * (ptCNew.at(1) + t2 * (ptCNew.at(1) - ptM.at(1))) - ptR1.at(1);
442 ptR2Mirr.at(2) = 2 * (ptCNew.at(2) + t2 * (ptCNew.at(2) - ptM.at(2))) - ptR1.at(2);
443
444 cout << "Coordinates of point R2 on reflective plane after reflection on the "
445 "mirror tile:"
446 << endl;
447 //cout << "* using mirror point M to define \U00000394: {" << ptR2Center.at(0) << ", " << ptR2Center.at(1) << ", " << ptR2Center.at(2) << "}" << endl;
448 cout << "* using sphere center C to define \U00000394: {" << ptR2Mirr.at(0) << ", " << ptR2Mirr.at(1) << ", "
449 << ptR2Mirr.at(2) << "}" << endl;
450}
451
452void CbmRichProjectionProducer2::ComputeP(vector<Double_t>& ptPMirr, vector<Double_t>& ptPR2,
453 vector<Double_t> normalPMT, vector<Double_t> ptM, vector<Double_t> ptR2Mirr,
454 Double_t constantePMT)
455{
456 cout << endl
457 << "//------------------------------ CbmRichCorrection: ComputeP "
458 "------------------------------//"
459 << endl
460 << endl;
461
462 Double_t k1 = 0., k2 = 0., checkCalc1 = 0., checkCalc2 = 0.;
463
464 k1 = -1
465 * ((normalPMT.at(0) * ptM.at(0) + normalPMT.at(1) * ptM.at(1) + normalPMT.at(2) * ptM.at(2) + constantePMT)
466 / (normalPMT.at(0) * (ptR2Mirr.at(0) - ptM.at(0)) + normalPMT.at(1) * (ptR2Mirr.at(1) - ptM.at(1))
467 + normalPMT.at(2) * (ptR2Mirr.at(2) - ptM.at(2))));
468 ptPMirr.at(0) = ptM.at(0) + k1 * (ptR2Mirr.at(0) - ptM.at(0));
469 ptPMirr.at(1) = ptM.at(1) + k1 * (ptR2Mirr.at(1) - ptM.at(1));
470 ptPMirr.at(2) = ptM.at(2) + k1 * (ptR2Mirr.at(2) - ptM.at(2));
471 k2 = -1
472 * ((normalPMT.at(0) * ptR2Mirr.at(0) + normalPMT.at(1) * ptR2Mirr.at(1) + normalPMT.at(2) * ptR2Mirr.at(2)
473 + constantePMT)
474 / (normalPMT.at(0) * (ptR2Mirr.at(0) - ptM.at(0)) + normalPMT.at(1) * (ptR2Mirr.at(1) - ptM.at(1))
475 + normalPMT.at(2) * (ptR2Mirr.at(2) - ptM.at(2))));
476 ptPR2.at(0) = ptR2Mirr.at(0) + k2 * (ptR2Mirr.at(0) - ptM.at(0));
477 ptPR2.at(1) = ptR2Mirr.at(1) + k2 * (ptR2Mirr.at(1) - ptM.at(1));
478 ptPR2.at(2) = ptR2Mirr.at(2) + k2 * (ptR2Mirr.at(2) - ptM.at(2));
479 cout << "Coordinates of point P on PMT plane, after reflection on the mirror "
480 "tile and extrapolation to the PMT plane:"
481 << endl;
482 cout << "* using mirror point M to define \U0001D49F ': {" << ptPMirr.at(0) << ", " << ptPMirr.at(1) << ", "
483 << ptPMirr.at(2) << "}" << endl;
484 //cout << "* using reflected point R2 to define \U0001D49F ': {" << ptPR2.at(0) << ", " << ptPR2.at(1) << ", " << ptPR2.at(2) << "}" << endl;
485 checkCalc1 =
486 ptPMirr.at(0) * normalPMT.at(0) + ptPMirr.at(1) * normalPMT.at(1) + ptPMirr.at(2) * normalPMT.at(2) + constantePMT;
487 cout << "Check whether extrapolated track point on PMT plane verifies its "
488 "equation (value should be 0.):"
489 << endl;
490 cout << "* using mirror point M, checkCalc = " << checkCalc1 << endl;
491 checkCalc2 =
492 ptPR2.at(0) * normalPMT.at(0) + ptPR2.at(1) * normalPMT.at(1) + ptPR2.at(2) * normalPMT.at(2) + constantePMT;
493 //cout << "* using reflected point R2, checkCalc = " << checkCalc2 << endl;
494}
495
ClassImp(CbmConverterManager)
Class for producing RICH hits directly from MCPoints.
int32_t GetMotherId() const
Definition CbmMCTrack.h:69
void RotatePoint(TVector3 *inPos, TVector3 *outPos, Bool_t noTilting=false)
CbmRichRecGeoPar * fGP
static CbmRichGeoManager & GetInstance()
static void GetDirCos(const FairTrackParam *par, Double_t &nx, Double_t &ny, Double_t &nz)
static string FindIntersection(const FairTrackParam *par, TVector3 &crossPoint, const string &volumeName, TGeoNavigator *navi)
Double_t * ProjectionProducer(FairTrackParam *point)
void GetPmtNormal(Int_t NofPMTPoints, vector< Double_t > &normalPMT, Double_t &normalCste)
virtual void DoProjection(TClonesArray *projectedPoint)
virtual void Init()
Initialization in case one needs to initialize some TCloneArrays.
void ComputeR2(vector< Double_t > &ptR2Center, vector< Double_t > &ptR2Mirr, vector< Double_t > ptM, vector< Double_t > ptC, vector< Double_t > ptR1, TGeoNavigator *navi, TString s)
void ComputeP(vector< Double_t > &ptPMirr, vector< Double_t > &ptPR2, vector< Double_t > normalPMT, vector< Double_t > ptM, vector< Double_t > ptR2Mirr, Double_t normalCste)
PMT parameters for the RICH geometry.
CbmRichRecGeoParPmt fPmt