]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - MUON/AliMUONDataInterface.cxx
Removed classes with new classes for raw data
[u/mrichter/AliRoot.git] / MUON / AliMUONDataInterface.cxx
index 4ca6f7df80404356b47ac869d966c9b54645274d..ed6062c67eaa8f9d92ff4f33326215d4b838b9b8 100644 (file)
 
 #include "AliMUONDataInterface.h"
 #include "AliMUONLocalTrigger.h"
+#include "AliMUONGlobalTrigger.h"
 #include "AliMUONHit.h"
 #include "AliMUONDigit.h"
 #include "AliMUONRawCluster.h"
+#include "AliMUONTrack.h"
 #include "AliLog.h"
 
 #include <iostream>
@@ -22,6 +24,30 @@ using std::cout;
 
 ClassImp(AliMUONDataInterface)
 
+///
+/// \class AliMUONDataInterface
+///
+/// An easy to use interface to the MUON module data stored in
+/// TreeK, TreeH, TreeS, TreeD and TreeR
+/// One can fetch any of the data objects with all the calls to runloader, 
+/// muon loader and AliMUONData done behind the scenes and automatically.
+///
+/// This interface in not necessarily the fastest way to fetch the data but
+/// it is the easiest.
+/// Note: If independant calls to the run loader, muon loader or 
+/// AliMUONData objects are interspersed with calls to the 
+/// AliMUONDataInterface to fetch data, one might need to call the Reset 
+/// method between these method calls at some point to prevent 
+/// AliMUONDataInterface from getting confused.
+/// This is necessary since this object assumes the state of runloader,
+/// muon loader nor AliMUONData has not changed between calls.
+/// If the state has changes then one must call Reset so that 
+/// AliMUONDataInterface refreshes what it knows about the state
+/// of the loader and AliMUONData objects.
+///
+/// \deprecated We have to revisit all this AliMUONData stuff anyway,
+/// and probably make a real AliMUONLoader instead...
+///
 
 AliMUONDataInterface::AliMUONDataInterface()
        : TObject(), fData(NULL, "MUON", "MUON")
@@ -80,6 +106,7 @@ void AliMUONDataInterface::Reset()
        fDigitAddressSet = kFALSE;
        fClusterAddressSet = kFALSE;
        fTriggerAddressSet = kFALSE;
+       fRecTracksAddressSet = kFALSE;
 }
 
 
@@ -108,6 +135,8 @@ Bool_t AliMUONDataInterface::UseCurrentRunLoader()
 
 Bool_t AliMUONDataInterface::FetchMuonLoader(TString filename, TString foldername)
 {
+  // fetches the muon loader for the given filename/foldername
+
        fMuonloader = fRunloader->GetLoader("MUONLoader");
        if (fMuonloader == NULL)
        {
@@ -208,6 +237,7 @@ Bool_t AliMUONDataInterface::FetchEvent(Int_t event)
                fDigitAddressSet = kFALSE;
                fClusterAddressSet = kFALSE;
                fTriggerAddressSet = kFALSE;
+               fRecTracksAddressSet = kFALSE;
        }
        if ( event != fEventnumber )
        {
@@ -221,6 +251,7 @@ Bool_t AliMUONDataInterface::FetchEvent(Int_t event)
                fDigitAddressSet = kFALSE;
                fClusterAddressSet = kFALSE;
                fTriggerAddressSet = kFALSE;
+               fRecTracksAddressSet = kFALSE;
        }
        return kTRUE;
 }
@@ -320,27 +351,46 @@ Bool_t AliMUONDataInterface::FetchTreeD()
 
 Bool_t AliMUONDataInterface::FetchTreeR()
 {
-// Fetch the reconstructed objects tree from the current muon loader.
-// Note: The addresses must still be set. 
-
-       if (fMuonloader->TreeR() == NULL)
+  // Fetch the reconstructed objects tree from the current muon loader.
+  // Note: The addresses must still be set. 
+  
+  if (fMuonloader->TreeR() == NULL)
+    {
+      fMuonloader->LoadRecPoints("READ");
+      if (fMuonloader->TreeR() == NULL)
        {
-               fMuonloader->LoadRecPoints("READ");
-               if (fMuonloader->TreeR() == NULL)
-               {
-                       AliError("Could not load TreeR.");
-                       return kFALSE;
-               }
-               
-               // Need to reset these flags so that the cluster and trigger address
-               // gets reset after this method. 
-               fClusterAddressSet = kFALSE;
-               fTriggerAddressSet = kFALSE;
+         AliError("Could not load TreeR.");
+         return kFALSE;
        }
-       return kTRUE;
+      
+      // Need to reset these flags so that the cluster and trigger address
+      // gets reset after this method. 
+      fClusterAddressSet = kFALSE;
+      fTriggerAddressSet = kFALSE;
+    }
+  return kTRUE;
 }
 
