EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
FairGeane.cxx
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file FairGeane.cxx
1 // Class for the GEANE initialization
2 //
3 // Author: M. Al-Turany
4 //
5 #include "FairGeane.h"
6 #include "FairGeaneApplication.h"
7 #include "FairField.h"
8 #include "FairRunAna.h"
9 #include "TGeoManager.h"
10 #include "TString.h"
11 #include "TGeoManager.h"
12 #include "TVirtualMC.h"
13 #include "TROOT.h"
14 #include "TSystem.h"
15 
16 using std::cout;
17 using std::endl;
18 
19 // ----- Default constructor -------------------------------------------
20 //FairGeane::FairGeane() {
21 // cout << "This ctr should not be called by user !!"<< endl;
22 //}
23 // ----- Standard constructor ------------------------------------------
24 FairGeane::FairGeane(const char* name, TString UserConfig, TString UserCuts )
25  : FairTask("Geane Application"),
26  fApp(new FairGeaneApplication(kTRUE)),
27  fName(name),
28  fUserConfig(UserConfig),
29  fUserCuts (UserCuts)
30 {
31  //Create a new Geometry
32  new TGeoManager("Geometry", "Geane geometry");
33  // now import the geometry from file to the empty TGeo
34  TGeoManager::Import(name);
35 
36 }
37 
38 
39 FairGeane::FairGeane(TString UserConfig, TString UserCuts )
40  : FairTask("Geane Application"),
41  fApp(new FairGeaneApplication(kFALSE)),
42  fName(""),
43  fUserConfig(UserConfig),
44  fUserCuts (UserCuts)
45 {
46 
47 
48 }
49 
51 {
52 
53  cout << "------------------------FairGeane::SetParTask()------------------------------" << endl;
54 }
55 
57 {
58 
59  cout << "------------------------FairGeane::Init ()------------------------------" << endl;
60 
61  //TString LibMacro;
62  //TString LibFunction;
63  TString ConfigMacro;
64  TString cuts=fUserCuts;
65  if(cuts== TString("")) { cuts="SetCuts.C"; }
66 
67  TString work = getenv("VMCWORKDIR");
68  TString work_config=work+"/gconfig/";
69  TString config_dir= getenv("CONFIG_DIR");
70  Bool_t AbsPath=kFALSE;
71  if (!config_dir.EndsWith("/")) { config_dir+="/"; }
72 
73 
74  //TString geaneLibMacro="g3libs.C";
75  TString geaneMacro;
76  if(fUserConfig.IsNull()) {
77  geaneMacro="Geane.C";
78  fUserConfig = geaneMacro;
79  } else {
80  if (fUserConfig.Contains("/")) { AbsPath=kTRUE; }
81  geaneMacro = fUserConfig;
82  cout << "---------------User config is used : " << geaneMacro.Data() <<"-----------------"<< endl;
83  }
84  //if (TString(gSystem->FindFile(config_dir.Data(),geaneLibMacro)) != TString("")) {
85  //cout << "---User path for Configuration (g3libs.C) is used : " << config_dir.Data() << endl;
86  //} else {
87  //geaneLibMacro=work_config+"g3libs.C";
88  //}
89  //LibMacro=geaneLibMacro;
90  //LibFunction="g3libs()";
91 
92  if (!AbsPath && TString(gSystem->FindFile(config_dir.Data(),geaneMacro)) != TString("")) {
93  cout << "---User path for Configuration (Geane.C) is used : " << config_dir.Data() << endl;
94  ConfigMacro =geaneMacro;
95  } else {
96  if(AbsPath) { ConfigMacro = fUserConfig; }
97  else { ConfigMacro =work_config+fUserConfig; }
98  }
99 
100  if (!AbsPath &&TString(gSystem->FindFile(config_dir.Data(),cuts)) != TString("")) {
101  cout << "---User path for Cuts and Processes (SetCuts.C) is used : " << config_dir.Data() << endl;
102  } else {
103  cuts =work_config+ "SetCuts.C";
104  }
105 
106  //gROOT->LoadMacro(LibMacro.Data());
107  //gROOT->ProcessLine(LibFunction.Data());
108 
109  gROOT->LoadMacro(ConfigMacro.Data());
110  gROOT->ProcessLine("Config()");
111 
112  // Hmm, these two lines were commented out (Jana issues?);
113  gROOT->LoadMacro(cuts);
114  gROOT->ProcessLine("SetCuts()");
115 
116  FairField* field=FairRunAna::Instance()->GetField();
117  field->Print();
118  fApp->SetField(field);
119 
120  fApp->InitMC(ConfigMacro.Data(), "");
121 
122  cout <<"I- FairGeane::FairGeane: Geane is Initialized " << endl;
123  return kSUCCESS;
124 
125 }
126 
127 
128 
129 
130 // ----- Destructor ----------------------------------------------------
131 
132 
133 
134 
136 {
137 
138 }
139 void FairGeane::SetField(FairField* field)
140 {
141 
142  cout<< "\033[5m\033[31m -W- FairGeane::SetField This method is not used anymore, use FairRunAna::SetField instead \033[0m " << endl;
143 
144 }
145