Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Fun.C
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file Fun.C
1 void ConfigureInput(TString inputFile) {
2  const bool hijing = true;
3  const bool genera = true;
4 
6 
7  if(hijing) {
9  //hr->SmearVertex(0.0,0.0,-5.0); // optional
10  se->registerSubsystem(hr);
12  se->registerInputManager( in );
13  in->fileopen( inputFile.Data() ); //fileopen only after you register!
14  }
15 
16  if(genera) {
18  gen->add_particles("pi-",5); // mu+,e+,proton,pi+,Upsilon
19  gen->add_particles("pi+",5); // mu-,e-,anti_proton,pi-
20  if(hijing) {
21  gen->set_reuse_existing_vertex(true);
22  gen->set_existing_vertex_offset_vector(0.0, 0.0, 0.0);
23  } else {
27  gen->set_vertex_distribution_mean(0.0, 0.0, 0.0);
28  gen->set_vertex_distribution_width(0.0, 0.0, 0.0);
29  }
31  gen->set_vertex_size_parameters(0.0, 0.0);
32  gen->set_eta_range(-1.1,+1.1);
33  gen->set_phi_range(-1.0 * TMath::Pi(), 1.0 * TMath::Pi());
34  gen->set_pt_range(0.2, 39.0);
35  gen->Embed(1);
36  gen->Verbosity(0);
37 
38  se->registerSubsystem(gen);
39  }
40 }
41 void RandomSeed() {
42  // By default every random number generator uses
43  // PHRandomSeed() which reads /dev/urandom to get its seed
44  // if the RANDOMSEED flag is set its value is taken as seed
45  // You ca neither set this to a random value using PHRandomSeed()
46  // which will make all seeds identical (not sure what the point of
47  // this would be:
48  // or set it to a fixed value so you can debug your code
49 
51  // rc->set_IntFlag("RANDOMSEED",PHRandomSeed());
52  // rc->set_IntFlag("RANDOMSEED", 12345);
53 }
55  bool do_magnet = true;
56  bool do_svtx = true;
57  bool do_preshower = false;
58  bool do_cemc = false;
59  bool do_hcalin = false;
60  bool do_hcalout = false;
61  bool do_pipe = true;
62  G4Init(do_svtx,do_preshower,do_cemc,do_hcalin,do_magnet,do_hcalout,do_pipe);
63 
64  int absorberactive = 1; // set to 1 to make all absorbers active volumes
65  // const string magfield = "1.5"; // if like float -> solenoidal field in T, if string use as fieldmap name (including path)
66  const string magfield = "/phenix/upgrades/decadal/fieldmaps/sPHENIX.2d.root"; // if like float -> solenoidal field in T, if string use as fieldmap name (including path)
67  const float magfield_rescale = 1.4/1.5; // scale the map to a 1.4 T field
68 
69  bool do_svtx_cell = do_svtx && true;
70  bool do_svtx_track = do_svtx_cell && true;
71  bool do_svtx_eval = do_svtx_track && false;
72 
73  bool do_bbc = true;
74  bool do_cemc_cell = do_cemc && true;
75  bool do_cemc_twr = do_cemc_cell && true;
76  bool do_cemc_cluster = do_cemc_twr && true;
77  bool do_cemc_eval = do_cemc_cluster && true;
78  bool do_hcalin_cell = do_hcalin && true;
79  bool do_hcalin_twr = do_hcalin_cell && true;
80  bool do_hcalin_cluster = do_hcalin_twr && true;
81  bool do_hcalin_eval = do_hcalin_cluster && true;
82  bool do_hcalout_cell = do_hcalout && true;
83  bool do_hcalout_twr = do_hcalout_cell && true;
84  bool do_hcalout_cluster = do_hcalout_twr && true;
85  bool do_hcalout_eval = do_hcalout_cluster && true;
86  bool do_global = true;
87  bool do_global_fastsim = true;
88  bool do_jet_reco = false;
89  bool do_jet_eval = false;
90  bool do_dst_compress = false;
91  bool do_DSTReader = false;
92 
93  G4Setup(absorberactive, magfield, TPythia6Decayer::kAll,
94  do_svtx, do_preshower, do_cemc, do_hcalin, do_magnet,
95  do_hcalout, do_pipe, magfield_rescale);
96  if (do_bbc) {
97  gROOT->LoadMacro("G4_Bbc.C");
98  BbcInit();
99  Bbc_Reco();
100  }
101  if (do_svtx_cell) Svtx_Cells();
102  if (do_cemc_cell) CEMC_Cells();
103  if (do_hcalin_cell) HCALInner_Cells();
104  if (do_hcalout_cell) HCALOuter_Cells();
105  if (do_cemc_twr) CEMC_Towers();
106  if (do_cemc_cluster) CEMC_Clusters();
107  if (do_hcalin_twr) HCALInner_Towers();
108  if (do_hcalin_cluster) HCALInner_Clusters();
109  if (do_hcalout_twr) HCALOuter_Towers();
110  if (do_hcalout_cluster) HCALOuter_Clusters();
111  if (do_dst_compress) ShowerCompress();
112  if (do_svtx_track) Svtx_Reco();
113  if (do_global) {
114  gROOT->LoadMacro("G4_Global.C");
115  Global_Reco();
116  } else if (do_global_fastsim) {
117  gROOT->LoadMacro("G4_Global.C");
118  Global_FastSim();
119  }
120  if (do_jet_reco) {
121  gROOT->LoadMacro("G4_Jets.C");
122  Jet_Reco();
123  }
124  if (do_svtx_eval) Svtx_Eval("g4svtx_eval.root");
125  if (do_cemc_eval) CEMC_Eval("g4cemc_eval.root");
126  if (do_hcalin_eval) HCALInner_Eval("g4hcalin_eval.root");
127  if (do_hcalout_eval) HCALOuter_Eval("g4hcalout_eval.root");
128  if (do_jet_eval) Jet_Eval("g4jet_eval.root");
129 
130 }
131 void Libraries() {
132  gSystem->Load("libfun4all.so");
133  gSystem->Load("libg4detectors.so");
134  gSystem->Load("libphhepmc.so");
135  gSystem->Load("libg4testbench.so");
136  gSystem->Load("libg4hough.so");
137  gSystem->Load("libg4calo.so");
138  gSystem->Load("libg4eval.so");
139  gSystem->Load("libTrackingPerformanceCheck.so");
140  gROOT->LoadMacro("G4Setup_sPHENIX.C");
141 }
142 
143 int Fun( const int nEvents = 1,
144  const int nFile = 0 ) {
145  if(nEvents < 0) return;
146  TStopwatch time;
147  time.Start();
148  Libraries();
149 
150  TString inputFile = Form("/gpfs/mnt/gpfs02/phenix/hhj/hhj1/frawley/tracking/stage1_jobs/in/hijing_%05d.txt.bz2",nFile);
151  //TString outputFile = Form("output/output_%05d.root",nFile);
152  TString outputFile = Form("output_%05d.root",nFile);
153 
155  se->Verbosity(0);
156 
157  RandomSeed();
158  ConfigureInput(inputFile);
160 
161  //ADDTASKS
163  revperf->SetLayerTPCBegins(7);
164  revperf->SetReconstructableTPCHits(30);
165  revperf->SetFairClustersContribution(20);
166  revperf->SetGoodTrackChi2NDF(2.0);
167  revperf->SetGoodTrackTPCClusters(20);
168  se->registerSubsystem(revperf);
169 
170  std::cout << "RUNNING..." << std::endl;
171  //se->Print();
172  se->run(nEvents);
173  se->dumpHistos(outputFile.Data());
174  se->End();
175  std::cout << "ALL DONE" << std::endl;
176  time.Stop();
177  time.Print();
178  delete se;
179  gSystem->Exit(0);
180 }