LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
GFGeoMatManager.cxx
Go to the documentation of this file.
1 /* Copyright 2008-2009, Technische Universitaet Muenchen,
2  Authors: Christian Hoeppner & Sebastian Neubert
3 
4  This file is part of GENFIT.
5 
6  GENFIT is free software: you can redistribute it and/or modify
7  it under the terms of the GNU Lesser General Public License as published
8  by the Free Software Foundation, either version 3 of the License, or
9  (at your option) any later version.
10 
11  GENFIT is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU Lesser General Public License for more details.
15 
16  You should have received a copy of the GNU Lesser General Public License
17  along with GENFIT. If not, see <http://www.gnu.org/licenses/>.
18 */
19 #include "GFGeoMatManager.h"
20 
21 #include "math.h"
22 #include <cassert>
23 
24 #include "TGeoManager.h"
25 #include "TGeoMaterial.h"
26 
27 #include "GFException.h"
28 
29 float MeanExcEnergy_get(int Z);
30 float MeanExcEnergy_get(TGeoMaterial*);
31 
33  double& matZ,
34  double& matA,
35  double& radiationLength,
36  double& mEE)
37 {
38  if (!gGeoManager->GetCurrentVolume()->GetMedium())
39  throw GFException(
40  "genf::GFGeoMatManager::getMaterialParameters(): no medium in volume!", __LINE__, __FILE__)
41  .setFatal();
42  TGeoMaterial* mat = gGeoManager->GetCurrentVolume()->GetMedium()->GetMaterial();
43  //std::cout << "GFGeoMatManager::getMaterialParameters: CurrentVolume is " << std::endl;
44  //gGeoManager->GetCurrentVolume()->Print();
45  //std::cout << "GFGeoMatManager::getMaterialParameters: Material is " << std::endl;
46  //gGeoManager->GetCurrentVolume()->GetMedium()->GetMaterial()->Print();
47 
48  matDensity = mat->GetDensity();
49  matZ = mat->GetZ();
50  matA = mat->GetA();
51  radiationLength = mat->GetRadLen();
52  mEE = MeanExcEnergy_get(mat);
53 }
54 
55 void genf::GFGeoMatManager::initTrack(const double& posx,
56  const double& posy,
57  const double& posz,
58  const double& dirx,
59  const double& diry,
60  const double& dirz)
61 {
62  gGeoManager->InitTrack(posx, posy, posz, dirx, diry, dirz);
63 }
64 
65 double genf::GFGeoMatManager::stepOrNextBoundary(const double& maxStep)
66 {
67  gGeoManager->FindNextBoundaryAndStep(maxStep);
68  return gGeoManager->GetStep();
69 }
70 
71 //ClassImp(GFGeoMatManager)
72 
73 /*
74 Reference for elemental mean excitation energies at:
75 http://physics.nist.gov/PhysRefData/XrayMassCoef/tab1.html
76 */
77 
78 const int MeanExcEnergy_NELEMENTS = 92;
80  19.2, 41.8, 40.0, 63.7, 76.0, 78., 82.0, 95.0, 115.0, 137.0, 149.0, 156.0, 166.0, 173.0,
81  173.0, 180.0, 174.0, 188.0, 190.0, 191.0, 216.0, 233.0, 245.0, 257.0, 272.0, 286.0, 297.0, 311.0,
82  322.0, 330.0, 334.0, 350.0, 347.0, 348.0, 343.0, 352.0, 363.0, 366.0, 379.0, 393.0, 417.0, 424.0,
83  428.0, 441.0, 449.0, 470.0, 470.0, 469.0, 488.0, 488.0, 487.0, 485.0, 491.0, 482.0, 488.0, 491.0,
84  501.0, 523.0, 535.0, 546.0, 560.0, 574.0, 580.0, 591.0, 614.0, 628.0, 650.0, 658.0, 674.0, 684.0,
85  694.0, 705.0, 718.0, 727.0, 736.0, 746.0, 757.0, 790.0, 790.0, 800.0, 810.0, 823.0, 823.0, 830.0,
86  825.0, 794.0, 827.0, 826.0, 841.0, 847.0, 878.0, 890.0};
87 
88 float MeanExcEnergy_get(int Z)
89 {
90  if ((Z <= 0) || (Z > MeanExcEnergy_NELEMENTS))
91  throw GFException("MeanExcEnergy_get(): Z out of range", __LINE__, __FILE__).setFatal();
92  return MeanExcEnergy_vals[Z - 1];
93 }
94 
95 float MeanExcEnergy_get(TGeoMaterial* mat)
96 {
97  if (mat->IsMixture()) {
98  double logMEE = 0.;
99  double denom = 0.;
100  TGeoMixture* mix = (TGeoMixture*)mat;
101  for (int i = 0; i < mix->GetNelements(); ++i) {
102  int index = int(floor((mix->GetZmixt())[i]));
103  //check whether the floor command worked
104  assert(fabs(index - ((mix->GetZmixt())[i])) < 1.e-3);
105  logMEE += 1. / (mix->GetAmixt())[i] * (mix->GetWmixt())[i] * (mix->GetZmixt())[i] *
106  log(MeanExcEnergy_get(index));
107  denom += (mix->GetWmixt())[i] * (mix->GetZmixt())[i] * 1. / (mix->GetAmixt())[i];
108  }
109  logMEE /= denom;
110  return exp(logMEE);
111  }
112  else { // not a mixture
113  int index = int(floor(mat->GetZ()));
114  //check whether the floor command worked
115  assert(fabs(index - mat->GetZ()) < 1.e-3);
116  return MeanExcEnergy_get(index);
117  }
118 }
float MeanExcEnergy_get(int Z)
void getMaterialParameters(double &matDensity, double &matZ, double &matA, double &radiationLength, double &mEE)
Gets material parameters (density, Z, A, radiation length, mean excitation energy) ...
const float MeanExcEnergy_vals[MeanExcEnergy_NELEMENTS]
double stepOrNextBoundary(const double &maxDist)
Makes a step, limited to next material boundary.
Float_t Z
Definition: plot.C:37
void initTrack(const double &posx, const double &posy, const double &posz, const double &dirx, const double &diry, const double &dirz)
Initializes the track.
Float_t mat
Definition: plot.C:38
Exception class for error handling in GENFIT (provides storage for diagnostic information) ...
Definition: GFException.h:47
GFException & setFatal(bool b=true)
set fatal flag. if this is true, the fit stops for this current track repr.
Definition: GFException.h:75
const int MeanExcEnergy_NELEMENTS
Float_t e
Definition: plot.C:35