Class Reference for E1039 Core & Analysis Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Fun4E1039Shielding.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 double hodo_gap = 0.,
9  const int do_e1039_shielding = 1,
10  const double target_coil_pos_z = -300
11  )
12 {
13  const bool do_collimator = true;
14  const bool do_target = true;
15  const double target_l = 7.9; //cm
16  const double target_z = (7.9-target_l)/2.; //cm
17  const int use_g4steps = 1;
18 
19  const bool gen_gun = false;
20  const bool gen_pythia8 = true;
21  const bool gen_test = false;
22  const bool gen_particle = false;
23 
24  gSystem->Load("libfun4all");
25  gSystem->Load("libg4detectors");
26  gSystem->Load("libg4testbench");
27  gSystem->Load("libg4eval");
28 
29  JobOptsSvc *jobopt_svc = JobOptsSvc::instance();
30  jobopt_svc->init("default.opts");
31 
32  GeomSvc *geom_svc = GeomSvc::instance();
33  geom_svc->setDetectorY0("H1T", 35.+hodo_gap/2.); //orig. ~ 35 cm
34  geom_svc->setDetectorY0("H1B", -35.-hodo_gap/2.);//orig. ~ -35 cm
35 
37  // Make the Server
40  se->Verbosity(0);
41 
42  // particle gun
43  if(gen_gun) {
44  PHG4ParticleGun *gun_beam = new PHG4ParticleGun("GUN_beam");
45  gun_beam->set_name("proton");//proton
46  gun_beam->set_vtx(0, 0, -400); //-363.32 cm
47  gun_beam->set_mom(0, 0, 120);
48  TF2 *beam_profile = new TF2("beam_profile",
49  //"(((x**2+y**2)<=0.81)*exp(-(x**2+y**2)/0.18))+(((x**2+y**2)>0.81&&(x**2+y**2)<=25&&abs(y)<1.)*0.9*exp(-4.5)/(sqrt(x**2+y**2)))",
50  "(((x**2+y**2)<=0.81)*exp(-(x**2+y**2)/0.18))+(((x**2+y**2)>0.81&&(x**2+y**2)<=25)*0.9*exp(-4.5)/(sqrt(x**2+y**2)))",
51  -5,5,-5,5);
52  //gun_beam->set_beam_profile(beam_profile);
53  //se->registerSubsystem(gun_beam);
54  }
55 
56  if(gen_pythia8) {
57  gSystem->Load("libPHPythia8.so");
58 
59  PHPythia8 *pythia8 = new PHPythia8();
60  pythia8->set_config_file("phpythia8_DY.cfg");
61  pythia8->set_vertex_distribution_mean(0, 0, target_coil_pos_z, 0);
62  se->registerSubsystem(pythia8);
63 
64  pythia8->set_trigger_AND();
65 
66  PHPy8ParticleTrigger* trigger_mup = new PHPy8ParticleTrigger();
67  trigger_mup->AddParticles("-13");
68  //trigger_mup->SetPxHighLow(7, 0.5);
69  //trigger_mup->SetPyHighLow(6, -6);
70  trigger_mup->SetPzHighLow(120, 10);
71  pythia8->register_trigger(trigger_mup);
72 
73  PHPy8ParticleTrigger* trigger_mum = new PHPy8ParticleTrigger();
74  trigger_mum->AddParticles("13");
75  //trigger_mum->SetPxHighLow(-0.5, -7);
76  //trigger_mum->SetPyHighLow(6, -6);
77  trigger_mum->SetPzHighLow(120, 10);
78  pythia8->register_trigger(trigger_mum);
79 
80  HepMCNodeReader *hr = new HepMCNodeReader();
81  hr->set_particle_filter_on(true);
84  se->registerSubsystem(hr);
85  }
86 
87  if(gen_test) {
88  PHG4ParticleGun *gun_mup = new PHG4ParticleGun("GUN_mup");
89  gun_mup->set_name("mu+");
90  //gun_mup->set_vtx(30, 0, 500);
91  //gun_mup->set_mom(0, 0, 30.);
92  gun_mup->set_vtx(0., 0., target_coil_pos_z);
93  gun_mup->set_mom(3., 0.2, 40.);
94  se->registerSubsystem(gun_mup);
95 
96  PHG4ParticleGun *gun_mum = new PHG4ParticleGun("GUN_mum");
97  gun_mum->set_name("mu-");
98  //gun_mum->set_vtx(-30, 0, 500);
99  //gun_mum->set_mom(0., 0., 30.);
100  gun_mum->set_vtx(0., 0., target_coil_pos_z);
101  gun_mum->set_mom(-3., -0.2, 40.);
102  se->registerSubsystem(gun_mum);
103  }
104 
105  if(gen_particle) {
106  // toss low multiplicity dummy events
108  gen->add_particles("mu+", 1); // mu+,e+,proton,pi+,Upsilon
109 
113  gen->set_vertex_distribution_mean(0.0, 0.0, target_coil_pos_z);
114  gen->set_vertex_distribution_width(0.0, 0.0, 0.0);
115 
117  gen->set_vertex_size_parameters(0.0, 0.0);
118 
119  gen->set_eta_range(2, 4);
120  gen->set_phi_range(-1.0 * TMath::Pi(), 1.0 * TMath::Pi());
121  //gen->set_pt_range(1.0, 3.0);
122  //gen->set_p_range(20, 25);
123 
124  //gen->set_pxpypz_range(2, 3.3, -0.5, 0.5, 20, 21);
125  //gen->set_pxpypz_range(1, 4, -1, 1, 15, 60);
126  gen->set_pxpypz_range(1, 4, -1, 1, 30, 60);
127 
128  //gen->Embed(2);
129  gen->Verbosity(0);
130 
131  se->registerSubsystem(gen);
132  }
133 
134  // Fun4All G4 module
135  PHG4Reco *g4Reco = new PHG4Reco();
136  g4Reco->Verbosity(1);
137  //g4Reco->G4Seed(123);
138  //g4Reco->set_field(5.);
139  g4Reco->set_field_map(
140  jobopt_svc->m_fMagFile+" "+
141  jobopt_svc->m_kMagFile+" "+
142  "1.0 1.0 5.0",
143  4);
144  // size of the world - every detector has to fit in here
145  g4Reco->SetWorldSizeX(1000);
146  g4Reco->SetWorldSizeY(1000);
147  g4Reco->SetWorldSizeZ(5000);
148  // shape of our world - it is a tube
149  g4Reco->SetWorldShape("G4BOX");
150  // this is what our world is filled with
151  g4Reco->SetWorldMaterial("G4_AIR"); //G4_Galactic, G4_AIR
152  // Geant4 Physics list to use
153  g4Reco->SetPhysicsList("FTFP_BERT");
154 
155  se->registerSubsystem(g4Reco);
156 
157  if(do_e1039_shielding == 1) {
158  const double inch = 2.54;
159 
160  PHG4SquareTubeSubsystem* shielding = NULL;
161 
162  shielding = new PHG4SquareTubeSubsystem("Shielding1",0);
163  shielding->set_string_param("hole_type","circle");
164  shielding->set_double_param("place_x",0);
165  shielding->set_double_param("place_y",0);
166  shielding->set_double_param("place_z", (-18*inch/2.-(2.15+11.38+ 36)*inch)); // I have added all the z length and put the z into the center of mass of the block.
167  shielding->set_double_param("size_x",250*inch); //the info is not given?
168  shielding->set_double_param("size_y",200*inch); //the info is not given?
169  shielding->set_double_param("size_z",(18-0.001)*inch);
170  shielding->set_double_param("inner_diameter",4*inch);
171  shielding->set_string_param("material","G4_CONCRETE");
172  g4Reco->registerSubsystem(shielding);
173 
174  shielding = new PHG4SquareTubeSubsystem("Shielding2",0);
175  shielding->set_string_param("hole_type","circle");
176  shielding->set_double_param("place_x",0);
177  shielding->set_double_param("place_y",0);
178  shielding->set_double_param("place_z",(-36*inch/2.-(2.15+11.38)*inch)); // I have added all the z length and put the z into the center of mass of the block.
179  shielding->set_double_param("size_x",250*inch); //the info is not given?
180  shielding->set_double_param("size_y",200*inch); //the info is not given?
181  shielding->set_double_param("size_z",36*inch);
182  shielding->set_double_param("inner_diameter",6*inch);
183  shielding->set_string_param("material","G4_CONCRETE");
184  g4Reco->registerSubsystem(shielding);
185 
186  shielding = new PHG4SquareTubeSubsystem("Shielding3",0);
187  shielding->set_double_param("place_x",0);
188  shielding->set_double_param("place_y",0);
189  shielding->set_double_param("place_z",-11.38*inch/2.);
190  shielding->set_double_param("size_x",50*inch);
191  shielding->set_double_param("size_y",50*inch);
192  shielding->set_double_param("size_z",(11.38-0.001)*inch);
193  shielding->set_double_param("inner_size_x",6*inch);
194  shielding->set_double_param("inner_size_y",6*inch);
195  shielding->set_string_param("material","G4_CONCRETE");
196  g4Reco->registerSubsystem(shielding);
197  }
198 
199  PHG4E1039InsensSubsystem* insens = new PHG4E1039InsensSubsystem("Insens");
200  g4Reco->registerSubsystem(insens);
201 
202  gROOT->LoadMacro("G4_Target.C");
203  SetupTarget(g4Reco, do_collimator, do_target, target_coil_pos_z, target_l, target_z, use_g4steps);
204 
205  gROOT->LoadMacro("G4_SensitiveDetectors.C");
206  SetupSensitiveDetectors(g4Reco);
207 
208  PHG4TruthSubsystem *truth = new PHG4TruthSubsystem();
209  g4Reco->registerSubsystem(truth);
210 
211  DPDigitizer *digitizer = new DPDigitizer("DPDigitizer", 0);
212  se->registerSubsystem(digitizer);
213 
214  gSystem->Load("libktracker.so");
215  KalmanFastTrackingWrapper *ktracker = new KalmanFastTrackingWrapper();
216  ktracker->set_geom_file_name("geom.root");
217  ktracker->Verbosity(10);
218  se->registerSubsystem(ktracker);
219 
221  // Output
223 
224  // save a comprehensive evaluation file
226  string("DSTReader.root"));
227  ana->set_save_particle(true);
228  ana->set_load_all_particle(false);
229  ana->set_load_active_particle(true);
230  ana->set_save_vertex(true);
231  //ana->AddNode("Coil");
232  //ana->AddNode("Target");
233  //ana->AddNode("Collimator");
234  //ana->AddNode("C1X");
235  //ana->AddNode("C2X");
236  se->registerSubsystem(ana);
237 
238  // input - we need a dummy to drive the event loop
240  se->registerInputManager(in);
241 
242  //Fun4AllDstOutputManager *out = new Fun4AllDstOutputManager("DSTOUT", "DST.root");
243  //se->registerOutputManager(out);
244 
245  // a quick evaluator to inspect on hit/particle/tower level
246 
247  if (nEvents > 0)
248  {
249  se->run(nEvents);
250 
251  PHGeomUtility::ExportGeomtry(se->topNode(),"geom.root");
252 
253  // finish job - close and save output files
254  se->End();
255  se->PrintTimer();
256  std::cout << "All done" << std::endl;
257 
258  // cleanup - delete the server and exit
259  delete se;
260  gSystem->Exit(0);
261  }
262  return;
263 }
264 
265 PHG4ParticleGun *get_gun(const char *name = "PGUN")
266 {
268  PHG4ParticleGun *pgun = (PHG4ParticleGun *) se->getSubsysReco(name);
269  return pgun;
270 }
int registerInputManager(Fun4AllInputManager *InManager)
int Fun4E1039Shielding(const int nEvents=1, const double hodo_gap=0., const int do_e1039_shielding=1, const double target_coil_pos_z=-300)
virtual int End()
Runs G4 as a subsystem.
Definition: PHG4Reco.h:38
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 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_particle_filter_on(const bool a)
static Fun4AllServer * instance()
Fun4AllServer * se
void PrintTimer(const std::string &name="")
static void ExportGeomtry(PHCompositeNode *topNode, const std::string &geometry_file)
DST node -&gt; TGeoManager -&gt; export files, like gdml, .root or .C formats.
void set_double_param(const std::string &name, const double dval)
#define NULL
Definition: Pdb.h:9
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
PHCompositeNode * topNode() const
Definition: Fun4AllServer.h:59
void set_save_particle(bool b)
Switch for saving any particles at all.
Definition: PHG4DSTReader.h:87
void ana()
Definition: ana.C:291
void set_string_param(const std::string &name, const std::string &sval)
void SetWorldSizeX(const double sx)
Definition: PHG4Reco.h:111
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_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
void set_eta_range(const double eta_min, const double eta_max)
range of randomized eta values
virtual void set_name(const std::string &particle="proton")
virtual void set_mom(const double x, const double y, const double z)
void setDetectorY0(const std::string detectorName, const double val)
Definition: GeomSvc.h:157
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 set_phi_range(const double phi_min, const double phi_max)
range of randomized phi values
void SetWorldSizeZ(const double sz)
Definition: PHG4Reco.h:113
void SetWorldSizeY(const double sy)
Definition: PHG4Reco.h:112