Class Reference for E1039 Core & Analysis Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Fun4DQ.C
Go to the documentation of this file.
1 #include <TSystem.h>
2 
3 #include <top/G4_Beamline.C>
4 #include <top/G4_Target.C>
5 #include <top/G4_InsensitiveVolumes.C>
6 #include <top/G4_SensitiveDetectors.C>
7 #include "G4_EMCal.C"
8 
9 R__LOAD_LIBRARY(libfun4all)
10 R__LOAD_LIBRARY(libPHPythia8)
11 R__LOAD_LIBRARY(libg4detectors)
12 R__LOAD_LIBRARY(libg4testbench)
13 R__LOAD_LIBRARY(libg4eval)
14 R__LOAD_LIBRARY(libg4dst)
15 R__LOAD_LIBRARY(libdptrigger)
16 R__LOAD_LIBRARY(libktracker)
17 R__LOAD_LIBRARY(libevt_filter)
18 
19 using namespace std;
20 
21 /*
22 This is an example script intended to demonstrate how to run SQReco in a minimalistic fashion, it is NOT
23 suitable for production use and users should develop their own reconstruction macro for their own analysis.
24 */
25 
26 int Fun4DQ(const int nevent = 10)
27 {
28  const bool dimuon = false;
29  const bool single = !dimuon;
30 
31  const bool do_collimator = true;
32  const bool do_target = true;
33  const bool do_shielding = true;
34  const bool do_fmag = true;
35  const bool do_kmag = true;
36  const bool do_absorber = true;
37 
38  const double collimator_pos_z = -602.36;
39  const double target_coil_pos_z = -300.;
40  const double target_l = 7.9; //cm
41  const double target_z = (7.9-target_l)/2.; //cm
42 
43  const double FMAGSTR = -1.054;
44  const double KMAGSTR = -0.951;
45 
47  rc->set_DoubleFlag("FMAGSTR", FMAGSTR);
48  rc->set_DoubleFlag("KMAGSTR", KMAGSTR);
49  rc->set_CharFlag("AlignmentMille", "support/align_mille.txt");
50  rc->set_CharFlag("fMagFile", "$E1039_RESOURCE/geometry/magnetic_fields/tab.Fmag");
51  rc->set_CharFlag("kMagFile", "$E1039_RESOURCE/geometry/magnetic_fields/tab.Kmag");
52  rc->Print();
53 
54  GeomSvc::UseDbSvc(true);
55  GeomSvc* geom_svc = GeomSvc::instance();
56 
58  se->Verbosity(0);
59 
60  if(dimuon) //change the pythia configuration file to change the dimuons generated
61  {
62  PHPythia8 *pythia8 = new PHPythia8();
63  //pythia8->Verbosity(99);
64  //pythia8->set_config_file("phpythia8_DY.cfg");
65  pythia8->set_config_file("support/phpythia8_DY.cfg");
66  pythia8->set_vertex_distribution_mean(0, 0, target_coil_pos_z, 0);
67  se->registerSubsystem(pythia8);
68 
69  pythia8->set_trigger_AND();
70 
71  PHPy8ParticleTrigger* trigger_mup = new PHPy8ParticleTrigger();
72  trigger_mup->AddParticles("-13");
73  trigger_mup->SetPzHighLow(120, 15);
74  pythia8->register_trigger(trigger_mup);
75 
76  PHPy8ParticleTrigger* trigger_mum = new PHPy8ParticleTrigger();
77  trigger_mum->AddParticles("13");
78  trigger_mum->SetPzHighLow(120, 15);
79  pythia8->register_trigger(trigger_mum);
80 
81  HepMCNodeReader* hr = new HepMCNodeReader();
82  hr->set_particle_filter_on(true);
85  se->registerSubsystem(hr);
86  }
87 
88  if(single) //change the hard-coded numbers to change the initial vertex/momentum distribution
89  {
91  genp->set_seed(123);
92  genp->add_particles("e+", 1); // mu+,e+,proton,pi+,Upsilon
94  genp->set_vertex_distribution_mean(0.0, 0.0, 550.);
95  genp->set_vertex_distribution_width(0.0, 0.0, 0.0);
97  genp->set_vertex_size_parameters(0.0, 0.0);
98  genp->set_pxpypz_range(-6., 6., -3. ,3., 10., 100.);
99  se->registerSubsystem(genp);
100  }
101 
102  // Fun4All G4 module
103  PHG4Reco* g4Reco = new PHG4Reco();
104  //PHG4Reco::G4Seed(123);
105  g4Reco->set_field_map(
106  rc->get_CharFlag("fMagFile")+" "+
107  rc->get_CharFlag("kMagFile")+" "+
108  Form("%f",FMAGSTR) + " " +
109  Form("%f",KMAGSTR) + " " +
110  "5.0",
112 
113  // size of the world - every detector has to fit in here
114  g4Reco->SetWorldSizeX(1000);
115  g4Reco->SetWorldSizeY(1000);
116  g4Reco->SetWorldSizeZ(5000);
117  g4Reco->SetWorldShape("G4BOX"); // shape of our world - it is a box
118  g4Reco->SetWorldMaterial("G4_AIR"); // // this is what our world is filled with G4_Galactic, G4_AIR
119  g4Reco->SetPhysicsList("FTFP_BERT"); // Geant4 Physics list to use
120 
121  SetupBeamline(g4Reco, do_collimator, collimator_pos_z);
122  SetupTarget(g4Reco, target_coil_pos_z, target_l, target_z, 1, 0);
123  SetupInsensitiveVolumes(g4Reco, do_shielding, do_fmag, do_kmag, do_absorber);
124  SetupSensitiveDetectors(g4Reco);
125  SetupEMCal(g4Reco, "EMCal", 0., 0., 1930.);
126  se->registerSubsystem(g4Reco);
127 
128  // save truth info to the Node Tree
129  PHG4TruthSubsystem* truth = new PHG4TruthSubsystem();
130  g4Reco->registerSubsystem(truth);
131 
132  // apply in-acceptance cut
133  // RequireParticlesInAcc* inacc = new RequireParticlesInAcc();
134  // if(dimuon)
135  // {
136  // inacc->SetNumParticlesPerEvent(2);
137  // }
138  // else if(single)
139  // {
140  // inacc->SetNumParticlesPerEvent(1);
141  // }
142  // se->registerSubsystem(inacc);
143 
144  // digitizer
145  SQDigitizer* digitizer = new SQDigitizer("Digitizer", 0);
146  //digitizer->Verbosity(99);
147  digitizer->registerEMCal("EMCal", 100);
148  se->registerSubsystem(digitizer);
149 
150  // trakcing module
151  // SQReco* reco = new SQReco();
152  // reco->Verbosity(0);
153  // //reco->set_geom_file_name("support/geom.root"); //not needed as it's created on the fly
154  // reco->set_enable_KF(true); //Kalman filter not needed for the track finding, disabling KF saves a lot of initialization time
155  // reco->setInputTy(SQReco::E1039); //options are SQReco::E906 and SQReco::E1039
156  // reco->setFitterTy(SQReco::KFREF); //not relavant for the track finding
157  // reco->set_evt_reducer_opt("none"); //if not provided, event reducer will be using JobOptsSvc to intialize; to turn off, set it to "none", for normal tracking, set to something like "aoc"
158  // reco->set_enable_eval(true); //set to true to generate evaluation file which includes final track candidates
159  // reco->set_eval_file_name("eval.root");
160  // reco->set_enable_eval_dst(false); //set to true to include final track cnadidates in the DST tree
161  // //reco->add_eval_list(4); //include back partial tracks in eval tree for debuging
162  // //reco->add_eval_list(3); //include station-3+/- in eval tree for debuging
163  // //reco->add_eval_list(2); //include station-2 tracks in eval tree for debuging
164  // se->registerSubsystem(reco);
165 
166  //Vertexing is not tested and probably does not work yet
167  // VertexFit* vertexing = new VertexFit();
168  // se->registerSubsystem(vertexing);
169 
170  // input - we need a dummy to drive the event loop
172  se->registerInputManager(in);
173 
175  // Output
177  // DST output manager, tunred off to save disk by default
178  Fun4AllDstOutputManager* out = new Fun4AllDstOutputManager("DSTOUT", "DST.root");
179  se->registerOutputManager(out);
180 
181  se->run(nevent);
182  PHGeomUtility::ExportGeomtry(se->topNode(), "geom.root");
183 
184  // finish job - close and save output files
185  se->End();
186  se->PrintTimer();
187  std::cout << "All done" << std::endl;
188 
189  // cleanup - delete the server and exit
190  delete se;
191  gSystem->Exit(0);
192 
193  return 0;
194 }
int registerInputManager(Fun4AllInputManager *InManager)
virtual int End()
virtual void set_DoubleFlag(const std::string &name, const double flag)
Definition: PHFlag.cc:77
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_trigger_AND()
Definition: PHPythia8.h:60
void AddParticles(std::string particles)
void SetWorldMaterial(const std::string &s)
Definition: PHG4Reco.h:118
void add_particles(const std::string &name, const unsigned int count)
interface for adding particles by name
void Print() const
print all the parameters
Definition: recoConsts.cc:185
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.
static recoConsts * instance()
Definition: recoConsts.cc:7
void SetupEMCal(PHG4Reco *g4Reco, const std::string name="EMCal", const double place_x=0., const double place_y=0., const double place_z=0., const int n_super_h=6, const int n_super_v=3, const int verbose=0)
Definition: G4_EMCal.C:8
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")
static bool UseDbSvc()
Definition: GeomSvc.h:304
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
int registerOutputManager(Fun4AllOutputManager *manager)
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 SetupInsensitiveVolumes(PHG4Reco *g4Reco, const bool toggle_shielding=true, const bool toggle_fmag=true, const bool toggle_kmag=true, const bool toggle_absorber=true, const int enable_fmag_filter=0, const double filter_max_slope=0.25, const double filter_min_energy=5.)
int Fun4DQ(const int nevent=10)
Definition: Fun4DQ.C:26
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 registerEMCal(std::string ecalName, int ecalID=100)
Register additional EMCal detector for digitizing.
Definition: SQDigitizer.h:52
PHCompositeNode * topNode() const
Definition: Fun4AllServer.h:59
virtual const std::string get_CharFlag(const std::string &flag) const
Definition: PHFlag.cc:13
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
void set_vertex_size_function(FUNCTION r)
set the distribution function of particles about the vertex
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 register_trigger(PHPy8GenTrigger *theTrigger)
set event selection criteria
Definition: PHPythia8.C:303
void SetupBeamline(PHG4Reco *g4Reco, const bool toggle_collimator=true, const double collimator_pos_z=-300, const int register_hits=0)
Definition: G4_Beamline.C:8
virtual void set_CharFlag(const std::string &name, const std::string &flag)
overide the virtual function to expand the environmental variables
Definition: recoConsts.cc:21
void set_seed(const unsigned int iseed)
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