source: MEMPHYS/HEAD/run/MEMPHYS_read_event.C @ 28

Last change on this file since 28 was 28, checked in by campagne, 19 years ago

fix bugs and polish print

File size: 5.8 KB
Line 
1void MEMPHYS_read_event() {
2
3  TFile* f = new TFile("MEMPHYS.root");
4  TTree* tEvent = (TTree*)f->Get("Event");
5
6  //declare Non subTuple part
7  Int_t eventId,inputEvtId, interMode, vtxVol;
8  tEvent->SetBranchAddress("eventId",&eventId);
9  tEvent->SetBranchAddress("inputEvtId",&inputEvtId);
10  tEvent->SetBranchAddress("interMode",&interMode);
11  tEvent->SetBranchAddress("vtxVol",&vtxVol);
12
13  Int_t nPart,leptonIndex, protonIndex;
14  tEvent->SetBranchAddress("nPart",&nPart);
15  tEvent->SetBranchAddress("leptonIndex",&leptonIndex);
16  tEvent->SetBranchAddress("protonIndex",&protonIndex);
17
18  Int_t nHits; 
19  tEvent->SetBranchAddress("nHits",&nHits);
20
21  Int_t nDigits;
22  Double_t sumPE;
23  tEvent->SetBranchAddress("nDigits",&nDigits);
24  tEvent->SetBranchAddress("sumPE",&sumPE);
25
26
27  //The Track Event:subTuple  part
28  TTree* Event_track = new TTree();
29  tEvent->SetBranchAddress("track",&Event_track);
30  Int_t pId,parent;
31  Float_t timeStart;
32  Double_t mass, pTot, ETot;
33  Int_t startVol, stopVol;
34
35  //The Direction Track:subTuple
36  TTree* Track_direction = new TTree();
37  Double_t dx,dy,dz;
38
39  //The Momentum Track:subTuple
40  TTree* Track_momentum = new TTree();
41  Double_t px,py,pz;
42 
43  //The StartPos Track:subTuple
44  TTree* Track_startPos = new TTree();
45  Double_t start_x,start_y,start_z;
46
47  //The StopPos Track:subTuple
48  TTree* Track_stopPos = new TTree();
49  Double_t stop_x,stop_y,stop_z;
50
51  //The Hit Event:subTuple
52  TTree* Event_hit = new TTree();
53  tEvent->SetBranchAddress("hit",&Event_hit);
54  Int_t totalPE;
55 
56  //The Pe Hit::subTuple
57  TTree* Hit_pe = new TTree();
58  Float_t hit_time;
59
60  //The Digit Event:subTuple   
61  TTree* Event_digit = new TTree();
62  tEvent->SetBranchAddress("digit",&Event_digit);
63  Int_t tubeId;
64  Double_t digit_pe, digit_time;
65
66  Int_t nEvent = tEvent->GetEntries();
67
68  for (Int_t i=0; i<nEvent; ++i){
69    tEvent->GetEntry(i);
70    std::cout << ">>>>>>>>>>>>> Event{" << i << "}: "
71              << " evt Id " << eventId
72              << " evt Input Id " << inputEvtId
73              << "\n interaction mode " << interMode
74              << " start in volume " << vtxVol << "\n"
75              <<" #tracks: " << nPart
76              <<" #hits: " << nHits
77              <<" #digits: " << nDigits
78              << std::endl;
79
80    Int_t nTracks = Event_track->GetEntries();
81    Int_t nTubeHits = Event_hit->GetEntries();
82    Int_t nTubeDigits = Event_digit->GetEntries();
83    std::cout << "Verif: nTracks = " << nTracks
84              << " nTube Hits = " << nTubeHits
85              << " nTube Digits = " << nTubeDigits
86              << std::endl;
87
88    // Have a brand new overwritten track TTree ; we have
89    // to rebind its user variables :
90    Event_track->SetBranchAddress("pId",&pId);
91    Event_track->SetBranchAddress("parent",&parent);
92    Event_track->SetBranchAddress("timeStart",&timeStart);
93
94    Event_track->SetBranchAddress("mass",&mass);
95    Event_track->SetBranchAddress("pTot",&pTot);
96    Event_track->SetBranchAddress("ETot",&ETot);
97
98    Event_track->SetBranchAddress("startVol",&startVol);
99    Event_track->SetBranchAddress("stopVol",&stopVol);
100
101    Event_track->SetBranchAddress("direction",&Track_direction);
102    Event_track->SetBranchAddress("momentum",&Track_momentum);
103    Event_track->SetBranchAddress("startPos",&Track_startPos);
104    Event_track->SetBranchAddress("stopPos",&Track_stopPos);
105
106    // Have a brand new overwritten hit TTree ; we have
107    // to rebind its user variables :
108    Event_hit->SetBranchAddress("totalPE",&totalPE);
109    Event_hit->SetBranchAddress("pe",&Hit_pe);
110   
111    // Have a brand new overwritten hit TTree ; we have
112    // to rebind its user variables :
113    Event_digit->SetBranchAddress("tubeId",&tubeId);
114    Event_digit->SetBranchAddress("pe",&digit_pe);
115    Event_digit->SetBranchAddress("time",&digit_time);
116
117
118    for (Int_t j=0; j<nTracks; ++j) {
119
120      Event_track->GetEntry(j);
121
122      Track_direction->SetBranchAddress("dx",&dx);
123      Track_direction->SetBranchAddress("dy",&dy);
124      Track_direction->SetBranchAddress("dz",&dz);
125      Track_direction->GetEntry(0);
126
127      Track_momentum->SetBranchAddress("px",&px);
128      Track_momentum->SetBranchAddress("py",&py);
129      Track_momentum->SetBranchAddress("pz",&pz);
130      Track_momentum->GetEntry(0);
131
132      Track_startPos->SetBranchAddress("x",&start_x);
133      Track_startPos->SetBranchAddress("y",&start_y);
134      Track_startPos->SetBranchAddress("z",&start_z);
135      Track_startPos->GetEntry(0);
136
137      Track_stopPos->SetBranchAddress("x",&stop_x);
138      Track_stopPos->SetBranchAddress("y",&stop_y);
139      Track_stopPos->SetBranchAddress("z",&stop_z);
140      Track_stopPos->GetEntry(0);
141   
142      std::cout << "----> Tk{"<<j<<"}: " 
143                << " pId " << pId
144                << " parent " << parent
145                << " creation time " << timeStart
146                << " Volumes " << startVol << " " << stopVol << "\n"
147                << " Start Pos (" << start_x << "," << start_y << "," << start_z << ")\n"
148                << " Stop Pos (" << stop_x << "," << stop_y << "," << stop_z << ")\n"
149                << " dx,dy,dz " << dx << " " << dy << " " << dz << "\n"
150                << " m " << mass
151                << " ETot " << ETot
152                << " pTot " << pTot
153                << " px,py,pz " << px << " " << py << " " << pz << "\n"
154                << std::endl;
155    }//loop on Tracks
156
157    //--------
158    // The Hits
159    //--------
160
161    for (Int_t k=0; k<nTubeHits; ++k) {
162     
163      Event_hit->GetEntry(k);
164
165      Hit_pe->SetBranchAddress("time",&hit_time);
166     
167      std::cout << "----> Hit{"<<k<<"}: total #PE " << totalPE << std::endl;
168      for (Int_t ki=0; ki<Hit_pe->GetEntries(); ++ki) {
169        Hit_pe->GetEntry(ki);
170        std::cout << "<" << hit_time << ">";
171      }
172      std::cout << std::endl;
173    }//Loop on Hits
174
175    //--------
176    // The Digits
177    //--------
178    for (Int_t l=0; l<nTubeDigits; ++l) {
179      Event_digit->GetEntry(l);
180     
181      std::cout << "----> Digit{"<<l<<"}: " 
182                << "tube[" << tubeId << "] = " 
183                << " pe: " << digit_pe
184                << " time: " << digit_time
185                << std::endl;
186     
187    }//Loop on Digits
188  }//loop on event
189}//read_event
Note: See TracBrowser for help on using the repository browser.