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

Last change on this file since 967 was 966, checked in by tbretz, 23 years ago
*** empty log message ***
File size: 4.7 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 << ednl;
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 MRawRunHeader runheader;
96 plist.AddToList(&runheader);
97
98 MRawEvtHeader evtheader;
99 plist.AddToList(&evtheader);
100
101 MRawEvtData evtdata;
102 plist.AddToList(&evtdata);
103
104 MRawCrateArray cratearray;
105 plist.AddToList(&cratearray);
106
107 MTime evttime("MRawEvtTime");
108 plist.AddToList(&evttime);
109*/
110 //
111 // create the tasks which should be executed and add them to the list
112 // in the case you don't need parameter containers, all of them can
113 // be created by MRawFileRead::PreProcess
114 //
115 MRawFileRead reader(kNamein);
116 MRawFileWrite writer(kNameout, "RECREATE", "Magic root-file", kComprlvl);
117 tasks.AddToList(&reader);
118 tasks.AddToList(&writer);
119
120 //
121 // create the looping object and thell it about the parameters to use
122 // and the tasks to execute
123 //
124 MEvtLoop magic;
125 magic.SetParList(&plist);
126
127 //
128 // Start the eventloop which reads the raw file (MRawFileRead) and
129 // write all the information into a root file (MRawFileWrite)
130 //
131 // between reading and writing we can do, transformations, checks, etc.
132 // (I'm think of a task like MRawDataCheck)
133 //
134 if (!magic.Eventloop())
135 {
136 gLog << "ERROR: Merging and preprocessing failed!" << endl;
137 return -1;
138 }
139
140 gLog << "Merpp finished successfull!" << endl;
141 return 0;
142}
143
144
Note: See TracBrowser for help on using the repository browser.