ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4_BToF.C
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file G4_BToF.C
1 #ifndef MACRO_G4BToF_C
2 #define MACRO_G4BToF_C
3 
4 #include <GlobalVariables.C>
5 
9 #include <g4main/PHG4Reco.h>
11 
12 R__LOAD_LIBRARY(libfun4all.so)
13 R__LOAD_LIBRARY(libg4testbench.so)
14 R__LOAD_LIBRARY(libg4detectors.so)
15 
16 namespace Enable
17 {
18  bool BTOF = false;
19  bool BTOF_OVERLAPCHECK = false;
20  int BTOF_VERBOSITY = 0;
21 } // namespace Enable
22 
23 namespace BTOF
24 {
25  const int gas_lyr = 6; // 1/2 of the total number of layers
26  const int mrpc_inn_lyr = 5; // 1/2 of the total number of layers
27  const double rad = 76.5; // cm
28  const double zpos = -60.0; // cm
29  const double length = 400.; //cm
30  int subsysID = 0;
31 } // namespace BTOF
32 
33 void BToFInit()
34 {
38 }
39 
40 double Build_G4_BTof(PHG4Reco* g4Reco,
41  double tof_rad = 82.0,
42  double zpos = -60.0,
43  double tof_length = 400.0)
44 {
46  bool OverlapCheck = Enable::OVERLAPCHECK || Enable::BTOF_OVERLAPCHECK;
47 
48  gSystem->Load("libfun4all");
49  gSystem->Load("libg4detectors.so");
50  gSystem->Load("libg4trackfastsim.so");
51 
52  double rsum = 0.0;
53 
54  //mRPC TOF parameters
55  double gas_gap = 0.0220; // 220 microns , 12 gas gaps
56  double mrpc_in_thick = 0.04; // 400 microns, 10 think glass
57  double mrpc_out_thick = 0.07; // 700 microns, 4 thick glass
58  double pcb_thickness = 0.06; // 600 microns, 3 PCBs
59  double cu_thickness = 0.003; // 30 microns, layer over pcb, (1 each on outer pcb and 2 on central pcb = 4)
60  double carbon_thickness = 0.01; // 100 microns , 2 layers
61  double mylar_thickness = 0.04; // 400 microns, 4 layers
62  double honeycomb_thickness = 0.75; // 7.5 mm, 2 honeycomb
63 
64  //-------------------------------
65  // mRPC material needs to change to plate glass (rad length 10.69 cm).
66  //Currently implemented G4_Si has rad length of 9.37 cm.
67  //Changing material to plate glass will increase radiation length by 10% w.r.t. to 1.X0(~10%)
68  // and the new radiation length will be 1.1X0 (~ 11%).Assuming G4_Si for mRPC is reasonable for the time being
69  //-----------------------------------
70 
71  PHG4CylinderSubsystem* tof_cyl;
72 
73  //Honeycomb
74  tof_cyl = new PHG4CylinderSubsystem("ToF_honeycomb_bottom", BTOF::subsysID);
75  tof_cyl->Verbosity(verbosity);
76  tof_cyl->set_double_param("radius", tof_rad);
77  tof_cyl->set_string_param("material", "NOMEX");
78  tof_cyl->set_double_param("thickness", honeycomb_thickness);
79  tof_cyl->set_int_param("lengthviarapidity", 0);
80  tof_cyl->set_double_param("place_z", zpos);
81  tof_cyl->set_double_param("length", tof_length);
82  tof_cyl->SuperDetector("bTOF");
83  tof_cyl->SetActive(0);
84  tof_cyl->OverlapCheck(OverlapCheck);
85  g4Reco->registerSubsystem(tof_cyl);
87  if (verbosity > 1) cout << " bottom HC :" << tof_rad << endl;
88 
89  //PCB
90  rsum = tof_rad + honeycomb_thickness;
91  tof_cyl = new PHG4CylinderSubsystem("ToF_pcb_bottom", BTOF::subsysID);
92  tof_cyl->Verbosity(verbosity);
93  tof_cyl->set_double_param("radius", rsum);
94  tof_cyl->set_string_param("material", "FR4");
95  tof_cyl->set_double_param("thickness", pcb_thickness);
96  tof_cyl->set_int_param("lengthviarapidity", 0);
97  tof_cyl->set_double_param("place_z", zpos);
98  tof_cyl->set_double_param("length", tof_length);
99  tof_cyl->SuperDetector("bTOF");
100  tof_cyl->SetActive(0);
101  tof_cyl->OverlapCheck(OverlapCheck);
102  g4Reco->registerSubsystem(tof_cyl);
103  ++BTOF::subsysID;
104  if (verbosity > 1) cout << " bototm PCB " << rsum << endl;
105 
106  //PCB Cu
107  rsum += pcb_thickness;
108  tof_cyl = new PHG4CylinderSubsystem("ToF_bottompcb_cu", BTOF::subsysID);
109  tof_cyl->Verbosity(verbosity);
110  tof_cyl->set_double_param("radius", rsum);
111  tof_cyl->set_string_param("material", "G4_Cu");
112  tof_cyl->set_double_param("thickness", cu_thickness);
113  tof_cyl->set_int_param("lengthviarapidity", 0);
114  tof_cyl->set_double_param("place_z", zpos);
115  tof_cyl->set_double_param("length", tof_length); // Length restricted to active area
116  tof_cyl->SuperDetector("bTOF");
117  tof_cyl->SetActive(0);
118  tof_cyl->OverlapCheck(OverlapCheck);
119  g4Reco->registerSubsystem(tof_cyl);
120  ++BTOF::subsysID;
121  if (verbosity > 1) cout << " PCB Cu :" << rsum << endl;
122 
123  //Mylar
124  rsum += cu_thickness;
125  tof_cyl = new PHG4CylinderSubsystem("ToF_mylar_bottom", BTOF::subsysID);
126  tof_cyl->Verbosity(verbosity);
127  tof_cyl->set_double_param("radius", rsum);
128  tof_cyl->set_string_param("material", "G4_MYLAR");
129  tof_cyl->set_double_param("thickness", mylar_thickness);
130  tof_cyl->set_int_param("lengthviarapidity", 0);
131  tof_cyl->set_double_param("place_z", zpos);
132  tof_cyl->set_double_param("length", tof_length);
133  tof_cyl->SuperDetector("bTOF");
134  tof_cyl->SetActive(0);
135  tof_cyl->OverlapCheck(OverlapCheck);
136  g4Reco->registerSubsystem(tof_cyl);
137  ++BTOF::subsysID;
138  if (verbosity > 1) cout << " Mylar : " << rsum << endl;
139 
140  //Carbon layer
141  rsum += mylar_thickness;
142  tof_cyl = new PHG4CylinderSubsystem("ToF_Carbon_bottom", BTOF::subsysID);
143  tof_cyl->set_double_param("radius", rsum);
144  tof_cyl->set_string_param("material", "G4_C");
145  tof_cyl->set_double_param("thickness", carbon_thickness);
146  tof_cyl->set_int_param("lengthviarapidity", 0);
147  tof_cyl->set_double_param("place_z", zpos);
148  tof_cyl->set_double_param("length", tof_length);
149  tof_cyl->SetActive(0);
150  tof_cyl->OverlapCheck(OverlapCheck);
151  g4Reco->registerSubsystem(tof_cyl);
152  ++BTOF::subsysID;
153  if (verbosity > 1) cout << " Carbon :" << rsum << endl;
154 
155  //Outside Glass layer
156  rsum += carbon_thickness;
157  tof_cyl = new PHG4CylinderSubsystem("ToF_glass_bottom", BTOF::subsysID);
158  tof_cyl->Verbosity(verbosity);
159  tof_cyl->set_double_param("radius", rsum);
160  tof_cyl->set_string_param("material", "G4_Si");
161  tof_cyl->set_double_param("thickness", mrpc_out_thick);
162  tof_cyl->set_int_param("lengthviarapidity", 0);
163  tof_cyl->set_double_param("place_z", zpos);
164  tof_cyl->set_double_param("length", tof_length);
165  tof_cyl->SuperDetector("bTOF");
166  tof_cyl->SetActive(0);
167  tof_cyl->OverlapCheck(OverlapCheck);
168  ++BTOF::subsysID;
169  g4Reco->registerSubsystem(tof_cyl);
170 
171  if (verbosity > 1) cout << " Glass outside :" << rsum << endl;
172 
173  //Active gas gap abd mRPC inner glass layers
174  double rsum_gasin_begin = rsum + mrpc_out_thick;
175  double rsum_innglass_begin = rsum_gasin_begin + gas_gap;
176  double rsum_gasin;
177  double rsum_innglass;
178  for (int layer = 0; layer < BTOF::gas_lyr; layer++)
179  {
180  rsum_gasin = rsum_gasin_begin + layer * gas_gap + layer * mrpc_in_thick;
181  tof_cyl = new PHG4CylinderSubsystem(Form("ToF_gas_%d", layer), BTOF::subsysID);
182  tof_cyl->Verbosity(verbosity);
183  tof_cyl->set_double_param("radius", rsum_gasin);
184  tof_cyl->set_string_param("material", "G4_Ar");
185  tof_cyl->set_double_param("thickness", gas_gap);
186  tof_cyl->set_int_param("lengthviarapidity", 0);
187  tof_cyl->set_double_param("place_z", zpos);
188  tof_cyl->set_double_param("length", tof_length);
189  tof_cyl->SuperDetector("bTOF");
190  tof_cyl->SetActive(1);
191  tof_cyl->OverlapCheck(OverlapCheck);
192  ++BTOF::subsysID;
193  g4Reco->registerSubsystem(tof_cyl);
194  if (verbosity > 1) cout << " gas inner" << layer << " : " << rsum_gasin << endl;
195 
197  {
198  rsum_innglass = rsum_gasin_begin + layer * mrpc_in_thick + (layer + 1) * gas_gap;
199  tof_cyl = new PHG4CylinderSubsystem(Form("ToF_inner_glass_%d", layer), BTOF::subsysID);
200  tof_cyl->Verbosity(verbosity);
201  tof_cyl->set_double_param("radius", rsum_innglass);
202  tof_cyl->set_string_param("material", "G4_Si");
203  tof_cyl->set_double_param("thickness", mrpc_in_thick);
204  tof_cyl->set_int_param("lengthviarapidity", 0);
205  tof_cyl->set_double_param("place_z", zpos);
206  tof_cyl->set_double_param("length", tof_length);
207  tof_cyl->SuperDetector("bTOF");
208  tof_cyl->SetActive(0);
209  tof_cyl->OverlapCheck(OverlapCheck);
210  ++BTOF::subsysID;
211  g4Reco->registerSubsystem(tof_cyl);
212  if (verbosity > 1) cout << " inner mrpc" << layer << " : " << rsum_innglass << endl;
213  }
214  }
215  rsum = rsum_gasin;
216 
217  //Middle thick Glass layer
218  rsum += gas_gap;
219  tof_cyl = new PHG4CylinderSubsystem("ToF_glass_bot_mid", BTOF::subsysID);
220  tof_cyl->Verbosity(verbosity);
221  tof_cyl->set_double_param("radius", rsum);
222  tof_cyl->set_string_param("material", "G4_Si");
223  tof_cyl->set_double_param("thickness", mrpc_out_thick);
224  tof_cyl->set_int_param("lengthviarapidity", 0);
225  tof_cyl->set_double_param("place_z", zpos);
226  tof_cyl->set_double_param("length", tof_length);
227  tof_cyl->SuperDetector("bTOF");
228  tof_cyl->SetActive(0);
229  tof_cyl->OverlapCheck(OverlapCheck);
230  ++BTOF::subsysID;
231  g4Reco->registerSubsystem(tof_cyl);
232  if (verbosity > 1) cout << " mid bottom glass :" << rsum << endl;
233 
234  //Middle Carbon layer
235  rsum += mrpc_out_thick;
236  tof_cyl = new PHG4CylinderSubsystem("ToF_Carbon_bot_mid", BTOF::subsysID);
237  tof_cyl->Verbosity(verbosity);
238  tof_cyl->set_double_param("radius", rsum);
239  tof_cyl->set_string_param("material", "G4_C");
240  tof_cyl->set_double_param("thickness", carbon_thickness);
241  tof_cyl->set_int_param("lengthviarapidity", 0);
242  tof_cyl->set_double_param("place_z", zpos);
243  tof_cyl->set_double_param("length", tof_length);
244  tof_cyl->SuperDetector("bTOF");
245  tof_cyl->SetActive(0);
246  tof_cyl->OverlapCheck(OverlapCheck);
247  ++BTOF::subsysID;
248  g4Reco->registerSubsystem(tof_cyl);
249  if (verbosity > 1) cout << " mid bottom Carbon :" << rsum << endl;
250 
251  //Middle mylar layer
252 
253  rsum += carbon_thickness;
254  tof_cyl = new PHG4CylinderSubsystem("ToF_mylar_bot_mid", BTOF::subsysID);
255  tof_cyl->Verbosity(verbosity);
256  tof_cyl->set_double_param("radius", rsum);
257  tof_cyl->set_string_param("material", "G4_MYLAR");
258  tof_cyl->set_double_param("thickness", mylar_thickness);
259  tof_cyl->set_int_param("lengthviarapidity", 0);
260  tof_cyl->set_double_param("place_z", zpos);
261  tof_cyl->set_double_param("length", tof_length);
262  tof_cyl->SuperDetector("bTOF");
263  tof_cyl->SetActive(0);
264  tof_cyl->OverlapCheck(OverlapCheck);
265  ++BTOF::subsysID;
266  g4Reco->registerSubsystem(tof_cyl);
267  if (verbosity > 1) cout << " Mid bottom Mylar : " << rsum << endl;
268 
269  //Middle PCB bottom Cu
270  rsum += mylar_thickness /*cu_thickness*/;
271  tof_cyl = new PHG4CylinderSubsystem("ToF_midpcb_cub", BTOF::subsysID);
272  tof_cyl->set_double_param("radius", rsum);
273  tof_cyl->set_string_param("material", "G4_Cu");
274  tof_cyl->set_double_param("thickness", cu_thickness);
275  tof_cyl->set_int_param("lengthviarapidity", 0);
276  tof_cyl->set_double_param("place_z", zpos);
277  tof_cyl->set_double_param("length", tof_length); // Length restricted to active area
278  tof_cyl->SetActive(0);
279  tof_cyl->OverlapCheck(OverlapCheck);
280  g4Reco->registerSubsystem(tof_cyl);
281  if (verbosity > 1) cout << " mid PCB bottom cu :" << rsum << endl;
282 
283  //Mid PCB
284  rsum += cu_thickness /*pcb_thickness*/;
285  tof_cyl = new PHG4CylinderSubsystem("ToF_pcb_mid", BTOF::subsysID);
286  tof_cyl->set_double_param("radius", rsum);
287  tof_cyl->set_string_param("material", "FR4");
288  tof_cyl->set_double_param("thickness", pcb_thickness);
289  tof_cyl->set_int_param("lengthviarapidity", 0);
290  tof_cyl->set_double_param("place_z", zpos);
291  tof_cyl->set_double_param("length", tof_length);
292  tof_cyl->SetActive(0);
293  tof_cyl->OverlapCheck(OverlapCheck);
294  ++BTOF::subsysID;
295  g4Reco->registerSubsystem(tof_cyl);
296  if (verbosity > 1) cout << " mid PCB " << rsum << endl;
297 
298  //Middle PCB top Cu
299  rsum += pcb_thickness;
300  tof_cyl = new PHG4CylinderSubsystem("ToF_midpcb_tcu", BTOF::subsysID);
301  tof_cyl->Verbosity(verbosity);
302  tof_cyl->set_double_param("radius", rsum);
303  tof_cyl->set_string_param("material", "G4_Cu");
304  tof_cyl->set_double_param("thickness", cu_thickness);
305  tof_cyl->set_int_param("lengthviarapidity", 0);
306  tof_cyl->set_double_param("place_z", zpos);
307  tof_cyl->set_double_param("length", tof_length); // Length restricted to active area
308  tof_cyl->SuperDetector("bTOF");
309  tof_cyl->SetActive(0);
310  tof_cyl->OverlapCheck(OverlapCheck);
311  ++BTOF::subsysID;
312  g4Reco->registerSubsystem(tof_cyl);
313  if (verbosity > 1) cout << " mid PCB top cu :" << rsum << endl;
314 
315  //Middle top mylar layer
316 
317  rsum += cu_thickness;
318  tof_cyl = new PHG4CylinderSubsystem("ToF_mylar_topmid", BTOF::subsysID);
319  tof_cyl->Verbosity(verbosity);
320  tof_cyl->set_double_param("radius", rsum);
321  tof_cyl->set_string_param("material", "G4_MYLAR");
322  tof_cyl->set_double_param("thickness", mylar_thickness);
323  tof_cyl->set_int_param("lengthviarapidity", 0);
324  tof_cyl->set_double_param("place_z", zpos);
325  tof_cyl->set_double_param("length", tof_length);
326  tof_cyl->SuperDetector("bTOF");
327  tof_cyl->SetActive(0);
328  tof_cyl->OverlapCheck(OverlapCheck);
329  ++BTOF::subsysID;
330  g4Reco->registerSubsystem(tof_cyl);
331  if (verbosity > 1) cout << " Mid top Mylar : " << rsum << endl;
332 
333  //Middle top carbon layer
334  rsum += mylar_thickness;
335  tof_cyl = new PHG4CylinderSubsystem("ToF_Carbon_top_mid", BTOF::subsysID);
336  tof_cyl->Verbosity(verbosity);
337  tof_cyl->set_double_param("radius", rsum);
338  tof_cyl->set_string_param("material", "G4_C");
339  tof_cyl->set_double_param("thickness", carbon_thickness);
340  tof_cyl->set_int_param("lengthviarapidity", 0);
341  tof_cyl->set_double_param("place_z", zpos);
342  tof_cyl->set_double_param("length", tof_length);
343  tof_cyl->SuperDetector("bTOF");
344  tof_cyl->SetActive(0);
345  tof_cyl->OverlapCheck(OverlapCheck);
346  ++BTOF::subsysID;
347  g4Reco->registerSubsystem(tof_cyl);
348  if (verbosity > 1) cout << " mid top Carbon :" << rsum << endl;
349 
350  //Middle top thick glass
351  rsum += carbon_thickness;
352  tof_cyl = new PHG4CylinderSubsystem("ToF_glass_top_mid", BTOF::subsysID);
353  tof_cyl->Verbosity(verbosity);
354  tof_cyl->set_double_param("radius", rsum);
355  tof_cyl->set_string_param("material", "G4_Si");
356  tof_cyl->set_double_param("thickness", mrpc_out_thick);
357  tof_cyl->set_int_param("lengthviarapidity", 0);
358  tof_cyl->set_double_param("place_z", zpos);
359  tof_cyl->set_double_param("length", tof_length);
360  tof_cyl->SuperDetector("bTOF");
361  tof_cyl->SetActive(0);
362  tof_cyl->OverlapCheck(OverlapCheck);
363  ++BTOF::subsysID;
364  g4Reco->registerSubsystem(tof_cyl);
365  if (verbosity > 1) cout << " mid top glass :" << rsum << endl;
366 
367  //Upper half gas gaps and mRPCs
368  //Active gas gap abd mRPC inner glass layers
369  double rsum_gasin_begin_uphalf = (rsum + mrpc_out_thick);
370  double rsum_innglass_begin_uphalf = (rsum_gasin_begin_uphalf + gas_gap);
371  double rsum_gasin_uphalf;
372  double rsum_innglass_uphalf;
373  for (int layer = 0; layer < BTOF::gas_lyr; layer++)
374  {
375  rsum_gasin_uphalf = rsum_gasin_begin_uphalf + layer * gas_gap + layer * mrpc_in_thick;
376  tof_cyl = new PHG4CylinderSubsystem(Form("ToF_gas_%d", layer + 6), BTOF::subsysID); //stupid way to implement indexing of active gas layer for the upper half of ToF
377  tof_cyl->Verbosity(verbosity);
378  tof_cyl->set_double_param("radius", rsum_gasin_uphalf);
379  tof_cyl->set_string_param("material", "G4_Ar");
380  tof_cyl->set_double_param("thickness", gas_gap);
381  tof_cyl->set_int_param("lengthviarapidity", 0);
382  tof_cyl->set_double_param("place_z", zpos);
383  tof_cyl->set_double_param("length", tof_length);
384  tof_cyl->SuperDetector("bTOF");
385  tof_cyl->SetActive(1);
386  tof_cyl->OverlapCheck(OverlapCheck);
387  ++BTOF::subsysID;
388  g4Reco->registerSubsystem(tof_cyl);
389  if (verbosity > 1) cout << " gas inner" << layer << " : " << rsum_gasin_uphalf << endl;
390 
392  {
393  rsum_innglass_uphalf = rsum_gasin_begin_uphalf + layer * mrpc_in_thick + (layer + 1) * gas_gap;
394  tof_cyl = new PHG4CylinderSubsystem(Form("ToF_inner_up_half_glass_%d", layer), BTOF::subsysID);
395  tof_cyl->Verbosity(verbosity);
396  tof_cyl->set_double_param("radius", rsum_innglass_uphalf);
397  tof_cyl->set_string_param("material", "G4_Si");
398  tof_cyl->set_double_param("thickness", mrpc_in_thick);
399  tof_cyl->set_int_param("lengthviarapidity", 0);
400  tof_cyl->set_double_param("place_z", zpos);
401  tof_cyl->set_double_param("length", tof_length);
402  tof_cyl->SuperDetector("bTOF");
403  tof_cyl->SetActive(0);
404  tof_cyl->OverlapCheck(OverlapCheck);
405  ++BTOF::subsysID;
406  g4Reco->registerSubsystem(tof_cyl);
407  if (verbosity > 1) cout << " inner mrpc" << layer << " : " << rsum_innglass_uphalf << endl;
408  }
409  }
410  rsum = rsum_gasin_uphalf;
411 
412  //top outer glass
413  rsum += gas_gap;
414  tof_cyl = new PHG4CylinderSubsystem("ToF_glass_top", BTOF::subsysID);
415  tof_cyl->Verbosity(verbosity);
416  tof_cyl->set_double_param("radius", rsum);
417  tof_cyl->set_string_param("material", "G4_Si");
418  tof_cyl->set_double_param("thickness", mrpc_out_thick);
419  tof_cyl->set_int_param("lengthviarapidity", 0);
420  tof_cyl->set_double_param("place_z", zpos);
421  tof_cyl->set_double_param("length", tof_length);
422  tof_cyl->SuperDetector("bTOF");
423  tof_cyl->SetActive(0);
424  tof_cyl->OverlapCheck(OverlapCheck);
425  ++BTOF::subsysID;
426  g4Reco->registerSubsystem(tof_cyl);
427  if (verbosity > 1) cout << " top glass :" << rsum << endl;
428 
429  // Carbon layer
430  rsum += mrpc_out_thick;
431  tof_cyl = new PHG4CylinderSubsystem("ToF_Carbon_top", BTOF::subsysID);
432  tof_cyl->Verbosity(verbosity);
433  tof_cyl->set_double_param("radius", rsum);
434  tof_cyl->set_string_param("material", "G4_C");
435  tof_cyl->set_double_param("thickness", carbon_thickness);
436  tof_cyl->set_int_param("lengthviarapidity", 0);
437  tof_cyl->set_double_param("place_z", zpos);
438  tof_cyl->set_double_param("length", tof_length);
439  tof_cyl->SuperDetector("bTOF");
440  tof_cyl->SetActive(0);
441  tof_cyl->OverlapCheck(OverlapCheck);
442  ++BTOF::subsysID;
443  g4Reco->registerSubsystem(tof_cyl);
444  if (verbosity > 1) cout << " Carbon :" << rsum << endl;
445 
446  //Mylar
447  rsum += carbon_thickness;
448  tof_cyl = new PHG4CylinderSubsystem("ToF_mylar_top", BTOF::subsysID);
449  tof_cyl->Verbosity(verbosity);
450  tof_cyl->set_double_param("radius", rsum);
451  tof_cyl->set_string_param("material", "G4_MYLAR");
452  tof_cyl->set_double_param("thickness", mylar_thickness);
453  tof_cyl->set_int_param("lengthviarapidity", 0);
454  tof_cyl->set_double_param("place_z", zpos);
455  tof_cyl->set_double_param("length", tof_length);
456  tof_cyl->SuperDetector("bTOF");
457  tof_cyl->SetActive(0);
458  tof_cyl->OverlapCheck(OverlapCheck);
459  ++BTOF::subsysID;
460  g4Reco->registerSubsystem(tof_cyl);
461  if (verbosity > 1) cout << "Mylar :" << rsum << endl;
462 
463  //PCB Cu
464  rsum += mylar_thickness;
465  tof_cyl = new PHG4CylinderSubsystem("ToF_toppcb_cu", BTOF::subsysID);
466  tof_cyl->Verbosity(verbosity);
467  tof_cyl->set_double_param("radius", rsum);
468  tof_cyl->set_string_param("material", "G4_Cu");
469  tof_cyl->set_double_param("thickness", cu_thickness);
470  tof_cyl->set_int_param("lengthviarapidity", 0);
471  tof_cyl->set_double_param("place_z", zpos);
472  tof_cyl->set_double_param("length", tof_length); // Length restricted to active area
473  tof_cyl->SuperDetector("bTOF");
474  tof_cyl->SetActive(0);
475  tof_cyl->OverlapCheck(OverlapCheck);
476  ++BTOF::subsysID;
477  g4Reco->registerSubsystem(tof_cyl);
478  if (verbosity > 1) cout << " PCB cu :" << rsum << endl;
479 
480  //Top PCB
481  rsum += cu_thickness;
482  tof_cyl = new PHG4CylinderSubsystem("ToF_pcb_top", BTOF::subsysID);
483  tof_cyl->Verbosity(verbosity);
484  tof_cyl->set_double_param("radius", rsum);
485  tof_cyl->set_string_param("material", "FR4");
486  tof_cyl->set_double_param("thickness", pcb_thickness);
487  tof_cyl->set_int_param("lengthviarapidity", 0);
488  tof_cyl->set_double_param("place_z", zpos);
489  tof_cyl->set_double_param("length", tof_length);
490  tof_cyl->SuperDetector("bTOF");
491  tof_cyl->SetActive(0);
492  tof_cyl->OverlapCheck(OverlapCheck);
493  ++BTOF::subsysID;
494  g4Reco->registerSubsystem(tof_cyl);
495  if (verbosity > 1) cout << " top PCB " << rsum << endl;
496 
497  //Honeycomb
498  rsum += pcb_thickness;
499  tof_cyl = new PHG4CylinderSubsystem("ToF_honeycomb_top", BTOF::subsysID);
500  tof_cyl->Verbosity(verbosity);
501  tof_cyl->set_double_param("radius", tof_rad);
502  tof_cyl->set_string_param("material", "NOMEX");
503  tof_cyl->set_double_param("thickness", honeycomb_thickness);
504  tof_cyl->SetActive(0);
505  tof_cyl->set_int_param("lengthviarapidity", 0);
506  tof_cyl->set_double_param("place_z", zpos);
507  tof_cyl->set_double_param("length", tof_length);
508  tof_cyl->SuperDetector("bTOF");
509  tof_cyl->SetActive(0);
510  tof_cyl->OverlapCheck(OverlapCheck);
511  ++BTOF::subsysID;
512  g4Reco->registerSubsystem(tof_cyl);
513  if (verbosity > 1) cout << " Top honeycomb :" << rsum << endl;
514 
515  if (verbosity > 1) cout << " tof thickness :" << tof_rad << endl;
516  return tof_rad;
517 }
518 
519 double BToFSetup(PHG4Reco* g4Reco)
520 {
521  double radius = 0;
522 
523  radius = Build_G4_BTof(g4Reco,
524  BTOF::rad,
525  BTOF::zpos,
526  BTOF::length);
527 
528  for (int igap = 0; igap < BTOF::gas_lyr + 6; igap++)
529  {
530  //Uncomment below if one wants tracking evaluation
531  /*
532  if (TRACKING::FastKalmanFilter)
533  TRACKING::FastKalmanFilter->add_phg4hits(string("G4HIT_") + string(Form("ToF_gas_%d", igap)), // const std::string& phg4hitsNames,
534  PHG4TrackFastSim::Cylinder, // const DETECTOR_TYPE phg4dettype,
535  1, //1. / sqrt(12.), // const float radres,
536  5.0e-1,//55e-4, // const float phires,
537  5.0e-1,//55e-4, // const float lonres,
538  1, // const float eff,
539  0); // const float noise
540 
541  */
542 
543  //Reference plane projection at initial R of ToF
544  TRACKING::FastKalmanFilter->add_cylinder_state(string("G4HIT_") + string(Form("ACTIVEGAS_BTOF_%d", igap)), 82.0);
545  TRACKING::ProjectionNames.insert(string("G4HIT_") + string(Form("ACTIVEGAS_BTOF_%d", igap)));
546  }
547  return radius; // cm
548 }
549 
550 void BToF_Reco(int verbosity = 0)
551 {
552  //---------------
553  // Load libraries
554  //---------------
555  gSystem->Load("libfun4all.so");
556  gSystem->Load("libg4detectors.so");
557 
558  //---------------
559  // Fun4All server
560  //---------------
561 
563 
564  return;
565 }
566 
567 #endif