BmnRoot
Loading...
Searching...
No Matches
BmnNdetGeo.cxx
Go to the documentation of this file.
1#include "BmnNdetGeo.h"
2
3#include <FairLogger.h>
4#include <TGeoBBox.h>
5#include <TGeoManager.h>
6
7std::pair<BmnNdetGeo::BoxFace, BmnNdetGeo::Direction> BmnNdetGeo::GetEnteredFace(const TVector3& globalPos,
8 const TVector3& globalMom)
9{
10 if (!gGeoManager)
12
13 TGeoNode* envelopeNode = gGeoManager->GetCurrentNode();
14 if (!envelopeNode)
16
17 auto* box = dynamic_cast<TGeoBBox*>(envelopeNode->GetVolume()->GetShape());
18 if (!box)
20
21 double gpos[3] = {globalPos.X(), globalPos.Y(), globalPos.Z()};
22 double gdir[3] = {globalMom.X(), globalMom.Y(), globalMom.Z()};
23 double lpos[3], ldir[3];
24
25 gGeoManager->MasterToLocal(gpos, lpos);
26 gGeoManager->MasterToLocalVect(gdir, ldir);
27
28 TVector3 local(lpos[0], lpos[1], lpos[2]);
29 TVector3 direc(ldir[0], ldir[1], ldir[2]);
30
31 struct
32 {
33 BoxFace face;
34 double coord;
35 TVector3 normal;
36 } checks[] = {{BoxFace::Xplus, local.X() - box->GetDX(), TVector3(1, 0, 0)},
37 {BoxFace::Xminus, local.X() + box->GetDX(), TVector3(-1, 0, 0)},
38 {BoxFace::Yplus, local.Y() - box->GetDY(), TVector3(0, 1, 0)},
39 {BoxFace::Yminus, local.Y() + box->GetDY(), TVector3(0, -1, 0)},
40 {BoxFace::Zplus, local.Z() - box->GetDZ(), TVector3(0, 0, 1)},
41 {BoxFace::Zminus, local.Z() + box->GetDZ(), TVector3(0, 0, -1)}};
42
43 const double eps = 1e-3;
44 for (const auto& check : checks) {
45 if (std::abs(check.coord) < eps) {
46 double dot = direc.Dot(check.normal);
48 return {check.face, d};
49 }
50 }
51
53}
const Float_t d
Z-ccordinate of the first GEM-station.
Definition BmnMwpcHit.cxx:7
static std::pair< BoxFace, Direction > GetEnteredFace(const TVector3 &globalPos, const TVector3 &globalMom)
Definition BmnNdetGeo.cxx:7