CbmRoot
CbmRichNavigationUtil2.h
Go to the documentation of this file.
1 
2 #ifndef RICH_CbmRichNavigationUtil2
3 #define RICH_CbmRichNavigationUtil2
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  TGeoNavigator* navi) {
18  TVector3 dirCos, pos;
19  pos.SetXYZ(par->GetX(), par->GetY(), par->GetZ());
20  Double_t nx, ny, nz;
21  GetDirCos(par, nx, ny, nz);
22  dirCos.SetXYZ(nx, ny, nz);
23 
24  return FindIntersection(dirCos, pos, crossPoint, volumeName, navi);
25  }
26 
27  static string FindIntersection(const TVector3& dirCos,
28  const TVector3& pos,
29  TVector3& crossPoint,
30  const string& volumeName,
31  TGeoNavigator* navi) {
32  // if (volumeName == "pmt_pixel")cout << "InitTrack: " << pos.X() << " " << pos.Y() << " " << pos.Z() << " " << dirCos.X() << " " << dirCos.Y()<< " " << dirCos.Z() << endl;
33  gGeoManager->InitTrack(
34  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  Double_t x = gGeoManager->GetCurrentPoint()[0];
42  Double_t y = gGeoManager->GetCurrentPoint()[1];
43  Double_t z = gGeoManager->GetCurrentPoint()[2];
44  // if (volumeName == "pmt_pixel")cout << "volumeName:" << volumeName << " " << "name:" << name << " x:"<< x << " y:" << y << " z:" << z << endl;
45 
46  std::size_t found = name.find(volumeName);
47  if (found != std::string::npos) {
48  // if (volumeName == "pmt_pixel")cout << "volumeName found" << endl;
49  crossPoint.SetXYZ(x, y, z);
50  gGeoManager->PopPoint();
51  navi = gGeoManager->GetCurrentNavigator();
52  return name;
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])
65  || std::isnan(gGeoManager->GetCurrentPoint()[1])
66  || std::isnan(gGeoManager->GetCurrentPoint()[2])) {
67  // if (volumeName == "pmt_pixel")std::cout << "Error! CbmRichNavigationUtil::FindIntersections: NaN values.\n";
68  gGeoManager->PopDummy();
69  return string("");
70  }
71 
72  gGeoManager->PopDummy();
73 
74  } while (true);
75 
76  return string("");
77  }
78 
79  static void GetDirCos(const FairTrackParam* par,
80  Double_t& nx,
81  Double_t& ny,
82  Double_t& nz) {
83  Double_t p =
84  (std::abs(par->GetQp()) != 0.) ? 1. / std::abs(par->GetQp()) : 1.e20;
85  Double_t pz = std::sqrt(
86  p * p / (par->GetTx() * par->GetTx() + par->GetTy() * par->GetTy() + 1));
87  Double_t px = par->GetTx() * pz;
88  Double_t py = par->GetTy() * pz;
89  TVector3 unit = TVector3(px, py, pz).Unit();
90  nx = unit.X();
91  ny = unit.Y();
92  nz = unit.Z();
93  }
94 };
95 
96 #endif
sqrt
friend F32vec4 sqrt(const F32vec4 &a)
Definition: L1/vectors/P4_F32vec4.h:41
CbmRichNavigationUtil2
Definition: CbmRichNavigationUtil2.h:11
CbmRichNavigationUtil2::GetDirCos
static void GetDirCos(const FairTrackParam *par, Double_t &nx, Double_t &ny, Double_t &nz)
Definition: CbmRichNavigationUtil2.h:79
CbmRichNavigationUtil2::FindIntersection
static string FindIntersection(const FairTrackParam *par, TVector3 &crossPoint, const string &volumeName, TGeoNavigator *navi)
Definition: CbmRichNavigationUtil2.h:14
x
Double_t x
Definition: CbmMvdSensorDigiToHitTask.cxx:68
y
Double_t y
Definition: CbmMvdSensorDigiToHitTask.cxx:68
pos
TVector3 pos
Definition: CbmMvdSensorDigiToHitTask.cxx:60
CbmRichNavigationUtil2::FindIntersection
static string FindIntersection(const TVector3 &dirCos, const TVector3 &pos, TVector3 &crossPoint, const string &volumeName, TGeoNavigator *navi)
Definition: CbmRichNavigationUtil2.h:27