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