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