FairShip
Loading...
Searching...
No Matches
MuGeoProcessor.h
Go to the documentation of this file.
1// SPDX-License-Identifier: LGPL-3.0-or-later
2// SPDX-FileCopyrightText: Copyright CERN for the benefit of the SHiP
3// Collaboration
4
5#ifndef NEWMUONDIS_MUGEOPROCESSOR_H_
6#define NEWMUONDIS_MUGEOPROCESSOR_H_
7
8#include <array>
9#include <map>
10#include <memory>
11#include <set>
12#include <string>
13
14#include "FairLogger.h" // for FairLogger, MESSAGE_ORIGIN
16#include "MuDISDefs.h"
17#include "MuonPath.h"
18#include "TGeoManager.h"
19#include "TGeoMaterial.h"
20#include "TGeoMatrix.h"
21#include "TGeoNode.h"
22#include "TGeoShape.h"
23#include "TGeoVolume.h"
24#include "TMath.h"
25#include "TVector3.h"
26
28 public:
31
34
36 // The caller retains ownership of the field and geometry.
37 void SetMuonShieldField(ShipBFieldMap* field, TGeoManager* geometry);
38 void SetPocaJumpThreshold(double threshold);
39 double GetPocaJumpThreshold() const { return fPocaJumpThreshold; }
40 void ResetDiagnostics();
41 void PrintDiagnostics() const;
42 int64_t GetLargeJumpCount() const { return fLargeJumps; }
43 int64_t GetMuonsWithLargeJumps() const { return fMuonsWithLargeJumps; }
44 int64_t GetBackwardMuonCount() const { return fBackwardMuons; }
45 int64_t GetUBTBackwardMissCount() const { return fUBTBackwardMisses; }
46 int64_t GetUBTBackwardPathCount() const { return fUBTBackwardPaths; }
47 int64_t GetStartInFieldCount() const { return fStartMagneticPaths; }
48 int64_t GetStartFieldFreeCount() const { return fStartStraightPaths; }
49 int64_t GetStartsBeforeZminCount() const { return fStartsBeforeZmin; }
50 double GetMaxTransverseJump() const { return fMaxTransverseJump; }
51
52 inline void SetZmax(const double& zmax) {
53 LOG(info) << " Maximum z position for MuonPath building: " << zmax
54 << " cm.";
55 fZmax = zmax;
56 };
57 inline void SetZmin(const double& zmin) {
58 LOG(info) << " Minimum z position for MuonPath building: " << zmin
59 << " cm.";
60 fZmin = zmin;
61 };
62
63 TVector3 GetVertex(const TVector3& r1, const TVector3& p1, const TVector3& r2,
64 const TVector3& p2);
65 void CheckAllVolumes();
66 std::map<std::string, MuonPath>& FillMuonPath();
67 void PrintVolumes();
68
69 private:
70 double fZmax;
71 double fZmin;
72 struct Measurement {
73 TVector3 position;
74 TVector3 momentum;
75 double time;
76 };
77 struct Segment {
79 double startZ;
80 double endZ;
82 };
83 void CacheGeometry();
84 bool AddMagneticSegments(const Measurement& start, double charge,
85 double endZ);
86 double GetTrajectoryPocaZ(const Measurement& hit) const;
87 bool AddMagneticChord(const TVector3& a, const TVector3& b, double momentum,
88 double& time, unsigned depth = 0);
89 bool Trace(const Measurement& measurement, double startZ, double endZ,
90 bool backward = false);
91 void AddPath(const MuonPath& path);
92 std::vector<Segment> fSegments;
93 std::set<const TGeoVolume*> fShieldVolumes;
94 TGeoManager* fGeometry = nullptr;
95 TGeoNode* fTopNode = nullptr;
96 std::unique_ptr<MagneticTrackPropagator> fPropagator;
97 double fShieldMinZ = 0.;
98 bool fTraceBackward = false;
100
101 double fPocaJumpThreshold = 1.; // transverse distance in cm
102 int64_t fMuons = 0;
103 int64_t fBackwardMuons = 0;
104 int64_t fInvalidMuons = 0;
105 // Routes prepared by initialise(), before material navigation.
106 int64_t fUBTBackwardPaths = 0;
110 int64_t fStartsBeyondZmax = 0;
111 int64_t fStartsBeforeZmin = 0; // diagnostic only; counted per path build
112 int64_t fTransitions = 0;
113 int64_t fLargeJumps = 0;
116 // Sums of MCTrack[0].fW for the corresponding muon counters.
117 struct MuonWeights {
118 double considered = 0.;
119 double backward = 0.;
120 double invalid = 0.;
121 double ubtBackward = 0.;
122 double ubtMiss = 0.;
123 double startMagnetic = 0.;
124 double startStraight = 0.;
125 double beyondZmax = 0.;
126 double beforeZmin = 0.;
127 double largeJump = 0.;
128 };
130 double fMuonWeight = 0.; // current muon, also used by FillMuonPath()
131
132 std::map<std::string, MuonPath> fPathMap;
133 std::map<std::string, std::set<std::string>> fVolMap;
134
135}; // class
136
137#endif // NEWMUONDIS_MUGEOPROCESSOR_H_
int64_t GetStartsBeforeZminCount() const
Measurement fUBT
TGeoManager * fGeometry
Shield material volumes.
double fPocaJumpThreshold
int64_t GetLargeJumpCount() const
int64_t fStartMagneticPaths
int64_t fMuonsWithLargeJumps
std::map< std::string, MuonPath > fPathMap
void SetMuonShieldField(ShipBFieldMap *field, TGeoManager *geometry)
int64_t GetMuonsWithLargeJumps() const
void SetZmax(const double &zmax)
std::map< std::string, std::set< std::string > > fVolMap
bool Trace(const Measurement &measurement, double startZ, double endZ, bool backward=false)
int64_t fStartStraightPaths
Measurement fStart
std::unique_ptr< MagneticTrackPropagator > fPropagator
Geometry cache identity.
int64_t fUBTBackwardPaths
int64_t fUBTBackwardMisses
std::vector< Segment > fSegments
TVector3 GetVertex(const TVector3 &r1, const TVector3 &p1, const TVector3 &r2, const TVector3 &p2)
void SetZmin(const double &zmin)
double GetMaxTransverseJump() const
bool initialise(ShipMuDIS::MuonBranches &aEvt)
MuonWeights fMuonWeights
int64_t GetUBTBackwardPathCount() const
int64_t GetUBTBackwardMissCount() const
double fShieldMinZ
Shield transport.
void PrintDiagnostics() const
bool AddMagneticSegments(const Measurement &start, double charge, double endZ)
void SetPocaJumpThreshold(double threshold)
bool AddMagneticChord(const TVector3 &a, const TVector3 &b, double momentum, double &time, unsigned depth=0)
std::map< std::string, MuonPath > & FillMuonPath()
TGeoNode * fTopNode
Borrowed geometry.
int64_t GetStartInFieldCount() const
std::set< const TGeoVolume * > fShieldVolumes
Runtime path segments.
int64_t GetBackwardMuonCount() const
double GetTrajectoryPocaZ(const Measurement &hit) const
int64_t GetStartFieldFreeCount() const
int64_t fStartsBeforeZmin
double fMaxTransverseJump
void AddPath(const MuonPath &path)
double GetPocaJumpThreshold() const
int64_t fStartsBeyondZmax
Class that defines a (3d) magnetic field map (distances in cm, fields in tesla).