Hall-D Software  alpha
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DMaterialMap.h
Go to the documentation of this file.
1 // Class for dealing with a map of the material in the detector
2 
3 #ifndef _DMaterialMap_
4 #define _DMaterialMap_
5 
6 #include <JANA/jerror.h>
7 
8 #include <DVector3.h>
9 #include <DVector2.h>
10 
11 class DMagneticFieldMap;
12 
14  public:
15  DMaterialMap(string namepath, JCalibration *jcalib);
16  virtual ~DMaterialMap(){};
17 
18  bool IS_VALID;
19 
21  {
22  public:
23  double A ;
24  double Z ;
25  double Density ;
26  double RadLen ;
27  double LogI; // log(mean excitation energy
28  double rhoZ_overA; // density*Z/A
29  double KrhoZ_overA; // 0.1535e-3*density*Z/A
30  double rhoZ_overA_logI; // density*Z/A * log(mean excitation energy)
31  double chi2c_factor; // prefactor for the characteristic angle for multiple scattering: chi2c^2=(chi2c_factor)*X/p^/beta^2
32  double chi2a_factor; // prefactor for the screening angle
33  double chi2a_corr;
34  };
35 
36  inline const MaterialNode* FindNode(const DVector3 &pos) const;
37 
38  jerror_t FindMat(DVector3 &pos, double &rhoZ_overA, double &rhoZ_overA_logI, double &RadLen) const;
39  jerror_t FindMatALT1(DVector3 &pos,double &KrhoZ_overA,
40  double &rhoZ_overA, double &logI,
41  double &RadLen) const;
42  jerror_t FindMat(DVector3 &pos, double &density, double &A, double &Z, double &RadLen) const;
43  jerror_t FindMatKalman(const DVector3 &pos,
44  double &K_rho_Z_over_A,
45  double &rho_Z_over_A,double &LogI,
46  double &chi2c_factor,
47  double &chi2a_factor,double &chi2a_corr,
48  double &Z) const;
49  bool IsInMap(const DVector3 &pos) const;
50  double EstimatedDistanceToBoundary(const DVector3 &pos, const DVector3 &mom);
51  double EstimatedDistanceToBoundarySearch(double r, double z, double p_hatR, double p_hatZ, double &s_to_boundary);
52  double DistanceToBox(double &x, double &y, double &xdir, double &ydir, double xmin, double xmax, double ymin, double ymax);
53 
54  string GetNamepath(void) const {return namepath;}
55  double GetRmin(void) const {return rmin;}
56  double GetRmax(void) const {return rmax;}
57  double GetZmin(void) const {return zmin;}
58  double GetZmax(void) const {return zmax;}
59  double GetNr(void) const {return Nr;}
60  double GetNz(void) const {return Nz;}
61  double Getdr(void) const {return dr;}
62  double Getdz(void) const {return dz;}
63 
64  private:
65  DMaterialMap(); // Forbid default constructor
66 
67  void FindBoundaries(void);
68 
69  string namepath;
70  vector<vector<MaterialNode> > nodes; // nodes[ir][iz]
71  int Nr, Nz; // Number of nodes in R and Z
72  double dr, dz; // Distance between nodes in R and Z
74  double r0, z0; // Location of first nodes in R and Z
75 
76  double rmin, rmax; // Range limits in R of this map
77  double zmin, zmax; // Range limits in Z of this map
78 
81 
82  bool irregular_density_profile; // Set to true if significant density changes do not follow r or z lines
83  vector<double> r_boundaries;
84  vector<double> z_boundaries;
85 
86  JCalibration *jcalib;
87 };
88 
89 //-----------------
90 // FindNode
91 //-----------------
93 {
94  // For now, this just finds the bin in the material map the given position is in
95  // (i.e. no interpolation )
96  //double pos_x = pos.X();
97  //double pos_y = pos.Y();
98  //double r = sqrt(pos_x*pos_x + pos_y*pos_y);
99  double r=pos.Perp();
100  double z = pos.Z();
101  int ir = (int)floor((r-rmin)*one_over_dr);
102  int iz = (int)floor((z-zmin)*one_over_dz);
103  if(ir<0 || ir>=Nr || iz<0 || iz>=Nz)return NULL;
104 
105  return &nodes[ir][iz];
106 }
107 
108 
109 #endif // _DMaterialMap_
void FindBoundaries(void)
jerror_t FindMatALT1(DVector3 &pos, double &KrhoZ_overA, double &rhoZ_overA, double &logI, double &RadLen) const
vector< double > z_boundaries
Definition: DMaterialMap.h:84
vector< vector< MaterialNode > > nodes
Definition: DMaterialMap.h:70
double GetZmin(void) const
Definition: DMaterialMap.h:57
TVector3 DVector3
Definition: DVector3.h:14
Double_t x[NCHANNELS]
Definition: st_tw_resols.C:39
double GetNr(void) const
Definition: DMaterialMap.h:59
#define y
double EstimatedDistanceToBoundary(const DVector3 &pos, const DVector3 &mom)
string namepath
Definition: DMaterialMap.h:69
bool ENABLE_BOUNDARY_CHECK
Definition: DMaterialMap.h:80
virtual ~DMaterialMap()
Definition: DMaterialMap.h:16
double DistanceToBox(double &x, double &y, double &xdir, double &ydir, double xmin, double xmax, double ymin, double ymax)
int MAX_BOUNDARY_SEARCH_STEPS
Definition: DMaterialMap.h:79
double one_over_dz
Definition: DMaterialMap.h:73
double GetZmax(void) const
Definition: DMaterialMap.h:58
jerror_t FindMatKalman(const DVector3 &pos, double &K_rho_Z_over_A, double &rho_Z_over_A, double &LogI, double &chi2c_factor, double &chi2a_factor, double &chi2a_corr, double &Z) const
double Getdr(void) const
Definition: DMaterialMap.h:61
double GetNz(void) const
Definition: DMaterialMap.h:60
bool IsInMap(const DVector3 &pos) const
vector< double > r_boundaries
Definition: DMaterialMap.h:83
Double_t ymin
Definition: bcal_hist_eff.C:89
double GetRmin(void) const
Definition: DMaterialMap.h:55
double one_over_dr
Definition: DMaterialMap.h:73
Double_t ymax
Definition: bcal_hist_eff.C:91
bool irregular_density_profile
Definition: DMaterialMap.h:82
const MaterialNode * FindNode(const DVector3 &pos) const
Definition: DMaterialMap.h:92
double GetRmax(void) const
Definition: DMaterialMap.h:56
string GetNamepath(void) const
Definition: DMaterialMap.h:54
JCalibration * jcalib
Definition: DMaterialMap.h:86
double Getdz(void) const
Definition: DMaterialMap.h:62
jerror_t FindMat(DVector3 &pos, double &rhoZ_overA, double &rhoZ_overA_logI, double &RadLen) const
double EstimatedDistanceToBoundarySearch(double r, double z, double p_hatR, double p_hatZ, double &s_to_boundary)