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

Annotation of /yoda/techmodel/techmodelreader.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 5.1 - (hide annotations) (download)
Sat Feb 4 12:37:45 2006 UTC (18 years, 9 months ago) by kusanagi
Branch: MAIN
Changes since 5.0: +25 -32 lines
Several new features in this release:
a) all the packets are conform to the Mass Memory Format specifications (http://people.roma2.infn.it/~cpu/Mass_Memory_Format.html)
b) unpacking either using the old files structure OR the new one file unpacking.
c) parametrized root files compression factor
d) deleting of the following packet: TofTest, TrkTest, TrkEvent.
e) the Tracker routines now work without the use of temp files.

The point a) allow Yoda to unpack in the root file all the packets generated by the CPU. According to the MassMemoryFormat; that is three possible data are available:

1) almost explicit structure of the packet (like for Log, Tracker, Mcmd, etc....);
2) dummy data collection structure (InitHeader, InitTrailer, CalibHeader, CalibTrailer);
3) just the data of the packet (almost all Alarm and Init procedures). The class regarding this packets have only one parameters, a TArrayC class, which contain the data-block included in the packet (tat is the data below the packet Header).

The point b) has been implemented as a consequence of an agreement about a more compact structure of the unpacked data. Up to now the structure of each unpacked data consisted of a folder, named after the packet type, and three files: xxx.Header.root, xxx.NamePacket.root, xxx.Registry.root.
Starting from this release YODA, by default will unpack the data in a unique root file. The structure of this file will consist of:
- several TTree(s) named after the packet type;
- into each TTree are foreseen three TBranche(s):
    - 'Header'  (the old xxx.Header.root file)
    - 'NameOfThePacket' (the old xxx.Event.root file or the xxx.Event.DETECTOR.root)
    - 'Registry' (the old xxx.Registry.root file)

Anyway is still possible, but deprecated, to unpack using the old structure, passing to the "yoda" command the optional parameter "-multifile"

The point c) has been implemented because is well know that writing time in a TTree is as much fast as much lower is the compression factor for the root file; anyway for a PAMELA dat file, a compression equal to 0 will generate a root file which will be more than two times the original size. To modify the compression parameter just add the optional parameter "-c [0-9]" to the yoda command line.

