#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>
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")
fDigitAddressSet = kFALSE;
fClusterAddressSet = kFALSE;
fTriggerAddressSet = kFALSE;
+ fRecTracksAddressSet = kFALSE;
}
Bool_t AliMUONDataInterface::FetchMuonLoader(TString filename, TString foldername)
{
+ // fetches the muon loader for the given filename/foldername
+
fMuonloader = fRunloader->GetLoader("MUONLoader");
if (fMuonloader == NULL)
{
fDigitAddressSet = kFALSE;
fClusterAddressSet = kFALSE;
fTriggerAddressSet = kFALSE;
+ fRecTracksAddressSet = kFALSE;
}
if ( event != fEventnumber )
{
fDigitAddressSet = kFALSE;
fClusterAddressSet = kFALSE;
fTriggerAddressSet = kFALSE;
+ fRecTracksAddressSet = kFALSE;
}
return kTRUE;
}
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.
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.
}
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));
+}