LArSoft  v06_85_00
Liquid Argon Software toolkit - http://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"TGeoMaterial.h"
25 #include"TGeoManager.h"
26 
27 #include"GFException.h"
28 
29 
30 float MeanExcEnergy_get(int Z);
31 float MeanExcEnergy_get(TGeoMaterial*);
32 
33 
35  double& matZ,
36  double& matA,
37  double& radiationLength,
38  double& mEE){
39  if (!gGeoManager->GetCurrentVolume()->GetMedium())
40  throw GFException("genf::GFGeoMatManager::getMaterialParameters(): no medium in volume!", __LINE__, __FILE__).setFatal();
41  TGeoMaterial * mat = gGeoManager->GetCurrentVolume()->GetMedium()->GetMaterial();
42  //std::cout << "GFGeoMatManager::getMaterialParameters: CurrentVolume is " << std::endl;
43  //gGeoManager->GetCurrentVolume()->Print();
44  //std::cout << "GFGeoMatManager::getMaterialParameters: Material is " << std::endl;
45  //gGeoManager->GetCurrentVolume()->GetMedium()->GetMaterial()->Print();
46 
47  matDensity = mat->GetDensity();
48  matZ = mat->GetZ();
49  matA = mat->GetA();
50  radiationLength = mat->GetRadLen();
51  mEE = MeanExcEnergy_get(mat);
52 }
53 
54 void genf::GFGeoMatManager::initTrack(const double& posx,
55  const double& posy,
56  const double& posz,
57  const double& dirx,
58  const double& diry,
59  const double& dirz){
60  gGeoManager->InitTrack(posx,posy,posz,dirx,diry,dirz);
61 }
62 
63 double genf::GFGeoMatManager::stepOrNextBoundary(const double& maxStep){
64  gGeoManager->FindNextBoundaryAndStep(maxStep);
65  return gGeoManager->GetStep();
66 }
67 
68 //ClassImp(GFGeoMatManager)
69 
70 /*
71 Reference for elemental mean excitation energies at:
72 http://physics.nist.gov/PhysRefData/XrayMassCoef/tab1.html
73 */
74 
75 const int MeanExcEnergy_NELEMENTS = 92;
76 const float MeanExcEnergy_vals[MeanExcEnergy_NELEMENTS] = {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, 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, 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, 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, 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, 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, 825.0, 794.0, 827.0, 826.0, 841.0, 847.0, 878.0, 890.0};
77 
78 float MeanExcEnergy_get(int Z){
79  if ((Z <= 0) || (Z > MeanExcEnergy_NELEMENTS))
80  throw GFException("MeanExcEnergy_get(): Z out of range", __LINE__, __FILE__).setFatal();
81  return MeanExcEnergy_vals[Z-1];
82 }
83 
84 float MeanExcEnergy_get(TGeoMaterial* mat){
85  if(mat->IsMixture()){
86  double logMEE = 0.;
87  double denom = 0.;
88  TGeoMixture *mix = (TGeoMixture*)mat;
89  for(int i=0;i<mix->GetNelements();++i){
90  int index = int(floor((mix->GetZmixt())[i]));
91  //check whether the floor command worked
92  assert(fabs(index-((mix->GetZmixt())[i]))<1.e-3);
93  logMEE += 1./(mix->GetAmixt())[i]*(mix->GetWmixt())[i]*(mix->GetZmixt())[i]*log(MeanExcEnergy_get(index));
94  denom += (mix->GetWmixt())[i]*(mix->GetZmixt())[i]*1./(mix->GetAmixt())[i];
95  }
96  logMEE/=denom;
97  return exp(logMEE);
98  }
99  else{ // not a mixture
100  int index = int(floor(mat->GetZ()));
101  //check whether the floor command worked
102  assert(fabs(index-mat->GetZ())<1.e-3);
103  return MeanExcEnergy_get(index);
104  }
105 }
106 
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:39
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:40
Exception class for error handling in GENFIT (provides storage for diagnostic information) ...
Definition: GFException.h:50
GFException & setFatal(bool b=true)
set fatal flag. if this is true, the fit stops for this current track repr.
Definition: GFException.h:80
const int MeanExcEnergy_NELEMENTS
Float_t e
Definition: plot.C:34