#include "AliMUONRawCluster.h"
#include "AliLog.h"
+#include <iostream>
+using std::endl;
+using std::cout;
+
ClassImp(AliMUONDataInterface)
AliMUONDataInterface::~AliMUONDataInterface()
{
-// Delete the runloader when done.
+// Delete the runloader if we created it.
// If the runloader is not to be deleted then call Reset just before
// the destructor is called.
- if (fRunloader != NULL)
+ if (fRunloader != NULL && fCreatedRunLoader)
delete fRunloader;
}
// Note: No resources are released!
// Specificaly AliRunLoader is not deleted.
+ fCreatedRunLoader = kFALSE;
fRunloader = NULL;
fMuonloader = NULL;
fEventnumber = -1;
}
+Bool_t AliMUONDataInterface::UseCurrentRunLoader()
+{
+// Tries to fetch the current runloader with AliRunLoader::GetRunLoader. If nothing is
+// currently loaded then kFALSE is returned and AliMUONDataInterface is reset.
+
+ Reset();
+ fRunloader = AliRunLoader::GetRunLoader();
+ if (fRunloader == NULL) return kFALSE;
+ // Fetch the current file name, folder name and event number.
+ fFilename = fRunloader->GetFileName();
+ fFoldername = fRunloader->GetEventFolder()->GetName();
+ fEventnumber = fRunloader->GetEventNumber();
+
+ if ( ! FetchMuonLoader(fFilename.Data(), fFoldername.Data()) )
+ {
+ Reset();
+ return kFALSE;
+ }
+
+ return kTRUE;
+}
+
+
+Bool_t AliMUONDataInterface::FetchMuonLoader(TString filename, TString foldername)
+{
+ fMuonloader = fRunloader->GetLoader("MUONLoader");
+ if (fMuonloader == NULL)
+ {
+ AliError(Form("Could not find the MUON loader in file: %s and folder: %s",
+ (const char*)filename, (const char*)foldername));
+ return kFALSE;
+ }
+
+ // Need to connect the muon loader to the AliMUONData object,
+ // else class to fData will return NULL.
+ fData.SetLoader(fMuonloader);
+ return kTRUE;
+}
+
+
Bool_t AliMUONDataInterface::LoadLoaders(TString filename, TString foldername)
{
// Load the run and muon loaders from the specified file and folder.
(const char*)filename, (const char*)foldername));
return kFALSE;
}
- fMuonloader = fRunloader->GetLoader("MUONLoader");
- if (fMuonloader == NULL)
+ fCreatedRunLoader = kTRUE;
+ if ( ! FetchMuonLoader(filename, foldername) )
{
- AliError(Form("Could not find the MUON loader in file: %s and folder: %s",
- (const char*)filename, (const char*)foldername));
fRunloader = NULL;
return kFALSE;
}
- // Need to connect the muon loader to the AliMUONData object,
- // else class to fData will return NULL.
- fData.SetLoader(fMuonloader);
-
fFilename = filename;
fFoldername = foldername;
fEventnumber = -1; // Reset the event number to force the event to be loaded.
fRunloader = AliRunLoader::GetRunLoader();
if (fRunloader == NULL)
return LoadLoaders(filename, foldername);
+ else
+ {
+ if (fMuonloader == NULL)
+ {
+ if ( ! FetchMuonLoader(filename, foldername) )
+ {
+ fRunloader = NULL;
+ return kFALSE;
+ }
+ }
+ }
// Fetch the current file and folder names.
fFilename = fRunloader->GetFileName();
{
// Fetch the specified event from the runloader and reset all the track, cathode
// and address flags to force them to be reloaded.
+// If a negative event number is specified then the current runloader event
+// number is used.
if (fEventnumber < 0)
{
if ( fSCathode != cathode )
{
fData.ResetSDigits();
- fData.GetCathodeS(cathode);
+ fData.GetSDigits();
fSCathode = cathode;
}
return fData.SDigits(chamber)->GetEntriesFast();
if ( fSCathode != cathode )
{
fData.ResetSDigits();
- fData.GetCathodeS(cathode);
+ fData.GetSDigits();
fSCathode = cathode;
}
return static_cast<AliMUONDigit*>( fData.SDigits(chamber)->At(sdigit) );
if ( fCathode != cathode )
{
fData.ResetDigits();
- fData.GetCathode(cathode);
+ fData.GetDigits();
fCathode = cathode;
}
return fData.Digits(chamber)->GetEntriesFast();
if ( fCathode != cathode )
{
fData.ResetDigits();
- fData.GetCathode(cathode);
+ fData.GetDigits();
fCathode = cathode;
}
return static_cast<AliMUONDigit*>( fData.Digits(chamber)->At(digit) );
if ( ! FetchLoaders(filename, foldername) ) return -1;
if ( ! FetchEvent(event) ) return -1;
- if ( ! FetchTreeR() ) return -1;
+ if ( ! FetchTreeD() ) return -1;
if ( ! fTriggerAddressSet )
{
// If the local trigger address in TreeR is not set yet then set it now.
fData.SetTreeAddress("GLT");
fData.ResetTrigger();
- fData.GetTrigger();
+ fData.GetTriggerD();
fTriggerAddressSet = kTRUE;
}
return fData.LocalTrigger()->GetEntriesFast();
if ( ! FetchLoaders(filename, foldername) ) return NULL;
if ( ! FetchEvent(event) ) return NULL;
- if ( ! FetchTreeR() ) return NULL;
+ if ( ! FetchTreeD() ) return NULL;
if ( ! fTriggerAddressSet )
{
// If the local trigger address in TreeR is not set yet then set it now.
fData.SetTreeAddress("GLT");
fData.ResetTrigger();
- fData.GetTrigger();
+ fData.GetTriggerD();
fTriggerAddressSet = kTRUE;
}
return static_cast<AliMUONLocalTrigger*>( fData.LocalTrigger()->At(trigger) );
if ( fSCathode != cathode )
{
fData.ResetSDigits();
- fData.GetCathodeS(cathode);
+ fData.GetSDigits();
fSCathode = cathode;
}
return fData.SDigits(chamber)->GetEntriesFast();
if ( fSCathode != cathode )
{
fData.ResetSDigits();
- fData.GetCathodeS(cathode);
+ fData.GetSDigits();
fSCathode = cathode;
}
return static_cast<AliMUONDigit*>( fData.SDigits(chamber)->At(sdigit) );
if ( fCathode != cathode )
{
fData.ResetDigits();
- fData.GetCathode(cathode);
+ fData.GetDigits();
fCathode = cathode;
}
return fData.Digits(chamber)->GetEntriesFast();
if ( fCathode != cathode )
{
fData.ResetDigits();
- fData.GetCathode(cathode);
+ fData.GetDigits();
fCathode = cathode;
}
return static_cast<AliMUONDigit*>( fData.Digits(chamber)->At(digit) );
return -1;
}
- if ( ! FetchTreeR() ) return -1;
+ if ( ! FetchTreeD() ) return -1;
if ( ! fTriggerAddressSet )
{
fData.SetTreeAddress("GLT");
fData.ResetTrigger();
- fData.GetTrigger();
+ fData.GetTriggerD();
fTriggerAddressSet = kTRUE;
}
return fData.LocalTrigger()->GetEntriesFast();
return NULL;
}
- if ( ! FetchTreeR() ) return NULL;
+ if ( ! FetchTreeD() ) return NULL;
if ( ! fTriggerAddressSet )
{
fData.SetTreeAddress("GLT");
fData.ResetTrigger();
- fData.GetTrigger();
+ fData.GetTriggerD();
fTriggerAddressSet = kTRUE;
}
return static_cast<AliMUONLocalTrigger*>( fData.LocalTrigger()->At(trigger) );