Class Reference for E1039 Core & Analysis Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Fun4CODA.C
Go to the documentation of this file.
1 
13 #if ROOT_VERSION_CODE >= ROOT_VERSION(6,00,0)
14 
15 #include <TSystem.h>
16 
17 #include "G4_SensitiveDetectors.C"
18 #include "G4_Target.C"
19 
20 R__LOAD_LIBRARY(libinterface_main)
21 R__LOAD_LIBRARY(libfun4all)
22 R__LOAD_LIBRARY(libdecoder_maindaq)
23 R__LOAD_LIBRARY(libg4testbench)
24 R__LOAD_LIBRARY(libg4detectors)
25 R__LOAD_LIBRARY(libg4eval)
26 R__LOAD_LIBRARY(libevt_filter)
27 R__LOAD_LIBRARY(libktracker)
28 R__LOAD_LIBRARY(libonlmonserver)
29 #endif
30 
32 const int nevent = 0,
33 const int run = 28692,
34 const int skip = 0
35 )
36 {
37  gSystem->Load("libinterface_main.so");
38  gSystem->Load("libfun4all");
39  gSystem->Load("libdecoder_maindaq");
40  gSystem->Load("libg4testbench");
41  gSystem->Load("libg4detectors");
42  gSystem->Load("libg4eval");
43  gSystem->Load("libktracker.so");
44  gSystem->Load("libonlmonserver.so");
45 
46  //const char* coda_dir = "/data3/data/mainDAQ/";
47  //const char* para_dir = "/seaquest/production/runs/";
48 
49  const char* coda_dir = "./";
50  const char* para_dir = "./";
51 
52  const char* out_dir = "./";
53 
54  ostringstream oss;
55  oss << setfill('0')
56  << coda_dir << "/run_" << setw(6) << run << ".dat";
57  string coda_file = oss.str();
58  oss.str("");
59  oss << out_dir << "/run_" << setw(6) << run << ".root";
60  string out_dst = oss.str();
61 
63  se->Verbosity(0);
64 
65  const double FMAGSTR = -1.044;//-1.054;
66  const double KMAGSTR = -1.025;//-0.951;
67 
69  rc->set_DoubleFlag("FMAGSTR", FMAGSTR);
70  rc->set_DoubleFlag("KMAGSTR", KMAGSTR);
71  rc->Print();
72 
73  JobOptsSvc *jobopt_svc = JobOptsSvc::instance();
74  jobopt_svc->init("run7_data.opts");
75 
76  GeomSvc::UseDbSvc(true);
77  GeomSvc *geom_svc = GeomSvc::instance();
78 
79  // Fun4All G4 module
80  PHG4Reco *g4Reco = new PHG4Reco();
81  //PHG4Reco::G4Seed(123);
82  //g4Reco->set_field(5.);
83  g4Reco->set_field_map(
84  jobopt_svc->m_fMagFile+" "+
85  jobopt_svc->m_kMagFile+" "+
86  Form("%f",FMAGSTR) + " " +
87  Form("%f",KMAGSTR) + " " +
88  "5.0",
90  // size of the world - every detector has to fit in here
91  g4Reco->SetWorldSizeX(1000);
92  g4Reco->SetWorldSizeY(1000);
93  g4Reco->SetWorldSizeZ(5000);
94  // shape of our world - it is a tube
95  g4Reco->SetWorldShape("G4BOX");
96  // this is what our world is filled with
97  g4Reco->SetWorldMaterial("G4_AIR"); //G4_Galactic, G4_AIR
98  // Geant4 Physics list to use
99  g4Reco->SetPhysicsList("FTFP_BERT");
100 
101  // insensitive elements of the spectrometer
102  PHG4E1039InsensSubsystem* insens = new PHG4E1039InsensSubsystem("Insens");
103  g4Reco->registerSubsystem(insens);
104 
105  // collimator, targer and shielding between target and FMag
106  gROOT->LoadMacro("G4_Target.C");
107  SetupTarget(g4Reco);
108 
109  // sensitive elements of the spectrometer
110  gROOT->LoadMacro("G4_SensitiveDetectors.C");
111  SetupSensitiveDetectors(g4Reco);
112 
113  se->registerSubsystem(g4Reco);
114 
115  // calib: in time
116  CalibInTime* cali_intime = new CalibInTime();
117  se->registerSubsystem(cali_intime);
118 
119  // calib: TDC to drift time
120  CalibXT* cali_xt = new CalibXT();
121  se->registerSubsystem(cali_xt);
122 
123  // Event Filter
124  EvtFilter *evt_filter = new EvtFilter();
125  se->registerSubsystem(evt_filter);
126 
127  // trakcing module
128  KalmanFastTrackingWrapper *ktracker = new KalmanFastTrackingWrapper();
129  //ktracker->Verbosity(99);
130  ktracker->set_enable_event_reducer(true);
131  ktracker->set_DS_level(0);
132  ktracker->set_pattern_db_name(gSystem->ExpandPathName("$E1039_RESOURCE/dsearch/v1/pattern.root"));
133  //PatternDBUtil::LooseMode(false);
134  se->registerSubsystem(ktracker);
135 
136  // input manager for CODA files
138  in->Verbosity(1);
139  //in->SetOnline(true);
140  in->EventSamplingFactor(200);
141  in->DirParam(para_dir);
142  in->fileopen(coda_file);
143  se->registerInputManager(in);
144 
145  // output manager for CODA files
146  Fun4AllDstOutputManager *out = new Fun4AllDstOutputManager("DSTOUT", out_dst);
147  se->registerOutputManager(out);
148 
149  //se->skip(skip);
150  se->run(nevent);
151 
152  PHGeomUtility::ExportGeomtry(se->topNode(),"geom.root");
153 
154  // finish job - close and save output files
155  se->End();
156  se->PrintTimer();
157  std::cout << "All done" << std::endl;
158 
159  // cleanup - delete the server and exit
160  delete se;
161  return 0;
162 }
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 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.
int run(const int nEvents=1)
Definition: run.C:10
static recoConsts * instance()
Definition: recoConsts.cc:7
int fileopen(const std::string &filenam)
int registerSubsystem(SubsysReco *subsystem, const std::string &topnodename="TOP")
static bool UseDbSvc()
Definition: GeomSvc.h:304
int run(const int nevnts=0, const bool require_nevents=false)
run n events (0 means up to end of file)
int registerOutputManager(Fun4AllOutputManager *manager)
void set_field_map(const std::string &fmap, const PHFieldConfig::FieldConfigTypes dim)
Definition: PHG4Reco.h:87
Definition: CalibXT.h:7
EvtFilter * evt_filter
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 DirParam(const std::string dir)
void SetWorldSizeX(const double sx)
Definition: PHG4Reco.h:111
void SetPhysicsList(const std::string &s)
Definition: PHG4Reco.h:119
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 EventSamplingFactor(const int factor)
void registerSubsystem(PHG4Subsystem *subsystem)
register subsystem
Definition: PHG4Reco.h:65
int Fun4CODA(const int nevent=0, const int run=28692, const int skip=0)
Definition: Fun4CODA.C:31
void SetWorldSizeZ(const double sz)
Definition: PHG4Reco.h:113
void SetWorldSizeY(const double sy)
Definition: PHG4Reco.h:112