-
+Bool_t AliMUONDataInterface::FetchTreeT()
+{
+  // fetch the reconstructed tracks tree from the current muon loader
+  // note : the addresses must still be set.
+  if (fMuonloader->TreeT() == NULL)
+    {
+      fMuonloader->LoadTracks("READ");
+      if (fMuonloader->TreeT() == NULL)
+       {
+         AliError("Could not load TreeT.");
+         return kFALSE;
+       }
+      
+      // Need to reset these flags so that the rec tracks address
+      // gets reset after this method. 
+      fRecTracksAddressSet = kFALSE;
+    }
+  return kTRUE;
+}
+  
 Int_t AliMUONDataInterface::NumberOfEvents(TString filename, TString foldername)
 {
 // Returns the number of events in the specified file/folder, and -1 on error.
@@ -622,7 +672,6 @@ AliMUONLocalTrigger* AliMUONDataInterface::LocalTrigger(
        return static_cast<AliMUONLocalTrigger*>( fData.LocalTrigger()->At(trigger) );
 }
 
-
 Bool_t AliMUONDataInterface::SetFile(TString filename, TString foldername)
 {
 // Set the current file and folder from which to fetch data.
@@ -1006,3 +1055,113 @@ AliMUONLocalTrigger* AliMUONDataInterface::LocalTrigger(Int_t trigger)
        }
        return static_cast<AliMUONLocalTrigger*>( fData.LocalTrigger()->At(trigger) );
 }
+
+Int_t AliMUONDataInterface::NumberOfGlobalTriggers()
+{
+  
+  // Get the number of local trigger objects in the current event.
+  // -1 is returned on error.
+  
+  if (fRunloader == NULL)
+    {
+      AliError("File not set.");
+      return -1;
+    }
+  if (fEventnumber < 0)
+    {
+      AliError("Event not chosen.");
+      return -1;
+    }
+  
+  if ( ! FetchTreeD() ) return -1;
+  if ( ! fTriggerAddressSet )
+    {
+      fData.SetTreeAddress("GLT");
+      fData.ResetTrigger();
+      fData.GetTriggerD();
+      fTriggerAddressSet = kTRUE;
+    }
+  return fData.GlobalTrigger()->GetEntriesFast();
+}
+
+AliMUONGlobalTrigger* AliMUONDataInterface::GlobalTrigger(Int_t trigger)
+{
+  // Fetch the specified local trigger object from the current event.
+  // NULL is returned on error.
+  
+  if (fRunloader == NULL)
+    {
+      AliError("File not set.");
+      return NULL;
+    }
+  if (fEventnumber < 0)
+    {
+      AliError( "Event not chosen.");
+      return NULL;
+    }
+  
+  if ( ! FetchTreeD() ) return NULL;
+  if ( ! fTriggerAddressSet )
+    {
+      fData.SetTreeAddress("GLT");
+      fData.ResetTrigger();
+      fData.GetTriggerD();
+      fTriggerAddressSet = kTRUE;
+    }
+  return static_cast<AliMUONGlobalTrigger*>( fData.GlobalTrigger()->At(trigger) );
+}
+
+Int_t AliMUONDataInterface::NumberOfRecTracks()
+{
+  // Fetch the number of reconstructed tracks from the current event.
+  // NULL is returned on error.
+  
+  if (fRunloader == NULL)
+    {
+      AliError("File not set.");
+      return -1;
+    }
+  if (fEventnumber < 0)
+    {
+      AliError( "Event not chosen.");
+      return -1;
+    }
+  
+  if ( ! FetchTreeT() ) return -1;
+  if ( ! fRecTracksAddressSet )
+    {
+      fData.SetTreeAddress("RT");
+      fData.ResetRecTracks();
+      fData.GetRecTracks();
+      fRecTracksAddressSet = kTRUE;
+    }
+  return fData.RecTracks()->GetEntriesFast();
+}
+
+AliMUONTrack* AliMUONDataInterface::RecTrack(Int_t rectrack)
+{
+  // Fetch the specified reconstructed track object from the current event.
+  // NULL is returned on error.
+  
+  if (fRunloader == NULL)
+    {
+      AliError("File not set.");
+      return NULL;
+    }
+  if (fEventnumber < 0)
+    {
+      AliError( "Event not chosen.");
+      return NULL;
+    }
+  
+  if ( ! FetchTreeT() ) return NULL;
+  if ( ! fRecTracksAddressSet )
+    {
+      fData.SetTreeAddress("RT");
+      fData.ResetRecTracks();
+      fData.GetRecTracks();
+      fRecTracksAddressSet = kTRUE;
+    }
+  return static_cast<AliMUONTrack*>( fData.RecTracks()->At(rectrack) );
+  // return (AliMUONTrack*)(fData.RecTracks()->At(rectrack));
+}