]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/MUONCheck.C
Cleaning the task in the destructor if it was posted
[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//
22
23// ROOT includes
d8d3b5b8 24#if !defined(__CINT__) || defined(__MAKECINT__)
88cb7938 25#include "TBranch.h"
26#include "TClonesArray.h"
27#include "TFile.h"
28#include "TH1.h"
29#include "TParticle.h"
30#include "TTree.h"
31
32// STEER includes
33#include "AliRun.h"
34#include "AliRunLoader.h"
35#include "AliHeader.h"
36#include "AliLoader.h"
37#include "AliStack.h"
38
39// MUON includes
40#include "AliMUON.h"
ce3f5e87 41#include "AliMUONData.h"
88cb7938 42#include "AliMUONHit.h"
43#include "AliMUONConstants.h"
44#include "AliMUONDigit.h"
45#include "AliMUONRawCluster.h"
46#include "AliMUONGlobalTrigger.h"
47#include "AliMUONLocalTrigger.h"
8547965d 48#include "AliMUONTrack.h"
344d0186 49#endif
88cb7938 50
51void MUONkine(char * filename="galice.root")
52{
53 TClonesArray * ListOfParticles = new TClonesArray("TParticle",1000);
54 TParticle * particle = new TParticle();
55 // Creating Run Loader and openning file containing Hits
56 AliRunLoader * RunLoader = AliRunLoader::Open(filename,"MUONFolder","READ");
57 if (RunLoader ==0x0) {
58 printf(">>> Error : Error Opening %s file \n",filename);
59 return;
60 }
61 RunLoader->LoadKinematics("READ");
62 Int_t ievent, nevents;
63 nevents = RunLoader->GetNumberOfEvents();
64
65 for(ievent=0; ievent<nevents; ievent++) { // Event loop
66 Int_t iparticle, nparticles;
67 // Getting event ievent
68 RunLoader->GetEvent(ievent);
69 RunLoader->TreeK()->GetBranch("Particles")->SetAddress(&particle);
70 nparticles = RunLoader->TreeK()->GetEntries();
71 printf(">>> Event %d, Number of particles is %d \n",ievent, nparticles);
72 for(iparticle=0; iparticle<nparticles; iparticle++) {
73 RunLoader->TreeK()->GetEvent(iparticle);
74 particle->Print("");
75 }
76 }
77 RunLoader->UnloadKinematics();
78}
79
80
81void MUONhits(char * filename="galice.root")
82{
88cb7938 83 // Creating Run Loader and openning file containing Hits
84 AliRunLoader * RunLoader = AliRunLoader::Open(filename,"MUONFolder","READ");
85 if (RunLoader ==0x0) {
86 printf(">>> Error : Error Opening %s file \n",filename);
87 return;
88 }
88cb7938 89 // Loading MUON subsystem
90 AliLoader * MUONLoader = RunLoader->GetLoader("MUONLoader");
1a1cdff8 91 MUONLoader->LoadHits("READ"); // Loading Tree of hits for MUON
92 AliMUONData muondata(MUONLoader,"MUON","MUON"); // Creating MUON data container
88cb7938 93 Int_t ievent, nevents;
94 nevents = RunLoader->GetNumberOfEvents();
95
96 for(ievent=0; ievent<nevents; ievent++) { // Event loop
97 printf(">>> Event %d \n",ievent);
88cb7938 98 // Getting event ievent
99 RunLoader->GetEvent(ievent);
ce3f5e87 100 muondata.SetTreeAddress("H");
88cb7938 101 Int_t itrack, ntracks;
1a1cdff8 102 ntracks = (Int_t) muondata.GetNtracks();
88cb7938 103 for (itrack=0; itrack<ntracks; itrack++) { // Track loop
104 printf(">>> Track %d \n",itrack);
105
106 //Getting List of Hits of Track itrack
1a1cdff8 107 muondata.GetTrack(itrack);
88cb7938 108
109 Int_t ihit, nhits;
ce3f5e87 110 nhits = (Int_t) muondata.Hits()->GetEntriesFast();
88cb7938 111 printf(">>> Number of hits %d \n",nhits);
112 AliMUONHit* mHit;
113 for(ihit=0; ihit<nhits; ihit++) {
ce3f5e87 114 mHit = static_cast<AliMUONHit*>(muondata.Hits()->At(ihit));
88cb7938 115 Int_t Nch = mHit->Chamber(); // chamber number
116 Int_t hittrack = mHit->Track();
117 Float_t x = mHit->X();
118 Float_t y = mHit->Y();
119 Float_t z = mHit->Z();
120 Float_t elos = mHit->Eloss();
121 Float_t theta = mHit->Theta();
122 Float_t phi = mHit->Phi();
123 Float_t momentum = mHit->Momentum();
124 printf(">>> Hit %2d Chamber %2d Track %4d x %6.3f y %6.3f z %7.3f elos %g theta %6.3f phi %5.3f momentum %5.3f\n",
125 ihit, Nch,hittrack,x,y,z,elos,theta,phi, momentum);
126 }
ce3f5e87 127 muondata.ResetHits();
88cb7938 128 } // end track loop
129 } // end event loop
130 MUONLoader->UnloadHits();
131}
132
133
134void MUONdigits(char * filename="galice.root")
135{
88cb7938 136 // Creating Run Loader and openning file containing Hits
137 AliRunLoader * RunLoader = AliRunLoader::Open(filename,"MUONFolder","READ");
138 if (RunLoader ==0x0) {
139 printf(">>> Error : Error Opening %s file \n",filename);
140 return;
141 }
ce3f5e87 142 // Loading MUON subsystem
88cb7938 143 AliLoader * MUONLoader = RunLoader->GetLoader("MUONLoader");
144 MUONLoader->LoadDigits("READ");
ce3f5e87 145 // Creating MUON data container
146 AliMUONData muondata(MUONLoader,"MUON","MUON");
147
88cb7938 148 Int_t ievent, nevents;
149 nevents = RunLoader->GetNumberOfEvents();
88cb7938 150 AliMUONDigit * mDigit;
151
88cb7938 152 for(ievent=0; ievent<nevents; ievent++) {
153 printf(">>> Event %d \n",ievent);
154 RunLoader->GetEvent(ievent);
155
156 // Addressing
157 Int_t ichamber, nchambers;
158 nchambers = AliMUONConstants::NCh(); ;
ce3f5e87 159 muondata.SetTreeAddress("D");
88cb7938 160 char branchname[30];
ce3f5e87 161
88cb7938 162 Int_t icathode, ncathodes;
163 ncathodes=2;
164 //Loop on cathodes
165 for(icathode=0; icathode<ncathodes; icathode++) {
166 printf(">>> Cathode %d\n",icathode);
1a1cdff8 167 muondata.GetCathode(icathode);
88cb7938 168 // Loop on chambers
169 for( ichamber=0; ichamber<nchambers; ichamber++) {
170 printf(">>> Chamber %d\n",ichamber);
88cb7938 171
172 Int_t idigit, ndigits;
1a1cdff8 173 ndigits = (Int_t) muondata.Digits(ichamber)->GetEntriesFast();
88cb7938 174
175 for(idigit=0; idigit<ndigits; idigit++) {
1a1cdff8 176 mDigit = static_cast<AliMUONDigit*>(muondata.Digits(ichamber)->At(idigit));
88cb7938 177 Int_t PadX = mDigit->PadX(); // Pad X number
178 Int_t PadY = mDigit->PadY(); // Pad Y number
179 Int_t Signal = mDigit->Signal(); // Physics Signal
c121e924 180 Int_t Physics= mDigit->Physics(); // Physics contribution to signal
88cb7938 181 Int_t Hit = mDigit->Hit(); // iHit
182 Int_t Cathode= mDigit->Cathode(); // Cathode
183 Int_t Track0 = mDigit->Track(0);
184 Int_t Track1 = mDigit->Track(1);
185 Int_t Track2 = mDigit->Track(2);
c121e924 186 Int_t TCharges0 = mDigit->TrackCharge(0); //charge per track making this digit (up to 10)
187 Int_t TCharges1 = mDigit->TrackCharge(1);
188 Int_t TCharges2 = mDigit->TrackCharge(2);
88cb7938 189
c121e924 190 printf(">>> Digit %4d cathode %1d hit %4d PadX %3d PadY %3d Signal %4d Physics %4d Track0 %4d TrackCharge0 %4d Track1 %'d
191 TrackCharge1 %4d Track2 %4d TrackCharge2 %4d \n",idigit, Cathode,Hit, PadX, PadY, Signal, Physics,
192 Track0, TCharges0, Track1, TCharges1, Track2, TCharges2);
88cb7938 193 } // end digit loop
194 } // end chamber loop
ce3f5e87 195 muondata.ResetDigits();
88cb7938 196 } // end cathode loop
197 } // end event loop
198 MUONLoader->UnloadDigits();
199}
200
201void MUONrecpoints(char * filename="galice.root") {
202
88cb7938 203 // Creating Run Loader and openning file containing Hits
204 AliRunLoader * RunLoader = AliRunLoader::Open(filename,"MUONFolder","READ");
205 if (RunLoader ==0x0) {
206 printf(">>> Error : Error Opening %s file \n",filename);
207 return;
208 }
ce3f5e87 209 // Getting MUONloader
88cb7938 210 AliLoader * MUONLoader = RunLoader->GetLoader("MUONLoader");
211 MUONLoader->LoadRecPoints("READ");
ce3f5e87 212 // Creating MUON data container
213 AliMUONData muondata(MUONLoader,"MUON","MUON");
88cb7938 214
215 Int_t ievent, nevents;
216 nevents = RunLoader->GetNumberOfEvents();
88cb7938 217 AliMUONRawCluster * mRecPoint;
218
88cb7938 219 for(ievent=0; ievent<nevents; ievent++) {
220 printf(">>> Event %d \n",ievent);
221 RunLoader->GetEvent(ievent);
88cb7938 222 // Addressing
223 Int_t ichamber, nchambers;
224 nchambers = AliMUONConstants::NTrackingCh();
ce3f5e87 225 muondata.SetTreeAddress("RC");
88cb7938 226 char branchname[30];
1a1cdff8 227 muondata.GetRawClusters();
88cb7938 228 // Loop on chambers
229 for( ichamber=0; ichamber<nchambers; ichamber++) {
230 printf(">>> Chamber %d\n",ichamber);
231 sprintf(branchname,"MUONRawClusters%d",ichamber+1);
232 //printf(">>> branchname %s\n",branchname);
ce3f5e87 233
88cb7938 234 Int_t irecpoint, nrecpoints;
ce3f5e87 235 nrecpoints = (Int_t) muondata.RawClusters(ichamber)->GetEntriesFast();
88cb7938 236
237 for(irecpoint=0; irecpoint<nrecpoints; irecpoint++) {
ce3f5e87 238 mRecPoint = static_cast<AliMUONRawCluster*>(muondata.RawClusters(ichamber)->At(irecpoint));
88cb7938 239// Int_t fTracks[3]; //labels of overlapped tracks
240// Int_t fQ[2] ; // Q of cluster (in ADC counts)
241// Float_t fX[2] ; // X of cluster
242// Float_t fY[2] ; // Y of cluster
243// Float_t fZ[2] ; // Z of cluster
244// Int_t fPeakSignal[2]; // Peak signal
245// Int_t fIndexMap[50][2]; // indeces of digits
246// Int_t fOffsetMap[50][2]; // Emmanuel special
247// Float_t fContMap[50][2]; // Contribution from digit
248// Int_t fPhysicsMap[50]; // Distinguish signal and background contr.
249// Int_t fMultiplicity[2]; // Cluster multiplicity
250// Int_t fNcluster[2]; // Number of clusters
251// Int_t fClusterType; // Cluster type
252// Float_t fChi2[2]; // Chi**2 of fit
253// Int_t fGhost; // 0 if not a ghost or ghost problem solved
254// // >0 if ghost problem remains because
255// // 1 both (true and ghost) satify
256// // charge chi2 compatibility
257// // 2 none give satisfactory chi2
258
259 Int_t Track0 = mRecPoint->fTracks[0];
260 Int_t Track1 = mRecPoint->fTracks[1];
261 Int_t Track2 = mRecPoint->fTracks[2];
262 Int_t Q0 = mRecPoint->fQ[0];
263 Int_t Q1 = mRecPoint->fQ[1];
264 Float_t x0 = mRecPoint->fX[0];
265 Float_t x1 = mRecPoint->fX[1];
266 Float_t y0 = mRecPoint->fY[0];
267 Float_t y1 = mRecPoint->fY[1];
268 Float_t z0 = mRecPoint->fZ[0];
269 Float_t z1 = mRecPoint->fZ[1];
270 Float_t chi2_0 = mRecPoint->fChi2[0];
271 Float_t chi2_1 = mRecPoint->fChi2[1];
272
273 printf(">>> RecPoint %4d x %6.3f %6.3f y %6.3f %6.3f z %6.3f %6.3f Q0 %4d Q1 %4d Hit %4d Track1 %4d Track2 %4d Chi2 %6.3f %6.3f \n",
274irecpoint, x0, x1, y0, y1, z0, z1, Q0, Q1, Track0, Track1, Track2, chi2_0, chi2_1);
275 } // end recpoint loop
276 } // end chamber loop
ce3f5e87 277 muondata.ResetRawClusters();
88cb7938 278 } // end event loop
279 MUONLoader->UnloadRecPoints();
280}
281
282void MUONTestTrigger (char * filename="galice.root"){
283// reads and dumps trigger objects from MUON.RecPoints.root
284 TClonesArray * globalTrigger;
285 TClonesArray * localTrigger;
286
287 // Creating Run Loader and openning file containing Hits
288 AliRunLoader * RunLoader = AliRunLoader::Open(filename,"MUONFolder","READ");
289 if (RunLoader ==0x0) {
c121e924 290 printf(">>> Error : Error Opening %s file \n",filename);
291 return;
88cb7938 292 }
293
88cb7938 294 AliLoader * MUONLoader = RunLoader->GetLoader("MUONLoader");
295 MUONLoader->LoadRecPoints("READ");
ce3f5e87 296 // Creating MUON data container
297 AliMUONData muondata(MUONLoader,"MUON","MUON");
88cb7938 298
c121e924 299
88cb7938 300 Int_t ievent, nevents;
301 nevents = RunLoader->GetNumberOfEvents();
302
303 AliMUONGlobalTrigger *gloTrg;
304 AliMUONLocalTrigger *locTrg;
305
306 for (ievent=0; ievent<nevents; ievent++) {
c121e924 307 RunLoader->GetEvent(ievent);
308
309 muondata.SetTreeAddress("GLT");
310 muondata.GetTrigger();
311
312 globalTrigger = muondata.GlobalTrigger();
313 localTrigger = muondata.LocalTrigger();
314
315 Int_t nglobals = (Int_t) globalTrigger->GetEntriesFast(); // should be 1
316 Int_t nlocals = (Int_t) localTrigger->GetEntriesFast(); // up to 234
317 printf("###################################################\n");
318 cout << " event " << ievent
319 << " nglobals nlocals: " << nglobals << " " << nlocals << "\n";
320
321 for (Int_t iglobal=0; iglobal<nglobals; iglobal++) { // Global Trigger
322 gloTrg = static_cast<AliMUONGlobalTrigger*>(globalTrigger->At(iglobal));
88cb7938 323
c121e924 324 printf("===================================================\n");
325 printf(" Global Trigger output Low pt High pt All\n");
326 printf(" number of Single Plus :\t");
327 printf("%i\t%i\t%i\t",gloTrg->SinglePlusLpt(),
328 gloTrg->SinglePlusHpt(),gloTrg->SinglePlusApt());
329 printf("\n");
330 printf(" number of Single Minus :\t");
331 printf("%i\t%i\t%i\t",gloTrg->SingleMinusLpt(),
332 gloTrg->SingleMinusHpt(),gloTrg->SingleMinusApt());
333 printf("\n");
334 printf(" number of Single Undefined :\t");
335 printf("%i\t%i\t%i\t",gloTrg->SingleUndefLpt(),
336 gloTrg->SingleUndefHpt(),gloTrg->SingleUndefApt());
337 printf("\n");
338 printf(" number of UnlikeSign pair :\t");
339 printf("%i\t%i\t%i\t",gloTrg->PairUnlikeLpt(),
340 gloTrg->PairUnlikeHpt(),gloTrg->PairUnlikeApt());
341 printf("\n");
342 printf(" number of LikeSign pair :\t");
343 printf("%i\t%i\t%i\t",gloTrg->PairLikeLpt(),
344 gloTrg->PairLikeHpt(),gloTrg->PairLikeApt());
345 printf("\n");
346 printf("===================================================\n");
88cb7938 347
c121e924 348 } // end of loop on Global Trigger
349
350 for (Int_t ilocal=0; ilocal<nlocals; ilocal++) { // Local Trigger
351 cout << " >>> Output for Local Trigger " << ilocal << "\n";
88cb7938 352
c121e924 353 locTrg = static_cast<AliMUONLocalTrigger*>(localTrigger->At(ilocal));
88cb7938 354
c121e924 355 cout << "Circuit StripX Dev StripY: "
356 << locTrg->LoCircuit() << " "
357 << locTrg->LoStripX() << " "
358 << locTrg->LoDev() << " "
359 << locTrg->LoStripY()
360 << "\n";
361 cout << "Lpt Hpt Apt: "
362 << locTrg->LoLpt() << " "
363 << locTrg->LoHpt() << " "
364 << locTrg->LoApt() << "\n";
88cb7938 365
c121e924 366 } // end of loop on Local Trigger
367 muondata.ResetTrigger();
88cb7938 368 } // end loop on event
c121e924 369 MUONLoader->UnloadRecPoints();
370}
371
372
88cb7938 373
8547965d 374void MUONRecTracks (char * filename="galice.root"){
375// reads and dumps trigger objects from MUON.RecPoints.root
376 TClonesArray * RecTracks;
377
378 // Creating Run Loader and openning file containing Hits
379 AliRunLoader * RunLoader = AliRunLoader::Open(filename,"MUONFolder","READ");
380 if (RunLoader ==0x0) {
381 printf(">>> Error : Error Opening %s file \n",filename);
382 return;
383 }
384
385 AliLoader * MUONLoader = RunLoader->GetLoader("MUONLoader");
386 MUONLoader->LoadTracks("READ");
387 // Creating MUON data container
388 AliMUONData muondata(MUONLoader,"MUON","MUON");
389
390 Int_t ievent, nevents;
391 nevents = RunLoader->GetNumberOfEvents();
392
393 AliMUONTrack * rectrack;
394
395 for (ievent=0; ievent<nevents; ievent++) {
396 RunLoader->GetEvent(ievent);
397
398 muondata.SetTreeAddress("RT");
399 muondata.GetRecTracks();
400 RecTracks = muondata.RecTracks();
401
402
403 Int_t nrectracks = (Int_t) RecTracks->GetEntriesFast(); //
404
405 printf(">>> Event %d Number of Recconstructed tracks %d \n",ievent, nrectracks);
406
407 muondata.ResetRecTracks();
408 } // end loop on event
409 MUONLoader->UnloadTracks();
410}
411
412
413
414
415
416
88cb7938 417
418
419
420