CbmRoot
Loading...
Searching...
No Matches
CbmRichNavigationUtil.h
Go to the documentation of this file.
1/* Copyright (C) 2016-2021 GSI/JINR-LIT, Darmstadt/Dubna
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Andrey Lebedev [committer], Semen Lebedev */
4
5#ifndef RICH_CbmRichNavigationUtil
6#define RICH_CbmRichNavigationUtil
7
8#include "FairTrackParam.h"
9#include <Logger.h>
10
11#include "TGeoManager.h"
12#include "TObject.h"
13#include "TVector3.h"
14
15
17
18public:
19 static string FindIntersection(const FairTrackParam* par, TVector3& crossPoint, const string& volumeName)
20 {
21 TVector3 dirCos, pos;
22 pos.SetXYZ(par->GetX(), par->GetY(), par->GetZ());
23 Double_t nx, ny, nz;
24 GetDirCos(par, nx, ny, nz);
25 dirCos.SetXYZ(nx, ny, nz);
26
27 return FindIntersection(dirCos, pos, crossPoint, volumeName);
28 }
29
30 static string FindIntersection(const TVector3& dirCos, const TVector3& pos, TVector3& crossPoint,
31 const string& volumeName)
32 {
33 // if (volumeName == "pmt_pixel")cout << "InitTrack: " << pos.X() << " " << pos.Y() << " " << pos.Z() << " " << dirCos.X() << " " << dirCos.Y()<< " " << dirCos.Z() << endl;
34 gGeoManager->InitTrack(pos.X(), pos.Y(), pos.Z(), dirCos.X(), dirCos.Y(), dirCos.Z());
35
36 if (gGeoManager->IsOutside()) { return string(""); }
37
38 do {
39 gGeoManager->PushPoint();
40 string name = string(gGeoManager->GetCurrentNode()->GetName());
41 string fullPath = string(gGeoManager->GetPath());
42 Double_t x = gGeoManager->GetCurrentPoint()[0];
43 Double_t y = gGeoManager->GetCurrentPoint()[1];
44 Double_t z = gGeoManager->GetCurrentPoint()[2];
45 // if (volumeName == "pmt_pixel")cout << "volumeName:" << volumeName << " " << "name:" << name << " x:"<< x << " y:" << y << " z:" << z << endl;
46
47 std::size_t found = name.find(volumeName);
48 if (found != std::string::npos) {
49 // if (volumeName == "pmt_pixel")cout << "volumeName found" << endl;
50 crossPoint.SetXYZ(x, y, z);
51 gGeoManager->PopPoint();
52 return fullPath;
53 }
54
55
56 Double_t step = 25.;
57 gGeoManager->FindNextBoundaryAndStep(step);
58 if (gGeoManager->IsOutside()) {
59 //if (volumeName == "pmt_pixel")std::cout << "Error! CbmRichNavigationUtil::FindIntersections: Outside geometry.\n";
60 gGeoManager->PopDummy();
61 return string("");
62 }
63 // Check for NaN values
64 if (std::isnan(gGeoManager->GetCurrentPoint()[0]) || std::isnan(gGeoManager->GetCurrentPoint()[1])
65 || std::isnan(gGeoManager->GetCurrentPoint()[2])) {
66 // if (volumeName == "pmt_pixel")std::cout << "Error! CbmRichNavigationUtil::FindIntersections: NaN values.\n";
67 gGeoManager->PopDummy();
68 return string("");
69 }
70
71 gGeoManager->PopDummy();
72
73 } while (true);
74
75 return string("");
76 }
77
78 static void GetDirCos(const FairTrackParam* par, Double_t& nx, Double_t& ny, Double_t& nz)
79 {
80 Double_t p = (std::abs(par->GetQp()) != 0.) ? 1. / std::abs(par->GetQp()) : 1.e20;
81 Double_t pz = std::sqrt(p * p / (par->GetTx() * par->GetTx() + par->GetTy() * par->GetTy() + 1));
82 Double_t px = par->GetTx() * pz;
83 Double_t py = par->GetTy() * pz;
84 TVector3 unit = TVector3(px, py, pz).Unit();
85 nx = unit.X();
86 ny = unit.Y();
87 nz = unit.Z();
88 }
89};
90
91#endif
static void GetDirCos(const FairTrackParam *par, Double_t &nx, Double_t &ny, Double_t &nz)
static string FindIntersection(const TVector3 &dirCos, const TVector3 &pos, TVector3 &crossPoint, const string &volumeName)
static string FindIntersection(const FairTrackParam *par, TVector3 &crossPoint, const string &volumeName)