]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/AliMUONData.cxx
Updated list of MUON libraries
[u/mrichter/AliRoot.git] / MUON / AliMUONData.cxx
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 /// \class AliMUONData
19 ///
20 /// Class containing MUON data: hits, digits, rawclusters, globaltrigger, localtrigger, etc ..
21 /// The classe makes the lik between the MUON data lists and the event trees from loaders
22 ///
23 /// \author Gines Martinez, Subatech,  September 2003
24 ///
25
26 #include "AliMUONData.h"
27 #include "AliMUONDataIterator.h"
28 #include "AliMUONConstants.h"
29 #include "AliMUONDigit.h"
30 #include "AliMUONGlobalTrigger.h"
31 #include "AliMUONLocalTrigger.h"
32 #include "AliMUONRegionalTrigger.h"
33 #include "AliMUONTriggerCrateStore.h"
34 #include "AliMUONTriggerCircuit.h"
35 #include "AliMUONGeometryTransformer.h"
36 #include "AliMUONRawCluster.h"
37
38 #include "AliRunLoader.h"
39 #include "AliStack.h"
40 #include "AliLog.h"
41
42 #include <TString.h>
43 #include <TParticle.h>
44 #include <TNtuple.h>
45 #include <Riostream.h>
46 #include <TFile.h>
47
48 /// \cond CLASSIMP
49 ClassImp(AliMUONData)
50 /// \endcond
51  
52 //_____________________________________________________________________________
53   AliMUONData::AliMUONData():
54     TNamed(),
55     fRunLoader(0x0),
56     fLoader(0x0),
57     fSDigits(0x0),
58     fDigits(0x0),
59     fGlobalTrigger(0x0),
60     fLocalTrigger(0x0),
61     fRegionalTrigger(0x0),
62     fNSdigits(0x0),
63     fNdigits(0x0),
64     fNglobaltrigger(0),
65     fNlocaltrigger(0),
66     fNregionaltrigger(0),
67     fSplitLevel(0),
68     fCurrentEvent(-1)
69 {
70 /// Default constructor
71 }
72 //_____________________________________________________________________________
73 AliMUONData::AliMUONData(AliLoader * loader, const char* name, const char* title):
74   TNamed(name,title),
75     fRunLoader(0x0),
76     fLoader(loader),
77     fSDigits(0x0),
78     fDigits(0x0),
79     fGlobalTrigger(0x0),
80     fLocalTrigger(0x0),
81     fRegionalTrigger(0x0),
82     fNSdigits(0x0),
83     fNdigits(0x0),
84     fNglobaltrigger(0),
85     fNlocaltrigger(0),
86     fNregionaltrigger(0),
87     fSplitLevel(0),
88     fCurrentEvent(-1)
89 {
90 /// Standard constructor
91 }
92
93 //_____________________________________________________________________________
94 AliMUONData::AliMUONData(const char* galiceFile, const char* folderName):
95   TNamed("MUON", "MUON"),
96     fRunLoader(0x0),
97     fLoader(0x0),
98     fSDigits(0x0),
99     fDigits(0x0),
100     fGlobalTrigger(0x0),
101     fLocalTrigger(0x0),
102     fRegionalTrigger(0x0),
103     fNSdigits(0x0),
104     fNdigits(0x0),
105     fNglobaltrigger(0),
106     fNlocaltrigger(0),
107     fNregionaltrigger(0),
108     fSplitLevel(0),
109     fCurrentEvent(-1)
110 {
111 /// Constructor for loading data from gAlice file
112
113   fRunLoader = AliRunLoader::Open(galiceFile, folderName, "READ");
114   if (!fRunLoader) {
115     AliError(Form("Error opening %s file \n", galiceFile));
116     return;
117   }  
118
119   fLoader = fRunLoader->GetLoader("MUONLoader");
120   if ( ! fLoader ) {
121     AliError(Form("Could get MUONLoader"));
122     return;
123   }  
124 }
125
126 //_____________________________________________________________________________
127 AliMUONData::~AliMUONData()
128 {
129 /// Destructor for AliMUONData
130   
131   if (fSDigits) {
132     fSDigits->Delete();
133     delete fSDigits;
134   }
135
136   if (fDigits) {
137     fDigits->Delete();
138     delete fDigits;
139   }
140   if (fGlobalTrigger){
141     fGlobalTrigger->Delete();
142     delete fGlobalTrigger;
143   }  
144   if (fRegionalTrigger){
145     fRegionalTrigger->Delete();
146     delete fRegionalTrigger;
147   }
148   if (fLocalTrigger){
149     fLocalTrigger->Delete();
150     delete fLocalTrigger;
151   }
152
153   if (fRunLoader) {
154     fRunLoader->UnloadAll();
155     delete fRunLoader;
156   }  
157 }
158 //_____________________________________________________________________________
159 void AliMUONData::AddSDigit(Int_t id, const AliMUONDigit& Sdigit)
160 {
161 /// Add a MUON Sdigit to the list of SDigits of the detection plane id
162
163   TClonesArray &lSdigits = * SDigits(id) ; 
164   new(lSdigits[fNSdigits[id]++]) AliMUONDigit(Sdigit);
165 }
166 //_____________________________________________________________________________
167 void AliMUONData::AddDigit(Int_t id, const AliMUONDigit& digit)
168 {
169 /// Add a MUON digit to the list of Digits of the detection plane id
170
171   TClonesArray &ldigits = * Digits(id) ; 
172   new(ldigits[fNdigits[id]++]) AliMUONDigit(digit);
173 }
174
175 //_____________________________________________________________________________
176 void AliMUONData::AddGlobalTrigger(const AliMUONGlobalTrigger& trigger )
177 {
178 /// Add a MUON Global Trigger to the list (only one GlobalTrigger per event !);
179
180   TClonesArray &globalTrigger = *fGlobalTrigger;
181   new(globalTrigger[fNglobaltrigger++]) AliMUONGlobalTrigger(trigger);
182 }
183
184 //____________________________________________________________________________
185 void AliMUONData::AddRegionalTrigger(const  AliMUONRegionalTrigger& trigger)
186 {
187 /// add a MUON regional Trigger to the list
188   TClonesArray &regionalTrigger = *fRegionalTrigger;
189   new(regionalTrigger[fNregionaltrigger++]) AliMUONRegionalTrigger(trigger);
190 }
191 //____________________________________________________________________________
192 void AliMUONData::AddLocalTrigger(const  AliMUONLocalTrigger& trigger)
193 {
194 /// add a MUON Local Trigger to the list
195
196   TClonesArray &localTrigger = *fLocalTrigger;
197   new(localTrigger[fNlocaltrigger++]) AliMUONLocalTrigger(trigger);
198 }
199
200 //____________________________________________________________________________
201 TClonesArray*  AliMUONData::SDigits(Int_t DetectionPlane) const
202 {
203 /// Getting List of SDigits
204
205   if (fSDigits)
206     return ( (TClonesArray*) fSDigits->At(DetectionPlane) );
207   else
208     return NULL;
209 }
210 //____________________________________________________________________________
211 TClonesArray*  AliMUONData::Digits(Int_t DetectionPlane) const
212 {
213 /// Getting List of Digits
214
215   if (fDigits)
216     return ( (TClonesArray*) fDigits->At(DetectionPlane) );
217   else
218     return NULL;
219 }
220 //____________________________________________________________________________
221 Bool_t   AliMUONData::IsDigitsBranchesInTree()
222 {
223 /// Checking if there are Digits Branches In TreeD
224
225   if (TreeD()==0x0) {
226     AliError("No treeD in memory");
227     return kFALSE;
228   }
229   else {
230      char branchname[30];
231      sprintf(branchname,"%sDigits1",GetName());
232      TBranch * branch = 0x0;
233      branch = TreeD()->GetBranch(branchname);
234      if (branch)  return kTRUE;
235      else return kFALSE;    
236   }
237 }
238 //____________________________________________________________________________
239 Bool_t   AliMUONData::IsTriggerBranchesInTreeD()
240 {
241 /// Checking if there are Trigger Branches In TreeD
242  if (TreeD()==0x0) {
243     AliError("No treeD in memory");
244     return kFALSE;
245   }
246   else {
247      char branchname[30];
248      sprintf(branchname,"%sLocalTrigger",GetName());
249      TBranch * branch = 0x0;
250      branch = TreeD()->GetBranch(branchname);
251      if (branch)  return kTRUE;
252      else return kFALSE;    
253   }
254 }
255
256 //____________________________________________________________________________
257 void AliMUONData::Fill(Option_t* option)
258 {
259 /// Method to fill the trees
260
261   const char *cS   = strstr(option,"S");   // SDigits branches in TreeS
262   const char *cD   = strstr(option,"D");   // Digits branches in TreeD
263   const char *cGLT = strstr(option,"GLT"); // Global and Local Trigger branches in TreeD
264   
265   char branchname[30];
266   TBranch * branch = 0x0;
267
268   // Filling TreeS
269   if ( TreeS() && cS) 
270   {
271     TreeS()->Fill();
272   }
273
274   // Filling TreeD
275
276   if ( TreeD() && cD && cGLT )
277   {
278     // Writing digits and (global+local) trigger at once.
279     TreeD()->Fill();
280   }
281   else
282   {
283     if ( TreeD() && cD ) 
284     {
285       if ( IsTriggerBranchesInTreeD() ) 
286       {
287         for (int i=0; i<AliMUONConstants::NCh(); i++) 
288         {
289           sprintf(branchname,"%sDigits%d",GetName(),i+1);
290           branch = TreeD()->GetBranch(branchname);
291           branch->Fill();
292         }
293       } 
294       else
295       {
296         TreeD()->Fill();
297       }
298     }
299     
300     if ( TreeD() && cGLT ) 
301     {
302       if ( IsDigitsBranchesInTree() ) 
303       {
304         sprintf(branchname,"%sLocalTrigger",GetName());
305         branch = TreeD()->GetBranch(branchname); 
306         branch->Fill();
307         sprintf(branchname,"%sRegionalTrigger",GetName());
308         branch = TreeD()->GetBranch(branchname);
309         branch->Fill();
310         sprintf(branchname,"%sGlobalTrigger",GetName());
311         branch = TreeD()->GetBranch(branchname);
312         branch->Fill();
313
314       } 
315       else
316       {
317         TreeD()->Fill();
318       }
319     }
320   } // end of TreeD() handling.
321 }
322
323 //_____________________________________________________________________________
324 void AliMUONData::MakeBranch(Option_t* option)
325 {
326 /// Create Tree branches for the MUON.
327
328   const Int_t kBufferSize = 4000;
329   char branchname[30];
330   
331   //Setting Data Container
332   SetDataContainer(option);  
333
334   const char *cS   = strstr(option,"S");   // Digits branches in TreeS
335   const char *cD   = strstr(option,"D");   // Digits branches in TreeD
336   const char *cGLT = strstr(option,"GLT"); // Global and Local Trigger branches in TreeD
337   
338   TBranch * branch = 0x0;
339   
340   //Creating Branches for SDigits
341   if (TreeS() && cS ) {
342     // one branch for Sdigits per chamber
343     for (Int_t iDetectionPlane=0; iDetectionPlane<AliMUONConstants::NCh() ;iDetectionPlane++) {
344       sprintf(branchname,"%sSDigits%d",GetName(),iDetectionPlane+1);
345       branch = 0x0;
346       branch = TreeS()->GetBranch(branchname);
347       if (branch) {  
348         AliInfo(Form("Branch %s is already in tree.",branchname));
349         return;
350       }
351       TClonesArray * sdigits = SDigits(iDetectionPlane); 
352       branch = TreeS()->Branch(branchname, &sdigits, kBufferSize,1);
353       //Info("MakeBranch","Making Branch %s for sdigits in detection plane %d\n",branchname,iDetectionPlane+1);
354     }
355   }
356
357   //Creating Branches for Digits
358   TTree* treeD = 0x0;
359   if ( cD || cGLT )
360   {
361     treeD = TreeD();
362   }
363
364   if ( treeD && cD ) 
365   {
366     // one branch for digits per chamber
367     for (Int_t iDetectionPlane=0; iDetectionPlane<AliMUONConstants::NCh() ;iDetectionPlane++) 
368     {
369       sprintf(branchname,"%sDigits%d",GetName(),iDetectionPlane+1);
370       branch = treeD->GetBranch(branchname);
371       if (branch) 
372       {  
373         AliInfo(Form("Branch %s is already in tree.",branchname));
374         return;
375       }
376       TClonesArray * digits = Digits(iDetectionPlane); 
377       branch = treeD->Branch(branchname, &digits, kBufferSize,1);
378     }
379   }
380   
381   if ( treeD && cGLT ) 
382   {
383     //
384     // one branch for global trigger
385     //
386     sprintf(branchname,"%sGlobalTrigger",GetName());
387     branch = treeD->GetBranch(branchname);
388     if (branch) 
389     {  
390       AliInfo(Form("Branch GlobalTrigger is already in treeD."));
391       return ;
392     }
393     branch = treeD->Branch(branchname, &fGlobalTrigger, kBufferSize);
394
395   //
396     // one branch for regional trigger
397     //  
398     sprintf(branchname,"%sRegionalTrigger",GetName());
399     branch = 0x0;
400     branch = treeD->GetBranch(branchname);
401     if (branch) 
402     {  
403       AliInfo(Form("Branch RegionalTrigger is already in treeD."));
404       return;
405     }
406     branch = treeD->Branch(branchname, &fRegionalTrigger, kBufferSize);
407   
408
409     //
410     // one branch for local trigger
411     //  
412     sprintf(branchname,"%sLocalTrigger",GetName());
413     branch = 0x0;
414     branch = treeD->GetBranch(branchname);
415     if (branch) 
416     {  
417       AliInfo(Form("Branch LocalTrigger is already in treeD."));
418       return;
419     }
420     branch = treeD->Branch(branchname, &fLocalTrigger, kBufferSize);
421   }
422 }
423
424 //____________________________________________________________________________
425 TClonesArray*  
426 AliMUONData::LocalTrigger() const
427 {
428 /// Getting local trigger
429
430   return fLocalTrigger;
431 }
432
433 //____________________________________________________________________________
434 TClonesArray*  
435 AliMUONData::RegionalTrigger() const
436 {
437 /// Getting regional trigger
438
439   return fRegionalTrigger;
440 }
441
442 //____________________________________________________________________________
443 void
444 AliMUONData::GetDigits() const 
445 {
446 /// Load the digits from TreeD for the current event.
447
448   Int_t event = fLoader->GetRunLoader()->GetEventNumber();
449   if ( fCurrentEvent != event )
450   {
451     if (fLoader->TreeD()) {
452       fLoader->TreeD()->GetEvent(0);
453       fCurrentEvent = event;
454     }
455   }
456 }
457
458 //____________________________________________________________________________
459 TClonesArray*  
460 AliMUONData::GlobalTrigger() const
461 {
462 /// Return the global trigger 
463
464   return fGlobalTrigger;
465 }
466
467 //____________________________________________________________________________
468 void AliMUONData::ResetSDigits()
469 {
470 /// Reset number of Sdigits and the Sdigits array for this detector
471
472     if (fSDigits == 0x0) return;
473     for ( int i=0;i<AliMUONConstants::NCh();i++ ) {
474       if ((*fSDigits)[i])    ((TClonesArray*)fSDigits->At(i))->Clear();
475       if (fNSdigits)  fNSdigits[i]=0;
476     }
477 }
478 //____________________________________________________________________________
479 void AliMUONData::ResetDigits()
480 {
481 /// Reset number of digits and the digits array for this detector
482
483     if (fDigits == 0x0) return;
484     for ( int i=0;i<AliMUONConstants::NCh();i++ ) {
485       if ((*fDigits)[i])    ((TClonesArray*)fDigits->At(i))->Clear("C");
486       if (fNdigits)  fNdigits[i]=0;
487     }
488 }
489 //_______________________________________________________________________________
490 void AliMUONData::ResetTrigger()
491 {
492 /// Reset Local and Global Trigger 
493
494   fNglobaltrigger = 0;
495   if (fGlobalTrigger) fGlobalTrigger->Clear();
496   fNregionaltrigger = 0;
497   if (fRegionalTrigger) fRegionalTrigger->Clear();
498   fNlocaltrigger = 0;
499   if (fLocalTrigger) fLocalTrigger->Clear();
500
501 }
502 //____________________________________________________________________________
503 void AliMUONData::SetDataContainer(Option_t* option)
504 {
505 /// Setting data containers of muon data
506
507   const char *cS   = strstr(option,"S");   // SDigits
508   const char *cD   = strstr(option,"D");   // Digits
509   const char *cGLT = strstr(option,"GLT"); // Global and Local Trigger
510
511   AliDebug(1,Form("option=%s",option));
512   
513   //
514   // Container for Sdigits
515   if (cS) {
516     if (fSDigits == 0x0) { 
517       AliDebug(1,"Creating fSDigits TObjArray");
518       fSDigits = new TObjArray(AliMUONConstants::NCh());
519       fNSdigits= new Int_t[AliMUONConstants::NCh()];
520       for (Int_t i=0; i<AliMUONConstants::NCh() ;i++) {
521         TClonesArray* a = new TClonesArray("AliMUONDigit",10000);
522         a->SetOwner();
523         fSDigits->AddAt(a,i);
524         AliDebug(1,Form("fSDigits[%d]=%p",i,a));
525         fNSdigits[i]=0;
526       }
527     }
528     else {
529       AliDebug(1,Form("fSDigits already there = %p",fSDigits));
530     }
531     ResetSDigits();
532   }  
533
534   //
535   // ObjArray of ClonesArrays for Digits
536   if ( cD ) {      
537     if (fDigits == 0x0 ) {
538       fDigits = new TObjArray(AliMUONConstants::NCh());
539       fNdigits= new Int_t[AliMUONConstants::NCh()];
540       for (Int_t i=0; i<AliMUONConstants::NCh() ;i++) {
541         TClonesArray * tca = new TClonesArray("AliMUONDigit",10000);
542         tca->SetOwner();
543         fDigits->AddAt(tca,i); 
544         fNdigits[i]=0;
545       }
546     } 
547     else {
548       AliDebug(1,Form("fDigits already there = %p",fDigits));
549     }
550     ResetDigits();
551   }
552
553   //
554   // ClonesArrays for Trigger
555   if ( cGLT ) { 
556     if (fLocalTrigger == 0x0) {
557       fLocalTrigger  = new TClonesArray("AliMUONLocalTrigger",234);
558     }
559     if (fRegionalTrigger == 0x0) {
560       fRegionalTrigger  = new TClonesArray("AliMUONRegionalTrigger",16);
561     }
562     if (fGlobalTrigger== 0x0) {
563       fGlobalTrigger = new TClonesArray("AliMUONGlobalTrigger",1); 
564     }
565     ResetTrigger();
566   }
567 }
568
569 //____________________________________________________________________________
570 void AliMUONData::SetTreeAddress(Option_t* option)
571 {
572   // Setting Data containers
573   SetDataContainer(option);
574
575 /// Setting Addresses to the events trees
576
577   const char *cS   = strstr(option,"S");   // SDigits branches in TreeS
578   const char *cD   = strstr(option,"D");   // Digits branches in TreeD
579   const char *cGLT = strstr(option,"GLT"); // Global and Local Trigger branches in TreeD
580   
581   // Set branch address for the Hits, Digits, RawClusters, GlobalTrigger and LocalTrigger Tree.
582   char branchname[30];
583   TBranch * branch = 0x0;
584   
585   AliDebug(1,Form("option=%s",option));
586   
587   //
588   // Branch address for Sdigit tree
589   if (TreeS() && fSDigits && cS) {
590     AliDebug(1,"Setting branch addresses");
591     for (int i=0; i<AliMUONConstants::NCh(); i++) {
592       sprintf(branchname,"%sSDigits%d",GetName(),i+1);
593       if (fSDigits) {
594         AliDebug(1,Form("TreeS=%p for ich=%d branchname=%s",
595                         TreeS(),i,branchname));
596         branch = TreeS()->GetBranch(branchname);
597         TClonesArray * sdigits = SDigits(i);
598         if (branch) branch->SetAddress( &sdigits );
599         else AliWarning(Form("(%s) Failed for SDigits Detection plane %d. Can not find branch in tree.",GetName(),i));
600       }
601     }
602   }
603
604   //
605   // Branch address for digit tree
606   if (TreeD() && fDigits && cD) {
607     for (int i=0; i<AliMUONConstants::NCh(); i++) {
608       sprintf(branchname,"%sDigits%d",GetName(),i+1);
609       if (fDigits) {
610         branch = TreeD()->GetBranch(branchname);
611         TClonesArray * digits = Digits(i);
612         if (branch) {
613           branch->SetAddress( &digits );
614         }
615         else AliWarning(Form("(%s) Failed for Digits Detection plane %d. Can not find branch in tree.",GetName(),i));
616       }
617     }
618   }
619   if ( TreeD()  && fLocalTrigger && cGLT) {
620     sprintf(branchname,"%sLocalTrigger",GetName());
621     branch = TreeD()->GetBranch(branchname);
622     if (branch) branch->SetAddress(&fLocalTrigger);
623     else AliWarning(Form("(%s) Failed for LocalTrigger. Can not find branch in treeD.",GetName()));
624   }
625  if ( TreeD()  && fRegionalTrigger && cGLT) {
626     sprintf(branchname,"%sRegionalTrigger",GetName());
627     branch = TreeD()->GetBranch(branchname);
628     if (branch) branch->SetAddress(&fRegionalTrigger);
629     else AliWarning(Form("(%s) Failed for RegionalTrigger. Can not find branch in treeD.",GetName()));
630   }
631   if ( TreeD() && fGlobalTrigger && cGLT) {
632     sprintf(branchname,"%sGlobalTrigger",GetName());
633     branch = TreeD()->GetBranch(branchname);
634     if (branch) branch->SetAddress(&fGlobalTrigger);
635     else AliWarning(Form("(%s) Failed for GlobalTrigger. Can not find branch in treeD.",GetName()));
636   }
637 }
638
639 //_____________________________________________________________________________
640 void
641 AliMUONData::Print(Option_t* opt) const
642 {
643 /// Dump object on screen
644
645   TString options(opt);
646   options.ToUpper();
647   
648   if ( options.Contains("D") )
649   {
650     for ( Int_t ich = 0; ich < AliMUONConstants::NCh(); ++ich)
651     {
652       TClonesArray* digits = Digits(ich);
653       Int_t ndigits = digits->GetEntriesFast();
654       for ( Int_t id = 0; id < ndigits; ++id )
655       {
656         AliMUONDigit* digit = 
657           static_cast<AliMUONDigit*>(digits->UncheckedAt(id));
658         digit->Print();
659       }
660     }
661   }
662
663   if ( options.Contains("S") )
664   {
665     for ( Int_t ich = 0; ich < AliMUONConstants::NCh(); ++ich)
666     {
667       TClonesArray* digits = SDigits(ich);
668       Int_t ndigits = digits->GetEntriesFast();
669       for ( Int_t id = 0; id < ndigits; ++id )
670       {
671         AliMUONDigit* digit = 
672         static_cast<AliMUONDigit*>(digits->UncheckedAt(id));
673         digit->Print();
674       }
675     }
676   }  
677 }
678
679 //_____________________________________________________________________________
680 void 
681 AliMUONData::DumpSDigits(Int_t event2Check, Option_t* opt)
682 {
683 /// Dump SDigits
684
685   fLoader->LoadSDigits("READ");
686   
687   // Event loop
688   Int_t nevents = fRunLoader->GetNumberOfEvents();
689   for (Int_t ievent=0; ievent<nevents; ievent++) {
690     if (event2Check!=0) ievent=event2Check;
691     printf(">>> Event %d \n",ievent);
692
693     // Getting event ievent
694     fRunLoader->GetEvent(ievent);
695     SetTreeAddress("S");
696     GetSDigits();
697
698     // Loop on chambers
699     Int_t nchambers = AliMUONConstants::NCh(); ;
700     for (Int_t ichamber=0; ichamber<nchambers; ichamber++) {
701       TClonesArray* digits = SDigits(ichamber);
702
703       // Loop on Sdigits
704       Int_t ndigits = (Int_t)digits->GetEntriesFast();
705       for (Int_t idigit=0; idigit<ndigits; idigit++) {
706         AliMUONDigit* mDigit = static_cast<AliMUONDigit*>(digits->At(idigit));
707         mDigit->Print(opt);
708       }
709     }
710     ResetSDigits();
711     if (event2Check!=0) ievent=nevents;
712   }
713   fLoader->UnloadSDigits();
714 }
715 //_____________________________________________________________________________
716 void 
717 AliMUONData::DumpDigits(Int_t event2Check, Option_t* opt)
718 {
719 /// Dump digits
720
721   fLoader->LoadDigits("READ");
722   
723   // Event loop
724   Int_t firstEvent = 0;
725   Int_t lastEvent = fRunLoader->GetNumberOfEvents()-1;
726   if ( event2Check != 0 ) {
727     firstEvent = event2Check;
728     lastEvent = event2Check;
729   }  
730   
731   for ( Int_t ievent = firstEvent; ievent <= lastEvent; ++ievent ) {
732     printf(">>> Event %d \n",ievent);
733     fRunLoader->GetEvent(ievent);
734
735     AliMUONDataIterator it(this, "digit", AliMUONDataIterator::kTrackingChambers);
736     AliMUONDigit* digit;
737  
738      while ( ( digit = (AliMUONDigit*)it.Next() ) )
739      {
740        digit->Print(opt);
741      }
742   } 
743   fLoader->UnloadDigits();
744 }