EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4_Intt.C
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file G4_Intt.C
1 #ifndef MACRO_G4INTT_C
2 #define MACRO_G4INTT_C
3 
4 #include <GlobalVariables.C>
5 #include <QA.C>
6 
7 #include <G4_Mvtx.C>
8 
10 #include <g4intt/PHG4InttDefs.h>
12 #include <g4intt/PHG4InttHitReco.h>
14 
15 #include <g4main/PHG4Reco.h>
16 
17 #include <intt/InttClusterizer.h>
18 #include <qa_modules/QAG4SimulationIntt.h>
19 
20 #include <fun4all/Fun4AllServer.h>
21 
22 #include <cmath>
23 #include <vector>
24 
25 R__LOAD_LIBRARY(libg4intt.so)
26 R__LOAD_LIBRARY(libintt.so)
27 R__LOAD_LIBRARY(libqa_modules.so)
28 
29 namespace Enable
30 {
31  bool INTT = false;
32  bool INTT_OVERLAPCHECK = false;
33  bool INTT_CELL = false;
34  bool INTT_CLUSTER = false;
35  bool INTT_QA = false;
36  int INTT_VERBOSITY = 0;
37 } // namespace Enable
38 
39 namespace G4INTT
40 {
41  int n_intt_layer = 4; // must be 4 or 0, setting to zero removes INTT completely
42  double intt_radius_max = 140.; // including stagger radius (mm)
46  PHG4InttDefs::SEGMENTATION_PHI};
47  int nladder[4] = {12, 12, 16, 16};
48  double sensor_radius[4] = {7.188 - 36e-4, 7.732 - 36e-4, 9.680 - 36e-4, 10.262 - 36e-4};
49 
50  double offsetphi[4] = {0.0, 0.5 * 360.0 / nladder[1], 0.0, 0.5 * 360.0 / nladder[3]};
51 
52  enum enu_InttDeadMapType // Dead map options for INTT
53  {
54  kInttNoDeadMap = 0, // All channel in Intt is alive
55  kInttDeadMap = 1, // with dead channel
56  };
57  //enu_InttDeadMapType InttDeadMapOption = kInttNoDeadMap; // Choose Intt deadmap here
58  enu_InttDeadMapType InttDeadMapOption = kInttDeadMap; // Choose Intt deadmap here
59 
60 } // namespace G4INTT
61 
62 void InttInit()
63 {
64  BlackHoleGeometry::max_radius = std::max(BlackHoleGeometry::max_radius, 20.); // estimated from display, can be made smaller but good enough
67  // the mvtx is not called if disabled but the default number of layers is set to 3, so we need to set it
68  // to zero
69  if (!Enable::MVTX)
70  {
72  }
73 }
74 
75 double Intt(PHG4Reco* g4Reco, double radius,
76  const int absorberactive = 0)
77 {
79  bool intt_overlapcheck = Enable::OVERLAPCHECK || Enable::INTT_OVERLAPCHECK;
80 
81  // instantiate the INTT subsystem and register it
82  // We make one instance of PHG4INTTSubsystem for all four layers of tracker
83  // dimensions are in mm, angles are in radians
84 
85  // PHG4InttSubsystem creates the detetor layer using PHG4InttDetector
86  // and instantiates the appropriate PHG4SteppingAction
87 
88  // The length of vpair is used to determine the number of layers
89  std::vector<std::pair<int, int>> vpair; // (sphxlayer, inttlayer)
90  for (int i = 0; i < G4INTT::n_intt_layer; i++)
91  {
92  // We want the sPHENIX layer numbers for the Intt to be from n_maps_layer to n_maps_layer+n_intt_layer - 1
93  vpair.push_back(std::make_pair(G4MVTX::n_maps_layer + i, i)); // sphxlayer=n_maps_layer+i corresponding to inttlayer=i
94  if (verbosity) cout << "Create strip tracker layer " << vpair[i].second << " as sphenix layer " << vpair[i].first << endl;
95  }
96 
97  PHG4InttSubsystem* sitrack = new PHG4InttSubsystem("INTT", vpair);
98  sitrack->Verbosity(verbosity);
99  sitrack->SetActive(1);
100  sitrack->OverlapCheck(intt_overlapcheck);
101  g4Reco->registerSubsystem(sitrack);
102 
103  // Set the laddertype and ladder spacing configuration
104 
105  cout << "Intt has " << G4INTT::n_intt_layer << " layers with layer setup:" << endl;
106  for (int i = 0; i < G4INTT::n_intt_layer; i++)
107  {
108  cout << " Intt layer " << i << " laddertype " << G4INTT::laddertype[i] << " nladders " << G4INTT::nladder[i]
109  << " sensor radius " << G4INTT::sensor_radius[i] << " offsetphi " << G4INTT::offsetphi[i] << endl;
110  sitrack->set_int_param(i, "laddertype", G4INTT::laddertype[i]);
111  sitrack->set_int_param(i, "nladder", G4INTT::nladder[i]);
112  sitrack->set_double_param(i, "sensor_radius", G4INTT::sensor_radius[i]); // expecting cm
113  sitrack->set_double_param(i, "offsetphi", G4INTT::offsetphi[i]); // expecting degrees
114  }
115 
116  // outer radius marker (translation back to cm)
117  radius = G4INTT::intt_radius_max * 0.1;
118  return radius;
119 }
120 
121 // Central detector cell reco is disabled as EIC setup use the fast tracking sim for now
123 {
126 
128  {
129  // Load pre-defined deadmaps
130  PHG4InttDeadMapLoader* deadMapINTT = new PHG4InttDeadMapLoader("INTT");
131 
132  for (int i = 0; i < G4INTT::n_intt_layer; i++)
133  {
134  string DeadMapConfigName = Form("intt_layer%d/", i);
135 
137  {
138  string DeadMapPath = string(getenv("CALIBRATIONROOT")) + string("/Tracking/INTT/DeadMap/");
139  //string DeadMapPath = "/sphenix/u/wxie/sphnx_software/INTT" + string("/DeadMap/");
140 
141  DeadMapPath += DeadMapConfigName;
142 
143  deadMapINTT->deadMapPath(G4MVTX::n_maps_layer + i, DeadMapPath);
144  }
145  else
146  {
147  cout << "G4_Intt.C - fatal error - invalid InttDeadMapOption = " << G4INTT::InttDeadMapOption << endl;
148  exit(1);
149  }
150  }
151 
152  deadMapINTT->Verbosity(verbosity);
153  //deadMapINTT -> Verbosity(1);
154  se->registerSubsystem(deadMapINTT);
155  }
156  // new storage containers
157  PHG4InttHitReco* reco = new PHG4InttHitReco();
158  // The timing windows are hard-coded in the INTT ladder model, they can be overridden here
159  //reco->set_double_param("tmax",80.0);
160  //reco->set_double_param("tmin",-20.0);
161  reco->Verbosity(verbosity);
162  se->registerSubsystem(reco);
163 
164  // Intt digitization
165  //===========
166  // these should be used for the Intt
167  /*
168  How threshold are calculated based on default FPHX settings
169  Four part information goes to the threshold calculation:
170  1. In 320 um thick silicon, the MIP e-h pair for a nominally indenting tracking is 3.87 MeV/cm * 320 um / 3.62 eV/e-h = 3.4e4 e-h pairs
171  2. From DOI: 10.1016/j.nima.2014.04.017, FPHX integrator amplifier gain is 100mV / fC. That translate MIP voltage to 550 mV.
172  3. From [FPHX Final Design Document](https://www.phenix.bnl.gov/WWW/fvtx/DetectorHardware/FPHX/FPHX2_June2009Revision.doc), the DAC0-7 setting for 8-ADC thresholds above the V_ref, as in Table 2 - Register Addresses and Defaults
173  4, From [FPHX Final Design Document](https://www.phenix.bnl.gov/WWW/fvtx/DetectorHardware/FPHX/FPHX2_June2009Revision.doc) section Front-end Program Bits, the formula to translate DAC setting to comparitor voltages.
174  The result threshold table based on FPHX default value is as following
175  | FPHX Register Address | Name | Default value | Voltage - Vref (mV) | To electrons based on calibration | Electrons | Fraction to MIP |
176  |-----------------------|-----------------|---------------|---------------------|-----------------------------------|-----------|-----------------|
177  | 4 | Threshold DAC 0 | 8 | 32 | 2500 | 2000 | 5.85E-02 |
178  | 5 | Threshold DAC 1 | 16 | 64 | 5000 | 4000 | 1.17E-01 |
179  | 6 | Threshold DAC 2 | 32 | 128 | 10000 | 8000 | 2.34E-01 |
180  | 7 | Threshold DAC 3 | 48 | 192 | 15000 | 12000 | 3.51E-01 |
181  | 8 | Threshold DAC 4 | 80 | 320 | 25000 | 20000 | 5.85E-01 |
182  | 9 | Threshold DAC 5 | 112 | 448 | 35000 | 28000 | 8.18E-01 |
183  | 10 | Threshold DAC 6 | 144 | 576 | 45000 | 36000 | 1.05E+00 |
184  | 11 | Threshold DAC 7 | 176 | 704 | 55000 | 44000 | 1.29E+00 |
185  DAC0-7 threshold as fraction to MIP voltage are set to PHG4InttDigitizer::set_adc_scale as 3-bit ADC threshold as fractions to MIP energy deposition.
186  */
187  std::vector<double> userrange; // 3-bit ADC threshold relative to the mip_e at each layer.
188  userrange.push_back(0.0584625322997416);
189  userrange.push_back(0.116925064599483);
190  userrange.push_back(0.233850129198966);
191  userrange.push_back(0.35077519379845);
192  userrange.push_back(0.584625322997416);
193  userrange.push_back(0.818475452196383);
194  userrange.push_back(1.05232558139535);
195  userrange.push_back(1.28617571059432);
196 
197  // new containers
198  PHG4InttDigitizer* digiintt = new PHG4InttDigitizer();
199  digiintt->Verbosity(verbosity);
200  //digiintt->Verbosity(3);
201  for (int i = 0; i < G4INTT::n_intt_layer; i++)
202  {
203  digiintt->set_adc_scale(G4MVTX::n_maps_layer + i, userrange);
204  }
205  se->registerSubsystem(digiintt);
206 
207  return;
208 }
209 
211 {
214 
215  InttClusterizer* inttclusterizer = new InttClusterizer("InttClusterizer", G4MVTX::n_maps_layer, G4MVTX::n_maps_layer + G4INTT::n_intt_layer - 1);
216  inttclusterizer->Verbosity(verbosity);
217  // no Z clustering for Intt type 1 layers (we DO want Z clustering for type 0 layers)
218  // turning off phi clustering for type 0 layers is not necessary, there is only one strip
219  // per sensor in phi
221  {
223  {
224  inttclusterizer->set_z_clustering(i, false);
225  }
226  }
227  se->registerSubsystem(inttclusterizer);
228 }
229 
230 void Intt_QA()
231 {
233 
236  qa->Verbosity(verbosity);
237  se->registerSubsystem(qa);
238 }
239 
240 #endif