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 #include "AliMUONDataInterface.h"
19 #include "AliMUONGeometryTransformer.h"
20 #include "AliMUONVDigit.h"
21 #include "AliMUONVCluster.h"
22 #include "AliMUONTrack.h"
23 #include "AliMUONLocalTrigger.h"
24 #include "AliMUONRegionalTrigger.h"
25 #include "AliMUONGlobalTrigger.h"
26 #include "AliMUONTriggerTrack.h"
27 #include "AliMUONTriggerCircuit.h"
28 #include "AliMUONVClusterStore.h"
29 #include "AliMUONVDigitStore.h"
30 #include "AliMUONVTrackStore.h"
31 #include "AliMUONVTriggerStore.h"
32 #include "AliMUONVTriggerTrackStore.h"
35 #include "AliMpIntPair.h"
36 #include "AliMpDEManager.h"
37 #include "AliMpConstants.h"
40 #include "AliLoader.h"
42 #include "AliRunLoader.h"
45 #include <TParticle.h>
46 #include <Riostream.h>
51 #include <TIterator.h>
55 //-----------------------------------------------------------------------------
56 /// \class AliMUONDataInterface
58 /// An easy to use interface to the MUON data data stored in
59 /// TreeS, TreeD, TreeR and TreeT.
61 /// For MC related information (i.e. TreeH, TreeK, TreeTR), see
62 /// AliMUONMCDataInterface.
65 /// This interface in not necessarily the fastest way to fetch the data but
66 /// it is the easiest.
68 /// \author Laurent Aphecetche, Subatech & Artur Szostak <artursz@iafrica.com> (University of Cape Town)
69 //-----------------------------------------------------------------------------
72 ClassImp(AliMUONDataInterface)
76 Int_t AliMUONDataInterface::fgInstanceCounter(0);
78 //______________________________________________________________________________
79 AliMUONDataInterface::AliMUONDataInterface(const char* filename)
86 fTriggerTrackStore(0x0),
89 fCurrentIteratorType(kNoIterator),
96 /// @param filename should be the full path to a valid galice.root file
103 if ( ! AliMpCDB::LoadDDLStore() ) {
104 AliFatal("Could not access mapping from OCDB !");
108 //______________________________________________________________________________
109 AliMUONDataInterface::~AliMUONDataInterface()
113 if ( fLoader != 0x0 )
115 delete fLoader->GetRunLoader();
120 //______________________________________________________________________________
122 AliMUONDataInterface::DigitStore(Int_t event)
124 /// Return digitStore for a given event.
125 /// Return 0x0 if event not found.
126 /// Returned pointer should not be deleted
128 if (not IsValid()) return 0x0;
129 if (event == fCurrentEvent and fDigitStore != 0x0) return fDigitStore;
132 if (not LoadEvent(event)) return 0x0;
134 fLoader->LoadDigits();
136 TTree* treeD = fLoader->TreeD();
139 AliError("Could not get treeD");
143 fDigitStore = AliMUONVDigitStore::Create(*treeD);
144 if ( fDigitStore != 0x0 )
146 fDigitStore->Clear();
147 fDigitStore->Connect(*treeD);
151 fLoader->UnloadDigits();
156 //______________________________________________________________________________
157 AliMUONVClusterStore*
158 AliMUONDataInterface::ClusterStore(Int_t event)
160 /// Return clusterStore for a given event.
161 /// Return 0x0 if event not found.
162 /// Returned pointer should not be deleted
164 if (not IsValid()) return 0x0;
165 if (event == fCurrentEvent and fClusterStore != 0x0) return fClusterStore;
168 if (not LoadEvent(event)) return 0x0;
170 fLoader->LoadRecPoints();
172 TTree* treeR = fLoader->TreeR();
175 AliError("Could not get treeR");
179 fClusterStore = AliMUONVClusterStore::Create(*treeR);
180 if ( fClusterStore != 0x0 )
182 fClusterStore->Clear();
183 fClusterStore->Connect(*treeR);
187 fLoader->UnloadRecPoints();
189 return fClusterStore;
192 //______________________________________________________________________________
194 AliMUONDataInterface::TrackStore(Int_t event)
196 /// Return the trackStore for a given event.
197 /// Return 0x0 if event not found.
198 /// Returned pointer should not be deleted
200 if (not IsValid()) return 0x0;
201 if (event == fCurrentEvent and fTrackStore != 0x0) return fTrackStore;
204 if (not LoadEvent(event)) return 0x0;
206 fLoader->LoadTracks();
208 TTree* treeT = fLoader->TreeT();
211 AliError("Could not get treeT");
215 fTrackStore = AliMUONVTrackStore::Create(*treeT);
216 if ( fTrackStore != 0x0 )
218 fTrackStore->Clear();
219 fTrackStore->Connect(*treeT);
223 fLoader->UnloadTracks();
228 //______________________________________________________________________________
229 AliMUONVTriggerTrackStore*
230 AliMUONDataInterface::TriggerTrackStore(Int_t event)
232 /// Return the triggerTrackStore for a given event.
233 /// Return 0x0 if event not found.
234 /// Returned pointer should not be deleted
236 if (not IsValid()) return 0x0;
237 if (event == fCurrentEvent and fTriggerTrackStore != 0x0) return fTriggerTrackStore;
240 if (not LoadEvent(event)) return 0x0;
242 fLoader->LoadTracks();
244 TTree* treeT = fLoader->TreeT();
247 AliError("Could not get treeT");
251 fTriggerTrackStore = AliMUONVTriggerTrackStore::Create(*treeT);
252 if ( fTriggerTrackStore != 0x0 )
254 fTriggerTrackStore->Clear();
255 fTriggerTrackStore->Connect(*treeT);
259 fLoader->UnloadTracks();
261 return fTriggerTrackStore;
264 //_____________________________________________________________________________
265 AliMUONVTriggerStore*
266 AliMUONDataInterface::TriggerStore(Int_t event, const char* treeLetter)
268 /// Return the triggerStore for a given event.
269 /// Return 0x0 if event not found.
270 /// Returned pointer should not be deleted
271 /// treeLetter can be R or D to tell from which tree to read the information
273 if (not IsValid()) return 0x0;
274 if (event == fCurrentEvent and fTriggerStore != 0x0) return fTriggerStore;
277 if (not LoadEvent(event)) return 0x0;
281 TString stree(treeLetter);
286 fLoader->LoadDigits();
287 tree = fLoader->TreeD();
289 else if ( stree == "R" )
291 fLoader->LoadRecPoints();
292 tree = fLoader->TreeR();
297 AliError(Form("Could not get tree%s",treeLetter));
301 fTriggerStore = AliMUONVTriggerStore::Create(*tree);
302 if ( fTriggerStore != 0x0 )
304 fTriggerStore->Clear();
305 fTriggerStore->Connect(*tree);
311 fLoader->UnloadDigits();
313 else if ( stree == "R" )
315 fLoader->UnloadRecPoints();
318 return fTriggerStore;
321 //______________________________________________________________________________
323 AliMUONDataInterface::DumpDigits(Int_t event, Bool_t sorted)
325 /// Dump the digits for a given event, sorted if so required
327 if ( fDigitStore != 0x0 )
331 DumpSorted(*fDigitStore);
335 fDigitStore->Print();
340 //______________________________________________________________________________
342 AliMUONDataInterface::DumpRecPoints(Int_t event, Bool_t sorted)
344 /// Dump the recpoints for a given event, sorted if so required
346 if ( fClusterStore != 0x0 )
350 DumpSorted(*fClusterStore);
354 fClusterStore->Print();
359 //_____________________________________________________________________________
361 AliMUONDataInterface::DumpSorted(const AliMUONVStore& store) const
363 /// Dump the given store, in sorted order
365 TIter next(store.CreateIterator());
368 list.SetOwner(kFALSE);
370 while ( ( object = next() ) )
380 //______________________________________________________________________________
382 AliMUONDataInterface::DumpTracks(Int_t event, Bool_t sorted)
384 /// Dump tracks for a given event, sorted if requested
388 if ( fTrackStore != 0x0 )
392 DumpSorted(*fTrackStore);
396 fTrackStore->Print();
401 //______________________________________________________________________________
403 AliMUONDataInterface::DumpTriggerTracks(Int_t event, Bool_t sorted)
405 /// Dump trigger tracks for a given event, sorted if requested
407 TriggerTrackStore(event);
409 if ( fTriggerTrackStore != 0x0 )
413 DumpSorted(*fTriggerTrackStore);
417 fTriggerTrackStore->Print();
422 //_____________________________________________________________________________
424 AliMUONDataInterface::DumpTrigger(Int_t event, const char* treeLetter)
426 /// Dump trigger for a given event from a given tree (if event>=0)
427 /// or loop over all events and build a trigger ntuple if event<0
428 /// treeLetter can be R or D to tell from which tree to read the information
432 NtupleTrigger(treeLetter);
436 TriggerStore(event,treeLetter);
438 if ( fTriggerStore != 0x0 )
440 fTriggerStore->Print();
445 //_____________________________________________________________________________
447 AliMUONDataInterface::NtupleTrigger(const char* treeLetter)
449 //// Loop over events to build trigger ntuples
452 TString sTreeLetter(treeLetter);
453 sTreeLetter.ToUpper();
455 if ( sTreeLetter != "R" && sTreeLetter != "D" )
457 AliError(Form("Cannot handle tree%s. Use D or R",treeLetter));
462 TNtuple tupleGlo("TgtupleGlo","Global Trigger Ntuple",
463 "ev:slpt:shpt:uplpt:uphpt:lplpt:lplpt");
464 TNtuple tupleLoc("TgtupleLoc","Local Trigger Ntuple",
465 "ev:LoCircuit:LoStripX:LoDev:StripY:LoLpt:LoHpt:y11:y21:x11");
467 // initialize counters
475 AliMUONGeometryTransformer transformer;
476 transformer.LoadGeometryData(Form("%s/geometry.root",
477 gSystem->DirName(fLoader->GetRunLoader()->GetFileName())));
478 AliMUONTriggerCircuit triggerCircuit(&transformer);
480 // select output file name from selected Tree
481 Char_t fileNameOut[30];
482 if (sTreeLetter == "D")
484 AliInfo(Form("reading from Digits\n"));
485 sprintf(fileNameOut,"TriggerCheckFromDigits.root");
487 else if (sTreeLetter == "R")
489 AliInfo(Form("reading from RecPoints\n"));
490 sprintf(fileNameOut,"TriggerCheckFromRP.root");
494 Int_t nevents = NumberOfEvents();
496 for (Int_t ievent=0; ievent<nevents; ++ievent)
498 if (ievent%100==0) AliInfo(Form("Processing event %d\n",ievent));
500 AliMUONVTriggerStore* triggerStore = TriggerStore(ievent);
504 AliError(Form("Could not read %s from tree%s","Trigger",treeLetter));
508 // get global trigger info
509 AliMUONGlobalTrigger* gloTrg = triggerStore->Global();
510 sLowpt+=gloTrg->SingleLpt();
511 sHighpt+=gloTrg->SingleHpt();
512 uSLowpt+=gloTrg->PairUnlikeLpt();
513 uSHighpt+=gloTrg->PairUnlikeHpt();
514 lSLowpt+=gloTrg->PairLikeLpt();
515 lSHighpt+=gloTrg->PairLikeHpt();
517 // loop on local triggers
518 TIter next(triggerStore->CreateIterator());
519 AliMUONLocalTrigger* locTrg(0x0);
520 while ( ( locTrg = static_cast<AliMUONLocalTrigger*>(next()) ) )
525 if ( locTrg->LoSdev()==1 && locTrg->LoDev()==0 &&
526 locTrg->LoStripX()==0) xTrig=kFALSE; // no trigger in X
527 else xTrig=kTRUE; // trigger in X
528 if (locTrg->LoTrigY()==1 &&
529 locTrg->LoStripY()==15 ) yTrig = kFALSE; // no trigger in Y
530 else yTrig = kTRUE; // trigger in Y
533 { // fill ntuple if trigger in X and Y
534 tupleLoc.Fill(ievent,locTrg->LoCircuit(),
540 triggerCircuit.GetY11Pos(locTrg->LoCircuit(),locTrg->LoStripX()),
541 triggerCircuit.GetY21Pos(locTrg->LoCircuit(),locTrg->LoStripX()+locTrg->LoDev()+1),
542 triggerCircuit.GetX11Pos(locTrg->LoCircuit(),locTrg->LoStripY()));
544 tupleGlo.Fill(ievent,gloTrg->SingleLpt(),gloTrg->SingleHpt(),
545 gloTrg->PairUnlikeLpt(),gloTrg->PairUnlikeHpt(),
546 gloTrg->PairLikeLpt(),gloTrg->PairLikeHpt());
547 } // end of loop on local triggers
548 } // end of loop on events
550 // print info and store ntuples
552 printf("=============================================\n");
553 printf("================ SUMMARY ==================\n");
555 printf("Total number of events processed %d \n",nevents);
557 printf(" Global Trigger output Low pt High pt\n");
558 printf(" number of Single :\t");
559 printf("%i\t%i\t",sLowpt,sHighpt);
561 printf(" number of UnlikeSign pair :\t");
562 printf("%i\t%i\t",uSLowpt,uSHighpt);
564 printf(" number of LikeSign pair :\t");
565 printf("%i\t%i\t",lSLowpt,lSHighpt);
567 printf("=============================================\n");
570 TFile myFile(fileNameOut, "RECREATE");
576 //_____________________________________________________________________________
578 AliMUONDataInterface::LoadEvent(Int_t event)
580 /// Load event if different from the current one.
581 /// Returns kFALSE on error and kTRUE if the event was loaded.
585 AliDebug(1,Form("Loading event %d using runLoader %p",event,fLoader->GetRunLoader()));
586 if (fLoader->GetRunLoader()->GetEvent(event) == 0)
588 fCurrentEvent = event;
595 //______________________________________________________________________________
597 AliMUONDataInterface::NumberOfEvents() const
599 /// Number of events in the current galice.root file we're attached to
600 if (not IsValid()) return -1;
601 return fLoader->GetRunLoader()->GetNumberOfEvents();
604 //_____________________________________________________________________________
606 AliMUONDataInterface::Open(const char* filename)
608 /// Connect to a given galice.root file
614 if ( fLoader != 0x0 )
616 delete fLoader->GetRunLoader();
623 TString foldername(Form("%s-%d",ClassName(),fgInstanceCounter));
625 while (AliRunLoader::GetRunLoader(foldername) != 0x0)
627 delete AliRunLoader::GetRunLoader(foldername);
630 AliRunLoader* runLoader = AliRunLoader::Open(filename,foldername);
631 if (runLoader == 0x0)
633 AliError(Form("Cannot open file %s",filename));
636 fLoader = runLoader->GetDetectorLoader("MUON");
639 AliError("Cannot get AliMUONLoader");
645 AliError(Form("Could not access %s filename. Object is unuseable",filename));
649 //_____________________________________________________________________________
650 Bool_t AliMUONDataInterface::GetEvent(Int_t event)
652 /// Loads all reconstructed data for the given event.
654 if (DigitStore(event) == 0x0) return kFALSE;
655 if (ClusterStore(event) == 0x0) return kFALSE;
656 if (TrackStore(event) == 0x0) return kFALSE;
657 if (TriggerStore(event) == 0x0) return kFALSE;
658 if (TriggerTrackStore(event) == 0x0) return kFALSE;
662 //_____________________________________________________________________________
663 Int_t AliMUONDataInterface::NumberOfDigits(Int_t detElemId)
665 /// Returns the number of digits to be found on a given detector element.
666 /// @param detElemId The detector element ID number to search on.
668 TIterator* iter = GetIterator(kDigitIteratorByDetectorElement, detElemId);
669 return CountObjects(iter);
672 //_____________________________________________________________________________
673 AliMUONVDigit* AliMUONDataInterface::Digit(Int_t detElemId, Int_t index)
675 /// Returns the a pointer to the index'th digit on the specified detector element.
676 /// @param detElemId The detector element ID number to search on.
677 /// @param index The index number of the digit to fetch in the range [0 .. N-1],
678 /// where N = NumberOfDigits(detElemId)
680 TIterator* iter = GetIterator(kDigitIteratorByDetectorElement, detElemId);
681 return static_cast<AliMUONVDigit*>( FetchObject(iter, index) );
684 //_____________________________________________________________________________
685 Int_t AliMUONDataInterface::NumberOfDigits(Int_t chamber, Int_t cathode)
687 /// Returns the number of digits to be found on a specific chamber and cathode.
688 /// @param chamber The chamber number in the range [0 .. 13].
689 /// @param cathode The cathode in the range [0 .. 1], where 0 is the bending and
690 /// 1 is the non-bending plane.
692 TIterator* iter = GetIterator(kDigitIteratorByChamberAndCathode, chamber, cathode);
693 return CountObjects(iter);
696 //_____________________________________________________________________________
697 AliMUONVDigit* AliMUONDataInterface::Digit(Int_t chamber, Int_t cathode, Int_t index)
699 /// Returns the a pointer to the index'th digit on the specified chamber and cathode.
700 /// @param chamber The chamber number in the range [0 .. 13].
701 /// @param cathode The cathode in the range [0 .. 1], where 0 is the bending and
702 /// 1 is the non-bending plane.
703 /// @param index The index number of the digit to fetch in the range [0 .. N-1],
704 /// where N = NumberOfDigits(chamber, cathode)
706 TIterator* iter = GetIterator(kDigitIteratorByChamberAndCathode, chamber, cathode);
707 return static_cast<AliMUONVDigit*>( FetchObject(iter, index) );
710 //_____________________________________________________________________________
711 Int_t AliMUONDataInterface::NumberOfRawClusters(Int_t chamber)
713 /// Returns the number of reconstructed raw clusters on the specified chamber.
714 /// @param chamber The chamber number in the range [0 .. 13].
716 TIterator* iter = GetIterator(kRawClusterIterator, chamber);
717 return CountObjects(iter);
720 //_____________________________________________________________________________
721 AliMUONVCluster* AliMUONDataInterface::RawCluster(Int_t chamber, Int_t index)
723 /// Returns a pointer to the index'th raw cluster on the specified chamber.
724 /// @param chamber The chamber number in the range [0 .. 13].
725 /// @param index The index number of the raw cluster to fetch in the range [0 .. N-1],
726 /// where N = NumberOfRawClusters(chamber)
728 TIterator* iter = GetIterator(kRawClusterIterator, chamber);
729 return static_cast<AliMUONVCluster*>( FetchObject(iter, index) );
732 //_____________________________________________________________________________
733 Int_t AliMUONDataInterface::NumberOfTracks()
735 /// Returns the number of reconstructed tracks.
737 TIterator* iter = GetIterator(kTrackIterator);
738 return CountObjects(iter);
741 //_____________________________________________________________________________
742 AliMUONTrack* AliMUONDataInterface::Track(Int_t index)
744 /// Returns a pointer to the index'th reconstructed track.
745 /// @param index The index number of the track to fetch in the range [0 .. N-1],
746 /// where N = NumberOfTracks()
748 TIterator* iter = GetIterator(kTrackIterator);
749 return static_cast<AliMUONTrack*>( FetchObject(iter, index) );
752 //_____________________________________________________________________________
753 Int_t AliMUONDataInterface::NumberOfLocalTriggers()
755 /// Returns the number of reconstructed local trigger objects.
757 TIterator* iter = GetIterator(kLocalTriggerIterator);
758 return CountObjects(iter);
761 //_____________________________________________________________________________
762 AliMUONLocalTrigger* AliMUONDataInterface::LocalTrigger(Int_t index)
764 /// Returns a pointer to the index'th local trigger object.
765 /// @param index The index number of the local trigger object to fetch in the range [0 .. N-1],
766 /// where N = NumberOfLocalTriggers()
768 TIterator* iter = GetIterator(kLocalTriggerIterator);
769 return static_cast<AliMUONLocalTrigger*>( FetchObject(iter, index) );
772 //_____________________________________________________________________________
773 Int_t AliMUONDataInterface::NumberOfRegionalTriggers()
775 /// Returns the number of regional trigger objects reconstructed.
777 TIterator* iter = GetIterator(kRegionalTriggerIterator);
778 return CountObjects(iter);
781 //_____________________________________________________________________________
782 AliMUONRegionalTrigger* AliMUONDataInterface::RegionalTrigger(Int_t index)
784 /// Returns a pointer to the index'th regional trigger object.
785 /// @param index The index number of the regional trigger object to fetch in the range [0 .. N-1],
786 /// where N = NumberOfRegionalTriggers()
788 TIterator* iter = GetIterator(kRegionalTriggerIterator);
789 return static_cast<AliMUONRegionalTrigger*>( FetchObject(iter, index) );
792 //_____________________________________________________________________________
793 AliMUONGlobalTrigger* AliMUONDataInterface::GlobalTrigger()
795 /// Returns a pointer to the reconstructed global trigger object for the event.
797 AliMUONVTriggerStore* store = TriggerStore(fCurrentEvent);
798 if (store == 0x0) return 0x0;
799 return store->Global();
802 //_____________________________________________________________________________
803 Int_t AliMUONDataInterface::NumberOfTriggerTracks()
805 /// Returns the number of reconstructed tracks in the trigger chambers.
807 TIterator* iter = GetIterator(kTriggerTrackIterator);
808 return CountObjects(iter);
811 //_____________________________________________________________________________
812 AliMUONTriggerTrack* AliMUONDataInterface::TriggerTrack(Int_t index)
814 /// Returns a pointer to the index'th reconstructed trigger track object.
815 /// @param index The index number of the trigger track to fetch in the range [0 .. N-1],
816 /// where N = NumberOfTriggerTracks()
818 TIterator* iter = GetIterator(kTriggerTrackIterator);
819 return static_cast<AliMUONTriggerTrack*>( FetchObject(iter, index) );
822 //_____________________________________________________________________________
823 void AliMUONDataInterface::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 (fDigitStore != 0x0)
834 if (fTriggerStore != 0x0)
836 delete fTriggerStore;
839 if (fClusterStore != 0x0)
841 delete fClusterStore;
844 if (fTrackStore != 0x0)
849 if (fTriggerTrackStore != 0x0)
851 delete fTriggerTrackStore;
852 fTriggerTrackStore = 0x0;
856 //_____________________________________________________________________________
857 TIterator* AliMUONDataInterface::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 == kDigitIteratorByDetectorElement
865 /// If type equals kDigitIteratorByChamberAndCathode or kRawClusterIterator
866 /// then this is the chamber number. In all other cases this parameter is
868 /// @param y If type == kDigitIteratorByChamberAndCathode then this parameter is the
869 /// cathode number. In all other cases this parameter is
872 if (type == fCurrentIteratorType and fDataX == x and fDataY == y)
875 if (fCurrentEvent == -1)
877 AliError("No event was selected. Try first using GetEvent().");
885 case kDigitIteratorByDetectorElement:
888 AliMUONVDigitStore* store = DigitStore(fCurrentEvent);
889 if (store == 0x0) return 0x0;
890 fIterator = store->CreateIterator(detElem, detElem, 2);
891 if (fIterator == 0x0) return 0x0;
892 fCurrentIteratorType = kDigitIteratorByDetectorElement;
897 case kDigitIteratorByChamberAndCathode:
901 if (chamber < 0 or AliMpConstants::NofChambers() <= chamber)
904 "Must have give a chamber value in the range [0..%d], but got a value of: %d",
905 AliMpConstants::NofChambers() - 1,
910 if (cathode < 0 or 1 < cathode)
912 AliError(Form("Must have give a cathode value in the range [0..1], but got a value of: %d", cathode));
916 AliMUONVDigitStore* store = DigitStore(fCurrentEvent);
917 if (store == 0x0) return 0x0;
918 AliMpIntPair pair = AliMpDEManager::GetDetElemIdRange(chamber);
919 fIterator = store->CreateIterator(pair.GetFirst(), pair.GetSecond(), cathode);
920 if (fIterator == 0x0) return 0x0;
921 fCurrentIteratorType = kDigitIteratorByChamberAndCathode;
927 case kRawClusterIterator:
930 AliMUONVClusterStore* store = ClusterStore(fCurrentEvent);
931 if (store == 0x0) return 0x0;
932 fIterator = store->CreateChamberIterator(chamber, chamber);
933 if (fIterator == 0x0) return 0x0;
934 fCurrentIteratorType = kRawClusterIterator;
941 AliMUONVTrackStore* store = TrackStore(fCurrentEvent);
942 if (store == 0x0) return 0x0;
943 fIterator = store->CreateIterator();
944 if (fIterator == 0x0) return 0x0;
945 fCurrentIteratorType = kTrackIterator;
949 case kLocalTriggerIterator:
951 AliMUONVTriggerStore* store = TriggerStore(fCurrentEvent);
952 if (store == 0x0) return 0x0;
953 fIterator = store->CreateLocalIterator();
954 if (fIterator == 0x0) return 0x0;
955 fCurrentIteratorType = kLocalTriggerIterator;
959 case kRegionalTriggerIterator:
961 AliMUONVTriggerStore* store = TriggerStore(fCurrentEvent);
962 if (store == 0x0) return 0x0;
963 fIterator = store->CreateRegionalIterator();
964 if (fIterator == 0x0) return 0x0;
965 fCurrentIteratorType = kRegionalTriggerIterator;
969 case kTriggerTrackIterator:
971 AliMUONVTriggerTrackStore* store = TriggerTrackStore(fCurrentEvent);
972 if (store == 0x0) return 0x0;
973 fIterator = store->CreateIterator();
974 if (fIterator == 0x0) return 0x0;
975 fCurrentIteratorType = kTriggerTrackIterator;
984 //_____________________________________________________________________________
985 void AliMUONDataInterface::ResetIterator()
987 /// The temporary iterator object is deleted if it exists and the pointer reset to 0x0.
988 /// The iterator type and temporary data indicating the state of the iterator are
991 if (fIterator != 0x0) delete fIterator;
992 fCurrentIteratorType = kNoIterator;
993 fCurrentIndex = fDataX = fDataY = -1;
997 //_____________________________________________________________________________
998 Int_t AliMUONDataInterface::CountObjects(TIterator* iter)
1000 /// Counts the number of objects in the iterator and resets it.
1001 /// @return The number of objects in 'iter'.
1003 if (iter == 0x0) return -1;
1006 while ( iter->Next() != 0x0 ) count++;
1012 //_____________________________________________________________________________
1013 TObject* AliMUONDataInterface::FetchObject(TIterator* iter, Int_t index)
1015 /// Fetches the index'th object from the iterator counting the first object
1016 /// returned by iterator after it is reset as index == 0. The next object
1017 /// has index == 1 and so on where the last object returned by the iterator
1018 /// has index == N-1 where N = CountObjects(iter)
1019 /// This method will only reset the iterator if index is smaller than
1020 /// fCurrentIndex, which is used to track the iteration progress and is
1021 /// updated when a new object if returned by this method.
1022 /// @param iter The iterator to fetch an object from.
1023 /// @param index The index number of the object to fetch in the range [0 .. N-1]
1024 /// where N = CountObjects(iter)
1028 AliError(Form("Index is out of bounds. Got a value of %d.", index));
1032 if (iter == 0x0) return 0x0;
1033 if (index <= fCurrentIndex)
1039 TObject* object = 0x0;
1040 while (fCurrentIndex < index)
1042 object = iter->Next();
1045 AliError(Form("Index is out of bounds. Got a value of %d.", index));