source: branches/Mars_McMismatchStudy/macros/tutorials/readraw.C@ 18237

Last change on this file since 18237 was 7159, checked in by tbretz, 19 years ago
*** empty log message ***
File size: 2.7 KB
Line 
1/* ======================================================================== *\
2!
3! *
4! * This file is part of MARS, the MAGIC Analysis and Reconstruction
5! * Software. It is distributed to you in the hope that it can be a useful
6! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
7! * It is distributed WITHOUT ANY WARRANTY.
8! *
9! * Permission to use, copy, modify and distribute this software and its
10! * documentation for any purpose is hereby granted without fee,
11! * provided that the above copyright notice appear in all copies and
12! * that both that copyright notice and this permission notice appear
13! * in supporting documentation. It is provided "as is" without express
14! * or implied warranty.
15! *
16!
17!
18! Author(s): Thomas Bretz 12/2000 <mailto:tbretz@astro.uni-wuerzburg.de>
19!
20! Copyright: MAGIC Software Development, 2000-2004
21!
22!
23\* ======================================================================== */
24
25
26void readraw(const char *fname="/data/MAGIC/Period016/mcdata/spot_1cm/standard/gamma/Gamma_zbin9_90_7_1740to1749_w0.root")
27{
28 //
29 // open the file
30 //
31 TFile input(fname, "READ");
32
33 //
34 // open the Run Header tree
35 //
36 TTree *runtree = (TTree*) input.Get("RunHeaders") ;
37
38 if (!runtree)
39 return;
40
41 cout << " Entries in Tree RunHeaders: " << runtree->GetEntries() << endl ;
42
43 //
44 // create an instance of MRawRunHeader, enable the branch and
45 // read the header, print it
46 //
47 MRawRunHeader *runheader = new MRawRunHeader();
48 runtree->GetBranch("MRawRunHeader.")->SetAddress(&runheader);
49 runtree->GetEvent(0);
50 runheader->Print();
51
52 //
53 // open the Data Tree
54 //
55 TTree *evttree = (TTree*) input.Get("Events");
56
57 //
58 // create the instances of the data to read in
59 //
60 MRawEvtHeader *evtheader = 0;
61 MTime *evttime = 0;
62 MRawEvtData *evtdata = 0;
63 MRawCrateArray *evtcrate = 0;
64
65 //
66 // enable the corresponding branches
67 //
68 evttree->GetBranch("MRawEvtHeader.")->SetAddress(&evtheader);
69 evttree->GetBranch("MRawEvtData.")->SetAddress(&evtdata);
70
71 // Use this for real data only
72 //evttree->GetBranch("MTime.")->SetAddress(&evttime);
73 //evttree->GetBranch("MRawCrateArray.")->SetAddress(&evtcrate);
74
75 //
76 // loop over all events and print the information
77 //
78 Int_t iEnt = evttree->GetEntries();
79 cout << " Entries in Tree Data: " << iEnt << endl;
80
81 for (Int_t i = 0; i<iEnt; i++)
82 {
83 // readin event with the selected branches
84 evttree->GetEvent(i);
85
86 evtheader->Print();
87 evtdata->Print();
88
89 // Use this for real data only
90 //evttime->Print();
91 //evtcrate->Print();
92 }
93}
94
95
Note: See TracBrowser for help on using the repository browser.