EIC Software
Reference for
EIC
simulation and reconstruction software on GitHub
Home page
Related Pages
Modules
Namespaces
Classes
Files
External Links
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
File.h
Go to the documentation of this file.
Or view
the newest version in sPHENIX GitHub for file File.h
1
10
#ifndef INCLUDE_EICSMEAR_ERHIC_FILE_H_
11
#define INCLUDE_EICSMEAR_ERHIC_FILE_H_
12
13
#include <iostream>
14
#include <map>
15
#include <string>
16
17
#include <TObject.h>
18
#include <TObjString.h>
19
#include <TString.h>
20
21
#include "
eicsmear/erhic/EventBase.h
"
22
#include "
eicsmear/erhic/EventHepMC.h
"
23
#include "
eicsmear/erhic/EventMilou.h
"
24
#include "
eicsmear/erhic/EventPythia.h
"
25
#include "
eicsmear/erhic/EventFactory.h
"
26
27
namespace
erhic {
28
37
class
LogReader
:
public
TObject
{
38
public
:
42
LogReader
() { }
43
47
virtual
~LogReader
() { }
48
52
virtual
LogReader
*
Create
()
const
= 0;
53
57
virtual
bool
Extract
(
const
std::string&
file
) = 0;
58
65
virtual
Int_t
Save
()
const
= 0;
66
67
ClassDef(
erhic::LogReader
, 1)
68
};
69
78
class
LogReaderPythia
:
public
LogReader
{
79
public
:
83
LogReaderPythia
();
84
88
virtual
~LogReaderPythia
();
89
93
LogReaderPythia
*
Create
()
const
;
94
98
bool
Extract
(
const
std::string&
file
);
99
105
Int_t
Save
()
const
;
106
107
protected
:
108
TObjString
crossSection_
;
109
TObjString
nEvents_
;
110
TObjString
nTrials_
;
111
112
ClassDef(
erhic::LogReaderPythia
, 2)
113
};
114
115
inline
LogReaderPythia
*
LogReaderPythia::Create
()
const
{
116
return
new
LogReaderPythia
;
117
}
118
127
class
LogReaderPepsi
:
public
LogReader
{
128
public
:
132
LogReaderPepsi
();
133
137
virtual
~LogReaderPepsi
();
138
142
LogReaderPepsi
*
Create
()
const
;
143
147
bool
Extract
(
const
std::string&
file
);
148
154
Int_t
Save
()
const
;
155
156
protected
:
157
TObjString
crossSection_
;
158
TObjString
nEvents_
;
159
TObjString
nTrials_
;
160
161
ClassDef(
erhic::LogReaderPepsi
, 2)
162
};
163
164
inline
LogReaderPepsi
*
LogReaderPepsi::Create
()
const
{
165
return
new
LogReaderPepsi
;
166
}
167
176
class
LogReaderDjangoh
:
public
LogReader
{
177
public
:
181
LogReaderDjangoh
();
182
186
virtual
~LogReaderDjangoh
();
187
191
LogReaderDjangoh
*
Create
()
const
;
192
196
bool
Extract
(
const
std::string&
file
);
197
203
Int_t
Save
()
const
;
204
205
protected
:
206
TObjString
crossSection_
;
207
TObjString
nEvents_
;
208
TObjString
nTrials_
;
209
210
ClassDef(
erhic::LogReaderDjangoh
, 2)
211
};
212
213
inline
LogReaderDjangoh
*
LogReaderDjangoh::Create
()
const
{
214
return
new
LogReaderDjangoh
;
215
}
216
225
class
LogReaderMilou
:
public
LogReader
{
226
public
:
230
LogReaderMilou
() { }
231
235
virtual
~LogReaderMilou
() { }
236
240
LogReaderMilou
*
Create
()
const
;
241
245
bool
Extract
(
const
std::string&
file
);
246
252
Int_t
Save
()
const
;
253
258
Int_t
GetNEvents
()
const
;
259
264
Double_t
GetCrossSection
()
const
;
265
270
Double_t
GetCrossSectionError
()
const
;
271
272
protected
:
273
TObjString
crossSection_
;
274
TObjString
crossSectionError_
;
275
TObjString
nEvents_
;
276
277
ClassDef(
erhic::LogReaderMilou
, 1)
278
};
279
280
inline
LogReaderMilou
*
LogReaderMilou::Create
()
const
{
281
return
new
LogReaderMilou
;
282
}
283
284
inline
Int_t
LogReaderMilou::GetNEvents
()
const
{
285
return
nEvents_
.GetString().Atoi();
286
}
287
288
inline
Double_t
LogReaderMilou::GetCrossSection
()
const
{
289
return
crossSection_
.GetString().Atof();
290
}
291
296
inline
Double_t
LogReaderMilou::GetCrossSectionError
()
const
{
297
return
crossSectionError_
.GetString().Atof();
298
}
299
306
class
LogReaderGmcTrans
:
public
LogReader
{
307
public
:
311
LogReaderGmcTrans
();
312
316
virtual
~LogReaderGmcTrans
();
317
321
LogReaderGmcTrans
*
Create
()
const
;
322
328
bool
Extract
(
const
std::string&
filename
);
329
336
Int_t
Save
()
const
;
337
342
Int_t
GetNEvents
()
const
;
343
348
Double_t
GetCrossSection
()
const
;
349
350
protected
:
351
TObjString
mNEvents
;
352
TObjString
mCrossSection
;
353
354
ClassDef(
erhic::LogReaderGmcTrans
, 1)
355
};
356
364
class
LogReaderFactory
{
365
public
:
369
static
LogReaderFactory
&
GetInstance
();
370
377
LogReader
*
CreateReader
(
const
EventBase
& event)
const
;
378
385
LogReader
*
CreateReader
(
const
std::string&
name
)
const
;
386
394
LogReader
*
CreateReader
(std::istream&)
const
;
395
404
std::string
Locate
(
const
std::string& mcFile)
const
;
405
406
protected
:
410
LogReaderFactory
();
411
415
~LogReaderFactory
();
416
417
typedef
std::map<std::string, LogReader*>
Map
;
418
Map
prototypes_
;
419
420
ClassDef(
erhic::LogReaderFactory
, 1)
421
};
422
428
class
FileType
:
public
TObject
{
429
public
:
433
virtual
~FileType
() { }
434
438
virtual
FileType
*
Create
()
const
= 0;
439
443
virtual
EventBase
*
AllocateEvent
()
const
= 0;
444
449
virtual
std::string
GetGeneratorName
()
const
;
450
455
virtual
void
SetGeneratorName
(
const
std::string newname=
""
);
456
460
virtual
LogReader
*
CreateLogReader
()
const
= 0;
461
465
virtual
VirtualEventFactory
*
CreateEventFactory
(std::istream&)
const
= 0;
466
467
protected
:
468
std::string
generatorname
;
469
470
ClassDef(
erhic::FileType
, 2)
471
};
472
473
/*
474
Templated file descriptor class, valid for Monte Carlo event classes.
475
e.g. File<EventPythia> describes a Pythia event file.
476
*/
477
template
<
typename
T>
478
class
File
:
public
FileType
{
479
public
:
486
File
();
487
491
virtual
~File
();
492
496
virtual
File<T>
*
Create
()
const
;
497
501
virtual
T
*
AllocateEvent
()
const
;
502
509
virtual
LogReader
*
CreateLogReader
()
const
;
510
514
virtual
EventFromAsciiFactory<T>
*
515
CreateEventFactory
(std::istream& is)
const
{
516
return
new
EventFromAsciiFactory<T>
(is);
517
}
518
519
protected
:
520
T
*
t_
;
521
522
// Warning: explicitly putting the erhic:: namespace before the class
523
// name doesn't seen to work for template classes.
524
ClassDef(
File
, 2)
525
};
526
527
template
<>
528
class
File
<erhic::
EventHepMC
> :
public
FileType
{
529
public
:
530
537
File
(){}
538
542
virtual
~File
(){}
543
547
virtual
File<erhic::EventHepMC>
*
Create
()
const
{
548
return
new
File<erhic::EventHepMC>
();
549
}
550
554
virtual
erhic::EventHepMC
*
AllocateEvent
()
const
{
555
return
new
erhic::EventHepMC
();
556
}
557
564
virtual
LogReader
*
CreateLogReader
()
const
{
return
nullptr
;}
565
566
EventFromAsciiFactory<erhic::EventHepMC>
*
CreateEventFactory
(std::istream& is)
const
{
567
return
new
EventFromAsciiFactory<erhic::EventHepMC>
(is);}
568
protected
:
569
erhic::EventHepMC
*
t_
;
570
571
ClassDef(
File<erhic::EventHepMC>
, 1)
572
};
573
574
template
<
typename
T>
575
inline
T
*
File<T>::AllocateEvent
()
const
{
576
return
new
T
;
577
}
578
579
template
<
typename
T>
580
inline
File<T>
*
File<T>::Create
()
const
{
581
return
new
File<T>
();
582
}
583
584
589
class
FileFactory
{
590
public
:
594
static
FileFactory
&
GetInstance
();
595
599
const
FileType
*
GetFile
(
const
std::string& generatorName)
const
;
600
605
const
FileType
*
GetFile
(std::shared_ptr<std::istream>& isp,
const
std::string fileName=
""
)
const
;
606
607
protected
:
611
FileFactory
();
612
616
virtual
~FileFactory
();
617
618
typedef
std::map<std::string, FileType*>
Map
;
619
Map
prototypes_
;
620
};
621
622
}
// namespace erhic
623
624
#endif // INCLUDE_EICSMEAR_ERHIC_FILE_H_
eic-smear
blob
master
include
eicsmear
erhic
File.h
Built by
Jin Huang
. updated:
Mon Jan 22 2024 12:43:32
using
1.8.2 with
EIC GitHub integration