source: tags/Mars-V0.8/merpp.cc@ 17437

Last change on this file since 17437 was 1330, checked in by tbretz, 23 years ago
*** empty log message ***
File size: 5.0 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 [default=9]" << endl << endl;
54 return -1;
55 }
56
57 //
58 // Set verbosity to highest level.
59 //
60 gLog.SetDebugLevel(2);
61
62 //
63 // This is to make argv[i] more readable insidethe code
64 //
65 const char *kNamein = argv[1];
66 const char *kNameout = argv[2];
67 const int kComprlvl = argc==4 ? atoi(argv[3]) : 9;
68
69 //
70 // initialize ROOT (this is obligatory here)
71 //
72 TROOT simple("merpp", "Mars - Merging and Preprocessing Program");
73
74 //
75 // check whether the given files are OK.
76 //
77 if (gSystem->AccessPathName(kNamein, kFileExists))
78 {
79 gLog << "Sorry, the input file '" << kNamein << "' doesn't exist." << endl;
80 return -1;
81 }
82
83 if (!gSystem->AccessPathName(kNameout, kFileExists))
84 gLog << "Warning: A file '" << kNameout << "' exists." << endl;
85 else
86 if (!gSystem->AccessPathName(kNameout, kWritePermission))
87 {
88 gLog << "Sorry, you don't have write permission for '" << kNameout << "'." << endl;
89 return -1;
90 }
91
92 MArray::Class()->IgnoreTObjectStreamer();
93 MParContainer::Class()->IgnoreTObjectStreamer();
94
95 //
96 // create a (empty) list of parameters which can be used by the tasks
97 // and an (empty) list of tasks which should be executed
98 //
99 MParList plist;
100
101 MTaskList tasks;
102 plist.AddToList(&tasks);
103
104 //
105 // ---- Tho following is only necessary to supress some output ----
106 //
107 MRawRunHeader runheader;
108 plist.AddToList(&runheader);
109
110 MRawEvtHeader evtheader;
111 plist.AddToList(&evtheader);
112
113 MRawEvtData evtdata;
114 plist.AddToList(&evtdata);
115
116 MRawCrateArray cratearray;
117 plist.AddToList(&cratearray);
118
119 MTime evttime("MRawEvtTime");
120 plist.AddToList(&evttime);
121
122 //
123 // create the tasks which should be executed and add them to the list
124 // in the case you don't need parameter containers, all of them can
125 // be created by MRawFileRead::PreProcess
126 //
127 MRawFileRead reader(kNamein);
128 MRawFileWrite writer(kNameout, "RECREATE", "Magic root-file", kComprlvl);
129 tasks.AddToList(&reader);
130 tasks.AddToList(&writer);
131
132 //
133 // create the looping object and thell it about the parameters to use
134 // and the tasks to execute
135 //
136 MEvtLoop magic;
137 magic.SetParList(&plist);
138
139 //
140 // Start the eventloop which reads the raw file (MRawFileRead) and
141 // write all the information into a root file (MRawFileWrite)
142 //
143 // between reading and writing we can do, transformations, checks, etc.
144 // (I'm think of a task like MRawDataCheck)
145 //
146 if (!magic.Eventloop())
147 {
148 gLog << "ERROR: Merging and preprocessing failed!" << endl;
149 return -1;
150 }
151
152 gLog << "Merpp finished successfull!" << endl;
153 return 0;
154}
155
156
Note: See TracBrowser for help on using the repository browser.