Geant4 VMC Version 6.6
Loading...
Searching...
No Matches
TG4TransitionRadiationPhysics.cxx
Go to the documentation of this file.
1//------------------------------------------------
2// The Geant4 Virtual Monte Carlo package
3// Copyright (C) 2007 - 2015 Ivana Hrivnacova
4// All rights reserved.
5//
6// For the licensing terms see geant4_vmc/LICENSE.
7// Contact: root-vmc@cern.ch
8//-------------------------------------------------
9
17
19// #include "TG4TransitionRadiationMessenger.h"
20#include "TG4GeometryManager.h"
21#include "TG4GeometryServices.h"
23
24#include <G4Electron.hh>
25#include <G4LogicalVolumeStore.hh>
26#include <G4Positron.hh>
27#include <G4ProcessManager.hh>
28#include <G4VXTRenergyLoss.hh>
29
30#include <G4AutoDelete.hh>
31#include <G4GammaXTRadiator.hh>
32#include <G4RegularXTRadiator.hh>
33#include <G4StrawTubeXTRadiator.hh>
34#include <G4TransparentRegXTRadiator.hh>
35#include <G4XTRGammaRadModel.hh>
36#include <G4XTRRegularRadModel.hh>
37#include <G4XTRTransparentRegRadModel.hh>
38
39//_____________________________________________________________________________
40G4ThreadLocal std::vector<G4VXTRenergyLoss*>*
42
43//_____________________________________________________________________________
50
51//_____________________________________________________________________________
53 G4int theVerboseLevel, const G4String& name)
54 : TG4VPhysicsConstructor(name, theVerboseLevel)
55{
57}
58
59//_____________________________________________________________________________
64
65//
66// private methods
67//
68
69//_____________________________________________________________________________
71 TG4RadiatorDescription* radiatorDescription)
72{
74
75 G4String xtrModel = radiatorDescription->GetXtrModel();
76
77 auto foilLayer = radiatorDescription->GetLayer(0);
78 auto gasLayer = radiatorDescription->GetLayer(1);
79 auto strawTube = radiatorDescription->GetStrawTube();
80
81 if (xtrModel == "strawR" && (!std::get<0>(strawTube).size())) {
82 TString text = "Straw tube parameters are not defined.";
83 TG4Globals::Warning("TG4TransitionRadiationPhysics", "CreateXTRProcess",
84 TString("Straw tube parameters are not defined.") + TG4Globals::Endl() +
85 TString("The XTR process is not created."));
86 return false;
87 }
88
89 G4Material* foilMaterial = G4Material::GetMaterial(std::get<0>(foilLayer));
90 if (!foilMaterial) {
91 TG4Globals::Warning("TG4TransitionRadiationPhysics", "CreateXTRProcess",
92 TString("Foil material ") + std::get<0>(foilLayer).data() +
93 TString(" does not exist.") + TG4Globals::Endl() +
94 TString("The XTR process is not created."));
95 return false;
96 }
97
98 G4Material* gasMaterial = G4Material::GetMaterial(std::get<0>(gasLayer));
99 if (!gasMaterial) {
100 TG4Globals::Warning("TG4TransitionRadiationPhysics", "CreateXTRProcess",
101 TString("Gas material ") + std::get<0>(gasLayer).data() +
102 TString(" does not exist.") + TG4Globals::Endl() +
103 TString("The XTR process is not created."));
104 return false;
105 }
106
107 G4Material* strawTubeMaterial = 0;
108 if (std::get<0>(strawTube).size()) {
109 strawTubeMaterial = G4Material::GetMaterial(std::get<0>(strawTube));
110 if (!strawTubeMaterial) {
111 TG4Globals::Warning("TG4TransitionRadiationPhysics", "CreateXTRProcess",
112 TString("Straw tube material ") + std::get<0>(strawTube).data() +
113 TString(" does not exist.") + TG4Globals::Endl() +
114 TString("The XTR process is not created."));
115 return false;
116 }
117 }
118
119 // Get remaining parameters
120 G4int foilNumber = radiatorDescription->GetFoilNumber();
121 G4double foilThickness, foilFluctuation;
122 G4double gasThickness, gasFluctuation;
123 std::tie(std::ignore, foilThickness, foilFluctuation) = foilLayer;
124 std::tie(std::ignore, gasThickness, gasFluctuation) = gasLayer;
125
126 // Check if fluctuation parameters are defined when gamma models are selected
127 if ((xtrModel == "gammaR" || xtrModel == "gammaM") &&
128 (foilFluctuation * gasFluctuation == 0.)) {
129 TG4Globals::Warning("TG4TransitionRadiationPhysics", "CreateXTRProcess",
130 TString("The gamma-distributed thickness parameter must be defined for "
131 "both radiator layers") +
133 TString("when gammaR or gammaM model is selected.") +
134 TG4Globals::Endl() + TString("The XTR process is not created."));
135 return false;
136 }
137
138 G4bool isXtrProcess = false;
139 G4String volumeName = radiatorDescription->GetVolumeName();
140 G4LogicalVolumeStore* lvStore = G4LogicalVolumeStore::GetInstance();
141 for (G4int i = 0; i < G4int(lvStore->size()); ++i) {
142 G4LogicalVolume* logicalVolume = (*lvStore)[i];
143
144 if (logicalVolume->GetName() != volumeName) continue;
145
146 G4VXTRenergyLoss* xtrProcess = 0;
147 if (xtrModel == "gammaR") {
148 xtrProcess = new G4GammaXTRadiator(logicalVolume, foilFluctuation,
149 gasFluctuation, foilMaterial, gasMaterial, foilThickness, gasThickness,
150 foilNumber, "GammaXTRadiator");
151 }
152 else if (xtrModel == "gammaM") {
153 xtrProcess = new G4XTRGammaRadModel(logicalVolume, foilFluctuation,
154 gasFluctuation, foilMaterial, gasMaterial, foilThickness, gasThickness,
155 foilNumber, "GammaXTRadiator");
156 }
157 else if (xtrModel == "strawR") {
158 xtrProcess = new G4StrawTubeXTRadiator(logicalVolume, foilMaterial,
159 gasMaterial, std::get<1>(strawTube), std::get<2>(strawTube),
160 strawTubeMaterial, true, "StrawXTRadiator");
161 }
162 else if (xtrModel == "regR") {
163 xtrProcess =
164 new G4RegularXTRadiator(logicalVolume, foilMaterial, gasMaterial,
165 foilThickness, gasThickness, foilNumber, "RegularXTRadiator");
166 }
167 else if (xtrModel == "transpR") {
168 xtrProcess =
169 new G4TransparentRegXTRadiator(logicalVolume, foilMaterial, gasMaterial,
170 foilThickness, gasThickness, foilNumber, "RegularXTRadiator");
171 }
172 else if (xtrModel == "regM") {
173 xtrProcess =
174 new G4XTRRegularRadModel(logicalVolume, foilMaterial, gasMaterial,
175 foilThickness, gasThickness, foilNumber, "RegularXTRadiator");
176 }
177 else {
178 TString text = "XTR model <";
179 text += xtrModel.data();
180 text += " is not defined.";
182 "TG4TransitionRadiationPhysics", "CreateXTRProcess", text);
183 }
184
185 if (xtrProcess) {
186 fXtrProcesses->push_back(xtrProcess);
187 xtrProcess->SetVerboseLevel(VerboseLevel());
188 // CHECK if better to decrement this
189
190 // set process to e-, e+
191 G4Electron::Electron()->GetProcessManager()->AddDiscreteProcess(
192 xtrProcess);
193 G4Positron::Positron()->GetProcessManager()->AddDiscreteProcess(
194 xtrProcess);
195
196 isXtrProcess = true;
197 }
198 }
199
200 if (!isXtrProcess) {
201 TG4Globals::Warning("TG4TransitionRadiationPhysics", "CreateXTRProcess",
202 TString("Volume ") + volumeName.data() + TString(" does not exist.") +
203 TG4Globals::Endl() + TString("The XTR process is not created."));
204 }
205
206 return isXtrProcess;
207}
208
209//
210// protected methods
211//
212
213//_____________________________________________________________________________
218
219//_____________________________________________________________________________
221{
222 const std::vector<TG4RadiatorDescription*> radiators =
224
225 // nothing to be done if no radiators are defined
226 if (!radiators.size()) return;
227
228 if (!fXtrProcesses) {
229 fXtrProcesses = new std::vector<G4VXTRenergyLoss*>();
230 G4AutoDelete::Register(fXtrProcesses);
231 }
232
233 for (G4int i = 0; i < G4int(radiators.size()); ++i) {
234
235 // create XTR process
236 G4bool isXtrProcess = CreateXTRProcess(radiators[i]);
237 if (!isXtrProcess) continue;
238
239 if (VerboseLevel() > 1) {
240 G4cout << "Constructed XTR process " << radiators[i]->GetXtrModel()
241 << " in radiator " << radiators[i]->GetVolumeName() << G4endl;
242 }
243 }
244
245 if (VerboseLevel() > 0) {
246 G4cout << "### Transition radiation physics constructed." << G4endl;
247 }
248}
249
250//_____________________________________________________________________________
Definition of the TG4GeometryManager class.
Definition of the TG4GeometryServices class.
Definition of the TG4RadiatorDescription class.
Definition of the TG4TransitionRadiationPhysics class.
static TG4GeometryManager * Instance()
const std::vector< TG4RadiatorDescription * > & GetRadiators() const
static void Warning(const TString &className, const TString &methodName, const TString &text)
static TString Endl()
Definition TG4Globals.h:100
The radiator description.
G4String GetVolumeName() const
Return the name of associated volume.
Component GetStrawTube() const
Return the straw tube parameters.
Component GetLayer(G4int i) const
G4String GetXtrModel() const
Return the transition radiation process model.
G4int GetFoilNumber() const
Return the number of foils.
static G4ThreadLocal std::vector< G4VXTRenergyLoss * > * fXtrProcesses
virtual void ConstructProcess()
Construct physics processes.
virtual void ConstructParticle()
Construct particles.
TG4TransitionRadiationPhysics(const G4String &name="TransitionRadiation")
G4bool CreateXTRProcess(TG4RadiatorDescription *)
Abstract base class for physics constructors with verbose.
virtual G4int VerboseLevel() const