Class Reference for E1039 Core & Analysis Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Fun4PatternDB.C
Go to the documentation of this file.
1 
2 #include <iostream>
3 
4 using namespace std;
5 
7  const int nEvents = 1,
8  const int nmu = 1,
9  const double target_coil_pos_z = -300
10  )
11 {
12  const bool do_collimator = false;
13  const bool do_target = false;
14  const double target_l = 7.9; //cm
15  const double target_z = (7.9-target_l)/2.; //cm
16  const int use_g4steps = 1;
17 
18  const bool gen_gun = false;
19  const bool gen_pythia8 = false;
20  const bool gen_particle = true;
21  const bool gen_scan = false;
22 
23  gSystem->Load("libfun4all");
24  gSystem->Load("libg4detectors");
25  gSystem->Load("libg4testbench");
26  gSystem->Load("libg4eval");
27 
28  JobOptsSvc *jobopt_svc = JobOptsSvc::instance();
29  jobopt_svc->init("default.opts");
30 
31  GeomSvc *geom_svc = GeomSvc::instance();
32 
34  // Make the Server
37  se->Verbosity(100);
38 
39  // particle gun
40  if(gen_gun) {
41  PHG4ParticleGun *gun = new PHG4ParticleGun("GUN");
42  gun->set_name("mu+");
43  gun->set_vtx(0, 0, target_coil_pos_z);
44  gun->set_mom(3, 0, 40);
45  se->registerSubsystem(gun);
46  }
47 
48  if(gen_pythia8) {
49  gSystem->Load("libPHPythia8.so");
50 
51  PHPythia8 *pythia8 = new PHPythia8();
52  pythia8->set_config_file("phpythia8_DY.cfg");
53  pythia8->set_vertex_distribution_mean(0, 0, target_coil_pos_z, 0);
54  se->registerSubsystem(pythia8);
55 
56  pythia8->set_trigger_AND();
57 
58  PHPy8ParticleTrigger* trigger_mup = new PHPy8ParticleTrigger();
59  trigger_mup->AddParticles("-13");
60  //trigger_mup->SetPxHighLow(7, 0.5);
61  //trigger_mup->SetPyHighLow(6, -6);
62  trigger_mup->SetPzHighLow(120, 10);
63  pythia8->register_trigger(trigger_mup);
64 
65  PHPy8ParticleTrigger* trigger_mum = new PHPy8ParticleTrigger();
66  trigger_mum->AddParticles("13");
67  //trigger_mum->SetPxHighLow(-0.5, -7);
68  //trigger_mum->SetPyHighLow(6, -6);
69  trigger_mum->SetPzHighLow(120, 10);
70  pythia8->register_trigger(trigger_mum);
71 
72  HepMCNodeReader *hr = new HepMCNodeReader();
73  hr->set_particle_filter_on(true);
76  se->registerSubsystem(hr);
77  }
78 
79  if(gen_scan) {
80  PHG4PSScanGenerator *gen = new PHG4PSScanGenerator("MUP");
81  gen->add_particles("mu+", nmu); // mu+,e+,proton,pi+,Upsilon
85  gen->set_vertex_distribution_mean(0.0, 0.0, target_coil_pos_z);
86  gen->set_vertex_distribution_width(0.0, 0.0, 0.0);
88  gen->set_vertex_size_parameters(0.0, 0.0);
89 
90  //gen->set_pxpypz_range(1, 4, -1, 1, 30, 60);
91  //gen->set_pxpypz_range(1, 4, -1, 1, 50, 51);
92  gen->set_pxpypz_range(1, 1.6, 0.7, 1, 50, 51);
93  gen->set_px_step(0.3);
94  gen->set_py_step(0.3);
95  gen->set_pz_step(3);
96 
97  gen->Verbosity(0);
98  se->registerSubsystem(gen);
99  }
100 
101  if(gen_particle) {
103  gen2->add_particles("mu+", nmu); // mu+,e+,proton,pi+,Upsilon
107  gen2->set_vertex_distribution_mean(0.0, 0.0, target_coil_pos_z);
108  gen2->set_vertex_distribution_width(0.0, 0.0, 0.0);
110  gen2->set_vertex_size_parameters(0.0, 0.0);
111 
112  gen2->set_pxpypz_range(0,6, -6,6, 10,100);
113  //gen2->set_pxpypz_range(1,4, -1,1, 30,60);
114 
115  //gen2->set_vertex_distribution_mean(10.4, 19.8, 614);
116  //gen2->set_pxpypz_range(-1.28,-1.28, 0.79,0.79, 27.1,27.1);
117 
118  //gen2->set_vertex_distribution_mean(23.1, 8.5, 614);
119  //gen2->set_pxpypz_range(-0.68,-0.68, 0.36,0.36, 28.4,28.4);
120 
121  gen2->Verbosity(0);
122  se->registerSubsystem(gen2);
123  }
124 
125  // Fun4All G4 module
126  PHG4Reco *g4Reco = new PHG4Reco();
127  //g4Reco->G4Seed(123);
128  //g4Reco->set_field(5.);
129  g4Reco->set_field_map(
130  jobopt_svc->m_fMagFile+" "+
131  jobopt_svc->m_kMagFile+" "+
132  "1.0 1.0 0.0",
133  4);
134  // size of the world - every detector has to fit in here
135  g4Reco->SetWorldSizeX(1000);
136  g4Reco->SetWorldSizeY(1000);
137  g4Reco->SetWorldSizeZ(5000);
138  // shape of our world - it is a tube
139  g4Reco->SetWorldShape("G4BOX");
140  // this is what our world is filled with
141  g4Reco->SetWorldMaterial("G4_AIR"); //G4_Galactic, G4_AIR
142  // Geant4 Physics list to use
143  g4Reco->SetPhysicsList("FTFP_BERT");
144 
145  PHG4E1039InsensSubsystem* insens = new PHG4E1039InsensSubsystem("Insens");
146  g4Reco->registerSubsystem(insens);
147 
148  gROOT->LoadMacro("G4_Target.C");
149  SetupTarget(g4Reco, do_collimator, do_target, target_coil_pos_z, target_l, target_z, use_g4steps);
150 
151  gROOT->LoadMacro("G4_SensitiveDetectors.C");
152  SetupSensitiveDetectors(g4Reco);
153 
154  se->registerSubsystem(g4Reco);
155 
156  PHG4TruthSubsystem *truth = new PHG4TruthSubsystem();
157  g4Reco->registerSubsystem(truth);
158 
159  DPDigitizer *digitizer = new DPDigitizer("DPDigitizer", 0);
160  se->registerSubsystem(digitizer);
161 
162  gSystem->Load("libktracker.so");
163  KalmanFastTrackingWrapper *ktracker = new KalmanFastTrackingWrapper();
164  //ktracker->Verbosity(10);
165  //ktracker->set_DS_level(0);
166  se->registerSubsystem(ktracker);
167 
169  // Output
171 
172  // save a comprehensive evaluation file
173  PHG4DSTReader *reader = new PHG4DSTReader(
174  string("DSTReader.root"));
175  reader->set_save_particle(true);
176  reader->set_load_all_particle(false);
177  reader->set_load_active_particle(true);
178  reader->set_save_vertex(true);
179  //reader->AddNode("Coil");
180  //reader->AddNode("Target");
181  //reader->AddNode("Collimator");
182  reader->AddNode("C1X");
183  reader->AddNode("C2X");
184  se->registerSubsystem(reader);
185 
186  // input - we need a dummy to drive the event loop
188  se->registerInputManager(in);
189 
190  //Fun4AllDstOutputManager *out = new Fun4AllDstOutputManager("DSTOUT", "DST.root");
191  //se->registerOutputManager(out);
192 
193  // a quick evaluator to inspect on hit/particle/tower level
194 
195  if (nEvents > 0)
196  {
197  se->run(nEvents);
198 
199  //PHGeomUtility::ExportGeomtry(se->topNode(),"geom.root");
200 
201  // finish job - close and save output files
202  se->End();
203  se->PrintTimer();
204  std::cout << "All done" << std::endl;
205 
206  // cleanup - delete the server and exit
207  delete se;
208  gSystem->Exit(0);
209  }
210  return;
211 }
212 
213 PHG4ParticleGun *get_gun(const char *name = "PGUN")
214 {
216  PHG4ParticleGun *pgun = (PHG4ParticleGun *) se->getSubsysReco(name);
217  return pgun;
218 }
int registerInputManager(Fun4AllInputManager *InManager)
void set_vertex_distribution_function(FUNCTION x, FUNCTION y, FUNCTION z)
toss a new vertex according to a Uniform or Gaus distribution
virtual int End()
Runs G4 as a subsystem.
Definition: PHG4Reco.h:38
void add_particles(const std::string &name, const unsigned int count)
interface for adding particles by name
void insert_particle_filter_pid(const int a)
void SetupSensitiveDetectors(PHG4Reco *g4Reco, bool toggle_dphodo=true, bool toggle_dc1=false, std::string chamberGas="SQ_ArCO2", std::string hodoMat="SQ_Scintillator", const int verbosity=0)
void set_load_all_particle(bool b)
Definition: PHG4DSTReader.h:73
void set_trigger_AND()
Definition: PHPythia8.h:60
void AddParticles(std::string particles)
PHG4DSTReader save information from DST to an evaluator, which could include hit. particle...
Definition: PHG4DSTReader.h:39
void SetWorldMaterial(const std::string &s)
Definition: PHG4Reco.h:118
SQDigitizer DPDigitizer
void set_vertex_size_parameters(const double mean, const double width)
set the dimensions of the distribution of particles about the vertex
void add_particles(const std::string &name, const unsigned int count)
interface for adding particles by name
void SetWorldShape(const std::string &s)
Definition: PHG4Reco.h:117
void set_vertex_distribution_width(const double x, const double y, const double z)
set the width of the vertex distribution function about the mean
void set_particle_filter_on(const bool a)
static Fun4AllServer * instance()
Fun4AllServer * se
void PrintTimer(const std::string &name="")
void set_vertex_size_function(FUNCTION r)
set the distribution function of particles about the vertex
void set_vertex_distribution_function(FUNCTION x, FUNCTION y, FUNCTION z)
toss a new vertex according to a Uniform or Gaus distribution
int registerSubsystem(SubsysReco *subsystem, const std::string &topnodename="TOP")
void set_config_file(const char *cfg_file)
Definition: PHPythia8.h:46
void SetPzHighLow(double pzHigh, double pzLow)
int run(const int nevnts=0, const bool require_nevents=false)
run n events (0 means up to end of file)
void set_vertex_distribution_mean(const double x, const double y, const double z)
set the mean value of the vertex distribution
void set_vertex_distribution_width(const double x, const double y, const double z)
set the width of the vertex distribution function about the mean
void set_field_map(const std::string &fmap, const PHFieldConfig::FieldConfigTypes dim)
Definition: PHG4Reco.h:87
void set_vertex_distribution_mean(const double x, const double y, const double z, const double t)
set the mean value of the vertex distribution, use PHENIX units of cm, ns
Definition: PHPythia8.h:86
void set_save_vertex(bool b)
Switch for vertex.
Definition: PHG4DSTReader.h:94
void SetupTarget(PHG4Reco *g4Reco, const double target_coil_pos_z=-300, const double target_l=7.9, const double target_z=0., const int use_g4steps=1, const int register_hits=0)
Definition: G4_Target.C:10
void AddNode(const std::string &name)
Definition: PHG4DSTReader.h:59
void set_py_step(double pyStep)
int Fun4PatternDB(const int nEvents=1, const int nmu=1, const double target_coil_pos_z=-300)
Definition: Fun4PatternDB.C:6
void set_save_particle(bool b)
Switch for saving any particles at all.
Definition: PHG4DSTReader.h:87
void SetWorldSizeX(const double sx)
Definition: PHG4Reco.h:111
void set_vertex_distribution_mean(const double x, const double y, const double z)
set the mean value of the vertex distribution
void set_pxpypz_range(const double x_min, const double x_max, const double y_min, const double y_max, const double z_min, const double z_max)
void SetPhysicsList(const std::string &s)
Definition: PHG4Reco.h:119
void set_vertex_size_parameters(const double mean, const double width)
set the dimensions of the distribution of particles about the vertex
virtual void set_vtx(const double x, const double y, const double z)
void set_vertex_size_function(FUNCTION r)
set the distribution function of particles about the vertex
SubsysReco * getSubsysReco(const std::string &name)
virtual void Verbosity(const int ival)
Sets the verbosity of this module (0 by default=quiet).
Definition: Fun4AllBase.h:58
static GeomSvc * instance()
singlton instance
Definition: GeomSvc.cxx:211
void set_pz_step(double pzStep)
void set_load_active_particle(bool b)
load all particle that produced a saved hit
Definition: PHG4DSTReader.h:80
void register_trigger(PHPy8GenTrigger *theTrigger)
set event selection criteria
Definition: PHPythia8.C:303
virtual void set_name(const std::string &particle="proton")
virtual void set_mom(const double x, const double y, const double z)
void set_px_step(double pxStep)
PHG4ParticleGun * get_gun(const char *name="PGUN")
void registerSubsystem(PHG4Subsystem *subsystem)
register subsystem
Definition: PHG4Reco.h:65
void set_pxpypz_range(const double x_min, const double x_max, const double y_min, const double y_max, const double z_min, const double z_max)
void SetWorldSizeZ(const double sz)
Definition: PHG4Reco.h:113
void SetWorldSizeY(const double sy)
Definition: PHG4Reco.h:112