source: trunk/MagicSoft/Mars/merpp.cc@ 1064

Last change on this file since 1064 was 1058, checked in by tbretz, 23 years ago
*** empty log message ***
File size: 4.9 KB
Line 
1#include <TSystem.h>
2
3#include "MParList.h"
4#include "MTaskList.h"
5#include "MEvtLoop.h"
6
7#include "MRawFileRead.h"
8#include "MRawFileWrite.h"
9
10#include "MLog.h"
11#include "MTime.h"
12#include "MArray.h"
13#include "MRawEvtData.h"
14#include "MRawRunHeader.h"
15#include "MRawEvtHeader.h"
16#include "MRawCrateArray.h"
17#include "MInputStreamID.h"
18
19//////////////////////////////////////////////////////////////////////////////
20// //
21// This is an easy implementation of the Merging process //
22// (as compilable prog) //
23// //
24// at the moment it reads a binary file ("rawtest.bin") which was written //
25// in the DAQ raw format. //
26// //
27// The data are stored in root container objects (classes derived from //
28// TObject like MRawRunHeader) //
29// //
30// This containers are written to a root file ("rawtest.root") //
31// //
32//////////////////////////////////////////////////////////////////////////////
33
34int main(const int argc, const char **argv)
35{
36 gLog << "==================================================" << endl ;
37 gLog << " MERPP v0.1" << endl;
38 gLog << " MARS Merging and Preprocessing Program" << endl ;
39 gLog << " Compiled on <" << __DATE__ << ">" << endl ;
40 gLog << " Using ROOT v" << ROOTVER << endl ;
41 gLog << "==================================================" << endl ;
42 gLog << endl;
43
44 //
45 // check for the right usage of the program
46 //
47 if (argc<3 || argc>4)
48 {
49 gLog << "Sorry the usage is:" << endl;
50 gLog << " merpp inputfile outputfile [compression level]" << endl << endl;
51 gLog << " input file: Magic DAQ binary file." << endl;
52 gLog << " ouput file: Merpped root file." << endl;
53 gLog << " compr. level: 1..9 [9]" << endl << endl;
54 return -1;
55 }
56
57 //
58 // This is to make argv[i] more readable insidethe code
59 //
60 const char *kNamein = argv[1];
61 const char *kNameout = argv[2];
62 const int kComprlvl = argc==4 ? atoi(argv[3]) : 9;
63
64 //
65 // initialize ROOT (this is obligatory here)
66 //
67 TROOT simple("merpp", "Mars - Merging and Preprocessing Program");
68
69 //
70 // check whether the given files are OK.
71 //
72 if (gSystem->AccessPathName(kNamein, kFileExists))
73 {
74 gLog << "Sorry, the input file '" << kNamein << "' doesn't exist." << endl;
75 return -1;
76 }
77
78 if (!gSystem->AccessPathName(kNameout, kFileExists))
79 gLog << "Warning: A file '" << kNameout << "' exists." << endl;
80 else
81 if (!gSystem->AccessPathName(kNameout, kWritePermission))
82 {
83 gLog << "Sorry, you don't have write permission for '" << kNameout << "'." << endl;
84 return -1;
85 }
86
87 MArray::Class()->IgnoreTObjectStreamer();
88 MParContainer::Class()->IgnoreTObjectStreamer();
89
90 //
91 // create a (empty) list of parameters which can be used by the tasks
92 // and an (empty) list of tasks which should be executed
93 //
94 MParList plist;
95
96 MTaskList tasks;
97 plist.AddToList(&tasks);
98
99 //
100 // ---- Tho following is only necessary to supress some output ----
101 //
102 MRawRunHeader runheader;
103 plist.AddToList(&runheader);
104
105 MRawEvtHeader evtheader;
106 plist.AddToList(&evtheader);
107
108 MRawEvtData evtdata;
109 plist.AddToList(&evtdata);
110
111 MRawCrateArray cratearray;
112 plist.AddToList(&cratearray);
113
114 MTime evttime("MRawEvtTime");
115 plist.AddToList(&evttime);
116
117 //
118 // create the tasks which should be executed and add them to the list
119 // in the case you don't need parameter containers, all of them can
120 // be created by MRawFileRead::PreProcess
121 //
122 MRawFileRead reader(kNamein);
123 MRawFileWrite writer(kNameout, "RECREATE", "Magic root-file", kComprlvl);
124 tasks.AddToList(&reader);
125 tasks.AddToList(&writer);
126
127 //
128 // create the looping object and thell it about the parameters to use
129 // and the tasks to execute
130 //
131 MEvtLoop magic;
132 magic.SetParList(&plist);
133
134 //
135 // Start the eventloop which reads the raw file (MRawFileRead) and
136 // write all the information into a root file (MRawFileWrite)
137 //
138 // between reading and writing we can do, transformations, checks, etc.
139 // (I'm think of a task like MRawDataCheck)
140 //
141 if (!magic.Eventloop())
142 {
143 gLog << "ERROR: Merging and preprocessing failed!" << endl;
144 return -1;
145 }
146
147 gLog << "Merpp finished successfull!" << endl;
148 return 0;
149}
150
151
Note: See TracBrowser for help on using the repository browser.