1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 //-----------------------------------------------------------------------------
19 /// \class AliMUONMCDataInterface
21 /// Easy to use MC data accessor
23 /// \author Laurent Aphecetche, Subatech
25 // Moved parts of old AliMUONDataInterface interface to AliMUONMCDataInterface
26 // Artur Szostak <artursz@iafrica.com> (University of Cape Town)
27 //-----------------------------------------------------------------------------
29 #include "AliMUONMCDataInterface.h"
30 #include "AliMUONVDigitStore.h"
31 #include "AliMUONVHitStore.h"
32 #include "AliMUONVTriggerStore.h"
33 #include "AliMUONHit.h"
34 #include "AliMUONVDigit.h"
35 #include "AliMUONLocalTrigger.h"
36 #include "AliMUONRegionalTrigger.h"
37 #include "AliMUONGlobalTrigger.h"
39 #include "AliMpIntPair.h"
40 #include "AliMpDEManager.h"
41 #include "AliMpConstants.h"
45 #include "AliRunLoader.h"
48 #include <Riostream.h>
49 #include <TClonesArray.h>
51 #include <TParticle.h>
52 #include <TIterator.h>
57 ClassImp(AliMUONMCDataInterface)
60 Int_t AliMUONMCDataInterface::fgInstanceCounter(0);
62 //_____________________________________________________________________________
63 AliMUONMCDataInterface::AliMUONMCDataInterface(const char* filename) :
73 fCurrentIteratorType(kNoIterator),
86 if ( ! AliMpCDB::LoadMpSegmentation() ) {
87 AliFatal("Could not access mapping from OCDB !");
91 //_____________________________________________________________________________
92 AliMUONMCDataInterface::~AliMUONMCDataInterface()
97 delete fLoader->GetRunLoader();
102 //_____________________________________________________________________________
104 AliMUONMCDataInterface::HitStore(Int_t event, Int_t track)
106 /// Return the hitStore for a given track of one event
107 /// Return 0x0 if event and/or track not found
108 /// Returned pointer should not be deleted
110 if (not IsValid()) return 0x0;
111 if (event == fCurrentEvent
112 and fDataX == track // using fDataX as track number.
118 if (not LoadEvent(event)) return 0x0;
122 TTree* treeH = fLoader->TreeH();
125 AliError("Could not get treeH");
129 fHitStore = AliMUONVHitStore::Create(*treeH);
130 AliDebug(1,"Creating hitStore from treeH");
131 if ( fHitStore != 0x0 )
133 fHitStore->Connect(*treeH);
134 if ( treeH->GetEvent(track) == 0 )
136 AliError(Form("Could not read track %d",track));
140 fDataX = track; // using fDataX as track number.
143 fLoader->UnloadHits();
148 //_____________________________________________________________________________
150 AliMUONMCDataInterface::SDigitStore(Int_t event)
152 /// Return the SDigit store for a given event.
153 /// Return 0 if event not found
154 /// Returned pointer should not be deleted
156 if (not IsValid()) return 0x0;
157 if (event == fCurrentEvent and fSDigitStore != 0x0) return fSDigitStore;
160 if (not LoadEvent(event)) return 0x0;
162 fLoader->LoadSDigits();
164 TTree* treeS = fLoader->TreeS();
167 AliError("Could not get treeS");
171 fSDigitStore = AliMUONVDigitStore::Create(*treeS);
172 if ( fSDigitStore != 0x0 )
174 fSDigitStore->Clear();
175 fSDigitStore->Connect(*treeS);
179 fLoader->UnloadSDigits();
184 //_____________________________________________________________________________
186 AliMUONMCDataInterface::DigitStore(Int_t event)
188 /// Return a pointer to the digitStore for a given event (or 0 if not found)
189 /// Returned pointer should not be deleted
191 if (not IsValid()) return 0x0;
192 if (event == fCurrentEvent and fDigitStore != 0x0) return fDigitStore;
195 if (not LoadEvent(event)) return 0x0;
197 fLoader->LoadDigits();
199 TTree* treeD = fLoader->TreeD();
202 AliError("Could not get treeD");
206 fDigitStore = AliMUONVDigitStore::Create(*treeD);
207 if ( fDigitStore != 0x0 )
209 fDigitStore->Clear();
210 fDigitStore->Connect(*treeD);
214 fLoader->UnloadDigits();
219 //_____________________________________________________________________________
221 AliMUONMCDataInterface::Stack(Int_t event)
223 /// Get the Stack (list of generated particles) for one event
224 /// Returned pointer should not be deleted
226 if ( not IsValid() ) return 0x0;
228 if (event != fCurrentEvent)
231 if ( not LoadEvent(event) ) return 0x0;
234 fLoader->GetRunLoader()->LoadKinematics();
236 return fLoader->GetRunLoader()->Stack();
239 //_____________________________________________________________________________
241 AliMUONMCDataInterface::TrackRefs(Int_t event, Int_t track)
243 /// Get the track references for a given (generated) track of one event
244 /// Returned pointer should not be deleted
246 if ( not IsValid() ) return 0x0;
248 if (event != fCurrentEvent)
251 if ( not LoadEvent(event) ) return 0x0;
254 if (track == fDataX) // using fDataX as track number.
257 fLoader->GetRunLoader()->LoadTrackRefs();
259 TTree* treeTR = fLoader->GetRunLoader()->TreeTR();
261 if ( fTrackRefs != 0x0 ) fTrackRefs->Clear("C");
265 if ( treeTR->GetEvent(track) > 0 )
267 TBranch* branch = treeTR->GetBranch("TrackReferences");
268 branch->SetAddress(&fTrackRefs);
269 branch->GetEvent(track);
270 fDataX = track; // using fDataX as track number.
275 AliError("Could not get TreeTR");
278 fLoader->GetRunLoader()->UnloadTrackRefs();
283 //_____________________________________________________________________________
284 AliMUONVTriggerStore*
285 AliMUONMCDataInterface::TriggerStore(Int_t event)
287 /// Return the triggerStore for a given event.
288 /// Return 0x0 if event not found.
289 /// Returned pointer should not be deleted.
291 if (not IsValid()) return 0x0;
292 if (event == fCurrentEvent and fTriggerStore != 0x0) return fTriggerStore;
295 if (not LoadEvent(event)) return 0x0;
297 fLoader->LoadDigits();
299 TTree* treeD = fLoader->TreeD();
302 AliError("Could not get treeD");
306 fTriggerStore = AliMUONVTriggerStore::Create(*treeD);
307 if ( fTriggerStore != 0x0 )
309 fTriggerStore->Clear();
310 fTriggerStore->Connect(*treeD);
314 fLoader->UnloadDigits();
316 return fTriggerStore;
319 //_____________________________________________________________________________
321 AliMUONMCDataInterface::DumpDigits(Int_t event, Bool_t sorted)
323 /// Dump the digits for a given event, sorted if requested.
326 if ( fDigitStore != 0x0 )
330 DumpSorted(*fDigitStore);
334 fDigitStore->Print();
339 //_____________________________________________________________________________
341 AliMUONMCDataInterface::DumpHits(Int_t event)
343 /// Dump all the hits for one event
345 Int_t ntracks = NumberOfTracks(event);
347 for ( Int_t i = 0; i < ntracks; ++i )
349 cout << ">> Track " << i << endl;
353 fHitStore->Print("","full");
358 //_____________________________________________________________________________
360 AliMUONMCDataInterface::DumpKine(Int_t event)
362 /// Dump all generated particles for one event
363 AliStack* stack = Stack(event);
367 Int_t nparticles = (Int_t) stack->GetNtrack();
369 for (Int_t iparticle=0; iparticle<nparticles; ++iparticle)
371 stack->Particle(iparticle)->Print("");
376 AliError("Could not get stack");
380 //_____________________________________________________________________________
382 AliMUONMCDataInterface::DumpSDigits(Int_t event, Bool_t sorted)
384 /// Dump the SDigits for a given event, sorted if requested
387 if ( fSDigitStore != 0x0 )
391 DumpSorted(*fSDigitStore);
395 fSDigitStore->Print();
400 //_____________________________________________________________________________
402 AliMUONMCDataInterface::DumpSorted(const AliMUONVStore& store) const
404 /// Dump the given store in sorted order
406 TIter next(store.CreateIterator());
409 list.SetOwner(kFALSE);
411 while ( ( object = next() ) )
421 //_____________________________________________________________________________
423 AliMUONMCDataInterface::DumpTrackRefs(Int_t event)
425 /// Dump track references for one event
426 Int_t ntrackrefs = NumberOfTrackRefs(event);
428 for ( Int_t i = 0; i < ntrackrefs; ++i )
431 if ( fTrackRefs != 0x0 )
433 fTrackRefs->Print("","*");
438 //_____________________________________________________________________________
440 AliMUONMCDataInterface::DumpTrigger(Int_t event)
442 /// Dump trigger for a given event (trigger is read from TreeD)
446 if ( fTriggerStore != 0x0 )
448 fTriggerStore->Print();
452 //_____________________________________________________________________________
454 AliMUONMCDataInterface::LoadEvent(Int_t event)
456 /// Load event if different from the current one.
457 /// Returns kFALSE on error and kTRUE if the event was loaded.
461 AliDebug(1,Form("Loading event %d using runLoader %p",event,fLoader->GetRunLoader()));
462 if (fLoader->GetRunLoader()->GetEvent(event) == 0)
464 fCurrentEvent = event;
472 //_____________________________________________________________________________
474 AliMUONMCDataInterface::NumberOfEvents() const
476 /// Number of events in the file we're connected to
477 if (not IsValid()) return -1;
478 return fLoader->GetRunLoader()->GetNumberOfEvents();
481 //_____________________________________________________________________________
483 AliMUONMCDataInterface::NumberOfTracks(Int_t event)
485 /// Number of tracks in the event
486 if ( not IsValid()) return -1;
488 if (event != fCurrentEvent)
491 if ( not LoadEvent(event) ) return -1;
498 TTree* treeH = fLoader->TreeH();
501 rv = static_cast<Int_t>(treeH->GetEntries());
505 AliError("Could not get TreeH");
508 fLoader->UnloadHits();
513 //_____________________________________________________________________________
515 AliMUONMCDataInterface::NumberOfTrackRefs(Int_t event)
517 /// Number of track references in the event
518 if ( not IsValid()) return -1;
520 if (event != fCurrentEvent)
523 if ( not LoadEvent(event) ) return -1;
526 fLoader->GetRunLoader()->LoadTrackRefs();
530 TTree* treeTR = fLoader->GetRunLoader()->TreeTR();
533 rv = static_cast<Int_t>(treeTR->GetEntries());
537 AliError("Could not get TreeTR");
540 fLoader->GetRunLoader()->UnloadTrackRefs();
545 //_____________________________________________________________________________
547 AliMUONMCDataInterface::Open(const char* filename)
549 /// Connect to a given galice.root file
555 if ( fLoader != 0x0 )
557 delete fLoader->GetRunLoader();
564 TString foldername(Form("%s-%d",ClassName(),fgInstanceCounter));
566 while (AliRunLoader::GetRunLoader(foldername))
568 delete AliRunLoader::GetRunLoader(foldername);
571 AliRunLoader* runLoader = AliRunLoader::Open(filename,foldername);
572 if (runLoader == 0x0)
574 AliError(Form("Cannot open file %s",filename));
577 fLoader = runLoader->GetDetectorLoader("MUON");
580 AliError("Cannot get AliMUONLoader");
586 AliError(Form("Could not access %s filename. Object is unuseable",filename));
590 //_____________________________________________________________________________
591 Bool_t AliMUONMCDataInterface::GetEvent(Int_t event)
593 /// Loads all simulated data for the given event.
595 if (HitStore(event, 0) == 0x0) return kFALSE;
596 if (SDigitStore(event) == 0x0) return kFALSE;
597 if (DigitStore(event) == 0x0) return kFALSE;
598 if (TriggerStore(event) == 0x0) return kFALSE;
599 if (TrackRefs(event, 0) == 0x0) return kFALSE;
603 //_____________________________________________________________________________
604 Int_t AliMUONMCDataInterface::NumberOfParticles()
606 /// Returns the total number of particles in the kinematics tree.
608 AliStack* stack = Stack(fCurrentEvent);
609 if ( stack == 0x0 ) return -1;
610 return (Int_t) stack->GetNtrack();
613 //_____________________________________________________________________________
614 TParticle* AliMUONMCDataInterface::Particle(Int_t index)
616 /// Returns the index'th particle in the kinematics tree.
617 /// @param index The index number of the particle in the range [0 ... N-1]
618 /// where N = NumberOfParticles()
620 AliStack* stack = Stack(fCurrentEvent);
621 if ( stack == 0x0 ) return 0x0;
622 return static_cast<TParticle*>( stack->Particle(index) );
625 //_____________________________________________________________________________
626 Int_t AliMUONMCDataInterface::NumberOfTracks()
628 /// Returns the number of primary tracks (from primary particles) in the current event.
630 return NumberOfTracks(fCurrentEvent);
633 //_____________________________________________________________________________
634 Int_t AliMUONMCDataInterface::NumberOfHits(Int_t track)
636 /// Returns the number of hits for a given primary track/particle.
637 /// @param track The track number in the range [0 .. N-1]
638 /// where N = NumberOfTracks()
640 TIterator* iter = GetIterator(kHitIterator, track);
641 return CountObjects(iter);
644 //_____________________________________________________________________________
646 AliMUONMCDataInterface::Hit(Int_t track, Int_t index)
648 /// Returns a pointer to the index'th hit object.
649 /// @param track The track number in the range [0 .. N-1]
650 /// where N = NumberOfTracks()
651 /// @param index The index number of the hit in the range [0 ... M-1]
652 /// where M = NumberOfHits(track)
654 TIterator* iter = GetIterator(kHitIterator, track);
655 return static_cast<AliMUONHit*>( FetchObject(iter, index) );
658 //_____________________________________________________________________________
659 Int_t AliMUONMCDataInterface::NumberOfSDigits(Int_t detElemId)
661 /// Returns the number of summable digits to be found on a given detector element.
662 /// @param detElemId The detector element ID number to search on.
664 TIterator* iter = GetIterator(kSDigitIteratorByDetectorElement, detElemId);
665 return CountObjects(iter);
668 //_____________________________________________________________________________
669 AliMUONVDigit* AliMUONMCDataInterface::SDigit(Int_t detElemId, Int_t index)
671 /// Returns the a pointer to the index'th summable digit on the specified detector element.
672 /// @param detElemId The detector element ID number to search on.
673 /// @param index The index number of the digit to fetch in the range [0 .. N-1],
674 /// where N = NumberOfDigits(detElemId)
676 TIterator* iter = GetIterator(kSDigitIteratorByDetectorElement, detElemId);
677 return static_cast<AliMUONVDigit*>( FetchObject(iter, index) );
680 //_____________________________________________________________________________
681 Int_t AliMUONMCDataInterface::NumberOfSDigits(Int_t chamber, Int_t cathode)
683 /// Returns the number of summable digits to be found on a specific chamber and cathode.
684 /// @param chamber The chamber number in the range [0 .. 13].
685 /// @param cathode The cathode in the range [0 .. 1], where 0 is the bending and
686 /// 1 is the non-bending plane.
688 TIterator* iter = GetIterator(kSDigitIteratorByChamberAndCathode, chamber, cathode);
689 return CountObjects(iter);
692 //_____________________________________________________________________________
693 AliMUONVDigit* AliMUONMCDataInterface::SDigit(Int_t chamber, Int_t cathode, Int_t index)
695 /// Returns the a pointer to the index'th summable digit on the specified chamber and cathode.
696 /// @param chamber The chamber number in the range [0 .. 13].
697 /// @param cathode The cathode in the range [0 .. 1], where 0 is the bending and
698 /// 1 is the non-bending plane.
699 /// @param index The index number of the digit to fetch in the range [0 .. N-1],
700 /// where N = NumberOfDigits(chamber, cathode)
702 TIterator* iter = GetIterator(kSDigitIteratorByChamberAndCathode, chamber, cathode);
703 return static_cast<AliMUONVDigit*>( FetchObject(iter, index) );
706 //_____________________________________________________________________________
707 Int_t AliMUONMCDataInterface::NumberOfDigits(Int_t detElemId)
709 /// Returns the number of simulated digits to be found on a given detector element.
710 /// @param detElemId The detector element ID number to search on.
712 TIterator* iter = GetIterator(kDigitIteratorByDetectorElement, detElemId);
713 return CountObjects(iter);
716 //_____________________________________________________________________________
717 AliMUONVDigit* AliMUONMCDataInterface::Digit(Int_t detElemId, Int_t index)
719 /// Returns the a pointer to the index'th simulated digit on the specified detector element.
720 /// @param detElemId The detector element ID number to search on.
721 /// @param index The index number of the digit to fetch in the range [0 .. N-1],
722 /// where N = NumberOfDigits(detElemId)
724 TIterator* iter = GetIterator(kDigitIteratorByDetectorElement, detElemId);
725 return static_cast<AliMUONVDigit*>( FetchObject(iter, index) );
728 //_____________________________________________________________________________
729 Int_t AliMUONMCDataInterface::NumberOfDigits(Int_t chamber, Int_t cathode)
731 /// Returns the number of simulated digits to be found on a specific chamber and cathode.
732 /// @param chamber The chamber number in the range [0 .. 13].
733 /// @param cathode The cathode in the range [0 .. 1], where 0 is the bending and
734 /// 1 is the non-bending plane.
736 TIterator* iter = GetIterator(kDigitIteratorByChamberAndCathode, chamber, cathode);
737 return CountObjects(iter);
740 //_____________________________________________________________________________
741 AliMUONVDigit* AliMUONMCDataInterface::Digit(Int_t chamber, Int_t cathode, Int_t index)
743 /// Returns the a pointer to the index'th simulated digit on the specified chamber and cathode.
744 /// @param chamber The chamber number in the range [0 .. 13].
745 /// @param cathode The cathode in the range [0 .. 1], where 0 is the bending and
746 /// 1 is the non-bending plane.
747 /// @param index The index number of the digit to fetch in the range [0 .. N-1],
748 /// where N = NumberOfDigits(chamber, cathode)
750 TIterator* iter = GetIterator(kDigitIteratorByChamberAndCathode, chamber, cathode);
751 return static_cast<AliMUONVDigit*>( FetchObject(iter, index) );
754 //_____________________________________________________________________________
755 Int_t AliMUONMCDataInterface::NumberOfLocalTriggers()
757 /// Returns the number of simulated local trigger objects.
759 TIterator* iter = GetIterator(kLocalTriggerIterator);
760 return CountObjects(iter);
763 //_____________________________________________________________________________
764 AliMUONLocalTrigger* AliMUONMCDataInterface::LocalTrigger(Int_t index)
766 /// Returns a pointer to the index'th simulated local trigger object.
767 /// @param index The index number of the local trigger object to fetch in the range [0 .. N-1],
768 /// where N = NumberOfLocalTriggers()
770 TIterator* iter = GetIterator(kLocalTriggerIterator);
771 return static_cast<AliMUONLocalTrigger*>( FetchObject(iter, index) );
774 //_____________________________________________________________________________
775 Int_t AliMUONMCDataInterface::NumberOfRegionalTriggers()
777 /// Returns the number of simulated regional trigger objects.
779 TIterator* iter = GetIterator(kRegionalTriggerIterator);
780 return CountObjects(iter);
783 //_____________________________________________________________________________
784 AliMUONRegionalTrigger* AliMUONMCDataInterface::RegionalTrigger(Int_t index)
786 /// Returns a pointer to the index'th simulated regional trigger object.
787 /// @param index The index number of the regional trigger object to fetch in the range [0 .. N-1],
788 /// where N = NumberOfRegionalTriggers()
790 TIterator* iter = GetIterator(kRegionalTriggerIterator);
791 return static_cast<AliMUONRegionalTrigger*>( FetchObject(iter, index) );
794 //_____________________________________________________________________________
795 AliMUONGlobalTrigger* AliMUONMCDataInterface::GlobalTrigger()
797 /// Returns a pointer to the simulated global trigger object for the event.
799 AliMUONVTriggerStore* store = TriggerStore(fCurrentEvent);
800 if (store == 0x0) return 0x0;
801 return store->Global();
804 //_____________________________________________________________________________
805 Int_t AliMUONMCDataInterface::NumberOfTrackRefs()
807 /// Number of track references in the currently selected event.
809 return NumberOfTrackRefs(fCurrentEvent);
812 //_____________________________________________________________________________
813 TClonesArray* AliMUONMCDataInterface::TrackRefs(Int_t track)
815 /// Returns the track references for a given track in the current event.
816 /// @param track The track to returns track references for. In the range [0 .. N-1]
817 /// where N = NumberOfTrackRefs()
819 return TrackRefs(fCurrentEvent, track);
822 //_____________________________________________________________________________
823 void AliMUONMCDataInterface::ResetStores()
825 /// Deletes all the store objects that have been created and resets the pointers to 0x0.
826 /// The temporary iterator object is automatically reset. See ResetIterator for more details.
829 if (fHitStore != 0x0)
834 if (fSDigitStore != 0x0)
839 if (fDigitStore != 0x0)
844 if (fTrackRefs != 0x0)
849 if (fTriggerStore != 0x0)
851 delete fTriggerStore;
856 //_____________________________________________________________________________
857 TIterator* AliMUONMCDataInterface::GetIterator(IteratorType type, Int_t x, Int_t y)
859 /// Creates an appropriate iterator object and returns it.
860 /// If the iterator has already been created then that one is returned otherwise
861 /// a new object is created.
862 /// Depending on the value of 'type' the semantics of parameters x and y can change.
863 /// @param type The type of iterator to create.
864 /// @param x This is the detector element ID if type equals kDigitIteratorByDetectorElement
865 /// or kSDigitIteratorByDetectorElement.
866 /// If type equals kDigitIteratorByChamberAndCathode or
867 /// kSDigitIteratorByChamberAndCathode then this is the chamber number.
868 /// For type == kHitIterator the parameter x is the track number.
869 /// In all other cases this parameter is ignored.
870 /// @param y If type equals kDigitIteratorByChamberAndCathode or
871 /// kSDigitIteratorByChamberAndCathode then this parameter is the cathode
872 /// number. In all other cases this parameter is ignored.
874 if (type == fCurrentIteratorType and fDataX == x and fDataY == y)
877 if (fCurrentEvent == -1)
879 AliError("No event was selected. Try first using GetEvent().");
890 AliMUONVHitStore* store = HitStore(fCurrentEvent, track);
891 if (store == 0x0) return 0x0;
892 fIterator = store->CreateIterator();
893 if (fIterator == 0x0) return 0x0;
894 fCurrentIteratorType = kHitIterator;
898 case kSDigitIteratorByDetectorElement:
901 AliMUONVDigitStore* store = SDigitStore(fCurrentEvent);
902 if (store == 0x0) return 0x0;
903 fIterator = store->CreateIterator(detElem, detElem, 2);
904 if (fIterator == 0x0) return 0x0;
905 fCurrentIteratorType = kSDigitIteratorByDetectorElement;
910 case kSDigitIteratorByChamberAndCathode:
914 if (chamber < 0 or AliMpConstants::NofChambers() <= chamber)
917 "Must have give a chamber value in the range [0..%d], but got a value of: %d",
918 AliMpConstants::NofChambers() - 1,
923 if (cathode < 0 or 1 < cathode)
925 AliError(Form("Must have give a cathode value in the range [0..1], but got a value of: %d", cathode));
929 AliMUONVDigitStore* store = SDigitStore(fCurrentEvent);
930 if (store == 0x0) return 0x0;
931 AliMpIntPair pair = AliMpDEManager::GetDetElemIdRange(chamber);
932 fIterator = store->CreateIterator(pair.GetFirst(), pair.GetSecond(), cathode);
933 if (fIterator == 0x0) return 0x0;
934 fCurrentIteratorType = kSDigitIteratorByChamberAndCathode;
940 case kDigitIteratorByDetectorElement:
943 AliMUONVDigitStore* store = DigitStore(fCurrentEvent);
944 if (store == 0x0) return 0x0;
945 fIterator = store->CreateIterator(detElem, detElem, 2);
946 if (fIterator == 0x0) return 0x0;
947 fCurrentIteratorType = kDigitIteratorByDetectorElement;
952 case kDigitIteratorByChamberAndCathode:
956 if (chamber < 0 or AliMpConstants::NofChambers() <= chamber)
959 "Must have give a chamber value in the range [0..%d], but got a value of: %d",
960 AliMpConstants::NofChambers() - 1,
965 if (cathode < 0 or 1 < cathode)
967 AliError(Form("Must have give a cathode value in the range [0..1], but got a value of: %d", cathode));
971 AliMUONVDigitStore* store = DigitStore(fCurrentEvent);
972 if (store == 0x0) return 0x0;
973 AliMpIntPair pair = AliMpDEManager::GetDetElemIdRange(chamber);
974 fIterator = store->CreateIterator(pair.GetFirst(), pair.GetSecond(), cathode);
975 if (fIterator == 0x0) return 0x0;
976 fCurrentIteratorType = kDigitIteratorByChamberAndCathode;
982 case kLocalTriggerIterator:
984 AliMUONVTriggerStore* store = TriggerStore(fCurrentEvent);
985 if (store == 0x0) return 0x0;
986 fIterator = store->CreateLocalIterator();
987 if (fIterator == 0x0) return 0x0;
988 fCurrentIteratorType = kLocalTriggerIterator;
992 case kRegionalTriggerIterator:
994 AliMUONVTriggerStore* store = TriggerStore(fCurrentEvent);
995 if (store == 0x0) return 0x0;
996 fIterator = store->CreateRegionalIterator();
997 if (fIterator == 0x0) return 0x0;
998 fCurrentIteratorType = kRegionalTriggerIterator;
1007 //_____________________________________________________________________________
1008 void AliMUONMCDataInterface::ResetIterator()
1010 /// The temporary iterator object is deleted if it exists and the pointer reset to 0x0.
1011 /// The iterator type and temporary data indicating the state of the iterator are
1014 if (fIterator != 0x0) delete fIterator;
1015 fCurrentIteratorType = kNoIterator;
1016 fCurrentIndex = fDataX = fDataY = -1;
1020 //_____________________________________________________________________________
1021 Int_t AliMUONMCDataInterface::CountObjects(TIterator* iter)
1023 /// Counts the number of objects in the iterator and resets it.
1024 /// @return The number of objects in 'iter'.
1026 if (iter == 0x0) return -1;
1029 while ( iter->Next() != 0x0 ) count++;
1035 //_____________________________________________________________________________
1036 TObject* AliMUONMCDataInterface::FetchObject(TIterator* iter, Int_t index)
1038 /// Fetches the index'th object from the iterator counting the first object
1039 /// returned by iterator after it is reset as index == 0. The next object
1040 /// has index == 1 and so on where the last object returned by the iterator
1041 /// has index == N-1 where N = CountObjects(iter)
1042 /// This method will only reset the iterator if index is smaller than
1043 /// fCurrentIndex, which is used to track the iteration progress and is
1044 /// updated when a new object if returned by this method.
1045 /// @param iter The iterator to fetch an object from.
1046 /// @param index The index number of the object to fetch in the range [0 .. N-1]
1047 /// where N = CountObjects(iter)
1051 AliError(Form("Index is out of bounds. Got a value of %d.", index));
1055 if (iter == 0x0) return 0x0;
1056 if (index <= fCurrentIndex)
1062 TObject* object = 0x0;
1063 while (fCurrentIndex < index)
1065 object = iter->Next();
1068 AliError(Form("Index is out of bounds. Got a value of %d.", index));