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