Class Reference for E1039 Core & Analysis Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Fun4MainDaq.C
Go to the documentation of this file.
1 
13 #if ROOT_VERSION_CODE >= ROOT_VERSION(6,00,0)
14 #include <g4main/PHG4Reco.h>
15 #include "G4_SensitiveDetectors.C"
16 #include "G4_Target.C"
17 R__LOAD_LIBRARY(libinterface_main)
18 R__LOAD_LIBRARY(libonlmonserver)
19 R__LOAD_LIBRARY(libdecoder_maindaq)
20 R__LOAD_LIBRARY(libg4detectors)
21 R__LOAD_LIBRARY(libktracker)
22 #endif
23 
24 int Fun4MainDaq(const int nevent = 0, const int run = 24172)
25 {
26  gSystem->Load("libdecoder_maindaq.so");
27  gSystem->Load("libonlmonserver.so");
28  gSystem->Load("libg4detectors");
29  gSystem->Load("libktracker.so");
30 
31  const char* dir_in = "/data3/data/mainDAQ";
32  const char* dir_out = ".";
33  const bool is_online = true; // false;
34 
35  ostringstream oss;
36  oss << setfill('0')
37  << dir_in << "/run_" << setw(6) << run << ".dat";
38  string fn_in = oss.str();
39  oss.str("");
40  oss << dir_out << "/run_" << setw(6) << run << ".root";
41  string fn_out = oss.str();
42 
44  //se->Verbosity(1);
45 
46  const double FMAGSTR = -1.044;//-1.054;
47  const double KMAGSTR = -1.025;//-0.951;
48 
50  rc->set_DoubleFlag("FMAGSTR", FMAGSTR);
51  rc->set_DoubleFlag("KMAGSTR", KMAGSTR);
52  rc->Print();
53 
54  JobOptsSvc *jobopt_svc = JobOptsSvc::instance();
55  jobopt_svc->init("e906_data.opts");
56 
57  GeomSvc *geom_svc = GeomSvc::instance();
58 
59  // Fun4All G4 module
60  PHG4Reco *g4Reco = new PHG4Reco();
61  //PHG4Reco::G4Seed(123);
62  //g4Reco->set_field(5.);
63  g4Reco->set_field_map(
64  jobopt_svc->m_fMagFile+" "+
65  jobopt_svc->m_kMagFile+" "+
66  Form("%f",FMAGSTR) + " " +
67  Form("%f",KMAGSTR) + " " +
68  "5.0",
70  // size of the world - every detector has to fit in here
71  g4Reco->SetWorldSizeX(1000);
72  g4Reco->SetWorldSizeY(1000);
73  g4Reco->SetWorldSizeZ(5000);
74  // shape of our world - it is a tube
75  g4Reco->SetWorldShape("G4BOX");
76  // this is what our world is filled with
77  g4Reco->SetWorldMaterial("G4_AIR"); //G4_Galactic, G4_AIR
78  // Geant4 Physics list to use
79  g4Reco->SetPhysicsList("FTFP_BERT");
80 
81  // insensitive elements of the spectrometer
82  PHG4E1039InsensSubsystem* insens = new PHG4E1039InsensSubsystem("Insens");
83  g4Reco->registerSubsystem(insens);
84 
85  // collimator, targer and shielding between target and FMag
86  gROOT->LoadMacro("G4_Target.C");
87  SetupTarget(g4Reco);
88 
89  // sensitive elements of the spectrometer
90  gROOT->LoadMacro("G4_SensitiveDetectors.C");
92 
93  se->registerSubsystem(g4Reco);
94 
95  se->registerSubsystem(new CalibInTime());
96  se->registerSubsystem(new CalibXT());
97 
98  // trakcing module
99  gSystem->Load("libktracker.so");
100  KalmanFastTrackingWrapper *ktracker = new KalmanFastTrackingWrapper();
101  //ktracker->Verbosity(99);
102  ktracker->set_enable_event_reducer(true);
103  ktracker->set_DS_level(0);
104  se->registerSubsystem(ktracker);
105 
106 
108  in->Verbosity(1);
109  in->EventSamplingFactor(10);
110  //if (is_online) in->PretendSpillInterval(20);
111 
112  in->DirParam("/seaquest/production/runs");
113  in->fileopen(fn_in);
114  se->registerInputManager(in);
115 
116  Fun4AllDstOutputManager *out = new Fun4AllDstOutputManager("DSTOUT", fn_out);
117  se->registerOutputManager(out);
118 
119  se->registerSubsystem(new DbUpRun());
120  se->registerSubsystem(new DbUpSpill());
121  se->registerSubsystem(new CalibInTime());
122  se->registerSubsystem(new CalibXT());
123 
124  if (is_online) { // Register the online-monitoring clients
125  se->StartServer();
126  se->registerSubsystem(new OnlMonMainDaq());
127  se->registerSubsystem(new OnlMonTrigSig());
147  se->registerSubsystem(new OnlMonReco ());
148  }
149 
150  se->run(nevent);
151  se->End();
152 
153  delete se;
154  cout << "Fun4MainDaq Done!" << endl;
155  return 0;
156 }
int registerInputManager(Fun4AllInputManager *InManager)
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
Fun4AllServer * se
int run(const int nEvents=1)
Definition: run.C:10
static recoConsts * instance()
Definition: recoConsts.cc:7
int fileopen(const std::string &filenam)
OnlMonMainDaq.
Definition: OnlMonMainDaq.h:6
int registerSubsystem(SubsysReco *subsystem, const std::string &topnodename="TOP")
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
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 DirParam(const std::string dir)
int Fun4MainDaq(const int run=46, const int nevent=0, const bool is_online=false)
Fun4MainDaq.C: Fun4all macro to decode the MainDAQ data.
Definition: Fun4MainDaq.C:9
void SetWorldSizeX(const double sx)
Definition: PHG4Reco.h:111
Definition: DbUpRun.h:7
void StartServer()
Definition: OnlMonServer.cc:66
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
static OnlMonServer * instance()
Definition: OnlMonServer.cc:34
void EventSamplingFactor(const int factor)
void registerSubsystem(PHG4Subsystem *subsystem)
register subsystem
Definition: PHG4Reco.h:65
void SetWorldSizeZ(const double sz)
Definition: PHG4Reco.h:113
void SetWorldSizeY(const double sy)
Definition: PHG4Reco.h:112