X-Git-Url: http://git.uio.no/git/?a=blobdiff_plain;f=MUON%2FAliMUONDataInterface.cxx;h=7aa2ccbaaa76c3cf9835db3c4f02176f3a67b2be;hb=bd0e81530434e60f06036a2ee112634aced4fe4d;hp=31ff500f4332447d94c15e08343ed0b2c2fcba8f;hpb=a55f49a01992f9b256e43a101357e2575981a0b3;p=u%2Fmrichter%2FAliRoot.git diff --git a/MUON/AliMUONDataInterface.cxx b/MUON/AliMUONDataInterface.cxx index 31ff500f433..7aa2ccbaaa7 100644 --- a/MUON/AliMUONDataInterface.cxx +++ b/MUON/AliMUONDataInterface.cxx @@ -18,18 +18,14 @@ #include "AliMUONDataInterface.h" #include "AliMUONGeometryTransformer.h" #include "AliMUONVDigit.h" -#include "AliMUONRawCluster.h" -#include "AliMUONTrack.h" +#include "AliMUONVCluster.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" @@ -40,6 +36,8 @@ #include "AliLoader.h" #include "AliLog.h" #include "AliRunLoader.h" +#include "AliHeader.h" +#include "AliCDBManager.h" #include #include @@ -56,7 +54,7 @@ /// \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. @@ -82,9 +80,8 @@ fLoader(0x0), fDigitStore(0x0), fTriggerStore(0x0), fClusterStore(0x0), -fTrackStore(0x0), -fTriggerTrackStore(0x0), fCurrentEvent(-1), +fTreeLetter(""), fIsValid(kFALSE), fCurrentIteratorType(kNoIterator), fCurrentIndex(-1), @@ -97,6 +94,11 @@ fIterator(0x0) ++fgInstanceCounter; + if ( AliCDBManager::Instance() != NULL && + AliCDBManager::Instance()->GetDefaultStorage() == NULL ) { + AliFatal("CDB default storage not defined."); + } + Open(filename); // Load mapping @@ -124,12 +126,25 @@ AliMUONDataInterface::DigitStore(Int_t event) /// 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(); @@ -160,12 +175,25 @@ AliMUONDataInterface::ClusterStore(Int_t event) /// 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(); @@ -189,78 +217,6 @@ AliMUONDataInterface::ClusterStore(Int_t event) 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) @@ -269,12 +225,39 @@ 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); @@ -314,6 +297,7 @@ AliMUONDataInterface::TriggerStore(Int_t event, const char* treeLetter) { fLoader->UnloadRecPoints(); } + fTreeLetter = stree; return fTriggerStore; } @@ -377,48 +361,6 @@ AliMUONDataInterface::DumpSorted(const AliMUONVStore& store) const 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) @@ -497,7 +439,7 @@ AliMUONDataInterface::NtupleTrigger(const char* treeLetter) { if (ievent%100==0) AliInfo(Form("Processing event %d\n",ievent)); - AliMUONVTriggerStore* triggerStore = TriggerStore(ievent); + AliMUONVTriggerStore* triggerStore = TriggerStore(ievent,treeLetter); if (!triggerStore) { @@ -519,15 +461,8 @@ AliMUONDataInterface::NtupleTrigger(const char* treeLetter) AliMUONLocalTrigger* locTrg(0x0); while ( ( locTrg = static_cast(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 @@ -633,6 +568,18 @@ AliMUONDataInterface::Open(const char* filename) AliError(Form("Cannot open file %s",filename)); fIsValid = kFALSE; } + + runLoader->LoadHeader(); + if ( ! runLoader->GetHeader() ) { + AliError("Cannot load header."); + fIsValid = kFALSE; + } + else { + Int_t runNumber = runLoader->GetHeader()->GetRun(); + AliCDBManager::Instance()->SetRun(runNumber); + } + runLoader->UnloadHeader(); + fLoader = runLoader->GetDetectorLoader("MUON"); if (fLoader == 0x0) { @@ -653,9 +600,7 @@ Bool_t AliMUONDataInterface::GetEvent(Int_t event) 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; } @@ -718,7 +663,7 @@ Int_t AliMUONDataInterface::NumberOfRawClusters(Int_t chamber) } //_____________________________________________________________________________ -AliMUONRawCluster* AliMUONDataInterface::RawCluster(Int_t chamber, Int_t index) +AliMUONVCluster* AliMUONDataInterface::RawCluster(Int_t chamber, Int_t index) { /// Returns a pointer to the index'th raw cluster on the specified chamber. /// @param chamber The chamber number in the range [0 .. 13]. @@ -726,27 +671,7 @@ AliMUONRawCluster* AliMUONDataInterface::RawCluster(Int_t chamber, Int_t index) /// where N = NumberOfRawClusters(chamber) TIterator* iter = GetIterator(kRawClusterIterator, chamber); - return static_cast( 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( FetchObject(iter, index) ); + return static_cast( FetchObject(iter, index) ); } //_____________________________________________________________________________ @@ -799,26 +724,6 @@ AliMUONGlobalTrigger* AliMUONDataInterface::GlobalTrigger() 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( FetchObject(iter, index) ); -} - //_____________________________________________________________________________ void AliMUONDataInterface::ResetStores() { @@ -841,16 +746,6 @@ void AliMUONDataInterface::ResetStores() delete fClusterStore; fClusterStore = 0x0; } - if (fTrackStore != 0x0) - { - delete fTrackStore; - fTrackStore = 0x0; - } - if (fTriggerTrackStore != 0x0) - { - delete fTriggerTrackStore; - fTriggerTrackStore = 0x0; - } } //_____________________________________________________________________________ @@ -936,16 +831,6 @@ TIterator* AliMUONDataInterface::GetIterator(IteratorType type, Int_t x, Int_t y 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); @@ -966,16 +851,6 @@ TIterator* AliMUONDataInterface::GetIterator(IteratorType type, Int_t x, Int_t y 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; }