#include "AliMUONGeometryTransformer.h"
#include "AliMUONVDigit.h"
#include "AliMUONVCluster.h"
-#include "AliMUONTrack.h"
#include "AliMUONLocalTrigger.h"
#include "AliMUONRegionalTrigger.h"
#include "AliMUONGlobalTrigger.h"
-#include "AliMUONTriggerTrack.h"
#include "AliMUONTriggerCircuit.h"
#include "AliMUONVClusterStore.h"
#include "AliMUONVDigitStore.h"
-#include "AliMUONVTrackStore.h"
#include "AliMUONVTriggerStore.h"
-#include "AliMUONVTriggerTrackStore.h"
#include "AliMpCDB.h"
-#include "AliMpIntPair.h"
+#include "AliMpEncodePair.h"
#include "AliMpDEManager.h"
#include "AliMpConstants.h"
#include "AliMpCDB.h"
#include "AliLoader.h"
-#include "AliLog.h"
#include "AliRunLoader.h"
+#include "AliHeader.h"
+#include "AliCDBManager.h"
+#include "AliLog.h"
-#include <TError.h>
-#include <TParticle.h>
#include <Riostream.h>
#include <TFile.h>
#include <TList.h>
/// \class AliMUONDataInterface
///
/// An easy to use interface to the MUON data data stored in
-/// TreeS, TreeD, TreeR and TreeT.
+/// TreeS, TreeD and TreeR.
///
/// For MC related information (i.e. TreeH, TreeK, TreeTR), see
/// AliMUONMCDataInterface.
fDigitStore(0x0),
fTriggerStore(0x0),
fClusterStore(0x0),
-fTrackStore(0x0),
-fTriggerTrackStore(0x0),
fCurrentEvent(-1),
+fTreeLetter(""),
fIsValid(kFALSE),
fCurrentIteratorType(kNoIterator),
fCurrentIndex(-1),
++fgInstanceCounter;
+ if ( AliCDBManager::Instance() != NULL &&
+ AliCDBManager::Instance()->GetDefaultStorage() == NULL ) {
+ AliFatal("CDB default storage not defined.");
+ }
+
Open(filename);
// Load mapping
{
/// dtor
ResetStores();
- if ( fLoader != 0x0 )
- {
- delete fLoader->GetRunLoader();
- }
--fgInstanceCounter;
}
/// Return digitStore for a given event.
/// Return 0x0 if event not found.
/// Returned pointer should not be deleted
+ ///
+ /// \note If a previous store has been retrieved by one of the methods of
+ /// this class, but for a different event number, then those stores will
+ /// be deleted and no longer valid.
+ /// If you require access to the data for the earlier retrieved store,
+ /// but for different events, then you should deep copy / clone the object.
if (not IsValid()) return 0x0;
- if (event == fCurrentEvent and fDigitStore != 0x0) return fDigitStore;
- ResetStores();
- if (not LoadEvent(event)) return 0x0;
+ if (event == fCurrentEvent)
+ {
+ if (fDigitStore != 0x0)
+ return fDigitStore;
+ }
+ else
+ {
+ ResetStores();
+ if ( not LoadEvent(event) ) return 0x0;
+ }
fLoader->LoadDigits();
/// Return clusterStore for a given event.
/// Return 0x0 if event not found.
/// Returned pointer should not be deleted
+ ///
+ /// \note If a previous store has been retrieved by one of the methods of
+ /// this class, but for a different event number, then those stores will
+ /// be deleted and no longer valid.
+ /// If you require access to the data for the earlier retrieved store,
+ /// but for different events, then you should deep copy / clone the object.
if (not IsValid()) return 0x0;
- if (event == fCurrentEvent and fClusterStore != 0x0) return fClusterStore;
- ResetStores();
- if (not LoadEvent(event)) return 0x0;
+ if (event == fCurrentEvent)
+ {
+ if (fClusterStore != 0x0)
+ return fClusterStore;
+ }
+ else
+ {
+ ResetStores();
+ if ( not LoadEvent(event) ) return 0x0;
+ }
fLoader->LoadRecPoints();
return fClusterStore;
}
-//______________________________________________________________________________
-AliMUONVTrackStore*
-AliMUONDataInterface::TrackStore(Int_t event)
-{
- /// Return the trackStore for a given event.
- /// Return 0x0 if event not found.
- /// Returned pointer should not be deleted
-
- if (not IsValid()) return 0x0;
- if (event == fCurrentEvent and fTrackStore != 0x0) return fTrackStore;
-
- ResetStores();
- if (not LoadEvent(event)) return 0x0;
-
- fLoader->LoadTracks();
-
- TTree* treeT = fLoader->TreeT();
- if (treeT == 0x0)
- {
- AliError("Could not get treeT");
- return 0x0;
- }
-
- fTrackStore = AliMUONVTrackStore::Create(*treeT);
- if ( fTrackStore != 0x0 )
- {
- fTrackStore->Clear();
- fTrackStore->Connect(*treeT);
- treeT->GetEvent(0);
- }
-
- fLoader->UnloadTracks();
-
- return fTrackStore;
-}
-
-//______________________________________________________________________________
-AliMUONVTriggerTrackStore*
-AliMUONDataInterface::TriggerTrackStore(Int_t event)
-{
- /// Return the triggerTrackStore for a given event.
- /// Return 0x0 if event not found.
- /// Returned pointer should not be deleted
-
- if (not IsValid()) return 0x0;
- if (event == fCurrentEvent and fTriggerTrackStore != 0x0) return fTriggerTrackStore;
-
- ResetStores();
- if (not LoadEvent(event)) return 0x0;
-
- fLoader->LoadTracks();
-
- TTree* treeT = fLoader->TreeT();
- if (treeT == 0x0)
- {
- AliError("Could not get treeT");
- return 0x0;
- }
-
- fTriggerTrackStore = AliMUONVTriggerTrackStore::Create(*treeT);
- if ( fTriggerTrackStore != 0x0 )
- {
- fTriggerTrackStore->Clear();
- fTriggerTrackStore->Connect(*treeT);
- treeT->GetEvent(0);
- }
-
- fLoader->UnloadTracks();
-
- return fTriggerTrackStore;
-}
-
//_____________________________________________________________________________
AliMUONVTriggerStore*
AliMUONDataInterface::TriggerStore(Int_t event, const char* treeLetter)
/// Return 0x0 if event not found.
/// Returned pointer should not be deleted
/// treeLetter can be R or D to tell from which tree to read the information
+ ///
+ /// \note If a previous store has been retrieved by one of the methods of
+ /// this class, but for a different event number, then those stores will
+ /// be deleted and no longer valid.
+ /// If you require access to the data for the earlier retrieved store,
+ /// but for different events, then you should deep copy / clone the object.
if (not IsValid()) return 0x0;
- if (event == fCurrentEvent and fTriggerStore != 0x0) return fTriggerStore;
- ResetStores();
- if (not LoadEvent(event)) return 0x0;
+ if (event == fCurrentEvent)
+ {
+ if (fTreeLetter == treeLetter)
+ {
+ if (fTriggerStore != 0x0)
+ return fTriggerStore;
+ }
+ else
+ {
+ // Reset only the fTriggerStore since the others might still be valid
+ // for the same event.
+ if (fTriggerStore != 0x0)
+ {
+ delete fTriggerStore;
+ fTriggerStore = 0x0;
+ }
+ }
+ }
+ else
+ {
+ // Event has changed so reset all the stores.
+ ResetStores();
+ if ( not LoadEvent(event) ) return 0x0;
+ }
TTree* tree(0x0);
{
fLoader->UnloadRecPoints();
}
+ fTreeLetter = stree;
return fTriggerStore;
}
list.Print();
}
-//______________________________________________________________________________
-void
-AliMUONDataInterface::DumpTracks(Int_t event, Bool_t sorted)
-{
- /// Dump tracks for a given event, sorted if requested
-
- TrackStore(event);
-
- if ( fTrackStore != 0x0 )
- {
- if ( sorted )
- {
- DumpSorted(*fTrackStore);
- }
- else
- {
- fTrackStore->Print();
- }
- }
-}
-
-//______________________________________________________________________________
-void
-AliMUONDataInterface::DumpTriggerTracks(Int_t event, Bool_t sorted)
-{
- /// Dump trigger tracks for a given event, sorted if requested
-
- TriggerTrackStore(event);
-
- if ( fTriggerTrackStore != 0x0 )
- {
- if ( sorted )
- {
- DumpSorted(*fTriggerTrackStore);
- }
- else
- {
- fTriggerTrackStore->Print();
- }
- }
-}
-
//_____________________________________________________________________________
void
AliMUONDataInterface::DumpTrigger(Int_t event, const char* treeLetter)
AliMUONLocalTrigger* locTrg(0x0);
while ( ( locTrg = static_cast<AliMUONLocalTrigger*>(next()) ) )
{
- Bool_t xTrig=kFALSE;
- Bool_t yTrig=kFALSE;
-
- if ( locTrg->LoSdev()==1 && locTrg->LoDev()==0 &&
- locTrg->LoStripX()==0) xTrig=kFALSE; // no trigger in X
- else xTrig=kTRUE; // trigger in X
- if (locTrg->LoTrigY()==1 &&
- locTrg->LoStripY()==15 ) yTrig = kFALSE; // no trigger in Y
- else yTrig = kTRUE; // trigger in Y
+ Bool_t xTrig=locTrg->IsTrigX();
+ Bool_t yTrig=locTrg->IsTrigY();
if (xTrig && yTrig)
{ // fill ntuple if trigger in X and Y
{
AliError(Form("Cannot open file %s",filename));
fIsValid = kFALSE;
+ return;
}
+
+ runLoader->LoadHeader();
+ if ( ! runLoader->GetHeader() ) {
+ AliError("Cannot load header.");
+ fIsValid = kFALSE;
+ }
+ else {
+ Int_t runNumber = runLoader->GetHeader()->GetRun();
+ AliCDBManager::Instance()->SetRun(runNumber>=0 ? runNumber : 1);
+ }
+ runLoader->UnloadHeader();
+
fLoader = runLoader->GetDetectorLoader("MUON");
if (fLoader == 0x0)
{
if (DigitStore(event) == 0x0) return kFALSE;
if (ClusterStore(event) == 0x0) return kFALSE;
- if (TrackStore(event) == 0x0) return kFALSE;
if (TriggerStore(event) == 0x0) return kFALSE;
- if (TriggerTrackStore(event) == 0x0) return kFALSE;
return kTRUE;
}
return static_cast<AliMUONVCluster*>( FetchObject(iter, index) );
}
-//_____________________________________________________________________________
-Int_t AliMUONDataInterface::NumberOfTracks()
-{
-/// Returns the number of reconstructed tracks.
-
- TIterator* iter = GetIterator(kTrackIterator);
- return CountObjects(iter);
-}
-
-//_____________________________________________________________________________
-AliMUONTrack* AliMUONDataInterface::Track(Int_t index)
-{
-/// Returns a pointer to the index'th reconstructed track.
-/// @param index The index number of the track to fetch in the range [0 .. N-1],
-/// where N = NumberOfTracks()
-
- TIterator* iter = GetIterator(kTrackIterator);
- return static_cast<AliMUONTrack*>( FetchObject(iter, index) );
-}
-
//_____________________________________________________________________________
Int_t AliMUONDataInterface::NumberOfLocalTriggers()
{
return store->Global();
}
-//_____________________________________________________________________________
-Int_t AliMUONDataInterface::NumberOfTriggerTracks()
-{
-/// Returns the number of reconstructed tracks in the trigger chambers.
-
- TIterator* iter = GetIterator(kTriggerTrackIterator);
- return CountObjects(iter);
-}
-
-//_____________________________________________________________________________
-AliMUONTriggerTrack* AliMUONDataInterface::TriggerTrack(Int_t index)
-{
-/// Returns a pointer to the index'th reconstructed trigger track object.
-/// @param index The index number of the trigger track to fetch in the range [0 .. N-1],
-/// where N = NumberOfTriggerTracks()
-
- TIterator* iter = GetIterator(kTriggerTrackIterator);
- return static_cast<AliMUONTriggerTrack*>( FetchObject(iter, index) );
-}
-
//_____________________________________________________________________________
void AliMUONDataInterface::ResetStores()
{
delete fClusterStore;
fClusterStore = 0x0;
}
- if (fTrackStore != 0x0)
- {
- delete fTrackStore;
- fTrackStore = 0x0;
- }
- if (fTriggerTrackStore != 0x0)
- {
- delete fTriggerTrackStore;
- fTriggerTrackStore = 0x0;
- }
}
//_____________________________________________________________________________
AliMUONVDigitStore* store = DigitStore(fCurrentEvent);
if (store == 0x0) return 0x0;
- AliMpIntPair pair = AliMpDEManager::GetDetElemIdRange(chamber);
- fIterator = store->CreateIterator(pair.GetFirst(), pair.GetSecond(), cathode);
+ MpPair_t pair = AliMpDEManager::GetDetElemIdRange(chamber);
+ fIterator = store->CreateIterator(AliMp::PairFirst(pair), AliMp::PairSecond(pair), cathode);
if (fIterator == 0x0) return 0x0;
fCurrentIteratorType = kDigitIteratorByChamberAndCathode;
fDataX = chamber;
return fIterator;
}
- case kTrackIterator:
- {
- AliMUONVTrackStore* store = TrackStore(fCurrentEvent);
- if (store == 0x0) return 0x0;
- fIterator = store->CreateIterator();
- if (fIterator == 0x0) return 0x0;
- fCurrentIteratorType = kTrackIterator;
- return fIterator;
- }
-
case kLocalTriggerIterator:
{
AliMUONVTriggerStore* store = TriggerStore(fCurrentEvent);
return fIterator;
}
- case kTriggerTrackIterator:
- {
- AliMUONVTriggerTrackStore* store = TriggerTrackStore(fCurrentEvent);
- if (store == 0x0) return 0x0;
- fIterator = store->CreateIterator();
- if (fIterator == 0x0) return 0x0;
- fCurrentIteratorType = kTriggerTrackIterator;
- return fIterator;
- }
-
default:
return 0x0;
}