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

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