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

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