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

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