]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/MUONCheckDI.C
Typo corrected.
[u/mrichter/AliRoot.git] / MUON / MUONCheckDI.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 // with using AliMUONDataInterface
21 // By Bruce Becker, DAPNIA/SPhN/CEA Saclay
22 // According to MUONCheck.C
23 //
24 #if !defined(__CINT__) || defined(__MAKECINT__)
25 // ROOT includes
26 #include "TBranch.h"
27 #include "TClonesArray.h"
28 #include "TFile.h"
29 #include "TH1.h"
30 #include "TParticle.h"
31 #include "TTree.h"
32
33 // STEER includes
34 #include "AliRun.h"
35 #include "AliRunLoader.h"
36 #include "AliHeader.h"
37 #include "AliLoader.h"
38 #include "AliStack.h"
39
40 // MUON includes
41 #include "AliMUON.h"
42 #include "AliMUONData.h"
43 #include "AliMUONHit.h"
44 #include "AliMUONConstants.h"
45 #include "AliMUONDigit.h"
46 #include "AliMUONRawCluster.h"
47 #include "AliMUONGlobalTrigger.h"
48 #include "AliMUONLocalTrigger.h"
49 #include "AliMUONTrack.h"
50 #include "AliMUONDataInterface.h"
51 #endif
52
53
54 void MUONkine(char * filename="galice.root")
55 {
56   AliMUONDataInterface amdi;
57   amdi.SetFile(filename);
58   Int_t nevents = amdi.NumberOfEvents();
59   
60   for(Int_t ievent=0; ievent<nevents; ievent++) 
61     {  // Event loop
62       Int_t iparticle, nparticles;
63       // Getting event ievent
64       amdi.GetEvent(ievent); 
65       nparticles = amdi.NumberOfParticles();
66       printf(">>> Event %d, Number of particles is %d \n",ievent, nparticles);
67       for(iparticle=0; iparticle<nparticles; iparticle++) 
68         {
69         amdi.Particle(iparticle)->Print("");
70         }
71     }
72 }
73
74
75 void MUONhits(char * filename="galice.root")
76 {
77   
78   AliMUONDataInterface amdi;
79   amdi.SetFile(filename);
80   Int_t nevents = amdi.NumberOfEvents();
81   
82   for(Int_t ievent=0; ievent<nevents; ievent++) 
83     {  // Event loop
84       printf(">>> Event %d \n",ievent);
85       // Getting event ievent
86       amdi.GetEvent(ievent); 
87       Int_t ntracks = amdi.NumberOfTracks();
88       for (Int_t itrack=0; itrack<ntracks; itrack++) 
89         { // Track loop
90           printf(">>> Track %d \n",itrack);
91           //Getting List of Hits of Track itrack
92           // amdi.GetTrack(itrack); 
93           
94           Int_t ihit, nhits;
95           nhits = amdi.NumberOfHits(itrack);
96           printf(">>> Number of hits  %d \n",nhits);
97           AliMUONHit* mHit;
98           for(ihit=0; ihit<nhits; ihit++) 
99             {
100               mHit = amdi.Hit(itrack,ihit);
101               Int_t Nch      = mHit->Chamber();  // chamber number
102               Int_t detele   = mHit-> DetElemId(); // Detection element if defined
103               Int_t hittrack = mHit->Track();
104               Float_t x      = mHit->X();
105               Float_t y      = mHit->Y();
106               Float_t z      = mHit->Z();
107               Float_t elos   = mHit->Eloss();
108               // Float_t theta  = mHit->Theta();
109               // Float_t phi    = mHit->Phi();
110               Float_t momentum = mHit->Momentum();
111               printf(">>> Hit %2d Chamber %2d DetEle %4d Track %4d x %6.3f y %6.3f z %7.3f elos %g  momentum %5.3f\n",
112                      ihit, Nch, detele, hittrack,x,y,z,elos,momentum);
113             }
114         } // end track loop
115     }  // end event loop
116 }
117
118
119 void MUONdigits(char * filename="galice.root")
120 {
121   
122   AliMUONDataInterface amdi;
123   amdi.SetFile(filename);
124   Int_t ievent, nevents;
125   nevents = amdi.NumberOfEvents();
126   AliMUONDigit * mDigit;
127   
128   for(ievent=0; ievent<nevents; ievent++) 
129     {
130       printf(">>> Event %d \n",ievent);
131       amdi.GetEvent(ievent);
132       
133       // Addressing
134       Int_t ichamber, nchambers;
135       nchambers = AliMUONConstants::NCh(); ;
136       
137       //      Int_t icathode, ncathodes;
138       //      ncathodes=2;
139       for( ichamber=0; ichamber<nchambers; ichamber++) 
140         {
141           printf(">>> Chamber %d\n",ichamber+1);
142           
143           Int_t idigit, ndigits;
144           ndigits = amdi.NumberOfDigits(ichamber,0); // second parameter here is cathode...
145           
146           for(idigit=0; idigit<ndigits; idigit++) 
147             {
148               mDigit = amdi.Digit(ichamber,0,idigit);
149               Int_t PadX   = mDigit->PadX();     // Pad X number
150               Int_t PadY   = mDigit->PadY();     // Pad Y number
151               Int_t Signal = mDigit->Signal();   // Physics Signal
152               Int_t Physics= mDigit->Physics();  // Physics contribution to signal
153               Int_t Hit    = mDigit->Hit();      // iHit
154               Int_t Cathode= mDigit->Cathode();  // Cathode
155               Int_t Track0 = mDigit->Track(0);
156               Int_t Track1 = mDigit->Track(1); 
157               Int_t Track2 = mDigit->Track(2);
158               Int_t TCharges0 = mDigit->TrackCharge(0);  //charge per track making this digit (up to 10)
159               Int_t TCharges1 = mDigit->TrackCharge(1);
160               Int_t TCharges2 = mDigit->TrackCharge(2);
161               Int_t idDE = mDigit->DetElemId();
162               //          printf(">>> Cathode %d\n",Cathode);
163               
164               printf(">>>IdDE %d Digit %4d cathode %1d hit %4d PadX %3d PadY %3d Signal %4d Physics %4d Track0 %4d TrackCharge0 %4d Track1 %4d TrackCharge1 %4d Track2 %4d TrackCharge2 %4d \n",
165                      idDE, idigit, Cathode,Hit, PadX, PadY, Signal, Physics, Track0, 
166                      TCharges0, Track1, TCharges1, Track2, TCharges2);
167             } // end digit loop
168         } // end chamber loop
169     }  // end event loop
170 }
171
172 void MUONrecpoints(char * filename="galice.root") 
173 {
174   AliMUONDataInterface amdi;
175   amdi.SetFile(filename);
176   
177   Int_t ievent, nevents;
178   nevents = amdi.NumberOfEvents();
179   AliMUONRawCluster * mRecPoint = 0;
180   
181   for(ievent=0; ievent<nevents; ievent++) 
182     {
183       printf(">>> Event %d \n",ievent);
184       amdi.GetEvent(ievent);
185       Int_t ichamber, nchambers;
186       nchambers = AliMUONConstants::NTrackingCh();
187       // Loop on chambers
188       for( ichamber=0; ichamber<nchambers; ichamber++) 
189         {
190           printf(">>> Chamber %d\n",ichamber);
191           Int_t irecpoint, nrecpoints;
192           nrecpoints = amdi.NumberOfRawClusters(ichamber);
193           printf("number of recpoints = %6d \n",nrecpoints);
194           for(irecpoint=0; irecpoint<nrecpoints; irecpoint++) 
195             {
196               mRecPoint = amdi.RawCluster(ichamber,irecpoint);
197               //     Int_t       fTracks[3];        //labels of overlapped tracks
198               //     Int_t       fQ[2]  ;           // Q of cluster (in ADC counts)     
199               //     Float_t     fX[2]  ;           // X of cluster
200               //     Float_t     fY[2]  ;           // Y of cluster
201               //     Float_t     fZ[2]  ;           // Z of cluster
202               //     Int_t       fPeakSignal[2];    // Peak signal 
203               //     Int_t       fIndexMap[50][2];  // indeces of digits
204               //     Int_t       fOffsetMap[50][2]; // Emmanuel special
205               //     Float_t     fContMap[50][2];   // Contribution from digit
206               //     Int_t       fPhysicsMap[50];   // Distinguish signal and background contr.
207               //     Int_t       fMultiplicity[2];  // Cluster multiplicity
208               //     Int_t       fNcluster[2];      // Number of clusters
209               //     Int_t       fClusterType;      // Cluster type
210               //     Float_t     fChi2[2];          // Chi**2 of fit
211               //     Int_t       fGhost;            // 0 if not a ghost or ghost problem solved
212               //                                    // >0 if ghost problem remains because
213               //                                    // 1 both (true and ghost) satify 
214               //                                    //   charge chi2 compatibility
215               //                                    // 2 none give satisfactory chi2
216               
217               Int_t Track0 = mRecPoint->GetTrack(0);
218               Int_t Track1 = mRecPoint->GetTrack(1); 
219               Int_t Track2 = mRecPoint->GetTrack(2);
220               Int_t Q0 = mRecPoint->GetCharge(0);
221               Int_t Q1 = mRecPoint->GetCharge(1);
222               Float_t x0 = mRecPoint->GetX(0);
223               Float_t x1 = mRecPoint->GetX(1);
224               Float_t y0 = mRecPoint->GetY(0);
225               Float_t y1 = mRecPoint->GetY(1);
226               Float_t z0 = mRecPoint->GetZ(0);
227               Float_t z1 = mRecPoint->GetZ(1);
228               Float_t chi2_0 =  mRecPoint->GetChi2(0);
229               Float_t chi2_1 =  mRecPoint->GetChi2(1);
230               Int_t de = mRecPoint->GetDetElemId();
231               printf(">>> RecPoint %4d  DetElem %2d 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",
232                      irecpoint,de,x0,x1,y0,y1,z0,z1,Q0,Q1,Track0, Track1, Track2, chi2_0, chi2_1);
233             } // end recpoint loop
234         } // end chamber loop
235     }  // end event loop
236 }
237
238 void MUONTestTrigger (char * filename="galice.root")
239 {
240   // reads and dumps trigger objects from MUON.RecPoints.root
241   
242   AliMUONDataInterface amdi;
243   amdi.SetFile(filename);
244   
245   Int_t ievent, nevents;
246   nevents = amdi.NumberOfEvents();
247   
248   AliMUONGlobalTrigger *gloTrg;
249   AliMUONLocalTrigger *locTrg;
250   
251   for (ievent=0; ievent<nevents; ievent++) 
252     {
253       amdi.GetEvent(ievent);
254       Int_t nglobals = amdi.NumberOfGlobalTriggers(); // should be 1
255       Int_t nlocals  = amdi.NumberOfLocalTriggers(); // up to 234
256       printf("###################################################\n");
257       cout << " event " << ievent 
258            << " nglobals nlocals: " << nglobals << " " << nlocals << "\n"; 
259       
260       for (Int_t iglobal=0; iglobal<nglobals; iglobal++) 
261         { // Global Trigger
262           gloTrg = amdi.GlobalTrigger(iglobal);
263           
264           printf("===================================================\n");
265           printf(" Global Trigger output       Low pt  High pt   All\n");
266           printf(" number of Single Plus      :\t");
267           printf("%i\t%i\t%i\t",gloTrg->SinglePlusLpt(),
268                  gloTrg->SinglePlusHpt(),gloTrg->SinglePlusApt());
269           printf("\n");
270           printf(" number of Single Minus     :\t");
271           printf("%i\t%i\t%i\t",gloTrg->SingleMinusLpt(),
272                  gloTrg->SingleMinusHpt(),gloTrg->SingleMinusApt());
273           printf("\n");
274           printf(" number of Single Undefined :\t"); 
275           printf("%i\t%i\t%i\t",gloTrg->SingleUndefLpt(),
276                  gloTrg->SingleUndefHpt(),gloTrg->SingleUndefApt());
277           printf("\n");
278           printf(" number of UnlikeSign pair  :\t"); 
279           printf("%i\t%i\t%i\t",gloTrg->PairUnlikeLpt(),
280                  gloTrg->PairUnlikeHpt(),gloTrg->PairUnlikeApt());
281           printf("\n");
282           printf(" number of LikeSign pair    :\t");  
283           printf("%i\t%i\t%i\t",gloTrg->PairLikeLpt(),
284                  gloTrg->PairLikeHpt(),gloTrg->PairLikeApt());
285           printf("\n");
286           printf("===================================================\n");
287           
288         } // end of loop on Global Trigger
289       
290       for (Int_t ilocal=0; ilocal<nlocals; ilocal++) 
291         { // Local Trigger
292           cout << " >>> Output for Local Trigger " << ilocal << "\n";
293           locTrg = amdi.LocalTrigger(ilocal);
294           cout << "Circuit StripX Dev StripY: " 
295                << locTrg->LoCircuit() << " " 
296                << locTrg->LoStripX() << " " 
297                << locTrg->LoDev() << " " 
298                << locTrg->LoStripY() 
299                << "\n";
300           cout << "Lpt Hpt Apt: "     
301                << locTrg->LoLpt() << " "   
302                << locTrg->LoHpt() << " "  
303                << locTrg->LoApt() << "\n";
304           
305         } // end of loop on Local Trigger
306     } // end loop on event  
307 }
308
309 void MUONRecTracks (char * filename="galice.root")
310 {
311   
312   // reads and dumps trigger objects from MUON.RecPoints.root
313   AliMUONDataInterface amdi;
314   amdi.SetFile(filename);
315   AliMUONTrack* rectrack;
316   AliMUONTrackParam* trackparam;
317   Double_t x,y,z;
318   Int_t ievent, nevents;
319   nevents = amdi.NumberOfEvents();
320   
321   
322   for (ievent=0; ievent<nevents; ievent++) 
323     {
324       amdi.GetEvent(ievent);
325       Int_t nrectracks = amdi.NumberOfRecTracks(); 
326       printf(">>> Event %d Number of Recconstructed tracks %d \n",ievent, nrectracks);
327       // loop over rec tracks and print vertex parameters
328       for(Int_t rectracki=0; rectracki < nrectracks;rectracki++)
329         {
330           rectrack  = amdi.RecTrack(rectracki);
331           trackparam = rectrack->GetTrackParamAtVertex(); // meaningless since the vertex is not known at the tracking level
332           x = trackparam->GetNonBendingCoor();
333           y = trackparam->GetBendingCoor();
334           z = trackparam->GetZ();
335           printf("Track Vertex : (x,y,z) = (%f,%f,%f \n",x,y,z);
336         } // end of loop over tracks
337     } // end loop on event  
338 }