Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4_Svtx_MAPScyl_ITTcyl_TPC.C
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file G4_Svtx_MAPScyl_ITTcyl_TPC.C
1 #include "G4_TPC.C"
2 
3 const int n_ib_layer = 3; // number of maps inner barrel layers
4 const int n_intt_layer = 4; // number of int. tracker layers. Make this number 0 to use MAPS + TPC only.
5 const int n_gas_layer = 40; // number of TPC layers
6 
7 int Min_si_layer = 0;
9 
10 void SvtxInit(int verbosity = 0)
11 {
12  Min_si_layer = 0;
14 }
15 
16 double Svtx(PHG4Reco* g4Reco, double radius,
17  const int absorberactive = 0,
18  int verbosity = 0) {
19 
20  float svtx_inner_radius = 2.3;
21 
22  if (radius > svtx_inner_radius) {
23  cout << "inconsistency: radius: " << radius
24  << " larger than SVTX inner radius: " << svtx_inner_radius << endl;
25  gSystem->Exit(-1);
26  }
27 
29 
30  // silicon layers ------------------------------------------------------------
31 
32  // inner barrel
33 
34  double ib_si_thickness[3] = {0.0050, 0.0050, 0.0050};
35  double ib_rad[3] = {svtx_inner_radius, 3.2, 3.9};
36  double ib_support_thickness[3] = {0.0036, 0.0036, 0.0036};
37  double ib_length[3] = {27.0, 27.0, 27.0};
38 
39  for (int ilayer=0;ilayer<n_ib_layer;++ilayer) {
40  cyl = new PHG4CylinderSubsystem("SVTX", ilayer);
41  cyl->Verbosity(verbosity);
42  radius = ib_rad[ilayer];
43  cyl->set_double_param("radius",radius);
44  //cyl->set_int_param("lengthviarapidity",0);
45  cyl->set_double_param("length",ib_length[ilayer]);
46  cyl->set_string_param("material","G4_Si");
47  cyl->set_double_param("thickness",ib_si_thickness[ilayer]);
48  cyl->SetActive();
49  cyl->SuperDetector("SVTX");
50  g4Reco->registerSubsystem( cyl );
51 
52  radius += ib_si_thickness[ilayer] + no_overlapp;
53 
54  cyl = new PHG4CylinderSubsystem("SVTXSUPPORT", ilayer);
55  cyl->Verbosity(verbosity);
56  cyl->set_double_param("radius",radius);
57  //cyl->set_int_param("lengthviarapidity",1);
58  cyl->set_double_param("length",ib_length[ilayer]);
59  cyl->set_string_param("material","G4_Cu");
60  cyl->set_double_param("thickness",ib_support_thickness[ilayer]);
61  cyl->SuperDetector("SVTXSUPPORT");
62  g4Reco->registerSubsystem( cyl );
63 
64  cout << "Added inner barrel layer with radius " << ib_rad[ilayer]
65  << " si thickness " << ib_si_thickness[ilayer]
66  << " support thickness " << ib_support_thickness[ilayer]
67  << " length " << ib_length[ilayer]
68  << endl;
69  }
70 
71  // intermediate tracker
72  // parameters from RIKEN
73  double intt_si_thickness[4] = {0.0120, 0.0120, 0.0120,0.0120};
74  double intt_rad[4] = { 6.0, 8.0, 10.0, 12.0};
75  // 120 microns of silicon is 0.13% of X_0, so to get 1% total we need 0.87% more in the Cu
76  double multiplier = 0.87; // how many times 1% do you want?
77  double apercent = 0.0144; // Cu thickness in cm corresponding to 1% X_0
78  double intt_support_thickness[4] = {apercent*multiplier, apercent*multiplier, apercent*multiplier, apercent*multiplier};
79  double intt_length[4] = {50.0, 50.0, 50.0, 50.0};
80 
81  for (int ilayer=n_ib_layer;ilayer<n_intt_layer+n_ib_layer;++ilayer) {
82  cyl = new PHG4CylinderSubsystem("SVTX", ilayer);
83  cyl->Verbosity(verbosity);
84  radius = intt_rad[ilayer-n_ib_layer];
85  cyl->set_double_param("radius",radius);
86  cyl->set_int_param("lengthviarapidity",1);
87  //cyl->set_double_param("length",intt_length[ilayer-n_ib_layer]);
88  cyl->set_string_param("material","G4_Si");
89  cyl->set_double_param("thickness",intt_si_thickness[ilayer-n_ib_layer]);
90  cyl->SetActive();
91  cyl->SuperDetector("SVTX");
92  g4Reco->registerSubsystem( cyl );
93 
94  radius += intt_si_thickness[ilayer-n_ib_layer] + no_overlapp;
95 
96  cyl = new PHG4CylinderSubsystem("SVTXSUPPORT", ilayer);
97  cyl->Verbosity(verbosity);
98  cyl->set_double_param("radius",radius);
99  cyl->set_int_param("lengthviarapidity",1);
100  //cyl->set_double_param("length", intt_length[ilayer-n_ib_layer]);
101  cyl->set_string_param("material","G4_Cu");
102  cyl->set_double_param("thickness",intt_support_thickness[ilayer-n_ib_layer]);
103  cyl->SuperDetector("SVTXSUPPORT");
104  g4Reco->registerSubsystem( cyl );
105 
106  cout << "Added intermediate tracker layer with radius " << intt_rad[ilayer-n_ib_layer]
107  << " si thickness " << intt_si_thickness[ilayer-n_ib_layer]
108  << " support thickness " << intt_support_thickness[ilayer-n_ib_layer]
109  << " length " << intt_length[ilayer-n_ib_layer]
110  << endl;
111  }
112 
113  //TPC
114  radius = AddTPC2G4Geo(g4Reco,radius,0);
115 
116  return radius;
117 }
118 
119 void Svtx_Cells(int verbosity = 0)
120 {
121  // runs the cellularization of the energy deposits (g4hits)
122  // into detector hits (g4cells)
123 
124  //---------------
125  // Load libraries
126  //---------------
127 
128  gSystem->Load("libfun4all.so");
129  gSystem->Load("libg4detectors.so");
130 
131  //---------------
132  // Fun4All server
133  //---------------
134 
136 
137  //-----------
138  // cells
139  //-----------
140 
141  // inner barrel
142  double svxcellsizex[3] = {0.0020, 0.0020, 0.0020};
143  double svxcellsizey[3] = {0.0020, 0.0020, 0.0020};
144 
145  // intermediate tracker
146  double intt_cellsizex[4] = { 0.0080, 0.0080, 0.0080, 0.0080}; // cm
147  double intt_cellsizey[4] = { 1.2, 1.2, 1.2, 1.2}; // cm
148 
149  PHG4CylinderCellTPCReco *svtx_cells = new PHG4CylinderCellTPCReco(n_ib_layer+n_intt_layer);
150  svtx_cells->Verbosity(1);
151  svtx_cells->Detector("SVTX");
152 
153  for (int i=0;i<n_ib_layer;++i) {
154  svtx_cells->cellsize(i, svxcellsizex[i], svxcellsizey[i]);
155  svtx_cells->set_timing_window(i, -2000.0, +2000.0);
156  }
157  for (int i=n_ib_layer;i<n_ib_layer+n_intt_layer;++i) {
158  svtx_cells->cellsize(i, intt_cellsizex[i-n_ib_layer], intt_cellsizey[i-n_ib_layer]);
159  svtx_cells->set_timing_window(i, -50.0, +50.0);
160  }
161 
162  // TPC
163  AddTPC2CellReco(svtx_cells);
164 
165  se->registerSubsystem(svtx_cells);
166  return;
167 }
168 
169 void Svtx_Reco(int verbosity = 0)
170 {
171  //---------------
172  // Load libraries
173  //---------------
174 
175  gSystem->Load("libfun4all.so");
176  gSystem->Load("libg4hough.so");
177 
178  //---------------
179  // Fun4All server
180  //---------------
181 
183 
184  //----------------------------------
185  // Digitize the cell energy into ADC
186  //----------------------------------
187  PHG4SvtxDigitizer* digi = new PHG4SvtxDigitizer();
188  digi->Verbosity(0);
189  for (int i=0;i<n_ib_layer+n_intt_layer;++i) {
190  digi->set_adc_scale(i, 255, 1.0e-6);
191  }
192  se->registerSubsystem( digi );
193 
194  //-------------------------------------
195  // Apply Live Area Inefficiency to Hits
196  //-------------------------------------
197  // defaults to 1.0 (fully active)
198 
199  PHG4SvtxDeadArea* deadarea = new PHG4SvtxDeadArea();
200  deadarea->Verbosity(verbosity);
201  for(int i=0;i<n_ib_layer;i++)
202  deadarea->set_hit_efficiency(i,0.99);
203 
204  for(int i=n_ib_layer;i<n_ib_layer+n_intt_layer;i++)
205  deadarea->set_hit_efficiency(i-n_ib_layer,0.99);
206 
207  se->registerSubsystem( deadarea );
208 
209  //-----------------------------
210  // Apply MIP thresholds to Hits
211  //-----------------------------
212 
213  PHG4SvtxThresholds* thresholds = new PHG4SvtxThresholds();
214  thresholds->Verbosity(verbosity);
215  for(int i=0;i<n_ib_layer;i++)
216  thresholds->set_threshold(i,0.25); // reduce to 0.1 for increased efficiency
217 
218  for(int i=n_ib_layer;i<n_ib_layer+n_intt_layer;i++)
219  thresholds->set_threshold(i,0.25);
220 
221  se->registerSubsystem( thresholds );
222 
223  //-------------
224  // Cluster Hits
225  //-------------
226 
227  PHG4SvtxClusterizer* clusterizer = new PHG4SvtxClusterizer("PHG4SvtxClusterizer",Min_si_layer,n_ib_layer+n_intt_layer-1);
228  clusterizer->set_threshold(0.25); // reduced from 0.5, should be same as cell threshold, since many hits are single cell
229  se->registerSubsystem( clusterizer );
230 
231  //---------------------
232  // Track reconstruction
233  //---------------------
234  PHG4HoughTransformTPC* hough = new PHG4HoughTransformTPC(Max_si_layer,Max_si_layer-30);
235  hough->set_mag_field(1.4);
236  hough->setPtRescaleFactor(1.00/0.993892);
237  hough->set_use_vertex(true);
238  hough->setRemoveHits(true);
239  hough->setRejectGhosts(true);
240  hough->set_min_pT(0.2);
241  hough->set_chi2_cut_full( 2.0 );
242  hough->set_chi2_cut_init( 2.0 );
243 
244  hough->setBinScale(1.0);
245  hough->setZBinScale(1.0);
246 
247  hough->Verbosity(verbosity);
248 
249  double mat_scale = 1.0;
250  // maps inner barrel, total of 0.3% of X_0 per layer
251  for(int i=0;i<n_ib_layer;i++)
252  hough->set_material(i, mat_scale*0.003);
253  // intermediate tracker, total 1% of X_0 pair layer
254  for(int i=n_ib_layer;i<n_ib_layer+n_intt_layer;i++)
255  hough->set_material(i-n_ib_layer, mat_scale*0.010);
256 
257  // silicon
258  for (int i=0;i<n_ib_layer+n_intt_layer;++i) {
259  hough->setVoteErrorScale(i, 1.0);
260  }
261  for (int i=0;i<n_ib_layer+n_intt_layer;++i) {
262  hough->setFitErrorScale(i, 1./sqrt(12.));
263  }
264 
265  //TPC
266  AddTPC2Reco(digi,hough);
267 
268  se->registerSubsystem( hough );
269 
270  //-----------------------
271  // Momentum Recalibration
272  //-----------------------
273  TF1 *corr = new TF1("corr","1.0/(1+0.00908642+5.91337e-05*x+-1.87201e-05*x*x+-3.31928e-06*x*x*x+1.03004e-07*x*x*x*x+-1.05111e-09*x*x*x*x*x)",0.0,40.0);
274  PHG4SvtxMomentumRecal* recal = new PHG4SvtxMomentumRecal("PHG4SvtxMomentumRecal",corr);
275  se->registerSubsystem(recal);
276 
277  //------------------
278  // Track Projections
279  //------------------
280  PHG4SvtxTrackProjection* projection = new PHG4SvtxTrackProjection();
281  projection->Verbosity(verbosity);
282  se->registerSubsystem( projection );
283 
284  //----------------------
285  // Beam Spot Calculation
286  //----------------------
287  PHG4SvtxBeamSpotReco* beamspot = new PHG4SvtxBeamSpotReco();
288  beamspot->Verbosity(verbosity);
289  se->registerSubsystem( beamspot );
290 
291  return;
292 }
293 
295 {
296  cout << "\033[31;1m"
297  << "Warning: G4_Svtx_Reco() was moved to G4_Svtx.C and renamed to Svtx_Reco(), please update macros"
298  << "\033[0m" << endl;
299  Svtx_Reco();
300 
301  return;
302 }
303 
304 void Svtx_Eval(std::string outputfile, int verbosity = 0)
305 {
306  //---------------
307  // Load libraries
308  //---------------
309 
310  gSystem->Load("libfun4all.so");
311  gSystem->Load("libg4detectors.so");
312  gSystem->Load("libg4hough.so");
313  gSystem->Load("libg4eval.so");
314 
315  //---------------
316  // Fun4All server
317  //---------------
318 
320 
321  //----------------
322  // SVTX evaluation
323  //----------------
324 
325  SvtxEvaluator* eval = new SvtxEvaluator("SVTXEVALUATOR", outputfile.c_str());
326  eval->do_cluster_eval(true); // make cluster ntuple
327  eval->do_g4hit_eval(false); // make g4hit ntuple
328  eval->do_hit_eval(false); // make hit ntuple
329  eval->do_gpoint_eval(false);
330  //eval->scan_for_embedded(true); // evaluator will only collect embedded tracks - it will also ignore decay tracks from embedded particles!
331  eval->scan_for_embedded(false); // evaluator takes all tracks
332  eval->Verbosity(verbosity);
333  se->registerSubsystem( eval );
334 
335  // MomentumEvaluator* eval = new MomentumEvaluator(outputfile.c_str(),0.2,0.4,Max_si_layer,2,Max_si_layer-4,10.,80.);
336  // se->registerSubsystem( eval );
337 
338  return;
339 }