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