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

Annotation of /yoda/techmodel/techmodelreader.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.5 - (hide annotations) (download)
Tue Aug 24 13:19:59 2004 UTC (20 years, 3 months ago) by kusanagi
Branch: MAIN
Changes since 1.4: +2 -1 lines
*** empty log message ***

1 kusanagi 1.1
2     #include "log4cpp/Category.hh"
3     #include "log4cpp/PropertyConfigurator.hh"
4     #include "log4cpp/RollingFileAppender.hh"
5     #include "log4cpp/PatternLayout.hh"
6    
7     #include "TROOT.h"
8    
9     #include "TechmodelPamelaRun.h"
10     #include "EventReader.h"
11     #include <fstream>
12     #include <cstdlib>
13     #include <stream.h>
14     #include <time.h>
15     extern "C" {
16     //#include "DirectoryStructure.h"
17     #include <dirent.h>
18     }
19    
20    
21     using namespace pamela;
22     using namespace pamela::techmodel;
23    
24     static log4cpp::Category& cat = log4cpp::Category::getInstance("pamela.techmodel.TechmodelReader");
25    
26     int main(int argc, char* argv[]) {
27    
28     // Check file name
29     if (argc != 2){
30     cat.info("You have forgotten the file name");
31     exit(1);
32     }
33    
34     std::ifstream from (argv[1]);
35     if (!from) cat.info("The file does not exist");
36    
37    
38     /*try {
39     log4cpp::PropertyConfigurator::configure("/home/kusanagi/yoda/techmodel/YodaLog.conf");
40     } catch (log4cpp::ConfigureFailure& f) {
41     std::cerr << "Logging Configure Problem " << f.what() << std::endl;
42     }*/
43    
44    
45     //--------------------------------------------------
46     //This is the configuration for the Yoda Logger
47     //The parameters in the RollingFileAppender means
48     // default ------------>the selected category
49     // YodaLog.txt ------------>the LogFile name
50     // 1000 ------------>The max size (in Kb) of the LogFile
51     // 5 ------------>How many times the file will be backup
52 kusanagi 1.3 char nomeFileLog[L_tmpnam];
53     tmpnam(nomeFileLog);
54     //std::string nomeFileLog = "YodaLog.txt";
55 kusanagi 1.1 log4cpp::Appender* appender;
56     log4cpp::Category& cat = log4cpp::Category::getRoot();
57     DIR *dirp;
58     std::string pathDir((char*)getenv("YODA_DATA"));
59 kusanagi 1.2
60 kusanagi 1.3 //std::string pathLog = pathDir + "/" + nomeFileLog;
61     std::string pathLog = nomeFileLog;
62 kusanagi 1.2 appender = new log4cpp::FileAppender("default", pathLog.c_str(), false);
63 kusanagi 1.1 log4cpp::PatternLayout * pl = new log4cpp::PatternLayout();
64     pl->setConversionPattern("%d{%Y/%m/%d %H:%M:%S.%l} %p %c - %m");
65     appender->setLayout(pl);
66     cat.setAppender(appender);
67 kusanagi 1.3 //cat.setPriority(log4cpp::Priority::DEBUG);
68 kusanagi 1.5 //cat.setPriority(log4cpp::Priority::WARN);
69     cat.setPriority(log4cpp::Priority::INFO);
70 kusanagi 1.1 time_t rawtime;
71     struct tm * timeinfo;
72    
73     time ( &rawtime );
74     timeinfo = localtime ( &rawtime );
75     //--------------------------------------------------
76     cat << log4cpp::Priority::INFO
77     << "<-------------------------------START UNPACKING------------------------------->\n"
78     << " Starting the program at: " << asctime (timeinfo) << " Opening file: " << argv[1]
79     << "\n \n" << log4cpp::CategoryStream::ENDLINE;
80     gROOT->SetBatch(kTRUE);
81    
82     EventReader Reader;
83    
84     int num = 0;
85     TechmodelPamelaRun Run(argv[1]);
86     Reader.Init(&Run);
87     cat << log4cpp::Priority::INFO
88     << "Init successul ok" << asctime (timeinfo) << log4cpp::CategoryStream::ENDLINE;
89     Reader.RunEvent(num); //TBD --- eliminate the runNumber
90     Reader.Finish();
91     Run.WriteFiles();
92     cat << log4cpp::Priority::INFO
93     << "<-------------------------------END UNPACKING------------------------------->"
94     << "\n " << log4cpp::CategoryStream::ENDLINE;
95     log4cpp::Category::shutdown();
96     std::string command;
97 kusanagi 1.3 //command = "mv " + pathLog + " " + pathDir + "/" + Run.GetRun() + "/YodaLog.txt";
98     command = "mv " + pathLog + " " + pathDir + "/" + Run.GetRun() + "/YodaLog.txt";
99 kusanagi 1.1 cat.info(command);
100     system(command.c_str());
101     }

  ViewVC Help
Powered by ViewVC 1.1.23