forked from ECCE-EIC/macros
-
Notifications
You must be signed in to change notification settings - Fork 0
/
G4_mRwell_EIC.C
475 lines (430 loc) · 20.3 KB
/
G4_mRwell_EIC.C
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
#ifndef MACRO_G4mRWELL_C
#define MACRO_G4mRWELL_C
#include <GlobalVariables.C>
#include <fun4all/Fun4AllServer.h>
#include <g4detectors/PHG4CylinderSubsystem.h>
#include <g4detectors/PHG4SectorSubsystem.h>
#include <g4main/PHG4Reco.h>
#include <g4trackfastsim/PHG4TrackFastSim.h>
R__LOAD_LIBRARY(libfun4all.so)
R__LOAD_LIBRARY(libg4testbench.so)
R__LOAD_LIBRARY(libg4detectors.so)
namespace Enable
{
bool RWELL = false;
bool RWELL_OVERLAPCHECK = false;
} // namespace Enable
namespace RWELL
{
//All units specified in cm unless stated otherwise
// const int n_layer = 2; //tracker layers
// //const double nom_radius[RWELL::n_layer] = {79.5,90.0}; //77 to not hit DIRC
// // const double nom_radius[RWELL::n_layer] = {78.67, 90.0}; //77 to not hit DIRC
// const double nom_radius[RWELL::n_layer] = {69 - 1.6 - 2.6, 78.67}; //77 to not hit DIRC
// const double nom_driftgap[RWELL::n_layer] = {0.4, 0.4};
// const double nom_length[RWELL::n_layer] = {300.0, 300.0};
const int n_layer = 3; //tracker layers
//const double nom_radius[RWELL::n_layer] = {44.2, 47.4, 77.0175};
const double nom_radius[RWELL::n_layer] = {33.14, 51., 77.0175};
double e_length_uRwell[RWELL::n_layer] = {40.08, 106., 197};
double h_length_uRwell[RWELL::n_layer] = {e_length_uRwell[0], e_length_uRwell[1], 145};
const double nom_driftgap[RWELL::n_layer] = {0.4, 0.4, 0.4};
//const double nom_length[RWELL::n_layer] = {140, 150, 280.0};
const double nom_length[RWELL::n_layer] = {2*e_length_uRwell[0], 2*e_length_uRwell[1], 342.0};
int subsysID = 0;
} //namespace RWELL
void RWellInit(int verbosity = 0)
{
BlackHoleGeometry::max_radius = std::max(BlackHoleGeometry::max_radius, RWELL::nom_radius[RWELL::n_layer - 1] / 10. + 0.7);
BlackHoleGeometry::max_z = std::max(BlackHoleGeometry::max_z, RWELL::nom_length[RWELL::n_layer - 1] / 2.0);
BlackHoleGeometry::min_z = std::min(BlackHoleGeometry::min_z, -RWELL::nom_length[RWELL::n_layer - 1] / 2.0);
}
double Build_G4_RWell_Bare(PHG4Reco* g4Reco,
double rwellrad = 80.0,
double driftgap = 1.83,
double length = 200.0,
int index = 0)
{
bool OverlapCheck = Enable::OVERLAPCHECK || Enable::RWELL_OVERLAPCHECK;
gSystem->Load("libfun4all");
gSystem->Load("libg4detectors.so");
gSystem->Load("libg4testbench.so");
gSystem->Load("libg4trackfastsim.so");
//double driftgap = 3.0;
//double rwellrad = radius;
//double length = length;
double rsum = 0.0;
//MPGD parameters (units in cm)
double kapton_thickness = 0.0175; //cm
double cu_thickness = 0.002; //cm
double pcb_thickness = 0.010; //cm
double prepreg_thickness = 0.005; //cm
//Suppoort parameters (units in cm)
//string supMat = "PEEK"; //support material
//string supMat = "G4_Galactic"; //support material
// making carbon fiber epoxy
// G4Material *cfrp_intt = new G4Material("CFRP_INTT", density = 1.69 * g / cm3, ncomponents = 3);
string supMat = "CFRP_INTT";
//inner tube
double support_01_thickness = 0.50;
double support_01_length = 7.2;
//inner ring
double support_02_thickness = 1.6;
double support_02_length = 1.2;
//outer ring
double support_03_thickness = 0.50;
double support_03_length = 1.2;
PHG4CylinderSubsystem* rwell_cyl;
double Shift = (RWELL::h_length_uRwell[index] - RWELL::e_length_uRwell[index])/2.0;
// here is our uRwell:
//Gass layer
rwell_cyl = new PHG4CylinderSubsystem(Form("RWELL_%d", index), RWELL::subsysID);
rwell_cyl->set_double_param("radius", rwellrad);
rwell_cyl->set_string_param("material", "G4_Ar");
rwell_cyl->set_double_param("thickness", driftgap);
rwell_cyl->set_int_param("lengthviarapidity", 0);
rwell_cyl->set_double_param("place_z", Shift);
rwell_cyl->set_double_param("length", length);
rwell_cyl->SuperDetector("RWELL");
rwell_cyl->SetActive(1);
rwell_cyl->OverlapCheck(OverlapCheck);
g4Reco->registerSubsystem(rwell_cyl);
//Kapton
rwell_cyl = new PHG4CylinderSubsystem(Form("RWELL_Kapton_%d", index), RWELL::subsysID);
rwell_cyl->set_double_param("radius", rwellrad - kapton_thickness);
rwell_cyl->set_string_param("material", "G4_KAPTON");
rwell_cyl->set_double_param("thickness", kapton_thickness);
rwell_cyl->set_int_param("lengthviarapidity", 0);
rwell_cyl->set_double_param("place_z", Shift);
rwell_cyl->set_double_param("length", length);
rwell_cyl->SuperDetector("RWELL");
rwell_cyl->SetActive(0);
rwell_cyl->OverlapCheck(OverlapCheck);
g4Reco->registerSubsystem(rwell_cyl);
//Cu
rsum = rwellrad + driftgap;
rwell_cyl = new PHG4CylinderSubsystem(Form("RWELL_Cu_%d", index), RWELL::subsysID);
rwell_cyl->set_double_param("radius", rsum);
rwell_cyl->set_string_param("material", "G4_Cu");
rwell_cyl->set_double_param("thickness", cu_thickness);
rwell_cyl->set_int_param("lengthviarapidity", 0);
rwell_cyl->set_double_param("place_z", Shift);
rwell_cyl->set_double_param("length", length);
rwell_cyl->SuperDetector("RWELL");
rwell_cyl->SetActive(0);
rwell_cyl->OverlapCheck(OverlapCheck);
g4Reco->registerSubsystem(rwell_cyl);
//Prepreg
rsum += cu_thickness;
rwell_cyl = new PHG4CylinderSubsystem(Form("RWELL_PrePreg_%d", index), RWELL::subsysID);
rwell_cyl->set_double_param("radius", rsum);
rwell_cyl->set_string_param("material", "NOMEX");
rwell_cyl->set_double_param("thickness", prepreg_thickness);
rwell_cyl->set_int_param("lengthviarapidity", 0);
rwell_cyl->set_double_param("place_z", Shift);
rwell_cyl->set_double_param("length", length);
rwell_cyl->SuperDetector("RWELL");
rwell_cyl->SetActive(0);
g4Reco->registerSubsystem(rwell_cyl);
rwell_cyl->OverlapCheck(OverlapCheck);
//PCB
rsum += prepreg_thickness;
rwell_cyl = new PHG4CylinderSubsystem(Form("RWELL_PCB_%d", index), RWELL::subsysID);
rwell_cyl->set_double_param("radius", rsum);
rwell_cyl->set_string_param("material", "FR4");
rwell_cyl->set_double_param("thickness", pcb_thickness);
rwell_cyl->set_int_param("lengthviarapidity", 0);
rwell_cyl->set_double_param("place_z", Shift);
rwell_cyl->set_double_param("length", length);
rwell_cyl->SuperDetector("RWELL");
rwell_cyl->SetActive(0);
rwell_cyl->OverlapCheck(OverlapCheck);
g4Reco->registerSubsystem(rwell_cyl);
return rwellrad;
}
double Build_G4_RWell_Sup01(PHG4Reco* g4Reco,
double rwellrad = 80.0,
double driftgap = 1.5,
double length = 200.0,
int index = 0)
{
gSystem->Load("libfun4all");
gSystem->Load("libg4detectors.so");
bool OverlapCheck = Enable::OVERLAPCHECK || Enable::RWELL_OVERLAPCHECK;
//double driftgap = gap;
//double rwellrad = radius;
//double length = length;
double rsum = 0.0;
//MPGD parameters (units in cm)
double kapton_thickness = 0.0175; //cm
double cu_thickness = 0.002; //cm
double pcb_thickness = 0.010; //cm
double prepreg_thickness = 0.005; //cm
//Suppoort parameters (units in cm)
//string supMat = "PEEK"; //support material
//string supMat = "G4_Galactic"; //support material
// making carbon fiber epoxy
// G4Material *cfrp_intt = new G4Material("CFRP_INTT", density = 1.69 * g / cm3, ncomponents = 3);
string supMat = "CFRP_INTT";
//inner tube
double support_01_thickness = 0.50;
double support_01_length = 7.2;
//inner ring
double support_02_thickness = 1.6;
double support_02_length = 1.2;
//outer ring
double support_03_thickness = 0.50;
double support_03_length = 1.2;
PHG4CylinderSubsystem* rwell_cyl;
double Shift = (RWELL::h_length_uRwell[index] - RWELL::e_length_uRwell[index])/2.0;
// here is our uRwell:
//Gass layer
rwell_cyl = new PHG4CylinderSubsystem("RWELL", index);
rwell_cyl->set_double_param("radius", rwellrad);
rwell_cyl->set_string_param("material", "G4_METHANE");
rwell_cyl->set_double_param("thickness", driftgap);
rwell_cyl->set_int_param("lengthviarapidity", 0);
rwell_cyl->set_double_param("place_z", Shift);
rwell_cyl->set_double_param("length", length);
// rwell_cyl->SuperDetector("RWELL"); // breakout RWELL into individual layers
rwell_cyl->SetActive(1);
rwell_cyl->OverlapCheck(OverlapCheck);
g4Reco->registerSubsystem(rwell_cyl);
++RWELL::subsysID;
//Kapton
rwell_cyl = new PHG4CylinderSubsystem(Form("RWELL_Kapton_%d", index), RWELL::subsysID);
rwell_cyl->set_double_param("radius", rwellrad - kapton_thickness);
rwell_cyl->set_string_param("material", "G4_KAPTON");
rwell_cyl->set_double_param("thickness", kapton_thickness);
rwell_cyl->set_int_param("lengthviarapidity", 0);
rwell_cyl->set_double_param("place_z", Shift);
rwell_cyl->set_double_param("length", length);
rwell_cyl->SuperDetector("RWELL");
rwell_cyl->SetActive(0);
rwell_cyl->OverlapCheck(OverlapCheck);
g4Reco->registerSubsystem(rwell_cyl);
++RWELL::subsysID;
//Cu
rsum = rwellrad + driftgap;
rwell_cyl = new PHG4CylinderSubsystem(Form("RWELL_Cu_%d", index), RWELL::subsysID);
rwell_cyl->set_double_param("radius", rsum);
rwell_cyl->set_string_param("material", "G4_Cu");
rwell_cyl->set_double_param("thickness", cu_thickness);
rwell_cyl->set_int_param("lengthviarapidity", 0);
rwell_cyl->set_double_param("place_z", Shift);
rwell_cyl->set_double_param("length", length);
rwell_cyl->SuperDetector("RWELL");
rwell_cyl->SetActive(0);
g4Reco->registerSubsystem(rwell_cyl);
rwell_cyl->OverlapCheck(OverlapCheck);
++RWELL::subsysID;
//Prepreg
rsum += cu_thickness;
rwell_cyl = new PHG4CylinderSubsystem(Form("RWELL_PrePreg_%d", index), RWELL::subsysID);
rwell_cyl->set_double_param("radius", rsum);
rwell_cyl->set_string_param("material", "NOMEX");
rwell_cyl->set_double_param("thickness", prepreg_thickness);
rwell_cyl->set_int_param("lengthviarapidity", 0);
rwell_cyl->set_double_param("length", length);
rwell_cyl->SuperDetector("RWELL");
rwell_cyl->SetActive(0);
rwell_cyl->OverlapCheck(OverlapCheck);
g4Reco->registerSubsystem(rwell_cyl);
++RWELL::subsysID;
//PCB
rsum += prepreg_thickness;
rwell_cyl = new PHG4CylinderSubsystem(Form("RWELL_PCB_%d", index), RWELL::subsysID);
rwell_cyl->set_double_param("radius", rsum);
rwell_cyl->set_string_param("material", "FR4");
rwell_cyl->set_double_param("thickness", pcb_thickness);
rwell_cyl->set_int_param("lengthviarapidity", 0);
rwell_cyl->set_double_param("place_z", Shift);
rwell_cyl->set_double_param("length", length);
rwell_cyl->SuperDetector("RWELL");
rwell_cyl->SetActive(0);
rwell_cyl->OverlapCheck(OverlapCheck);
g4Reco->registerSubsystem(rwell_cyl);
++RWELL::subsysID;
//---Support structure--
//tube
rsum += pcb_thickness;
rwell_cyl = new PHG4CylinderSubsystem(Form("RWELL_Support01_0_%d", index), RWELL::subsysID); //RWELL_<support type>_<location>_<index>
//Support 01 = tube
//Support 02 = inner ring
//Support 03 = outer ring
//location 0 = z < 0
//location 1 = z > 0
rwell_cyl->set_double_param("radius", rsum);
rwell_cyl->set_string_param("material", supMat);
rwell_cyl->set_double_param("thickness", support_01_thickness);
rwell_cyl->set_int_param("lengthviarapidity", 0);
rwell_cyl->set_double_param("place_z", -length / 2 + Shift + 0.5);
rwell_cyl->set_double_param("length", support_01_length);
rwell_cyl->SuperDetector("RWELL");
rwell_cyl->SetActive(0);
rwell_cyl->OverlapCheck(OverlapCheck);
g4Reco->registerSubsystem(rwell_cyl);
++RWELL::subsysID;
//tube 2
rwell_cyl = new PHG4CylinderSubsystem(Form("RWELL_Support01_1_%d", index), RWELL::subsysID);
rwell_cyl->set_double_param("radius", rsum);
rwell_cyl->set_string_param("material", supMat);
rwell_cyl->set_double_param("thickness", support_01_thickness);
rwell_cyl->set_int_param("lengthviarapidity", 0);
rwell_cyl->set_double_param("place_z", length / 2 + Shift);
rwell_cyl->set_double_param("length", support_01_length);
rwell_cyl->SuperDetector("RWELL");
rwell_cyl->SetActive(0);
rwell_cyl->OverlapCheck(OverlapCheck);
g4Reco->registerSubsystem(rwell_cyl);
++RWELL::subsysID;
//inner ring
rsum += support_01_thickness;
rwell_cyl = new PHG4CylinderSubsystem(Form("RWELL_Support02_0_%d", index), RWELL::subsysID);
rwell_cyl->set_double_param("radius", rsum);
rwell_cyl->set_string_param("material", supMat);
rwell_cyl->set_double_param("thickness", support_02_thickness);
rwell_cyl->set_int_param("lengthviarapidity", 0);
rwell_cyl->set_double_param("place_z", -length / 2 + support_01_length / 2 + Shift);
rwell_cyl->set_double_param("length", support_02_length);
rwell_cyl->SuperDetector("RWELL");
rwell_cyl->SetActive(0);
rwell_cyl->OverlapCheck(OverlapCheck);
g4Reco->registerSubsystem(rwell_cyl);
++RWELL::subsysID;
//inner ring 2
rwell_cyl = new PHG4CylinderSubsystem(Form("RWELL_Support02_1_%d", index), RWELL::subsysID);
rwell_cyl->set_double_param("radius", rsum);
rwell_cyl->set_string_param("material", supMat);
rwell_cyl->set_double_param("thickness", support_02_thickness);
rwell_cyl->set_int_param("lengthviarapidity", 0);
rwell_cyl->set_double_param("place_z", length / 2 + Shift - support_01_length / 2);
rwell_cyl->set_double_param("length", support_02_length);
rwell_cyl->SuperDetector("RWELL");
rwell_cyl->SetActive(0);
rwell_cyl->OverlapCheck(OverlapCheck);
g4Reco->registerSubsystem(rwell_cyl);
++RWELL::subsysID;
//outer ring
rsum += support_02_thickness;
rwell_cyl = new PHG4CylinderSubsystem(Form("RWELL_Support03_0_%d", index), RWELL::subsysID);
rwell_cyl->set_double_param("radius", rsum);
rwell_cyl->set_string_param("material", supMat);
rwell_cyl->set_double_param("thickness", support_03_thickness);
rwell_cyl->set_int_param("lengthviarapidity", 0);
rwell_cyl->set_double_param("length", support_03_length);
rwell_cyl->set_double_param("place_z", -length / 2 + Shift + support_01_length / 2);
rwell_cyl->SuperDetector("RWELL");
rwell_cyl->SetActive(0);
rwell_cyl->OverlapCheck(OverlapCheck);
g4Reco->registerSubsystem(rwell_cyl);
++RWELL::subsysID;
//outer ring 2
rwell_cyl = new PHG4CylinderSubsystem(Form("RWELL_Support03_1_%d", index), RWELL::subsysID);
rwell_cyl->set_double_param("radius", rsum);
rwell_cyl->set_string_param("material", supMat);
rwell_cyl->set_double_param("thickness", support_03_thickness);
rwell_cyl->set_int_param("lengthviarapidity", 0);
rwell_cyl->set_double_param("length", support_03_length);
rwell_cyl->set_double_param("place_z", length / 2 + Shift - support_01_length / 2);
rwell_cyl->SuperDetector("RWELL");
rwell_cyl->SetActive(0);
rwell_cyl->OverlapCheck(OverlapCheck);
g4Reco->registerSubsystem(rwell_cyl);
++RWELL::subsysID;
return rwellrad;
}
//! type selects the RWell material
// 0: bare RWell (no support structure)
// 1: Implimentation of FIT support rings
double RWellSetup(PHG4Reco* g4Reco,
int type = 1)
{
double radius = 0;
for (int ilyr = 0; ilyr < RWELL::n_layer; ilyr++) //RWELL trackers are registered in Build_RWELL macro
{
if (type == 0)
{
radius = Build_G4_RWell_Bare(g4Reco, //returns RWELL radiaus
RWELL::nom_radius[ilyr], //radius
RWELL::nom_driftgap[ilyr], //driftgap,
RWELL::nom_length[ilyr], //length
ilyr); //index
}
if (type == 1)
{
radius = Build_G4_RWell_Sup01(g4Reco, //returns RWELL radiaus
RWELL::nom_radius[ilyr], //radius
RWELL::nom_driftgap[ilyr], //driftgap,
RWELL::nom_length[ilyr], //length
ilyr); //index
}
// // sourav: For spatial resolution the mRwell I will use about 55 microns
// // (usually it is in between 40-60 microns depending on the angle of incidence of
// // primary tracks when mRwell are used in microTPC mode i.e drift gap of 3-4 mm) .
if (TRACKING::FastKalmanFilter)
{
TRACKING::FastKalmanFilter->add_phg4hits(string("G4HIT_") + string(Form("RWELL_%d", ilyr)), // const std::string& phg4hitsNames,
PHG4TrackFastSim::Cylinder, // const DETECTOR_TYPE phg4dettype,
1. / sqrt(12.), // const float radres,
55e-4, // const float phires,
55e-4, // const float lonres,
1, // const float eff,
0); // const float noise
TRACKING::FastKalmanFilter->add_cylinder_state(Form("RWELL_%d", ilyr), RWELL::nom_radius[ilyr]);
TRACKING::ProjectionNames.insert(Form("RWELL_%d", ilyr));
}
// FastKalmanFilterInnerTrack has everything within DIRC
if (TRACKING::FastKalmanFilterInnerTrack and RWELL::nom_radius[ilyr] < 70)
TRACKING::FastKalmanFilterInnerTrack->add_phg4hits(string("G4HIT_") + string(Form("RWELL_%d", ilyr)), // const std::string& phg4hitsNames,
PHG4TrackFastSim::Cylinder, // const DETECTOR_TYPE phg4dettype,
1. / sqrt(12.), // const float radres,
55e-4, // const float phires,
55e-4, // const float lonres,
1, // const float eff,
0); // const float noise
// only for layers that is close to the silicon tracker system, use in FastKalmanFilterSiliconTrack
if (TRACKING::FastKalmanFilterSiliconTrack and RWELL::nom_radius[ilyr] < 50)
TRACKING::FastKalmanFilterSiliconTrack->add_phg4hits(string("G4HIT_") + string(Form("RWELL_%d", ilyr)), // const std::string& phg4hitsNames,
PHG4TrackFastSim::Cylinder, // const DETECTOR_TYPE phg4dettype,
1. / sqrt(12.), // const float radres,
55e-4, // const float phires,
55e-4, // const float lonres,
1, // const float eff,
0); // const float noise
}
return radius; //cm
}
// Central detector cell reco is disabled as EIC setup use the fast tracking sim for now
void RWell_Cells(int verbosity = 0)
{
// runs the cellularization of the energy deposits (g4hits)
// into detector hits (g4cells)
//---------------
// Load libraries
//---------------
gSystem->Load("libfun4all.so");
gSystem->Load("libg4detectors.so");
//---------------
// Fun4All server
//---------------
Fun4AllServer* se = Fun4AllServer::instance();
//-----------
// SVTX cells
//-----------
return;
}
// Central detector reco is disabled as EIC setup use the fast tracking sim for now
void RWell_Reco(int verbosity = 0)
{
//---------------
// Load libraries
//---------------
gSystem->Load("libfun4all.so");
//---------------
// Fun4All server
//---------------
Fun4AllServer* se = Fun4AllServer::instance();
return;
}
#endif