source: tags/Mars-V0.9.4.2/readdaq.cc@ 15495

Last change on this file since 15495 was 7091, checked in by tbretz, 20 years ago
*** empty log message ***
File size: 5.0 KB
Line 
1#include <TSystem.h>
2
3#include "MParList.h"
4#include "MTaskList.h"
5#include "MEvtLoop.h"
6
7#include "MLog.h"
8#include "MLogManip.h"
9
10#include "MArgs.h"
11#include "MTime.h"
12#include "MPrint.h"
13#include "MRawRunHeader.h"
14#include "MRawEvtHeader.h"
15#include "MRawEvtData.h"
16#include "MRawCrateArray.h"
17#include "MRawFileRead.h"
18
19
20//#include "MInputStreamID.h"
21//#include "MMcEvt.hxx"
22//#include "MMcTrig.hxx"
23
24using namespace std;
25
26/////////////////////////////////////////////////////////////////////////////
27//
28// This is an demonstration how to read in a unmerpped daq file
29//
30/////////////////////////////////////////////////////////////////////////////
31
32static void StartUpMessage()
33{
34 gLog << all << endl;
35
36 // 1 2 3 4 5
37 // 12345678901234567890123456789012345678901234567890
38 gLog << "==================================================" << endl;
39 gLog << " ReadDaq - MARS V" << MARSVER << endl;
40 gLog << " MARS - Read and print daq data files" << endl;
41 gLog << " Compiled with ROOT v" << ROOTVER << " on <" << __DATE__ ">" << endl;
42 gLog << "==================================================" << endl;
43 gLog << endl;
44}
45
46static void Usage()
47{
48 gLog << all << endl;
49 gLog << "Sorry the usage is:" << endl;
50 gLog << " readdaq [-h] [-?] [-vn] [-dec] [-a0] inputfile[.raw]" << endl << endl;
51 gLog << " input file: Magic DAQ binary file." << endl;
52 gLog.Usage();
53 gLog << " -d1: print data in decimal values" << endl;
54 gLog << " -c1: print MRawCrateArray data" << endl;
55 gLog << " -?, -h, --help: This help" << endl << endl;
56}
57
58int main(int argc, char **argv)
59{
60 //
61 // Evaluate arguments
62 //
63 MArgs arg(argc, argv);
64 gLog.Setup(arg);
65
66 StartUpMessage();
67
68 if (arg.HasOnly("-?") || arg.HasOnly("-h") || arg.HasOnly("--help"))
69 {
70 Usage();
71 return 2;
72 }
73
74 //
75 // Set verbosity to highest level.
76 //
77 const bool kDecimal = arg.HasOption("-d") && arg.GetIntAndRemove("-d")==1;
78 const bool kPrintArray = arg.HasOption("-c") && arg.GetIntAndRemove("-c")==1;
79
80 //
81 // check for the right usage of the program
82 //
83 if (arg.GetNumArguments()!=1)
84 {
85 Usage();
86 return 2;
87 }
88
89 //
90 // This is to make argv[i] more readable insidethe code
91 //
92 TString kNamein = arg.GetArgumentStr(0);
93
94 if (!kNamein.EndsWith(".raw"))
95 kNamein += ".raw";
96
97 //
98 // Initialize Non-GUI (batch) mode
99 //
100 gROOT->SetBatch();
101
102 //
103 // check whether the given files are OK.
104 //
105 if (gSystem->AccessPathName(kNamein, kFileExists))
106 {
107 gLog << err << "Sorry, the input file '" << kNamein << "' doesn't exist." << endl;
108 return 2;
109 }
110
111 //
112 // open the file
113 //
114 gLog << " Open the file '" << kNamein << "'" << endl;
115
116
117 //
118 // create a (empty) list of parameters which can be used by the tasks
119 // and an (empty) list of tasks which should be executed
120 //
121 MParList plist;
122
123 MTaskList tasks;
124 tasks.SetOwner();
125 plist.AddToList(&tasks);
126
127 //
128 // ---- The following is only necessary to supress some output ----
129 //
130 MRawRunHeader runheader;
131 plist.AddToList(&runheader);
132
133 MRawEvtHeader evtheader;
134 plist.AddToList(&evtheader);
135
136 MRawEvtData evtdata;
137 plist.AddToList(&evtdata);
138
139 MRawEvtData evtdata2("MRawEvtData2");
140 plist.AddToList(&evtdata2);
141
142 MRawCrateArray cratearray;
143 plist.AddToList(&cratearray);
144
145 MTime evttime;
146 plist.AddToList(&evttime);
147
148 //
149 // create the tasks which should be executed and add them to the list
150 // in the case you don't need parameter containers, all of them can
151 // be created by MRawFileRead::PreProcess
152 //
153 MRawFileRead read(kNamein);
154 tasks.AddToList(&read);
155
156 MPrint print0;
157 MPrint print1("MRawEvtHeader", "nogains", "PrintEvtHeader");
158 MPrint print2("MTime", "", "PrintTime");
159 MPrint print3("MRawCrateArray", "", "PrintCrateArray");
160 MPrint print4("MRawEvtData", kDecimal?"dec":"hex", "PrintEvtData");
161 MPrint print5("MRawEvtData2", kDecimal?"dec":"hex", "PrintEvtData2");
162
163 tasks.AddToList(&print0);
164 tasks.AddToList(&print1);
165 tasks.AddToList(&print2);
166 if (kPrintArray)
167 tasks.AddToList(&print3);
168 tasks.AddToList(&print4);
169 tasks.AddToList(&print5);
170
171 //
172 // create the looping object and tell it about the parameters to use
173 // and the tasks to execute
174 //
175 MEvtLoop magic;
176 magic.SetParList(&plist);
177
178 //
179 // Start the eventloop which reads the raw file (MRawFileRead) and
180 // write all the information into a root file (MRawFileWrite)
181 //
182 // between reading and writing we can do, transformations, checks, etc.
183 // (I'm think of a task like MRawDataCheck)
184 //
185 if (!magic.Eventloop())
186 {
187 gLog << err << "ERROR: Reading DAQ file failed!" << endl;
188 return 2;
189 }
190
191 gLog << all << "Reading DAQ file finished successfull!" << endl;
192
193 // end of small readin program
194
195 return 0;
196}
Note: See TracBrowser for help on using the repository browser.