New implementation for data quality control
[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"
9120648a 61#include "AliMpCathodType.h"
62#include "AliMpPlaneType.h"
e516b01d 63#endif
2b32c661 64
bf485fb9 65void MUONkine(Int_t event2Check=0, char * filename="galice.root")
88cb7938 66{
3b0cf968 67 // Stack of particle for each event
68 AliStack* stack;
88cb7938 69 // Creating Run Loader and openning file containing Hits
70 AliRunLoader * RunLoader = AliRunLoader::Open(filename,"MUONFolder","READ");
71 if (RunLoader ==0x0) {
72 printf(">>> Error : Error Opening %s file \n",filename);
73 return;
74 }
3b0cf968 75
88cb7938 76 RunLoader->LoadKinematics("READ");
77 Int_t ievent, nevents;
78 nevents = RunLoader->GetNumberOfEvents();
79
80 for(ievent=0; ievent<nevents; ievent++) { // Event loop
2b32c661 81 if (event2Check!=0) ievent=event2Check;
88cb7938 82 Int_t iparticle, nparticles;
83 // Getting event ievent
84 RunLoader->GetEvent(ievent);
3b0cf968 85 stack = RunLoader->Stack();
86 nparticles = (Int_t) stack->GetNtrack();
88cb7938 87 printf(">>> Event %d, Number of particles is %d \n",ievent, nparticles);
88 for(iparticle=0; iparticle<nparticles; iparticle++) {
3b0cf968 89 stack->Particle(iparticle)->Print("");
88cb7938 90 }
2b32c661 91 if (event2Check!=0) ievent=nevents;
88cb7938 92 }
93 RunLoader->UnloadKinematics();
94}
95
96
bf485fb9 97void MUONhits(Int_t event2Check=0, char * filename="galice.root")
88cb7938 98{
88cb7938 99 // Creating Run Loader and openning file containing Hits
100 AliRunLoader * RunLoader = AliRunLoader::Open(filename,"MUONFolder","READ");
101 if (RunLoader ==0x0) {
102 printf(">>> Error : Error Opening %s file \n",filename);
103 return;
104 }
88cb7938 105 // Loading MUON subsystem
106 AliLoader * MUONLoader = RunLoader->GetLoader("MUONLoader");
1a1cdff8 107 MUONLoader->LoadHits("READ"); // Loading Tree of hits for MUON
108 AliMUONData muondata(MUONLoader,"MUON","MUON"); // Creating MUON data container
88cb7938 109 Int_t ievent, nevents;
110 nevents = RunLoader->GetNumberOfEvents();
111
112 for(ievent=0; ievent<nevents; ievent++) { // Event loop
2b32c661 113 if (event2Check!=0) ievent=event2Check;
88cb7938 114 printf(">>> Event %d \n",ievent);
88cb7938 115 // Getting event ievent
116 RunLoader->GetEvent(ievent);
ce3f5e87 117 muondata.SetTreeAddress("H");
88cb7938 118 Int_t itrack, ntracks;
1a1cdff8 119 ntracks = (Int_t) muondata.GetNtracks();
88cb7938 120 for (itrack=0; itrack<ntracks; itrack++) { // Track loop
88cb7938 121 //Getting List of Hits of Track itrack
bf485fb9 122 muondata.GetTrack(itrack);
88cb7938 123 Int_t ihit, nhits;
ce3f5e87 124 nhits = (Int_t) muondata.Hits()->GetEntriesFast();
bf485fb9 125 printf(">>> Track %d, Number of hits %d \n",itrack,nhits);
88cb7938 126 AliMUONHit* mHit;
127 for(ihit=0; ihit<nhits; ihit++) {
ce3f5e87 128 mHit = static_cast<AliMUONHit*>(muondata.Hits()->At(ihit));
6464217e 129 mHit->Print("full");
88cb7938 130 }
ce3f5e87 131 muondata.ResetHits();
88cb7938 132 } // end track loop
2b32c661 133 if (event2Check!=0) ievent=nevents;
88cb7938 134 } // end event loop
135 MUONLoader->UnloadHits();
136}
137
138
bf485fb9 139void MUONdigits(Int_t event2Check=0, char * filename="galice.root")
88cb7938 140{
88cb7938 141 // Creating Run Loader and openning file containing Hits
142 AliRunLoader * RunLoader = AliRunLoader::Open(filename,"MUONFolder","READ");
143 if (RunLoader ==0x0) {
144 printf(">>> Error : Error Opening %s file \n",filename);
145 return;
146 }
ce3f5e87 147 // Loading MUON subsystem
88cb7938 148 AliLoader * MUONLoader = RunLoader->GetLoader("MUONLoader");
149 MUONLoader->LoadDigits("READ");
ce3f5e87 150 // Creating MUON data container
151 AliMUONData muondata(MUONLoader,"MUON","MUON");
75fbac63 152
88cb7938 153 Int_t ievent, nevents;
154 nevents = RunLoader->GetNumberOfEvents();
88cb7938 155 AliMUONDigit * mDigit;
156
88cb7938 157 for(ievent=0; ievent<nevents; ievent++) {
2b32c661 158 if (event2Check!=0) ievent=event2Check;
88cb7938 159 printf(">>> Event %d \n",ievent);
160 RunLoader->GetEvent(ievent);
75fbac63 161
88cb7938 162 // Addressing
163 Int_t ichamber, nchambers;
164 nchambers = AliMUONConstants::NCh(); ;
6babe058 165 muondata.SetTreeAddress("D,GLT");
75fbac63 166
bf485fb9 167 muondata.GetDigits();
168 // Loop on chambers
169 for( ichamber=0; ichamber<nchambers; ichamber++) {
170 Int_t idigit, ndigits;
75fbac63 171 TClonesArray* digits = muondata.Digits(ichamber);
172 digits->Sort();
173 ndigits = (Int_t)digits->GetEntriesFast();
bf485fb9 174 for(idigit=0; idigit<ndigits; idigit++) {
75fbac63 175 mDigit = static_cast<AliMUONDigit*>(digits->At(idigit));
176 mDigit->Print("tracks");
bf485fb9 177 } // end digit loop
178 } // end chamber loop
179 muondata.ResetDigits();
2b32c661 180 if (event2Check!=0) ievent=nevents;
88cb7938 181 } // end event loop
182 MUONLoader->UnloadDigits();
183}
184
75fbac63 185void MUONsdigits(Int_t event2Check=0, char * filename="galice.root")
186{
187 // Creating Run Loader and openning file containing Hits
188 AliRunLoader * RunLoader = AliRunLoader::Open(filename,"MUONFolder","READ");
189 if (RunLoader ==0x0) {
190 printf(">>> Error : Error Opening %s file \n",filename);
191 return;
192 }
193 // Loading MUON subsystem
194 AliLoader * MUONLoader = RunLoader->GetLoader("MUONLoader");
195 MUONLoader->LoadSDigits("READ");
196 // Creating MUON data container
197 AliMUONData muondata(MUONLoader,"MUON","MUON");
198
199 Int_t ievent, nevents;
200 nevents = RunLoader->GetNumberOfEvents();
201 AliMUONDigit * mDigit;
202
203 for(ievent=0; ievent<nevents; ievent++) {
204 if (event2Check!=0) ievent=event2Check;
205 printf(">>> Event %d \n",ievent);
206 RunLoader->GetEvent(ievent);
207
208 // Addressing
209 Int_t ichamber, nchambers;
210 nchambers = AliMUONConstants::NCh(); ;
211 muondata.SetTreeAddress("S");
212
213 muondata.GetSDigits();
214 // Loop on chambers
215 for( ichamber=0; ichamber<nchambers; ichamber++) {
216 Int_t idigit, ndigits;
217 TClonesArray* digits = muondata.SDigits(ichamber);
218 ndigits = (Int_t)digits->GetEntriesFast();
219 for(idigit=0; idigit<ndigits; idigit++) {
220 mDigit = static_cast<AliMUONDigit*>(digits->At(idigit));
221 mDigit->Print("tracks");
222 } // end digit loop
223 } // end chamber loop
224 muondata.ResetSDigits();
225 if (event2Check!=0) ievent=nevents;
226 } // end event loop
227 MUONLoader->UnloadSDigits();
3b969def 228
75fbac63 229}
230
bf485fb9 231void MUONoccupancy(Int_t event2Check=0, Bool_t perDetEle =kFALSE, char * filename="galice.root") {
232 // Creating Run Loader and openning file containing Hits
233 AliRunLoader * RunLoader = AliRunLoader::Open(filename,"MUONFolder","READ");
234 if (RunLoader ==0x0) {
235 printf(">>> Error : Error Opening %s file \n",filename);
236 return;
237 }
238 // Loading MUON subsystem
239 AliLoader * MUONLoader = RunLoader->GetLoader("MUONLoader");
240 MUONLoader->LoadDigits("READ");
241 // Creating MUON data container
242 AliMUONData muondata(MUONLoader,"MUON","MUON");
243
244 Int_t ievent, nevents;
245 nevents = RunLoader->GetNumberOfEvents();
246 AliMUONDigit * mDigit =0x0;
3e8e7033 247 const AliMpVSegmentation * segbend = 0x0;
248 const AliMpVSegmentation * segnonbend = 0x0;
bf485fb9 249 AliMpIntPair pad(0,0);
250
251 Int_t dEoccupancy_bending[14][26];
252 Int_t dEoccupancy_nonbending[14][26];
253 Int_t cHoccupancy_bending[14];
254 Int_t cHoccupancy_nonbending[14];
255 Int_t totaloccupancy_bending =0;
256 Int_t totaloccupancy_nonbending =0;
257
258 Int_t dEchannels_bending[14][26];
259 Int_t dEchannels_nonbending[14][26];
260 Int_t cHchannels_bending[14];
261 Int_t cHchannels_nonbending[14];
262 Int_t totalchannels_bending =0;
263 Int_t totalchannels_nonbending =0;
264
265 Int_t ichamber, nchambers,idetele, detele, ix, iy;
266 nchambers = AliMUONConstants::NCh(); ;
267
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) ) {
9120648a 278 segbend = AliMpSegmentation::Instance()
279 ->GetMpSegmentation(detele, AliMp::kCath0);
280 segnonbend = AliMpSegmentation::Instance()
281 ->GetMpSegmentation(detele, AliMp::kCath1);
282 if (AliMpDEManager::GetPlaneType(detele, AliMp::kCath0) != AliMp::kBendingPlane ) {
3e8e7033 283 const AliMpVSegmentation* tmp = segbend;
6babe058 284 segbend = segnonbend;
285 segnonbend = tmp;
286 }
287
bf485fb9 288 for(ix=0; ix<=segbend->MaxPadIndexX(); ix++) {
289 for(iy=0; iy<=segbend->MaxPadIndexY(); iy++) {
290 pad.SetFirst(ix);
291 pad.SetSecond(iy);
292 if( segbend->HasPad(pad) ) {
293 dEchannels_bending[ichamber][idetele]++;
294 cHchannels_bending[ichamber]++;
295 totalchannels_bending++;
296 }
297 }
298 }
299 for(ix=0; ix<=segnonbend->MaxPadIndexX(); ix++) {
300 for(iy=0; iy<=segnonbend->MaxPadIndexY(); iy++) {
301 pad.SetFirst(ix);
302 pad.SetSecond(iy);
303 if(segnonbend->HasPad(pad)) {
304 dEchannels_nonbending[ichamber][idetele]++;
305 cHchannels_nonbending[ichamber]++;
306 totalchannels_nonbending++;
307 }
308 }
309 }
310 if (perDetEle) printf(">>> Detection element %4d has %5d channels in bending and %5d channels in nonbending \n",
311 detele, dEchannels_bending[ichamber][idetele], dEchannels_nonbending[ichamber][idetele] );
312 }
313 }
314 printf(">>> Chamber %2d has %6d channels in bending and %6d channels in nonbending \n",
315 ichamber+1, cHchannels_bending[ichamber], cHchannels_nonbending[ichamber]);
316 }
317 printf(">>Spectrometer has %7d channels in bending and %7d channels in nonbending \n",
318 totalchannels_bending, totalchannels_nonbending);
319
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
384void 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 430void 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
3b969def 459 AliMUONGeometryTransformer* transformer = new AliMUONGeometryTransformer(kFALSE);
460 transformer->ReadGeometryData("volpath.dat", "geometry.root");
461
e1a10d41 462 TClonesArray* triggerCircuit = new TClonesArray("AliMUONTriggerCircuit", 234);
3b969def 463
464 for (Int_t i = 0; i < AliMUONConstants::NTriggerCircuit(); i++) {
e1a10d41 465 AliMUONTriggerCircuit* c = new AliMUONTriggerCircuit();
3b969def 466 c->SetTransformer(transformer);
467 c->Init(i,*crateManager);
468 TClonesArray& circuit = *triggerCircuit;
e1a10d41 469 new(circuit[circuit.GetEntriesFast()])AliMUONTriggerCircuit(*c);
3b969def 470 delete c;
471 }
88cb7938 472
39c07f3b 473 Char_t fileName[30];
88cb7938 474 AliLoader * MUONLoader = RunLoader->GetLoader("MUONLoader");
39c07f3b 475 if (!readFromRP) {
476 cout << " reading from digits \n";
477 MUONLoader->LoadDigits("READ");
478 sprintf(fileName,"TriggerCheckFromDigits.root");
479 } else {
480 cout << " reading from RecPoints \n";
481 MUONLoader->LoadRecPoints("READ");
482 sprintf(fileName,"TriggerCheckFromRP.root");
483 }
484
ce3f5e87 485 // Creating MUON data container
486 AliMUONData muondata(MUONLoader,"MUON","MUON");
88cb7938 487
c121e924 488
88cb7938 489 Int_t ievent, nevents;
490 nevents = RunLoader->GetNumberOfEvents();
491
0ad940df 492 AliMUONGlobalTrigger *gloTrg(0x0);
493 AliMUONLocalTrigger *locTrg(0x0);
88cb7938 494
495 for (ievent=0; ievent<nevents; ievent++) {
2b32c661 496 if (event2Check!=0) ievent=event2Check;
da47578c 497 if (ievent%100==0 || event2Check) cout << "Processing event " << ievent << endl;
c121e924 498 RunLoader->GetEvent(ievent);
499
39c07f3b 500 if (!readFromRP) {
501 muondata.SetTreeAddress("D,GLT");
502 muondata.GetTriggerD();
503 } else {
504 muondata.SetTreeAddress("RC,TC");
505 muondata.GetTrigger();
506 }
507
c121e924 508 globalTrigger = muondata.GlobalTrigger();
509 localTrigger = muondata.LocalTrigger();
510
511 Int_t nglobals = (Int_t) globalTrigger->GetEntriesFast(); // should be 1
512 Int_t nlocals = (Int_t) localTrigger->GetEntriesFast(); // up to 234
da47578c 513 if (PRINTOUT) printf("###################################################\n");
eba3379e 514 if (PRINTOUT) printf("event %d nglobal %d nlocal %d \n",ievent,nglobals,nlocals);
515
c121e924 516 for (Int_t iglobal=0; iglobal<nglobals; iglobal++) { // Global Trigger
517 gloTrg = static_cast<AliMUONGlobalTrigger*>(globalTrigger->At(iglobal));
88cb7938 518
8d4fefab 519 SLowpt+=gloTrg->SingleLpt() ;
520 SHighpt+=gloTrg->SingleHpt() ;
da47578c 521 USLowpt+=gloTrg->PairUnlikeLpt();
522 USHighpt+=gloTrg->PairUnlikeHpt();
da47578c 523 LSLowpt+=gloTrg->PairLikeLpt();
524 LSHighpt+=gloTrg->PairLikeHpt();
88cb7938 525
eba3379e 526 if (PRINTOUT) gloTrg->Print("full");
527
c121e924 528 } // end of loop on Global Trigger
39c07f3b 529
c121e924 530 for (Int_t ilocal=0; ilocal<nlocals; ilocal++) { // Local Trigger
c121e924 531 locTrg = static_cast<AliMUONLocalTrigger*>(localTrigger->At(ilocal));
95b727ce 532
4a69b40c 533 if (locTrg->LoLpt()!=0) { // board is fired
95b727ce 534
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()));
4a69b40c 540 } // board is fired
95b727ce 541
c121e924 542 } // end of loop on Local Trigger
da47578c 543
da47578c 544 // fill ntuple
8d4fefab 545 TgtupleGlo->Fill(ievent,nglobals,gloTrg->SingleLpt(),gloTrg->SingleHpt(),gloTrg->PairUnlikeLpt(),gloTrg->PairUnlikeHpt(),gloTrg->PairLikeLpt(),gloTrg->PairLikeHpt());
da47578c 546
c121e924 547 muondata.ResetTrigger();
2b32c661 548 if (event2Check!=0) ievent=nevents;
88cb7938 549 } // end loop on event
da47578c 550
551 // Print out summary if loop ran over all event
144414de 552 if (!event2Check){
3b969def 553
144414de 554 printf("\n");
39c07f3b 555 printf("=============================================\n");
556 printf("================ SUMMARY ==================\n");
144414de 557 printf("\n");
558 printf("Total number of events processed %d \n", (event2Check==0) ? nevents : 1);
559 printf("\n");
39c07f3b 560 printf(" Global Trigger output Low pt High pt\n");
8d4fefab 561 printf(" number of Single :\t");
562 printf("%i\t%i\t",SLowpt,SHighpt);
144414de 563 printf("\n");
564 printf(" number of UnlikeSign pair :\t");
39c07f3b 565 printf("%i\t%i\t",USLowpt,USHighpt);
144414de 566 printf("\n");
567 printf(" number of LikeSign pair :\t");
39c07f3b 568 printf("%i\t%i\t",LSLowpt,LSHighpt);
144414de 569 printf("\n");
39c07f3b 570 printf("=============================================\n");
3b969def 571 fflush(stdout);
144414de 572 }
573
da47578c 574 if (WRITE){
39c07f3b 575 TFile *myFile = new TFile(fileName, "RECREATE");
576 TgtupleGlo->Write();
577 TgtupleLoc->Write();
578 myFile->Close();
da47578c 579 }
c121e924 580
4a69b40c 581 if (!readFromRP) {
582 MUONLoader->UnloadDigits();
583 } else {
584 MUONLoader->UnloadRecPoints();
585 }
586
3b969def 587 delete crateManager;
3b969def 588 delete transformer;
589 delete triggerCircuit;
590
da47578c 591}
88cb7938 592
bf485fb9 593void MUONrectracks (Int_t event2Check=0, char * filename="galice.root"){
8547965d 594// reads and dumps trigger objects from MUON.RecPoints.root
595 TClonesArray * RecTracks;
596
597 // Creating Run Loader and openning file containing Hits
598 AliRunLoader * RunLoader = AliRunLoader::Open(filename,"MUONFolder","READ");
599 if (RunLoader ==0x0) {
600 printf(">>> Error : Error Opening %s file \n",filename);
601 return;
602 }
3b969def 603 // waiting for mag field in CDB
604 printf("Loading field map...\n");
605 if (!AliTracker::GetFieldMap()) {
b97b210c 606 AliMagFMaps* field = new AliMagFMaps("Maps","Maps", 1, 1., 10., AliMagFMaps::k5kG);
3b969def 607 AliTracker::SetFieldMap(field, kFALSE);
608 }
8547965d 609 AliLoader * MUONLoader = RunLoader->GetLoader("MUONLoader");
610 MUONLoader->LoadTracks("READ");
611 // Creating MUON data container
612 AliMUONData muondata(MUONLoader,"MUON","MUON");
613
614 Int_t ievent, nevents;
615 nevents = RunLoader->GetNumberOfEvents();
616
e516b01d 617 // AliMUONTrack * rectrack;
8547965d 618
619 for (ievent=0; ievent<nevents; ievent++) {
2b32c661 620 if (event2Check!=0) ievent=event2Check;
8547965d 621 RunLoader->GetEvent(ievent);
622
623 muondata.SetTreeAddress("RT");
624 muondata.GetRecTracks();
625 RecTracks = muondata.RecTracks();
626
627
628 Int_t nrectracks = (Int_t) RecTracks->GetEntriesFast(); //
629
bf485fb9 630 printf(">>> Event %d, Number of Recconstructed tracks %d \n",ievent, nrectracks);
631 // loop over tracks
6464217e 632
633 // setting pointer for tracks, triggertracks & trackparam at vertex
bf485fb9 634 AliMUONTrack* recTrack = 0;
635 AliMUONTrackParam* trackParam = 0;
636
37827b29 637 // set the magnetic field for track extrapolations
638 AliMUONTrackExtrap::SetField(AliTracker::GetFieldMap());
bf485fb9 639 for (Int_t iRecTracks = 0; iRecTracks < nrectracks; iRecTracks++) {
6464217e 640 // // reading info from tracks
641 recTrack = (AliMUONTrack*) RecTracks->At(iRecTracks);
642 trackParam = (AliMUONTrackParam*) (recTrack->GetTrackParamAtHit())->First();
37827b29 643 AliMUONTrackExtrap::ExtrapToZ(trackParam,0.);
6464217e 644 recTrack->Print("full");
bf485fb9 645 } // end loop tracks
646
8547965d 647 muondata.ResetRecTracks();
2b32c661 648 if (event2Check!=0) ievent=nevents;
8547965d 649 } // end loop on event
650 MUONLoader->UnloadTracks();
651}
652