1 kusanagi 1.1
2 kusanagi 1.7 #include <log4cxx/logger.h>
3     #include <log4cxx/propertyconfigurator.h>
4 kusanagi 1.1 #include "EventReader.h"
5     #include <time.h>
6 kusanagi 2.2
7 kusanagi 1.1 extern "C" {
8 kusanagi 5.1 #include <dirent.h>
9 kusanagi 1.1 }
10    
11    
12 kusanagi 2.1
13 kusanagi 1.1 using namespace pamela;
14 kusanagi 1.7 using namespace log4cxx;
15     using namespace std;
16 kusanagi 1.1 using namespace pamela::techmodel;
17    
18 kusanagi 1.7 static LoggerPtr logger = Logger::getLogger(_T("pamela.techmodel.TechmodelReader"));
19 kusanagi 1.1
20     int main(int argc, char* argv[]) {
21 kusanagi 1.7
22     stringstream oss;
23     int maxPackets = 0;
24 kusanagi 5.1 bool multiFile = 0;
25     short compression = 3;
26 kusanagi 1.7 char nomeFileLog[L_tmpnam];
27     tmpnam(nomeFileLog);
28     DIR *dirp;
29 kusanagi 2.2
30     // check if yoda_DATA exist!!!!
31     char *outDir;
32     try {
33     outDir = getenv("YODA_DATA");
34 kusanagi 2.3 if (getenv("YODA_DATA") == NULL) throw NotFoundEnvironmentVarException("The variable YODA_DATA has not been found.");
35 kusanagi 2.2 } catch (NotFoundEnvironmentVarException exc) {
36 kusanagi 2.4 cout << "The variable YODA_DATA has not been found. \n";
37     cout << "Please check your environment variables \n";
38 kusanagi 2.2 oss.str("");
39     oss << exc.print();
40     logger->fatal(oss.str().c_str());
41 kusanagi 2.3 exit(1);
42 kusanagi 2.2 }
43    
44     string pathDir(outDir);
45    
46 kusanagi 1.7 string pathLog = nomeFileLog;
47 kusanagi 2.1 bool ANALIZE = false;
48 kusanagi 1.7 //---------------- Log4cxx configuration-----------------------------------------------
49     //Define the configuration file to be used on log4cxx
50     PropertyConfigurator::configure(pathDir + "/log4cxx.conf");
51     //BasicConfigurator::configure();
52     //Retrieve the rootLogger and append to it a default FileAppender.
53     //Note that the priority level of the rootLogger (defined in log4cxx.conf) is unmodified
54     //LoggerPtr rootLogger = Logger::getRootLogger();
55    
56     //FileAppender *fileAppender = new FileAppender();
57     //fileAppender->setFile(pathLog);
58     //fileAppender->setAppend(false);
59     //fileAppender->setBufferedIO(true); //the default size is 8k
60     //fileAppender->setBufferSize(1000000);
61     //fileAppender->activateOptions();
62     //fileAppender->setLayout(new PatternLayout());
63    
64     //FileAppender *fileAppender = new FileAppender(new PatternLayout(), pathLog, false, true, 10000);
65     //rootLogger->addAppender(fileAppender);
66     //rootLogger->removeAppender('A1');
67     //---------------- Log4cxx configuration-----------------------------------------------
68    
69 kusanagi 1.1 // Check file name
70 kusanagi 1.7
71     if (argc < 2){
72     //logger->info(_T("You have forgotten the file name."));
73     cout << "You have forgotten the file name. \n";
74     cout << "Try '--help' for more information. \n";
75     exit(1);
76     }
77    
78     if (!strcmp(argv[1], "--help")){
79     cout << "Usage: yoda FILE [OPTION] \n";
80     cout << "\t --help print this help and exit \n";
81     cout << "\t -p maximum number of packets to process [default all] \n";
82 kusanagi 5.1 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 kusanagi 1.7 exit(1);
85     }
86    
87     ifstream from (argv[1]);
88     if (!from) {
89     //logger->info(_T("The file does not exist."));
90     cout << "The file does not exist. \n";
91 kusanagi 1.1 exit(1);
92     }
93    
94 kusanagi 1.7 for (int i = 2; i < argc; i++){
95     if (!strcmp(argv[i], "-p")){
96     if (++i >= argc){
97     cerr << "-p needs arguments. \n";
98     cout << "Try '--help' for more information. \n";
99     exit(1);
100     }
101 kusanagi 5.1 if (isdigit(*argv[i]) && (atoi(argv[i]) > 0)) {
102 kusanagi 1.7 maxPackets = atoi(argv[i]);
103     } else {
104     //logger->info(_T("The file does not exist."));
105     cerr << "-p needs a integer value. \n";
106     cout << "Try '--help' for more information. \n";
107     exit(1);
108     }
109 kusanagi 5.1 continue;
110 kusanagi 1.7 }
111    
112 kusanagi 5.1 if (!strcmp(argv[i], "-multifile")) multiFile = 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 kusanagi 1.7 }
130     }
131 kusanagi 1.6
132 kusanagi 1.1 time_t rawtime;
133     struct tm * timeinfo;
134     time ( &rawtime );
135     timeinfo = localtime ( &rawtime );
136 kusanagi 1.7
137 kusanagi 2.1 oss.str("");
138 kusanagi 1.7 oss << "<-------------------------------START UNPACKING------------------------------->\n"
139     << " Starting the program at: " << asctime (timeinfo) << " Opening file: " << argv[1];
140     logger->info(oss.str().c_str());
141    
142    
143 kusanagi 1.1 gROOT->SetBatch(kTRUE);
144 kusanagi 1.7 EventReader *reader = new EventReader(maxPackets);
145 kusanagi 1.1
146     int num = 0;
147 kusanagi 5.1 TechmodelPamelaRun Run(argv[1], outDir, multiFile, compression);
148 kusanagi 1.7 reader->Init(&Run);
149    
150 kusanagi 2.1 oss.str("");
151 kusanagi 1.7 oss << "Init successul ok" << asctime (timeinfo);
152     logger->debug(oss.str().c_str());
153    
154     reader->RunEvent(num); //TBD --- eliminate the runNumber
155     reader->Finish();
156 kusanagi 1.1 Run.WriteFiles();
157 kusanagi 1.7
158     logger->info("<-------------------------------END UNPACKING------------------------------->\n");
159    
160     //Momentarly suspended the save
161     //system(command.c_str());
162 kusanagi 1.1 }

  ViewVC Help
Powered by ViewVC 1.1.23