Updated comments for Doxygen - corrected warnings
[u/mrichter/AliRoot.git] / MUON / AliMUONDataInterface.cxx
CommitLineData
13985652 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$ */
48b32e42 17
18#include <TError.h>
30178c30 19#include <TParticle.h>
48b32e42 20
21#include "AliRunLoader.h"
22#include "AliLoader.h"
23
24#include "AliMUONDataInterface.h"
30178c30 25#include "AliMUONLocalTrigger.h"
554b38a6 26#include "AliMUONGlobalTrigger.h"
30178c30 27#include "AliMUONHit.h"
28#include "AliMUONDigit.h"
29#include "AliMUONRawCluster.h"
554b38a6 30#include "AliMUONTrack.h"
8c343c7c 31#include "AliLog.h"
48b32e42 32
6d149c9e 33#include <iostream>
34using std::endl;
35using std::cout;
36
85fec35d 37///
38/// \class AliMUONDataInterface
39///
40/// An easy to use interface to the MUON module data stored in
41/// TreeK, TreeH, TreeS, TreeD and TreeR
42/// One can fetch any of the data objects with all the calls to runloader,
43/// muon loader and AliMUONData done behind the scenes and automatically.
44///
45/// This interface in not necessarily the fastest way to fetch the data but
46/// it is the easiest.
47/// Note: If independant calls to the run loader, muon loader or
48/// AliMUONData objects are interspersed with calls to the
49/// AliMUONDataInterface to fetch data, one might need to call the Reset
50/// method between these method calls at some point to prevent
51/// AliMUONDataInterface from getting confused.
52/// This is necessary since this object assumes the state of runloader,
53/// muon loader nor AliMUONData has not changed between calls.
54/// If the state has changes then one must call Reset so that
55/// AliMUONDataInterface refreshes what it knows about the state
56/// of the loader and AliMUONData objects.
57///
58/// \deprecated We have to revisit all this AliMUONData stuff anyway,
59/// and probably make a real AliMUONLoader instead...
60///
13985652 61/// \author Artur Szostak
62/// email: artur@alice.phy.uct.ac.za
63
64
65/// \cond CLASSIMP
66ClassImp(AliMUONDataInterface)
67/// \endcond
48b32e42 68
69AliMUONDataInterface::AliMUONDataInterface()
70 : TObject(), fData(NULL, "MUON", "MUON")
71{
72// Set all internal pointers to NULL and indices to -1.
73
74 Reset();
925e6570 75}
48b32e42 76
11ca64ac 77AliMUONDataInterface::AliMUONDataInterface(const AliMUONDataInterface& rhs)
78 : TObject(rhs)
79{
80// Protected copy constructor
81
8c343c7c 82 AliFatal("Not implemented.");
11ca64ac 83}
48b32e42 84
85AliMUONDataInterface::~AliMUONDataInterface()
86{
6d149c9e 87// Delete the runloader if we created it.
48b32e42 88// If the runloader is not to be deleted then call Reset just before
89// the destructor is called.
90
6d149c9e 91 if (fRunloader != NULL && fCreatedRunLoader)
48b32e42 92 delete fRunloader;
925e6570 93}
48b32e42 94
11ca64ac 95AliMUONDataInterface&
96AliMUONDataInterface::operator=(const AliMUONDataInterface& rhs)
97{
98// Protected assignement operator
99
100 if (this == &rhs) return *this;
101
8c343c7c 102 AliFatal("Not implemented.");
11ca64ac 103
104 return *this;
105}
106
48b32e42 107
108void AliMUONDataInterface::Reset()
109{
110// Sets all internal pointers to NULL and indices to -1.
111// Note: No resources are released!
112// Specificaly AliRunLoader is not deleted.
113
6d149c9e 114 fCreatedRunLoader = kFALSE;
48b32e42 115 fRunloader = NULL;
116 fMuonloader = NULL;
117 fEventnumber = -1;
118 fTrack = -1;
119 fSCathode = -1;
120 fCathode = -1;
121 fHitAddressSet = kFALSE;
122 fSDigitAddressSet = kFALSE;
123 fDigitAddressSet = kFALSE;
124 fClusterAddressSet = kFALSE;
125 fTriggerAddressSet = kFALSE;
554b38a6 126 fRecTracksAddressSet = kFALSE;
925e6570 127}
48b32e42 128
129
6d149c9e 130Bool_t AliMUONDataInterface::UseCurrentRunLoader()
131{
132// Tries to fetch the current runloader with AliRunLoader::GetRunLoader. If nothing is
133// currently loaded then kFALSE is returned and AliMUONDataInterface is reset.
134
135 Reset();
136 fRunloader = AliRunLoader::GetRunLoader();
137 if (fRunloader == NULL) return kFALSE;
138 // Fetch the current file name, folder name and event number.
139 fFilename = fRunloader->GetFileName();
140 fFoldername = fRunloader->GetEventFolder()->GetName();
141 fEventnumber = fRunloader->GetEventNumber();
142
143 if ( ! FetchMuonLoader(fFilename.Data(), fFoldername.Data()) )
144 {
145 Reset();
146 return kFALSE;
147 }
148
149 return kTRUE;
150}
151
152
153Bool_t AliMUONDataInterface::FetchMuonLoader(TString filename, TString foldername)
154{
85fec35d 155 // fetches the muon loader for the given filename/foldername
156
6d149c9e 157 fMuonloader = fRunloader->GetLoader("MUONLoader");
158 if (fMuonloader == NULL)
159 {
160 AliError(Form("Could not find the MUON loader in file: %s and folder: %s",
161 (const char*)filename, (const char*)foldername));
162 return kFALSE;
163 }
164
165 // Need to connect the muon loader to the AliMUONData object,
166 // else class to fData will return NULL.
167 fData.SetLoader(fMuonloader);
168 return kTRUE;
169}
170
171
48b32e42 172Bool_t AliMUONDataInterface::LoadLoaders(TString filename, TString foldername)
173{
174// Load the run and muon loaders from the specified file and folder.
175// kTRUE is returned on success and kFALSE on failure.
176
177 fRunloader = AliRunLoader::Open(filename, foldername, "READ");
178 if (fRunloader == NULL)
179 {
8c343c7c 180 AliError(Form("Could not find or load the run loader for the file: %s and folder: %s",
181 (const char*)filename, (const char*)foldername));
48b32e42 182 return kFALSE;
925e6570 183 }
6d149c9e 184 fCreatedRunLoader = kTRUE;
185 if ( ! FetchMuonLoader(filename, foldername) )
48b32e42 186 {
48b32e42 187 fRunloader = NULL;
188 return kFALSE;
925e6570 189 }
48b32e42 190
48b32e42 191 fFilename = filename;
192 fFoldername = foldername;
193 fEventnumber = -1; // Reset the event number to force the event to be loaded.
194 return kTRUE;
925e6570 195}
48b32e42 196
197
198Bool_t AliMUONDataInterface::FetchLoaders(TString filename, TString foldername)
199{
200// Fetch the run loader and muon loader objects from memory if they already exist,
201// or from memory if they do not.
202// If the currently loaded run loader (if any) is not refering to the file and folder
203// we are interested in then it is deleted and reopened with the required file and
204// folder names.
205
206 if (fRunloader == NULL)
207 {
208 fRunloader = AliRunLoader::GetRunLoader();
209 if (fRunloader == NULL)
210 return LoadLoaders(filename, foldername);
6d149c9e 211 else
212 {
213 if (fMuonloader == NULL)
214 {
215 if ( ! FetchMuonLoader(filename, foldername) )
216 {
217 fRunloader = NULL;
218 return kFALSE;
219 }
220 }
221 }
48b32e42 222
223 // Fetch the current file and folder names.
224 fFilename = fRunloader->GetFileName();
225 fFoldername = fRunloader->GetEventFolder()->GetName();
925e6570 226 }
48b32e42 227
228 // If filename or foldername are not the same as the ones currently selected then
229 // reopen the file.
230 if ( filename.CompareTo(fFilename) != 0 || foldername.CompareTo(fFoldername) != 0 )
231 {
232 delete fRunloader;
233 return LoadLoaders(filename, foldername);
925e6570 234 }
48b32e42 235 return kTRUE;
925e6570 236}
48b32e42 237
238
239Bool_t AliMUONDataInterface::FetchEvent(Int_t event)
240{
241// Fetch the specified event from the runloader and reset all the track, cathode
242// and address flags to force them to be reloaded.
6d149c9e 243// If a negative event number is specified then the current runloader event
244// number is used.
48b32e42 245
246 if (fEventnumber < 0)
247 {
248 fEventnumber = fRunloader->GetEventNumber();
249 fTrack = -1;
250 fSCathode = -1;
251 fCathode = -1;
252 fHitAddressSet = kFALSE;
253 fSDigitAddressSet = kFALSE;
254 fDigitAddressSet = kFALSE;
255 fClusterAddressSet = kFALSE;
256 fTriggerAddressSet = kFALSE;
554b38a6 257 fRecTracksAddressSet = kFALSE;
925e6570 258 }
48b32e42 259 if ( event != fEventnumber )
260 {
261 if ( fRunloader->GetEvent(event) < 0 ) return kFALSE;
262 fEventnumber = event;
263 fTrack = -1;
264 fSCathode = -1;
265 fCathode = -1;
266 fHitAddressSet = kFALSE;
267 fSDigitAddressSet = kFALSE;
268 fDigitAddressSet = kFALSE;
269 fClusterAddressSet = kFALSE;
270 fTriggerAddressSet = kFALSE;
554b38a6 271 fRecTracksAddressSet = kFALSE;
925e6570 272 }
48b32e42 273 return kTRUE;
925e6570 274}
48b32e42 275
276
277Bool_t AliMUONDataInterface::FetchTreeK()
278{
279// Fetch the Kine tree from the current run loader.
280
281 if (fRunloader->TreeK() == NULL)
282 {
283 fRunloader->LoadKinematics("READ");
284 if (fRunloader->TreeK() == NULL)
285 {
8c343c7c 286 AliError("Could not load TreeK.");
48b32e42 287 return kFALSE;
925e6570 288 }
289 }
48b32e42 290 return kTRUE;
925e6570 291}
48b32e42 292
293
294Bool_t AliMUONDataInterface::FetchTreeH()
295{
296// Fetch the Hits tree from the current muon loader.
297// Set all the required addresses etc...
298
299 if (fMuonloader->TreeH() == NULL)
300 {
301 fMuonloader->LoadHits("READ");
302 if (fMuonloader->TreeH() == NULL)
303 {
8c343c7c 304 AliError("Could not load TreeH.");
48b32e42 305 return kFALSE;
925e6570 306 }
48b32e42 307 fData.SetTreeAddress("H");
308 fHitAddressSet = kTRUE;
309 }
310 else if ( ! fHitAddressSet )
311 {
312 fData.SetTreeAddress("H");
313 fHitAddressSet = kTRUE;
925e6570 314 }
48b32e42 315 return kTRUE;
925e6570 316}
48b32e42 317
318
319Bool_t AliMUONDataInterface::FetchTreeS()
320{
321// Fetch the S-Digits tree from the current muon loader.
322// Set all the required addresses etc...
323
324 if (fMuonloader->TreeS() == NULL)
325 {
326 fMuonloader->LoadSDigits("READ");
327 if (fMuonloader->TreeS() == NULL)
328 {
8c343c7c 329 AliError("Could not load TreeS.");
48b32e42 330 return kFALSE;
925e6570 331 }
48b32e42 332 fData.SetTreeAddress("S");
333 fSDigitAddressSet = kTRUE;
334 }
335 else if ( ! fSDigitAddressSet )
336 {
337 fData.SetTreeAddress("S");
338 fSDigitAddressSet = kTRUE;
925e6570 339 }
48b32e42 340 return kTRUE;
925e6570 341}
48b32e42 342
343
344Bool_t AliMUONDataInterface::FetchTreeD()
345{
346// Fetch the digits tree from the current muon loader.
347// Set all the required addresses etc...
348
349 if (fMuonloader->TreeD() == NULL)
350 {
351 fMuonloader->LoadDigits("READ");
352 if (fMuonloader->TreeD() == NULL)
353 {
8c343c7c 354 AliError("Could not load TreeD.");
48b32e42 355 return kFALSE;
925e6570 356 }
48b32e42 357 fData.SetTreeAddress("D");
358 fDigitAddressSet = kTRUE;
359 }
360 else if ( ! fDigitAddressSet )
361 {
362 fData.SetTreeAddress("D");
363 fDigitAddressSet = kTRUE;
925e6570 364 }
48b32e42 365 return kTRUE;
925e6570 366}
48b32e42 367
368
369Bool_t AliMUONDataInterface::FetchTreeR()
370{
554b38a6 371 // Fetch the reconstructed objects tree from the current muon loader.
372 // Note: The addresses must still be set.
373
374 if (fMuonloader->TreeR() == NULL)
375 {
376 fMuonloader->LoadRecPoints("READ");
377 if (fMuonloader->TreeR() == NULL)
48b32e42 378 {
554b38a6 379 AliError("Could not load TreeR.");
380 return kFALSE;
925e6570 381 }
554b38a6 382
383 // Need to reset these flags so that the cluster and trigger address
384 // gets reset after this method.
385 fClusterAddressSet = kFALSE;
386 fTriggerAddressSet = kFALSE;
387 }
388 return kTRUE;
925e6570 389}
48b32e42 390
554b38a6 391Bool_t AliMUONDataInterface::FetchTreeT()
392{
393 // fetch the reconstructed tracks tree from the current muon loader
394 // note : the addresses must still be set.
395 if (fMuonloader->TreeT() == NULL)
396 {
397 fMuonloader->LoadTracks("READ");
398 if (fMuonloader->TreeT() == NULL)
399 {
400 AliError("Could not load TreeT.");
401 return kFALSE;
402 }
403
404 // Need to reset these flags so that the rec tracks address
405 // gets reset after this method.
406 fRecTracksAddressSet = kFALSE;
407 }
408 return kTRUE;
409}
410
48b32e42 411Int_t AliMUONDataInterface::NumberOfEvents(TString filename, TString foldername)
412{
413// Returns the number of events in the specified file/folder, and -1 on error.
414
415 if ( ! FetchLoaders(filename, foldername) ) return -1;
416 return fRunloader->GetNumberOfEvents();
925e6570 417}
48b32e42 418
419
420Int_t AliMUONDataInterface::NumberOfParticles(TString filename, TString foldername, Int_t event)
421{
422// Returns the number of events in the specified file/folder, and -1 on error.
423
424 if ( ! FetchLoaders(filename, foldername) ) return -1;
425 if ( ! FetchEvent(event) ) return -1;
426 if ( ! FetchTreeK() ) return -1;
427 return (Int_t) fRunloader->TreeK()->GetEntriesFast();
925e6570 428}
48b32e42 429
430
431TParticle* AliMUONDataInterface::Particle(
432 TString filename, TString foldername, Int_t event, Int_t particle
433 )
434{
435// Returns the specified particle in the given file, folder and event.
436// NULL is returned on error.
437
438 if ( ! FetchLoaders(filename, foldername) ) return NULL;
439 if ( ! FetchEvent(event) ) return NULL;
440 if ( ! FetchTreeK() ) return NULL;
441
442 TTree* treeK = fRunloader->TreeK();
443 TParticle* p = NULL;
444 treeK->GetBranch("Particles")->SetAddress(&p);
445 treeK->GetEvent(particle);
446 return p;
925e6570 447}
48b32e42 448
449
450Int_t AliMUONDataInterface::NumberOfTracks(TString filename, TString foldername, Int_t event)
451{
452// Returns the number of tracks in the specified file/folder and event.
453// -1 is returned on error.
454
455 if ( ! FetchLoaders(filename, foldername) ) return -1;
456 if ( ! FetchEvent(event) ) return -1;
457 if ( ! FetchTreeH() ) return -1;
458 return fData.GetNtracks();
925e6570 459}
48b32e42 460
461
462Int_t AliMUONDataInterface::NumberOfHits(
463 TString filename, TString foldername, Int_t event, Int_t track
464 )
465{
466// Returns the number of hits in the specified file/folder, event and track.
467// -1 is returned on error.
468
469 if ( ! FetchLoaders(filename, foldername) ) return -1;
470 if ( ! FetchEvent(event) ) return -1;
471 if ( ! FetchTreeH() ) return -1;
472
473 if (fTrack < 0 || fTrack != track)
474 {
475 fData.ResetHits();
476 fData.GetTrack(track);
477 fTrack = track;
925e6570 478 }
48b32e42 479 return fData.Hits()->GetEntriesFast();
925e6570 480}
48b32e42 481
482
483AliMUONHit* AliMUONDataInterface::Hit(
484 TString filename, TString foldername, Int_t event,
485 Int_t track, Int_t hit
486 )
487{
488// Returns the specified hit in the given file, folder, event and track.
489// NULL is returned on error.
490
491 if ( ! FetchLoaders(filename, foldername) ) return NULL;
492 if ( ! FetchEvent(event) ) return NULL;
493 if ( ! FetchTreeH() ) return NULL;
494
495 if (fTrack < 0 || fTrack != track)
496 {
497 fData.ResetHits();
498 fData.GetTrack(track);
499 fTrack = track;
925e6570 500 }
48b32e42 501 return static_cast<AliMUONHit*>( fData.Hits()->At(hit) );
925e6570 502}
48b32e42 503
504
505Int_t AliMUONDataInterface::NumberOfSDigits(
506 TString filename, TString foldername, Int_t event,
507 Int_t chamber, Int_t cathode
508 )
509{
510// Returns the number of s-digits in the given file, folder, event,
511// chamber and cathode. -1 is returned on error.
512
513 Assert( 0 <= chamber && chamber <= 13 );
514 Assert( 0 <= cathode && cathode <= 1 );
515
516 if ( ! FetchLoaders(filename, foldername) ) return -1;
517 if ( ! FetchEvent(event) ) return -1;
518 if ( ! FetchTreeS() ) return -1;
519
520 if ( fSCathode != cathode )
521 {
522 fData.ResetSDigits();
935b9895 523 fData.GetSDigits();
48b32e42 524 fSCathode = cathode;
925e6570 525 }
48b32e42 526 return fData.SDigits(chamber)->GetEntriesFast();
925e6570 527}
48b32e42 528
529
530AliMUONDigit* AliMUONDataInterface::SDigit(
531 TString filename, TString foldername, Int_t event,
532 Int_t chamber, Int_t cathode, Int_t sdigit
533 )
534{
535// Returns the specified s-digit in the given file, folder, event,
536// chamber and cathode. NULL is returned on error.
537
538 Assert( 0 <= chamber && chamber <= 13 );
539 Assert( 0 <= cathode && cathode <= 1 );
540
541 if ( ! FetchLoaders(filename, foldername) ) return NULL;
542 if ( ! FetchEvent(event) ) return NULL;
543 if ( ! FetchTreeS() ) return NULL;
544
545 if ( fSCathode != cathode )
546 {
547 fData.ResetSDigits();
935b9895 548 fData.GetSDigits();
48b32e42 549 fSCathode = cathode;
925e6570 550 }
48b32e42 551 return static_cast<AliMUONDigit*>( fData.SDigits(chamber)->At(sdigit) );
925e6570 552}
48b32e42 553
554
555Int_t AliMUONDataInterface::NumberOfDigits(
556 TString filename, TString foldername, Int_t event,
557 Int_t chamber, Int_t cathode
558 )
559{
560// Returns the number of digits in the given file, folder, event,
561// chamber and cathode. -1 is returned on error.
562 Assert( 0 <= chamber && chamber <= 13 );
563 Assert( 0 <= cathode && cathode <= 1 );
564
565 if ( ! FetchLoaders(filename, foldername) ) return -1;
566 if ( ! FetchEvent(event) ) return -1;
567 if ( ! FetchTreeD() ) return -1;
568
569 if ( fCathode != cathode )
570 {
571 fData.ResetDigits();
935b9895 572 fData.GetDigits();
48b32e42 573 fCathode = cathode;
925e6570 574 }
48b32e42 575 return fData.Digits(chamber)->GetEntriesFast();
925e6570 576}
48b32e42 577
578
579AliMUONDigit* AliMUONDataInterface::Digit(
580 TString filename, TString foldername, Int_t event,
581 Int_t chamber, Int_t cathode, Int_t digit
582 )
583{
584// Returns the specified digit in the given file, folder, event,
585// chamber and cathode. NULL is returned on error.
586
587 Assert( 0 <= chamber && chamber <= 13 );
588 Assert( 0 <= cathode && cathode <= 1 );
589
590 if ( ! FetchLoaders(filename, foldername) ) return NULL;
591 if ( ! FetchEvent(event) ) return NULL;
592 if ( ! FetchTreeD() ) return NULL;
593
594 if ( fCathode != cathode )
595 {
596 fData.ResetDigits();
935b9895 597 fData.GetDigits();
48b32e42 598 fCathode = cathode;
925e6570 599 }
48b32e42 600 return static_cast<AliMUONDigit*>( fData.Digits(chamber)->At(digit) );
925e6570 601}
48b32e42 602
603
604Int_t AliMUONDataInterface::NumberOfRawClusters(
605 TString filename, TString foldername, Int_t event, Int_t chamber
606 )
607{
608// Returns the number of raw clusters in the specified file, folder, event and chamber.
609// -1 is returned or error.
610
611 Assert( 0 <= chamber && chamber <= 13 );
612 if ( ! FetchLoaders(filename, foldername) ) return -1;
613 if ( ! FetchEvent(event) ) return -1;
614 if ( ! FetchTreeR() ) return -1;
615 if ( ! fClusterAddressSet )
616 {
617 // If the raw cluster address in TreeR is not set yet then set it now.
618 fData.SetTreeAddress("RC");
619 fData.ResetRawClusters();
620 fData.GetRawClusters();
621 fClusterAddressSet = kTRUE;
925e6570 622 }
48b32e42 623 return fData.RawClusters(chamber)->GetEntriesFast();
925e6570 624}
48b32e42 625
626
627AliMUONRawCluster* AliMUONDataInterface::RawCluster(
628 TString filename, TString foldername, Int_t event,
629 Int_t chamber, Int_t cluster
630 )
631{
632// Fetch the specified raw cluster from the given file, folder, event and chamber number.
633// NULL is returned on error.
634
635 Assert( 0 <= chamber && chamber <= 13 );
636 if ( ! FetchLoaders(filename, foldername) ) return NULL;
637 if ( ! FetchEvent(event) ) return NULL;
638 if ( ! FetchTreeR() ) return NULL;
639 if ( ! fClusterAddressSet )
640 {
641 // If the raw cluster address in TreeR is not set yet then set it now.
642 fData.SetTreeAddress("RC");
643 fData.ResetRawClusters();
644 fData.GetRawClusters();
645 fClusterAddressSet = kTRUE;
925e6570 646 }
48b32e42 647 return static_cast<AliMUONRawCluster*>( fData.RawClusters(chamber)->At(cluster) );
925e6570 648}
48b32e42 649
650
651Int_t AliMUONDataInterface::NumberOfLocalTriggers(TString filename, TString foldername, Int_t event)
652{
653// Return the number of local trigger objects in the specified file, folder and
654// event number. -1 is returned on error.
655
656 if ( ! FetchLoaders(filename, foldername) ) return -1;
657 if ( ! FetchEvent(event) ) return -1;
6d149c9e 658 if ( ! FetchTreeD() ) return -1;
48b32e42 659 if ( ! fTriggerAddressSet )
660 {
935b9895 661 // If the local trigger address in TreeR is not set yet then set it now.
48b32e42 662 fData.SetTreeAddress("GLT");
663 fData.ResetTrigger();
6d149c9e 664 fData.GetTriggerD();
48b32e42 665 fTriggerAddressSet = kTRUE;
925e6570 666 }
48b32e42 667 return fData.LocalTrigger()->GetEntriesFast();
925e6570 668}
48b32e42 669
670
671AliMUONLocalTrigger* AliMUONDataInterface::LocalTrigger(
672 TString filename, TString foldername, Int_t event, Int_t trigger
673 )
674{
675// Fetch the specified local trigger object from the given file, folder and event number.
676// NULL is returned on error.
677
678 if ( ! FetchLoaders(filename, foldername) ) return NULL;
679 if ( ! FetchEvent(event) ) return NULL;
6d149c9e 680 if ( ! FetchTreeD() ) return NULL;
48b32e42 681 if ( ! fTriggerAddressSet )
682 {
935b9895 683 // If the local trigger address in TreeR is not set yet then set it now.
48b32e42 684 fData.SetTreeAddress("GLT");
685 fData.ResetTrigger();
6d149c9e 686 fData.GetTriggerD();
48b32e42 687 fTriggerAddressSet = kTRUE;
925e6570 688 }
48b32e42 689 return static_cast<AliMUONLocalTrigger*>( fData.LocalTrigger()->At(trigger) );
925e6570 690}
48b32e42 691
48b32e42 692Bool_t AliMUONDataInterface::SetFile(TString filename, TString foldername)
693{
694// Set the current file and folder from which to fetch data.
695// kTRUE is returned if the run and muon loaders were found, else kFALSE.
696
697 return FetchLoaders(filename, foldername);
925e6570 698}
48b32e42 699
700
701Bool_t AliMUONDataInterface::GetEvent(Int_t event)
702{
703// Select the current event from which to fetch data.
704// kTRUE is returned if the event was found, else kFALSE is returned.
705
382c2b3f 706 if (fRunloader == NULL)
707 {
708 AliError("File not set.");
709 return kFALSE;
710 }
711 else
712 return FetchEvent(event);
925e6570 713}
48b32e42 714
715
716Int_t AliMUONDataInterface::NumberOfEvents()
717{
718// Get the number of events in the currently selected file.
719// -1 is returned on error.
720
721 if (fRunloader == NULL)
722 {
8c343c7c 723 AliError("File not set.");
48b32e42 724 return -1;
925e6570 725 }
48b32e42 726 return fRunloader->GetNumberOfEvents();
925e6570 727}
48b32e42 728
729
730Int_t AliMUONDataInterface::NumberOfParticles()
731{
732// Get the number of particles in the current event.
733// -1 is returned on error.
734
735 if (fRunloader == NULL)
736 {
8c343c7c 737 AliError("File not set.");
48b32e42 738 return -1;
925e6570 739 }
48b32e42 740 if ( ! FetchTreeK() ) return -1;
741 return (Int_t) fRunloader->TreeK()->GetEntriesFast();
925e6570 742}
48b32e42 743
744
745TParticle* AliMUONDataInterface::Particle(Int_t particle)
746{
747// Fetch the specified particle from the current event.
748// NULL is returned on error.
749
750 if (fRunloader == NULL)
751 {
8c343c7c 752 AliError("File not set.");
48b32e42 753 return NULL;
925e6570 754 }
48b32e42 755 if (fEventnumber < 0)
756 {
8c343c7c 757 AliError("Event not chosen.");
48b32e42 758 return NULL;
925e6570 759 }
48b32e42 760 if ( ! FetchTreeK() ) return NULL;
761 TTree* treeK = fRunloader->TreeK();
762 TParticle* p = NULL;
763 treeK->GetBranch("Particles")->SetAddress(&p);
764 treeK->GetEvent(particle);
765 return p;
925e6570 766}
48b32e42 767
768
769Int_t AliMUONDataInterface::NumberOfTracks()
770{
771// Get the number of tracks in the current event.
772// -1 is returned on error.
773
774 if (fRunloader == NULL)
775 {
8c343c7c 776 AliError("File not set.");
48b32e42 777 return -1;
925e6570 778 }
48b32e42 779 if (fEventnumber < 0)
780 {
8c343c7c 781 AliError( "Event not chosen.");
48b32e42 782 return -1;
925e6570 783 }
48b32e42 784 if ( ! FetchTreeH() ) return -1;
785 return fData.GetNtracks();
925e6570 786}
48b32e42 787
788
789Int_t AliMUONDataInterface::NumberOfHits(Int_t track)
790{
791// Get the number of hits for the given track in the current event.
792// -1 is returned on error.
793
794 if (fRunloader == NULL)
795 {
8c343c7c 796 AliError("File not set.");
48b32e42 797 return -1;
925e6570 798 }
48b32e42 799 if (fEventnumber < 0)
800 {
8c343c7c 801 AliError("Event not chosen.");
48b32e42 802 return -1;
925e6570 803 }
48b32e42 804 if ( ! FetchTreeH() ) return -1;
805 if (fTrack < 0 || fTrack != track)
806 {
807 fData.ResetHits();
808 fData.GetTrack(track);
809 fTrack = track;
925e6570 810 }
48b32e42 811 return fData.Hits()->GetEntriesFast();
925e6570 812}
48b32e42 813
814
815AliMUONHit* AliMUONDataInterface::Hit(Int_t track, Int_t hit)
816{
817// Fetch the specified hit from the current event.
818// NULL is returned on error.
819
820 if (fRunloader == NULL)
821 {
8c343c7c 822 AliError("File not set.");
48b32e42 823 return NULL;
925e6570 824 }
48b32e42 825 if (fEventnumber < 0)
826 {
8c343c7c 827 AliError("Event not chosen.");
48b32e42 828 return NULL;
925e6570 829 }
48b32e42 830 if ( ! FetchTreeH() ) return NULL;
831 if (fTrack < 0 || fTrack != track)
832 {
833 fData.ResetHits();
834 fData.GetTrack(track);
835 fTrack = track;
925e6570 836 }
48b32e42 837 return static_cast<AliMUONHit*>( fData.Hits()->At(hit) );
925e6570 838}
48b32e42 839
840
841Int_t AliMUONDataInterface::NumberOfSDigits(Int_t chamber, Int_t cathode)
842{
843// Get the number of s-digits on the chamber, cathode in the current event.
844// -1 is returned on error.
845
846 Assert( 0 <= chamber && chamber <= 13 );
847 Assert( 0 <= cathode && cathode <= 1 );
848
849 if (fRunloader == NULL)
850 {
8c343c7c 851 AliError("File not set.");
48b32e42 852 return -1;
925e6570 853 }
48b32e42 854 if (fEventnumber < 0)
855 {
8c343c7c 856 AliError("Event not chosen.");
48b32e42 857 return -1;
925e6570 858 }
48b32e42 859
860 if ( ! FetchTreeS() ) return -1;
861 if ( fSCathode != cathode )
862 {
863 fData.ResetSDigits();
935b9895 864 fData.GetSDigits();
48b32e42 865 fSCathode = cathode;
925e6570 866 }
48b32e42 867 return fData.SDigits(chamber)->GetEntriesFast();
925e6570 868}
48b32e42 869
870
871AliMUONDigit* AliMUONDataInterface::SDigit(Int_t chamber, Int_t cathode, Int_t sdigit)
872{
873// Fetch the specified s-digits on the chamber, cathode from the current event.
874// NULL is returned on error.
875
876 Assert( 0 <= chamber && chamber <= 13 );
877 Assert( 0 <= cathode && cathode <= 1 );
878
879 if (fRunloader == NULL)
880 {
8c343c7c 881 AliError("File not set.");
48b32e42 882 return NULL;
925e6570 883 }
48b32e42 884 if (fEventnumber < 0)
885 {
8c343c7c 886 AliError("Event not chosen.");
48b32e42 887 return NULL;
925e6570 888 }
48b32e42 889
890 if ( ! FetchTreeS() ) return NULL;
891 if ( fSCathode != cathode )
892 {
893 fData.ResetSDigits();
935b9895 894 fData.GetSDigits();
48b32e42 895 fSCathode = cathode;
925e6570 896 }
48b32e42 897 return static_cast<AliMUONDigit*>( fData.SDigits(chamber)->At(sdigit) );
925e6570 898}
48b32e42 899
900
901Int_t AliMUONDataInterface::NumberOfDigits(Int_t chamber, Int_t cathode)
902{
903// Get the number of digits on the chamber, cathode in the current event.
904// -1 is returned on error.
905
906 Assert( 0 <= chamber && chamber <= 13 );
907 Assert( 0 <= cathode && cathode <= 1 );
908
909 if (fRunloader == NULL)
910 {
8c343c7c 911 AliError("File not set.");
48b32e42 912 return -1;
925e6570 913 }
48b32e42 914 if (fEventnumber < 0)
915 {
8c343c7c 916 AliError("Event not chosen.");
48b32e42 917 return -1;
925e6570 918 }
48b32e42 919
920 if ( ! FetchTreeD() ) return -1;
921 if ( fCathode != cathode )
922 {
923 fData.ResetDigits();
935b9895 924 fData.GetDigits();
48b32e42 925 fCathode = cathode;
925e6570 926 }
48b32e42 927 return fData.Digits(chamber)->GetEntriesFast();
925e6570 928}
48b32e42 929
930
931AliMUONDigit* AliMUONDataInterface::Digit(Int_t chamber, Int_t cathode, Int_t digit)
932{
933// Fetch the specified digits on the chamber, cathode from the current event.
934// NULL is returned on error.
935
936 Assert( 0 <= chamber && chamber <= 13 );
937 Assert( 0 <= cathode && cathode <= 1 );
938
939 if (fRunloader == NULL)
940 {
8c343c7c 941 AliError("File not set.");
48b32e42 942 return NULL;
925e6570 943 }
48b32e42 944 if (fEventnumber < 0)
945 {
8c343c7c 946 AliError("Event not chosen.");
48b32e42 947 return NULL;
925e6570 948 }
48b32e42 949
950 if ( ! FetchTreeD() ) return NULL;
951 if ( fCathode != cathode )
952 {
953 fData.ResetDigits();
935b9895 954 fData.GetDigits();
48b32e42 955 fCathode = cathode;
925e6570 956 }
48b32e42 957 return static_cast<AliMUONDigit*>( fData.Digits(chamber)->At(digit) );
925e6570 958}
48b32e42 959
960
961Int_t AliMUONDataInterface::NumberOfRawClusters(Int_t chamber)
962{
963// Get the number of raw clusters on the given chamber in the current event.
964// -1 is returned on error.
965
966 Assert( 0 <= chamber && chamber <= 13 );
967
968 if (fRunloader == NULL)
969 {
8c343c7c 970 AliError("File not set.");
48b32e42 971 return -1;
925e6570 972 }
48b32e42 973 if (fEventnumber < 0)
974 {
8c343c7c 975 AliError("Event not chosen.");
48b32e42 976 return -1;
925e6570 977 }
48b32e42 978
979 if ( ! FetchTreeR() ) return -1;
980 if ( ! fClusterAddressSet )
981 {
982 fData.SetTreeAddress("RC");
983 fData.ResetRawClusters();
984 fData.GetRawClusters();
985 fClusterAddressSet = kTRUE;
925e6570 986 }
48b32e42 987 return fData.RawClusters(chamber)->GetEntriesFast();
925e6570 988}
48b32e42 989
990
991AliMUONRawCluster* AliMUONDataInterface::RawCluster(Int_t chamber, Int_t cluster)
992{
993// Fetch the specified raw cluster on the given chamber from the current event.
994// NULL is returned on error.
995
996 Assert( 0 <= chamber && chamber <= 13 );
997
998 if (fRunloader == NULL)
999 {
8c343c7c 1000 AliError("File not set.");
48b32e42 1001 return NULL;
925e6570 1002 }
48b32e42 1003 if (fEventnumber < 0)
1004 {
8c343c7c 1005 AliError("Event not chosen.");
48b32e42 1006 return NULL;
925e6570 1007 }
48b32e42 1008
1009 if ( ! FetchTreeR() ) return NULL;
1010 if ( ! fClusterAddressSet )
1011 {
1012 fData.SetTreeAddress("RC");
1013 fData.ResetRawClusters();
1014 fData.GetRawClusters();
1015 fClusterAddressSet = kTRUE;
925e6570 1016 }
48b32e42 1017 return static_cast<AliMUONRawCluster*>( fData.RawClusters(chamber)->At(cluster) );
925e6570 1018}
48b32e42 1019
1020
1021Int_t AliMUONDataInterface::NumberOfLocalTriggers()
1022{
1023// Get the number of local trigger objects in the current event.
1024// -1 is returned on error.
1025
1026 if (fRunloader == NULL)
1027 {
8c343c7c 1028 AliError("File not set.");
48b32e42 1029 return -1;
925e6570 1030 }
48b32e42 1031 if (fEventnumber < 0)
1032 {
8c343c7c 1033 AliError("Event not chosen.");
48b32e42 1034 return -1;
925e6570 1035 }
48b32e42 1036
6d149c9e 1037 if ( ! FetchTreeD() ) return -1;
48b32e42 1038 if ( ! fTriggerAddressSet )
1039 {
1040 fData.SetTreeAddress("GLT");
1041 fData.ResetTrigger();
6d149c9e 1042 fData.GetTriggerD();
48b32e42 1043 fTriggerAddressSet = kTRUE;
925e6570 1044 }
48b32e42 1045 return fData.LocalTrigger()->GetEntriesFast();
925e6570 1046}
48b32e42 1047
1048
1049AliMUONLocalTrigger* AliMUONDataInterface::LocalTrigger(Int_t trigger)
1050{
1051// Fetch the specified local trigger object from the current event.
1052// NULL is returned on error.
1053
1054 if (fRunloader == NULL)
1055 {
8c343c7c 1056 AliError("File not set.");
48b32e42 1057 return NULL;
925e6570 1058 }
48b32e42 1059 if (fEventnumber < 0)
1060 {
8c343c7c 1061 AliError( "Event not chosen.");
48b32e42 1062 return NULL;
925e6570 1063 }
48b32e42 1064
6d149c9e 1065 if ( ! FetchTreeD() ) return NULL;
48b32e42 1066 if ( ! fTriggerAddressSet )
1067 {
1068 fData.SetTreeAddress("GLT");
1069 fData.ResetTrigger();
6d149c9e 1070 fData.GetTriggerD();
48b32e42 1071 fTriggerAddressSet = kTRUE;
925e6570 1072 }
48b32e42 1073 return static_cast<AliMUONLocalTrigger*>( fData.LocalTrigger()->At(trigger) );
925e6570 1074}
554b38a6 1075
1076Int_t AliMUONDataInterface::NumberOfGlobalTriggers()
1077{
1078
1079 // Get the number of local trigger objects in the current event.
1080 // -1 is returned on error.
1081
1082 if (fRunloader == NULL)
1083 {
1084 AliError("File not set.");
1085 return -1;
1086 }
1087 if (fEventnumber < 0)
1088 {
1089 AliError("Event not chosen.");
1090 return -1;
1091 }
1092
1093 if ( ! FetchTreeD() ) return -1;
1094 if ( ! fTriggerAddressSet )
1095 {
1096 fData.SetTreeAddress("GLT");
1097 fData.ResetTrigger();
1098 fData.GetTriggerD();
1099 fTriggerAddressSet = kTRUE;
1100 }
1101 return fData.GlobalTrigger()->GetEntriesFast();
1102}
1103
1104AliMUONGlobalTrigger* AliMUONDataInterface::GlobalTrigger(Int_t trigger)
1105{
1106 // Fetch the specified local trigger object from the current event.
1107 // NULL is returned on error.
1108
1109 if (fRunloader == NULL)
1110 {
1111 AliError("File not set.");
1112 return NULL;
1113 }
1114 if (fEventnumber < 0)
1115 {
1116 AliError( "Event not chosen.");
1117 return NULL;
1118 }
1119
1120 if ( ! FetchTreeD() ) return NULL;
1121 if ( ! fTriggerAddressSet )
1122 {
1123 fData.SetTreeAddress("GLT");
1124 fData.ResetTrigger();
1125 fData.GetTriggerD();
1126 fTriggerAddressSet = kTRUE;
1127 }
1128 return static_cast<AliMUONGlobalTrigger*>( fData.GlobalTrigger()->At(trigger) );
1129}
1130
1131Int_t AliMUONDataInterface::NumberOfRecTracks()
1132{
1133 // Fetch the number of reconstructed tracks from the current event.
1134 // NULL is returned on error.
1135
1136 if (fRunloader == NULL)
1137 {
1138 AliError("File not set.");
1139 return -1;
1140 }
1141 if (fEventnumber < 0)
1142 {
1143 AliError( "Event not chosen.");
1144 return -1;
1145 }
1146
1147 if ( ! FetchTreeT() ) return -1;
1148 if ( ! fRecTracksAddressSet )
1149 {
1150 fData.SetTreeAddress("RT");
1151 fData.ResetRecTracks();
1152 fData.GetRecTracks();
1153 fRecTracksAddressSet = kTRUE;
1154 }
1155 return fData.RecTracks()->GetEntriesFast();
1156}
1157
1158AliMUONTrack* AliMUONDataInterface::RecTrack(Int_t rectrack)
1159{
1160 // Fetch the specified reconstructed track object from the current event.
1161 // NULL is returned on error.
1162
1163 if (fRunloader == NULL)
1164 {
1165 AliError("File not set.");
1166 return NULL;
1167 }
1168 if (fEventnumber < 0)
1169 {
1170 AliError( "Event not chosen.");
1171 return NULL;
1172 }
1173
1174 if ( ! FetchTreeT() ) return NULL;
1175 if ( ! fRecTracksAddressSet )
1176 {
1177 fData.SetTreeAddress("RT");
1178 fData.ResetRecTracks();
1179 fData.GetRecTracks();
1180 fRecTracksAddressSet = kTRUE;
1181 }
1182 return static_cast<AliMUONTrack*>( fData.RecTracks()->At(rectrack) );
1183 // return (AliMUONTrack*)(fData.RecTracks()->At(rectrack));
1184}