58 file =
new std::fstream();
62 if (!filedir.IsNull()) {
63 filename = filedir +
"/" + fname;
67 filename = filename.Strip();
68 if (strcmp(status,
"in") == 0) {
69 file->open(filename, ios::in);
72 if (strcmp(status,
"out") == 0) {
73 file->open(filename, ios::in);
77 file->open(filename, ios::out);
81 Error(
"open",
"Output file %s exists already and will not be recreated.", filename.Data());
85 Error(
"open",
"Invalid file option!");
88 if (file->rdbuf()->is_open() == 0) {
89 Fatal(
"open",
"Failed to open file %s", filename.Data());
98 if (file && file->rdbuf()->is_open() == 1) {
107 if (
isOpen() && writable) {
127 cout <<
"Open output file: " << filename << endl;
129 cout <<
"Open input file: " << filename << endl;
132 cout <<
"No file open." << endl;
139 if (!
isOpen() || writable || media == 0) {
149 if (!
isOpen() || writable || set == 0) {
152 set->
read(*file, media);
159 if (!
isOpen() || !writable || media == 0) {
169 if (!
isOpen() || !writable || set == 0) {
179 if (!
isOpen() || writable || interface == 0) {
183 TString simRefRun, historyDate;
185 while (!(*file).eof()) {
187 buf = buf.Strip(buf.kBoth);
188 if (!buf.IsNull() && buf(0, 2) !=
"//" && buf(0, 1) !=
"*") {
189 if (buf.Contains(
".geo") || buf.Contains(
"_gdb")) {
192 if (buf.Contains(
".setup")) {
195 if (buf.Contains(
"SimulRefRunDb:")) {
196 k = buf.Last(
' ') + 1;
198 simRefRun = buf(k, buf.Length() - k);
201 if (buf.Contains(
"HistoryDateDb:")) {
202 k = buf.First(
' ') + 1;
203 if (buf.Length() > k) {
204 historyDate = buf(k, buf.Length() - k);
205 historyDate = historyDate.Strip(historyDate.kBoth);
216 if (historyDate.Length() > 0) {
219 if (rc && simRefRun.Length() > 0) {
229 if (!
isOpen() || writable || interface == 0) {
232 const Int_t maxbuf = 256;
236 Int_t maxModules = 0, secNo = -1;
238 const char d[] =
" ";
239 while (!(*file).eof()) {
240 (*file).getline(buf, maxbuf);
241 if (strlen(buf) >= 3 && buf[1] !=
'/') {
247 Ssiz_t n = s.First(
']');
252 Error(
"readDetectorSetup",
"Detector %s not found", det.Data());
257 mod =
new Int_t[maxModules];
260 char* ss = strtok(buf, d);
261 if (ss && strlen(ss) > 3) {
262 secNo =
static_cast<Int_t
>(ss[3] -
'0') - 1;
263 for (Int_t i = 0; i < maxModules && mod; i++) {
264 ss = strtok(
nullptr, d);
266 sscanf(ss,
"%i", &mod[i]);
Int_t getMaxModules(void)
FairGeoIo * getOraInput()
Bool_t readDetectorSetup(FairGeoInterface *)
virtual Bool_t setHistoryDate(const char *)=0
Bool_t read(FairGeoMedia *)
Bool_t write(FairGeoMedia *)
void setModules(Int_t, Int_t *)
virtual Bool_t read(std::fstream &, FairGeoMedia *)
ClassImp(FairEventBuilder)
virtual void write(std::fstream &)
virtual ~FairGeoAsciiIo()
virtual Bool_t setSimulRefRun(const char *)=0
FairGeoSet * findSet(const char *)
void addInputFile(const char *)
Bool_t readGeomConfig(FairGeoInterface *)
void addSetupFile(const char *f)
Bool_t open(const char *, const Text_t *status="in")