Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Wrapper.cxx
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file Wrapper.cxx
1 int Min_cemc_layer = -1;
2 int Max_cemc_layer = -1;
9 int Min_si_layer = -1;
10 int Max_si_layer = -1;
11 int Cemc_slats_per_cell = 72; // make it 2*2*2*3*3 so we can try other combinations
12 
13 // #include<src/PJTranslator.h>
14 
15 int Wrapper(
16  int nEvents = 1,
17  const char * fileList = "/star/u/kkauder/sphenix/analysis/sPhenixAj/SingleEventPythia.list",
18  // const char * fileList = "/star/u/kkauder/sphenix/analysis/sPhenixAj/singleparticle.list",
19  const char * outputFile = "G4sPHENIXCells.root"
20  )
21 {
22  //===============
23  // Input options
24  //===============
25 
26  // Either:
27  // read previously generated g4-hits files, in this case it opens a DST and skips
28  // the simulations step completely. The G4Setup macro is only loaded to get information
29  // about the number of layers used for the cell reco code
30  const bool readhits = false;
31  // Or:
32  // read files in HepMC format (typically output from event generators like hijing or pythia)
33  const bool readhepmc = true; // read HepMC files
34  // Or:
35  // Use particle generator
36 
37  //======================
38  // What to run
39  //======================
40 
41  bool do_svtx = true;
42  bool do_svtx_cell = true;
43  bool do_svtx_track = true;
44  bool do_svtx_eval = true;
45 
46  bool do_preshower = false;
47 
48  bool do_cemc = true;
49  bool do_cemc_cell = true;
50  bool do_cemc_twr = true;
51  bool do_cemc_cluster = true;
52  bool do_cemc_eval = true;
53 
54  bool do_hcalin = true;
55  bool do_hcalin_cell = true;
56  bool do_hcalin_twr = true;
57  bool do_hcalin_cluster = true;
58  bool do_hcalin_eval = true;
59 
60  bool do_magnet = true;
61 
62  bool do_hcalout = true;
63  bool do_hcalout_cell = true;
64  bool do_hcalout_twr = true;
65  bool do_hcalout_cluster = true;
66  bool do_hcalout_eval = true;
67 
68  //---------------
69  // Load libraries
70  //---------------
71 
72  gSystem->Load("libfun4all.so");
73  gSystem->Load("libg4detectors.so");
74  gSystem->Load("libphhepmc.so");
75  gSystem->Load("libg4testbench.so");
76  gSystem->Load("libg4hough.so");
77  gSystem->Load("libg4calo.so");
78  gSystem->Load("libg4eval.so");
79  gSystem->Load("libPHAJMaker.so");
80 
81  // establish the geometry and reconstruction setup
82  gROOT->LoadMacro("G4Setup_sPHENIX.C");
83  G4Init(do_svtx,do_preshower,do_cemc,do_hcalin,do_magnet,do_hcalout);
84 
85  int absorberactive = 1; // set to 1 to make all absorbers active volumes
86  // const string magfield = "1.5"; // if like float -> solenoidal field in T, if string use as fieldmap name (including path)
87  const string magfield = "/phenix/upgrades/decadal/fieldmaps/bPHENIX.dp.root"; // if like float -> solenoidal field in T, if string use as fieldmap name (including path)
88 
89 
90  //---------------
91  // Fun4All server
92  //---------------
94  se->Verbosity(0);
95 
96  // unique seed
97  int uniqueseed = TRandom3(0).GetSeed();
99  rc->set_IntFlag("RANDOMSEED", uniqueseed);
100 
101  //-----------------
102  // Event generation
103  //-----------------
104 
105  if (readhits)
106  {
107  // Get the hits from a file
108  // The input manager is declared later
109  }
110  else if (readhepmc)
111  {
112  // this module is needed to read the HepMC records into our G4 sims
113  // but only if you read HepMC input files
114  HepMCNodeReader *hr = new HepMCNodeReader();
115  se->registerSubsystem(hr);
116  }
117  else
118  {
119  // toss low multiplicity dummy events
121  gen->add_particles("e-",5); // mu+,e+,proton,pi+,Upsilon
122  gen->add_particles("e+",5); // mu-,e-,anti_proton,pi-
123  if (readhepmc) {
124  gen->set_reuse_existing_vertex(true);
125  gen->set_existing_vertex_offset_vector(0.0,0.0,0.0);
126  } else {
130  gen->set_vertex_distribution_mean(0.0,0.0,0.0);
131  gen->set_vertex_distribution_width(0.0,0.0,5.0);
132  }
134  gen->set_vertex_size_parameters(0.0,0.0);
135  gen->set_eta_range(-0.5, 0.5);
136  gen->set_phi_range(-1.0*TMath::Pi(), 1.0*TMath::Pi());
137  gen->set_pt_range(0.1, 10.0);
138  gen->set_embedflag(1);
139  gen->set_seed(uniqueseed);
140  gen->set_verbosity(0);
141  se->registerSubsystem(gen);
142  }
143 
144  if (!readhits)
145  {
146  //---------------------
147  // Detector description
148  //---------------------
149 
150  G4Setup(absorberactive, magfield, TPythia6Decayer::kAll,
151  do_svtx, do_preshower, do_cemc, do_hcalin, do_magnet, do_hcalout);
152  }
153 
154  //------------------
155  // Detector Division
156  //------------------
157 
158 
159  if (do_svtx_cell) Svtx_Cells();
160 
161  if (do_cemc_cell) CEMC_Cells();
162 
163  if (do_hcalin_cell) HCALInner_Cells();
164 
165  if (do_hcalout_cell) HCALOuter_Cells();
166 
167  //-----------------------------
168  // CEMC towering and clustering
169  //-----------------------------
170 
171  if (do_cemc_twr) CEMC_Towers();
172  if (do_cemc_cluster) CEMC_Clusters();
173 
174  //-----------------------------
175  // HCAL towering and clustering
176  //-----------------------------
177 
178  if (do_hcalin_cell) HCALInner_Towers();
179  if (do_hcalin_cell) HCALInner_Clusters();
180 
181  if (do_hcalout_cell) HCALOuter_Towers();
182  if (do_hcalout_cell) HCALOuter_Clusters();
183 
184  //--------------
185  // SVTX tracking
186  //--------------
187 
188  if (do_svtx_track) Svtx_Reco();
189 
190  //----------------------
191  // Simulation evaluation
192  //----------------------
193 
194  if (do_svtx_eval) Svtx_Eval("g4svtx_eval.root");
195 
196  if (do_cemc_eval) CEMC_Eval("g4cemc_eval.root");
197 
198  if (do_hcalin_cell) HCALInner_Eval("g4hcalin_eval.root");
199 
200  if (do_hcalout_cell) HCALOuter_Eval("g4hcalout_eval.root");
201 
202  // PHAJMaker *ana = new PHAJMaker(outputFile);
203  // se->registerSubsystem(ana);
204 
205  PJTranslator *trans = new PJTranslator( "PJTranslator" );
206  se->registerSubsystem(trans);
207 
208  // PHAJMaker *ana = new PHAJMaker(outputFile);
209  PHAJMaker *AJ = new PHAJMaker("AJ");
210  se->registerSubsystem(AJ);
211 
212  //--------------
213  // IO management
214  //--------------
215 
216  if (readhits)
217  {
218  // Hits file
219  Fun4AllInputManager *hitsin = new Fun4AllDstInputManager("DSTin");
220  throw (-1);
221  // hitsin->fileopen(inputFile);
222  // hitsin->AddListFile(fileList);
223  se->registerInputManager(hitsin);
224  }
225  if (readhepmc)
226  {
228  in->AddListFile(fileList);
229  se->registerInputManager( in );
230  //se->fileopen( in->Name(), inputFile );
231  }
232  else
233  {
234  // for single particle generators we just need something which drives
235  // the event loop, the Dummy Input Mgr does just that
236  throw(-1);
238  se->registerInputManager( in );
239  }
240 
241 
242  // Fun4AllDstOutputManager *out = new Fun4AllDstOutputManager("DSTOUT", outputFile);
243  // se->registerOutputManager(out);
244 
245  //-----------------
246  // Event processing
247  //-----------------
248  se->run(nEvents);
249 
250  //-----
251  // Exit
252  //-----
253 
254  se->End();
255  se->dumpHistos();
256  std::cout << "All done" << std::endl;
257  delete se;
258  gSystem->Exit(0);
259 }
260 
262 {
263  return Min_cemc_layer;
264 }
265 
267 {
268  return Max_cemc_layer;
269 }
270 
272 {
273  return Min_hcal_in_layer;
274 }
275 
277 {
278  return Max_hcal_in_layer;
279 }
280 
282 {
283  return Min_hcal_out_layer;
284 }
285 
287 {
288  return Max_hcal_out_layer;
289 }
290 
292 {
293  return Min_si_layer;
294 }
295 
297 {
298  return Max_si_layer;
299 }
300 
302 {
303  return Min_preshower_layer;
304 }
305 
307 {
308  return Max_preshower_layer;
309 }