Using AliMpSegmentation instead of AliMpSegFactory which was removed
[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
3e8e7033 57#include "AliMpSegmentation.h"
bf485fb9 58#include "AliMpVSegmentation.h"
59#include "AliMpIntPair.h"
6babe058 60#include "AliMpDEManager.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;
3e8e7033 245 const AliMpVSegmentation * segbend = 0x0;
246 const AliMpVSegmentation * segnonbend = 0x0;
bf485fb9 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
266 for (ichamber=0; ichamber<nchambers; ichamber++) {
267 cHchannels_bending[ichamber]=0;
268 cHchannels_nonbending[ichamber]=0;
269 for (idetele=0; idetele<26; idetele++) {
270 detele= 100*(ichamber +1)+idetele;
271 dEchannels_bending[ichamber][idetele]=0;
272 dEchannels_nonbending[ichamber][idetele]=0;
273 dEoccupancy_bending[ichamber][idetele]=0;
274 dEoccupancy_nonbending[ichamber][idetele]=0;
6babe058 275 if ( AliMpDEManager::IsValidDetElemId(detele) ) {
276
3e8e7033 277 segbend = AliMpSegmentation::Instance()->GetMpSegmentation(detele, 0);
278 segnonbend = AliMpSegmentation::Instance()->GetMpSegmentation(detele, 1);
6babe058 279 if (AliMpDEManager::GetPlaneType(detele, 0) != kBendingPlane ) {
3e8e7033 280 const AliMpVSegmentation* tmp = segbend;
6babe058 281 segbend = segnonbend;
282 segnonbend = tmp;
283 }
284
bf485fb9 285 for(ix=0; ix<=segbend->MaxPadIndexX(); ix++) {
286 for(iy=0; iy<=segbend->MaxPadIndexY(); iy++) {
287 pad.SetFirst(ix);
288 pad.SetSecond(iy);
289 if( segbend->HasPad(pad) ) {
290 dEchannels_bending[ichamber][idetele]++;
291 cHchannels_bending[ichamber]++;
292 totalchannels_bending++;
293 }
294 }
295 }
296 for(ix=0; ix<=segnonbend->MaxPadIndexX(); ix++) {
297 for(iy=0; iy<=segnonbend->MaxPadIndexY(); iy++) {
298 pad.SetFirst(ix);
299 pad.SetSecond(iy);
300 if(segnonbend->HasPad(pad)) {
301 dEchannels_nonbending[ichamber][idetele]++;
302 cHchannels_nonbending[ichamber]++;
303 totalchannels_nonbending++;
304 }
305 }
306 }
307 if (perDetEle) printf(">>> Detection element %4d has %5d channels in bending and %5d channels in nonbending \n",
308 detele, dEchannels_bending[ichamber][idetele], dEchannels_nonbending[ichamber][idetele] );
309 }
310 }
311 printf(">>> Chamber %2d has %6d channels in bending and %6d channels in nonbending \n",
312 ichamber+1, cHchannels_bending[ichamber], cHchannels_nonbending[ichamber]);
313 }
314 printf(">>Spectrometer has %7d channels in bending and %7d channels in nonbending \n",
315 totalchannels_bending, totalchannels_nonbending);
316
317 ievent=event2Check;
318 printf(">>> Event %d \n",ievent);
319 RunLoader->GetEvent(ievent);
320
321 // Addressing
322 muondata.SetTreeAddress("D");
323 muondata.GetDigits();
324 // Loop on chambers
325 for( ichamber=0; ichamber<nchambers; ichamber++) {
326 cHoccupancy_bending[ichamber] = 0;
327 cHoccupancy_nonbending[ichamber]= 0;
328 Int_t idigit, ndigits;
329 ndigits = (Int_t) muondata.Digits(ichamber)->GetEntriesFast();
330 for(idigit=0; idigit<ndigits; idigit++) {
331 mDigit = static_cast<AliMUONDigit*>(muondata.Digits(ichamber)->At(idigit));
332 Int_t detele = mDigit->DetElemId();
333 Int_t idetele = detele-(ichamber+1)*100;
334 if ( mDigit->Cathode() == 0 ) {
335
336 cHoccupancy_bending[ichamber]++;
337 dEoccupancy_bending[ichamber][idetele]++;
338 totaloccupancy_bending++;
339 }
340 else {
341 cHoccupancy_nonbending[ichamber]++;
342 dEoccupancy_nonbending[ichamber][idetele]++;
343 totaloccupancy_nonbending++;
344 }
345 } // end digit loop
346
347 printf(">>> Chamber %2d nChannels Bending %5d nChannels NonBending %5d \n",
348 ichamber+1,
349 cHoccupancy_bending[ichamber],
350 cHoccupancy_nonbending[ichamber]);
0ad940df 351 printf(">>> Chamber %2d Occupancy Bending %5.2f %% Occupancy NonBending %5.2f %% \n",
bf485fb9 352 ichamber+1,
353 100.*((Float_t) cHoccupancy_bending[ichamber])/((Float_t) cHchannels_bending[ichamber]),
354 100.*((Float_t) cHoccupancy_nonbending[ichamber])/((Float_t) cHchannels_bending[ichamber]) );
355
356
357 for(Int_t idetele=0; idetele<26; idetele++) {
358 Int_t detele = idetele + 100*(ichamber+1);
6babe058 359 if ( AliMpDEManager::IsValidDetElemId(detele) ) {
bf485fb9 360 if (perDetEle) {
361 printf(">>> DetEle %4d nChannels Bending %5d nChannels NonBending %5d \n",
362 idetele+100*(ichamber+1),
363 dEoccupancy_bending[ichamber][idetele],
364 dEoccupancy_nonbending[ichamber][idetele]);
0ad940df 365 printf(">>> DetEle %4d Occupancy Bending %5.2f %% Occupancy NonBending %5.2f %% \n",
bf485fb9 366 idetele+100*(ichamber+1),
367 100.*((Float_t) dEoccupancy_bending[ichamber][idetele])/((Float_t) dEchannels_bending[ichamber][idetele]),
368 100.*((Float_t) dEoccupancy_nonbending[ichamber][idetele])/((Float_t) dEchannels_bending[ichamber][idetele]));
369 }
370 }
371 }
372 } // end chamber loop
0ad940df 373 printf(">>> Muon Spectrometer Occupancy Bending %5.2f %% Occupancy NonBending %5.2f %% \n",
bf485fb9 374 100.*((Float_t) totaloccupancy_bending)/((Float_t) totalchannels_bending),
375 100.*((Float_t) totaloccupancy_nonbending)/((Float_t) totalchannels_nonbending) );
376 muondata.ResetDigits();
377 // } // end cathode loop
378 MUONLoader->UnloadDigits();
379}
380
381void MUONrecpoints(Int_t event2Check=0, char * filename="galice.root") {
88cb7938 382
88cb7938 383 // Creating Run Loader and openning file containing Hits
384 AliRunLoader * RunLoader = AliRunLoader::Open(filename,"MUONFolder","READ");
385 if (RunLoader ==0x0) {
386 printf(">>> Error : Error Opening %s file \n",filename);
387 return;
388 }
ce3f5e87 389 // Getting MUONloader
88cb7938 390 AliLoader * MUONLoader = RunLoader->GetLoader("MUONLoader");
391 MUONLoader->LoadRecPoints("READ");
ce3f5e87 392 // Creating MUON data container
393 AliMUONData muondata(MUONLoader,"MUON","MUON");
88cb7938 394
395 Int_t ievent, nevents;
396 nevents = RunLoader->GetNumberOfEvents();
e516b01d 397 AliMUONRawCluster * mRecPoint = 0;
88cb7938 398
88cb7938 399 for(ievent=0; ievent<nevents; ievent++) {
2b32c661 400 if (event2Check!=0) ievent=event2Check;
88cb7938 401 printf(">>> Event %d \n",ievent);
402 RunLoader->GetEvent(ievent);
88cb7938 403 // Addressing
404 Int_t ichamber, nchambers;
405 nchambers = AliMUONConstants::NTrackingCh();
6babe058 406 muondata.SetTreeAddress("RC,TC");
88cb7938 407 char branchname[30];
1a1cdff8 408 muondata.GetRawClusters();
88cb7938 409 // Loop on chambers
410 for( ichamber=0; ichamber<nchambers; ichamber++) {
88cb7938 411 sprintf(branchname,"MUONRawClusters%d",ichamber+1);
412 //printf(">>> branchname %s\n",branchname);
88cb7938 413 Int_t irecpoint, nrecpoints;
ce3f5e87 414 nrecpoints = (Int_t) muondata.RawClusters(ichamber)->GetEntriesFast();
bf485fb9 415 // printf(">>> Chamber %2d, Number of recpoints = %6d \n",ichamber+1, nrecpoints);
88cb7938 416 for(irecpoint=0; irecpoint<nrecpoints; irecpoint++) {
ce3f5e87 417 mRecPoint = static_cast<AliMUONRawCluster*>(muondata.RawClusters(ichamber)->At(irecpoint));
6464217e 418 mRecPoint->Print("full");
88cb7938 419 } // end recpoint loop
420 } // end chamber loop
ce3f5e87 421 muondata.ResetRawClusters();
2b32c661 422 if (event2Check!=0) ievent=nevents;
88cb7938 423 } // end event loop
424 MUONLoader->UnloadRecPoints();
425}
426
39c07f3b 427void MUONrectrigger (Int_t event2Check=0, char * filename="galice.root", Int_t WRITE = 0, Bool_t readFromRP = 0)
9e48bfe3 428{
84da0ea0 429
da47578c 430 // reads and dumps trigger objects from MUON.RecPoints.root
88cb7938 431 TClonesArray * globalTrigger;
432 TClonesArray * localTrigger;
433
da47578c 434 // Do NOT print out all the info if the loop runs over all events
435 Int_t PRINTOUT = (event2Check == 0 ) ? 0 : 1 ;
9e48bfe3 436
da47578c 437 // Book a ntuple for more detailled studies
8d4fefab 438 TNtuple *TgtupleGlo = new TNtuple("TgtupleGlo","Global Trigger Ntuple","ev:global:slpt:shpt:uplpt:uphpt:lplpt:lplpt");
39c07f3b 439 TNtuple *TgtupleLoc = new TNtuple("TgtupleLoc","Local Trigger Ntuple","ev:LoCircuit:LoStripX:LoDev:StripY:LoLpt:LoHpt:y11:y21:x11");
da47578c 440
441 // counters
8d4fefab 442 Int_t SLowpt=0,SHighpt=0;
39c07f3b 443 Int_t USLowpt=0,USHighpt=0;
444 Int_t LSLowpt=0,LSHighpt=0;
da47578c 445
88cb7938 446 // Creating Run Loader and openning file containing Hits
447 AliRunLoader * RunLoader = AliRunLoader::Open(filename,"MUONFolder","READ");
448 if (RunLoader ==0x0) {
c121e924 449 printf(">>> Error : Error Opening %s file \n",filename);
450 return;
88cb7938 451 }
84da0ea0 452
3b969def 453 AliMUONTriggerCrateStore* crateManager = new AliMUONTriggerCrateStore();
454 crateManager->ReadFromFile();
455
3b969def 456 AliMUONGeometryTransformer* transformer = new AliMUONGeometryTransformer(kFALSE);
457 transformer->ReadGeometryData("volpath.dat", "geometry.root");
458
e1a10d41 459 TClonesArray* triggerCircuit = new TClonesArray("AliMUONTriggerCircuit", 234);
3b969def 460
461 for (Int_t i = 0; i < AliMUONConstants::NTriggerCircuit(); i++) {
e1a10d41 462 AliMUONTriggerCircuit* c = new AliMUONTriggerCircuit();
3b969def 463 c->SetTransformer(transformer);
464 c->Init(i,*crateManager);
465 TClonesArray& circuit = *triggerCircuit;
e1a10d41 466 new(circuit[circuit.GetEntriesFast()])AliMUONTriggerCircuit(*c);
3b969def 467 delete c;
468 }
88cb7938 469
39c07f3b 470 Char_t fileName[30];
88cb7938 471 AliLoader * MUONLoader = RunLoader->GetLoader("MUONLoader");
39c07f3b 472 if (!readFromRP) {
473 cout << " reading from digits \n";
474 MUONLoader->LoadDigits("READ");
475 sprintf(fileName,"TriggerCheckFromDigits.root");
476 } else {
477 cout << " reading from RecPoints \n";
478 MUONLoader->LoadRecPoints("READ");
479 sprintf(fileName,"TriggerCheckFromRP.root");
480 }
481
ce3f5e87 482 // Creating MUON data container
483 AliMUONData muondata(MUONLoader,"MUON","MUON");
88cb7938 484
c121e924 485
88cb7938 486 Int_t ievent, nevents;
487 nevents = RunLoader->GetNumberOfEvents();
488
0ad940df 489 AliMUONGlobalTrigger *gloTrg(0x0);
490 AliMUONLocalTrigger *locTrg(0x0);
88cb7938 491
492 for (ievent=0; ievent<nevents; ievent++) {
2b32c661 493 if (event2Check!=0) ievent=event2Check;
da47578c 494 if (ievent%100==0 || event2Check) cout << "Processing event " << ievent << endl;
c121e924 495 RunLoader->GetEvent(ievent);
496
39c07f3b 497 if (!readFromRP) {
498 muondata.SetTreeAddress("D,GLT");
499 muondata.GetTriggerD();
500 } else {
501 muondata.SetTreeAddress("RC,TC");
502 muondata.GetTrigger();
503 }
504
c121e924 505 globalTrigger = muondata.GlobalTrigger();
506 localTrigger = muondata.LocalTrigger();
507
508 Int_t nglobals = (Int_t) globalTrigger->GetEntriesFast(); // should be 1
509 Int_t nlocals = (Int_t) localTrigger->GetEntriesFast(); // up to 234
da47578c 510 if (PRINTOUT) printf("###################################################\n");
eba3379e 511 if (PRINTOUT) printf("event %d nglobal %d nlocal %d \n",ievent,nglobals,nlocals);
512
c121e924 513 for (Int_t iglobal=0; iglobal<nglobals; iglobal++) { // Global Trigger
514 gloTrg = static_cast<AliMUONGlobalTrigger*>(globalTrigger->At(iglobal));
88cb7938 515
8d4fefab 516 SLowpt+=gloTrg->SingleLpt() ;
517 SHighpt+=gloTrg->SingleHpt() ;
da47578c 518 USLowpt+=gloTrg->PairUnlikeLpt();
519 USHighpt+=gloTrg->PairUnlikeHpt();
da47578c 520 LSLowpt+=gloTrg->PairLikeLpt();
521 LSHighpt+=gloTrg->PairLikeHpt();
88cb7938 522
eba3379e 523 if (PRINTOUT) gloTrg->Print("full");
524
c121e924 525 } // end of loop on Global Trigger
39c07f3b 526
c121e924 527 for (Int_t ilocal=0; ilocal<nlocals; ilocal++) { // Local Trigger
c121e924 528 locTrg = static_cast<AliMUONLocalTrigger*>(localTrigger->At(ilocal));
eba3379e 529 if (PRINTOUT) locTrg->Print("full");
84da0ea0 530
e1a10d41 531 AliMUONTriggerCircuit* circuit = (AliMUONTriggerCircuit*)triggerCircuit->At(locTrg->LoCircuit()-1);
fc103025 532
39c07f3b 533 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 534 } // end of loop on Local Trigger
da47578c 535
da47578c 536 // fill ntuple
8d4fefab 537 TgtupleGlo->Fill(ievent,nglobals,gloTrg->SingleLpt(),gloTrg->SingleHpt(),gloTrg->PairUnlikeLpt(),gloTrg->PairUnlikeHpt(),gloTrg->PairLikeLpt(),gloTrg->PairLikeHpt());
da47578c 538
c121e924 539 muondata.ResetTrigger();
2b32c661 540 if (event2Check!=0) ievent=nevents;
88cb7938 541 } // end loop on event
da47578c 542
543 // Print out summary if loop ran over all event
144414de 544 if (!event2Check){
3b969def 545
144414de 546 printf("\n");
39c07f3b 547 printf("=============================================\n");
548 printf("================ SUMMARY ==================\n");
144414de 549 printf("\n");
550 printf("Total number of events processed %d \n", (event2Check==0) ? nevents : 1);
551 printf("\n");
39c07f3b 552 printf(" Global Trigger output Low pt High pt\n");
8d4fefab 553 printf(" number of Single :\t");
554 printf("%i\t%i\t",SLowpt,SHighpt);
144414de 555 printf("\n");
556 printf(" number of UnlikeSign pair :\t");
39c07f3b 557 printf("%i\t%i\t",USLowpt,USHighpt);
144414de 558 printf("\n");
559 printf(" number of LikeSign pair :\t");
39c07f3b 560 printf("%i\t%i\t",LSLowpt,LSHighpt);
144414de 561 printf("\n");
39c07f3b 562 printf("=============================================\n");
3b969def 563 fflush(stdout);
144414de 564 }
565
da47578c 566 if (WRITE){
39c07f3b 567 TFile *myFile = new TFile(fileName, "RECREATE");
568 TgtupleGlo->Write();
569 TgtupleLoc->Write();
570 myFile->Close();
da47578c 571 }
c121e924 572
da47578c 573 MUONLoader->UnloadRecPoints();
3b969def 574
575 delete crateManager;
3b969def 576 delete transformer;
577 delete triggerCircuit;
578
da47578c 579}
88cb7938 580
9e48bfe3 581
bf485fb9 582void MUONrectracks (Int_t event2Check=0, char * filename="galice.root"){
8547965d 583// reads and dumps trigger objects from MUON.RecPoints.root
584 TClonesArray * RecTracks;
585
586 // Creating Run Loader and openning file containing Hits
587 AliRunLoader * RunLoader = AliRunLoader::Open(filename,"MUONFolder","READ");
588 if (RunLoader ==0x0) {
589 printf(">>> Error : Error Opening %s file \n",filename);
590 return;
591 }
3b969def 592 // waiting for mag field in CDB
593 printf("Loading field map...\n");
594 if (!AliTracker::GetFieldMap()) {
b97b210c 595 AliMagFMaps* field = new AliMagFMaps("Maps","Maps", 1, 1., 10., AliMagFMaps::k5kG);
3b969def 596 AliTracker::SetFieldMap(field, kFALSE);
597 }
8547965d 598 AliLoader * MUONLoader = RunLoader->GetLoader("MUONLoader");
599 MUONLoader->LoadTracks("READ");
600 // Creating MUON data container
601 AliMUONData muondata(MUONLoader,"MUON","MUON");
602
603 Int_t ievent, nevents;
604 nevents = RunLoader->GetNumberOfEvents();
605
e516b01d 606 // AliMUONTrack * rectrack;
8547965d 607
608 for (ievent=0; ievent<nevents; ievent++) {
2b32c661 609 if (event2Check!=0) ievent=event2Check;
8547965d 610 RunLoader->GetEvent(ievent);
611
612 muondata.SetTreeAddress("RT");
613 muondata.GetRecTracks();
614 RecTracks = muondata.RecTracks();
615
616
617 Int_t nrectracks = (Int_t) RecTracks->GetEntriesFast(); //
618
bf485fb9 619 printf(">>> Event %d, Number of Recconstructed tracks %d \n",ievent, nrectracks);
620 // loop over tracks
6464217e 621
622 // setting pointer for tracks, triggertracks & trackparam at vertex
bf485fb9 623 AliMUONTrack* recTrack = 0;
624 AliMUONTrackParam* trackParam = 0;
625
37827b29 626 // set the magnetic field for track extrapolations
627 AliMUONTrackExtrap::SetField(AliTracker::GetFieldMap());
bf485fb9 628 for (Int_t iRecTracks = 0; iRecTracks < nrectracks; iRecTracks++) {
6464217e 629 // // reading info from tracks
630 recTrack = (AliMUONTrack*) RecTracks->At(iRecTracks);
631 trackParam = (AliMUONTrackParam*) (recTrack->GetTrackParamAtHit())->First();
37827b29 632 AliMUONTrackExtrap::ExtrapToZ(trackParam,0.);
6464217e 633 recTrack->Print("full");
bf485fb9 634 } // end loop tracks
635
8547965d 636 muondata.ResetRecTracks();
2b32c661 637 if (event2Check!=0) ievent=nevents;
8547965d 638 } // end loop on event
639 MUONLoader->UnloadTracks();
640}
641