source: tags/Mars-V0.3/merpp.cc@ 10492

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