Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4_Svtx.C
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file G4_Svtx.C
1 // reference SVTX macro used for MIE projections
2 
3 int Min_si_layer = 0;
4 int Max_si_layer = 6;
5 
6 void SvtxInit(int verbosity = 0)
7 {
8  Min_si_layer = 0;
9  Max_si_layer = 6;
10 }
11 
12 double Svtx(PHG4Reco* g4Reco, double radius,
13  const int absorberactive = 0,
14  int verbosity = 0) {
15 
16  float svtx_inner_radius = 2.71;
17 
18  if (radius > svtx_inner_radius) {
19  cout << "inconsistency: radius: " << radius
20  << " larger than SVTX inner radius: " << svtx_inner_radius << endl;
21  gSystem->Exit(-1);
22  }
23 
24  //---------------
25  // Load libraries
26  //---------------
27 
28  gSystem->Load("libg4detectors.so");
29  gSystem->Load("libg4testbench.so");
30 
32 
33  //======================================================================================================
34  // The thicknesses from Yasuyuki on June 12, 2014 are as follows:
35  // For Si 1mm = 1.07% X_0
36  // For Cu 1mm = 6.96% X_0
37  // The thickness of the tracking layers is:
38  // Pixels: 1.3% X_0 (0.21% sensor + 1.07% support) sensor = 200 mc Si, support = 154 mc Cu
39  // Stripixel: 5% X_0 (0.67% sensor + 4.3% support) sensor = 624 mc Si, support = 618 mc Cu
40  // Outer strips: 2% X_0 (conservative) (0.34% sensor + 1.66% support) sensor = 320 mc Si, support = 238 mc Cu
41  //=======================================================================================================
42 
43  double si_thickness[7] = {0.02, 0.02, 0.032, 0.032, 0.032, 0.032, 0.032};
44  double svxrad[7] = {svtx_inner_radius, 4.63, 9.5, 10.5, 44.5, 45.5, 80.0}; // provides 98 MeV Upsilon resolution
45  // Thicknesses (in % X_0) of 1.3,1.3,2.7/2,2.7/2,2.0/2,2.0/2,2.0 - YA's most conservative case
46  double support_thickness[7] = {0.0154, 0.0154, 0.0338/2.0, 0.0338/2.0, 0.0238/2.0, 0.0238/2.0, 0.0238};
47  double length[7] = {20., 20., -1, -1., - 1., - 1., -1}; // -1 use eta coverage to determine length
48 
49  // here is our silicon:
50  double inner_radius = radius;
51  for (int ilayer = Min_si_layer; ilayer <= Max_si_layer; ilayer++)
52  {
53  cyl = new PHG4CylinderSubsystem("SVTX", ilayer);
54  radius = svxrad[ilayer];
55  // protect against installing layer with radius < inner radius from argument
56  if (radius < inner_radius)
57  {
58  cout << "current radius " << radius << " smaller than inner radius "
59  << inner_radius << endl;
60  gSystem->Exit(-1);
61  }
62  cyl->set_double_param("radius",radius);
63  if (length[ilayer] > 0)
64  {
65  cyl->set_int_param("lengthviarapidity",0);
66  cyl->set_double_param("length",length[ilayer]);
67  }
68  else
69  {
70  cyl->set_int_param("lengthviarapidity",1);
71  }
72  cyl->set_string_param("material","G4_Si");
73  cyl->set_double_param("thickness",si_thickness[ilayer]);
74  cyl->SetActive();
75  cyl->SuperDetector("SVTX");
76  g4Reco->registerSubsystem( cyl );
77 
78  radius += si_thickness[ilayer] + no_overlapp;
79  cyl = new PHG4CylinderSubsystem("SVTXSUPPORT", ilayer);
80  cyl->set_double_param("radius",radius);
81  if (length[ilayer] > 0)
82  {
83  cyl->set_int_param("lengthviarapidity",0);
84  cyl->set_double_param("length",length[ilayer]);
85  }
86  else
87  {
88  cyl->set_int_param("lengthviarapidity",1);
89  }
90  cyl->set_string_param("material","G4_Cu");
91  cyl->set_double_param("thickness",support_thickness[ilayer]);
92  if (absorberactive) cyl->SetActive();
93  cyl->SuperDetector("SVTXSUPPORT");
94  g4Reco->registerSubsystem( cyl );
95  }
96  if (ilayer != (Max_si_layer+1)) // coming out of the loop, layer is layer+1
97  {
98  cout << "layer number mismatch for Max_si_layer, Max_si_layer "
99  << Max_si_layer << " should be " << ilayer << endl;
100  gSystem->Exit(-1);
101  }
102  radius += support_thickness[Max_si_layer] + no_overlapp;
103 
104  if (verbosity > 0) {
105  cout << "============================ G4_Svtx.C::Svtx() ============================" << endl;
106  cout << " SVTX Material Description:" << endl;
107  for (int ilayer = Min_si_layer; ilayer <= Max_si_layer; ilayer++) {
108  cout << " layer " << ilayer
109  << " radius " << svxrad[ilayer]
110  << " zlength " << length[ilayer]
111  << " thickness (Si) " << si_thickness[ilayer]
112  << " support thickness (Cu) " << support_thickness[ilayer]
113  << endl;
114  }
115  cout << "===========================================================================" << endl;
116  }
117  return radius;
118 }
119 
120 void Svtx_Cells(int verbosity = 0)
121 {
122  // runs the cellularization of the energy deposits (g4hits)
123  // into detector hits (g4cells)
124 
125  //---------------
126  // Load libraries
127  //---------------
128 
129  gSystem->Load("libfun4all.so");
130  gSystem->Load("libg4detectors.so");
131 
132  //---------------
133  // Fun4All server
134  //---------------
135 
137 
138  //-----------
139  // SVTX cells
140  //-----------
141 
142  // The pattern recognition layers (4 & 6) are set at 2 mm in Z and 240 microns
143  // pitch to make the area the same as the long strips
144  // Layers 3, 5 and 7 are long strips parallel to the beam line
145 
146  // 60 micron X strips, 240 micron pattern reco strips
147  double svxcellsizex[7] = {0.0050, 0.0050, 0.0060, 0.0240, 0.0060, 0.0240, 0.0060};
148 
149  // 8 mm tracking strips, 2 mm pattern reco strips
150  double svxcellsizey[7] = {0.0425, 0.0425, 0.8000, 0.2000, 0.8000, 0.2000, 0.8000};
151 
152  PHG4CylinderCellReco *svtx_cells = new PHG4CylinderCellReco();
153  svtx_cells->Detector("SVTX");
154  svtx_cells->Verbosity(verbosity);
155  int idx = 0;
156  for (int i = Min_si_layer; i <= Max_si_layer; ++i) {
157  svtx_cells->cellsize(i, svxcellsizex[idx], svxcellsizey[idx]);
158  ++idx;
159  }
160  se->registerSubsystem(svtx_cells);
161 
162  return;
163 }
164 
165 void Svtx_Reco(int verbosity = 0)
166 {
167  // reconstructs the MIE Svtx v2 detector (7 layers)
168 
169  // requires Svtx setup and Svtx cell routines
170  // prefers calorimeter reconstruction prior (once projections are working)
171 
172  //---------------
173  // Load libraries
174  //---------------
175 
176  gSystem->Load("libfun4all.so");
177  gSystem->Load("libg4hough.so");
178 
179  //---------------
180  // Fun4All server
181  //---------------
182 
184 
185  //----------------------------------
186  // Digitize the cell energy into ADC
187  //----------------------------------
188  // defaults to 8-bit ADC with MIP at 0.25% dynamic range
189  PHG4SvtxDigitizer* digi = new PHG4SvtxDigitizer();
190  digi->Verbosity(verbosity);
191  digi->set_adc_scale(0, 255, 1.0e-6); // 1.0 keV / bit
192  digi->set_adc_scale(1, 255, 1.0e-6); // 1.0 keV / bit
193  digi->set_adc_scale(2, 255, 1.6e-6); // 1.6 keV / bit
194  digi->set_adc_scale(3, 255, 1.6e-6); // 1.6 keV / bit
195  digi->set_adc_scale(4, 255, 1.6e-6); // 1.6 keV / bit
196  digi->set_adc_scale(5, 255, 1.6e-6); // 1.6 keV / bit
197  digi->set_adc_scale(6, 255, 1.6e-6); // 1.6 keV / bit
198  se->registerSubsystem( digi );
199 
200  //-------------------------------------
201  // Apply Live Area Inefficiency to Hits
202  //-------------------------------------
203  // defaults to 1.0 (fully active)
204  PHG4SvtxDeadArea* deadarea = new PHG4SvtxDeadArea();
205  deadarea->Verbosity(verbosity);
206  // deadarea->set_hit_efficiency(0,0.90);
207  // deadarea->set_hit_efficiency(1,0.90);
208  // deadarea->set_hit_efficiency(2,0.98);
209  // deadarea->set_hit_efficiency(3,0.98);
210  // deadarea->set_hit_efficiency(4,0.98);
211  // deadarea->set_hit_efficiency(5,0.98);
212  // deadarea->set_hit_efficiency(6,0.98);
213  se->registerSubsystem( deadarea );
214 
215  //-----------------------------
216  // Apply MIP thresholds to Hits
217  //-----------------------------
218  PHG4SvtxThresholds* thresholds = new PHG4SvtxThresholds();
219  thresholds->Verbosity(verbosity);
220  thresholds->set_threshold(0,0.33);
221  thresholds->set_threshold(1,0.33);
222  thresholds->set_threshold(2,0.33);
223  thresholds->set_threshold(3,0.33);
224  thresholds->set_threshold(4,0.33);
225  thresholds->set_threshold(5,0.33);
226  thresholds->set_threshold(6,0.33);
227  thresholds->set_use_thickness_mip(0, true);
228  se->registerSubsystem( thresholds );
229 
230  //-------------
231  // Cluster Hits
232  //-------------
233  // needs to have clusters hold hit ids not cell ids
234  // will require changes to evaluation
235  PHG4SvtxClusterizer* clusterizer = new PHG4SvtxClusterizer();
236  clusterizer->Verbosity(verbosity);
237  clusterizer->set_threshold(0.33);
238  clusterizer->set_z_clustering(2, false);
239  clusterizer->set_z_clustering(3, false);
240  clusterizer->set_z_clustering(4, false);
241  clusterizer->set_z_clustering(5, false);
242  clusterizer->set_z_clustering(6, false);
243  // clusterizer->set_energy_weighting(2, true);
244  // clusterizer->set_energy_weighting(3, true);
245  // clusterizer->set_energy_weighting(4, true);
246  // clusterizer->set_energy_weighting(5, true);
247  // clusterizer->set_energy_weighting(6, true);
248  se->registerSubsystem( clusterizer );
249 
250  //---------------------
251  // Track reconstruction
252  //---------------------
253  PHG4HoughTransform* hough = new PHG4HoughTransform(7,7);
254  hough->Verbosity(verbosity);
255  hough->set_mag_field(1.4);
256  hough->set_material(0, 0.013);
257  hough->set_material(1, 0.013);
258  hough->set_material(2, 0.013);
259  hough->set_material(3, 0.013);
260  hough->set_material(4, 0.010);
261  hough->set_material(5, 0.010);
262  hough->set_material(6, 0.020);
263  hough->setPtRescaleFactor(0.9972);
264  hough->set_chi2_cut_init(3.0);
265  hough->set_chi2_cut_full(3.0);
266  hough->set_ca_chi2_cut(3.0);
267  hough->setCutOnDCA(true);
268  hough->setDCACut(0.1);
269  hough->setDCAZCut(0.1);
270  hough->setRejectGhosts(false);
271  hough->setRemoveHits(false);
272  se->registerSubsystem( hough );
273 
274  //---------------------
275  // Ghost rejection
276  //---------------------
277  // needs updates to merge split tracks when possible
278  PHG4TrackGhostRejection* rejection = new PHG4TrackGhostRejection(7);
279  rejection->Verbosity(verbosity);
280  rejection->set_max_shared_hits(3);
281  se->registerSubsystem( rejection );
282 
283  //------------------------
284  // Final Track Refitting
285  //------------------------
286  // PHG4TrackKalmanFitter *kalman = new PHG4TrackKalmanFitter
287  // we need a module to redo the Kalman fit with G4 material and real mag field
288  // to update the track container
289 
290  //------------------------
291  // Primary Track Refitting
292  //------------------------
293  // PHG4TrackKalmanFitter *kalman = new PHG4TrackKalmanFitter
294  // we need a module to redo the Kalman fit including the vertex position
295  // and create a separate stream of output tracks
296 
297  //------------------
298  // Track Projections
299  //------------------
300  PHG4SvtxTrackProjection* projection = new PHG4SvtxTrackProjection();
301  projection->Verbosity(verbosity);
302  se->registerSubsystem( projection );
303 
304  //----------------------
305  // Beam Spot Calculation
306  //----------------------
307  PHG4SvtxBeamSpotReco* beamspot = new PHG4SvtxBeamSpotReco();
308  beamspot->Verbosity(verbosity);
309  se->registerSubsystem( beamspot );
310 
311  return;
312 }
313 
315 {
316  cout << "\033[31;1m"
317  << "Warning: G4_Svtx_Reco() was moved to G4_Svtx.C and renamed to Svtx_Reco(), please update macros"
318  << "\033[0m" << endl;
319  Svtx_Reco();
320 
321  return;
322 }
323 
324 void Svtx_Eval(std::string outputfile, int verbosity = 0)
325 {
326  //---------------
327  // Load libraries
328  //---------------
329 
330  gSystem->Load("libfun4all.so");
331  gSystem->Load("libg4detectors.so");
332  gSystem->Load("libg4hough.so");
333  gSystem->Load("libg4eval.so");
334 
335  //---------------
336  // Fun4All server
337  //---------------
338 
340 
341  //----------------
342  // SVTX evaluation
343  //----------------
344 
345  SubsysReco* eval = new SvtxEvaluator("SVTXEVALUATOR", outputfile.c_str());
346  eval->Verbosity(verbosity);
347  se->registerSubsystem( eval );
348 
349  return;
350 }