BmnRoot
Loading...
Searching...
No Matches
show_event_count.cxx
Go to the documentation of this file.
1//============================================================================
2// Name : show_event_count.cxx
3// Author : Konstantin Gertsenberger
4// Copyright : JINR
5// Description : Get event count for the generator file
6//============================================================================
7
8// own headers
9#include "MpdGetNumEvents.h"
10
11// ROOT includes
12#include "TString.h"
13#include "TSystem.h"
14
15// C++ includes
16#include <algorithm>
17#include <iostream>
18#include <sstream>
19#include <string>
20
21using namespace std;
22
23bool ends_with(string const& fullString, string const& ending)
24{
25 if (fullString.length() >= ending.length())
26 return (0 == fullString.compare(fullString.length() - ending.length(), ending.length(), ending));
27 else
28 return false;
29}
30
31int main(int argc, char** argv)
32{
33 // help information
34 if (argc > 1) {
35 string first_par = argv[1];
36 if ((first_par == "/?") || (first_par == "--help") || (first_par == "-h")) {
37 cout << "The utility shows event count for a given generator file or just ROOT file" << endl
38 << "The first parameter: case-insensitive generator name (urqmd, hsd (phsd), qgsm (laqgsm,dcm-gsqm) "
39 "or 'root' value (w/o quotes)"
40 << endl
41 << "The second parameter: generator file path" << endl
42 << "Example: show_event_count dcmqgsm /eos/nica/bmn/sim/DQGSM/" << endl
43 << "Example: show_event_count root example.root" << endl;
44
45 return 0;
46 }
47 }
48
49 if (argc != 3) {
50 cout << "The ShowEventCount utility takes 2 parameters: " << endl
51 << "1st - generator name or 'root' value (w/o quotes); 2nd - generator or ROOT file path" << endl;
52 return -1;
53 }
54
55 string generator_name = argv[1];
56 transform(generator_name.begin(), generator_name.end(), generator_name.begin(),
57 [](unsigned char c) { return tolower(c); });
58 string file_path = argv[2];
59
60 if (generator_name == "urqmd") {
61 cout << MpdGetNumEvents::GetNumURQMDEvents(file_path.c_str(), 1);
62 return 0;
63 } else if (ends_with(generator_name, "hsd")) {
64 cout << MpdGetNumEvents::GetNumPHSDEvents(file_path.c_str(), 1);
65 return 0;
66 } else if (ends_with(generator_name, "qgsm")) {
67 cout << MpdGetNumEvents::GetNumQGSMEvents(file_path.c_str(), 1);
68 return 0;
69 } else if (ends_with(generator_name, "smm")) {
70 cout << MpdGetNumEvents::GetNumDCMSMMEvents(file_path.c_str(), 1);
71 return 0;
72 } else if ((generator_name == "jam") || (generator_name == "rqmd")) {
73 cout << MpdGetNumEvents::GetNumROOTEvents(file_path.c_str(), "events", 1);
74 return 0;
75 } else if (ends_with(generator_name, "root")) {
76 cout << MpdGetNumEvents::GetNumROOTEvents(file_path.c_str(), nullptr, 1);
77 return 0;
78 } else if (generator_name == "auto") {
79 cout << MpdGetNumEvents::GetNumEvents(file_path.c_str(), 1);
80 return 0;
81 } else {
82 cout << "The generator name (or 'root' value) is not defined. See possible values: show_event_count /?";
83 return -2;
84 }
85
86 return 0;
87}
static Int_t GetNumROOTEvents(const char *filename, const char *treename="", int iVerbose=2)
static Int_t GetNumPHSDEvents(const char *filename, int iVerbose=2)
static Int_t GetNumQGSMEvents(const char *fileName, int iVerbose=2)
static Int_t GetNumEvents(const char *filename, int iVerbose=2)
static Int_t GetNumURQMDEvents(const char *fileName, int iVerbose=2)
static Int_t GetNumDCMSMMEvents(const char *fileName, int iVerbose=2)
STL namespace.
int main()
bool ends_with(string const &fullString, string const &ending)