+/// Loads all simulated data for the given event.
+
+ if (HitStore(event, 0) == 0x0) return kFALSE;
+ if (SDigitStore(event) == 0x0) return kFALSE;
+ if (DigitStore(event) == 0x0) return kFALSE;
+ if (TriggerStore(event) == 0x0) return kFALSE;
+ if (TrackRefs(event, 0) == 0x0) return kFALSE;
+ return kTRUE;
+}
+
+//_____________________________________________________________________________
+Int_t AliMUONMCDataInterface::NumberOfParticles()
+{
+/// Returns the total number of particles in the kinematics tree.
+
+ AliStack* stack = Stack(fCurrentEvent);
+ if ( stack == 0x0 ) return -1;
+ return (Int_t) stack->GetNtrack();
+}
+
+//_____________________________________________________________________________
+TParticle* AliMUONMCDataInterface::Particle(Int_t index)
+{
+/// Returns the index'th particle in the kinematics tree.
+/// @param index The index number of the particle in the range [0 ... N-1]
+/// where N = NumberOfParticles()
+
+ AliStack* stack = Stack(fCurrentEvent);
+ if ( stack == 0x0 ) return 0x0;
+ return static_cast<TParticle*>( stack->Particle(index) );
+}
+
+//_____________________________________________________________________________
+Int_t AliMUONMCDataInterface::NumberOfTracks()
+{
+/// Returns the number of primary tracks (from primary particles) in the current event.
+
+ return NumberOfTracks(fCurrentEvent);
+}
+
+//_____________________________________________________________________________
+Int_t AliMUONMCDataInterface::NumberOfHits(Int_t track)
+{
+/// Returns the number of hits for a given primary track/particle.
+/// @param track The track number in the range [0 .. N-1]
+/// where N = NumberOfTracks()
+
+ TIterator* iter = GetIterator(kHitIterator, track);
+ return CountObjects(iter);
+}
+
+//_____________________________________________________________________________
+AliMUONHit*
+AliMUONMCDataInterface::Hit(Int_t track, Int_t index)
+{
+/// Returns a pointer to the index'th hit object.
+/// @param track The track number in the range [0 .. N-1]
+/// where N = NumberOfTracks()
+/// @param index The index number of the hit in the range [0 ... M-1]
+/// where M = NumberOfHits(track)
+
+ TIterator* iter = GetIterator(kHitIterator, track);
+ return static_cast<AliMUONHit*>( FetchObject(iter, index) );
+}
+
+//_____________________________________________________________________________
+Int_t AliMUONMCDataInterface::NumberOfSDigits(Int_t detElemId)
+{
+/// Returns the number of summable digits to be found on a given detector element.
+/// @param detElemId The detector element ID number to search on.
+
+ TIterator* iter = GetIterator(kSDigitIteratorByDetectorElement, detElemId);
+ return CountObjects(iter);
+}
+
+//_____________________________________________________________________________
+AliMUONVDigit* AliMUONMCDataInterface::SDigit(Int_t detElemId, Int_t index)
+{
+/// Returns the a pointer to the index'th summable digit on the specified detector element.
+/// @param detElemId The detector element ID number to search on.
+/// @param index The index number of the digit to fetch in the range [0 .. N-1],
+/// where N = NumberOfDigits(detElemId)
+
+ TIterator* iter = GetIterator(kSDigitIteratorByDetectorElement, detElemId);
+ return static_cast<AliMUONVDigit*>( FetchObject(iter, index) );
+}
+
+//_____________________________________________________________________________
+Int_t AliMUONMCDataInterface::NumberOfSDigits(Int_t chamber, Int_t cathode)
+{
+/// Returns the number of summable digits to be found on a specific chamber and cathode.
+/// @param chamber The chamber number in the range [0 .. 13].
+/// @param cathode The cathode in the range [0 .. 1], where 0 is the bending and
+/// 1 is the non-bending plane.
+
+ TIterator* iter = GetIterator(kSDigitIteratorByChamberAndCathode, chamber, cathode);
+ return CountObjects(iter);
+}
+
+//_____________________________________________________________________________
+AliMUONVDigit* AliMUONMCDataInterface::SDigit(Int_t chamber, Int_t cathode, Int_t index)
+{
+/// Returns the a pointer to the index'th summable digit on the specified chamber and cathode.
+/// @param chamber The chamber number in the range [0 .. 13].
+/// @param cathode The cathode in the range [0 .. 1], where 0 is the bending and
+/// 1 is the non-bending plane.
+/// @param index The index number of the digit to fetch in the range [0 .. N-1],
+/// where N = NumberOfDigits(chamber, cathode)
+
+ TIterator* iter = GetIterator(kSDigitIteratorByChamberAndCathode, chamber, cathode);
+ return static_cast<AliMUONVDigit*>( FetchObject(iter, index) );
+}
+
+//_____________________________________________________________________________
+Int_t AliMUONMCDataInterface::NumberOfDigits(Int_t detElemId)
+{
+/// Returns the number of simulated digits to be found on a given detector element.
+/// @param detElemId The detector element ID number to search on.
+
+ TIterator* iter = GetIterator(kDigitIteratorByDetectorElement, detElemId);
+ return CountObjects(iter);
+}
+
+//_____________________________________________________________________________
+AliMUONVDigit* AliMUONMCDataInterface::Digit(Int_t detElemId, Int_t index)
+{
+/// Returns the a pointer to the index'th simulated digit on the specified detector element.
+/// @param detElemId The detector element ID number to search on.
+/// @param index The index number of the digit to fetch in the range [0 .. N-1],
+/// where N = NumberOfDigits(detElemId)
+
+ TIterator* iter = GetIterator(kDigitIteratorByDetectorElement, detElemId);
+ return static_cast<AliMUONVDigit*>( FetchObject(iter, index) );
+}
+
+//_____________________________________________________________________________
+Int_t AliMUONMCDataInterface::NumberOfDigits(Int_t chamber, Int_t cathode)
+{
+/// Returns the number of simulated digits to be found on a specific chamber and cathode.
+/// @param chamber The chamber number in the range [0 .. 13].
+/// @param cathode The cathode in the range [0 .. 1], where 0 is the bending and
+/// 1 is the non-bending plane.
+
+ TIterator* iter = GetIterator(kDigitIteratorByChamberAndCathode, chamber, cathode);
+ return CountObjects(iter);
+}
+
+//_____________________________________________________________________________
+AliMUONVDigit* AliMUONMCDataInterface::Digit(Int_t chamber, Int_t cathode, Int_t index)
+{
+/// Returns the a pointer to the index'th simulated digit on the specified chamber and cathode.
+/// @param chamber The chamber number in the range [0 .. 13].
+/// @param cathode The cathode in the range [0 .. 1], where 0 is the bending and
+/// 1 is the non-bending plane.
+/// @param index The index number of the digit to fetch in the range [0 .. N-1],
+/// where N = NumberOfDigits(chamber, cathode)
+
+ TIterator* iter = GetIterator(kDigitIteratorByChamberAndCathode, chamber, cathode);
+ return static_cast<AliMUONVDigit*>( FetchObject(iter, index) );
+}
+
+//_____________________________________________________________________________
+Int_t AliMUONMCDataInterface::NumberOfLocalTriggers()
+{
+/// Returns the number of simulated local trigger objects.
+
+ TIterator* iter = GetIterator(kLocalTriggerIterator);
+ return CountObjects(iter);
+}
+
+//_____________________________________________________________________________
+AliMUONLocalTrigger* AliMUONMCDataInterface::LocalTrigger(Int_t index)
+{
+/// Returns a pointer to the index'th simulated local trigger object.
+/// @param index The index number of the local trigger object to fetch in the range [0 .. N-1],
+/// where N = NumberOfLocalTriggers()
+
+ TIterator* iter = GetIterator(kLocalTriggerIterator);
+ return static_cast<AliMUONLocalTrigger*>( FetchObject(iter, index) );
+}
+
+//_____________________________________________________________________________
+Int_t AliMUONMCDataInterface::NumberOfRegionalTriggers()
+{
+/// Returns the number of simulated regional trigger objects.
+
+ TIterator* iter = GetIterator(kRegionalTriggerIterator);
+ return CountObjects(iter);
+}
+
+//_____________________________________________________________________________
+AliMUONRegionalTrigger* AliMUONMCDataInterface::RegionalTrigger(Int_t index)
+{
+/// Returns a pointer to the index'th simulated regional trigger object.
+/// @param index The index number of the regional trigger object to fetch in the range [0 .. N-1],
+/// where N = NumberOfRegionalTriggers()
+
+ TIterator* iter = GetIterator(kRegionalTriggerIterator);
+ return static_cast<AliMUONRegionalTrigger*>( FetchObject(iter, index) );
+}
+
+//_____________________________________________________________________________
+AliMUONGlobalTrigger* AliMUONMCDataInterface::GlobalTrigger()
+{
+/// Returns a pointer to the simulated global trigger object for the event.
+
+ AliMUONVTriggerStore* store = TriggerStore(fCurrentEvent);
+ if (store == 0x0) return 0x0;
+ return store->Global();
+}
+
+//_____________________________________________________________________________
+Int_t AliMUONMCDataInterface::NumberOfTrackRefs()
+{
+/// Number of track references in the currently selected event.
+
+ return NumberOfTrackRefs(fCurrentEvent);
+}
+
+//_____________________________________________________________________________
+TClonesArray* AliMUONMCDataInterface::TrackRefs(Int_t track)
+{
+/// Returns the track references for a given track in the current event.
+/// @param track The track to returns track references for. In the range [0 .. N-1]
+/// where N = NumberOfTrackRefs()
+
+ return TrackRefs(fCurrentEvent, track);
+}
+
+//_____________________________________________________________________________
+void AliMUONMCDataInterface::ResetStores()
+{
+/// Deletes all the store objects that have been created and resets the pointers to 0x0.
+/// The temporary iterator object is automatically reset. See ResetIterator for more details.
+
+ ResetIterator();
+ if (fHitStore != 0x0)
+ {
+ delete fHitStore;
+ fHitStore = 0x0;
+ }
+ if (fSDigitStore != 0x0)
+ {
+ delete fSDigitStore;
+ fSDigitStore = 0x0;
+ }
+ if (fDigitStore != 0x0)
+ {
+ delete fDigitStore;
+ fDigitStore = 0x0;
+ }
+ if (fTrackRefs != 0x0)
+ {
+ delete fTrackRefs;
+ fTrackRefs = 0x0;
+ }
+ if (fTriggerStore != 0x0)
+ {
+ delete fTriggerStore;
+ fTriggerStore = 0x0;
+ }
+}
+
+//_____________________________________________________________________________
+TIterator* AliMUONMCDataInterface::GetIterator(IteratorType type, Int_t x, Int_t y)
+{
+/// Creates an appropriate iterator object and returns it.
+/// If the iterator has already been created then that one is returned otherwise
+/// a new object is created.
+/// Depending on the value of 'type' the semantics of parameters x and y can change.
+/// @param type The type of iterator to create.
+/// @param x This is the detector element ID if type equals kDigitIteratorByDetectorElement
+/// or kSDigitIteratorByDetectorElement.
+/// If type equals kDigitIteratorByChamberAndCathode or
+/// kSDigitIteratorByChamberAndCathode then this is the chamber number.
+/// For type == kHitIterator the parameter x is the track number.
+/// In all other cases this parameter is ignored.
+/// @param y If type equals kDigitIteratorByChamberAndCathode or
+/// kSDigitIteratorByChamberAndCathode then this parameter is the cathode
+/// number. In all other cases this parameter is ignored.
+
+ if (type == fCurrentIteratorType and fDataX == x and fDataY == y)
+ return fIterator;