29 #include <HepMC3/Version.h> 
   36 static void LogLineParse(std::string line, 
const std::string searchPattern, std::string& toupdate, 
const double rescale=1 ){
 
   37   size_t position = line.find(searchPattern);
 
   38   if (position != std::string::npos) {
 
   41     if ( toupdate!=
"") 
throw std::runtime_error( 
"LogLineParse: Found two instances of the search pattern");
 
   44     line.erase(0, position + searchPattern.length());
 
   70   if (!ifs.is_open()) 
return false;
 
   73   std::string normalisation;
 
   79     LogLineParse( line, 
"Pythia total cross section normalisation:", normalisation );
 
   80     LogLineParse( line, 
"Total Number of generated events", nEvents );
 
   87   std::cout << 
"Extracted information from " << file << std::endl;
 
   92   Int_t byteswritten = 0;
 
   94   byteswritten += 
nEvents_.Write(
"nEvents");
 
   95   byteswritten += 
nTrials_.Write(
"nTrials");
 
  110   if (!ifs.is_open()) 
return false;
 
  112   std::string normalisation;
 
  119     LogLineParse( line, 
"total cross section in pb from MC simulation", normalisation, 1
e-6 );
 
  120     LogLineParse( line, 
"Total Number of generated events", nEvents );
 
  121     LogLineParse( line, 
"Total Number of trials", nTrials );
 
  125   nEvents_.SetString(nEvents.c_str());
 
  126   nTrials_.SetString(nTrials.c_str());
 
  127   std::cout << 
"Extracted information from " << file << std::endl;
 
  132   Int_t byteswritten = 0;
 
  134   byteswritten += 
nEvents_.Write(
"nEvents");
 
  135   byteswritten += 
nTrials_.Write(
"nTrials");
 
  151   if (!ifs.is_open()) 
return false;
 
  162   const std::string xsecPattern(
"Cross-section from HERACLES =");
 
  163   const std::string xsecAltPattern(
"Total cross section is now    SIGTOT =");
 
  164   std::string normalisation;
 
  171     size_t position = line.find(xsecPattern);
 
  172     if (position != std::string::npos && normalisation.empty()) {
 
  175       std::stringstream ss;
 
  176       line.erase(0, position + xsecPattern.length());
 
  187     position = line.find(xsecAltPattern);
 
  189     if (position != std::string::npos) {
 
  192       std::stringstream ss;
 
  193       line.erase(0, position + xsecAltPattern.length());
 
  204     const std::string searchPattern2(
"TOTAL EVENT NUMBER");
 
  205     position = line.find(searchPattern2);
 
  206     if (position != std::string::npos) {
 
  209       std::stringstream ss;
 
  210       line.erase(0, position + searchPattern2.length());
 
  220   nEvents_.SetString(nEvents.c_str());
 
  221   std::cout << 
nEvents_.GetString().Atoi() << std::endl;
 
  223   std::cout << 
"Extracted information from " << file << std::endl;
 
  238   if (!ifs.is_open()) 
return false;
 
  242   const std::string nEventPattern(
"Number of generated events    =");
 
  243   const std::string xsecPattern(
"Total cross-section (nb) :");
 
  244   const std::string errorPattern(
"Error                    :");
 
  248   std::stringstream ss;
 
  255     if (line.find(nEventPattern) != std::string::npos) {
 
  257                  line.find(nEventPattern) + nEventPattern.length());
 
  261     } 
else if (line.find(xsecPattern) != std::string::npos) {
 
  263                  line.find(xsecPattern) + xsecPattern.length());
 
  267     } 
else if (line.find(errorPattern) != std::string::npos) {
 
  269                  line.find(errorPattern) + errorPattern.length());
 
  277   return !(
nEvents_.GetString().IsNull() ||
 
  292 , mCrossSection(
"") {
 
  305   if (!
file.is_open()) {
 
  309   const std::string eventPattern(
"generated events (IEVGEN)");
 
  311   const std::string xsecPattern(
"total xsec in microbarns after selector");
 
  313   std::stringstream sstream;  
 
  315   while (
file.good()) {
 
  318     if (line.find(eventPattern) != std::string::npos) {
 
  328     if (line.find(xsecPattern) != std::string::npos) {
 
  337   return !(
mNEvents.GetString().IsNull() ||
 
  367   TString 
name = 
event.ClassName();
 
  368   name.ReplaceAll(
"erhic::", 
"");
 
  369   name.ReplaceAll(
"Event", 
"");
 
  387     reader = 
prototypes_.find(str.Data())->second->Create();
 
  406   if (str.Contains(
"pythia")) {
 
  408   } 
else if (str.Contains(
"pepsi") || str.Contains(
"lepto")) {
 
  410   } 
else if (str.Contains(
"rapgap")) {
 
  412   } 
else if (str.Contains(
"djangoh")) {
 
  416   } 
else if (str.Contains(
"milou")) {
 
  418   } 
else if (str.Contains(
"simple")) {
 
  420    } 
else if (str.Contains(
"demp")) {
 
  422   } 
else if (str.Contains(
"sartre")) {
 
  431   std::string extension;
 
  432   if (mcFile.find_last_of(
'.') != std::string::npos) {
 
  433     extension = mcFile.substr(mcFile.find_last_of(
'.'));
 
  436   if (std::string(
".") == gSystem->DirName(inFileName)) {
 
  437     inFileName.Prepend(
"/").Prepend(gSystem->pwd());
 
  446   if (inFileName.Contains(
"TXTFILES")) {
 
  448     logFileName.ReplaceAll(
"TXTFILES", 
"LOGFILES");
 
  449     logFileName.ReplaceAll(extension.c_str(), 
".log");
 
  453   if (gSystem->AccessPathName(logFileName, kFileExists)) {
 
  457   if (logFileName.IsNull()) {
 
  459     if (extension.empty()) {
 
  460       logFileName.Append(
".log");
 
  462       logFileName.ReplaceAll(extension.c_str(), 
".log");
 
  467   if (gSystem->AccessPathName(logFileName, kFileExists)) {
 
  470   return logFileName.Data();
 
  494   TString 
name = 
t_->ClassName();
 
  495   name.ReplaceAll(
"erhic::", 
"");
 
  496   name.ReplaceAll(
"Event", 
"");
 
  574   } 
while (line.empty());
 
  581   if (str.Contains(
"pythia")) {
 
  583   } 
else if (str.Contains(
"pepsi") || str.Contains(
"lepto")) {
 
  585   } 
else if (str.Contains(
"rapgap")) {
 
  587   } 
else if (str.Contains(
"djangoh")) {
 
  589   } 
else if (str.Contains(
"milou")) {
 
  591   } 
else if (str.Contains(
"beagle")) {
 
  593   } 
else if (str.Contains(
"gmctrans")) {
 
  595   } 
else if (str.Contains(
"dpmjet")) {
 
  597   } 
else if (str.Contains(
"simple")) {
 
  599   } 
else if (str.Contains(
"demp")) {
 
  601   } 
else if (str.Contains(
"sartre")) {
 
  603   } 
else if (str.Contains(
"hepmc")) {
 
  607     if ( TString(fileName).EndsWith(
"gz", TString::kIgnoreCase) ||
 
  608    TString(fileName).EndsWith(
"zip", TString::kIgnoreCase)){
 
  609 #if HEPMC3_VERSION_CODE < 3002005       
  611       std::cerr << 
"HepMC before v 3.2.5 only supports ifstream (no compressed files)." << endl;
 
  613 #endif // HEPMC3_VERSION_CODE < 3002004 
  615       auto tmp = std::make_shared<igzstream>();
 
  616       tmp->open(fileName.c_str());
 
  619   std::string message(
"Unable to open file ");
 
  620   throw std::runtime_error(message.append(fileName));
 
  624       auto tmp = std::make_shared<std::ifstream>();
 
  625       tmp->open(fileName.c_str());
 
  628   std::string message(
"Unable to open file ");
 
  629   throw std::runtime_error(message.append(fileName));
 
  669     if (i->second) 
delete i->second;