32 std::ifstream ifs(file.c_str(), std::ios::in);
34 if (!ifs.is_open())
return false;
37 const std::string searchPattern(
"Pythia total cross section normalisation:");
38 std::string normalisation;
42 std::getline(ifs, line);
43 size_t position = line.find(searchPattern);
44 if (position != std::string::npos) {
48 line.erase(0, position + searchPattern.length());
54 const std::string searchPattern2(
"Total Number of generated events");
55 position = line.find(searchPattern2);
56 if (position != std::string::npos) {
60 line.erase(0, position + searchPattern2.length());
67 crossSection_.SetString(normalisation.c_str());
68 std::cout << crossSection_.GetString().Atof() << std::endl;
70 std::cout <<
nEvents_.GetString().Atoi() << std::endl;
71 std::cout <<
"Extracted information from " << file << std::endl;
77 crossSection_.Write(
"crossSection") +
92 std::ifstream ifs(file.c_str(), std::ios::in);
93 if (!ifs.is_open())
return false;
95 const std::string searchPattern(
96 "total cross section in pb from MC simulation");
97 std::string normalisation;
100 std::getline(ifs, line);
101 size_t position = line.find(searchPattern);
102 if (position != std::string::npos) {
105 std::stringstream ss;
106 line.erase(0, position + searchPattern.length());
119 const std::string searchPattern2(
"Total Number of trials");
120 position = line.find(searchPattern2);
121 if (position != std::string::npos) {
124 std::stringstream ss;
125 line.erase(0, position + searchPattern2.length());
132 crossSection_.SetString(normalisation.c_str());
133 std::cout << crossSection_.GetString().Atof() << std::endl;
134 nEvents_.SetString(nEvents.c_str());
135 std::cout <<
nEvents_.GetString().Atoi() << std::endl;
136 std::cout <<
"Extracted information from " << file << std::endl;
142 crossSection_.Write(
"crossSection") +
156 std::ifstream ifs(file.c_str(), std::ios::in);
158 if (!ifs.is_open())
return false;
169 const std::string xsecPattern(
"Cross-section from HERACLES =");
170 const std::string xsecAltPattern(
"Total cross section is now SIGTOT =");
171 std::string normalisation;
175 std::getline(ifs, line);
178 size_t position = line.find(xsecPattern);
179 if (position != std::string::npos && normalisation.empty()) {
182 std::stringstream ss;
183 line.erase(0, position + xsecPattern.length());
194 position = line.find(xsecAltPattern);
196 if (position != std::string::npos) {
199 std::stringstream ss;
200 line.erase(0, position + xsecAltPattern.length());
211 const std::string searchPattern2(
"TOTAL EVENT NUMBER");
212 position = line.find(searchPattern2);
213 if (position != std::string::npos) {
216 std::stringstream ss;
217 line.erase(0, position + searchPattern2.length());
225 crossSection_.SetString(normalisation.c_str());
226 std::cout << crossSection_.GetString().Atof() << std::endl;
227 nEvents_.SetString(nEvents.c_str());
228 std::cout <<
nEvents_.GetString().Atoi() << std::endl;
230 std::cout <<
"Extracted information from " << file << std::endl;
236 crossSection_.Write(
"crossSection") +
243 std::ifstream ifs(file.c_str(), std::ios::in);
245 if (!ifs.is_open())
return false;
249 const std::string nEventPattern(
"Number of generated events =");
250 const std::string xsecPattern(
"Total cross-section (nb) :");
251 const std::string errorPattern(
"Error :");
255 std::stringstream ss;
258 std::getline(ifs, line);
262 if (line.find(nEventPattern) != std::string::npos) {
264 line.find(nEventPattern) + nEventPattern.length());
268 }
else if (line.find(xsecPattern) != std::string::npos) {
270 line.find(xsecPattern) + xsecPattern.length());
273 crossSection_.SetString(tmp.c_str());
274 }
else if (line.find(errorPattern) != std::string::npos) {
276 line.find(errorPattern) + errorPattern.length());
284 return !(
nEvents_.GetString().IsNull() ||
285 crossSection_.GetString().IsNull() ||
292 bytes += crossSection_.Write(
"crossSection");
299 , mCrossSection(
"") {
311 std::ifstream file(filename.c_str(), std::ios::in);
312 if (!file.is_open()) {
316 const std::string eventPattern(
"generated events (IEVGEN)");
318 const std::string xsecPattern(
"total xsec in microbarns after selector");
320 std::stringstream sstream;
322 while (file.good()) {
323 std::getline(file, line);
325 if (line.find(eventPattern) != std::string::npos) {
335 if (line.find(xsecPattern) != std::string::npos) {
344 return !(
mNEvents.GetString().IsNull() ||
374 TString name =
event.ClassName();
375 name.ReplaceAll(
"erhic::",
"");
376 name.ReplaceAll(
"Event",
"");
393 if (prototypes_.find(str.Data()) != prototypes_.end()) {
394 reader = prototypes_.find(str.Data())->second->Create();
407 std::getline(is, line);
413 if (str.Contains(
"pythia")) {
415 }
else if (str.Contains(
"pepsi") || str.Contains(
"lepto")) {
417 }
else if (str.Contains(
"rapgap")) {
419 }
else if (str.Contains(
"djangoh")) {
421 }
else if (str.Contains(
"milou")) {
428 TString inFileName(mcFile);
430 std::string extension;
431 if (mcFile.find_last_of(
'.') != std::string::npos) {
432 extension = mcFile.substr(mcFile.find_last_of(
'.'));
435 if (std::string(
".") == gSystem->DirName(inFileName)) {
436 inFileName.Prepend(
"/").Prepend(gSystem->pwd());
445 if (inFileName.Contains(
"TXTFILES")) {
446 logFileName = inFileName;
447 logFileName.ReplaceAll(
"TXTFILES",
"LOGFILES");
448 logFileName.ReplaceAll(extension.c_str(),
".log");
452 if (gSystem->AccessPathName(logFileName, kFileExists)) {
456 if (logFileName.IsNull()) {
457 logFileName = inFileName;
458 if (extension.empty()) {
459 logFileName.Append(
".log");
461 logFileName.ReplaceAll(extension.c_str(),
".log");
466 if (gSystem->AccessPathName(logFileName, kFileExists)) {
469 return logFileName.Data();
473 prototypes_.insert(std::make_pair(
"pythia",
475 prototypes_.insert(std::make_pair(
"milou",
477 prototypes_.insert(std::make_pair(
"pepsi",
479 prototypes_.insert(std::make_pair(
"djangoh",
485 Map::iterator i = prototypes_.begin();
486 for (; i != prototypes_.end(); ++i) {
506 TString name = t_->ClassName();
507 name.ReplaceAll(
"erhic::",
"");
508 name.ReplaceAll(
"Event",
"");
525 if (prototypes_.find(name) != prototypes_.end()) {
526 file = prototypes_.find(name)->second->Create();
533 std::getline(is, line);
539 if (str.Contains(
"pythia")) {
541 }
else if (str.Contains(
"pepsi") || str.Contains(
"lepto")) {
543 }
else if (str.Contains(
"rapgap")) {
545 }
else if (str.Contains(
"djangoh")) {
547 }
else if (str.Contains(
"milou")) {
549 }
else if (str.Contains(
"gmctrans")) {
556 prototypes_.insert(std::make_pair(
"djangoh",
558 prototypes_.insert(std::make_pair(
"dpmjet",
560 prototypes_.insert(std::make_pair(
"milou",
562 prototypes_.insert(std::make_pair(
"pepsi",
564 prototypes_.insert(std::make_pair(
"pythia",
566 prototypes_.insert(std::make_pair(
"rapgap",
568 prototypes_.insert(std::make_pair(
"gmctrans",
573 Map::iterator i = prototypes_.begin();
574 for (; i != prototypes_.end(); ++i) {
575 if (i->second)
delete i->second;
std::string Locate(const std::string &mcFile) const
bool Extract(const std::string &file)
virtual ~LogReaderGmcTrans()
TObjString nEvents_
Cross section error in nb
bool Extract(const std::string &file)
TObjString mCrossSection
Total cross section in microbarns.
LogReaderGmcTrans * Create() const
TObjString nEvents_
Total cross section in microbarns
static FileFactory & GetInstance()
virtual ~LogReaderPythia()
bool Extract(const std::string &file)
bool Extract(const std::string &file)
static LogReaderFactory & GetInstance()
TObjString crossSectionError_
Total cross section in nb
virtual ~LogReaderDjangoh()
const FileType * GetFile(const std::string &generatorName) const
bool Extract(const std::string &filename)
const FileType * GetFile(std::istream &) const
TObjString mNEvents
Number of generated events.
LogReader * CreateReader(const EventBase &event) const
virtual ~LogReaderPepsi()
virtual LogReader * CreateLogReader() const
TObjString nEvents_
Total cross section in microbarns
virtual std::string GetGeneratorName() const
TObjString nEvents_
Total cross section in microbarns
Double_t GetCrossSection() const