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

Contents of /yoda/techmodel/techmodelreader.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.3 - (show annotations) (download)
Thu Aug 19 15:24:46 2004 UTC (20 years, 3 months ago) by kusanagi
Branch: MAIN
Changes since 1.2: +9 -5 lines
*** empty log message ***

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 char nomeFileLog[L_tmpnam];
53 tmpnam(nomeFileLog);
54 //std::string nomeFileLog = "YodaLog.txt";
55 log4cpp::Appender* appender;
56 log4cpp::Category& cat = log4cpp::Category::getRoot();
57 DIR *dirp;
58 std::string pathDir((char*)getenv("YODA_DATA"));
59
60 //std::string pathLog = pathDir + "/" + nomeFileLog;
61 std::string pathLog = nomeFileLog;
62 appender = new log4cpp::FileAppender("default", pathLog.c_str(), false);
63 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 //cat.setPriority(log4cpp::Priority::DEBUG);
68 cat.setPriority(log4cpp::Priority::INFO);
69 time_t rawtime;
70 struct tm * timeinfo;
71
72 time ( &rawtime );
73 timeinfo = localtime ( &rawtime );
74 //--------------------------------------------------
75 cat << log4cpp::Priority::INFO
76 << "<-------------------------------START UNPACKING------------------------------->\n"
77 << " Starting the program at: " << asctime (timeinfo) << " Opening file: " << argv[1]
78 << "\n \n" << log4cpp::CategoryStream::ENDLINE;
79 gROOT->SetBatch(kTRUE);
80
81 EventReader Reader;
82
83 int num = 0;
84 TechmodelPamelaRun Run(argv[1]);
85 Reader.Init(&Run);
86 cat << log4cpp::Priority::INFO
87 << "Init successul ok" << asctime (timeinfo) << log4cpp::CategoryStream::ENDLINE;
88 Reader.RunEvent(num); //TBD --- eliminate the runNumber
89 Reader.Finish();
90 Run.WriteFiles();
91 cat << log4cpp::Priority::INFO
92 << "<-------------------------------END UNPACKING------------------------------->"
93 << "\n " << log4cpp::CategoryStream::ENDLINE;
94 log4cpp::Category::shutdown();
95 std::string command;
96 //command = "mv " + pathLog + " " + pathDir + "/" + Run.GetRun() + "/YodaLog.txt";
97 command = "mv " + pathLog + " " + pathDir + "/" + Run.GetRun() + "/YodaLog.txt";
98 cat.info(command);
99 system(command.c_str());
100 }

  ViewVC Help
Powered by ViewVC 1.1.23