source: trunk/MagicSoft/Mars/readraw.cc@ 531

Last change on this file since 531 was 463, checked in by harald, 24 years ago
The first implementation of a gui to test the data of Octobertest was implemented. Therefore the two subdirs mgui and mdatacheck were introduced. The program for the gui is called -> mars <-.
File size: 3.0 KB
Line 
1#include <iostream.h>
2
3#include <TSystem.h>
4
5#include "TFile.h"
6#include "TTree.h"
7#include "TBranch.h"
8
9#include "MParList.h"
10#include "MTaskList.h"
11#include "MEvtLoop.h"
12
13#include "MTime.h"
14#include "MRawRunHeader.h"
15#include "MRawEvtHeader.h"
16#include "MRawEvtData.h"
17#include "MRawCrateArray.h"
18#include "MInputStreamID.h"
19
20#include "MGMarsMain.h"
21
22/////////////////////////////////////////////////////////////////////////////
23//
24// This is an demonstration how to read in a merpped root file
25//
26/////////////////////////////////////////////////////////////////////////////
27
28int main(const int argc, const char **argv)
29{
30 cout << "==================================================" << endl ;
31 cout << " ReadRaw v0.1" << endl;
32 cout << " MARS Merging and Preprocessing Program" << endl ;
33 cout << " Compiled on <" << __DATE__ << ">" << endl ;
34 cout << "==================================================" << endl ;
35 cout << endl;
36
37 //
38 // check for the right usage of the program
39 //
40 if (argc!=2)
41 {
42 cout << "Sorry the usage is:" << endl;
43 cout << " readraw inputfile" << endl << endl;
44 return -1;
45 }
46
47 //
48 // initialize ROOT (this is obligatory here)
49 //
50 TROOT simple("Readraw","Mars - Merging and Preprocessing Program");
51
52 //
53 // check whether the given files are OK.
54 //
55 if (gSystem->AccessPathName(argv[1], kFileExists))
56 {
57 cout << "Sorry, the file '" << argv[1] << "' doesn't exist." << endl;
58 return -1;
59 }
60
61 MRawRunHeader *runheader = new MRawRunHeader();
62 MRawEvtHeader *evtheader = new MRawEvtHeader();
63 MTime *evttime = new MTime();
64 MRawEvtData *evtdata = new MRawEvtData();
65 MRawCrateArray *evtcrate = new MRawCrateArray();
66
67 //
68 // open the file
69 //
70 TFile input(argv[1], "READ");
71
72 //
73 // open the Run Header and read in
74 //
75
76 TTree *runtree = (TTree*) input.Get("RunHeaders") ;
77
78 cout << " Entries in Tree RunHeaders: " << dec << runtree->GetEntries() << endl ;
79
80 runtree->GetBranch("MRawRunHeader")->SetAddress(&runheader);
81 runtree->GetEvent(0);
82
83 runheader->Print();
84
85
86 //
87 // open the DataTree and read in
88 //
89 TTree *evttree = (TTree*) input.Get("Data") ;
90
91 //
92 // connnect the branches in that tree
93 //
94 evttree->GetBranch("MRawEvtHeader")->SetAddress(&evtheader);
95 evttree->GetBranch("MTime")->SetAddress(&evttime);
96 evttree->GetBranch("MRawEvtData")->SetAddress(&evtdata);
97 evttree->GetBranch("MRawCrateArray")->SetAddress(&evtcrate);
98
99 Int_t nent = (Int_t)evttree->GetEntries();
100 cout << " Entries in Tree Data: " << dec << nent << endl;
101
102 for (Int_t i = 0; i<nent; i++)
103 {
104 cout << "Entry: " << i << endl;
105
106 // readin event with the selected branches
107 evttree->GetEvent(i);
108
109 evtheader->Print();
110 evttime->Print();
111 evtcrate->Print();
112 evtdata->Print();
113 }
114
115 // end of small readin program
116
117 return 0;
118}
119
120
Note: See TracBrowser for help on using the repository browser.