11 #include "FairGeoNode.h"
12 #include "FairGeoTransform.h"
13 #include "FairGeoVector.h"
14 #include "FairRootManager.h"
16 #include "FairRunAna.h"
17 #include "FairRuntimeDb.h"
18 #include "FairTrackParam.h"
19 #include "TGeoManager.h"
21 #include "TClonesArray.h"
22 #include "TMatrixFSym.h"
29 #include "FairLogger.h"
37 #include "../alignment/CbmRichMirrorMisalignmentCorrectionUtils.h"
41 : fTrackParams(NULL), fNHits(0), fEventNum(0) {}
44 FairRootManager* fManager = FairRootManager::Instance();
50 LOG(info) <<
"CbmRichProjectionProducerAnalytical::Init()";
51 FairRootManager* manager = FairRootManager::Instance();
53 fTrackParams = (TClonesArray*) manager->GetObject(
"RichTrackParamZ");
55 Fatal(
"CbmRichProjectionProducerAnalytical::Init:",
56 "No RichTrackParamZ array!");
66 cout <<
"CbmRichProjectionProducerAnalytical:: event " <<
fEventNum << endl;
75 TMatrixFSym covMat(5);
76 for (Int_t
i = 0;
i < 5;
i++) {
77 for (Int_t j = 0; j <=
i; j++) {
81 covMat(0, 0) = covMat(1, 1) = covMat(2, 2) = covMat(3, 3) = covMat(4, 4) =
84 for (Int_t j = 0; j <
fTrackParams->GetEntriesFast(); j++) {
85 FairTrackParam* point = (FairTrackParam*)
fTrackParams->At(j);
86 new ((*richProj)[j]) FairTrackParam(0., 0., 0., 0., 0., 0., covMat);
89 if (point->GetX() == 0 && point->GetY() == 0 && point->GetZ() == 0
90 && point->GetTx() == 0 && point->GetTy() == 0)
92 if (point->GetQp() == 0)
continue;
95 TVector3 startP, momP, crossP, centerP;
98 Double_t p = 1. / TMath::Abs(point->GetQp());
100 if ((1 + point->GetTx() * point->GetTx() + point->GetTy() * point->GetTy())
103 / TMath::Sqrt(1 + point->GetTx() * point->GetTx()
104 + point->GetTy() * point->GetTy());
106 cout <<
" -E- RichProjectionProducer: strange value for calculating pz: "
107 << (1 + point->GetTx() * point->GetTx()
108 + point->GetTy() * point->GetTy())
113 Double_t px = pz * point->GetTx();
114 Double_t py = pz * point->GetTy();
115 momP.SetXYZ(px, py, pz);
116 point->Position(startP);
117 if ((mirrorY * startP.y()) < 0)
130 (momP.x() * (startP.x() - mirrorX) + momP.y() * (startP.y() - mirrorY)
131 + momP.z() * (startP.z() - mirrorZ));
133 (momP.x() * momP.x() + momP.y() * momP.y() + momP.z() * momP.z());
135 (startP.x() * startP.x() + mirrorX * mirrorX + startP.y() * startP.y()
136 + mirrorY * mirrorY + startP.z() * startP.z() + mirrorZ * mirrorZ
137 - 2 * startP.x() * mirrorX - 2 * startP.y() * mirrorY
138 - 2 * startP.z() * mirrorZ - mirrorR * mirrorR);
140 if ((RxP * RxP - normP2 * dist) > 0.) {
142 rho1 = (-RxP + TMath::Sqrt(RxP * RxP - normP2 * dist)) / normP2;
144 cout <<
" Error in track extrapolation: momentum = 0 " << endl;
149 Double_t crossPx = startP.x() + rho1 * momP.x();
150 Double_t crossPy = startP.y() + rho1 * momP.y();
151 Double_t crossPz = startP.z() + rho1 * momP.z();
152 crossP.SetXYZ(crossPx, crossPy, crossPz);
156 if ((mirrorY * crossP.y()) < 0) {
159 (momP.x() * (startP.x() - mirrorX) + momP.y() * (startP.y() - mirrorY)
160 + momP.z() * (startP.z() - mirrorZ));
162 (momP.x() * momP.x() + momP.y() * momP.y() + momP.z() * momP.z());
164 (startP.x() * startP.x() + mirrorX * mirrorX + startP.y() * startP.y()
165 + mirrorY * mirrorY + startP.z() * startP.z() + mirrorZ * mirrorZ
166 - 2 * startP.x() * mirrorX - 2 * startP.y() * mirrorY
167 - 2 * startP.z() * mirrorZ - mirrorR * mirrorR);
169 if ((RxP * RxP - normP2 * dist) > 0.) {
171 rho1 = (-RxP + TMath::Sqrt(RxP * RxP - normP2 * dist)) / normP2;
173 cout <<
" Error in track extrapolation: momentum = 0 " << endl;
178 crossPx = startP.x() + rho1 * momP.x();
179 crossPy = startP.y() + rho1 * momP.y();
180 crossPz = startP.z() + rho1 * momP.z();
181 crossP.SetXYZ(crossPx, crossPy, crossPz);
184 centerP.SetXYZ(mirrorX, mirrorY, mirrorZ);
188 point, crossPoint,
"mirror_tile_");
195 TVector3 normP(crossP.x() - newCenterP.x(),
196 crossP.y() - newCenterP.y(),
197 crossP.z() - newCenterP.z());
199 normP = normP.Unit();
201 if ((normP.z() * momP.z()) < 0.)
202 normP = TVector3(-1. * normP.x(), -1. * normP.y(), -1. * normP.z());
206 normP.x() * momP.x() + normP.y() * momP.y() + normP.z() * momP.z();
209 ref.SetXYZ(2 * np * normP.x() - momP.x(),
210 2 * np * normP.y() - momP.y(),
211 2 * np * normP.z() - momP.z());
215 TVector3 inPos(0., 0., 0.), outPos(0., 0., 0.);
233 Fatal(
"CbmRichProjectionProducerAnalytical ",
"unknown geometry type");
240 FairTrackParam richtrack(
241 outPos.x(), outPos.y(), outPos.z(), 0., 0., 0., covMat);
242 *(FairTrackParam*) (
richProj->At(j)) = richtrack;
250 const string volumeName) {
261 std::map<string, std::pair<Double_t, Double_t>> mirrorCorrectionParamMap;
262 mirrorCorrectionParamMap =
264 for (std::map<
string, std::pair<Double_t, Double_t>>::iterator it =
265 mirrorCorrectionParamMap.begin();
266 it != mirrorCorrectionParamMap.end();
268 if (it->first == mirrorID) {
269 cout <<
"Map's first key: " << it->first
270 <<
" and pair: " << it->second.first <<
", " << it->second.second
272 newCenterP.SetX(centerP.X() + it->second.first);
273 newCenterP.SetY(centerP.Y() + it->second.second);
274 newCenterP.SetZ(centerP.Z());
346 string str1 =
"mirror_tile_", str2 =
"";
347 std::size_t found = volumeName.find(str1);
348 if (found != std::string::npos) {
350 Int_t end = str1.length() + 3;
351 str2 = volumeName.substr(found, end);
353 cout <<
"Mirror ID: " << str2 << endl;
359 const TVector3* centerP,
360 const TVector3* crossP,
362 TVector3* outPoint) {
379 "CbmRichProjectionProducerAnalytical::GetPmtIntersectionPointTwoWings ",
380 "Wrong geometry, this method could be used only for "
381 "CbmRichGeometryTypeTwoWings");
391 if (centerP->y() > 0) {
393 (-TMath::Sin(pmtPhi) * (pmtPlaneX - crossP->x())
394 - TMath::Sin(pmtTheta) * TMath::Cos(pmtPhi) * (pmtPlaneY - crossP->y())
395 + TMath::Cos(pmtTheta) * TMath::Cos(pmtPhi) * (pmtPlaneZ - crossP->z()))
396 / (-TMath::Sin(pmtPhi) * ref->x()
397 - TMath::Sin(pmtTheta) * TMath::Cos(pmtPhi) * ref->y()
398 + TMath::Cos(pmtTheta) * TMath::Cos(pmtPhi) * ref->z());
400 if (centerP->y() < 0) {
402 (-TMath::Sin(pmtPhi) * (pmtPlaneX - crossP->x())
403 - TMath::Sin(-pmtTheta) * TMath::Cos(pmtPhi) * (-pmtPlaneY - crossP->y())
404 + TMath::Cos(-pmtTheta) * TMath::Cos(pmtPhi) * (pmtPlaneZ - crossP->z()))
405 / (-TMath::Sin(pmtPhi) * ref->x()
406 - TMath::Sin(-pmtTheta) * TMath::Cos(pmtPhi) * ref->y()
407 + TMath::Cos(-pmtTheta) * TMath::Cos(pmtPhi) * ref->z());
411 Double_t xX = crossP->x() + ref->x() * rho2;
412 Double_t yY = crossP->y() + ref->y() * rho2;
413 Double_t zZ = crossP->z() + ref->z() * rho2;
416 if (centerP->y() > 0) {
417 rho2 = (-TMath::Sin(-pmtPhi) * (-pmtPlaneX - crossP->x())
418 - TMath::Sin(pmtTheta) * TMath::Cos(-pmtPhi)
419 * (pmtPlaneY - crossP->y())
420 + TMath::Cos(pmtTheta) * TMath::Cos(-pmtPhi)
421 * (pmtPlaneZ - crossP->z()))
422 / (-TMath::Sin(-pmtPhi) * ref->x()
423 - TMath::Sin(pmtTheta) * TMath::Cos(-pmtPhi) * ref->y()
424 + TMath::Cos(pmtTheta) * TMath::Cos(-pmtPhi) * ref->z());
426 if (centerP->y() < 0) {
427 rho2 = (-TMath::Sin(-pmtPhi) * (-pmtPlaneX - crossP->x())
428 - TMath::Sin(-pmtTheta) * TMath::Cos(-pmtPhi)
429 * (-pmtPlaneY - crossP->y())
430 + TMath::Cos(-pmtTheta) * TMath::Cos(-pmtPhi)
431 * (pmtPlaneZ - crossP->z()))
432 / (-TMath::Sin(-pmtPhi) * ref->x()
433 - TMath::Sin(-pmtTheta) * TMath::Cos(-pmtPhi) * ref->y()
434 + TMath::Cos(-pmtTheta) * TMath::Cos(-pmtPhi) * ref->z());
437 xX = crossP->x() + ref->x() * rho2;
438 yY = crossP->y() + ref->y() * rho2;
439 zZ = crossP->z() + ref->z() * rho2;
442 outPoint->SetXYZ(xX, yY, zZ);
447 const TVector3* centerP,
448 const TVector3* crossP,
450 TVector3* outPoint) {
453 Fatal(
"CbmRichProjectionProducerAnalytical::GetPmtIntersectionPointCyl ",
454 "Wrong geometry, this method could be used only for "
455 "CbmRichGeometryTypeCylindrical");
460 Double_t maxDist = 0.;
462 for (map<string, CbmRichRecGeoParPmt>::iterator it = gp->
fPmtMap.begin();
465 Double_t pmtPlaneX = it->second.fPlaneX;
466 Double_t pmtPlaneY = it->second.fPlaneY;
467 Double_t pmtPlaneZ = it->second.fPlaneZ;
468 Double_t pmtPhi = it->second.fPhi;
469 Double_t pmtTheta = it->second.fTheta;
471 if (!(pmtPlaneX >= 0 && pmtPlaneY >= 0))
continue;
475 if (centerP->y() > 0) {
477 (-TMath::Sin(pmtPhi) * (pmtPlaneX - crossP->x())
478 - TMath::Sin(pmtTheta) * TMath::Cos(pmtPhi) * (pmtPlaneY - crossP->y())
479 + TMath::Cos(pmtTheta) * TMath::Cos(pmtPhi)
480 * (pmtPlaneZ - crossP->z()))
481 / (-TMath::Sin(pmtPhi) * ref->x()
482 - TMath::Sin(pmtTheta) * TMath::Cos(pmtPhi) * ref->y()
483 + TMath::Cos(pmtTheta) * TMath::Cos(pmtPhi) * ref->z());
485 if (centerP->y() < 0) {
486 rho2 = (-TMath::Sin(pmtPhi) * (pmtPlaneX - crossP->x())
487 - TMath::Sin(-pmtTheta) * TMath::Cos(pmtPhi)
488 * (-pmtPlaneY - crossP->y())
489 + TMath::Cos(-pmtTheta) * TMath::Cos(pmtPhi)
490 * (pmtPlaneZ - crossP->z()))
491 / (-TMath::Sin(pmtPhi) * ref->x()
492 - TMath::Sin(-pmtTheta) * TMath::Cos(pmtPhi) * ref->y()
493 + TMath::Cos(-pmtTheta) * TMath::Cos(pmtPhi) * ref->z());
496 Double_t cxX = crossP->x() + ref->x() * rho2;
497 Double_t cyY = crossP->y() + ref->y() * rho2;
498 Double_t czZ = crossP->z() + ref->z() * rho2;
501 if (centerP->y() > 0) {
502 rho2 = (-TMath::Sin(-pmtPhi) * (-pmtPlaneX - crossP->x())
503 - TMath::Sin(pmtTheta) * TMath::Cos(-pmtPhi)
504 * (pmtPlaneY - crossP->y())
505 + TMath::Cos(pmtTheta) * TMath::Cos(-pmtPhi)
506 * (pmtPlaneZ - crossP->z()))
507 / (-TMath::Sin(-pmtPhi) * ref->x()
508 - TMath::Sin(pmtTheta) * TMath::Cos(-pmtPhi) * ref->y()
509 + TMath::Cos(pmtTheta) * TMath::Cos(-pmtPhi) * ref->z());
511 if (centerP->y() < 0) {
512 rho2 = (-TMath::Sin(-pmtPhi) * (-pmtPlaneX - crossP->x())
513 - TMath::Sin(-pmtTheta) * TMath::Cos(-pmtPhi)
514 * (-pmtPlaneY - crossP->y())
515 + TMath::Cos(-pmtTheta) * TMath::Cos(-pmtPhi)
516 * (pmtPlaneZ - crossP->z()))
517 / (-TMath::Sin(-pmtPhi) * ref->x()
518 - TMath::Sin(-pmtTheta) * TMath::Cos(-pmtPhi) * ref->y()
519 + TMath::Cos(-pmtTheta) * TMath::Cos(-pmtPhi) * ref->z());
522 cxX = crossP->x() + ref->x() * rho2;
523 cyY = crossP->y() + ref->y() * rho2;
524 czZ = crossP->z() + ref->z() * rho2;
527 Double_t dP = TMath::Sqrt((crossP->x() - cxX) * (crossP->X() - cxX)
528 + (crossP->y() - cyY) * (crossP->y() - cyY)
529 + (crossP->z() - czZ) * (crossP->Z() - czZ));
539 outPoint->SetXYZ(xX, yY, zZ);