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