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