]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/AliMUONDataInterface.cxx
Bug on error calculations (Christian)
[u/mrichter/AliRoot.git] / MUON / AliMUONDataInterface.cxx
1
2 // Author: Artur Szostak
3 //  email: artur@alice.phy.uct.ac.za
4
5 #include <TError.h>
6 #include <TParticle.h>
7
8 #include "AliRunLoader.h"
9 #include "AliLoader.h"
10
11 #include "AliMUONDataInterface.h"
12 #include "AliMUONLocalTrigger.h"
13 #include "AliMUONHit.h"
14 #include "AliMUONDigit.h"
15 #include "AliMUONRawCluster.h"
16
17
18 ClassImp(AliMUONDataInterface)
19
20
21 AliMUONDataInterface::AliMUONDataInterface()
22         : TObject(), fData(NULL, "MUON", "MUON")
23 {
24 // Set all internal pointers to NULL and indices to -1.
25
26         Reset();
27 };
28
29 AliMUONDataInterface::AliMUONDataInterface(const AliMUONDataInterface& rhs)
30   : TObject(rhs)
31 {
32 // Protected copy constructor
33
34   Fatal("AliMUONDataInterface", "Not implemented.");
35 }
36
37 AliMUONDataInterface::~AliMUONDataInterface()
38 {
39 // Delete the runloader when done.
40 // If the runloader is not to be deleted then call Reset just before 
41 // the destructor is called.
42
43         if (fRunloader != NULL)
44                 delete fRunloader;
45 };
46
47 AliMUONDataInterface&  
48 AliMUONDataInterface::operator=(const AliMUONDataInterface& rhs)
49 {
50 // Protected assignement operator
51
52   if (this == &rhs) return *this;
53
54   Fatal("operator=", "Not implemented.");
55     
56   return *this;  
57 }    
58           
59
60 void AliMUONDataInterface::Reset()
61 {
62 // Sets all internal pointers to NULL and indices to -1.
63 // Note: No resources are released!
64 // Specificaly AliRunLoader is not deleted.
65
66         fRunloader = NULL;
67         fMuonloader = NULL;
68         fEventnumber = -1;
69         fTrack = -1;
70         fSCathode = -1;
71         fCathode = -1;
72         fHitAddressSet = kFALSE;
73         fSDigitAddressSet = kFALSE;
74         fDigitAddressSet = kFALSE;
75         fClusterAddressSet = kFALSE;
76         fTriggerAddressSet = kFALSE;
77 };
78
79
80 Bool_t AliMUONDataInterface::LoadLoaders(TString filename, TString foldername)
81 {
82 // Load the run and muon loaders from the specified file and folder.
83 // kTRUE is returned on success and kFALSE on failure.
84
85         fRunloader = AliRunLoader::Open(filename, foldername, "READ");
86         if (fRunloader == NULL)
87         {
88                 Error("LoadLoaders", "Could not find or load the run loader for the file: %s and folder: %s", 
89                         (const char*)filename, (const char*)foldername);
90                 return kFALSE;
91         };
92         fMuonloader = fRunloader->GetLoader("MUONLoader");
93         if (fMuonloader == NULL)
94         {
95                 Error("LoadLoaders", "Could not find the MUON loader in file: %s and folder: %s", 
96                         (const char*)filename, (const char*)foldername);
97                 fRunloader = NULL;
98                 return kFALSE;
99         };
100         
101         // Need to connect the muon loader to the AliMUONData object,
102         // else class to fData will return NULL.
103         fData.SetLoader(fMuonloader);
104         
105         fFilename = filename;
106         fFoldername = foldername;
107         fEventnumber = -1;  // Reset the event number to force the event to be loaded.
108         return kTRUE;
109 };
110
111
112 Bool_t AliMUONDataInterface::FetchLoaders(TString filename, TString foldername)
113 {
114 // Fetch the run loader and muon loader objects from memory if they already exist,
115 // or from memory if they do not. 
116 // If the currently loaded run loader (if any) is not refering to the file and folder
117 // we are interested in then it is deleted and reopened with the required file and
118 // folder names.
119
120         if (fRunloader == NULL)
121         {
122                 fRunloader = AliRunLoader::GetRunLoader();
123                 if (fRunloader == NULL)
124                         return LoadLoaders(filename, foldername);
125                 
126                 // Fetch the current file and folder names.
127                 fFilename = fRunloader->GetFileName();
128                 fFoldername = fRunloader->GetEventFolder()->GetName();
129         };
130
131         // If filename or foldername are not the same as the ones currently selected then
132         // reopen the file.
133         if ( filename.CompareTo(fFilename) != 0 || foldername.CompareTo(fFoldername) != 0 )
134         {
135                 delete fRunloader;
136                 return LoadLoaders(filename, foldername);
137         };
138         return kTRUE;
139 };
140
141
142 Bool_t AliMUONDataInterface::FetchEvent(Int_t event)
143 {
144 // Fetch the specified event from the runloader and reset all the track, cathode
145 // and address flags to force them to be reloaded.
146
147         if (fEventnumber < 0)
148         {
149                 fEventnumber = fRunloader->GetEventNumber();
150                 fTrack = -1;
151                 fSCathode = -1;
152                 fCathode = -1;
153                 fHitAddressSet = kFALSE;
154                 fSDigitAddressSet = kFALSE;
155                 fDigitAddressSet = kFALSE;
156                 fClusterAddressSet = kFALSE;
157                 fTriggerAddressSet = kFALSE;
158         };
159         if ( event != fEventnumber )
160         {
161                 if ( fRunloader->GetEvent(event) < 0 ) return kFALSE;
162                 fEventnumber = event;
163                 fTrack = -1;
164                 fSCathode = -1;
165                 fCathode = -1;
166                 fHitAddressSet = kFALSE;
167                 fSDigitAddressSet = kFALSE;
168                 fDigitAddressSet = kFALSE;
169                 fClusterAddressSet = kFALSE;
170                 fTriggerAddressSet = kFALSE;
171         };
172         return kTRUE;
173 };
174
175
176 Bool_t AliMUONDataInterface::FetchTreeK()
177 {
178 // Fetch the Kine tree from the current run loader.
179
180         if (fRunloader->TreeK() == NULL)
181         {
182                 fRunloader->LoadKinematics("READ");
183                 if (fRunloader->TreeK() == NULL)
184                 {
185                         Error("FetchTreeK", "Could not load TreeK.");
186                         return kFALSE;
187                 };
188         };
189         return kTRUE;
190 };
191
192
193 Bool_t AliMUONDataInterface::FetchTreeH()
194 {
195 // Fetch the Hits tree from the current muon loader.
196 // Set all the required addresses etc...
197
198         if (fMuonloader->TreeH() == NULL)
199         {
200                 fMuonloader->LoadHits("READ");
201                 if (fMuonloader->TreeH() == NULL)
202                 {
203                         Error("FetchTreeH", "Could not load TreeH.");
204                         return kFALSE;
205                 };
206                 fData.SetTreeAddress("H");
207                 fHitAddressSet = kTRUE;
208         }
209         else if ( ! fHitAddressSet )
210         {
211                 fData.SetTreeAddress("H");
212                 fHitAddressSet = kTRUE;
213         };
214         return kTRUE;
215 };
216
217
218 Bool_t AliMUONDataInterface::FetchTreeS()
219 {
220 // Fetch the S-Digits tree from the current muon loader.
221 // Set all the required addresses etc...
222
223         if (fMuonloader->TreeS() == NULL)
224         {
225                 fMuonloader->LoadSDigits("READ");
226                 if (fMuonloader->TreeS() == NULL)
227                 {
228                         Error("FetchTreeS", "Could not load TreeS.");
229                         return kFALSE;
230                 };
231                 fData.SetTreeAddress("S");
232                 fSDigitAddressSet = kTRUE;
233         }
234         else if ( ! fSDigitAddressSet )
235         {
236                 fData.SetTreeAddress("S");
237                 fSDigitAddressSet = kTRUE;
238         };
239         return kTRUE;
240 };
241
242
243 Bool_t AliMUONDataInterface::FetchTreeD()
244 {
245 // Fetch the digits tree from the current muon loader.
246 // Set all the required addresses etc...
247
248         if (fMuonloader->TreeD() == NULL)
249         {
250                 fMuonloader->LoadDigits("READ");
251                 if (fMuonloader->TreeD() == NULL)
252                 {
253                         Error("FetchTreeD", "Could not load TreeD.");
254                         return kFALSE;
255                 };
256                 fData.SetTreeAddress("D");
257                 fDigitAddressSet = kTRUE;
258         }
259         else if ( ! fDigitAddressSet )
260         {
261                 fData.SetTreeAddress("D");
262                 fDigitAddressSet = kTRUE;
263         };
264         return kTRUE;
265 };
266
267
268 Bool_t AliMUONDataInterface::FetchTreeR()
269 {
270 // Fetch the reconstructed objects tree from the current muon loader.
271 // Nore: The addresses must still be set. 
272
273         if (fMuonloader->TreeR() == NULL)
274         {
275                 fMuonloader->LoadRecPoints("READ");
276                 if (fMuonloader->TreeR() == NULL)
277                 {
278                         Error("FetchTreeR", "Could not load TreeR.");
279                         return kFALSE;
280                 };
281                 
282                 // Need to reset these flags so that the cluster and trigger address
283                 // gets reset after this method. 
284                 fClusterAddressSet = kFALSE;
285                 fTriggerAddressSet = kFALSE;
286         };
287         return kTRUE;
288 };
289
290
291 Int_t AliMUONDataInterface::NumberOfEvents(TString filename, TString foldername)
292 {
293 // Returns the number of events in the specified file/folder, and -1 on error.
294
295         if ( ! FetchLoaders(filename, foldername) ) return -1;
296         return fRunloader->GetNumberOfEvents();
297 };
298
299
300 Int_t AliMUONDataInterface::NumberOfParticles(TString filename, TString foldername, Int_t event)
301 {
302 // Returns the number of events in the specified file/folder, and -1 on error.
303
304         if ( ! FetchLoaders(filename, foldername) ) return -1;
305         if ( ! FetchEvent(event) ) return -1;
306         if ( ! FetchTreeK() ) return -1;
307         return (Int_t) fRunloader->TreeK()->GetEntriesFast();
308 };
309
310
311 TParticle* AliMUONDataInterface::Particle(
312                 TString filename, TString foldername, Int_t event, Int_t particle
313         )
314 {
315 // Returns the specified particle in the given file, folder and event.
316 // NULL is returned on error.
317
318         if ( ! FetchLoaders(filename, foldername) ) return NULL;
319         if ( ! FetchEvent(event) ) return NULL;
320         if ( ! FetchTreeK() ) return NULL;
321         
322         TTree* treeK = fRunloader->TreeK();
323         TParticle* p = NULL;
324         treeK->GetBranch("Particles")->SetAddress(&p);
325         treeK->GetEvent(particle);
326         return p;
327 };
328
329
330 Int_t AliMUONDataInterface::NumberOfTracks(TString filename, TString foldername, Int_t event)
331 {
332 // Returns the number of tracks in the specified file/folder and event.
333 // -1 is returned on error.
334
335         if ( ! FetchLoaders(filename, foldername) ) return -1;
336         if ( ! FetchEvent(event) ) return -1;
337         if ( ! FetchTreeH() ) return -1;
338         return fData.GetNtracks();
339 };
340
341
342 Int_t AliMUONDataInterface::NumberOfHits(
343                 TString filename, TString foldername, Int_t event, Int_t track
344         )
345 {
346 // Returns the number of hits in the specified file/folder, event and track.
347 // -1 is returned on error.
348
349         if ( ! FetchLoaders(filename, foldername) ) return -1;
350         if ( ! FetchEvent(event) ) return -1;
351         if ( ! FetchTreeH() ) return -1;
352
353         if (fTrack < 0 || fTrack != track)
354         {
355                 fData.ResetHits();
356                 fData.GetTrack(track);
357                 fTrack = track;
358         };
359         return fData.Hits()->GetEntriesFast();
360 };
361
362
363 AliMUONHit* AliMUONDataInterface::Hit(
364                 TString filename, TString foldername, Int_t event,
365                 Int_t track, Int_t hit
366         )
367 {
368 // Returns the specified hit in the given file, folder, event and track.
369 // NULL is returned on error.
370
371         if ( ! FetchLoaders(filename, foldername) ) return NULL;
372         if ( ! FetchEvent(event) ) return NULL;
373         if ( ! FetchTreeH() ) return NULL;
374
375         if (fTrack < 0 || fTrack != track)
376         {
377                 fData.ResetHits();
378                 fData.GetTrack(track);
379                 fTrack = track;
380         };
381         return static_cast<AliMUONHit*>( fData.Hits()->At(hit) );
382 };
383
384
385 Int_t AliMUONDataInterface::NumberOfSDigits(
386                 TString filename, TString foldername, Int_t event,
387                 Int_t chamber, Int_t cathode
388         )
389 {
390 // Returns the number of s-digits in the given file, folder, event,
391 // chamber and cathode. -1 is returned on error.
392
393         Assert( 0 <= chamber && chamber <= 13 );
394         Assert( 0 <= cathode && cathode <= 1 );
395         
396         if ( ! FetchLoaders(filename, foldername) ) return -1;
397         if ( ! FetchEvent(event) ) return -1;
398         if ( ! FetchTreeS() ) return -1;
399
400         if ( fSCathode != cathode )
401         {
402                 fData.ResetSDigits();
403                 fData.GetCathodeS(cathode);
404                 fSCathode = cathode;
405         };
406         return fData.SDigits(chamber)->GetEntriesFast();
407 };
408
409
410 AliMUONDigit* AliMUONDataInterface::SDigit(
411                 TString filename, TString foldername, Int_t event,
412                 Int_t chamber, Int_t cathode, Int_t sdigit
413         )
414 {
415 // Returns the specified s-digit in the given file, folder, event,
416 // chamber and cathode. NULL is returned on error.
417
418         Assert( 0 <= chamber && chamber <= 13 );
419         Assert( 0 <= cathode && cathode <= 1 );
420         
421         if ( ! FetchLoaders(filename, foldername) ) return NULL;
422         if ( ! FetchEvent(event) ) return NULL;
423         if ( ! FetchTreeS() ) return NULL;
424
425         if ( fSCathode != cathode )
426         {
427                 fData.ResetSDigits();
428                 fData.GetCathodeS(cathode);
429                 fSCathode = cathode;
430         };
431         return static_cast<AliMUONDigit*>( fData.SDigits(chamber)->At(sdigit) );
432 };
433
434
435 Int_t AliMUONDataInterface::NumberOfDigits(
436                 TString filename, TString foldername, Int_t event,
437                 Int_t chamber, Int_t cathode
438         )
439 {
440 // Returns the number of digits in the given file, folder, event,
441 // chamber and cathode. -1 is returned on error.
442         Assert( 0 <= chamber && chamber <= 13 );
443         Assert( 0 <= cathode && cathode <= 1 );
444         
445         if ( ! FetchLoaders(filename, foldername) ) return -1;
446         if ( ! FetchEvent(event) ) return -1;
447         if ( ! FetchTreeD() ) return -1;
448
449         if ( fCathode != cathode )
450         {
451                 fData.ResetDigits();
452                 fData.GetCathode(cathode);
453                 fCathode = cathode;
454         };
455         return fData.Digits(chamber)->GetEntriesFast();
456 };
457
458
459 AliMUONDigit* AliMUONDataInterface::Digit(
460                 TString filename, TString foldername, Int_t event,
461                 Int_t chamber, Int_t cathode, Int_t digit
462         )
463 {
464 // Returns the specified digit in the given file, folder, event,
465 // chamber and cathode. NULL is returned on error.
466
467         Assert( 0 <= chamber && chamber <= 13 );
468         Assert( 0 <= cathode && cathode <= 1 );
469         
470         if ( ! FetchLoaders(filename, foldername) ) return NULL;
471         if ( ! FetchEvent(event) ) return NULL;
472         if ( ! FetchTreeD() ) return NULL;
473
474         if ( fCathode != cathode )
475         {
476                 fData.ResetDigits();
477                 fData.GetCathode(cathode);
478                 fCathode = cathode;
479         };
480         return static_cast<AliMUONDigit*>( fData.Digits(chamber)->At(digit) );
481 };
482
483
484 Int_t AliMUONDataInterface::NumberOfRawClusters(
485                 TString filename, TString foldername, Int_t event, Int_t chamber
486         )
487 {
488 // Returns the number of raw clusters in the specified file, folder, event and chamber.
489 // -1 is returned or error.
490
491         Assert( 0 <= chamber && chamber <= 13 );
492         if ( ! FetchLoaders(filename, foldername) ) return -1;
493         if ( ! FetchEvent(event) ) return -1;
494         if ( ! FetchTreeR() ) return -1;
495         if ( ! fClusterAddressSet )
496         {
497                 // If the raw cluster address in TreeR is not set yet then set it now.
498                 fData.SetTreeAddress("RC");
499                 fData.ResetRawClusters();
500                 fData.GetRawClusters();
501                 fClusterAddressSet = kTRUE;
502         };
503         return fData.RawClusters(chamber)->GetEntriesFast();
504 };
505
506
507 AliMUONRawCluster* AliMUONDataInterface::RawCluster(
508                 TString filename, TString foldername, Int_t event,
509                 Int_t chamber, Int_t cluster
510         )
511 {
512 // Fetch the specified raw cluster from the given file, folder, event and chamber number.
513 // NULL is returned on error.
514
515         Assert( 0 <= chamber && chamber <= 13 );
516         if ( ! FetchLoaders(filename, foldername) ) return NULL;
517         if ( ! FetchEvent(event) ) return NULL;
518         if ( ! FetchTreeR() ) return NULL;
519         if ( ! fClusterAddressSet )
520         {
521                 // If the raw cluster address in TreeR is not set yet then set it now.
522                 fData.SetTreeAddress("RC");
523                 fData.ResetRawClusters();
524                 fData.GetRawClusters();
525                 fClusterAddressSet = kTRUE;
526         };
527         return static_cast<AliMUONRawCluster*>( fData.RawClusters(chamber)->At(cluster) );
528 };
529
530
531 Int_t AliMUONDataInterface::NumberOfLocalTriggers(TString filename, TString foldername, Int_t event)
532 {
533 // Return the number of local trigger objects in the specified file, folder and
534 // event number. -1 is returned on error.
535
536         if ( ! FetchLoaders(filename, foldername) ) return -1;
537         if ( ! FetchEvent(event) ) return -1;
538         if ( ! FetchTreeR() ) return -1;
539         if ( ! fTriggerAddressSet )
540         {
541                 // If the local trigger address in TreeR is not set yet then set it now.
542                 fData.SetTreeAddress("GLT");
543                 fData.ResetTrigger();
544                 fData.GetTrigger();
545                 fTriggerAddressSet = kTRUE;
546         };
547         return fData.LocalTrigger()->GetEntriesFast();
548 };
549
550
551 AliMUONLocalTrigger* AliMUONDataInterface::LocalTrigger(
552                 TString filename, TString foldername, Int_t event, Int_t trigger
553         )
554 {
555 // Fetch the specified local trigger object from the given file, folder and event number.
556 // NULL is returned on error.
557
558         if ( ! FetchLoaders(filename, foldername) ) return NULL;
559         if ( ! FetchEvent(event) ) return NULL;
560         if ( ! FetchTreeR() ) return NULL;
561         if ( ! fTriggerAddressSet )
562         {
563                 // If the local trigger address in TreeR is not set yet then set it now.
564                 fData.SetTreeAddress("GLT");
565                 fData.ResetTrigger();
566                 fData.GetTrigger();
567                 fTriggerAddressSet = kTRUE;
568         };
569         return static_cast<AliMUONLocalTrigger*>( fData.LocalTrigger()->At(trigger) );
570 };
571
572
573 Bool_t AliMUONDataInterface::SetFile(TString filename, TString foldername)
574 {
575 // Set the current file and folder from which to fetch data.
576 // kTRUE is returned if the run and muon loaders were found, else kFALSE. 
577
578         return FetchLoaders(filename, foldername);
579 };
580
581
582 Bool_t AliMUONDataInterface::GetEvent(Int_t event)
583 {
584 // Select the current event from which to fetch data.
585 // kTRUE is returned if the event was found, else kFALSE is returned.
586
587         return FetchEvent(event);
588 };
589
590
591 Int_t AliMUONDataInterface::NumberOfEvents()
592 {
593 // Get the number of events in the currently selected file.
594 // -1 is returned on error.
595
596         if (fRunloader == NULL)
597         {
598                 Error("NumberOfEvents", "File not set.");
599                 return -1;
600         };
601         return fRunloader->GetNumberOfEvents();
602 };
603
604
605 Int_t AliMUONDataInterface::NumberOfParticles()
606 {
607 // Get the number of particles in the current event.
608 // -1 is returned on error.
609
610         if (fRunloader == NULL)
611         {
612                 Error("NumberOfParticles", "File not set.");
613                 return -1;
614         };
615         if ( ! FetchTreeK() ) return -1;
616         return (Int_t) fRunloader->TreeK()->GetEntriesFast();
617 };
618
619
620 TParticle* AliMUONDataInterface::Particle(Int_t particle)
621 {
622 // Fetch the specified particle from the current event.
623 // NULL is returned on error.
624
625         if (fRunloader == NULL)
626         {
627                 Error("Particle", "File not set.");
628                 return NULL;
629         };
630         if (fEventnumber < 0)
631         {
632                 Error("Particle", "Event not chosen.");
633                 return NULL;
634         };
635         if ( ! FetchTreeK() ) return NULL;
636         TTree* treeK = fRunloader->TreeK();
637         TParticle* p = NULL;
638         treeK->GetBranch("Particles")->SetAddress(&p);
639         treeK->GetEvent(particle);
640         return p;
641 };
642
643
644 Int_t AliMUONDataInterface::NumberOfTracks()
645 {
646 // Get the number of tracks in the current event.
647 // -1 is returned on error.
648
649         if (fRunloader == NULL)
650         {
651                 Error("NumberOfTracks", "File not set.");
652                 return -1;
653         };
654         if (fEventnumber < 0)
655         {
656                 Error("NumberOfTracks", "Event not chosen.");
657                 return -1;
658         };
659         if ( ! FetchTreeH() ) return -1;
660         return fData.GetNtracks();
661 };
662
663
664 Int_t AliMUONDataInterface::NumberOfHits(Int_t track)
665 {
666 // Get the number of hits for the given track in the current event.
667 // -1 is returned on error.
668
669         if (fRunloader == NULL)
670         {
671                 Error("NumberOfHits", "File not set.");
672                 return -1;
673         };
674         if (fEventnumber < 0)
675         {
676                 Error("NumberOfHits", "Event not chosen.");
677                 return -1;
678         };
679         if ( ! FetchTreeH() ) return -1;
680         if (fTrack < 0 || fTrack != track)
681         {
682                 fData.ResetHits();
683                 fData.GetTrack(track);
684                 fTrack = track;
685         };
686         return fData.Hits()->GetEntriesFast();
687 };
688
689
690 AliMUONHit* AliMUONDataInterface::Hit(Int_t track, Int_t hit)
691 {
692 // Fetch the specified hit from the current event.
693 // NULL is returned on error.
694
695         if (fRunloader == NULL)
696         {
697                 Error("Hit", "File not set.");
698                 return NULL;
699         };
700         if (fEventnumber < 0)
701         {
702                 Error("Hit", "Event not chosen.");
703                 return NULL;
704         };
705         if ( ! FetchTreeH() ) return NULL;
706         if (fTrack < 0 || fTrack != track)
707         {
708                 fData.ResetHits();
709                 fData.GetTrack(track);
710                 fTrack = track;
711         };
712         return static_cast<AliMUONHit*>( fData.Hits()->At(hit) );
713 };
714
715
716 Int_t AliMUONDataInterface::NumberOfSDigits(Int_t chamber, Int_t cathode)
717 {
718 // Get the number of s-digits on the chamber, cathode in the current event.
719 // -1 is returned on error.
720
721         Assert( 0 <= chamber && chamber <= 13 );
722         Assert( 0 <= cathode && cathode <= 1 );
723         
724         if (fRunloader == NULL)
725         {
726                 Error("NumberOfSDigits", "File not set.");
727                 return -1;
728         };
729         if (fEventnumber < 0)
730         {
731                 Error("NumberOfSDigits", "Event not chosen.");
732                 return -1;
733         };
734
735         if ( ! FetchTreeS() ) return -1;
736         if ( fSCathode != cathode )
737         {
738                 fData.ResetSDigits();
739                 fData.GetCathodeS(cathode);
740                 fSCathode = cathode;
741         };
742         return fData.SDigits(chamber)->GetEntriesFast();
743 };
744
745
746 AliMUONDigit* AliMUONDataInterface::SDigit(Int_t chamber, Int_t cathode, Int_t sdigit)
747 {
748 // Fetch the specified s-digits on the chamber, cathode from the current event.
749 // NULL is returned on error.
750
751         Assert( 0 <= chamber && chamber <= 13 );
752         Assert( 0 <= cathode && cathode <= 1 );
753         
754         if (fRunloader == NULL)
755         {
756                 Error("SDigit", "File not set.");
757                 return NULL;
758         };
759         if (fEventnumber < 0)
760         {
761                 Error("SDigit", "Event not chosen.");
762                 return NULL;
763         };
764
765         if ( ! FetchTreeS() ) return NULL;
766         if ( fSCathode != cathode )
767         {
768                 fData.ResetSDigits();
769                 fData.GetCathodeS(cathode);
770                 fSCathode = cathode;
771         };
772         return static_cast<AliMUONDigit*>( fData.SDigits(chamber)->At(sdigit) );
773 };
774
775
776 Int_t AliMUONDataInterface::NumberOfDigits(Int_t chamber, Int_t cathode)
777 {
778 // Get the number of digits on the chamber, cathode in the current event.
779 // -1 is returned on error.
780
781         Assert( 0 <= chamber && chamber <= 13 );
782         Assert( 0 <= cathode && cathode <= 1 );
783         
784         if (fRunloader == NULL)
785         {
786                 Error("NumberOfDigits", "File not set.");
787                 return -1;
788         };
789         if (fEventnumber < 0)
790         {
791                 Error("NumberOfDigits", "Event not chosen.");
792                 return -1;
793         };
794         
795         if ( ! FetchTreeD() ) return -1;
796         if ( fCathode != cathode )
797         {
798                 fData.ResetDigits();
799                 fData.GetCathode(cathode);
800                 fCathode = cathode;
801         };
802         return fData.Digits(chamber)->GetEntriesFast();
803 };
804
805
806 AliMUONDigit* AliMUONDataInterface::Digit(Int_t chamber, Int_t cathode, Int_t digit)
807 {
808 // Fetch the specified digits on the chamber, cathode from the current event.
809 // NULL is returned on error.
810
811         Assert( 0 <= chamber && chamber <= 13 );
812         Assert( 0 <= cathode && cathode <= 1 );
813         
814         if (fRunloader == NULL)
815         {
816                 Error("Digit", "File not set.");
817                 return NULL;
818         };
819         if (fEventnumber < 0)
820         {
821                 Error("Digit", "Event not chosen.");
822                 return NULL;
823         };
824
825         if ( ! FetchTreeD() ) return NULL;
826         if ( fCathode != cathode )
827         {
828                 fData.ResetDigits();
829                 fData.GetCathode(cathode);
830                 fCathode = cathode;
831         };
832         return static_cast<AliMUONDigit*>( fData.Digits(chamber)->At(digit) );
833 };
834
835
836 Int_t AliMUONDataInterface::NumberOfRawClusters(Int_t chamber)
837 {
838 // Get the number of raw clusters on the given chamber in the current event.
839 // -1 is returned on error.
840
841         Assert( 0 <= chamber && chamber <= 13 );
842
843         if (fRunloader == NULL)
844         {
845                 Error("NumberOfRawClusters", "File not set.");
846                 return -1;
847         };
848         if (fEventnumber < 0)
849         {
850                 Error("NumberOfRawClusters", "Event not chosen.");
851                 return -1;
852         };
853
854         if ( ! FetchTreeR() ) return -1;
855         if ( ! fClusterAddressSet )
856         {
857                 fData.SetTreeAddress("RC");
858                 fData.ResetRawClusters();
859                 fData.GetRawClusters();
860                 fClusterAddressSet = kTRUE;
861         };
862         return fData.RawClusters(chamber)->GetEntriesFast();
863 };
864
865
866 AliMUONRawCluster* AliMUONDataInterface::RawCluster(Int_t chamber, Int_t cluster)
867 {
868 // Fetch the specified raw cluster on the given chamber from the current event.
869 // NULL is returned on error.
870
871         Assert( 0 <= chamber && chamber <= 13 );
872
873         if (fRunloader == NULL)
874         {
875                 Error("RawCluster", "File not set.");
876                 return NULL;
877         };
878         if (fEventnumber < 0)
879         {
880                 Error("RawCluster", "Event not chosen.");
881                 return NULL;
882         };
883
884         if ( ! FetchTreeR() ) return NULL;
885         if ( ! fClusterAddressSet )
886         {
887                 fData.SetTreeAddress("RC");
888                 fData.ResetRawClusters();
889                 fData.GetRawClusters();
890                 fClusterAddressSet = kTRUE;
891         };
892         return static_cast<AliMUONRawCluster*>( fData.RawClusters(chamber)->At(cluster) );
893 };
894
895
896 Int_t AliMUONDataInterface::NumberOfLocalTriggers()
897 {
898 // Get the number of local trigger objects in the current event.
899 // -1 is returned on error.
900
901         if (fRunloader == NULL)
902         {
903                 Error("NumberOfLocalTriggers", "File not set.");
904                 return -1;
905         };
906         if (fEventnumber < 0)
907         {
908                 Error("NumberOfLocalTriggers", "Event not chosen.");
909                 return -1;
910         };
911
912         if ( ! FetchTreeR() ) return -1;
913         if ( ! fTriggerAddressSet )
914         {
915                 fData.SetTreeAddress("GLT");
916                 fData.ResetTrigger();
917                 fData.GetTrigger();
918                 fTriggerAddressSet = kTRUE;
919         };
920         return fData.LocalTrigger()->GetEntriesFast();
921 };
922
923
924 AliMUONLocalTrigger* AliMUONDataInterface::LocalTrigger(Int_t trigger)
925 {
926 // Fetch the specified local trigger object from the current event.
927 // NULL is returned on error.
928
929         if (fRunloader == NULL)
930         {
931                 Error("LocalTrigger", "File not set.");
932                 return NULL;
933         };
934         if (fEventnumber < 0)
935         {
936                 Error("LocalTrigger", "Event not chosen.");
937                 return NULL;
938         };
939
940         if ( ! FetchTreeR() ) return NULL;
941         if ( ! fTriggerAddressSet )
942         {
943                 fData.SetTreeAddress("GLT");
944                 fData.ResetTrigger();
945                 fData.GetTrigger();
946                 fTriggerAddressSet = kTRUE;
947         };
948         return static_cast<AliMUONLocalTrigger*>( fData.LocalTrigger()->At(trigger) );
949 };