ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PHG4TRDDetector.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file PHG4TRDDetector.cc
1 #include "PHG4TRDDetector.h"
2 #include <g4main/PHG4Detector.h> // for PHG4Detector
3 #include <phparameter/PHParameters.h>
4 
5 #include <Geant4/G4Colour.hh>
6 #include <Geant4/G4Element.hh>
7 #include <Geant4/G4LogicalVolume.hh>
8 #include <Geant4/G4Material.hh>
9 #include <Geant4/G4PVDivision.hh>
10 #include <Geant4/G4PVPlacement.hh>
11 #include <Geant4/G4RotationMatrix.hh>
12 #include <Geant4/G4SystemOfUnits.hh>
13 #include <Geant4/G4ThreeVector.hh> // for G4ThreeVector
14 #include <Geant4/G4Tubs.hh>
15 #include <Geant4/G4VPhysicalVolume.hh> // for G4VPhysicalVolume
16 #include <Geant4/G4VisAttributes.hh>
17 
18 #include <cmath>
19 #include <iostream> // for operator<<, endl, bas...
20 
21 class PHCompositeNode;
22 class PHG4Subsystem;
23 
24 using namespace std;
25 
26 PHG4TRDDetector::PHG4TRDDetector(PHG4Subsystem *subsys, PHCompositeNode *Node, PHParameters *parameters, const std::string &dnam, const int lyr)
27  : PHG4Detector(subsys, Node, dnam)
28  , m_Params(parameters)
29  , Phys(nullptr)
30  , fPhysicsRadiator(nullptr)
31  , TRD_det_Phys(nullptr)
32  , MPGD_win_Phys(nullptr)
33  , Cathode_Phys(nullptr)
34  , Gas_Active(nullptr)
35  , GEM_top_Phys(nullptr)
36  , GEM_diel_Phys(nullptr)
37  , GEM_bottom_Phys(nullptr)
38  , MMG_mesh_Phys(nullptr)
39  , Res_lay_Phys(nullptr)
40  , MMG_strips_Phys(nullptr)
41  , PCB_Phys(nullptr)
42  , m_Active(m_Params->get_int_param("active"))
43  , m_AbsorberActive(m_Params->get_int_param("absorberactive"))
44  , m_Layer(lyr)
45 {
46 }
47 
48 //_______________________________________________________________
49 //_______________________________________________________________
51 {
52  if (m_Active)
53  {
54  if (volume == fPhysicsRadiator)
55  {
56  return -1;
57  }
58  }
59 
60  if (m_AbsorberActive)
61  {
62  if (volume == Gas_Active)
63  {
64  return 1;
65  }
66  }
67  return 0;
68 }
69 
70 //_______________________________________________________________
72 {
73  // Generic mother volume
74  //All other components of TRD will be in it
75  G4Material *TRDMaterial = GetDetectorMaterial(m_Params->get_string_param("material"));
76 
77  double RIn = m_Params->get_double_param("RIn") * cm; // 20.* cm
78  double ROut = m_Params->get_double_param("ROut") * cm; // 200 * cm
79  double ThicknessZ = m_Params->get_double_param("ThicknessZ") * cm; // 30. *cm
80  double PosZ = m_Params->get_double_param("PosZ") * cm; // none defined
81 
82  cout << "Mother CENTER Pos ( z ) :"
83  << " " << PosZ << " Mother length " << ThicknessZ << endl;
84 
85  G4Tubs *Solid = new G4Tubs("TRD_GVol_Solid", RIn, ROut, ThicknessZ / 2., 0., 360 * deg);
86  G4LogicalVolume *Logic = new G4LogicalVolume(Solid, TRDMaterial, "TRD_GVol_Logic", 0, 0, 0);
87  G4VisAttributes *attr_TRD_GVol = new G4VisAttributes(G4Color(0.3, 0.5, 0.9, 0.9));
88  //attr_TRD_GVol->SetColor(G4Color::Green());
89  attr_TRD_GVol->SetForceSolid(true);
90  Logic->SetVisAttributes(attr_TRD_GVol);
91  Phys = new G4PVPlacement(0, G4ThreeVector(0, 0, PosZ), Logic, "H_CAP_TRD_Physics", logicWorld, 0, false, OverlapCheck());
92 
93  //Radiator construction ---------
94  double det_RIn = m_Params->get_double_param("det_RIn") * cm;
95  double det_ROut = m_Params->get_double_param("det_ROut") * cm;
96  //Phase space distribution of radiators -------------
97  double fGasGap = 0.0600 * cm; // for ZEUS 300 publication
98  double fDetGap = 0.001 * cm;
99  double fRadThickness = 0.0020 * cm; // 16 um // ZEUS NIMA 323 (1992) 135-139, D=20um, dens.= 0.1 g/cm3
100  //double fRadThick = 18.*cm - fGasGap + fDetGap ;
101  double fRadThick = 10. * cm - fGasGap + fDetGap;
102  // int fFoilNumber = 0;
103  //fFoilNumber = fRadThick / (fRadThickness + fGasGap);
104 
105  double fRadZ; // none defined
106  //fRadZ = -ThicknessZ/2. + fRadThick/2. + 2.* cm;
107  fRadZ = (-ThicknessZ / 2. + fRadThick / 2.);
108 
109  double foilGasRatio = fRadThickness / (fRadThickness + fGasGap);
110 
111  // ------ Define materials for radiator----------
112 
113  //G4Material *Mylar = GetDetectorMaterial("Mylar");
114  G4Material *Air = GetDetectorMaterial("G4_AIR");
115  //G4Material *Al = GetDetectorMaterial("G4_Al");
116  //G4Material *CH2 = GetDetectorMaterial("G4_CH2");
117  //G4Material *He = GetDetectorMaterial("He");
118 
119  double a_c = 12.0107 * g / mole;
120  G4Element *Carbon = new G4Element("Carbon", "C", 6, a_c);
121  double a_h = 1.01 * g / mole;
122  G4Element *Hydrogen = new G4Element("Hydrogen", "H", 1, a_h);
123 
124  double density_ch2 = 0.935 * g / cm3; // g/cm^3
125  G4Material *CH2 = new G4Material("CH2", density_ch2, 2);
126  CH2->AddElement(Carbon, 1);
127  CH2->AddElement(Hydrogen, 2);
128 
129  double foilDensity = 0.91 * g / cm3; // CH2 1.39*g/cm3; // Mylar // 0.534*g/cm3; //Li
130  double gasDensity = 1.2928 * mg / cm3; // Air // 1.977*mg/cm3; // CO2 0.178*mg/cm3; // He
131  double totDensity = foilDensity * foilGasRatio + gasDensity * (1.0 - foilGasRatio);
132  double fractionFoil = foilDensity * foilGasRatio / totDensity;
133  double fractionGas = gasDensity * (1.0 - foilGasRatio) / totDensity;
134 
135  G4Material *radiatorMat0 = new G4Material("radiatorMat0", totDensity, 2);
136  radiatorMat0->AddMaterial(CH2, fractionFoil);
137  radiatorMat0->AddMaterial(Air, fractionGas);
138  double NewDensity = 0.083 * (g / cm3);
139  G4Material *radiatorMat = new G4Material("radiatorMat", NewDensity, 1);
140  radiatorMat->AddMaterial(radiatorMat0, 1.);
141 
142  //------------------------end --material -------------------------------
143 
144  //Define all sorts of G4 volumes
145  G4Tubs *fSolidRadiator = new G4Tubs("TRD_Radiator_Solid", det_RIn, det_ROut, 0.5 * fRadThick, 0., 360 * deg);
146  G4LogicalVolume *fLogicRadiator = new G4LogicalVolume(fSolidRadiator, radiatorMat, "TRD_Radiator_Logic", 0, 0, 0);
147 
148  G4VisAttributes *TRD_rad_att = new G4VisAttributes();
149  TRD_rad_att->SetColour(G4Colour::Blue());
150  TRD_rad_att->SetVisibility(true);
151  TRD_rad_att->SetForceSolid(true);
152  fLogicRadiator->SetVisAttributes(TRD_rad_att);
153 
154  fPhysicsRadiator = new G4PVPlacement(0, G4ThreeVector(0, 0, fRadZ), fLogicRadiator, "TRD_Radiator_Phys", Logic, 0, false, OverlapCheck()); // Placing the Radiator in global detector volume "Phys". Phys has been placed in world volume earlier
155  /*
156  G4Region *fRadRegion = new G4Region("XTRradiator");
157  fRadRegion->AddRootLogicalVolume(fLogicRadiator);
158  */
159 
160  // Absorber (Xe gas with MPGD)
161 
162  //Cover for gas
163  //Mylar cover
164  double window_th = 0.002 * cm;
165  //double off = 0.001*cm;
166  // double window_pos_Z = -1.0 * det_ThicknessZ/2 + off;
167  double window_pos_Z = fRadZ + fRadThick / 2. + window_th / 2.;
168  G4Material *window_Material = GetDetectorMaterial("G4_MYLAR");
169 
170  G4Tubs *MPGD_win_Solid = new G4Tubs("MPGD_win_Solid", det_RIn, det_ROut, window_th / 2., 0., 360 * deg);
171  ;
172  G4LogicalVolume *MPGD_win_Logic = new G4LogicalVolume(MPGD_win_Solid, window_Material, "MPGD_win_Logic", 0, 0, 0);
173  G4VisAttributes *MPGD_win_att = new G4VisAttributes();
174  MPGD_win_att->SetColour(G4Colour::Gray());
175  MPGD_win_att->SetVisibility(true);
176  MPGD_win_att->SetForceSolid(true);
177  MPGD_win_Logic->SetVisAttributes(MPGD_win_att);
178 
179  MPGD_win_Phys = new G4PVPlacement(0, G4ThreeVector(0, 0, window_pos_Z), MPGD_win_Logic, "MPGD_win_Phys", Logic, 0, false, OverlapCheck());
180 
181  double det_ThicknessZ = 2.5 * cm;
182  // double det_Pos_Z = fRadZ+ fRadThick/2. + det_ThicknessZ/2. ;
183  double det_Pos_Z = window_pos_Z + window_th / 2. + det_ThicknessZ / 2.;
184  //G4Material *det_Material = GetDetectorMaterial("G4_Xe");
185  G4Material *det_Material = GetDetectorMaterial("G4_AIR");
186 
187  G4Tubs *TRD_det_Solid = new G4Tubs("TRD_det_Solid", det_RIn, det_ROut, det_ThicknessZ / 2., 0., 360 * deg);
188  ;
189  G4LogicalVolume *TRD_det_Logic = new G4LogicalVolume(TRD_det_Solid, det_Material, "TRD_det_Logic", 0, 0, 0);
190  G4VisAttributes *TRD_det_att = new G4VisAttributes();
191  TRD_det_att->SetColour(G4Colour::Red());
192  TRD_det_att->SetVisibility(true);
193  TRD_det_att->SetForceSolid(true);
194  TRD_det_Logic->SetVisAttributes(TRD_det_att);
195 
196  TRD_det_Phys = new G4PVPlacement(0, G4ThreeVector(0, 0, det_Pos_Z), TRD_det_Logic, "TRD_det_Phys", Logic, 0, false, OverlapCheck()); // Placing the MPGD with Xe in global detector volume "Phys". Phys has been placed in world volume earlier
197 
198  cout << " det RIN :" << det_RIn << " det ROUT :" << det_ROut << endl;
199 
200  //Define MPGD detector with drift cathode and R/o. These are the daughter of TRD_det_Logic
201 
202  //construct drift cathode
203 
204  double cat_th = 0.005 * cm;
205  double dead_ar = 0.01 * cm;
206  G4Material *G4_Al = GetDetectorMaterial("G4_Al");
207  G4Material *myCatMesh = new G4Material("myCatMesh", 0.9 * g / cm3, G4_Al, kStateSolid); // Density of Al reduced considering it's a mesh
208 
209  G4Tubs *Cathode = new G4Tubs("Cathode", det_RIn, det_ROut, cat_th / 2., 0., 360 * deg);
210  G4LogicalVolume *Cathode_Logic = new G4LogicalVolume(Cathode, myCatMesh, " Cathode_Logic", 0, 0, 0);
211  G4VisAttributes *Cathode_att = new G4VisAttributes();
212  Cathode_att->SetColour(G4Colour::Magenta());
213  Cathode_att->SetVisibility(true);
214  Cathode_att->SetForceSolid(true);
215  Cathode_Logic->SetVisAttributes(Cathode_att);
216  double cat_pos = -1.0 * det_ThicknessZ / 2. + dead_ar + cat_th / 2.;
217 
218  Cathode_Phys = new G4PVPlacement(0, G4ThreeVector(0, 0, cat_pos), Cathode_Logic, "Cathode_Phys", TRD_det_Logic, 0, false, OverlapCheck());
219 
220  //construct active gas volume upto top GEM
221  double gas_thick = 2.0 * cm;
222  G4Material *gas_act = GetDetectorMaterial("G4_Xe");
223  G4Tubs *drift_gas = new G4Tubs("drift_gas", det_RIn, det_ROut, gas_thick / 2., 0., 360 * deg);
224  G4LogicalVolume *gas_Logic = new G4LogicalVolume(drift_gas, gas_act, "gas_Logic", 0, 0, 0);
225  G4VisAttributes *gas_att = new G4VisAttributes();
226  gas_att->SetColour(G4Colour::Green());
227  gas_att->SetVisibility(true);
228  gas_att->SetForceSolid(true);
229  gas_Logic->SetVisAttributes(gas_att);
230  double gas_pos = cat_pos + cat_th / 2. + gas_thick / 2.;
231 
232  Gas_Active = new G4PVPlacement(0, G4ThreeVector(0, 0, gas_pos), gas_Logic, "Gas_Active", TRD_det_Logic, 0, false, OverlapCheck());
233 
234  // construct GEMs and MMG and R/o
235  //GEMs + top + below region dimensions
236  double cu_th = 0.0005 * cm;
237  // double dr_gap = 2.0*cm;
238  double tr_gap = 0.2 * cm;
239  double kap_th = 0.005 * cm;
240  G4Material *gem_cond = GetDetectorMaterial("G4_Cu");
241  G4Material *gem_diel = GetDetectorMaterial("G4_KAPTON");
242 
243  //MMG + below dimensions
244  double av_gap = 0.014 * cm;
245  double mesh_th = 0.0012 * cm;
246 
247  G4Material *G4_Cr = GetDetectorMaterial("G4_Cr");
248  G4Material *G4_Fe = GetDetectorMaterial("G4_Fe");
249  G4Material *G4_Mn = GetDetectorMaterial("G4_Mn");
250  G4Material *G4_Ni = GetDetectorMaterial("G4_Ni");
251  G4Material *G4_Si = GetDetectorMaterial("G4_Si");
252  G4Material *G4_O = GetDetectorMaterial("G4_O");
253  G4Material *G4_H = GetDetectorMaterial("G4_H");
254 
255  G4Material *myMMMesh = new G4Material("myMMMesh", 2.8548 * g / cm3, 5, kStateSolid);
256  myMMMesh->AddMaterial(G4_Cr, 0.1900);
257  myMMMesh->AddMaterial(G4_Fe, 0.6800);
258  myMMMesh->AddMaterial(G4_Mn, 0.0200);
259  myMMMesh->AddMaterial(G4_Ni, 0.1000);
260  myMMMesh->AddMaterial(G4_Si, 0.0100);
261 
262  //R/o dimensions
263  double res_th = 0.0020 * cm;
264  double pcb_th = 0.01 * cm;
265  double cu_st_th = 0.0012 * cm;
266 
267  G4Material *G4_C = GetDetectorMaterial("G4_C");
268  G4Material *Reslay = new G4Material("Reslay", 0.77906 * g / cm3, G4_C, kStateSolid);
269 
270  G4Material *G4_Cu = GetDetectorMaterial("G4_Cu");
271  G4Material *MMstrips = new G4Material("MMstrips", 5.28414 * g / cm3, G4_Cu, kStateSolid);
272 
273  G4Material *myFR4 = new G4Material("myFR4", 1.860 * g / cm3, 4, kStateSolid);
274  myFR4->AddMaterial(G4_C, 0.43550);
275  myFR4->AddMaterial(G4_H, 0.03650);
276  myFR4->AddMaterial(G4_O, 0.28120);
277  myFR4->AddMaterial(G4_Si, 0.24680);
278 
279  G4Tubs *GEM_top_Solid = new G4Tubs("GEM_top_Solid", det_RIn, det_ROut, cu_th / 2., 0., 360 * deg);
280  G4LogicalVolume *GEM_top_Logic = new G4LogicalVolume(GEM_top_Solid, gem_cond, "GEM_top_Logic", 0, 0, 0);
281  G4VisAttributes *GEM_top_att = new G4VisAttributes();
282  GEM_top_att->SetColour(G4Colour::Yellow());
283  GEM_top_att->SetVisibility(true);
284  GEM_top_att->SetForceSolid(true);
285  GEM_top_Logic->SetVisAttributes(GEM_top_att);
286  //double gem_top_z = /*window_pos_Z + window_th/2. + dr_gap + cu_th/2.*/ -1.0*det_ThicknessZ/2. + dr_gap + cu_th/2. ;
287  //double gem_top_z = cat_pos + cat_th/2. + dr_gap + cu_th/2;
288  double gem_top_z = gas_pos + gas_thick / 2. + cu_th / 2;
289  GEM_top_Phys = new G4PVPlacement(0, G4ThreeVector(0, 0, gem_top_z), GEM_top_Logic, "GEM_top_Phys", TRD_det_Logic, 0, false, OverlapCheck());
290 
291  G4Tubs *GEM_diel_Solid = new G4Tubs("GEM_diel_Solid", det_RIn, det_ROut, kap_th / 2., 0., 360 * deg);
292  G4LogicalVolume *GEM_diel_Logic = new G4LogicalVolume(GEM_diel_Solid, gem_diel, "GEM_diel_Logic", 0, 0, 0);
293  G4VisAttributes *GEM_diel_att = new G4VisAttributes();
294  GEM_diel_att->SetColour(G4Colour::Green());
295  GEM_diel_att->SetVisibility(true);
296  GEM_diel_att->SetForceSolid(true);
297  GEM_diel_Logic->SetVisAttributes(GEM_diel_att);
298 
299  double diel_z = gem_top_z + cu_th / 2. + kap_th / 2.;
300 
301  GEM_diel_Phys = new G4PVPlacement(0, G4ThreeVector(0, 0, diel_z), GEM_diel_Logic, "GEM_diel_Phys", TRD_det_Logic, 0, false, OverlapCheck());
302 
303  G4Tubs *GEM_bottom_Solid = new G4Tubs("GEM_bottom_Solid", det_RIn, det_ROut, cu_th / 2., 0., 360 * deg);
304  G4LogicalVolume *GEM_bottom_Logic = new G4LogicalVolume(GEM_bottom_Solid, gem_cond, "GEM_bottom_Logic", 0, 0, 0);
305  G4VisAttributes *GEM_bottom_att = new G4VisAttributes();
306  GEM_bottom_att->SetColour(G4Colour::Yellow());
307  GEM_bottom_att->SetVisibility(true);
308  GEM_bottom_att->SetForceSolid(true);
309  GEM_bottom_Logic->SetVisAttributes(GEM_bottom_att);
310 
311  double gem_bot_z = diel_z + kap_th / 2. + cu_th / 2.;
312  GEM_bottom_Phys = new G4PVPlacement(0, G4ThreeVector(0, 0, gem_bot_z), GEM_bottom_Logic, "GEM_bottom_Phys", TRD_det_Logic, 0, false, OverlapCheck());
313 
314  G4Tubs *MMG_mesh_Solid = new G4Tubs("MMG_mesh_Solid", det_RIn, det_ROut, cu_th / 2., 0., 360 * deg);
315  G4LogicalVolume *MMG_mesh_Logic = new G4LogicalVolume(MMG_mesh_Solid, myMMMesh, "MMG_mesh_Logic", 0, 0, 0);
316  G4VisAttributes *MMG_mesh_att = new G4VisAttributes();
317  MMG_mesh_att->SetColour(G4Colour::Brown());
318  MMG_mesh_att->SetVisibility(true);
319  MMG_mesh_att->SetForceSolid(true);
320  MMG_mesh_Logic->SetVisAttributes(MMG_mesh_att);
321 
322  double mmg_mesh_z = gem_bot_z + cu_th / 2. + tr_gap + mesh_th / 2.;
323  MMG_mesh_Phys = new G4PVPlacement(0, G4ThreeVector(0, 0, mmg_mesh_z), MMG_mesh_Logic, "MMG_mesh_Phys", TRD_det_Logic, 0, false, OverlapCheck());
324 
325  G4Tubs *Res_lay_Solid = new G4Tubs("Res_lay_Solid", det_RIn, det_ROut, res_th / 2., 0., 360 * deg);
326  G4LogicalVolume *Res_lay_Logic = new G4LogicalVolume(Res_lay_Solid, Reslay, "Res_lay_Logic", 0, 0, 0);
327  G4VisAttributes *Res_lay_att = new G4VisAttributes();
328  Res_lay_att->SetColour(G4Colour::Brown());
329  Res_lay_att->SetVisibility(true);
330  Res_lay_att->SetForceSolid(true);
331  Res_lay_Logic->SetVisAttributes(Res_lay_att);
332 
333  double res_lay_z = mmg_mesh_z + mesh_th / 2. + av_gap + res_th / 2.;
334  Res_lay_Phys = new G4PVPlacement(0, G4ThreeVector(0, 0, res_lay_z), Res_lay_Logic, "Res_lay_Phys", TRD_det_Logic, 0, false, OverlapCheck());
335 
336  G4Tubs *MMG_strips_Solid = new G4Tubs("MMG_strips_Solid", det_RIn, det_ROut, cu_st_th / 2., 0., 360. * deg);
337  G4LogicalVolume *MMG_strips_Logic = new G4LogicalVolume(MMG_strips_Solid, MMstrips, "MMG_strips_Logic", 0, 0, 0);
338  G4VisAttributes *MMG_strips_att = new G4VisAttributes();
339  MMG_strips_att->SetColour(G4Colour::Yellow());
340  MMG_strips_att->SetVisibility(true);
341  MMG_strips_att->SetForceSolid(true);
342  MMG_strips_Logic->SetVisAttributes(MMG_strips_att);
343 
344  double mmg_str_z = res_lay_z + res_th / 2. + cu_st_th / 2.;
345  MMG_strips_Phys = new G4PVPlacement(0, G4ThreeVector(0, 0, mmg_str_z), MMG_strips_Logic, "MMG_strips_Phys", TRD_det_Logic, 0, false, OverlapCheck());
346 
347  G4Tubs *PCB_Solid = new G4Tubs("PCB_Solid", det_RIn, det_ROut, pcb_th / 2., 0., 360. * deg);
348  G4LogicalVolume *PCB_Logic = new G4LogicalVolume(PCB_Solid, myFR4, "PCB_Logic", 0, 0, 0);
349  G4VisAttributes *PCB_att = new G4VisAttributes();
350  PCB_att->SetColour(G4Colour::Green());
351  PCB_att->SetVisibility(true);
352  PCB_att->SetForceSolid(true);
353  PCB_Logic->SetVisAttributes(PCB_att);
354 
355  double pcb_z = mmg_str_z + cu_st_th / 2. + pcb_th / 2.;
356  PCB_Phys = new G4PVPlacement(0, G4ThreeVector(0, 0, pcb_z), PCB_Logic, "PCB_Phys", TRD_det_Logic, 0, false, OverlapCheck());
357 
358  /*
359  G4Region * fRegGasDet = new G4Region("XTRdEdxDetector");
360  fRegGasDet->AddRootLogicalVolume(TRD_det_Logic);
361  */
362 }