EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4_TTL_EIC.C
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file G4_TTL_EIC.C
1 #ifndef MACRO_G4TTLEIC_C
2 #define MACRO_G4TTLEIC_C
3 
4 #include "GlobalVariables.C"
5 
9 
10 #include <g4main/PHG4Reco.h>
11 
12 #include <string>
13 
14 R__LOAD_LIBRARY(libg4detectors.so)
15 
16 int make_forward_station(string name, PHG4Reco *g4Reco, double zpos, double Rmin,
17  double Rmax,double tSilicon, double xoffset=0);
18 int make_forward_station_basic(string name, PHG4Reco *g4Reco, double zpos, double Rmin,
19  double Rmax,double tSilicon);
20 int make_barrel_layer_basic(string name, PHG4Reco *g4Reco,
21  double radius, double halflength, double tSilicon, double zOffset);
22 int make_barrel_layer_LYSO_basic(string name, PHG4Reco *g4Reco,
23  double radius, double halflength, double tSilicon, double zOffset);
24 int make_barrel_layer(string name, PHG4Reco *g4Reco,
25  double radius, double halflength, double tSilicon, double zOffset);
26 
27 //-----------------------------------------------------------------------------------//
28 namespace Enable
29 {
30  bool FTTL = false;
31  bool ETTL = false;
32  bool CTTL = false;
33  bool FTTL_CLUSTER = false;
34  bool ETTL_CLUSTER = false;
35 }
36 
37 namespace G4TTL
38 {
39  int layer[3] = { 2, 1, 2};
40  double positionToVtx[3][3] = { {-169., -172., -309.5}, {80., 114.7, 0. }, { 287., 289., 340.} };
41  double minExtension[3][3] = { {8, 8, 15.3}, {218, 180, 0 }, {11.62, 11.7, 13.8 } };
42  double maxExtension[3][3] = { {61., 61. , 200}, {-40, 0, 0 }, {170., 170., 250 } };
43  namespace SETTING
44  {
45  bool optionCEMC = true;
46  bool optionEEMCH = true;
47  bool optionBasicGeo = false;
48  bool optionLYSO = false;
49  int optionDR = 0;
50  int optionGeo = 1;
51  int optionGran = 1;
52  } // namespace SETTING
53 } // namespace G4FHCAL
54 
55 
56 //-----------------------------------------------------------------------------------//
57 void TTL_Init()
58 {
61 
63  G4TTL::positionToVtx[0][0] = -155.5;
64  G4TTL::positionToVtx[0][1] = -158.5;
65  }
66 
68  G4TTL::maxExtension[0][0] = 80.;
69  G4TTL::maxExtension[0][1] = 80.;
70  G4TTL::positionToVtx[1][0] = 92.;
72  }
73 
75  G4TTL::minExtension[1][0] = 180;
76  G4TTL::maxExtension[1][0] = -25;
77  }
78 
79  if (G4TTL::SETTING::optionGeo == 1){
80  cout << "TTL setup infront of ECals with 2 layers fwd/bwd & 1 layer barrel" << endl;
81  } if (G4TTL::SETTING::optionGeo == 2){
82  cout << "TTL setup infront of ECals with 2 layers fwd/bwd & 1 layer barrel, lower barrel layer" << endl;
83  G4TTL::positionToVtx[1][0] = 50.;
85  G4TTL::minExtension[1][0] = 100.;
86  G4TTL::maxExtension[1][0] = 0.;
87  } if (G4TTL::SETTING::optionGeo == 3){
88  cout << "TTL setup infront of ECals with 1 layers fwd/bwd & 1 layer barrel, lower barrel layer" << endl;
89  G4TTL::positionToVtx[1][0] = 50.;
91  G4TTL::minExtension[1][0] = 100.;
92  G4TTL::maxExtension[1][0] = 0.;
93  G4TTL::layer[0] = 1;
94  G4TTL::layer[2] = 1;
101  } if (G4TTL::SETTING::optionGeo == 4){
102  cout << "TTL setup infront of ECals with 2 layers fwd/bwd & 1 layer barrel, 1 layer before HCals everywhere" << endl;
103  G4TTL::layer[0] = 3;
104  G4TTL::layer[1] = 2;
106  G4TTL::layer[2] = 3;
107  }
108 
110  cout << "TTL setup infront of ECals with 2 layers fwd/bwd & 1 layer barrel, 1 layer before HCals everywhere choosen!" << endl;
111  cout << "conflicting in forward region with DR calo, reducing by 1 layer!" << endl;
112  G4TTL::layer[2] = 2;
113  } else if (G4TTL::SETTING::optionDR == 1 && G4TTL::SETTING::optionGeo == 4 ){
114  cout << "TTL setup infront of ECals with 2 layers fwd/bwd & 1 layer barrel, 1 layer before HCals everywhere choosen!" << endl;
115  cout << "conflicting in forward region with DR calo, reducing adding larger cutout!" << endl;
116  G4TTL::minExtension[2][2] = 2.5;
117  }
118 
119 }
120 //-----------------------------------------------------------------------------------//
121 void FTTLSetup(PHG4Reco *g4Reco, TString fttloption = "")
122 {
123  const double cm = PHG4Sector::Sector_Geometry::Unit_cm();
124  const double mm = .1 * cm;
125  const double um = 1e-3 * mm;
126 
127  for (Int_t i = 0; i < G4TTL::layer[2]; i++){
128  cout << G4TTL::positionToVtx[2][i] << "\t" << G4TTL::minExtension[2][i] << "\t" << G4TTL::maxExtension[2][i] << endl;
130  make_forward_station(Form("FTTL_%d", i), g4Reco, G4TTL::positionToVtx[2][i], G4TTL::minExtension[2][i], G4TTL::maxExtension[2][i], 85*um, 6.0);
131  } else {
132  make_forward_station_basic(Form("FTTL_%d", i), g4Reco, G4TTL::positionToVtx[2][i], G4TTL::minExtension[2][i], G4TTL::maxExtension[2][i], 85*um);
133  }
134  }
135 }
136 
137 
138 //-----------------------------------------------------------------------------------//
139 void ETTLSetup(PHG4Reco *g4Reco, TString ettloption = "")
140 {
141  const double cm = PHG4Sector::Sector_Geometry::Unit_cm();
142  const double mm = .1 * cm;
143  const double um = 1e-3 * mm;
144  for (Int_t i = 0; i < G4TTL::layer[0]; i++){
145  cout << G4TTL::positionToVtx[0][i] << "\t" << G4TTL::minExtension[0][i] << "\t" << G4TTL::maxExtension[0][i] << endl;
147  make_forward_station(Form("ETTL_%d", i), g4Reco, G4TTL::positionToVtx[0][i], G4TTL::minExtension[0][i], G4TTL::maxExtension[0][i], 85*um, 0);
148  } else {
149  make_forward_station_basic(Form("ETTL_%d", i), g4Reco, G4TTL::positionToVtx[0][i], G4TTL::minExtension[0][i], G4TTL::maxExtension[0][i], 85*um);
150  }
151  }
152 }
153 
154 //-----------------------------------------------------------------------------------//
155 void CTTLSetup(PHG4Reco *g4Reco, TString cttloption = "")
156 {
157  const double cm = PHG4Sector::Sector_Geometry::Unit_cm();
158  const double mm = .1 * cm;
159  const double um = 1e-3 * mm;
160 
161  for (Int_t i = 0; i < G4TTL::layer[1]; i++){
162  cout << "Radius: " << G4TTL::positionToVtx[1][i] << "\tLength: " << G4TTL::minExtension[1][i] << "\tz-Offset: " << G4TTL::maxExtension[1][i] << endl;
164  make_barrel_layer_LYSO_basic(Form("CTTL_%d",i), g4Reco, G4TTL::positionToVtx[1][i], G4TTL::minExtension[1][i], 85*um, G4TTL::maxExtension[1][i]);
166  make_barrel_layer_basic(Form("CTTL_%d",i), g4Reco, G4TTL::positionToVtx[1][i], G4TTL::minExtension[1][i], 85*um, G4TTL::maxExtension[1][i]);
167  } else {
168  make_barrel_layer(Form("CTTL_%d",i), g4Reco, G4TTL::positionToVtx[1][i], G4TTL::minExtension[1][i], 85*um, G4TTL::maxExtension[1][i]);
169  }
170  }
171 }
172 
173 
174 //-----------------------------------------------------------------------------------//
175 int make_forward_station(string name, PHG4Reco *g4Reco,
176  double zpos, double rMin, double rMax,
177  double tSilicon, //silicon thickness
178  double xoffset = 0 )
179 {
180  cout << "r min: " << rMin << "\t r max: " << rMax << "\t z: " << zpos << endl;
181 
182  // always facing the interaction point
183  double polar_angle = 0;
184  if (zpos < 0){
185  zpos = -zpos;
186  polar_angle = M_PI;
187  }
188 
190  ttl = new PHG4TTLSubsystem(name);
191  ttl->SetDetailed(false);
192  ttl->SuperDetector(name);
193  ttl->set_double_param("polar_angle", polar_angle); //
194  ttl->set_int_param("isForward", 1); //
195  ttl->set_double_param("place_z", zpos * cm); //
196  ttl->set_double_param("rMin", rMin * cm); //
197  ttl->set_double_param("rMax", rMax * cm); //
198  ttl->set_double_param("offset_x", xoffset * cm); //
199  ttl->set_double_param("tSilicon", tSilicon); //
201 
202  g4Reco->registerSubsystem(ttl);
203  return 0;
204 }
205 
206 
207 //-----------------------------------------------------------------------------------//
209  double zpos, double rmin, double rmax,
210  double tSilicon) //silicon thickness
211 {
212  // cout
213  // << "make_GEM_station - GEM construction with PHG4SectorSubsystem - make_GEM_station_EdgeReadout of "
214  // << name << endl;
215 
216  // always facing the interaction point
217  double etamin = -TMath::Log(TMath::Tan(rmin/TMath::Abs(zpos)/2));
218  double etamax = -TMath::Log(TMath::Tan(rmax/TMath::Abs(zpos)/2));
219 
220  double polar_angle = 0;
221  if (zpos < 0){
222  zpos = -zpos;
223  polar_angle = M_PI;
224  etamin = -etamin;
225  etamax = -etamax;
226  }
227  if (etamax < etamin){
228  double t = etamax;
229  etamax = etamin;
230  etamin = t;
231  }
232 
234  ttl = new PHG4SectorSubsystem(name);
235 
236  ttl->SuperDetector(name);
237 
238  ttl->get_geometry().set_normal_polar_angle(polar_angle);
244  ttl->get_geometry().set_N_Sector(1);
245  ttl->get_geometry().set_material("G4_AIR");
247 
248  const double cm = PHG4Sector::Sector_Geometry::Unit_cm();
249  const double mm = .1 * cm;
250  const double um = 1e-3 * mm;
251  // build up layers
252 
253  ttl->get_geometry().AddLayer("SiliconSensor", "G4_Si", tSilicon, true, 100);
254  ttl->get_geometry().AddLayer("Metalconnection", "G4_Al", 100 * um, false, 100);
255  ttl->get_geometry().AddLayer("HDI", "G4_KAPTON", 20 * um, false, 100);
256  ttl->get_geometry().AddLayer("Cooling", "G4_WATER", 100 * um, false, 100);
257  ttl->get_geometry().AddLayer("Support", "G4_GRAPHITE", 50 * um, false, 100);
258  ttl->get_geometry().AddLayer("Support_Gap", "G4_AIR", 1 * cm, false, 100);
259  ttl->get_geometry().AddLayer("Support2", "G4_GRAPHITE", 50 * um, false, 100);
260 
261  g4Reco->registerSubsystem(ttl);
262  return 0;
263 }
264 
265 //-----------------------------------------------------------------------------------//
266 int make_barrel_layer(string name, PHG4Reco *g4Reco,
267  double radius, double halflength, double tSilicon, double zOffset )
268 {
269  // cout << "r min: " << rMin << "\t r max: " << rMax << "\t z: " << zpos << endl;
271  cout << "The improved barrel TTL layer is placed at a fixed radius of rMin = 80 * cm and is meant to only be used with the BECAL!" << endl;
272  }
274  ttl = new PHG4TTLSubsystem(name);
275  ttl->SetDetailed(false);
276  ttl->SuperDetector(name);
277  ttl->set_int_param("isForward", 0); //
278  ttl->set_double_param("place_z", zOffset * cm); //
279  ttl->set_double_param("rMin", radius * cm); //
280  ttl->set_double_param("length", 2.0 * halflength * cm);
281  ttl->set_double_param("tSilicon", tSilicon); //
283 
284  g4Reco->registerSubsystem(ttl);
285  return 0;
286 }
287 
288 
289 
290 
291 //-----------------------------------------------------------------------------------//
292 int make_barrel_layer_basic(string name, PHG4Reco *g4Reco,
293  double radius, double halflength, double tSilicon, double zOffset){
294 
295  //---------------------------------
296  //build barrel layer
297  //---------------------------------
298  const int nSubLayer = 7;
299 
300  string layerName[nSubLayer] = {"SiliconSensor", "Metalconnection", "HDI", "Cooling",
301  "Support1", "Support_Gap", "Support2"};
302  string material[nSubLayer] = {"G4_Si", "G4_Al", "G4_KAPTON", "G4_WATER",
303  "G4_GRAPHITE", "G4_AIR", "G4_GRAPHITE"};
304  double thickness[nSubLayer] = {tSilicon , 15 * um, 20 * um, 100 * um,
305  50 * um, 1, 50 * um};
306 
307  double max_bh_radius = 0.;
309 // cout << "started to create cylinder layer: " << name << endl;
310 
311  double currRadius = radius;
312 // cout << currRadius << endl;
313  for (int l = 0; l < nSubLayer; l++) {
314 // cout << name <<"_"<< layerName[l] << endl;
315  cyl = new PHG4CylinderSubsystem(name + "_" + layerName[l],l);
316  cyl->SuperDetector(name);
317  cyl->set_double_param("radius", currRadius);
318  cyl->set_double_param("length", 2.0 * halflength);
319  cyl->set_string_param("material", material[l]);
320  cyl->set_double_param("thickness", thickness[l]);
321  cyl->set_double_param("place_x", 0.);
322  cyl->set_double_param("place_y", 0.);
323  cyl->set_double_param("place_z", zOffset);
324 
325  if (l == 0) cyl->SetActive(); //only the Silicon Sensor is active
327  g4Reco->registerSubsystem(cyl);
328  currRadius = currRadius+thickness[l];
329 // cout << currRadius << endl;
330  }
331 
332  return 0;
333 }
334 
335 //-----------------------------------------------------------------------------------//
337  double radius, double halflength, double tSilicon, double zOffset){
338 
339  //---------------------------------
340  //build barrel layer
341  //---------------------------------
342  const int nSubLayer = 4;
343 
344  string layerName[nSubLayer] = {"Cooling", "Crystal","SiliconSensor", "Motherboard"};
345  string material[nSubLayer] = {"G4_Al", "LSO", "G4_Si", "FR4"};
346  double thickness[nSubLayer] = {0.031 * cm, 0.029 * cm, tSilicon, 0.033 * cm};
347 
348  double max_bh_radius = 0.;
350 // cout << "started to create cylinder layer: " << name << endl;
351 
352  double currRadius = radius;
353 // cout << currRadius << endl;
354  for (int l = 0; l < nSubLayer; l++) {
355 // cout << name <<"_"<< layerName[l] << endl;
356  cyl = new PHG4CylinderSubsystem(name + "_" + layerName[l],l);
357  cyl->SuperDetector(name);
358  cyl->set_double_param("radius", currRadius);
359  cyl->set_double_param("length", 2.0 * halflength);
360  cyl->set_string_param("material", material[l]);
361  cyl->set_double_param("thickness", thickness[l]);
362  cyl->set_double_param("place_x", 0.);
363  cyl->set_double_param("place_y", 0.);
364  cyl->set_double_param("place_z", zOffset);
365 
366  if (l == 2) cyl->SetActive(); //only the Silicon Sensor is active
368  g4Reco->registerSubsystem(cyl);
369  currRadius = currRadius+thickness[l];
370 // cout << currRadius << endl;
371  }
372 
373  return 0;
374 }
375 
376 
378 {
379  // int verbosity = std::max(Enable::VERBOSITY, Enable::MVTX_VERBOSITY);
381 
382  for (Int_t i = 0; i < G4TTL::layer[2]; i++){
384  RawDigitBuilderTTL *digits_FTTL = new RawDigitBuilderTTL(Form("DigitBuilder_FTTL%d",i));
385  digits_FTTL->Detector(Form("FTTL_%d", i));
386  // digits_FTTL->set_sim_tower_node_prefix("SIM");
387  se->registerSubsystem(digits_FTTL);
388  }
389  }
390 }
391 
393 {
394  // int verbosity = std::max(Enable::VERBOSITY, Enable::MVTX_VERBOSITY);
396 
397  for (Int_t i = 0; i < G4TTL::layer[0]; i++){
399  RawDigitBuilderTTL *digits_ETTL = new RawDigitBuilderTTL(Form("DigitBuilder_ETTL%d",i));
400  digits_ETTL->Detector(Form("ETTL_%d", i));
401  // digits_ETTL->set_sim_tower_node_prefix("SIM");
402  se->registerSubsystem(digits_ETTL);
403  }
404  }
405 }
406 
407 
408 #endif
409 
410 //-----------------------------------------------------------------------------------//