source: ELYSE/HEAD/scripts/ROOT/analysis_leaks.C @ 597

Last change on this file since 597 was 286, checked in by campagne, 17 years ago

ELYSE sauvegarde provisoire (JEC)

File size: 7.2 KB
Line 
1//
2//  This script is a first version to read, with ROOT, a ELYSE.root
3// file having the "TTree within TTree" of the ELYSE_batch
4// progrem (see Analysis.cxx).
5//  But the below way to read the data has clearly a HUGE
6// memory consumption problem that someone can see by using
7// the "top" program on a UNIX.
8//
9//  Usage :
10//    OS> <setup ROOT>
11//  ( OS> root batch_dummy.C )
12//    OS> root analyis_leaks.C
13//
14//  G.Barrand
15//
16
17void analysis_leaks() {
18
19  TFile* f = new TFile("ELYSE.root");
20  TTree* tEvent = (TTree*)f->Get("Event");
21
22  //declare Non subTuple part
23  Int_t eventId,inputEvtId, interMode, vtxVol;
24  tEvent->SetBranchAddress("eventId",&eventId);
25  tEvent->SetBranchAddress("inputEvtId",&inputEvtId);
26  tEvent->SetBranchAddress("interMode",&interMode);
27  tEvent->SetBranchAddress("vtxVol",&vtxVol);
28
29  Int_t nPart,leptonIndex, protonIndex;
30  tEvent->SetBranchAddress("nPart",&nPart);
31  tEvent->SetBranchAddress("leptonIndex",&leptonIndex);
32  tEvent->SetBranchAddress("protonIndex",&protonIndex);
33
34  Int_t nHits; 
35  tEvent->SetBranchAddress("nHits",&nHits);
36
37  Int_t nDigits;
38  Double_t sumPE;
39  tEvent->SetBranchAddress("nDigits",&nDigits);
40  tEvent->SetBranchAddress("sumPE",&sumPE);
41
42  TTree* Event_vtxPos = new TTree();
43  tEvent->SetBranchAddress("vtxPos",&Event_vtxPos);
44  Double_t vx,vy,vz;
45
46  //The Track Event:subTuple  part
47  TTree* Event_track = new TTree();
48  tEvent->SetBranchAddress("track",&Event_track);
49  Int_t pId,parent;
50  Float_t timeStart;
51  Double_t mass, pTot, ETot;
52  Int_t startVol, stopVol;
53
54  //The Direction Track:subTuple
55  TTree* Track_direction = new TTree();
56  Double_t dx,dy,dz;
57
58  //The Momentum Track:subTuple
59  TTree* Track_momentum = new TTree();
60  Double_t px,py,pz;
61 
62  //The StartPos Track:subTuple
63  TTree* Track_startPos = new TTree();
64  Double_t start_x,start_y,start_z;
65
66  //The StopPos Track:subTuple
67  TTree* Track_stopPos = new TTree();
68  Double_t stop_x,stop_y,stop_z;
69
70  //The Hit Event:subTuple
71  TTree* Event_hit = new TTree();
72  tEvent->SetBranchAddress("hit",&Event_hit);
73  Int_t tubeId_hit; //JEC 16/1/06
74  Int_t totalPE;   
75 
76  //The Pe Hit::subTuple
77  TTree* Hit_pe = new TTree();
78  Float_t hit_time;
79  Float_t trk_length; //NV 13/6/06
80
81  //The Digit Event:subTuple   
82  TTree* Event_digit = new TTree();
83  tEvent->SetBranchAddress("digit",&Event_digit);
84  Int_t tubeId;
85  Double_t digit_pe, digit_time;
86
87  Int_t nEvent = (Int_t)tEvent->GetEntries(); 
88  std::cout << " nEvents = " << nEvent << endl;
89
90  //Int_t nEvent = 10000;
91  for (Int_t i=0; i<nEvent; ++i) {
92
93    /*
94    Event_vtxPos->Reset();
95    Event_track->Reset();
96    Track_direction->Reset();
97    Track_momentum->Reset();
98    Track_startPos->Reset();
99    Track_stopPos->Reset();
100    Event_hit->Reset();
101    Hit_pe->Reset();
102    Event_digit->Reset();
103    //tEvent->ResetBranchAddresses();
104    */
105
106    tEvent->GetEntry(i);
107    std::cout << ">>>>>>>>>>>>> Event{" << i << "}: "
108              << " evt Id " << eventId
109    //        << " evt Input Id " << inputEvtId
110    //        << "\n interaction mode " << interMode
111    //        << " start in volume " << vtxVol << "\n"
112    //        <<" #tracks: " << nPart
113    //        <<" #hits: " << nHits
114    //        <<" #digits: " << nDigits
115              << std::endl;
116
117    Int_t nTracks = (Int_t)Event_track->GetEntries();
118    Int_t nTubeHits = (Int_t)Event_hit->GetEntries();
119    Int_t nTubeDigits = (Int_t)Event_digit->GetEntries();
120    //std::cout << "Verif: nTracks = " << nTracks
121    //        << " nTube Hits = " << nTubeHits
122    //        << " nTube Digits = " << nTubeDigits
123    //        << std::endl;
124
125    Event_vtxPos->SetBranchAddress("x",&vx);
126    Event_vtxPos->SetBranchAddress("y",&vy);
127    Event_vtxPos->SetBranchAddress("z",&vz);
128
129    // Have a brand new overwritten track TTree ; we have
130    // to rebind its user variables :
131    Event_track->SetBranchAddress("pId",&pId);
132    Event_track->SetBranchAddress("parent",&parent);
133    Event_track->SetBranchAddress("timeStart",&timeStart);
134
135    Event_track->SetBranchAddress("mass",&mass);
136    Event_track->SetBranchAddress("pTot",&pTot);
137    Event_track->SetBranchAddress("ETot",&ETot);
138
139    Event_track->SetBranchAddress("startVol",&startVol);
140    Event_track->SetBranchAddress("stopVol",&stopVol);
141
142    Event_track->SetBranchAddress("direction",&Track_direction);
143    Event_track->SetBranchAddress("momentum",&Track_momentum);
144    Event_track->SetBranchAddress("startPos",&Track_startPos);
145    Event_track->SetBranchAddress("stopPos",&Track_stopPos);
146
147    // Have a brand new overwritten hit TTree ; we have
148    // to rebind its user variables :
149    Event_hit->SetBranchAddress("tubeId",&tubeId_hit); //JEC 16/1/06   
150    Event_hit->SetBranchAddress("totalPE",&totalPE);
151    Event_hit->SetBranchAddress("pe",&Hit_pe);
152   
153    // Have a brand new overwritten digit TTree ; we have
154    // to rebind its user variables :
155    Event_digit->SetBranchAddress("tubeId",&tubeId);
156    Event_digit->SetBranchAddress("pe",&digit_pe);
157    Event_digit->SetBranchAddress("time",&digit_time);
158
159
160    for (Int_t j=0; j<nTracks; ++j) {
161    //for (Int_t j=0; j<0; ++j) {
162      Event_track->GetEntry(j);
163
164      Track_direction->SetBranchAddress("dx",&dx);
165      Track_direction->SetBranchAddress("dy",&dy);
166      Track_direction->SetBranchAddress("dz",&dz);
167      Track_direction->GetEntry(0);
168
169      Track_momentum->SetBranchAddress("px",&px);
170      Track_momentum->SetBranchAddress("py",&py);
171      Track_momentum->SetBranchAddress("pz",&pz);
172      Track_momentum->GetEntry(0);
173
174      Track_startPos->SetBranchAddress("x",&start_x);
175      Track_startPos->SetBranchAddress("y",&start_y);
176      Track_startPos->SetBranchAddress("z",&start_z);
177      Track_startPos->GetEntry(0);
178
179      Track_stopPos->SetBranchAddress("x",&stop_x);
180      Track_stopPos->SetBranchAddress("y",&stop_y);
181      Track_stopPos->SetBranchAddress("z",&stop_z);
182      Track_stopPos->GetEntry(0);
183   
184      std::cout << "----> Tk{"<<j<<"}: " 
185                << " pId " << pId
186                << " parent " << parent
187                << " creation time " << timeStart
188                << " Volumes " << startVol << " " << stopVol << "\n"
189                << " Start Pos (" << start_x << "," << start_y << "," << start_z << ")\n"
190                << " Stop Pos (" << stop_x << "," << stop_y << "," << stop_z << ")\n"
191                << " dx,dy,dz " << dx << " " << dy << " " << dz << "\n"
192                << " m " << mass
193                << " ETot " << ETot
194                << " pTot " << pTot
195                << " px,py,pz " << px << " " << py << " " << pz << "\n"
196                << std::endl;
197    }//loop on Tracks
198
199    //--------
200    // The Hits
201    //--------
202
203
204    for (Int_t k=0; k<nTubeHits; ++k) {
205     
206      Event_hit->GetEntry(k);
207
208      Hit_pe->SetBranchAddress("time",&hit_time);
209      //Hit_pe->SetBranchAddress("length",&trk_length);
210      //JEC 16/1/06 add the tubeId_hit info
211      std::cout << "----> Hit{"<<k<<"}: tube[" << tubeId_hit << "] total #PE " << totalPE << std::endl;
212      for (Int_t ki=0; ki<Hit_pe->GetEntries(); ++ki) {
213        Hit_pe->GetEntry(ki);
214        std::cout << "<" << hit_time << ">" << "<" << trk_length << ">" ;
215      }
216      std::cout << std::endl;
217    }//Loop on Hits
218
219    //--------
220    // The Digits
221    //--------
222    //for (Int_t l=0; l<nTubeDigits; ++l)
223    for (Int_t l=0; l<0; ++l) {
224      Event_digit->GetEntry(l);
225     
226      std::cout << "----> Digit{"<<l<<"}: " 
227                << "tube[" << tubeId << "] = " 
228                << " pe: " << digit_pe
229                << " time: " << digit_time
230                << std::endl;
231     
232    }//Loop on Digits
233  }//loop on event
234}//read_event
Note: See TracBrowser for help on using the repository browser.