c121e924 |
1 | /************************************************************************** |
2 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * |
3 | * * |
4 | * Author: The ALICE Off-line Project. * |
5 | * Contributors are mentioned in the code where appropriate. * |
6 | * * |
7 | * Permission to use, copy, modify and distribute this software and its * |
8 | * documentation strictly for non-commercial purposes is hereby granted * |
9 | * without fee, provided that the above copyright notice appears in all * |
10 | * copies and that both the copyright notice and this permission notice * |
11 | * appear in the supporting documentation. The authors make no claims * |
12 | * about the suitability of this software for any purpose. It is * |
13 | * provided "as is" without express or implied warranty. * |
14 | **************************************************************************/ |
15 | |
16 | /* $Id$ */ |
17 | |
88cb7938 |
18 | // |
19 | // Macro for checking aliroot output and associated files contents |
20 | // Gines Martinez, Subatech June 2003 |
21 | // |
e516b01d |
22 | #if !defined(__CINT__) || defined(__MAKECINT__) |
88cb7938 |
23 | // ROOT includes |
24 | #include "TBranch.h" |
25 | #include "TClonesArray.h" |
26 | #include "TFile.h" |
27 | #include "TH1.h" |
bf485fb9 |
28 | #include "TMath.h" |
88cb7938 |
29 | #include "TParticle.h" |
30 | #include "TTree.h" |
da47578c |
31 | #include "TNtuple.h" |
88cb7938 |
32 | |
33 | // STEER includes |
34 | #include "AliRun.h" |
35 | #include "AliRunLoader.h" |
36 | #include "AliHeader.h" |
37 | #include "AliLoader.h" |
38 | #include "AliStack.h" |
3b969def |
39 | #include "AliTracker.h" |
40 | #include "AliMagFMaps.h" |
88cb7938 |
41 | |
42 | // MUON includes |
43 | #include "AliMUON.h" |
ce3f5e87 |
44 | #include "AliMUONData.h" |
88cb7938 |
45 | #include "AliMUONHit.h" |
46 | #include "AliMUONConstants.h" |
47 | #include "AliMUONDigit.h" |
48 | #include "AliMUONRawCluster.h" |
49 | #include "AliMUONGlobalTrigger.h" |
50 | #include "AliMUONLocalTrigger.h" |
8547965d |
51 | #include "AliMUONTrack.h" |
bf485fb9 |
52 | #include "AliMUONTrackParam.h" |
e1a10d41 |
53 | #include "AliMUONTriggerCircuit.h" |
3b969def |
54 | #include "AliMUONTriggerCrateStore.h" |
bf485fb9 |
55 | |
56 | #include "AliMpVSegmentation.h" |
57 | #include "AliMpIntPair.h" |
6babe058 |
58 | #include "AliMpDEManager.h" |
59 | #include "AliMpSegFactory.h" |
e516b01d |
60 | #endif |
2b32c661 |
61 | |
bf485fb9 |
62 | void MUONkine(Int_t event2Check=0, char * filename="galice.root") |
88cb7938 |
63 | { |
3b0cf968 |
64 | // Stack of particle for each event |
65 | AliStack* stack; |
88cb7938 |
66 | // Creating Run Loader and openning file containing Hits |
67 | AliRunLoader * RunLoader = AliRunLoader::Open(filename,"MUONFolder","READ"); |
68 | if (RunLoader ==0x0) { |
69 | printf(">>> Error : Error Opening %s file \n",filename); |
70 | return; |
71 | } |
3b0cf968 |
72 | |
88cb7938 |
73 | RunLoader->LoadKinematics("READ"); |
74 | Int_t ievent, nevents; |
75 | nevents = RunLoader->GetNumberOfEvents(); |
76 | |
77 | for(ievent=0; ievent<nevents; ievent++) { // Event loop |
2b32c661 |
78 | if (event2Check!=0) ievent=event2Check; |
88cb7938 |
79 | Int_t iparticle, nparticles; |
80 | // Getting event ievent |
81 | RunLoader->GetEvent(ievent); |
3b0cf968 |
82 | stack = RunLoader->Stack(); |
83 | nparticles = (Int_t) stack->GetNtrack(); |
88cb7938 |
84 | printf(">>> Event %d, Number of particles is %d \n",ievent, nparticles); |
85 | for(iparticle=0; iparticle<nparticles; iparticle++) { |
3b0cf968 |
86 | stack->Particle(iparticle)->Print(""); |
88cb7938 |
87 | } |
2b32c661 |
88 | if (event2Check!=0) ievent=nevents; |
88cb7938 |
89 | } |
90 | RunLoader->UnloadKinematics(); |
91 | } |
92 | |
93 | |
bf485fb9 |
94 | void MUONhits(Int_t event2Check=0, char * filename="galice.root") |
88cb7938 |
95 | { |
88cb7938 |
96 | // Creating Run Loader and openning file containing Hits |
97 | AliRunLoader * RunLoader = AliRunLoader::Open(filename,"MUONFolder","READ"); |
98 | if (RunLoader ==0x0) { |
99 | printf(">>> Error : Error Opening %s file \n",filename); |
100 | return; |
101 | } |
88cb7938 |
102 | // Loading MUON subsystem |
103 | AliLoader * MUONLoader = RunLoader->GetLoader("MUONLoader"); |
1a1cdff8 |
104 | MUONLoader->LoadHits("READ"); // Loading Tree of hits for MUON |
105 | AliMUONData muondata(MUONLoader,"MUON","MUON"); // Creating MUON data container |
88cb7938 |
106 | Int_t ievent, nevents; |
107 | nevents = RunLoader->GetNumberOfEvents(); |
108 | |
109 | for(ievent=0; ievent<nevents; ievent++) { // Event loop |
2b32c661 |
110 | if (event2Check!=0) ievent=event2Check; |
88cb7938 |
111 | printf(">>> Event %d \n",ievent); |
88cb7938 |
112 | // Getting event ievent |
113 | RunLoader->GetEvent(ievent); |
ce3f5e87 |
114 | muondata.SetTreeAddress("H"); |
88cb7938 |
115 | Int_t itrack, ntracks; |
1a1cdff8 |
116 | ntracks = (Int_t) muondata.GetNtracks(); |
88cb7938 |
117 | for (itrack=0; itrack<ntracks; itrack++) { // Track loop |
88cb7938 |
118 | //Getting List of Hits of Track itrack |
bf485fb9 |
119 | muondata.GetTrack(itrack); |
88cb7938 |
120 | Int_t ihit, nhits; |
ce3f5e87 |
121 | nhits = (Int_t) muondata.Hits()->GetEntriesFast(); |
bf485fb9 |
122 | printf(">>> Track %d, Number of hits %d \n",itrack,nhits); |
88cb7938 |
123 | AliMUONHit* mHit; |
124 | for(ihit=0; ihit<nhits; ihit++) { |
ce3f5e87 |
125 | mHit = static_cast<AliMUONHit*>(muondata.Hits()->At(ihit)); |
6464217e |
126 | mHit->Print("full"); |
88cb7938 |
127 | } |
ce3f5e87 |
128 | muondata.ResetHits(); |
88cb7938 |
129 | } // end track loop |
2b32c661 |
130 | if (event2Check!=0) ievent=nevents; |
88cb7938 |
131 | } // end event loop |
132 | MUONLoader->UnloadHits(); |
133 | } |
134 | |
135 | |
bf485fb9 |
136 | void MUONdigits(Int_t event2Check=0, char * filename="galice.root") |
88cb7938 |
137 | { |
88cb7938 |
138 | // Creating Run Loader and openning file containing Hits |
139 | AliRunLoader * RunLoader = AliRunLoader::Open(filename,"MUONFolder","READ"); |
140 | if (RunLoader ==0x0) { |
141 | printf(">>> Error : Error Opening %s file \n",filename); |
142 | return; |
143 | } |
ce3f5e87 |
144 | // Loading MUON subsystem |
88cb7938 |
145 | AliLoader * MUONLoader = RunLoader->GetLoader("MUONLoader"); |
146 | MUONLoader->LoadDigits("READ"); |
ce3f5e87 |
147 | // Creating MUON data container |
148 | AliMUONData muondata(MUONLoader,"MUON","MUON"); |
75fbac63 |
149 | |
88cb7938 |
150 | Int_t ievent, nevents; |
151 | nevents = RunLoader->GetNumberOfEvents(); |
88cb7938 |
152 | AliMUONDigit * mDigit; |
153 | |
88cb7938 |
154 | for(ievent=0; ievent<nevents; ievent++) { |
2b32c661 |
155 | if (event2Check!=0) ievent=event2Check; |
88cb7938 |
156 | printf(">>> Event %d \n",ievent); |
157 | RunLoader->GetEvent(ievent); |
75fbac63 |
158 | |
88cb7938 |
159 | // Addressing |
160 | Int_t ichamber, nchambers; |
161 | nchambers = AliMUONConstants::NCh(); ; |
6babe058 |
162 | muondata.SetTreeAddress("D,GLT"); |
75fbac63 |
163 | |
bf485fb9 |
164 | muondata.GetDigits(); |
165 | // Loop on chambers |
166 | for( ichamber=0; ichamber<nchambers; ichamber++) { |
167 | Int_t idigit, ndigits; |
75fbac63 |
168 | TClonesArray* digits = muondata.Digits(ichamber); |
169 | digits->Sort(); |
170 | ndigits = (Int_t)digits->GetEntriesFast(); |
bf485fb9 |
171 | for(idigit=0; idigit<ndigits; idigit++) { |
75fbac63 |
172 | mDigit = static_cast<AliMUONDigit*>(digits->At(idigit)); |
173 | mDigit->Print("tracks"); |
bf485fb9 |
174 | } // end digit loop |
175 | } // end chamber loop |
176 | muondata.ResetDigits(); |
2b32c661 |
177 | if (event2Check!=0) ievent=nevents; |
88cb7938 |
178 | } // end event loop |
179 | MUONLoader->UnloadDigits(); |
180 | } |
181 | |
75fbac63 |
182 | void MUONsdigits(Int_t event2Check=0, char * filename="galice.root") |
183 | { |
184 | // Creating Run Loader and openning file containing Hits |
185 | AliRunLoader * RunLoader = AliRunLoader::Open(filename,"MUONFolder","READ"); |
186 | if (RunLoader ==0x0) { |
187 | printf(">>> Error : Error Opening %s file \n",filename); |
188 | return; |
189 | } |
190 | // Loading MUON subsystem |
191 | AliLoader * MUONLoader = RunLoader->GetLoader("MUONLoader"); |
192 | MUONLoader->LoadSDigits("READ"); |
193 | // Creating MUON data container |
194 | AliMUONData muondata(MUONLoader,"MUON","MUON"); |
195 | |
196 | Int_t ievent, nevents; |
197 | nevents = RunLoader->GetNumberOfEvents(); |
198 | AliMUONDigit * mDigit; |
199 | |
200 | for(ievent=0; ievent<nevents; ievent++) { |
201 | if (event2Check!=0) ievent=event2Check; |
202 | printf(">>> Event %d \n",ievent); |
203 | RunLoader->GetEvent(ievent); |
204 | |
205 | // Addressing |
206 | Int_t ichamber, nchambers; |
207 | nchambers = AliMUONConstants::NCh(); ; |
208 | muondata.SetTreeAddress("S"); |
209 | |
210 | muondata.GetSDigits(); |
211 | // Loop on chambers |
212 | for( ichamber=0; ichamber<nchambers; ichamber++) { |
213 | Int_t idigit, ndigits; |
214 | TClonesArray* digits = muondata.SDigits(ichamber); |
215 | ndigits = (Int_t)digits->GetEntriesFast(); |
216 | for(idigit=0; idigit<ndigits; idigit++) { |
217 | mDigit = static_cast<AliMUONDigit*>(digits->At(idigit)); |
218 | mDigit->Print("tracks"); |
219 | } // end digit loop |
220 | } // end chamber loop |
221 | muondata.ResetSDigits(); |
222 | if (event2Check!=0) ievent=nevents; |
223 | } // end event loop |
224 | MUONLoader->UnloadSDigits(); |
3b969def |
225 | |
75fbac63 |
226 | } |
227 | |
bf485fb9 |
228 | void MUONoccupancy(Int_t event2Check=0, Bool_t perDetEle =kFALSE, char * filename="galice.root") { |
229 | // Creating Run Loader and openning file containing Hits |
230 | AliRunLoader * RunLoader = AliRunLoader::Open(filename,"MUONFolder","READ"); |
231 | if (RunLoader ==0x0) { |
232 | printf(">>> Error : Error Opening %s file \n",filename); |
233 | return; |
234 | } |
235 | // Loading MUON subsystem |
236 | AliLoader * MUONLoader = RunLoader->GetLoader("MUONLoader"); |
237 | MUONLoader->LoadDigits("READ"); |
238 | // Creating MUON data container |
239 | AliMUONData muondata(MUONLoader,"MUON","MUON"); |
240 | |
241 | Int_t ievent, nevents; |
242 | nevents = RunLoader->GetNumberOfEvents(); |
243 | AliMUONDigit * mDigit =0x0; |
244 | AliMpVSegmentation * segbend = 0x0; |
245 | AliMpVSegmentation * segnonbend = 0x0; |
246 | AliMpIntPair pad(0,0); |
247 | |
248 | Int_t dEoccupancy_bending[14][26]; |
249 | Int_t dEoccupancy_nonbending[14][26]; |
250 | Int_t cHoccupancy_bending[14]; |
251 | Int_t cHoccupancy_nonbending[14]; |
252 | Int_t totaloccupancy_bending =0; |
253 | Int_t totaloccupancy_nonbending =0; |
254 | |
255 | Int_t dEchannels_bending[14][26]; |
256 | Int_t dEchannels_nonbending[14][26]; |
257 | Int_t cHchannels_bending[14]; |
258 | Int_t cHchannels_nonbending[14]; |
259 | Int_t totalchannels_bending =0; |
260 | Int_t totalchannels_nonbending =0; |
261 | |
262 | Int_t ichamber, nchambers,idetele, detele, ix, iy; |
263 | nchambers = AliMUONConstants::NCh(); ; |
264 | |
6babe058 |
265 | AliMpSegFactory factory; |
266 | |
bf485fb9 |
267 | for (ichamber=0; ichamber<nchambers; ichamber++) { |
268 | cHchannels_bending[ichamber]=0; |
269 | cHchannels_nonbending[ichamber]=0; |
270 | for (idetele=0; idetele<26; idetele++) { |
271 | detele= 100*(ichamber +1)+idetele; |
272 | dEchannels_bending[ichamber][idetele]=0; |
273 | dEchannels_nonbending[ichamber][idetele]=0; |
274 | dEoccupancy_bending[ichamber][idetele]=0; |
275 | dEoccupancy_nonbending[ichamber][idetele]=0; |
6babe058 |
276 | if ( AliMpDEManager::IsValidDetElemId(detele) ) { |
277 | |
278 | segbend = factory.CreateMpSegmentation(detele, 0); |
279 | segnonbend = factory.CreateMpSegmentation(detele, 1); |
280 | if (AliMpDEManager::GetPlaneType(detele, 0) != kBendingPlane ) { |
281 | AliMpVSegmentation* tmp = segbend; |
282 | segbend = segnonbend; |
283 | segnonbend = tmp; |
284 | } |
285 | |
bf485fb9 |
286 | for(ix=0; ix<=segbend->MaxPadIndexX(); ix++) { |
287 | for(iy=0; iy<=segbend->MaxPadIndexY(); iy++) { |
288 | pad.SetFirst(ix); |
289 | pad.SetSecond(iy); |
290 | if( segbend->HasPad(pad) ) { |
291 | dEchannels_bending[ichamber][idetele]++; |
292 | cHchannels_bending[ichamber]++; |
293 | totalchannels_bending++; |
294 | } |
295 | } |
296 | } |
297 | for(ix=0; ix<=segnonbend->MaxPadIndexX(); ix++) { |
298 | for(iy=0; iy<=segnonbend->MaxPadIndexY(); iy++) { |
299 | pad.SetFirst(ix); |
300 | pad.SetSecond(iy); |
301 | if(segnonbend->HasPad(pad)) { |
302 | dEchannels_nonbending[ichamber][idetele]++; |
303 | cHchannels_nonbending[ichamber]++; |
304 | totalchannels_nonbending++; |
305 | } |
306 | } |
307 | } |
308 | if (perDetEle) printf(">>> Detection element %4d has %5d channels in bending and %5d channels in nonbending \n", |
309 | detele, dEchannels_bending[ichamber][idetele], dEchannels_nonbending[ichamber][idetele] ); |
310 | } |
311 | } |
312 | printf(">>> Chamber %2d has %6d channels in bending and %6d channels in nonbending \n", |
313 | ichamber+1, cHchannels_bending[ichamber], cHchannels_nonbending[ichamber]); |
314 | } |
315 | printf(">>Spectrometer has %7d channels in bending and %7d channels in nonbending \n", |
316 | totalchannels_bending, totalchannels_nonbending); |
317 | |
6babe058 |
318 | factory.DeleteSegmentations(); |
319 | |
bf485fb9 |
320 | ievent=event2Check; |
321 | printf(">>> Event %d \n",ievent); |
322 | RunLoader->GetEvent(ievent); |
323 | |
324 | // Addressing |
325 | muondata.SetTreeAddress("D"); |
326 | muondata.GetDigits(); |
327 | // Loop on chambers |
328 | for( ichamber=0; ichamber<nchambers; ichamber++) { |
329 | cHoccupancy_bending[ichamber] = 0; |
330 | cHoccupancy_nonbending[ichamber]= 0; |
331 | Int_t idigit, ndigits; |
332 | ndigits = (Int_t) muondata.Digits(ichamber)->GetEntriesFast(); |
333 | for(idigit=0; idigit<ndigits; idigit++) { |
334 | mDigit = static_cast<AliMUONDigit*>(muondata.Digits(ichamber)->At(idigit)); |
335 | Int_t detele = mDigit->DetElemId(); |
336 | Int_t idetele = detele-(ichamber+1)*100; |
337 | if ( mDigit->Cathode() == 0 ) { |
338 | |
339 | cHoccupancy_bending[ichamber]++; |
340 | dEoccupancy_bending[ichamber][idetele]++; |
341 | totaloccupancy_bending++; |
342 | } |
343 | else { |
344 | cHoccupancy_nonbending[ichamber]++; |
345 | dEoccupancy_nonbending[ichamber][idetele]++; |
346 | totaloccupancy_nonbending++; |
347 | } |
348 | } // end digit loop |
349 | |
350 | printf(">>> Chamber %2d nChannels Bending %5d nChannels NonBending %5d \n", |
351 | ichamber+1, |
352 | cHoccupancy_bending[ichamber], |
353 | cHoccupancy_nonbending[ichamber]); |
0ad940df |
354 | printf(">>> Chamber %2d Occupancy Bending %5.2f %% Occupancy NonBending %5.2f %% \n", |
bf485fb9 |
355 | ichamber+1, |
356 | 100.*((Float_t) cHoccupancy_bending[ichamber])/((Float_t) cHchannels_bending[ichamber]), |
357 | 100.*((Float_t) cHoccupancy_nonbending[ichamber])/((Float_t) cHchannels_bending[ichamber]) ); |
358 | |
359 | |
360 | for(Int_t idetele=0; idetele<26; idetele++) { |
361 | Int_t detele = idetele + 100*(ichamber+1); |
6babe058 |
362 | if ( AliMpDEManager::IsValidDetElemId(detele) ) { |
bf485fb9 |
363 | if (perDetEle) { |
364 | printf(">>> DetEle %4d nChannels Bending %5d nChannels NonBending %5d \n", |
365 | idetele+100*(ichamber+1), |
366 | dEoccupancy_bending[ichamber][idetele], |
367 | dEoccupancy_nonbending[ichamber][idetele]); |
0ad940df |
368 | printf(">>> DetEle %4d Occupancy Bending %5.2f %% Occupancy NonBending %5.2f %% \n", |
bf485fb9 |
369 | idetele+100*(ichamber+1), |
370 | 100.*((Float_t) dEoccupancy_bending[ichamber][idetele])/((Float_t) dEchannels_bending[ichamber][idetele]), |
371 | 100.*((Float_t) dEoccupancy_nonbending[ichamber][idetele])/((Float_t) dEchannels_bending[ichamber][idetele])); |
372 | } |
373 | } |
374 | } |
375 | } // end chamber loop |
0ad940df |
376 | printf(">>> Muon Spectrometer Occupancy Bending %5.2f %% Occupancy NonBending %5.2f %% \n", |
bf485fb9 |
377 | 100.*((Float_t) totaloccupancy_bending)/((Float_t) totalchannels_bending), |
378 | 100.*((Float_t) totaloccupancy_nonbending)/((Float_t) totalchannels_nonbending) ); |
379 | muondata.ResetDigits(); |
380 | // } // end cathode loop |
381 | MUONLoader->UnloadDigits(); |
382 | } |
383 | |
384 | void MUONrecpoints(Int_t event2Check=0, char * filename="galice.root") { |
88cb7938 |
385 | |
88cb7938 |
386 | // Creating Run Loader and openning file containing Hits |
387 | AliRunLoader * RunLoader = AliRunLoader::Open(filename,"MUONFolder","READ"); |
388 | if (RunLoader ==0x0) { |
389 | printf(">>> Error : Error Opening %s file \n",filename); |
390 | return; |
391 | } |
ce3f5e87 |
392 | // Getting MUONloader |
88cb7938 |
393 | AliLoader * MUONLoader = RunLoader->GetLoader("MUONLoader"); |
394 | MUONLoader->LoadRecPoints("READ"); |
ce3f5e87 |
395 | // Creating MUON data container |
396 | AliMUONData muondata(MUONLoader,"MUON","MUON"); |
88cb7938 |
397 | |
398 | Int_t ievent, nevents; |
399 | nevents = RunLoader->GetNumberOfEvents(); |
e516b01d |
400 | AliMUONRawCluster * mRecPoint = 0; |
88cb7938 |
401 | |
88cb7938 |
402 | for(ievent=0; ievent<nevents; ievent++) { |
2b32c661 |
403 | if (event2Check!=0) ievent=event2Check; |
88cb7938 |
404 | printf(">>> Event %d \n",ievent); |
405 | RunLoader->GetEvent(ievent); |
88cb7938 |
406 | // Addressing |
407 | Int_t ichamber, nchambers; |
408 | nchambers = AliMUONConstants::NTrackingCh(); |
6babe058 |
409 | muondata.SetTreeAddress("RC,TC"); |
88cb7938 |
410 | char branchname[30]; |
1a1cdff8 |
411 | muondata.GetRawClusters(); |
88cb7938 |
412 | // Loop on chambers |
413 | for( ichamber=0; ichamber<nchambers; ichamber++) { |
88cb7938 |
414 | sprintf(branchname,"MUONRawClusters%d",ichamber+1); |
415 | //printf(">>> branchname %s\n",branchname); |
88cb7938 |
416 | Int_t irecpoint, nrecpoints; |
ce3f5e87 |
417 | nrecpoints = (Int_t) muondata.RawClusters(ichamber)->GetEntriesFast(); |
bf485fb9 |
418 | // printf(">>> Chamber %2d, Number of recpoints = %6d \n",ichamber+1, nrecpoints); |
88cb7938 |
419 | for(irecpoint=0; irecpoint<nrecpoints; irecpoint++) { |
ce3f5e87 |
420 | mRecPoint = static_cast<AliMUONRawCluster*>(muondata.RawClusters(ichamber)->At(irecpoint)); |
6464217e |
421 | mRecPoint->Print("full"); |
88cb7938 |
422 | } // end recpoint loop |
423 | } // end chamber loop |
ce3f5e87 |
424 | muondata.ResetRawClusters(); |
2b32c661 |
425 | if (event2Check!=0) ievent=nevents; |
88cb7938 |
426 | } // end event loop |
427 | MUONLoader->UnloadRecPoints(); |
428 | } |
429 | |
39c07f3b |
430 | void MUONrectrigger (Int_t event2Check=0, char * filename="galice.root", Int_t WRITE = 0, Bool_t readFromRP = 0) |
9e48bfe3 |
431 | { |
84da0ea0 |
432 | |
da47578c |
433 | // reads and dumps trigger objects from MUON.RecPoints.root |
88cb7938 |
434 | TClonesArray * globalTrigger; |
435 | TClonesArray * localTrigger; |
436 | |
da47578c |
437 | // Do NOT print out all the info if the loop runs over all events |
438 | Int_t PRINTOUT = (event2Check == 0 ) ? 0 : 1 ; |
9e48bfe3 |
439 | |
da47578c |
440 | // Book a ntuple for more detailled studies |
8d4fefab |
441 | TNtuple *TgtupleGlo = new TNtuple("TgtupleGlo","Global Trigger Ntuple","ev:global:slpt:shpt:uplpt:uphpt:lplpt:lplpt"); |
39c07f3b |
442 | TNtuple *TgtupleLoc = new TNtuple("TgtupleLoc","Local Trigger Ntuple","ev:LoCircuit:LoStripX:LoDev:StripY:LoLpt:LoHpt:y11:y21:x11"); |
da47578c |
443 | |
444 | // counters |
8d4fefab |
445 | Int_t SLowpt=0,SHighpt=0; |
39c07f3b |
446 | Int_t USLowpt=0,USHighpt=0; |
447 | Int_t LSLowpt=0,LSHighpt=0; |
da47578c |
448 | |
88cb7938 |
449 | // Creating Run Loader and openning file containing Hits |
450 | AliRunLoader * RunLoader = AliRunLoader::Open(filename,"MUONFolder","READ"); |
451 | if (RunLoader ==0x0) { |
c121e924 |
452 | printf(">>> Error : Error Opening %s file \n",filename); |
453 | return; |
88cb7938 |
454 | } |
84da0ea0 |
455 | |
3b969def |
456 | AliMUONTriggerCrateStore* crateManager = new AliMUONTriggerCrateStore(); |
457 | crateManager->ReadFromFile(); |
458 | |
459 | AliMpSegFactory* segFactory = new AliMpSegFactory(); |
460 | |
461 | AliMUONGeometryTransformer* transformer = new AliMUONGeometryTransformer(kFALSE); |
462 | transformer->ReadGeometryData("volpath.dat", "geometry.root"); |
463 | |
e1a10d41 |
464 | TClonesArray* triggerCircuit = new TClonesArray("AliMUONTriggerCircuit", 234); |
3b969def |
465 | |
466 | for (Int_t i = 0; i < AliMUONConstants::NTriggerCircuit(); i++) { |
e1a10d41 |
467 | AliMUONTriggerCircuit* c = new AliMUONTriggerCircuit(); |
3b969def |
468 | c->SetSegFactory(segFactory); |
469 | c->SetTransformer(transformer); |
470 | c->Init(i,*crateManager); |
471 | TClonesArray& circuit = *triggerCircuit; |
e1a10d41 |
472 | new(circuit[circuit.GetEntriesFast()])AliMUONTriggerCircuit(*c); |
3b969def |
473 | delete c; |
474 | } |
88cb7938 |
475 | |
39c07f3b |
476 | Char_t fileName[30]; |
88cb7938 |
477 | AliLoader * MUONLoader = RunLoader->GetLoader("MUONLoader"); |
39c07f3b |
478 | if (!readFromRP) { |
479 | cout << " reading from digits \n"; |
480 | MUONLoader->LoadDigits("READ"); |
481 | sprintf(fileName,"TriggerCheckFromDigits.root"); |
482 | } else { |
483 | cout << " reading from RecPoints \n"; |
484 | MUONLoader->LoadRecPoints("READ"); |
485 | sprintf(fileName,"TriggerCheckFromRP.root"); |
486 | } |
487 | |
ce3f5e87 |
488 | // Creating MUON data container |
489 | AliMUONData muondata(MUONLoader,"MUON","MUON"); |
88cb7938 |
490 | |
c121e924 |
491 | |
88cb7938 |
492 | Int_t ievent, nevents; |
493 | nevents = RunLoader->GetNumberOfEvents(); |
494 | |
0ad940df |
495 | AliMUONGlobalTrigger *gloTrg(0x0); |
496 | AliMUONLocalTrigger *locTrg(0x0); |
88cb7938 |
497 | |
498 | for (ievent=0; ievent<nevents; ievent++) { |
2b32c661 |
499 | if (event2Check!=0) ievent=event2Check; |
da47578c |
500 | if (ievent%100==0 || event2Check) cout << "Processing event " << ievent << endl; |
c121e924 |
501 | RunLoader->GetEvent(ievent); |
502 | |
39c07f3b |
503 | if (!readFromRP) { |
504 | muondata.SetTreeAddress("D,GLT"); |
505 | muondata.GetTriggerD(); |
506 | } else { |
507 | muondata.SetTreeAddress("RC,TC"); |
508 | muondata.GetTrigger(); |
509 | } |
510 | |
c121e924 |
511 | globalTrigger = muondata.GlobalTrigger(); |
512 | localTrigger = muondata.LocalTrigger(); |
513 | |
514 | Int_t nglobals = (Int_t) globalTrigger->GetEntriesFast(); // should be 1 |
515 | Int_t nlocals = (Int_t) localTrigger->GetEntriesFast(); // up to 234 |
da47578c |
516 | if (PRINTOUT) printf("###################################################\n"); |
eba3379e |
517 | if (PRINTOUT) printf("event %d nglobal %d nlocal %d \n",ievent,nglobals,nlocals); |
518 | |
c121e924 |
519 | for (Int_t iglobal=0; iglobal<nglobals; iglobal++) { // Global Trigger |
520 | gloTrg = static_cast<AliMUONGlobalTrigger*>(globalTrigger->At(iglobal)); |
88cb7938 |
521 | |
8d4fefab |
522 | SLowpt+=gloTrg->SingleLpt() ; |
523 | SHighpt+=gloTrg->SingleHpt() ; |
da47578c |
524 | USLowpt+=gloTrg->PairUnlikeLpt(); |
525 | USHighpt+=gloTrg->PairUnlikeHpt(); |
da47578c |
526 | LSLowpt+=gloTrg->PairLikeLpt(); |
527 | LSHighpt+=gloTrg->PairLikeHpt(); |
88cb7938 |
528 | |
eba3379e |
529 | if (PRINTOUT) gloTrg->Print("full"); |
530 | |
c121e924 |
531 | } // end of loop on Global Trigger |
39c07f3b |
532 | |
c121e924 |
533 | for (Int_t ilocal=0; ilocal<nlocals; ilocal++) { // Local Trigger |
c121e924 |
534 | locTrg = static_cast<AliMUONLocalTrigger*>(localTrigger->At(ilocal)); |
eba3379e |
535 | if (PRINTOUT) locTrg->Print("full"); |
84da0ea0 |
536 | |
e1a10d41 |
537 | AliMUONTriggerCircuit* circuit = (AliMUONTriggerCircuit*)triggerCircuit->At(locTrg->LoCircuit()-1); |
fc103025 |
538 | |
39c07f3b |
539 | TgtupleLoc->Fill(ievent,locTrg->LoCircuit(),locTrg->LoStripX(),locTrg->LoDev(),locTrg->LoStripY(),locTrg->LoLpt(),locTrg->LoHpt(),circuit->GetY11Pos(locTrg->LoStripX()),circuit->GetY21Pos(locTrg->LoStripX()+locTrg->LoDev()+1),circuit->GetX11Pos(locTrg->LoStripY())); |
c121e924 |
540 | } // end of loop on Local Trigger |
da47578c |
541 | |
da47578c |
542 | // fill ntuple |
8d4fefab |
543 | TgtupleGlo->Fill(ievent,nglobals,gloTrg->SingleLpt(),gloTrg->SingleHpt(),gloTrg->PairUnlikeLpt(),gloTrg->PairUnlikeHpt(),gloTrg->PairLikeLpt(),gloTrg->PairLikeHpt()); |
da47578c |
544 | |
c121e924 |
545 | muondata.ResetTrigger(); |
2b32c661 |
546 | if (event2Check!=0) ievent=nevents; |
88cb7938 |
547 | } // end loop on event |
da47578c |
548 | |
549 | // Print out summary if loop ran over all event |
144414de |
550 | if (!event2Check){ |
3b969def |
551 | |
144414de |
552 | printf("\n"); |
39c07f3b |
553 | printf("=============================================\n"); |
554 | printf("================ SUMMARY ==================\n"); |
144414de |
555 | printf("\n"); |
556 | printf("Total number of events processed %d \n", (event2Check==0) ? nevents : 1); |
557 | printf("\n"); |
39c07f3b |
558 | printf(" Global Trigger output Low pt High pt\n"); |
8d4fefab |
559 | printf(" number of Single :\t"); |
560 | printf("%i\t%i\t",SLowpt,SHighpt); |
144414de |
561 | printf("\n"); |
562 | printf(" number of UnlikeSign pair :\t"); |
39c07f3b |
563 | printf("%i\t%i\t",USLowpt,USHighpt); |
144414de |
564 | printf("\n"); |
565 | printf(" number of LikeSign pair :\t"); |
39c07f3b |
566 | printf("%i\t%i\t",LSLowpt,LSHighpt); |
144414de |
567 | printf("\n"); |
39c07f3b |
568 | printf("=============================================\n"); |
3b969def |
569 | fflush(stdout); |
144414de |
570 | } |
571 | |
da47578c |
572 | if (WRITE){ |
39c07f3b |
573 | TFile *myFile = new TFile(fileName, "RECREATE"); |
574 | TgtupleGlo->Write(); |
575 | TgtupleLoc->Write(); |
576 | myFile->Close(); |
da47578c |
577 | } |
c121e924 |
578 | |
da47578c |
579 | MUONLoader->UnloadRecPoints(); |
3b969def |
580 | |
581 | delete crateManager; |
582 | delete segFactory; |
583 | delete transformer; |
584 | delete triggerCircuit; |
585 | |
da47578c |
586 | } |
88cb7938 |
587 | |
9e48bfe3 |
588 | |
bf485fb9 |
589 | void MUONrectracks (Int_t event2Check=0, char * filename="galice.root"){ |
8547965d |
590 | // reads and dumps trigger objects from MUON.RecPoints.root |
591 | TClonesArray * RecTracks; |
592 | |
593 | // Creating Run Loader and openning file containing Hits |
594 | AliRunLoader * RunLoader = AliRunLoader::Open(filename,"MUONFolder","READ"); |
595 | if (RunLoader ==0x0) { |
596 | printf(">>> Error : Error Opening %s file \n",filename); |
597 | return; |
598 | } |
3b969def |
599 | // waiting for mag field in CDB |
600 | printf("Loading field map...\n"); |
601 | if (!AliTracker::GetFieldMap()) { |
b97b210c |
602 | AliMagFMaps* field = new AliMagFMaps("Maps","Maps", 1, 1., 10., AliMagFMaps::k5kG); |
3b969def |
603 | AliTracker::SetFieldMap(field, kFALSE); |
604 | } |
8547965d |
605 | AliLoader * MUONLoader = RunLoader->GetLoader("MUONLoader"); |
606 | MUONLoader->LoadTracks("READ"); |
607 | // Creating MUON data container |
608 | AliMUONData muondata(MUONLoader,"MUON","MUON"); |
609 | |
610 | Int_t ievent, nevents; |
611 | nevents = RunLoader->GetNumberOfEvents(); |
612 | |
e516b01d |
613 | // AliMUONTrack * rectrack; |
8547965d |
614 | |
615 | for (ievent=0; ievent<nevents; ievent++) { |
2b32c661 |
616 | if (event2Check!=0) ievent=event2Check; |
8547965d |
617 | RunLoader->GetEvent(ievent); |
618 | |
619 | muondata.SetTreeAddress("RT"); |
620 | muondata.GetRecTracks(); |
621 | RecTracks = muondata.RecTracks(); |
622 | |
623 | |
624 | Int_t nrectracks = (Int_t) RecTracks->GetEntriesFast(); // |
625 | |
bf485fb9 |
626 | printf(">>> Event %d, Number of Recconstructed tracks %d \n",ievent, nrectracks); |
627 | // loop over tracks |
6464217e |
628 | |
629 | // setting pointer for tracks, triggertracks & trackparam at vertex |
bf485fb9 |
630 | AliMUONTrack* recTrack = 0; |
631 | AliMUONTrackParam* trackParam = 0; |
632 | |
633 | for (Int_t iRecTracks = 0; iRecTracks < nrectracks; iRecTracks++) { |
6464217e |
634 | // // reading info from tracks |
635 | recTrack = (AliMUONTrack*) RecTracks->At(iRecTracks); |
636 | trackParam = (AliMUONTrackParam*) (recTrack->GetTrackParamAtHit())->First(); |
637 | trackParam->ExtrapToZ(0.0); |
638 | recTrack->Print("full"); |
bf485fb9 |
639 | } // end loop tracks |
640 | |
8547965d |
641 | muondata.ResetRecTracks(); |
2b32c661 |
642 | if (event2Check!=0) ievent=nevents; |
8547965d |
643 | } // end loop on event |
644 | MUONLoader->UnloadTracks(); |
645 | } |
646 | |