]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - MUON/AliMUONDataInterface.h
recover the detector tag int and not the string from the AOD particle
[u/mrichter/AliRoot.git] / MUON / AliMUONDataInterface.h
index e49b0b0ced686d66f55adf7e2a1a360993f5ed22..183075d17453a3991b44cce7939c25ddbe4a08d9 100644 (file)
@@ -1,5 +1,5 @@
-#ifndef ALI_MUON_DATA_INTERFACE_H
-#define ALI_MUON_DATA_INTERFACE_H
+#ifndef ALIMUONDATAINTERFACE_H
+#define ALIMUONDATAINTERFACE_H
 /*  Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
  * See cxx source for full Copyright notice                               */
 
 /// \class AliMUONDataInterface
 /// \brief An easy to use interface to MUON data
 
-// Author: Artur Szostak
-//  email: artur@alice.phy.uct.ac.za
+// Author: Artur Szostak (University of Cape Town)
+//  email: artursz@iafrica.com
 //
 // Updated to MUON module w/o MUONData by Laurent Aphecetche, Subatech
 //
 
 #include <TObject.h>
+#include <TString.h>
 
-class AliMUONDataManager;
+class TIterator;
+class AliLoader;
+class AliMUONVStore;
 class AliMUONVDigitStore;
-class AliMUONVTriggerStore;
-class AliMUONVTriggerTrackStore;
 class AliMUONVClusterStore;
-class AliMUONVTrackStore;
-
-// >>LA should not needed (once we remove deprecated methods)
-class AliMUONHit; 
-class AliMUONDigit;
+class AliMUONVTriggerStore;
+class AliMUONVDigit;
+class AliMUONVCluster;
 class AliMUONLocalTrigger;
+class AliMUONRegionalTrigger;
 class AliMUONGlobalTrigger;
