| 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 (tbretz@uni-sw.gwdg.de) | 
|---|
| 19 | ! | 
|---|
| 20 | !   Copyright: MAGIC Software Development, 2000-2001 | 
|---|
| 21 | ! | 
|---|
| 22 | ! | 
|---|
| 23 | \* ======================================================================== */ | 
|---|
| 24 |  | 
|---|
| 25 |  | 
|---|
| 26 | void readin() | 
|---|
| 27 | { | 
|---|
| 28 | // | 
|---|
| 29 | // open the file | 
|---|
| 30 | // | 
|---|
| 31 | TFile input("test.root", "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("Data") ; | 
|---|
| 56 |  | 
|---|
| 57 | // | 
|---|
| 58 | // create the instances of the data to read in | 
|---|
| 59 | // | 
|---|
| 60 | MRawEvtHeader  *evtheader = new MRawEvtHeader(); | 
|---|
| 61 | MTime          *evttime   = new MTime(); | 
|---|
| 62 | MRawEvtData    *evtdata   = new MRawEvtData(); | 
|---|
| 63 | MRawCrateArray *evtcrate  = new MRawCrateArray(); | 
|---|
| 64 |  | 
|---|
| 65 | // | 
|---|
| 66 | // enable the corresponding branches | 
|---|
| 67 | // | 
|---|
| 68 | evttree->GetBranch("MRawEvtHeader")->SetAddress(&evtheader); | 
|---|
| 69 | evttree->GetBranch("MTime")->SetAddress(&evttime); | 
|---|
| 70 | evttree->GetBranch("MRawEvtData")->SetAddress(&evtdata); | 
|---|
| 71 | evttree->GetBranch("MRawCrateArray")->SetAddress(&evtcrate); | 
|---|
| 72 |  | 
|---|
| 73 | // | 
|---|
| 74 | // loop over all events and print the information | 
|---|
| 75 | // | 
|---|
| 76 | Int_t iEnt = evttree->GetEntries(); | 
|---|
| 77 | cout << " Entries in Tree Data: " << iEnt << endl; | 
|---|
| 78 |  | 
|---|
| 79 | for (Int_t i = 0; i<iEnt; i++) | 
|---|
| 80 | { | 
|---|
| 81 | // readin event with the selected branches | 
|---|
| 82 | evttree->GetEvent(i); | 
|---|
| 83 |  | 
|---|
| 84 | evtheader->Print(); | 
|---|
| 85 | evttime->Print(); | 
|---|
| 86 | evtcrate->Print(); | 
|---|
| 87 | evtdata->Print(); | 
|---|
| 88 | } | 
|---|
| 89 | } | 
|---|
| 90 |  | 
|---|
| 91 |  | 
|---|