source: branches/start/MagicSoft/Mars/readraw.cc@ 8593

Last change on this file since 8593 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: 2.9 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 "MRawRunHeader.h"
14#include "MRawEvtHeader.h"
15#include "MRawEvtData.h"
16#include "MRawCrateArray.h"
17#include "MTime.h"
18#include "MInputStreamID.h"
19
20/////////////////////////////////////////////////////////////////////////////
21//
22// This is an easy implementation of the Merging process (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
47 //
48 // initialize ROOT (this is obligatory here)
49 //
50 TROOT simple("Merpp","Mars - Merging and Preprocessing Program");
51
52 MRawRunHeader *runheader = new MRawRunHeader();
53 MRawEvtHeader *evtheader = new MRawEvtHeader();
54 MTime *evttime = new MTime();
55 MRawEvtData *evtdata = new MRawEvtData();
56 MRawCrateArray *evtcrate = new MRawCrateArray();
57
58 //
59 // open the file
60 //
61 TFile input("delme.root", "READ");
62
63 //
64 // open the Run Header and read in
65 //
66
67 TTree *runtree = (TTree*) input.Get("RunHeaders") ;
68
69 cout << " Entries in Tree RunHeaders: " << dec << runtree->GetEntries() << endl ;
70
71 runtree->GetBranch("MRawRunHeader")->SetAddress(&runheader);
72 runtree->GetEvent(0);
73
74 runheader->Print();
75
76
77 //
78 // open the DataTree and read in
79 //
80 TTree *evttree = (TTree*) input.Get("Data") ;
81
82 //
83 // connnect the branches in that tree
84 //
85 evttree->GetBranch("MRawEvtHeader")->SetAddress(&evtheader);
86 evttree->GetBranch("MTime")->SetAddress(&evttime);
87 evttree->GetBranch("MRawEvtData")->SetAddress(&evtdata);
88 evttree->GetBranch("MRawCrateArray")->SetAddress(&evtcrate);
89
90 Int_t iEnt = (Int_t)evttree->GetEntries();
91 cout << " Entries in Tree Data: " << dec << iEnt << endl;
92
93 for (Int_t i = 0; i<iEnt; i++)
94 {
95 cout << "Entry: " << i << endl;
96
97 // readin event with the selected branches
98 evttree->GetEvent(i);
99
100 evtheader->Print();
101 evttime->Print();
102 evtcrate->Print();
103 evtdata->Print();
104 }
105
106 // end of small readin program
107
108 return 0;
109}
110
111
Note: See TracBrowser for help on using the repository browser.