/
Fun4All_G4_simplified_v2_DIRC_barrel_GEM.C
334 lines (309 loc) · 14.2 KB
/
Fun4All_G4_simplified_v2_DIRC_barrel_GEM.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
/*
================================================================================================================
The purpose of this code is to have a version of the all-silicon tracker that is simplified so that we can study
different variations of the geometry quickly. Specifically, I wrote this code to study the impact that adding a
cylindrical GEM outside the DIRC can have on tracking.
================================================================================================================
*/
#pragma once
#include <phgenfit/Track.h>
#include <fun4all/Fun4AllDstInputManager.h>
#include <fun4all/Fun4AllDstOutputManager.h>
#include <fun4all/Fun4AllDummyInputManager.h>
#include <fun4all/Fun4AllInputManager.h>
#include <fun4all/Fun4AllNoSyncDstInputManager.h>
#include <fun4all/Fun4AllOutputManager.h>
#include <fun4all/Fun4AllServer.h>
#include <fun4all/SubsysReco.h>
#include <g4detectors/PHG4DetectorSubsystem.h>
#include <g4detectors/PHG4CylinderSubsystem.h>
#include <g4histos/G4HitNtuple.h>
#include <g4main/PHG4ParticleGenerator.h>
#include <g4main/PHG4ParticleGeneratorBase.h>
#include <g4main/PHG4Reco.h>
#include <g4main/PHG4TruthSubsystem.h>
#include <g4trackfastsim/PHG4TrackFastSim.h>
#include <g4trackfastsim/PHG4TrackFastSimEval.h>
#include <phool/recoConsts.h>
#include <g4lblvtx/PHG4ParticleGenerator_flat_pT.h>
#include <g4lblvtx/AllSi_Al_support_Subsystem.h>
#include "G4_BlackHole.C"
//#include "../../G4_DIRC.C"
#include "G4_DIRC_SMALL.C"
R__LOAD_LIBRARY(libfun4all.so)
R__LOAD_LIBRARY(libg4detectors.so)
R__LOAD_LIBRARY(libg4lblvtx.so)
R__LOAD_LIBRARY(libg4trackfastsim.so)
void Fun4All_G4_simplified_v2_DIRC_barrel_GEM(
int nEvents = -1, // number of events
double vtx_matBud = 0.05, // % X/X0 (material budget of vertexing layers)
double barr_matBud = 0.55, // % X/X0 (material budget of middle layers)
double disk_matBud = 0.25, // % X/X0 (material budget of disk layers)
double pmin = 0., // GeV/c
double pmax = 30., // GeV/c
int magnetic_field = 4, // Magnetic field setting
TString out_name = "out_vtx_study") // output filename
{
// ======================================================================================================
// Input from the user
const int particle_gen = 1;// 1 = particle generator, 2 = particle gun, 3 = simple event generator, 4 = pythia8 e+p collision, 5 = particle generator flat in pT
double pix_size_vtx = 10.; // um - size of pixels in vertexing layers
double pix_size_bar = 10.; // um - size of pixels in barrel layers
double pix_size_dis = 10.; // um - size of pixels in disk layers
bool use_blackhole = false;
bool use_barrel_GEM = false;
bool use_DIRC = false;
// ======================================================================================================
// Make the Server
Fun4AllServer *se = Fun4AllServer::instance();
// If you want to fix the random seed for reproducibility
// recoConsts *rc = recoConsts::instance();
// rc->set_IntFlag("RANDOMSEED", 12345);
// ======================================================================================================
// Particle Generator Setup
PHG4ParticleGenerator *gen = new PHG4ParticleGenerator();
gen->set_name(std::string("pi-")); // geantino, pi-, pi+, mu-, mu+, e-., e+, proton, ... (currently passed as an input)
gen->set_vtx(0,0,0); // Vertex generation range
gen->set_mom_range(pmin,pmax); // Momentum generation range in GeV/c
gen->set_z_range(0.,0.);
gen->set_eta_range(-1.2,1.2);
gen->set_phi_range(0,2.*TMath::Pi());
// --------------------------------------------------------------------------------------
// Particle generator flat in pT
PHG4ParticleGenerator_flat_pT *gen_pT = new PHG4ParticleGenerator_flat_pT();
gen_pT->set_name(std::string("pi-")); // geantino, pi-, pi+, mu-, mu+, e-., e+, proton, ... (currently passed as an input)
gen_pT->set_vtx(0,0,0); // Vertex generation range
gen_pT->set_pT_range(.00001,5.); // Momentum generation range in GeV/c
gen_pT->set_z_range(0.,0.);
gen_pT->set_eta_range(-4,4); // Detector coverage corresponds to |η|< 4
gen_pT->set_phi_range(0.,2.*TMath::Pi());
// ======================================================================================================
if (particle_gen==1){se->registerSubsystem( gen); cout << "Using particle generator" << endl;}
else if(particle_gen==5){se->registerSubsystem(gen_pT); cout << "Using particle generator flat in pT" << endl;}
else{ cout << "Particle generator option requested has not been implemented. Bailing out!" << endl; exit(0); }
// ======================================================================================================
if(use_DIRC)
DIRCInit();
// ======================================================================================================
PHG4Reco *g4Reco = new PHG4Reco();
//g4Reco->SetWorldMaterial("G4_Galactic");
// ======================================================================================================
// Magnetic field setting
TString B_label;
if(magnetic_field==1){ // uniform 1.5T
B_label = "_B_1.5T";
g4Reco->set_field(1.5);
}
else if(magnetic_field==2){ // uniform 3.0T
B_label = "_B_3.0T";
g4Reco->set_field(3.0);
}
else if(magnetic_field==3){ // sPHENIX 1.4T map
B_label = "_sPHENIX";
g4Reco->set_field_map(string(getenv("CALIBRATIONROOT")) + string("/Field/Map/sPHENIX.2d.root"), PHFieldConfig::kField2D);
g4Reco->set_field_rescale(-1.4/1.5);
}
else if(magnetic_field==4){ // Beast 3.0T map
B_label = "_Beast";
g4Reco->set_field_map(string(getenv("CALIBRATIONROOT")) + string("/Field/Map/mfield.4col.dat"), PHFieldConfig::kFieldBeast);
}
else{ // The user did not provide a valid B field setting
cout << "User did not provide a valid magnetic field setting. Set 'magnetic_field'. Bailing out!" << endl;
}
// ======================================================================================================
// Detector setup
PHG4CylinderSubsystem *cyl;
//---------------------------
// Vertexing
double si_vtx_r_pos[] = {3.30,5.70};
const int nVtxLayers = sizeof(si_vtx_r_pos)/sizeof(*si_vtx_r_pos);
double si_z_vtxlength[] = {30.,30.};
double si_thick_vtx = vtx_matBud/100.*9.37;
for (int ilayer = 0; ilayer < nVtxLayers ; ilayer++){
cyl = new PHG4CylinderSubsystem("SVTX", ilayer);
cyl->set_string_param("material" , "G4_Si" );
cyl->set_double_param("radius" , si_vtx_r_pos[ilayer] );
cyl->set_double_param("thickness", si_thick_vtx );
cyl->set_double_param("place_z" , 0 );
cyl->set_double_param("length" , si_z_vtxlength[ilayer]);
cyl->SetActive();
cyl->SuperDetector("SVTX");
cyl->set_color(0,0.8,0.1);
g4Reco->registerSubsystem(cyl);
}
//---------------------------
// Barrel
double si_r_pos[] = {21.,22.68,39.3,43.23};
const int nTrckLayers = sizeof(si_r_pos)/sizeof(*si_r_pos);
double si_z_length[] = {54.,60.,105.,114.};
double si_thick_bar = barr_matBud/100.*9.37;
for (int ilayer = 0; ilayer < nTrckLayers ; ilayer++){
cyl = new PHG4CylinderSubsystem("BARR", ilayer);
cyl->set_string_param("material" , "G4_Si" );
cyl->set_double_param("radius" , si_r_pos[ilayer] );
cyl->set_double_param("thickness", si_thick_bar );
cyl->set_double_param("place_z" , 0 );
cyl->set_double_param("length" , si_z_length[ilayer]);
cyl->SetActive();
cyl->SuperDetector("BARR");
cyl->set_color(0,0.5,1);
g4Reco->registerSubsystem(cyl);
}
//---------------------------
// Disks
double si_z_pos[] = {-121.,-97.,-73.,-49.,-25.,25.,49.,73.,97.,121.};
double si_r_max[10] = {0};
double si_r_min[10] = {0};
double si_thick_disk = disk_matBud/100.*9.37;
for(int i = 0 ; i < 10 ; i++){
si_r_max[i] = TMath::Min(43.23,18.5*abs(si_z_pos[i])/si_z_pos[5]);
if(si_z_pos[i]>66.8&&si_z_pos[i]>0) si_r_min[i] = (0.05025461*si_z_pos[i]-0.180808);
else if(si_z_pos[i]>0) si_r_min[i] = 3.18;
else if(si_z_pos[i]<-79.8&&si_z_pos[i]<0) si_r_min[i] = (-0.0297039*si_z_pos[i]+0.8058281);
else si_r_min[i] = 3.18;
si_r_max[i] -= si_r_min[i];
}
for (int ilayer = 0; ilayer < 10; ilayer++){
cyl = new PHG4CylinderSubsystem("FBVS", ilayer);
cyl->set_string_param("material" , "G4_Si" );
cyl->set_double_param("radius" , si_r_min[ilayer]);
cyl->set_double_param("thickness", si_r_max[ilayer]);
cyl->set_double_param("place_z" , si_z_pos[ilayer]);
cyl->set_double_param("length" , si_thick_disk );
cyl->SetActive();
cyl->SuperDetector("FBST");
cyl->set_color(1,0,0);
g4Reco->registerSubsystem(cyl);
}
//---------------------------
// Cylindrical GEM outside DIRC
double barrel_GEM_inner_radius = 60.; // GEM radius
double barrel_GEM_radial_thick = si_thick_bar*3.;
double barrel_GEM_z_length = 121.;
cyl = new PHG4CylinderSubsystem("BARR_GEM",1);
cyl->set_string_param("material" , "G4_Si" );
cyl->set_double_param("radius" , barrel_GEM_inner_radius);
cyl->set_double_param("thickness", barrel_GEM_radial_thick);
cyl->set_double_param("place_z" , 0 );
cyl->set_double_param("length" , 2.*barrel_GEM_z_length );
cyl->SetActive();
cyl->SuperDetector("BARR_GEM");
cyl->set_color(0,0.5,1);
g4Reco->registerSubsystem(cyl);
//---------------------------
// Black hole to suck loopers out of their misery
double BH_r = si_r_pos[nTrckLayers-1]+2;
double BH_zmin = si_z_pos[0]-2;
double BH_zmax = si_z_pos[sizeof(si_z_pos)/sizeof(*si_z_pos)-1]+2;
if(use_blackhole)
wrap_with_cylindrical_blackhole(g4Reco,BH_r,BH_zmin,BH_zmax);
//---------------------------
// mid-rapidity beryllium pipe
double be_pipe_radius = 3.1000;
double be_pipe_thickness = 3.1762 - be_pipe_radius; // 760 um for sPHENIX
double be_pipe_length_plus = 66.8; // +z beam pipe extend.
double be_pipe_length_neg = -79.8; // -z beam pipe extend.
double be_pipe_length = be_pipe_length_plus - be_pipe_length_neg;
double be_pipe_center = 0.5 * (be_pipe_length_plus + be_pipe_length_neg);
cyl = new PHG4CylinderSubsystem("BE_PIPE", 1);
cyl->set_double_param("radius", be_pipe_radius);
cyl->set_int_param("lengthviarapidity", 0);
cyl->set_double_param("length", be_pipe_length);
cyl->set_double_param("place_z", be_pipe_center);
cyl->set_string_param("material", "G4_Be");
cyl->set_double_param("thickness", be_pipe_thickness);
cyl->SuperDetector("PIPE");
g4Reco->registerSubsystem(cyl);
//---------------------------
// ------------
// Al Support Structure
AllSi_Al_support_Subsystem *Al_supp = new AllSi_Al_support_Subsystem("Al_supp");
g4Reco->registerSubsystem(Al_supp);
// ------------
if(use_DIRC)
double dirc_out_skin = DIRCSetup(g4Reco);
// ------------
PHG4TruthSubsystem *truth = new PHG4TruthSubsystem();
g4Reco->registerSubsystem(truth);
se->registerSubsystem(g4Reco);
//---------------------------
// fast pattern recognition and full Kalman filter
// output evaluation file for truth track and reco tracks are PHG4TruthInfoContainer
//---------------------------
PHG4TrackFastSim *kalman = new PHG4TrackFastSim("PHG4TrackFastSim");
kalman->set_use_vertex_in_fitting(false);
kalman->set_sub_top_node_name("BARR");
kalman->set_trackmap_out_name("SvtxTrackMap");
// add Vertexing Layers
kalman->add_phg4hits(
"G4HIT_SVTX", // const std::string& phg4hitsNames,
PHG4TrackFastSim::Cylinder,
999., // radial-resolution [cm]
pix_size_vtx/10000./sqrt(12.), // azimuthal-resolution [cm]
pix_size_vtx/10000./sqrt(12.), // z-resolution [cm]
1, // efficiency,
0 // noise hits
);
// add Barrel Layers
kalman->add_phg4hits(
"G4HIT_BARR", // const std::string& phg4hitsNames,
PHG4TrackFastSim::Cylinder,
999., // radial-resolution [cm]
pix_size_bar/10000./sqrt(12.), // azimuthal-resolution [cm]
pix_size_bar/10000./sqrt(12.), // z-resolution [cm]
1, // efficiency,
0 // noise hits
);
// add Disk Layers
kalman->add_phg4hits(
"G4HIT_FBST", // const std::string& phg4hitsNames,
PHG4TrackFastSim::Vertical_Plane,
pix_size_dis/10000./sqrt(12.), // radial-resolution [cm]
pix_size_dis/10000./sqrt(12.), // azimuthal-resolution [cm]
999., // z-resolution [cm]
1, // efficiency,
0 // noise hits
);
// add barrel GEM layer
if(use_barrel_GEM){
kalman->add_phg4hits(
"G4HIT_BARR_GEM", // const std::string& phg4hitsNames,
PHG4TrackFastSim::Cylinder,
999., // radial-resolution [cm]
50e-4, // azimuthal-resolution [cm]
50e-4, // z-resolution [cm]
1, // efficiency,
0
);
}
// Mom. res.
//kalman->set_use_vertex_in_fitting(true);
//kalman->set_vertex_xy_resolution(50e-4);
//kalman->set_vertex_z_resolution(50e-4);
//kalman->enable_vertexing(false); // this is false by default
//kalman->set_vertex_min_ndf(10);
//kalman->Verbosity(10);
kalman->set_use_vertex_in_fitting(false);
kalman->set_vertex_xy_resolution(0);
kalman->set_vertex_z_resolution(0);
kalman->enable_vertexing(false); // this is false by default
kalman->set_vertex_min_ndf(2);
se->registerSubsystem(kalman);
std::string outputFile = (std::string)(out_name)+std::string(B_label)+"_FastSimEval.root";
PHG4TrackFastSimEval *fast_sim_eval = new PHG4TrackFastSimEval("FastTrackingEval");
fast_sim_eval->set_filename(outputFile);
se->registerSubsystem(fast_sim_eval);
// ======================================================================================================
// IOManagers...
const std::string dst_name = std::string(out_name)+std::string(B_label)+"_G4LBLVtx.root";
Fun4AllDstOutputManager *out = new Fun4AllDstOutputManager("DSTOUT",dst_name);
out->Verbosity(0);
se->registerOutputManager(out);
Fun4AllInputManager *in = new Fun4AllDummyInputManager("JADE");
se->registerInputManager(in);
if (nEvents <= 0) return;
se->run(nEvents);
se->End();
delete se;
gSystem->Exit(0);
}