Class Reference for E1039 Core & Analysis Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Fun4Sim_TrkQA.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 
8 R__LOAD_LIBRARY(libfun4all)
9 R__LOAD_LIBRARY(libPHPythia8)
10 R__LOAD_LIBRARY(libg4detectors)
11 R__LOAD_LIBRARY(libg4testbench)
12 R__LOAD_LIBRARY(libg4eval)
13 R__LOAD_LIBRARY(libg4dst)
14 R__LOAD_LIBRARY(libdptrigger)
15 R__LOAD_LIBRARY(libktracker)
16 R__LOAD_LIBRARY(libevt_filter)
17 R__LOAD_LIBRARY(libana_trkqa)
18 
19 using namespace std;
20 
21 /*
22 Macro to run AnaTrkQA module (still in development)
23 */
24 
25 int Fun4Sim_TrkQA(const int nevent = 10)
26 {
27 
28 
29  const bool single_gun = true;
30  const bool dimuon_gun =false;
31 
32  const bool do_collimator = true;
33  const bool do_target = true;
34  const bool do_shielding = true;
35  const bool do_fmag = true;
36  const bool do_kmag = true;
37  const bool do_absorber = true;
38 
39  const double collimator_pos_z = -602.36;
40  const double target_coil_pos_z = -300.;
41  const double target_l = 7.9; //cm
42  const double target_z = (7.9-target_l)/2.; //cm
43 
44  const double FMAGSTR = -1.054;
45  const double KMAGSTR = -0.951;
46 
48  rc->set_DoubleFlag("FMAGSTR", FMAGSTR);
49  rc->set_DoubleFlag("KMAGSTR", KMAGSTR);
50  //rc->set_IntFlag("RANDOMSEED", seed);
51  rc->set_DoubleFlag("SIGX_BEAM", 2.);
52  rc->set_DoubleFlag("SIGY_BEAM", 2.);
53 
54  rc->Print();
55 
56  GeomSvc::UseDbSvc(true);
57  GeomSvc* geom_svc = GeomSvc::instance();
58  geom_svc->printTable();
59 
61  se->Verbosity(0);
62 
63 
64 
65  if(single_gun) //change the hard-coded numbers to change the initial vertex/momentum distribution
66  {
68  genp->add_particles("mu+", 1); // mu+,mu-,e+,proton,pi+,Upsilon
70  genp->set_vertex_distribution_mean(0.0, 0.0, target_coil_pos_z);
71  genp->set_vertex_distribution_width(0.0, 0.0, 0.0);
73  genp->set_vertex_size_parameters(0.0, 0.0);
74  genp->set_pxpypz_range(-6., 6., -3. ,3., 25., 100.);
75  se->registerSubsystem(genp);
76  }
77 
78 // multi particle gun
79  if(dimuon_gun) {
81  //genp->set_seed(123);
82  genp->add_particles("mu+", 1); // mu+,e+,proton,pi+,Upsilon
86  genp->set_vertex_distribution_mean(0.0, 0.0, target_coil_pos_z);
87  genp->set_vertex_distribution_width(0.0, 0.0, 0.0);
89  genp->set_vertex_size_parameters(0.0, 0.0);
90 
91  if(FMAGSTR>0)
92  //genp->set_pxpypz_range(0,6, -6,6, 10,100);
93  genp->set_pxpypz_range(-3,6, -3,3, 10,100);
94  else
95  //genp->set_pxpypz_range(-6,0, -6,6, 10,100);
96  genp->set_pxpypz_range(-6,3, -3,3, 10,100);
97 
98 
99  genp->Verbosity(0);
100  se->registerSubsystem(genp);
101 
103  //genm->set_seed(123);
104  genm->add_particles("mu-", 1); // mu+,e+,proton,pi+,Upsilon
108  genm->set_vertex_distribution_mean(0.0, 0.0, target_coil_pos_z);
109  genm->set_vertex_distribution_width(0.0, 0.0, 0.0);
111  genm->set_vertex_size_parameters(0.0, 0.0);
112 
113  if(FMAGSTR>0)
114  //genm->set_pxpypz_range(-6,0, -6,6, 10,100);
115  genm->set_pxpypz_range(-6,3, -3,3, 10,100);
116  else
117  //genm->set_pxpypz_range(0,6, -6,6, 10,100);
118  genm->set_pxpypz_range(-3,6, -3,3, 10,100);
119 
120  genm->Verbosity(0);
121  se->registerSubsystem(genm);
122  }
123 
124 
125 
126 
127 
128 
129  // Fun4All G4 module
130  PHG4Reco* g4Reco = new PHG4Reco();
131  //PHG4Reco::G4Seed(123);
132  g4Reco->set_field_map(
133  rc->get_CharFlag("fMagFile")+" "+
134  rc->get_CharFlag("kMagFile")+" "+
135  Form("%f",FMAGSTR) + " " +
136  Form("%f",KMAGSTR) + " " +
137  "5.0",
139 
140  // size of the world - every detector has to fit in here
141  g4Reco->SetWorldSizeX(1000);
142  g4Reco->SetWorldSizeY(1000);
143  g4Reco->SetWorldSizeZ(5000);
144  // shape of our world - it is a box
145  g4Reco->SetWorldShape("G4BOX");
146  // this is what our world is filled with
147  g4Reco->SetWorldMaterial("G4_AIR"); //G4_Galactic, G4_AIR
148  // Geant4 Physics list to use
149  g4Reco->SetPhysicsList("FTFP_BERT");
150 
151  SetupBeamline(g4Reco, do_collimator, collimator_pos_z);
152  SetupTarget(g4Reco, target_coil_pos_z, target_l, target_z, 1, 0);
153  SetupInsensitiveVolumes(g4Reco, do_shielding, do_fmag, do_kmag, do_absorber);
154  SetupSensitiveDetectors(g4Reco);
155  se->registerSubsystem(g4Reco);
156 
157  // save truth info to the Node Tree
158  PHG4TruthSubsystem* truth = new PHG4TruthSubsystem();
159  g4Reco->registerSubsystem(truth);
160 
161  /* // apply in-acceptance cut
162  RequireParticlesInAcc* inacc = new RequireParticlesInAcc();
163  if(dimuon)
164  {
165  inacc->SetNumParticlesPerEvent(2);
166  se->registerSubsystem(inacc);
167  }
168  else if(single)
169  {
170  inacc->SetNumParticlesPerEvent(1);
171  se->registerSubsystem(inacc);
172  }
173  */
174  // digitizer
175  SQDigitizer* digitizer = new SQDigitizer("Digitizer", 0);
176  //digitizer->Verbosity(99);
177  se->registerSubsystem(digitizer);
178 
179  // trakcing module
180  SQReco* reco = new SQReco();
181  reco->Verbosity(0);
182  //reco->set_legacy_rec_container(legacy_rec_container);
183  //reco->set_geom_file_name("support/geom.root"); //not needed as it's created on the fly
184  reco->set_enable_KF(true); //Kalman filter not needed for the track finding, disabling KF saves a lot of initialization time
185  reco->setInputTy(SQReco::E1039); //options are SQReco::E906 and SQReco::E1039
186  reco->setFitterTy(SQReco::KFREF); //not relavant for the track finding
187  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"
188  reco->set_enable_eval(true); //set to true to generate evaluation file which includes final track candidates
189  reco->set_eval_file_name("eval.root");
190  reco->set_enable_eval_dst(false); //set to true to include final track cnadidates in the DST tree
191  //if(cosmic) reco->add_eval_list(3); //output of cosmic reco is contained in the eval output for now
192  //reco->add_eval_list(3); //include back partial tracks in eval tree for debuging
193  //reco->add_eval_list(2); //include station-3+/- in eval tree for debuging
194  //reco->add_eval_list(1); //include station-2 in eval tree for debugging
195  se->registerSubsystem(reco);
196 
197 /* TruthNodeMaker* truthMaker = new TruthNodeMaker();
198  truthMaker->set_legacy_rec_container(legacy_rec_container);
199  se->registerSubsystem(truthMaker);
200 
201  SQTruthVertexing* truthVtx = new SQTruthVertexing();
202  truthVtx->set_legacy_rec_container(legacy_rec_container);
203  se->registerSubsystem(truthVtx);
204 */
205 
206  VertexFit* vertexing = new VertexFit();
207  se->registerSubsystem(vertexing);
208 
209  //Analysis module for track QA
210  AnaTrkQA* trackQA = new AnaTrkQA();
211  trackQA->set_out_name("trackQA.root");
212  se->registerSubsystem(trackQA);
213 
214 
215 
216  // input - we need a dummy to drive the event loop
218  se->registerInputManager(in);
219 
221  // Output
223  // DST output manager, tunred off to save disk by default
224  //Fun4AllDstOutputManager* out = new Fun4AllDstOutputManager("DSTOUT","DST.root");
225  //se->registerOutputManager(out);
226 
227  se->run(nevent);
228  PHGeomUtility::ExportGeomtry(se->topNode(), "geom.root");
229 
230  // finish job - close and save output files
231  se->End();
232  se->PrintTimer();
233  std::cout << "All done" << std::endl;
234 
235  // cleanup - delete the server and exit
236  delete se;
237  gSystem->Exit(0);
238 
239  return 0;
240 }
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 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 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
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 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_enable_KF(bool enable)
Definition: SQReco.h:66
void set_out_name(const std::string &outName)
Definition: AnaTrkQA.h:76
int run(const int nevnts=0, const bool require_nevents=false)
run n events (0 means up to end of file)
void set_eval_file_name(const TString &evalFileName)
Definition: SQReco.h:60
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 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.)
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
virtual const std::string get_CharFlag(const std::string &flag) const
Definition: PHFlag.cc:13
int Fun4Sim_TrkQA(const int nevent=10)
Definition: Fun4Sim_TrkQA.C:25
void SetWorldSizeX(const double sx)
Definition: PHG4Reco.h:111
Definition: SQReco.h:42
void setInputTy(SQReco::INPUT_TYPE input_ty)
Definition: SQReco.h:56
void printTable()
Definition: GeomSvc.cxx:1164
void set_evt_reducer_opt(const TString &opt)
Definition: SQReco.h:75
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_enable_eval(bool enable)
Definition: SQReco.h:69
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 SetupBeamline(PHG4Reco *g4Reco, const bool toggle_collimator=true, const double collimator_pos_z=-300, const int register_hits=0)
Definition: G4_Beamline.C:8
void registerSubsystem(PHG4Subsystem *subsystem)
register subsystem
Definition: PHG4Reco.h:65
void setFitterTy(SQReco::FITTER_TYPE fitter_ty)
Definition: SQReco.h:57
void set_enable_eval_dst(bool enable)
Definition: SQReco.h:71
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