1 |
|
|
2 |
#include <log4cxx/logger.h> |
#include <log4cxx/logger.h> |
|
#include <log4cxx/basicconfigurator.h> |
|
|
#include <log4cxx/fileappender.h> |
|
|
#include <log4cxx/patternlayout.h> |
|
3 |
#include <log4cxx/propertyconfigurator.h> |
#include <log4cxx/propertyconfigurator.h> |
|
#include <log4cxx/helpers/exception.h> |
|
|
|
|
|
#include "TROOT.h" |
|
|
|
|
|
#include "TechmodelPamelaRun.h" |
|
4 |
#include "EventReader.h" |
#include "EventReader.h" |
|
|
|
|
#include <cstdlib> |
|
|
#include <iostream> |
|
5 |
#include <time.h> |
#include <time.h> |
|
#include "Exception.h" |
|
6 |
|
|
7 |
extern "C" { |
extern "C" { |
8 |
//#include "DirectoryStructure.h" |
#include <dirent.h> |
|
#include <dirent.h> |
|
9 |
} |
} |
10 |
|
|
11 |
|
|
21 |
|
|
22 |
stringstream oss; |
stringstream oss; |
23 |
int maxPackets = 0; |
int maxPackets = 0; |
24 |
|
bool multiFile = 0; |
25 |
|
short compression = 3; |
26 |
char nomeFileLog[L_tmpnam]; |
char nomeFileLog[L_tmpnam]; |
27 |
tmpnam(nomeFileLog); |
tmpnam(nomeFileLog); |
28 |
DIR *dirp; |
DIR *dirp; |
44 |
string pathDir(outDir); |
string pathDir(outDir); |
45 |
|
|
46 |
string pathLog = nomeFileLog; |
string pathLog = nomeFileLog; |
47 |
|
bool ANALIZE = false; |
48 |
//---------------- Log4cxx configuration----------------------------------------------- |
//---------------- Log4cxx configuration----------------------------------------------- |
49 |
//Define the configuration file to be used on log4cxx |
//Define the configuration file to be used on log4cxx |
50 |
PropertyConfigurator::configure(pathDir + "/log4cxx.conf"); |
PropertyConfigurator::configure(pathDir + "/log4cxx.conf"); |
71 |
if (argc < 2){ |
if (argc < 2){ |
72 |
//logger->info(_T("You have forgotten the file name.")); |
//logger->info(_T("You have forgotten the file name.")); |
73 |
cout << "You have forgotten the file name. \n"; |
cout << "You have forgotten the file name. \n"; |
74 |
cout << "Try '-help' for more information. \n"; |
cout << "Try '--help' for more information. \n"; |
75 |
exit(1); |
exit(1); |
76 |
} |
} |
77 |
|
|
78 |
if (!strcmp(argv[1], "-help")){ |
if (!strcmp(argv[1], "--help")){ |
79 |
cout << "Usage: yoda FILE [OPTION] \n"; |
cout << "Usage: yoda FILE [OPTION] \n"; |
80 |
cout << "\t -help print this help and exit \n"; |
cout << "\t --help print this help and exit \n"; |
81 |
cout << "\t -p maximum number of packets to process [default all] \n"; |
cout << "\t -p maximum number of packets to process [default all] \n"; |
82 |
|
cout << "\t -m generate multiple root files. Values: {'true', 'false'} [default = 'false']\n"; |
83 |
|
cout << "\t -c set the compression level for the generated root files. Values: [0,9] [default = 3]\n"; |
84 |
exit(1); |
exit(1); |
85 |
} |
} |
86 |
|
|
|
if (!strcmp(argv[1], "-version")){ |
|
|
cout << GetVersionInfo() << "\n"; |
|
|
exit(1); |
|
|
} |
|
|
|
|
87 |
ifstream from (argv[1]); |
ifstream from (argv[1]); |
88 |
if (!from) { |
if (!from) { |
89 |
//logger->info(_T("The file does not exist.")); |
//logger->info(_T("The file does not exist.")); |
95 |
if (!strcmp(argv[i], "-p")){ |
if (!strcmp(argv[i], "-p")){ |
96 |
if (++i >= argc){ |
if (++i >= argc){ |
97 |
cerr << "-p needs arguments. \n"; |
cerr << "-p needs arguments. \n"; |
98 |
cout << "Try '-help' for more information. \n"; |
cout << "Try '--help' for more information. \n"; |
99 |
exit(1); |
exit(1); |
100 |
} |
} |
101 |
if (isdigit(*argv[i])) { |
if (isdigit(*argv[i]) && (atoi(argv[i]) > 0)) { |
102 |
maxPackets = atoi(argv[i]); |
maxPackets = atoi(argv[i]); |
103 |
} else { |
} else { |
104 |
//logger->info(_T("The file does not exist.")); |
//logger->info(_T("The file does not exist.")); |
105 |
cerr << "-p needs a integer value. \n"; |
cerr << "-p needs a integer value. \n"; |
106 |
cout << "Try '-help' for more information. \n"; |
cout << "Try '--help' for more information. \n"; |
107 |
exit(1); |
exit(1); |
108 |
} |
} |
109 |
|
continue; |
110 |
} |
} |
111 |
|
|
112 |
if (!maxPackets){ |
if (!strcmp(argv[i], "-multifile")) multiFile = 1; |
|
cout << "Try '-help' for more information. \n"; |
|
|
exit(1); |
|
|
} |
|
|
|
|
113 |
|
|
114 |
|
if (!strcmp(argv[i], "-c")){ |
115 |
|
if (++i >= argc){ |
116 |
|
cerr << "-c needs arguments. \n"; |
117 |
|
cout << "Try '--help' for more information. \n"; |
118 |
|
exit(1); |
119 |
|
} |
120 |
|
if ((isdigit(*argv[i])) && ( (atoi(argv[i]) >= 0) && (atoi(argv[i]) <= 9))) { |
121 |
|
compression = atoi(argv[i]); |
122 |
|
} else { |
123 |
|
//logger->info(_T("The file does not exist.")); |
124 |
|
cerr << "-c needs a integer value beetween 0 and 9. \n"; |
125 |
|
cout << "Try '--help' for more information. \n"; |
126 |
|
exit(1); |
127 |
|
} |
128 |
|
continue; |
129 |
|
} |
130 |
} |
} |
|
|
|
|
|
|
|
//-------------------------------------------------- |
|
|
//This is the configuration for the Yoda Logger |
|
|
//The parameters in the RollingFileAppender means |
|
|
// default ------------>the selected category |
|
|
// YodaLog.txt ------------>the LogFile name |
|
|
// 1000 ------------>The max size (in Kb) of the LogFile |
|
|
// 5 ------------>How many times the file will be backup |
|
131 |
|
|
132 |
time_t rawtime; |
time_t rawtime; |
133 |
struct tm * timeinfo; |
struct tm * timeinfo; |
144 |
EventReader *reader = new EventReader(maxPackets); |
EventReader *reader = new EventReader(maxPackets); |
145 |
|
|
146 |
int num = 0; |
int num = 0; |
147 |
TechmodelPamelaRun Run(argv[1]); |
TechmodelPamelaRun Run(argv[1], outDir, multiFile, compression); |
148 |
reader->Init(&Run); |
reader->Init(&Run); |
149 |
|
|
150 |
oss.str(""); |
oss.str(""); |
160 |
//Momentarly suspended the save |
//Momentarly suspended the save |
161 |
//system(command.c_str()); |
//system(command.c_str()); |
162 |
} |
} |
|
|
|
|
/** |
|
|
* Get a string with the version info of the algorithm. |
|
|
*/ |
|
|
const char* GetVersionInfo(void) const { |
|
|
return "$Name$ $Revision$"; |
|
|
} |
|