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

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