]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/AliMUON1DArray.cxx
Minor fixes in the event tag to take into account the new way of storing the trigger...
[u/mrichter/AliRoot.git] / MUON / AliMUON1DArray.cxx
CommitLineData
70b4a8d6 1/**************************************************************************
2* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3* *
4* Author: The ALICE Off-line Project. *
5* Contributors are mentioned in the code where appropriate. *
6* *
7* Permission to use, copy, modify and distribute this software and its *
8* documentation strictly for non-commercial purposes is hereby granted *
9* without fee, provided that the above copyright notice appears in all *
10* copies and that both the copyright notice and this permission notice *
11* appear in the supporting documentation. The authors make no claims *
12* about the suitability of this software for any purpose. It is *
13* provided "as is" without express or implied warranty. *
14**************************************************************************/
15
16// $Id$
17
18#include "AliMUON1DArray.h"
19
20#include "AliLog.h"
21#include "TObjArray.h"
22
23///
24/// This class is simply a wrapper to a TObjArray, offering in addition a
25/// control over the replacement policy when you add
26/// something to it.
27///
28
29ClassImp(AliMUON1DArray)
30
31//_____________________________________________________________________________
32AliMUON1DArray::AliMUON1DArray(Int_t theSize)
33: AliMUONV1DStore(),
34 fArray(0x0)
35{
36 //
37 // Default ctor
38 //
39 if ( theSize )
40 {
41 fArray = new TObjArray(theSize);
42 }
43}
44
45//_____________________________________________________________________________
46AliMUON1DArray::AliMUON1DArray(const AliMUON1DArray& other)
47: AliMUONV1DStore(),
48 fArray(0x0)
49{
50 other.CopyTo(*this);
51}
52
53//_____________________________________________________________________________
54AliMUON1DArray&
55AliMUON1DArray::operator=(const AliMUON1DArray& other)
56{
57 other.CopyTo(*this);
58 return *this;
59}
60
61//_____________________________________________________________________________
62AliMUON1DArray::~AliMUON1DArray()
63{
64 //
65 // dtor, we're the owner of our internal array.
66 //
67 delete fArray;
68}
69
70//_____________________________________________________________________________
71void
72AliMUON1DArray::CopyTo(AliMUON1DArray& dest) const
73{
74 //
75 // Make a deep copy
76 //
77 delete dest.fArray;
78 dest.fArray = new TObjArray;
79 dest.fArray->SetOwner(kTRUE);
80 for ( Int_t i = 0; i < fArray->GetLast(); ++i )
81 {
82 dest.fArray->AddAt(fArray->At(i)->Clone(),i);
83 }
84}
85
86//_____________________________________________________________________________
87TObject*
88AliMUON1DArray::Get(Int_t i) const
89{
90 //
91 // Get the object located at index i, if it exists, and if i is correct.
92 //
93 if ( i >= 0 && i < fArray->GetSize() )
94 {
95 return fArray->At(i);
96 }
97 AliError(Form("Index %d out of bounds (max %d)",i,fArray->GetSize()));
98 return 0x0;
99}
100
101//_____________________________________________________________________________
102Bool_t
103AliMUON1DArray::Set(Int_t i, TObject* object, Bool_t replace)
104{
105 //
106 // Set the object located at i
107 // If replace=kFALSE and there's already an object at location i,
108 // this method fails and returns kFALSE, otherwise it returns kTRUE
109 //
110 if ( i >= 0 && i < fArray->GetSize() )
111 {
112 TObject* o = Get(i);
113 if ( o && !replace )
114 {
115 AliError(Form("Object %p is already there for i=%d",o,i));
116 return kFALSE;
117 }
118 if ( replace )
119 {
120 delete o;
121 }
122 fArray->AddAt(object,i);
123 return kTRUE;
124 }
125 AliError(Form("Index %d out of bounds (max %d)",i,fArray->GetSize()));
126 return kFALSE;
127}
128
129
130