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

Annotation of /yoda/techmodel/techmodelreader.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.6 - (hide annotations) (download)
Thu Aug 26 08:21:31 2004 UTC (20 years, 3 months ago) by kusanagi
Branch: MAIN
Changes since 1.5: +26 -12 lines
Modified the Data filed from "UINT32*" to "TArrayI*" because the previous doesn't
stored the data (unable to manage UINT32* stream?)

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 kusanagi 1.6
55     DIR *dirp;
56 kusanagi 1.1 std::string pathDir((char*)getenv("YODA_DATA"));
57 kusanagi 1.3 std::string pathLog = nomeFileLog;
58 kusanagi 1.6 log4cpp::Category& root = log4cpp::Category::getRoot();
59     try{
60     std::string initFileName = pathDir + "/log4cpp.conf";
61     log4cpp::PropertyConfigurator::configure(initFileName);
62     } catch (log4cpp::ConfigureFailure& f) {
63     std::cerr << "Could not load log configuration from file: " << f.what() << std::endl
64     << "Using default setup (all msgs to stdout)" << std::endl;
65     log4cpp::Appender* appender;
66     appender = new log4cpp::FileAppender("default", pathLog.c_str(), false);
67     // set a nice layout
68     log4cpp::PatternLayout * pl = new log4cpp::PatternLayout();
69     pl->setConversionPattern("%d{%Y/%m/%d %H:%M:%S.%l} %p %c - %m");
70     appender->setLayout(pl);
71     //log4cpp::Category& cat = log4cpp::Category::getInstance("cat");
72     // remove default appender
73     cat.removeAllAppenders();
74     // use this appender for all categories
75     cat.addAppender(appender);
76    
77     // log messages from all levels.
78     //cat.setPriority(log4cpp::Priority::DEBUG);
79 kusanagi 1.5 //cat.setPriority(log4cpp::Priority::WARN);
80     cat.setPriority(log4cpp::Priority::INFO);
81 kusanagi 1.6 }
82    
83 kusanagi 1.1 time_t rawtime;
84     struct tm * timeinfo;
85    
86     time ( &rawtime );
87     timeinfo = localtime ( &rawtime );
88     //--------------------------------------------------
89 kusanagi 1.6 cat.log(log4cpp::Priority::INFO,"Importance depends on context");
90 kusanagi 1.1 cat << log4cpp::Priority::INFO
91     << "<-------------------------------START UNPACKING------------------------------->\n"
92     << " Starting the program at: " << asctime (timeinfo) << " Opening file: " << argv[1]
93     << "\n \n" << log4cpp::CategoryStream::ENDLINE;
94     gROOT->SetBatch(kTRUE);
95    
96     EventReader Reader;
97    
98     int num = 0;
99     TechmodelPamelaRun Run(argv[1]);
100     Reader.Init(&Run);
101     cat << log4cpp::Priority::INFO
102     << "Init successul ok" << asctime (timeinfo) << log4cpp::CategoryStream::ENDLINE;
103     Reader.RunEvent(num); //TBD --- eliminate the runNumber
104     Reader.Finish();
105     Run.WriteFiles();
106     cat << log4cpp::Priority::INFO
107     << "<-------------------------------END UNPACKING------------------------------->"
108     << "\n " << log4cpp::CategoryStream::ENDLINE;
109     log4cpp::Category::shutdown();
110     std::string command;
111 kusanagi 1.3 //command = "mv " + pathLog + " " + pathDir + "/" + Run.GetRun() + "/YodaLog.txt";
112     command = "mv " + pathLog + " " + pathDir + "/" + Run.GetRun() + "/YodaLog.txt";
113 kusanagi 1.1 cat.info(command);
114     system(command.c_str());
115     }

  ViewVC Help
Powered by ViewVC 1.1.23