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