From f6e5d0e9a4551ef56da9c7d4f0d99dfc32c37e43 Mon Sep 17 00:00:00 2001 From: ivana Date: Tue, 31 Jan 2006 16:37:04 +0000 Subject: [PATCH] Basic implementation of AliMUONVNDStore containers, using AliMpExMap internally. Should be revised for better performance... (Laurent) --- MUON/AliMUON1DMap.cxx | 71 ++++++++++++++++++++++++++++++ MUON/AliMUON1DMap.h | 38 ++++++++++++++++ MUON/AliMUON2DMap.cxx | 100 ++++++++++++++++++++++++++++++++++++++++++ MUON/AliMUON2DMap.h | 40 +++++++++++++++++ MUON/AliMUON3DMap.cxx | 75 +++++++++++++++++++++++++++++++ MUON/AliMUON3DMap.h | 40 +++++++++++++++++ 6 files changed, 364 insertions(+) create mode 100644 MUON/AliMUON1DMap.cxx create mode 100644 MUON/AliMUON1DMap.h create mode 100644 MUON/AliMUON2DMap.cxx create mode 100644 MUON/AliMUON2DMap.h create mode 100644 MUON/AliMUON3DMap.cxx create mode 100644 MUON/AliMUON3DMap.h diff --git a/MUON/AliMUON1DMap.cxx b/MUON/AliMUON1DMap.cxx new file mode 100644 index 00000000000..c97bb5af98f --- /dev/null +++ b/MUON/AliMUON1DMap.cxx @@ -0,0 +1,71 @@ +/************************************************************************** +* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * +* * +* Author: The ALICE Off-line Project. * +* Contributors are mentioned in the code where appropriate. * +* * +* Permission to use, copy, modify and distribute this software and its * +* documentation strictly for non-commercial purposes is hereby granted * +* without fee, provided that the above copyright notice appears in all * +* copies and that both the copyright notice and this permission notice * +* appear in the supporting documentation. The authors make no claims * +* about the suitability of this software for any purpose. It is * +* provided "as is" without express or implied warranty. * +**************************************************************************/ + +// $Id$ + +#include "AliMUON1DMap.h" + +#include "AliLog.h" +#include "AliMpExMap.h" + +ClassImp(AliMUON1DMap) + +//_____________________________________________________________________________ +AliMUON1DMap::AliMUON1DMap() : AliMUONV1DStore(), fMap(new AliMpExMap(true)) +{ +} + +//_____________________________________________________________________________ +AliMUON1DMap::~AliMUON1DMap() +{ + delete fMap; +} + +//_____________________________________________________________________________ +TObject* +AliMUON1DMap::Get(Int_t detElemId) const +{ + return fMap->GetValue(detElemId); +} + +//_____________________________________________________________________________ +Bool_t +AliMUON1DMap::IsOwner() const +{ + return kTRUE; +} + +//_____________________________________________________________________________ +Bool_t +AliMUON1DMap::Set(Int_t detElemId, TObject* object, Bool_t replace) +{ + TObject* o = Get(detElemId); + if ( o && !replace ) + { + AliError(Form("Object %p is already there for detElemId %d",o,detElemId)); + return kFALSE; + } + if ( o && IsOwner() ) + { + delete o; + } + fMap->Add(detElemId,object); + return kTRUE; +} + + + + + diff --git a/MUON/AliMUON1DMap.h b/MUON/AliMUON1DMap.h new file mode 100644 index 00000000000..bd09449ebb0 --- /dev/null +++ b/MUON/AliMUON1DMap.h @@ -0,0 +1,38 @@ +/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * +* See cxx source for full Copyright notice */ + +// $Id$ + +/// \ingroup +/// \class AliMUONDeMap +/// \brief Basic implementation of AliMUONV1DStore container using +/// AliMpExMap internally +/// +/// Should be revised for better preformance ... +/// +/// \author Laurent Aphecetche + +#ifndef AliMUON1DMAP_H +#define AliMUON1DMAP_H + +class AliMpExMap; + +#include "AliMUONV1DStore.h" + +class AliMUON1DMap : public AliMUONV1DStore +{ +public: + AliMUON1DMap(); + virtual ~AliMUON1DMap(); + + virtual TObject* Get(Int_t detElemId) const; + virtual Bool_t Set(Int_t detElemId, TObject* object, Bool_t replace=kTRUE); + virtual Bool_t IsOwner() const; + +private: + AliMpExMap* fMap; + + ClassDef(AliMUON1DMap,1) // +}; + +#endif diff --git a/MUON/AliMUON2DMap.cxx b/MUON/AliMUON2DMap.cxx new file mode 100644 index 00000000000..6c5cce64cbd --- /dev/null +++ b/MUON/AliMUON2DMap.cxx @@ -0,0 +1,100 @@ +/************************************************************************** +* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * +* * +* Author: The ALICE Off-line Project. * +* Contributors are mentioned in the code where appropriate. * +* * +* Permission to use, copy, modify and distribute this software and its * +* documentation strictly for non-commercial purposes is hereby granted * +* without fee, provided that the above copyright notice appears in all * +* copies and that both the copyright notice and this permission notice * +* appear in the supporting documentation. The authors make no claims * +* about the suitability of this software for any purpose. It is * +* provided "as is" without express or implied warranty. * +**************************************************************************/ + +// $Id$ + +#include "AliMUON2DMap.h" + +#include "AliLog.h" +#include "AliMpExMap.h" + +#include + +ClassImp(AliMUON2DMap) + +//_____________________________________________________________________________ +AliMUON2DMap::AliMUON2DMap() : AliMUONV2DStore(), fMap(new AliMpExMap(true)) +{ +} + +//_____________________________________________________________________________ +AliMUON2DMap::~AliMUON2DMap() +{ + delete fMap; +} + +//_____________________________________________________________________________ +TObject* +AliMUON2DMap::Get(Int_t i, Int_t j) const +{ + TObject* o = fMap->GetValue(i); + if ( o ) + { + AliMpExMap* m = dynamic_cast(o); + if (!m) AliFatal(Form("fMap[%d] not of the expected type",i)); + return m->GetValue(j); + } + return 0x0; +} + +//_____________________________________________________________________________ +Bool_t +AliMUON2DMap::IsOwner() const +{ + return kTRUE; +} + +//_____________________________________________________________________________ +void +AliMUON2DMap::Print(Option_t*) const +{ + +} + +//_____________________________________________________________________________ +Bool_t +AliMUON2DMap::Set(Int_t i, Int_t j, TObject* object, Bool_t replace) +{ + TObject* o = fMap->GetValue(i); + if ( !o ) + { + AliMpExMap* m = new AliMpExMap(true); + fMap->Add(i,m); + o = fMap->GetValue(i); + assert(m==o); + } + AliMpExMap* m = dynamic_cast(o); + if (!m) AliFatal(Form("fMap[%d] not of the expected type",i)); + o = m->GetValue(j); + if ( !o || ( o && replace ) ) + { + if ( IsOwner() ) + { + delete o; + } + m->Add(j,object); + } + else if ( o && !replace ) + { + AliError(Form("Object %p is already there for (i,j)=(%d,%d)",o,i,j)); + return kFALSE; + } + return kTRUE; +} + + + + + diff --git a/MUON/AliMUON2DMap.h b/MUON/AliMUON2DMap.h new file mode 100644 index 00000000000..413e26b61bb --- /dev/null +++ b/MUON/AliMUON2DMap.h @@ -0,0 +1,40 @@ +/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * +* See cxx source for full Copyright notice */ + +// $Id$ + +/// \ingroup base +/// \class AliMUON2DMap +/// \brief Basic implementation of AliMUONV2DStore container using +/// AliMpExMap internally +/// +/// Should be revised for better preformance ... +/// +/// \author Laurent Aphecetche + +#ifndef AliMUON2DMAP_H +#define AliMUON2DMAP_H + +#include "AliMUONV2DStore.h" + +class AliMpExMap; + +class AliMUON2DMap : public AliMUONV2DStore +{ +public: + AliMUON2DMap(); + virtual ~AliMUON2DMap(); + + virtual TObject* Get(Int_t i, Int_t j) const; + virtual Bool_t Set(Int_t i, Int_t j, TObject*, Bool_t replace); + virtual Bool_t IsOwner() const; + + virtual void Print(Option_t* opt="") const; + +private: + AliMpExMap* fMap; + + ClassDef(AliMUON2DMap,1) // +}; + +#endif diff --git a/MUON/AliMUON3DMap.cxx b/MUON/AliMUON3DMap.cxx new file mode 100644 index 00000000000..86fb9c536ef --- /dev/null +++ b/MUON/AliMUON3DMap.cxx @@ -0,0 +1,75 @@ +/************************************************************************** +* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * +* * +* Author: The ALICE Off-line Project. * +* Contributors are mentioned in the code where appropriate. * +* * +* Permission to use, copy, modify and distribute this software and its * +* documentation strictly for non-commercial purposes is hereby granted * +* without fee, provided that the above copyright notice appears in all * +* copies and that both the copyright notice and this permission notice * +* appear in the supporting documentation. The authors make no claims * +* about the suitability of this software for any purpose. It is * +* provided "as is" without express or implied warranty. * +**************************************************************************/ + +// $Id$ + +#include "AliMUON3DMap.h" + +ClassImp(AliMUON3DMap) + +#include "AliMUON1DMap.h" +#include "AliMUON2DMap.h" + +#include "Riostream.h" + +//_____________________________________________________________________________ +AliMUON3DMap::AliMUON3DMap() : AliMUONV3DStore(), fStore(new AliMUON1DMap) +{ +} + +//_____________________________________________________________________________ +AliMUON3DMap::~AliMUON3DMap() +{ + delete fStore; +} + +//_____________________________________________________________________________ +TObject* +AliMUON3DMap::Get(Int_t i, Int_t j, Int_t k) const +{ + AliMUONV2DStore* m = static_cast(fStore->Get(i)); + if (!m) return 0x0; + return m->Get(j,k); +} + +//_____________________________________________________________________________ +Bool_t +AliMUON3DMap::IsOwner() const +{ + return kTRUE; +} + +//_____________________________________________________________________________ +void +AliMUON3DMap::Print(Option_t*) const +{ + cout << "Would need an iterator here to be able to print !" << endl; +} + +//_____________________________________________________________________________ +Bool_t +AliMUON3DMap::Set(Int_t i, Int_t j, Int_t k, TObject* object, Bool_t replace) +{ + AliMUONV2DStore* m = static_cast(fStore->Get(i)); + if (!m) + { + fStore->Set(i,new AliMUON2DMap,replace); + m = static_cast(fStore->Get(i)); + } + return m->Set(j,k,object,replace); +} + + + diff --git a/MUON/AliMUON3DMap.h b/MUON/AliMUON3DMap.h new file mode 100644 index 00000000000..826b682209a --- /dev/null +++ b/MUON/AliMUON3DMap.h @@ -0,0 +1,40 @@ +/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * +* See cxx source for full Copyright notice */ + +// $Id$ + +/// \ingroup base +/// \class AliMUON3DMap +/// \brief Basic implementation of AliMUONV3DStore container using +/// AliMpExMap internally +/// +/// Should be revised for better preformance ... +/// +/// \author Laurent Aphecetche + +#ifndef ALIMUON3DMAP_H +#define ALIMUON3DMAP_H + +#ifndef ALIMUONV3DSTORE_H +# include "AliMUONV3DStore.h" +#endif + +class AliMUONV1DStore; + +class AliMUON3DMap : public AliMUONV3DStore +{ +public: + AliMUON3DMap(); + virtual ~AliMUON3DMap(); + + virtual TObject* Get(Int_t i, Int_t j, Int_t k) const; + virtual Bool_t Set(Int_t i, Int_t j, Int_t k, TObject*, Bool_t replace); + virtual Bool_t IsOwner() const; + virtual void Print(Option_t* opt="") const; + +private: + AliMUONV1DStore* fStore; + ClassDef(AliMUON3DMap,1) // +}; + +#endif -- 2.39.3