/[PAMELA software]/yoda/techmodel/techmodelreader.cpp
ViewVC logotype

Diff of /yoda/techmodel/techmodelreader.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 4.0.8.3 by kusanagi, Tue Apr 4 13:31:55 2006 UTC revision 5.1 by kusanagi, Sat Feb 4 12:37:45 2006 UTC
# Line 1  Line 1 
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    
# Line 34  int main(int argc, char* argv[]) { Line 21  int main(int argc, char* argv[]) {
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;
# Line 55  int main(int argc, char* argv[]) { Line 44  int main(int argc, char* argv[]) {
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");
# Line 81  int main(int argc, char* argv[]) { Line 71  int main(int argc, char* argv[]) {
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."));
# Line 108  int main(int argc, char* argv[]) { Line 95  int main(int argc, char* argv[]) {
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;
# Line 153  int main(int argc, char* argv[]) { Line 144  int main(int argc, char* argv[]) {
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("");
# Line 169  int main(int argc, char* argv[]) { Line 160  int main(int argc, char* argv[]) {
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 "$Revision$";  
 }  

Legend:
Removed from v.4.0.8.3  
changed lines
  Added in v.5.1

  ViewVC Help
Powered by ViewVC 1.1.23