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 "AliMUONRawCluster.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"
38 #include "AliMpSegmentation.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 //______________________________________________________________________________
104 AliMUONDataInterface::~AliMUONDataInterface()
108 if ( fLoader != 0x0 )
110 delete fLoader->GetRunLoader();
115 //______________________________________________________________________________
117 AliMUONDataInterface::DigitStore(Int_t event)
119 /// Return digitStore for a given event.
120 /// Return 0x0 if event not found.
121 /// Returned pointer should not be deleted
123 if (not IsValid()) return 0x0;
124 if (event == fCurrentEvent and fDigitStore != 0x0) return fDigitStore;
127 if (not LoadEvent(event)) return 0x0;
129 fLoader->LoadDigits();
131 TTree* treeD = fLoader->TreeD();
134 AliError("Could not get treeD");
138 fDigitStore = AliMUONVDigitStore::Create(*treeD);
139 if ( fDigitStore != 0x0 )
141 fDigitStore->Clear();
142 fDigitStore->Connect(*treeD);
146 fLoader->UnloadDigits();
151 //______________________________________________________________________________
152 AliMUONVClusterStore*
153 AliMUONDataInterface::ClusterStore(Int_t event)
155 /// Return clusterStore for a given event.
156 /// Return 0x0 if event not found.
157 /// Returned pointer should not be deleted
159 if (not IsValid()) return 0x0;
160 if (event == fCurrentEvent and fClusterStore != 0x0) return fClusterStore;
163 if (not LoadEvent(event)) return 0x0;
165 fLoader->LoadRecPoints();
167 TTree* treeR = fLoader->TreeR();
170 AliError("Could not get treeR");
174 fClusterStore = AliMUONVClusterStore::Create(*treeR);
175 if ( fClusterStore != 0x0 )
177 fClusterStore->Clear();
178 fClusterStore->Connect(*treeR);
182 fLoader->UnloadRecPoints();
184 return fClusterStore;
187 //______________________________________________________________________________
189 AliMUONDataInterface::TrackStore(Int_t event)
191 /// Return the trackStore for a given event.
192 /// Return 0x0 if event not found.
193 /// Returned pointer should not be deleted
195 if (not IsValid()) return 0x0;
196 if (event == fCurrentEvent and fTrackStore != 0x0) return fTrackStore;
199 if (not LoadEvent(event)) return 0x0;
201 fLoader->LoadTracks();
203 TTree* treeT = fLoader->TreeT();
206 AliError("Could not get treeT");
210 fTrackStore = AliMUONVTrackStore::Create(*treeT);
211 if ( fTrackStore != 0x0 )
213 fTrackStore->Clear();
214 fTrackStore->Connect(*treeT);
218 fLoader->UnloadTracks();
223 //______________________________________________________________________________
224 AliMUONVTriggerTrackStore*
225 AliMUONDataInterface::TriggerTrackStore(Int_t event)
227 /// Return the triggerTrackStore for a given event.
228 /// Return 0x0 if event not found.
229 /// Returned pointer should not be deleted
231 if (not IsValid()) return 0x0;
232 if (event == fCurrentEvent and fTriggerTrackStore != 0x0) return fTriggerTrackStore;
235 if (not LoadEvent(event)) return 0x0;
237 fLoader->LoadTracks();
239 TTree* treeT = fLoader->TreeT();
242 AliError("Could not get treeT");
246 fTriggerTrackStore = AliMUONVTriggerTrackStore::Create(*treeT);
247 if ( fTriggerTrackStore != 0x0 )
249 fTriggerTrackStore->Clear();
250 fTriggerTrackStore->Connect(*treeT);
254 fLoader->UnloadTracks();
256 return fTriggerTrackStore;
259 //_____________________________________________________________________________
260 AliMUONVTriggerStore*
261 AliMUONDataInterface::TriggerStore(Int_t event, const char* treeLetter)
263 /// Return the triggerStore for a given event.
264 /// Return 0x0 if event not found.
265 /// Returned pointer should not be deleted
266 /// treeLetter can be R or D to tell from which tree to read the information
268 if (not IsValid()) return 0x0;
269 if (event == fCurrentEvent and fTriggerStore != 0x0) return fTriggerStore;
272 if (not LoadEvent(event)) return 0x0;
276 TString stree(treeLetter);
281 fLoader->LoadDigits();
282 tree = fLoader->TreeD();
284 else if ( stree == "R" )
286 fLoader->LoadRecPoints();
287 tree = fLoader->TreeR();
292 AliError(Form("Could not get tree%s",treeLetter));
296 fTriggerStore = AliMUONVTriggerStore::Create(*tree);
297 if ( fTriggerStore != 0x0 )
299 fTriggerStore->Clear();
300 fTriggerStore->Connect(*tree);
306 fLoader->UnloadDigits();
308 else if ( stree == "R" )
310 fLoader->UnloadRecPoints();
313 return fTriggerStore;
316 //______________________________________________________________________________
318 AliMUONDataInterface::DumpDigits(Int_t event, Bool_t sorted)
320 /// Dump the digits for a given event, sorted if so required
322 if ( fDigitStore != 0x0 )
326 DumpSorted(*fDigitStore);
330 fDigitStore->Print();
335 //______________________________________________________________________________
337 AliMUONDataInterface::DumpRecPoints(Int_t event, Bool_t sorted)
339 /// Dump the recpoints for a given event, sorted if so required
341 if ( fClusterStore != 0x0 )
345 DumpSorted(*fClusterStore);
349 fClusterStore->Print();
354 //_____________________________________________________________________________
356 AliMUONDataInterface::DumpSorted(const AliMUONVStore& store) const
358 /// Dump the given store, in sorted order
360 TIter next(store.CreateIterator());
363 list.SetOwner(kFALSE);
365 while ( ( object = next() ) )
375 //______________________________________________________________________________
377 AliMUONDataInterface::DumpTracks(Int_t event, Bool_t sorted)
379 /// Dump tracks for a given event, sorted if requested
383 if ( fTrackStore != 0x0 )
387 DumpSorted(*fTrackStore);
391 fTrackStore->Print();
396 //______________________________________________________________________________
398 AliMUONDataInterface::DumpTriggerTracks(Int_t event, Bool_t sorted)
400 /// Dump trigger tracks for a given event, sorted if requested
402 TriggerTrackStore(event);
404 if ( fTriggerTrackStore != 0x0 )
408 DumpSorted(*fTriggerTrackStore);
412 fTriggerTrackStore->Print();
417 //_____________________________________________________________________________
419 AliMUONDataInterface::DumpTrigger(Int_t event, const char* treeLetter)
421 /// Dump trigger for a given event from a given tree (if event>=0)
422 /// or loop over all events and build a trigger ntuple if event<0
423 /// treeLetter can be R or D to tell from which tree to read the information
427 NtupleTrigger(treeLetter);
431 TriggerStore(event,treeLetter);
433 if ( fTriggerStore != 0x0 )
435 fTriggerStore->Print();
440 //_____________________________________________________________________________
442 AliMUONDataInterface::NtupleTrigger(const char* treeLetter)
444 //// Loop over events to build trigger ntuples
447 TString sTreeLetter(treeLetter);
448 sTreeLetter.ToUpper();
450 if ( sTreeLetter != "R" && sTreeLetter != "D" )
452 AliError(Form("Cannot handle tree%s. Use D or R",treeLetter));
457 TNtuple tupleGlo("TgtupleGlo","Global Trigger Ntuple",
458 "ev:slpt:shpt:uplpt:uphpt:lplpt:lplpt");
459 TNtuple tupleLoc("TgtupleLoc","Local Trigger Ntuple",
460 "ev:LoCircuit:LoStripX:LoDev:StripY:LoLpt:LoHpt:y11:y21:x11");
462 // initialize counters
470 AliMUONGeometryTransformer transformer;
471 transformer.LoadGeometryData(Form("%s/geometry.root",
472 gSystem->DirName(fLoader->GetRunLoader()->GetFileName())));
475 if ( ! AliMpCDB::LoadMpSegmentation() )
477 AliFatal("Could not access mapping from OCDB !");
481 if ( ! AliMpCDB::LoadDDLStore() )
483 AliFatal("Could not access DDL Store from OCDB !");
486 AliMUONTriggerCircuit triggerCircuit(&transformer);
488 // select output file name from selected Tree
489 Char_t fileNameOut[30];
490 if (sTreeLetter == "D")
492 AliInfo(Form("reading from Digits\n"));
493 sprintf(fileNameOut,"TriggerCheckFromDigits.root");
495 else if (sTreeLetter == "R")
497 AliInfo(Form("reading from RecPoints\n"));
498 sprintf(fileNameOut,"TriggerCheckFromRP.root");
502 Int_t nevents = NumberOfEvents();
504 for (Int_t ievent=0; ievent<nevents; ++ievent)
506 if (ievent%100==0) AliInfo(Form("Processing event %d\n",ievent));
508 AliMUONVTriggerStore* triggerStore = TriggerStore(ievent);
512 AliError(Form("Could not read %s from tree%s","Trigger",treeLetter));
516 // get global trigger info
517 AliMUONGlobalTrigger* gloTrg = triggerStore->Global();
518 sLowpt+=gloTrg->SingleLpt();
519 sHighpt+=gloTrg->SingleHpt();
520 uSLowpt+=gloTrg->PairUnlikeLpt();
521 uSHighpt+=gloTrg->PairUnlikeHpt();
522 lSLowpt+=gloTrg->PairLikeLpt();
523 lSHighpt+=gloTrg->PairLikeHpt();
525 // loop on local triggers
526 TIter next(triggerStore->CreateIterator());
527 AliMUONLocalTrigger* locTrg(0x0);
528 while ( ( locTrg = static_cast<AliMUONLocalTrigger*>(next()) ) )
533 if ( locTrg->LoSdev()==1 && locTrg->LoDev()==0 &&
534 locTrg->LoStripX()==0) xTrig=kFALSE; // no trigger in X
535 else xTrig=kTRUE; // trigger in X
536 if (locTrg->LoTrigY()==1 &&
537 locTrg->LoStripY()==15 ) yTrig = kFALSE; // no trigger in Y
538 else yTrig = kTRUE; // trigger in Y
541 { // fill ntuple if trigger in X and Y
542 tupleLoc.Fill(ievent,locTrg->LoCircuit(),
548 triggerCircuit.GetY11Pos(locTrg->LoCircuit(),locTrg->LoStripX()),
549 triggerCircuit.GetY21Pos(locTrg->LoCircuit(),locTrg->LoStripX()+locTrg->LoDev()+1),
550 triggerCircuit.GetX11Pos(locTrg->LoCircuit(),locTrg->LoStripY()));
552 tupleGlo.Fill(ievent,gloTrg->SingleLpt(),gloTrg->SingleHpt(),
553 gloTrg->PairUnlikeLpt(),gloTrg->PairUnlikeHpt(),
554 gloTrg->PairLikeLpt(),gloTrg->PairLikeHpt());
555 } // end of loop on local triggers
556 } // end of loop on events
558 // print info and store ntuples
560 printf("=============================================\n");
561 printf("================ SUMMARY ==================\n");
563 printf("Total number of events processed %d \n",nevents);
565 printf(" Global Trigger output Low pt High pt\n");
566 printf(" number of Single :\t");
567 printf("%i\t%i\t",sLowpt,sHighpt);
569 printf(" number of UnlikeSign pair :\t");
570 printf("%i\t%i\t",uSLowpt,uSHighpt);
572 printf(" number of LikeSign pair :\t");
573 printf("%i\t%i\t",lSLowpt,lSHighpt);
575 printf("=============================================\n");
578 TFile myFile(fileNameOut, "RECREATE");
584 //_____________________________________________________________________________
586 AliMUONDataInterface::LoadEvent(Int_t event)
588 /// Load event if different from the current one.
589 /// Returns kFALSE on error and kTRUE if the event was loaded.
593 AliDebug(1,Form("Loading event %d using runLoader %p",event,fLoader->GetRunLoader()));
594 if (fLoader->GetRunLoader()->GetEvent(event) == 0)
596 fCurrentEvent = event;
603 //______________________________________________________________________________
605 AliMUONDataInterface::NumberOfEvents() const
607 /// Number of events in the current galice.root file we're attached to
608 if (not IsValid()) return -1;
609 return fLoader->GetRunLoader()->GetNumberOfEvents();
612 //_____________________________________________________________________________
614 AliMUONDataInterface::Open(const char* filename)
616 /// Connect to a given galice.root file
622 if ( fLoader != 0x0 )
624 delete fLoader->GetRunLoader();
631 TString foldername(Form("%s-%d",ClassName(),fgInstanceCounter));
633 while (AliRunLoader::GetRunLoader(foldername) != 0x0)
635 delete AliRunLoader::GetRunLoader(foldername);
638 AliRunLoader* runLoader = AliRunLoader::Open(filename,foldername);
639 if (runLoader == 0x0)
641 AliError(Form("Cannot open file %s",filename));
644 fLoader = runLoader->GetDetectorLoader("MUON");
647 AliError("Cannot get AliMUONLoader");
653 AliError(Form("Could not access %s filename. Object is unuseable",filename));
657 //_____________________________________________________________________________
658 Bool_t AliMUONDataInterface::GetEvent(Int_t event)
660 /// Loads all reconstructed data for the given event.
662 if (DigitStore(event) == 0x0) return kFALSE;
663 if (ClusterStore(event) == 0x0) return kFALSE;
664 if (TrackStore(event) == 0x0) return kFALSE;
665 if (TriggerStore(event) == 0x0) return kFALSE;
666 if (TriggerTrackStore(event) == 0x0) return kFALSE;
670 //_____________________________________________________________________________
671 Int_t AliMUONDataInterface::NumberOfDigits(Int_t detElemId)
673 /// Returns the number of digits to be found on a given detector element.
674 /// @param detElemId The detector element ID number to search on.
676 TIterator* iter = GetIterator(kDigitIteratorByDetectorElement, detElemId);
677 return CountObjects(iter);
680 //_____________________________________________________________________________
681 AliMUONVDigit* AliMUONDataInterface::Digit(Int_t detElemId, Int_t index)
683 /// Returns the a pointer to the index'th digit on the specified detector element.
684 /// @param detElemId The detector element ID number to search on.
685 /// @param index The index number of the digit to fetch in the range [0 .. N-1],
686 /// where N = NumberOfDigits(detElemId)
688 TIterator* iter = GetIterator(kDigitIteratorByDetectorElement, detElemId);
689 return static_cast<AliMUONVDigit*>( FetchObject(iter, index) );
692 //_____________________________________________________________________________
693 Int_t AliMUONDataInterface::NumberOfDigits(Int_t chamber, Int_t cathode)
695 /// Returns the number of digits to be found on a specific 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.
700 TIterator* iter = GetIterator(kDigitIteratorByChamberAndCathode, chamber, cathode);
701 return CountObjects(iter);
704 //_____________________________________________________________________________
705 AliMUONVDigit* AliMUONDataInterface::Digit(Int_t chamber, Int_t cathode, Int_t index)
707 /// Returns the a pointer to the index'th digit on the specified chamber and cathode.
708 /// @param chamber The chamber number in the range [0 .. 13].
709 /// @param cathode The cathode in the range [0 .. 1], where 0 is the bending and
710 /// 1 is the non-bending plane.
711 /// @param index The index number of the digit to fetch in the range [0 .. N-1],
712 /// where N = NumberOfDigits(chamber, cathode)
714 TIterator* iter = GetIterator(kDigitIteratorByChamberAndCathode, chamber, cathode);
715 return static_cast<AliMUONVDigit*>( FetchObject(iter, index) );
718 //_____________________________________________________________________________
719 Int_t AliMUONDataInterface::NumberOfRawClusters(Int_t chamber)
721 /// Returns the number of reconstructed raw clusters on the specified chamber.
722 /// @param chamber The chamber number in the range [0 .. 13].
724 TIterator* iter = GetIterator(kRawClusterIterator, chamber);
725 return CountObjects(iter);
728 //_____________________________________________________________________________
729 AliMUONRawCluster* AliMUONDataInterface::RawCluster(Int_t chamber, Int_t index)
731 /// Returns a pointer to the index'th raw cluster on the specified chamber.
732 /// @param chamber The chamber number in the range [0 .. 13].
733 /// @param index The index number of the raw cluster to fetch in the range [0 .. N-1],
734 /// where N = NumberOfRawClusters(chamber)
736 TIterator* iter = GetIterator(kRawClusterIterator, chamber);
737 return static_cast<AliMUONRawCluster*>( FetchObject(iter, index) );
740 //_____________________________________________________________________________
741 Int_t AliMUONDataInterface::NumberOfTracks()
743 /// Returns the number of reconstructed tracks.
745 TIterator* iter = GetIterator(kTrackIterator);
746 return CountObjects(iter);
749 //_____________________________________________________________________________
750 AliMUONTrack* AliMUONDataInterface::Track(Int_t index)
752 /// Returns a pointer to the index'th reconstructed track.
753 /// @param index The index number of the track to fetch in the range [0 .. N-1],
754 /// where N = NumberOfTracks()
756 TIterator* iter = GetIterator(kTrackIterator);
757 return static_cast<AliMUONTrack*>( FetchObject(iter, index) );
760 //_____________________________________________________________________________
761 Int_t AliMUONDataInterface::NumberOfLocalTriggers()
763 /// Returns the number of reconstructed local trigger objects.
765 TIterator* iter = GetIterator(kLocalTriggerIterator);
766 return CountObjects(iter);
769 //_____________________________________________________________________________
770 AliMUONLocalTrigger* AliMUONDataInterface::LocalTrigger(Int_t index)
772 /// Returns a pointer to the index'th local trigger object.
773 /// @param index The index number of the local trigger object to fetch in the range [0 .. N-1],
774 /// where N = NumberOfLocalTriggers()
776 TIterator* iter = GetIterator(kLocalTriggerIterator);
777 return static_cast<AliMUONLocalTrigger*>( FetchObject(iter, index) );
780 //_____________________________________________________________________________
781 Int_t AliMUONDataInterface::NumberOfRegionalTriggers()
783 /// Returns the number of regional trigger objects reconstructed.
785 TIterator* iter = GetIterator(kRegionalTriggerIterator);
786 return CountObjects(iter);
789 //_____________________________________________________________________________
790 AliMUONRegionalTrigger* AliMUONDataInterface::RegionalTrigger(Int_t index)
792 /// Returns a pointer to the index'th regional trigger object.
793 /// @param index The index number of the regional trigger object to fetch in the range [0 .. N-1],
794 /// where N = NumberOfRegionalTriggers()
796 TIterator* iter = GetIterator(kRegionalTriggerIterator);
797 return static_cast<AliMUONRegionalTrigger*>( FetchObject(iter, index) );
800 //_____________________________________________________________________________
801 AliMUONGlobalTrigger* AliMUONDataInterface::GlobalTrigger()
803 /// Returns a pointer to the reconstructed global trigger object for the event.
805 AliMUONVTriggerStore* store = TriggerStore(fCurrentEvent);
806 if (store == 0x0) return 0x0;
807 return store->Global();
810 //_____________________________________________________________________________
811 Int_t AliMUONDataInterface::NumberOfTriggerTracks()
813 /// Returns the number of reconstructed tracks in the trigger chambers.
815 TIterator* iter = GetIterator(kTriggerTrackIterator);
816 return CountObjects(iter);
819 //_____________________________________________________________________________
820 AliMUONTriggerTrack* AliMUONDataInterface::TriggerTrack(Int_t index)
822 /// Returns a pointer to the index'th reconstructed trigger track object.
823 /// @param index The index number of the trigger track to fetch in the range [0 .. N-1],
824 /// where N = NumberOfTriggerTracks()
826 TIterator* iter = GetIterator(kTriggerTrackIterator);
827 return static_cast<AliMUONTriggerTrack*>( FetchObject(iter, index) );
830 //_____________________________________________________________________________
831 void AliMUONDataInterface::ResetStores()
833 /// Deletes all the store objects that have been created and resets the pointers to 0x0.
834 /// The temporary iterator object is automatically reset. See ResetIterator for more details.
837 if (fDigitStore != 0x0)
842 if (fTriggerStore != 0x0)
844 delete fTriggerStore;
847 if (fClusterStore != 0x0)
849 delete fClusterStore;
852 if (fTrackStore != 0x0)
857 if (fTriggerTrackStore != 0x0)
859 delete fTriggerTrackStore;
860 fTriggerTrackStore = 0x0;
864 //_____________________________________________________________________________
865 TIterator* AliMUONDataInterface::GetIterator(IteratorType type, Int_t x, Int_t y)
867 /// Creates an appropriate iterator object and returns it.
868 /// If the iterator has already been created then that one is returned otherwise
869 /// a new object is created.
870 /// Depending on the value of 'type' the semantics of parameters x and y can change.
871 /// @param type The type of iterator to create.
872 /// @param x This is the detector element ID if type == kDigitIteratorByDetectorElement
873 /// If type equals kDigitIteratorByChamberAndCathode or kRawClusterIterator
874 /// then this is the chamber number. In all other cases this parameter is
876 /// @param y If type == kDigitIteratorByChamberAndCathode then this parameter is the
877 /// cathode number. In all other cases this parameter is
880 if (type == fCurrentIteratorType and fDataX == x and fDataY == y)
883 if (fCurrentEvent == -1)
885 AliError("No event was selected. Try first using GetEvent().");
893 case kDigitIteratorByDetectorElement:
896 AliMUONVDigitStore* store = DigitStore(fCurrentEvent);
897 if (store == 0x0) return 0x0;
898 AliMpSegmentation::ReadData(kFALSE); // kFALSE so that we do not get warning message.
899 fIterator = store->CreateIterator(detElem, detElem, 2);
900 if (fIterator == 0x0) return 0x0;
901 fCurrentIteratorType = kDigitIteratorByDetectorElement;
906 case kDigitIteratorByChamberAndCathode:
910 if (chamber < 0 or AliMpConstants::NofChambers() <= chamber)
913 "Must have give a chamber value in the range [0..%d], but got a value of: %d",
914 AliMpConstants::NofChambers() - 1,
919 if (cathode < 0 or 1 < cathode)
921 AliError(Form("Must have give a cathode value in the range [0..1], but got a value of: %d", cathode));
925 AliMUONVDigitStore* store = DigitStore(fCurrentEvent);
926 if (store == 0x0) return 0x0;
927 AliMpSegmentation::ReadData(kFALSE); // kFALSE so that we do not get warning message.
928 AliMpIntPair pair = AliMpDEManager::GetDetElemIdRange(chamber);
929 fIterator = store->CreateIterator(pair.GetFirst(), pair.GetSecond(), cathode);
930 if (fIterator == 0x0) return 0x0;
931 fCurrentIteratorType = kDigitIteratorByChamberAndCathode;
937 case kRawClusterIterator:
940 AliMUONVClusterStore* store = ClusterStore(fCurrentEvent);
941 if (store == 0x0) return 0x0;
942 fIterator = store->CreateChamberIterator(chamber, chamber);
943 if (fIterator == 0x0) return 0x0;
944 fCurrentIteratorType = kRawClusterIterator;
951 AliMUONVTrackStore* store = TrackStore(fCurrentEvent);
952 if (store == 0x0) return 0x0;
953 fIterator = store->CreateIterator();
954 if (fIterator == 0x0) return 0x0;
955 fCurrentIteratorType = kTrackIterator;
959 case kLocalTriggerIterator:
961 AliMUONVTriggerStore* store = TriggerStore(fCurrentEvent);
962 if (store == 0x0) return 0x0;
963 fIterator = store->CreateLocalIterator();
964 if (fIterator == 0x0) return 0x0;
965 fCurrentIteratorType = kLocalTriggerIterator;
969 case kRegionalTriggerIterator:
971 AliMUONVTriggerStore* store = TriggerStore(fCurrentEvent);
972 if (store == 0x0) return 0x0;
973 fIterator = store->CreateRegionalIterator();
974 if (fIterator == 0x0) return 0x0;
975 fCurrentIteratorType = kRegionalTriggerIterator;
979 case kTriggerTrackIterator:
981 AliMUONVTriggerTrackStore* store = TriggerTrackStore(fCurrentEvent);
982 if (store == 0x0) return 0x0;
983 fIterator = store->CreateIterator();
984 if (fIterator == 0x0) return 0x0;
985 fCurrentIteratorType = kTriggerTrackIterator;
994 //_____________________________________________________________________________
995 void AliMUONDataInterface::ResetIterator()
997 /// The temporary iterator object is deleted if it exists and the pointer reset to 0x0.
998 /// The iterator type and temporary data indicating the state of the iterator are
1001 if (fIterator != 0x0) delete fIterator;
1002 fCurrentIteratorType = kNoIterator;
1003 fCurrentIndex = fDataX = fDataY = -1;
1007 //_____________________________________________________________________________
1008 Int_t AliMUONDataInterface::CountObjects(TIterator* iter)
1010 /// Counts the number of objects in the iterator and resets it.
1011 /// @return The number of objects in 'iter'.
1013 if (iter == 0x0) return -1;
1016 while ( iter->Next() != 0x0 ) count++;
1022 //_____________________________________________________________________________
1023 TObject* AliMUONDataInterface::FetchObject(TIterator* iter, Int_t index)
1025 /// Fetches the index'th object from the iterator counting the first object
1026 /// returned by iterator after it is reset as index == 0. The next object
1027 /// has index == 1 and so on where the last object returned by the iterator
1028 /// has index == N-1 where N = CountObjects(iter)
1029 /// This method will only reset the iterator if index is smaller than
1030 /// fCurrentIndex, which is used to track the iteration progress and is
1031 /// updated when a new object if returned by this method.
1032 /// @param iter The iterator to fetch an object from.
1033 /// @param index The index number of the object to fetch in the range [0 .. N-1]
1034 /// where N = CountObjects(iter)
1038 AliError(Form("Index is out of bounds. Got a value of %d.", index));
1042 if (iter == 0x0) return 0x0;
1043 if (index <= fCurrentIndex)
1049 TObject* object = 0x0;
1050 while (fCurrentIndex < index)
1052 object = iter->Next();
1055 AliError(Form("Index is out of bounds. Got a value of %d.", index));