From 46df197d13c70711d59cb354c0f12f1838a28c33 Mon Sep 17 00:00:00 2001 From: ivana Date: Fri, 25 Jul 2008 10:10:48 +0000 Subject: [PATCH] Fixes in MUON: - Fixing how the stores are reset in AliMUONDataInterface and adding some detail to the documentation. - Fixing bit packing bug in AliMUONRawWriter. - Adding protection code to AliMUONRecoCheck to check if the TParticlePDG* ppdg pointer is NULL or not. (Artur) --- MUON/AliMUONDataInterface.cxx | 73 +++++++++++++++++++++++++++++---- MUON/AliMUONDataInterface.h | 6 ++- MUON/AliMUONMCDataInterface.cxx | 36 ++++++++++++++++ MUON/AliMUONMCDataInterface.h | 6 ++- MUON/AliMUONRawWriter.cxx | 6 +-- MUON/AliMUONRecoCheck.cxx | 2 +- 6 files changed, 114 insertions(+), 15 deletions(-) diff --git a/MUON/AliMUONDataInterface.cxx b/MUON/AliMUONDataInterface.cxx index d6518cae4ca..7aa2ccbaaa7 100644 --- a/MUON/AliMUONDataInterface.cxx +++ b/MUON/AliMUONDataInterface.cxx @@ -81,6 +81,7 @@ fDigitStore(0x0), fTriggerStore(0x0), fClusterStore(0x0), fCurrentEvent(-1), +fTreeLetter(""), fIsValid(kFALSE), fCurrentIteratorType(kNoIterator), fCurrentIndex(-1), @@ -125,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(); @@ -161,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(); @@ -198,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); @@ -243,6 +297,7 @@ AliMUONDataInterface::TriggerStore(Int_t event, const char* treeLetter) { fLoader->UnloadRecPoints(); } + fTreeLetter = stree; return fTriggerStore; } diff --git a/MUON/AliMUONDataInterface.h b/MUON/AliMUONDataInterface.h index 657f23a31e6..183075d1745 100644 --- a/MUON/AliMUONDataInterface.h +++ b/MUON/AliMUONDataInterface.h @@ -17,6 +17,7 @@ // #include +#include class TIterator; class AliLoader; @@ -45,7 +46,9 @@ public: Int_t NumberOfEvents() const; - /// Returns the index number of the current event as used int GetEvent(Int_t). + /// Returns the index number of the current event loaded. + /// This is the event number as was used in the last calls to DigitStore(Int_t), + /// ClusterStore(Int_t), TriggerStore(Int_t) or GetEvent(Int_t). Int_t CurrentEvent() const { return fCurrentEvent; } AliMUONVDigitStore* DigitStore(Int_t event); @@ -115,6 +118,7 @@ private: AliMUONVTriggerStore* fTriggerStore; //!< current trigger store (owner) AliMUONVClusterStore* fClusterStore; //!< current cluster store (owner) Int_t fCurrentEvent; //!< Current event we've read in + TString fTreeLetter; //!< The tree letter used in the last call to TriggerStore(). Bool_t fIsValid; //!< whether we were initialized properly or not IteratorType fCurrentIteratorType; //!< The type of iterator that is currently set. diff --git a/MUON/AliMUONMCDataInterface.cxx b/MUON/AliMUONMCDataInterface.cxx index 3a3ca33e57a..ef54adcb17f 100644 --- a/MUON/AliMUONMCDataInterface.cxx +++ b/MUON/AliMUONMCDataInterface.cxx @@ -113,6 +113,12 @@ AliMUONMCDataInterface::HitStore(Int_t event, Int_t track) /// Return the hitStore for a given track of one event /// Return 0x0 if event and/or track 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; @@ -162,6 +168,12 @@ AliMUONMCDataInterface::SDigitStore(Int_t event) /// Return the SDigit store for a given event. /// Return 0 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; @@ -204,6 +216,12 @@ AliMUONMCDataInterface::DigitStore(Int_t event) { /// Return a pointer to the digitStore for a given event (or 0 if 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; @@ -246,6 +264,12 @@ AliMUONMCDataInterface::Stack(Int_t event) { /// Get the Stack (list of generated particles) for one event /// 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; @@ -266,6 +290,12 @@ AliMUONMCDataInterface::TrackRefs(Int_t event, Int_t track) { /// Get the track references for a given (generated) track of one event /// 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; @@ -313,6 +343,12 @@ AliMUONMCDataInterface::TriggerStore(Int_t event) /// Return the triggerStore 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; diff --git a/MUON/AliMUONMCDataInterface.h b/MUON/AliMUONMCDataInterface.h index ab39283c5ee..540c83752f6 100644 --- a/MUON/AliMUONMCDataInterface.h +++ b/MUON/AliMUONMCDataInterface.h @@ -48,7 +48,11 @@ public: Bool_t IsValid() const { return fIsValid; }; Int_t NumberOfEvents() const; - /// Returns the index number of the current event as used int GetEvent(Int_t). + + /// Returns the index number of the current event loaded. + /// This is the event number as was used in the last calls to any of the methods + /// in this interface that have 'Int_t event' in the parameter list. + /// GetEvent(Int_t event) for example. Int_t CurrentEvent() const { return fCurrentEvent; } Int_t NumberOfTracks(Int_t event); diff --git a/MUON/AliMUONRawWriter.cxx b/MUON/AliMUONRawWriter.cxx index 630df049a06..6b68fc4a195 100644 --- a/MUON/AliMUONRawWriter.cxx +++ b/MUON/AliMUONRawWriter.cxx @@ -594,9 +594,9 @@ Int_t AliMUONRawWriter::WriteTriggerDDL(const AliMUONVTriggerStore& triggerStore // fill darc word, not darc status for the moment (empty) //see AliMUONRegHeader.h for details AliBitPacking::PackWord((UInt_t)eventPhys,word,31,31); - AliBitPacking::PackWord((UInt_t)serialNb,word,19,24); - AliBitPacking::PackWord((UInt_t)version,word,7,14); - AliBitPacking::PackWord((UInt_t)iReg,word,15,18); + AliBitPacking::PackWord((UInt_t)serialNb,word,20,25); + AliBitPacking::PackWord((UInt_t)version,word,8,15); + AliBitPacking::PackWord((UInt_t)crate->GetId(),word,16,19); AliBitPacking::PackWord((UInt_t)regOut,word,0,7); fRegHeader->SetWord(word); diff --git a/MUON/AliMUONRecoCheck.cxx b/MUON/AliMUONRecoCheck.cxx index a2bc41a88ab..7bc85de0e1d 100644 --- a/MUON/AliMUONRecoCheck.cxx +++ b/MUON/AliMUONRecoCheck.cxx @@ -220,7 +220,7 @@ void AliMUONRecoCheck::MakeTrackRefs() // get the particle charge for further calculation TParticlePDG* ppdg = particle->GetPDG(); - Int_t charge = (Int_t)(ppdg->Charge()/3.0); + Int_t charge = ppdg != NULL ? (Int_t)(ppdg->Charge()/3.0) : 0; AliMUONTrack track; -- 2.43.0