source: branches/start/MagicSoft/Mars/merpp.cc@ 9584

Last change on this file since 9584 was 454, checked in by harald, 24 years ago
Import the first sources of the MAGIC Analysis and Reconstruction Software. T. Bretz and H. Kornmayer 20.December 2000
File size: 3.6 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 (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 cout << "==================================================" << endl ;
36 cout << " MERPP v0.1" << endl;
37 cout << " MARS Merging and Preprocessing Program" << endl ;
38 cout << " Compiled on <" << __DATE__ << ">" << endl ;
39 cout << "==================================================" << endl ;
40 cout << endl;
41
42 //
43 // check for the right usage of the program
44 //
45 if (argc!=3)
46 {
47 cout << "Sorry the usage is:" << endl;
48 cout << " 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 cout << "Sorry, the file '" << argv[1] << "' doesn't exist." << endl;
63 return -1;
64 }
65
66 if (!gSystem->AccessPathName(argv[2], kFileExists))
67 cout << "Warning: The file '" << argv[2] << "' exists." << endl;
68 else
69 if (!gSystem->AccessPathName(argv[2], kWritePermission))
70 {
71 cout << "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.