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