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

Last change on this file since 457 was 456, checked in by tbretz, 24 years ago
2000/12/23: Thomas Bretz, changes see Changelog. 2000/12/23: Thomas Bretz, changes see Changelog. 2000/12/23: Thomas Bretz, changes see Changelog. 2000/12/23: Thomas Bretz, changes see Changelog. 2000/12/23: Thomas Bretz, changes see Changelog. 2000/12/23: Thomas Bretz, changes see Changelog. 2000/12/23: Thomas Bretz, changes see Changelog. 2000/12/23: Thomas Bretz, changes see Changelog. 2000/12/23: Thomas Bretz, changes see Changelog. 2000/12/23: Thomas Bretz, changes see Changelog. 2000/12/23: Thomas Bretz, changes see Changelog. 2000/12/23: Thomas Bretz, changes see Changelog. 2000/12/23: Thomas Bretz, changes see Changelog. 2000/12/23: Thomas Bretz, changes see Changelog. 2000/12/23: Thomas Bretz, changes see Changelog. 2000/12/23: Thomas Bretz, changes see Changelog. 2000/12/23: Thomas Bretz, changes see Changelog. 2000/12/23: Thomas Bretz, changes see Changelog. 2000/12/23: Thomas Bretz, changes see Changelog. 2000/12/23: Thomas Bretz, changes see Changelog.
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/////////////////////////////////////////////////////////////////////////////
21//
22// This is an demonstration how to read in a merpped root file
23//
24/////////////////////////////////////////////////////////////////////////////
25
26int main(const int argc, const char **argv)
27{
28 cout << "==================================================" << endl ;
29 cout << " ReadRaw v0.1" << endl;
30 cout << " MARS Merging and Preprocessing Program" << endl ;
31 cout << " Compiled on <" << __DATE__ << ">" << endl ;
32 cout << "==================================================" << endl ;
33 cout << endl;
34
35 //
36 // check for the right usage of the program
37 //
38 if (argc!=2)
39 {
40 cout << "Sorry the usage is:" << endl;
41 cout << " readraw inputfile" << endl << endl;
42 return -1;
43 }
44
45 //
46 // initialize ROOT (this is obligatory here)
47 //
48 TROOT simple("Readraw","Mars - Merging and Preprocessing Program");
49
50 //
51 // check whether the given files are OK.
52 //
53 if (gSystem->AccessPathName(argv[1], kFileExists))
54 {
55 cout << "Sorry, the file '" << argv[1] << "' doesn't exist." << endl;
56 return -1;
57 }
58
59 MRawRunHeader *runheader = new MRawRunHeader();
60 MRawEvtHeader *evtheader = new MRawEvtHeader();
61 MTime *evttime = new MTime();
62 MRawEvtData *evtdata = new MRawEvtData();
63 MRawCrateArray *evtcrate = new MRawCrateArray();
64
65 //
66 // open the file
67 //
68 TFile input("delme.root", "READ");
69
70 //
71 // open the Run Header and read in
72 //
73
74 TTree *runtree = (TTree*) input.Get("RunHeaders") ;
75
76 cout << " Entries in Tree RunHeaders: " << dec << runtree->GetEntries() << endl ;
77
78 runtree->GetBranch("MRawRunHeader")->SetAddress(&runheader);
79 runtree->GetEvent(0);
80
81 runheader->Print();
82
83
84 //
85 // open the DataTree and read in
86 //
87 TTree *evttree = (TTree*) input.Get("Data") ;
88
89 //
90 // connnect the branches in that tree
91 //
92 evttree->GetBranch("MRawEvtHeader")->SetAddress(&evtheader);
93 evttree->GetBranch("MTime")->SetAddress(&evttime);
94 evttree->GetBranch("MRawEvtData")->SetAddress(&evtdata);
95 evttree->GetBranch("MRawCrateArray")->SetAddress(&evtcrate);
96
97 Int_t nent = (Int_t)evttree->GetEntries();
98 cout << " Entries in Tree Data: " << dec << nent << endl;
99
100 for (Int_t i = 0; i<nent; i++)
101 {
102 cout << "Entry: " << i << endl;
103
104 // readin event with the selected branches
105 evttree->GetEvent(i);
106
107 evtheader->Print();
108 evttime->Print();
109 evtcrate->Print();
110 evtdata->Print();
111 }
112
113 // end of small readin program
114
115 return 0;
116}
117
118
Note: See TracBrowser for help on using the repository browser.