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