CbmRoot
CbmTrdGas.cxx
Go to the documentation of this file.
1 
5 #include "CbmTrdGas.h"
6 
7 #include <FairLogger.h> // for LOG, Logger
8 
9 #include <TGenericClassInfo.h> // for TGenericClassInfo
10 #include <TGeoBBox.h> // for TGeoBBox
11 #include <TGeoManager.h> // for TGeoManager, gGeoManager
12 #include <TGeoMaterial.h> // for TGeoMixture
13 #include <TGeoVolume.h> // for TGeoVolume
14 #include <TMath.h> // for Nint
15 #include <TObjArray.h> // for TObjArray, TObjArrayIter
16 #include <TObject.h> // for TObject
17 #include <TString.h> // for TString, operator+, operator<<
18 
19 #include <stdlib.h> // for getenv
20 
22 
24  : TObject()
25  , fDetType(-1)
26  , fGasThick(0.)
27  , fPercentNobleGas(0.)
28  , fPercentCO2(0.)
29  , fNobleGasType(-1)
30  , fFileNameLike("")
31  , fFileNameANN("") {
32  if (fgInstance) {
33  LOG(fatal) << "CbmTrdGas::CbmTrdGas Singleton instance already exists.";
34  }
35  fgInstance = this;
36 }
37 
39 
41  // Read MWPC gas properties from geometry. This enforce that gas
42  // mixture simulation and reconstruction is the same. This is important
43  // because dE/dx is calculated in the simulation and TR is calculated
44  // in the reconstruction.
45 
46  // Get pointer to gas volume
47  TGeoVolume* fm =
48  (TGeoVolume*) gGeoManager->GetListOfVolumes()->FindObject("gas");
49  if (!fm) {
50  TObjArray* volList = gGeoManager->GetListOfVolumes();
51  TObjArrayIter iter(volList);
52  TGeoVolume* vol = nullptr;
53  LOG(error) << "********** List of available volumes ************ ";
54  while ((vol = (TGeoVolume*) iter.Next())) {
55  LOG(error) << vol->GetName();
56  }
57  LOG(error) << "***************** End of List ******************* \n"
58  << " -E- Could not find volume <gas>. \n"
59  << " -E- If there is no list above this text then probably \n"
60  << " -E- the geometry was not loaded in the macro.\n"
61  << " -E- Please do it with fRun->LoadGeometry(). \n "
62  << " -E- If you see a list probably the names of the \n"
63  << " -E- volumes have changed and CbmTrdRadiator has to \n"
64  << " -E- be changed accordingly. ";
65  LOG(fatal) << "CbmTrdGas::Init: No volumes defined.";
66  }
67 
68  // check if detector is of GSI or Muenster/Bucarest type
69  // the type is coded in the master volume name
70  TGeoVolume* fm1 =
71  (TGeoVolume*) gGeoManager->GetListOfVolumes()->FindObject("trd1mb");
72 
73  // get pointer to shape of gas volume
74  TGeoBBox* shape = (TGeoBBox*) fm->GetShape();
75 
76  if (fm1) { // MB type
77  fDetType = 1;
78  // only halve thickness of gas layer tacken into account because the
79  // total absorbed TR is calculated in two steps since the real chamber
80  // consists of two gas volumes with both halve the thickness as from
81  // geometry
82  fGasThick = 2 * (shape->GetDZ());
83  LOG(info) << "CbmTrdGas::Init: Detector type : double sided geometry (1) ";
84  LOG(info) << "CbmTrdGas::Init: Gas thickness : " << fGasThick << " cm";
85  } else { // GSI type
86  fDetType = 0;
87  fGasThick = 2 * (shape->GetDZ());
88  LOG(info) << "CbmTrdGas::Init: Detector type : standard GSI geometry (2) ";
89  LOG(info) << "CbmTrdGas::Init: Gas thickness : " << fGasThick << " cm";
90  }
91 
92  // Get all the necessary properties of the gas mixture
93  TGeoMixture* mixt = (TGeoMixture*) fm->GetMaterial();
94  Int_t nmixt = mixt->GetNelements();
95  if (nmixt != 3) {
96  LOG(error) << "CbmTrdGas::Init: This is not a mixture composed out of "
97  "three different elements.";
98  LOG(error)
99  << "CbmTrdGas::Init: Don't know what to do, so stop execution here.";
100  LOG(fatal) << "CbmTrdGas::Init: Unknown gas mixture.";
101  }
102 
103  Bool_t foundCarbon = kFALSE;
104  Bool_t foundOxygen = kFALSE;
105  Int_t carbon = 0;
106  Int_t oxygen = 0;
107  Int_t noblegas = 0;
108 
109  Double_t* elem = mixt->GetZmixt();
110  Double_t* weight = mixt->GetWmixt();
111  Double_t* amixt = mixt->GetAmixt();
112 
113  for (Int_t i = 0; i < nmixt; i++) {
114  if (elem[i] == 6.0) {
115  carbon = i;
116  foundCarbon = kTRUE;
117  } else if (elem[i] == 8.0) {
118  oxygen = i;
119  foundOxygen = kTRUE;
120  } else
121  noblegas = i;
122  }
123  if (!(foundCarbon && foundOxygen)) {
124  LOG(error) << "CbmTrdGas::Init: This gas mixture has no CO2 admixture \n"
125  << "CbmTrdGas::Init: If you want to use this mixture you have "
126  "to change \n"
127  << "CbmTrdGas::Init: CbmTrdRadiator to be consistent \n";
128  LOG(fatal) << "CbmTrdGas::Init: Unknown gas mixture.";
129  }
130  if (elem[noblegas] != 54) {
131  LOG(error) << "CbmTrdGas::Init: This gas mixture has no Xe admixture \n"
132  << "CbmTrdGas::Init: If you want to use this mixture you have "
133  "to change \n"
134  << "CbmTrdGas::Init: CbmTrdRadiator to be consistent";
135  LOG(fatal) << "CbmTrdGas::Init: Unknown gas mixture.";
136  } else {
137  fNobleGasType = 1;
138  }
139 
140  Double_t massC = amixt[carbon];
141  Double_t massO = amixt[oxygen];
142  Double_t massXe = amixt[noblegas];
143  Double_t x = weight[noblegas];
144  Double_t percentNoblegas =
145  100
146  * (((massC * x) + (2 * massO * x))
147  / (massXe + massC * x + 2 * massO * x - massXe * x));
148 
149  fPercentNobleGas = TMath::Nint(percentNoblegas) / 100.;
151 
152  if (elem[noblegas] == 54) {
153  LOG(info) << "CbmTrdGas::Init: Percent (Xe) : "
154  << (fPercentNobleGas * 100);
155  }
156  LOG(info) << "CbmTrdGas::Init: Percent (CO2) : " << (fPercentCO2 * 100);
157 
158  SetFileName();
159 }
160 
161 TString CbmTrdGas::GetFileName(TString method) const {
162  if (method.Contains("Like")) {
163  return fFileNameLike;
164  } else if (method.Contains("ANN")) {
165  return fFileNameANN;
166  } else {
167  LOG(error)
168  << "CbmTrdGas::GetFileName: Electron ID method " << method
169  << " not known. \n"
170  << "CbmTrdGas::GetFileName: The input must be either Like or ANN";
171  return "";
172  }
173 }
174 
176  Int_t fraction = TMath::Nint(fPercentNobleGas * 100);
177  Int_t thickness = TMath::Nint(fGasThick * 10);
178 
179  const char* detector = "";
180  if (fDetType == 0) {
181  detector = "GSI";
182  } else if (fDetType == 1) {
183  detector = "MB";
184  } else {
185  LOG(error) << "CbmTrdGas::SetFileName: Detector type " << fDetType
186  << " not known";
187  LOG(error) << "CbmTrdGas::SetFileName: Stop execution of program due to "
188  "initialization error.";
189  LOG(fatal) << "CbmTrdGas::SetFileName: Unknown detector type.";
190  }
191  const char* gastype = "";
192  if (fNobleGasType == 1) {
193  gastype = "Xenon";
194  } else {
195  LOG(error) << "CbmTrdGas::SetFileName: Gas type " << fNobleGasType
196  << " not known";
197  LOG(error) << "CbmTrdGas::SetFileName: Stop execution of program due to "
198  "initialization error.";
199  LOG(fatal) << "CbmTrdGas::SetFileName: Unknown gas type.";
200  }
201 
202  TString path = getenv("VMCWORKDIR");
203  path = path + "/parameters/trd/";
204  fFileNameLike.Form(
205  "Likelihood_%s_%d_%s_%d.root", gastype, fraction, detector, thickness);
206  fFileNameANN.Form(
207  "ANN_%s_%d_%s_%d.root", gastype, fraction, detector, thickness);
208 
209  fFileNameLike = path + fFileNameLike;
210  fFileNameANN = path + fFileNameANN;
211 }
212 
CbmTrdGas::GetFileName
TString GetFileName(TString method) const
Definition: CbmTrdGas.cxx:161
CbmTrdGas::fFileNameLike
TString fFileNameLike
Definition: CbmTrdGas.h:42
CbmTrdGas::fgInstance
static CbmTrdGas * fgInstance
Definition: CbmTrdGas.h:41
CbmTrdGas.h
Container for gas properties of TRD.
CbmTrdGas::SetFileName
void SetFileName()
/‍** File name of input for ANN method *‍/
Definition: CbmTrdGas.cxx:175
i
int i
Definition: L1/vectors/P4_F32vec4.h:25
CbmTrdGas::~CbmTrdGas
virtual ~CbmTrdGas()
Definition: CbmTrdGas.cxx:38
CbmTrdGas::CbmTrdGas
CbmTrdGas()
Definition: CbmTrdGas.cxx:23
CbmTrdGas::fFileNameANN
TString fFileNameANN
/‍** File name of input for likelihood method *‍/
Definition: CbmTrdGas.h:43
CbmTrdGas::fNobleGasType
Int_t fNobleGasType
Definition: CbmTrdGas.h:40
ClassImp
ClassImp(CbmConverterManager) InitStatus CbmConverterManager
Definition: CbmConverterManager.cxx:12
CbmTrdGas::fGasThick
Double_t fGasThick
Definition: CbmTrdGas.h:37
CbmTrdGas::fDetType
Int_t fDetType
Definition: CbmTrdGas.h:36
shape
UInt_t shape
Definition: CbmMvdSensorDigiToHitTask.cxx:73
x
Double_t x
Definition: CbmMvdSensorDigiToHitTask.cxx:68
CbmTrdGas::fPercentCO2
Double_t fPercentCO2
Definition: CbmTrdGas.h:39
CbmTrdGas
Definition: CbmTrdGas.h:14
CbmTrdGas::Init
void Init()
Definition: CbmTrdGas.cxx:40
CbmTrdGas::fPercentNobleGas
Double_t fPercentNobleGas
Definition: CbmTrdGas.h:38