Fork me on GitHub

Changeset 380 in svn for trunk/Examples


Ignore:
Timestamp:
May 12, 2009, 9:47:12 AM (15 years ago)
Author:
Xavier Rouby
Message:

new PDG table

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Examples/Convertors_Only.cpp

    r266 r380  
    4545#include "DataConverter.h"
    4646#include "HEPEVTConverter.h"
     47#include "HepMCConverter.h"
    4748#include "LHEFConverter.h"
    4849#include "STDHEPConverter.h"
     
    6061
    6162using namespace std;
    62 
    63 //------------------------------------------------------------------------------
    64 void todo(string filename) {
    65   ifstream infile(filename.c_str());
    66   cout << "** TODO list ..." << endl;
    67   while(infile.good()) {
    68     string temp;
    69     getline(infile,temp);
    70     cout << "*" << temp << endl;
    71   }
    72   cout << "** done...\n";
    73 }
    7463
    7564//------------------------------------------------------------------------------
     
    8877  delete [] appOpt;
    8978
    90   if(argc != 3) {
    91     cout << " Usage: " << argv[0] << " input_file output_file " << endl;
     79  if(argc != 4) {
     80    cout << " Usage: " << argv[0] << " input_file output_file PDG_Table" << endl;
    9281    cout << " input_list - list of files in Ntpl, StdHep of LHEF format," << endl;
    93     cout << " output_file - output file." << endl;
     82    cout << " output_file - output file," << endl;
     83    cout << " PDG_Table - file with PDG particle table" << endl;
    9484    exit(1);
    9585  }
     
    160150 
    161151  //read the output TROOT file
    162   string inputFileList(argv[1]), outputfilename(argv[2]);
     152  string inputFileList(argv[1]), outputfilename(argv[2]), pdgtablefilename(argv[3]);
    163153  if(outputfilename.find(".root") > outputfilename.length()) {
    164154    cout <<"**    ERROR: 'output_file' should be a .root file. Exiting...      **"<< endl;
    165155    exit(1);
    166156  }
    167  
     157 
     158  RESOLution DET;
     159  DET.PdgTableFilename = pdgtablefilename;
     160  DET.ReadParticleDataGroupTable(); //  DET.PDGtable.print();
     161
    168162  TFile *outputFile = TFile::Open(outputfilename.c_str(), "RECREATE"); // Creates the file, but should be closed just after
    169163  outputFile->Close();
     
    174168 
    175169  // data converters
    176   DataConverter *converter=NULL;
    177170  cout <<"**                                                                 **"<<endl;
    178171  cout <<"**        ####### Start convertion to TRoot format ########        **"<< endl;
    179172
    180   if(strstr(line.c_str(),".hep"))
    181     {                           
     173  if(line.length() == 1+line.find_last_of(".hep"))
     174    {
    182175      cout <<"**                 StdHEP file format detected                     **"<<endl;
    183176      cout <<"**                This can take several minutes                    **"<< endl;
    184       converter = new STDHEPConverter(inputFileList,outputfilename);//case ntpl file in input list
    185     }
    186   else if(strstr(line.c_str(),".lhe"))
     177      STDHEPConverter converter(inputFileList,outputfilename,DET.PDGtable);//case ntpl file in input list
     178    }
     179  else if(line.length() == 1+line.find_last_of(".lhe"))
    187180    {
    188181      cout <<"**                   LHEF file format detected                     **"<<endl;
    189182      cout <<"**                 This can take several minutes                   **"<< endl;
    190       converter = new LHEFConverter(inputFileList,outputfilename);//case ntpl file in input list
    191     }
    192   else if(strstr(line.c_str(),".root"))
     183      LHEFConverter converter(inputFileList,outputfilename,DET.PDGtable);//case ntpl file in input list
     184    }
     185  else if(line.length() == 1+line.find_last_of(".root"))
    193186    {
    194187      cout <<"**                   h2root file format detected                   **"<<endl;
    195188      cout <<"**                  This can take several minutes                  **"<< endl;
    196       converter = new HEPEVTConverter(inputFileList,outputfilename);//case ntpl file in input list
     189      HEPEVTConverter converter(inputFileList,outputfilename,DET.PDGtable);//case ntpl file in input list
     190    }
     191  else if(line.length() == 1+line.find_last_of(".hepmc"))
     192    {
     193      cout <<"**                HepMC ASCII file format detected                 **"<<endl;
     194      cout <<"**                  This can take several minutes                  **"<< endl;
     195      HepMCConverter converter(inputFileList,outputfilename,DET.PDGtable);
    197196    }
    198197  else {
    199       cerr << left  << setw(4) <<"**  "<<""
    200            << left  << setw(63) << line.c_str() <<""
    201            << right << setw(2) <<"**"<<endl;
    202       cerr <<"**         ERROR: File format not identified --  Exiting...        **"<< endl;
    203       cout <<"**                                                                 **"<< endl;
    204       cout <<"*********************************************************************"<< endl;
    205       return -1;};
     198    cerr << left  << setw(4) <<"**  "<<""
     199         << left  << setw(63) << line.c_str() <<""
     200         << right << setw(2) <<"**"<<endl;
     201    cerr <<"**         ERROR: File format not identified --  Exiting...        **"<< endl;
     202    cout <<"**                                                                 **"<< endl;
     203    cout <<"*********************************************************************"<< endl;
     204    return -1;};
     205
    206206  cout <<"**                       Exiting conversion...                     **"<< endl;
    207207  cout <<"*********************************************************************"<< endl;
     
    209209
    210210
    211   delete converter;
    212211 
    213212}
Note: See TracChangeset for help on using the changeset viewer.