]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/MUONCheck.C
Fixing problems in the generation of HTML documentation
[u/mrichter/AliRoot.git] / MUON / MUONCheck.C
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
18 //
19 // Macro for checking aliroot output and associated files contents
20 // Gines Martinez, Subatech June 2003
21 //
22
23 // ROOT includes
24 #if !defined(__CINT__) || defined(__MAKECINT__)
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"
41 #include "AliMUONData.h"
42 #include "AliMUONHit.h"
43 #include "AliMUONConstants.h"
44 #include "AliMUONDigit.h"
45 #include "AliMUONRawCluster.h"
46 #include "AliMUONGlobalTrigger.h"
47 #include "AliMUONLocalTrigger.h"
48 #include "AliMUONTrack.h"
49 #ENDIF
50
51 void 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
81 void MUONhits(char * filename="galice.root")
82 {
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   }
89   // Loading MUON subsystem
90   AliLoader * MUONLoader = RunLoader->GetLoader("MUONLoader");
91   MUONLoader->LoadHits("READ");  // Loading Tree of hits for MUON
92   AliMUONData muondata(MUONLoader,"MUON","MUON");  // Creating MUON data container
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);
98     // Getting event ievent
99     RunLoader->GetEvent(ievent); 
100     muondata.SetTreeAddress("H");
101     Int_t itrack, ntracks;
102     ntracks = (Int_t) muondata.GetNtracks();
103     for (itrack=0; itrack<ntracks; itrack++) { // Track loop
104       printf(">>> Track %d \n",itrack);
105
106       //Getting List of Hits of Track itrack
107       muondata.GetTrack(itrack); 
108
109       Int_t ihit, nhits;
110       nhits = (Int_t) muondata.Hits()->GetEntriesFast();
111       printf(">>> Number of hits  %d \n",nhits);
112       AliMUONHit* mHit;
113       for(ihit=0; ihit<nhits; ihit++) {
114         mHit = static_cast<AliMUONHit*>(muondata.Hits()->At(ihit));
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       }
127       muondata.ResetHits();
128     } // end track loop
129   }  // end event loop
130   MUONLoader->UnloadHits();
131 }
132
133
134 void MUONdigits(char * filename="galice.root")
135 {
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   }
142   // Loading MUON subsystem
143   AliLoader * MUONLoader = RunLoader->GetLoader("MUONLoader");
144   MUONLoader->LoadDigits("READ");
145   // Creating MUON data container
146   AliMUONData muondata(MUONLoader,"MUON","MUON");
147
148   Int_t ievent, nevents;
149   nevents = RunLoader->GetNumberOfEvents();
150   AliMUONDigit * mDigit;
151   
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(); ;
159     muondata.SetTreeAddress("D"); 
160     char branchname[30];    
161  
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);
167       muondata.GetCathode(icathode);
168       // Loop on chambers
169       for( ichamber=0; ichamber<nchambers; ichamber++) {
170         printf(">>> Chamber %d\n",ichamber);
171         
172         Int_t idigit, ndigits;
173         ndigits = (Int_t) muondata.Digits(ichamber)->GetEntriesFast();
174         
175         for(idigit=0; idigit<ndigits; idigit++) {
176           mDigit = static_cast<AliMUONDigit*>(muondata.Digits(ichamber)->At(idigit));
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
180           Int_t Physics= mDigit->Physics();  // Physics contribution to signal
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);
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);
189           
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);
193         } // end digit loop
194       } // end chamber loop
195       muondata.ResetDigits();
196     } // end cathode loop
197   }  // end event loop
198   MUONLoader->UnloadDigits();
199 }
200
201 void MUONrecpoints(char * filename="galice.root") {
202
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   }
209   // Getting MUONloader
210   AliLoader * MUONLoader = RunLoader->GetLoader("MUONLoader");
211   MUONLoader->LoadRecPoints("READ");
212   // Creating MUON data container
213   AliMUONData muondata(MUONLoader,"MUON","MUON");
214
215   Int_t ievent, nevents;
216   nevents = RunLoader->GetNumberOfEvents();
217   AliMUONRawCluster * mRecPoint;
218   
219   for(ievent=0; ievent<nevents; ievent++) {
220     printf(">>> Event %d \n",ievent);
221     RunLoader->GetEvent(ievent);
222     // Addressing
223     Int_t ichamber, nchambers;
224     nchambers = AliMUONConstants::NTrackingCh();
225     muondata.SetTreeAddress("RC"); 
226     char branchname[30];    
227     muondata.GetRawClusters();
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);
233   
234       Int_t irecpoint, nrecpoints;
235       nrecpoints = (Int_t) muondata.RawClusters(ichamber)->GetEntriesFast();
236       
237       for(irecpoint=0; irecpoint<nrecpoints; irecpoint++) {
238         mRecPoint = static_cast<AliMUONRawCluster*>(muondata.RawClusters(ichamber)->At(irecpoint));
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",
274 irecpoint, x0, x1, y0, y1, z0, z1, Q0, Q1, Track0, Track1, Track2, chi2_0, chi2_1);
275       } // end recpoint loop
276     } // end chamber loop
277     muondata.ResetRawClusters();
278   }  // end event loop
279   MUONLoader->UnloadRecPoints();
280 }
281
282 void 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) {
290     printf(">>> Error : Error Opening %s file \n",filename);
291     return;
292   }
293   
294   AliLoader * MUONLoader = RunLoader->GetLoader("MUONLoader");
295   MUONLoader->LoadRecPoints("READ");
296   // Creating MUON data container
297   AliMUONData muondata(MUONLoader,"MUON","MUON");
298   
299   
300   Int_t ievent, nevents;
301   nevents = RunLoader->GetNumberOfEvents();
302   
303   AliMUONGlobalTrigger *gloTrg;
304   AliMUONLocalTrigger *locTrg;
305   
306   for (ievent=0; ievent<nevents; ievent++) {
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));
323       
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");
347       
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";
352       
353       locTrg = static_cast<AliMUONLocalTrigger*>(localTrigger->At(ilocal));
354       
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";
365       
366     } // end of loop on Local Trigger
367     muondata.ResetTrigger();
368   } // end loop on event  
369   MUONLoader->UnloadRecPoints();
370 }
371
372
373
374 void 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
417
418
419
420