Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Fun4AllPythia.C
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file Fun4AllPythia.C
5 #include <fun4all/Fun4AllUtils.h>
6 
7 
8 #include <phool/PHRandomSeed.h>
9 #include <phool/recoConsts.h>
10 
11 #include <stdlib.h>
12 
13 #include <g4main/PHG4Reco.h>
15 
16 #include <GlobalVariables.C>
17 
18 #include <G4_Input.C>
19 #include <phpythia8/PHPy8JetTrigger.h>
20 
21 #include <jethistogrammer/jetHistogrammer.h>
22 
23 #include <g4jets/FastJetAlgo.h>
24 #include <g4jets/JetReco.h>
25 #include <g4jets/TruthJetInput.h>
26 #include <time.h>
27 
28 R__LOAD_LIBRARY(libjetHistogrammer.so)
29 
30 void Fun4AllPythia(int nEvents = 1,
31  const string &Jet_Trigger = "Jet10", // or "PhotonJet"
32  int doCrossSection = 1,
33  const string &outname = "out"
34 )
35 {
36 
37  clock_t tStart = clock();
38 
39 
41  se -> Verbosity(0);
42 
43  Input::PYTHIA8 = true;
44  Input::VERBOSITY = 0;
45 
46 
47  if (Jet_Trigger == "PhotonJet")
48  {
49  PYTHIA8::config_file = "phpythia8_JS_GJ_MDC2.cfg";
50  }
51  else if (Jet_Trigger == "Jet10")
52  {
53  PYTHIA8::config_file = "phpythia8_15GeV_JS_MDC2.cfg";
54  }
55  else if (Jet_Trigger == "Jet30")
56  {
57  PYTHIA8::config_file = "phpythia8_30GeV_JS_MDC2.cfg";
58  }
59  else if(Jet_Trigger == "MB")
60  {
61  PYTHIA8::config_file = "phpythia8_minBias_MDC2.cfg";
62  }
63  else
64  {
65  std::cout << "Invalid jet trigger " << Jet_Trigger << std::endl;
66  gSystem->Exit(1);
67  }
68 
69  InputInit();
70 
71  if(Jet_Trigger != "MB")
72  {
73  PHPy8JetTrigger *p8_js_signal_trigger = new PHPy8JetTrigger();
74  p8_js_signal_trigger->SetEtaHighLow(1.5,-1.5); // Set eta acceptance for particles into the jet between +/- 1.5
75  p8_js_signal_trigger->SetJetR(0.4); //Set the radius for the trigger jet
76  p8_js_signal_trigger->Verbosity(0);;
77  if (Jet_Trigger == "Jet10")
78  {
79  p8_js_signal_trigger->SetMinJetPt(10); // require a 10 GeV minimum pT jet in the event
80  }
81  else if (Jet_Trigger == "Jet30")
82  {
83  p8_js_signal_trigger->SetMinJetPt(30); // require a 30 GeV minimum pT jet in the event
84  }
85  else if (Jet_Trigger == "PhotonJet")
86  {
87  delete p8_js_signal_trigger;
88  p8_js_signal_trigger = nullptr;
89  cout << "no cut for PhotonJet" << endl;
90  }
91  else
92  {
93  cout << "invalid jet trigger: " << Jet_Trigger << endl;
94  gSystem->Exit(1);
95  }
96 
97  if (p8_js_signal_trigger)
98  {
99  INPUTGENERATOR::Pythia8->register_trigger(p8_js_signal_trigger);
101  }
102  }
104  INPUTGENERATOR::Pythia8 -> Verbosity(doCrossSection*10);
105 
106  InputRegister();
107  InputManagers();
108  PHG4Reco *reco = new PHG4Reco();
109  reco -> set_field(0);
110  reco -> SetWorldMaterial("G4_Galactic");
111  reco -> SetWorldSizeX(100);
112  reco -> SetWorldSizeY(100);
113  reco -> SetWorldSizeZ(100);
114  reco -> save_DST_geometry(false);
115 
116  PHG4TruthSubsystem *truth = new PHG4TruthSubsystem();
117  reco -> registerSubsystem(truth);
118  se -> registerSubsystem(reco);
119 
120  JetReco *truthJetReco = new JetReco();
121  TruthJetInput *jetInput = new TruthJetInput(Jet::PARTICLE);
122  truthJetReco -> add_input(jetInput);
123  truthJetReco->add_algo(new FastJetAlgo(Jet::ANTIKT, 0.4), "AntiKt_Truth_r04");
124  truthJetReco->set_algo_node("ANTIKT");
125  truthJetReco->set_input_node("TRUTH");
126  truthJetReco->Verbosity(0);
127 
128  se -> registerSubsystem(truthJetReco);
129 
130  string out = outname + Jet_Trigger + ".root";
131  jetHistogrammer *jetHistos = new jetHistogrammer("jetHistogrammer",out.c_str());
132  se -> registerSubsystem(jetHistos);
133 
134 
135  se -> run(nEvents);
136 
137  se -> End();
138  std::cout << "All done" << std::endl;
139 
140 
141  delete se;
142  std::cout << "Total runtime: " << double(clock() - tStart) / (double)CLOCKS_PER_SEC << std::endl;;
143 
144  gSystem -> Exit(0);
145  return 0;
146 }
147 
148