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