-class AliMUONRawCluster;
-class AliMUONTrack;
-class TParticle;
-// <<LA
-class TList;
+
 
 class AliMUONDataInterface : public TObject
 {
- public:
+public:
   
   AliMUONDataInterface(const char* filename="galice.root");
   virtual ~AliMUONDataInterface();
   
-  Bool_t IsValid() const;
+  /// Returns true if the data interface was able to open the root file correctly.
+  Bool_t IsValid() const { return fIsValid; };
 
-  AliMUONVClusterStore* ClusterStore(Int_t event) const;
-  void DumpRecPoints(Int_t event, Bool_t sorted=kFALSE) const;
+  void Open(const char* filename);
 
-  /** Return the digit store for one event. The returned pointer should be
-    deleted by the client.
-    */
-  AliMUONVDigitStore* DigitStore(Int_t event) const;  
-  void DumpDigits(Int_t event, Bool_t sorted=kFALSE) const;
-  TList* DigitStoreAsList(Int_t event) const;
-  
   Int_t NumberOfEvents() const;
-
-  AliMUONVDigitStore* SDigitStore(Int_t event) const;
-  void DumpSDigits(Int_t event, Bool_t sorted=kFALSE) const;
-  
-  AliMUONVTrackStore* TrackStore(Int_t event) const;
-  void DumpTracks(Int_t event, Bool_t sorted=kFALSE) const;
-  
-  /// Get the triggerStore from the given tree (can be "D" or "R").
-  AliMUONVTriggerStore* TriggerStore(Int_t event, const char* treeLetter) const;
-  void DumpTrigger(Int_t event, const char* treeLetter="R") const;
-  
-  AliMUONVTriggerTrackStore* TriggerTrackStore(Int_t event) const;
-  void DumpTriggerTracks(Int_t event, Bool_t sorted=kFALSE) const;
-  
-  // all the methods below are deprecated.
   
-  // Sets all internal pointers to NULL without releasing the current runloader.
-  void Reset();
-  
-  Bool_t UseCurrentRunLoader();
-  
-  Int_t NumberOfEvents(TString filename, TString foldername);
-  
-  Int_t NumberOfParticles(TString filename, TString foldername, Int_t event);
-  TParticle* Particle(TString filename, TString foldername, Int_t event, Int_t particle);
-  
-  Int_t NumberOfTracks(TString filename, TString foldername, Int_t event);
-  Int_t NumberOfHits(TString filename, TString foldername, Int_t event, Int_t track);
-  AliMUONHit* Hit(TString filename, TString foldername, Int_t event, Int_t track, Int_t hit);
-  
-  Int_t NumberOfSDigits(TString filename, TString foldername, Int_t event, Int_t chamber, Int_t cathode);
-  AliMUONDigit* SDigit(TString filename, TString foldername, Int_t event, Int_t chamber, Int_t cathode, Int_t sdigit);
-  
-  Int_t NumberOfDigits(TString filename, TString foldername, Int_t event, Int_t chamber, Int_t cathode);
-  AliMUONDigit* Digit(TString filename, TString foldername, Int_t event, Int_t chamber, Int_t cathode, Int_t digit);
-  
-  Int_t NumberOfRawClusters(TString filename, TString foldername, Int_t event, Int_t chamber);
-  AliMUONRawCluster* RawCluster(TString filename, TString foldername, Int_t event, Int_t chamber, Int_t cluster);
-  
-  Int_t NumberOfLocalTriggers(TString filename, TString foldername, Int_t event);
-  AliMUONLocalTrigger* LocalTrigger(TString filename, TString foldername, Int_t event, Int_t trigger);
+  /// Returns the index number of the current event loaded.
+  /// This is the event number as was used in the last calls to DigitStore(Int_t),
+  /// ClusterStore(Int_t), TriggerStore(Int_t) or GetEvent(Int_t).
+  Int_t   CurrentEvent() const { return fCurrentEvent; }
+
+  AliMUONVDigitStore* DigitStore(Int_t event);  
+  AliMUONVClusterStore* ClusterStore(Int_t event);
+  AliMUONVTriggerStore* TriggerStore(Int_t event, const char* treeLetter="R");
+
+  /// Dump the clusters for a given event, sorted if so required
+  void DumpClusters(Int_t event, Bool_t sorted=kTRUE)  { return DumpRecPoints(event,sorted); }
+  void DumpRecPoints(Int_t event, Bool_t sorted=kTRUE);
+  void DumpDigits(Int_t event, Bool_t sorted=kTRUE);
+  void DumpTrigger(Int_t event, const char* treeLetter="R");  
   
-  Bool_t SetFile(TString filename = "galice.root", TString foldername = "MUONFolder");
   Bool_t GetEvent(Int_t event = 0);
   
-  Int_t NumberOfParticles();
-  TParticle* Particle(Int_t particle);
-  
-  Int_t NumberOfTracks();
-  Int_t NumberOfHits(Int_t track);
-  AliMUONHit* Hit(Int_t track, Int_t hit);
-  
-  Int_t NumberOfSDigits(Int_t chamber, Int_t cathode);
-  AliMUONDigit* SDigit(Int_t chamber, Int_t cathode, Int_t sdigit);
-  
+  // Note the following methods can be extremely slow. Remember they are only
+  // here for end user convenience for his/her small tests and macros.
+  // If you want speed then don't use these methods. If you really want peak
+  // performance then you should be talking to the AliRunLoader and Store
+  // objects directly.
+  Int_t NumberOfDigits(Int_t detElemId);
+  AliMUONVDigit* Digit(Int_t detElemId, Int_t index);
   Int_t NumberOfDigits(Int_t chamber, Int_t cathode);
-  AliMUONDigit* Digit(Int_t chamber, Int_t cathode, Int_t digit);
-  
+  AliMUONVDigit* Digit(Int_t chamber, Int_t cathode, Int_t index);
   Int_t NumberOfRawClusters(Int_t chamber);
-  AliMUONRawCluster* RawCluster(Int_t chamber, Int_t cluster);
-  
+  AliMUONVCluster* RawCluster(Int_t chamber, Int_t index);
   Int_t NumberOfLocalTriggers();
-  AliMUONLocalTrigger* LocalTrigger(Int_t trigger);
-  
-  Int_t NumberOfGlobalTriggers();
-  AliMUONGlobalTrigger* GlobalTrigger(Int_t trigger);
-  // Returns the name of the currently selected file.
-  
-  Int_t NumberOfRecTracks();
-  AliMUONTrack* RecTrack(Int_t rectrack);
-  
-  /// Returns the file name from which we are fetching data
-  TString CurrentFile() const { return ""; }
-  
-  /// Returns the name of the currently selected folder.
-  TString CurrentFolder() const { return ""; }
-  
-  /// Returns the number of the currently selected event.
-  Int_t   CurrentEvent() const { return 0; }
+  AliMUONLocalTrigger* LocalTrigger(Int_t index);
+  Int_t NumberOfRegionalTriggers();
+  AliMUONRegionalTrigger* RegionalTrigger(Int_t index);
+  AliMUONGlobalTrigger* GlobalTrigger();
   
-  /// Returns the currently selected track.
-  Int_t   CurrentTrack() const { return 0; }
+private:
+
+  /// The various identifiers for the type of iterator constructed.
+  enum IteratorType
+  {
+    kNoIterator,  ///< No iterator was constructed.
+    kDigitIteratorByDetectorElement,  ///< A digit iterator for iterating over detector elements.
+    kDigitIteratorByChamberAndCathode,  ///< A digit iterator for iterating over chambers and cathodes.
+    kRawClusterIterator,  ///< A raw cluster iterator.
+    kLocalTriggerIterator,  ///< An iterator for iterating over reconstructed local triggers.
+    kRegionalTriggerIterator  ///< An iterator for iterating over reconstructed regional triggers.
+  };
+    
+  void DumpSorted(const AliMUONVStore& store) const;
+
+  Bool_t LoadEvent(Int_t event);
+
+  void NtupleTrigger(const char* treeLetter);
   
-  /// Returns the currently selected cathode in TreeS.
-  Int_t   CurrentSCathode() const { return 0; }
+  void ResetStores();
   
-  /// Returns the currently selected cathode in TreeD.
-  Int_t   CurrentDCathode() const { return 0; }
+  TIterator* GetIterator(IteratorType type, Int_t x = 0, Int_t y = 0);
+  void ResetIterator();
   
- private:
-    
-  void DumpIt(const char* treeLetter, const char* what, Int_t event, Bool_t sorted) const;
+  Int_t CountObjects(TIterator* iter);
+  TObject* FetchObject(TIterator* iter, Int_t index);
   
   /// Not implemented
   AliMUONDataInterface(const AliMUONDataInterface& rhs);
   /// Not implemented
   AliMUONDataInterface& operator=(const AliMUONDataInterface& rhs);
-
-  AliMUONDataManager* fDataManager; //!< Internal data accessor
   
-  ClassDef(AliMUONDataInterface, 0)  // An easy to use interface to MUON data
+  
+  AliLoader* fLoader; //!< Tree accessor
+  AliMUONVDigitStore* fDigitStore; //!< current digit store (owner)
+  AliMUONVTriggerStore* fTriggerStore; //!< current trigger store (owner)
+  AliMUONVClusterStore* fClusterStore; //!< current cluster store (owner)
+  Int_t fCurrentEvent; //!< Current event we've read in
+  TString fTreeLetter; //!< The tree letter used in the last call to TriggerStore().
+  Bool_t fIsValid; //!< whether we were initialized properly or not
+  
+  IteratorType fCurrentIteratorType;  //!< The type of iterator that is currently set.
+  Int_t fCurrentIndex;  //!< A current index number maintained for certain iteration operations.
+  Int_t fDataX; //!< Extra data parameter about the iterator, can be the chamber number or detector element.
+  Int_t fDataY; //!< Extra data parameter about the iterator, can be the cathode number.
+  TIterator* fIterator; //!< Iterator for various iteration operations.
+  
+  static Int_t fgInstanceCounter; //!< To build unique folder name for each instance
+  
+  ClassDef(AliMUONDataInterface, 0)  // An easy to use interface to MUON reconstructed data
 };
     
 
-#endif // ALI_MUON_DATA_INTERFACE_H
+#endif // ALIMUONDATAINTERFACE_H