Class Reference for E1039 Core & Analysis Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
G4_Target.C
Go to the documentation of this file.
1 #pragma once
2 #if ROOT_VERSION_CODE >= ROOT_VERSION(6,00,0)
3 #include <g4detectors/PHG4E1039InsensSubsystem.h>
8 class SubsysReco;
9 R__LOAD_LIBRARY(libg4detectors)
10 #endif
11 
12 using namespace std;
13 
15  PHG4Reco *g4Reco,
16  const bool do_collimator = true,
17  const bool do_target = true,
18  const double target_coil_pos_z = -130,
19  const double target_l = 7.9,
20  const double target_z = 0.,
21  const int use_g4steps = 1
22 ) {
23 
24  const double collimator_pos_z = target_coil_pos_z - 302.36;
25 
26  //gSystem->Load("libfun4all.so");
27  //gSystem->Load("libg4detectors");
28  //gSystem->Load("libg4testbench");
29 
30  //Fun4AllServer *se = Fun4AllServer::instance();
31  //PHG4Reco *g4Reco = (PHG4Reco *) se->getSubsysReco("PHG4RECO");
32 
33  if(do_collimator) {
34  PHG4CollimatorSubsystem* collimator = new PHG4CollimatorSubsystem("Collimator",0);
35  collimator->SuperDetector("Collimator");
36  collimator->set_double_param("place_z", collimator_pos_z);//-302.36 cm
37  collimator->set_double_param("size_z",121.92);
38  collimator->SetActive(1);
39  g4Reco->registerSubsystem(collimator);
40  }
41 
42  if(do_target) {
43  PHG4TargetCoilSubsystem* coil_0 = new PHG4TargetCoilSubsystem("Coil", 0);
44  coil_0->SuperDetector("Coil");
45  coil_0->set_double_param("rot_x", 90.);
46  coil_0->set_double_param("rot_y", 0.);
47  coil_0->set_double_param("rot_z", 0.);
48  coil_0->set_double_param("place_x", 0.);
49  coil_0->set_double_param("place_y", (22.7+4.)/2);
50  coil_0->set_double_param("place_z", target_coil_pos_z);
51  coil_0->set_int_param("use_g4steps", use_g4steps);
52  coil_0->SetActive(1); // it is an active volume - save G4Hits
53  g4Reco->registerSubsystem(coil_0);
54 
55  PHG4TargetCoilSubsystem* coil_1 = new PHG4TargetCoilSubsystem("Coil", 1);
56  coil_1->SuperDetector("Coil");
57  coil_1->set_double_param("rot_x", -90.);
58  coil_1->set_double_param("rot_y", 0.);
59  coil_1->set_double_param("rot_z", 0.);
60  coil_1->set_double_param("place_x", 0.);
61  coil_1->set_double_param("place_y", -(22.7+4.)/2);
62  coil_1->set_double_param("place_z", target_coil_pos_z);
63  coil_1->set_int_param("use_g4steps", use_g4steps);
64  coil_1->SetActive(1); // it is an active volume - save G4Hits
65  g4Reco->registerSubsystem(coil_1);
66 
67  PHG4CylinderSubsystem* target = new PHG4CylinderSubsystem("Target", 0);
68  target->SuperDetector("Target");
69  target->set_double_param("length", target_l);
70  target->set_double_param("rot_x", 0.);
71  target->set_double_param("rot_y", 0.);
72  target->set_double_param("rot_z", 0.);
73  target->set_double_param("place_x", 0.);
74  target->set_double_param("place_y", 0.);
75  target->set_double_param("place_z", target_coil_pos_z + target_z);
76  target->set_double_param("radius", 0.);
77  target->set_double_param("thickness", (2.)/2);
78  target->set_string_param("material", "Target"); // material of target
79  target->set_int_param("lengthviarapidity", 0);
80  target->set_int_param("use_g4steps", use_g4steps);
81  target->SetActive(1); // it is an active volume - save G4Hits
82  g4Reco->registerSubsystem(target);
83  }
84 
85  return;
86 }
87 
Runs G4 as a subsystem.
Definition: PHG4Reco.h:38
void set_int_param(const std::string &name, const int ival)
void SuperDetector(const std::string &name)
void set_double_param(const std::string &name, const double dval)
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 set_string_param(const std::string &name, const std::string &sval)
void SetActive(const int i=1)
void registerSubsystem(PHG4Subsystem *subsystem)
register subsystem
Definition: PHG4Reco.h:65