StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
readFgtTree.C
1 /***************************************************************************
2  *
3  * $Id: readFgtTree.C,v 1.1 2012/01/28 09:29:26 sgliske Exp $
4  * Author: S. Gliske, Jan 2012
5  *
6  ***************************************************************************
7  *
8  * Description: example of how to read the TTree in a root file
9  * generated by StFgtDaq2Root. The adc values for all timebins for
10  * strips 0-9, apv 0, disc 0, are sent to standard output for the
11  * first 5 events.
12  *
13  ***************************************************************************
14  *
15  * $Log: readFgtTree.C,v $
16  * Revision 1.1 2012/01/28 09:29:26 sgliske
17  * creation
18  *
19  *
20  **************************************************************************/
21 
22 enum { kNumTimeBins = 7, kNumChans = 128, kNumApv = 10, kNumQuad = 3, kNumStripsPerEvent = 26880 };
23 
24 struct chan_t {
25  Int_t tb[kNumTimeBins];
26 };
27 
28 struct apv_t {
29  chan_t chan[kNumChans];
30 };
31 
32 struct quad_t {
33  apv_t apv[kNumApv];
34 };
35 
36 struct cosmicFgt_t {
37  quad_t quad[kNumQuad];
38 };
39 
40 readFgtTree( const Char_t *file = "fgtTest.root" ) {
41  TFile *f = new TFile( file, "READ");
42  TTree *tree = f->Get("fgtTree");
43  if(!tree){
44  cout << "error" << endl;
45  return;
46  };
47 
48  cosmicFgt_t fgtData;
49 
50  tree->SetBranchAddress("branch", &fgtData );
51 
52  for( Int_t ev = 0; ev<5; ++ev ){
53  tree->GetEvent(ev);
54  Int_t quad = 0;
55  Int_t apv = 2;
56 
57  for( Int_t chan = 0; chan < 10; ++chan ){
58  cout << "event " << ev << ", quad " << quad << ", apv " << apv
59  << ", chan " << chan << " values ";
60  for( Int_t tb = 0; tb < 7; ++tb )
61  cout << fgtData.quad[0].apv[apv].chan[chan].tb[tb] << ' ';
62  cout << endl;
63  };
64  };
65  f->Close();
66 };