]> git.uio.no Git - u/mrichter/AliRoot.git/blame - STEER/AliAODCaloCells.cxx
removing redundant checks for overlapping run-ranges
[u/mrichter/AliRoot.git] / STEER / AliAODCaloCells.cxx
CommitLineData
8d122774 1/**************************************************************************
2 * Copyright(c) 1998-2007, 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//-------------------------------------------------------------------------
19// AOD class to store calorimeter cell data
20// Author: Markus Oldenburg, CERN
21//-------------------------------------------------------------------------
22
23#include "AliAODCaloCells.h"
24
25ClassImp(AliAODCaloCells)
26
c8fe2783 27AliAODCaloCells::AliAODCaloCells() : AliVCaloCells(), fNCells(0), fCellNumber(0), fAmplitude(0), fIsSorted(kTRUE), fType(kUndef)
8d122774 28{
29 // default constructor
30}
31
c8fe2783 32AliAODCaloCells::AliAODCaloCells(const char* name, const char* title, VCells_t ttype) :
33 AliVCaloCells(name, title), fNCells(0), fCellNumber(0), fAmplitude(0), fIsSorted(kTRUE), fType(ttype)
8d122774 34{
c8fe2783 35 //constructor
8d122774 36}
37
5c1dc41f 38AliAODCaloCells::AliAODCaloCells(const AliAODCaloCells& cells) :
c8fe2783 39 AliVCaloCells(cells),
5c1dc41f 40 fNCells(cells.fNCells),
41 fCellNumber(0),
42 fAmplitude(0),
43 fIsSorted(cells.fIsSorted),
44 fType(cells.fType)
45{
46// Copy constructor
c8fe2783 47 fCellNumber = new Short_t[fNCells];
48 fAmplitude = new Double32_t[fNCells];
49
50 for (Int_t i = 0; i < fNCells; i++) {
51 fCellNumber[i] = cells.fCellNumber[i];
52 fAmplitude[i] = cells.fAmplitude[i];
53 }
5c1dc41f 54}
55
56AliAODCaloCells& AliAODCaloCells::operator=(const AliAODCaloCells& cells)
57{
c8fe2783 58 // Assignment operator
59 if(&cells == this) return *this;
60 fNCells = cells.fNCells;
61 for (Int_t i = 0; i < fNCells; i++) {
62 fCellNumber[i] = cells.fCellNumber[i];
63 fAmplitude[i] = cells.fAmplitude[i];
64 }
65 SetName(cells.GetName()) ;
66 SetTitle(cells.GetTitle()) ;
67 return *this;
5c1dc41f 68}
69
8d122774 70AliAODCaloCells::~AliAODCaloCells()
71{
72 // destructor
73
74 DeleteContainer();
75}
76
ecff8f07 77
78void AliAODCaloCells::Copy(TObject &obj) const {
79
80 // this overwrites the virtual TOBject::Copy()
81 // to allow run time copying without casting
82 // in AliESDEvent
83
84 if(this==&obj)return;
85 AliAODCaloCells *robj = dynamic_cast<AliAODCaloCells*>(&obj);
86 if(!robj)return; // not an AliAODCaloCells
87 *robj = *this;
88
89}
90
91AliVCaloCells *AliAODCaloCells::CopyCaloCells(Bool_t all = kTRUE) const {
92
93 // copy the calo cells into a new object. If option all=FALSE, just the object type,
94 // for mixing
95
96 AliVCaloCells *obj = new AliAODCaloCells();
97
98 if(all){
99 obj->SetName (GetName()) ;
100 obj->SetTitle(GetTitle()) ;
101 obj->SetType (GetType()) ;
102
103 obj->SetNumberOfCells(fNCells);
104 for (Short_t i = 0; i < fNCells; i++)
105 obj->SetCell(i,fCellNumber[i],fAmplitude[i],-1);
106 }
107
108 return obj;
109
110}
111
8d122774 112void AliAODCaloCells::CreateContainer(Short_t nCells)
113{
114 // function that creates container to store calorimeter cell data
115
116 DeleteContainer();
117
118 if (nCells <= 0) {
119 fNCells = 0;
120 return;
121 }
122
123 fNCells = nCells;
124
125 fCellNumber = new Short_t[fNCells];
c8fe2783 126 fAmplitude = new Double32_t[fNCells];
127
341952b8 128 // set to zero
129 for(int i = 0;i<fNCells;++i){
c8fe2783 130 fAmplitude[i] = fCellNumber[i] = 0 ;
341952b8 131 }
8d122774 132}
133
134void AliAODCaloCells::DeleteContainer()
135{
136 // deletes allocated memory
137
138 if (fCellNumber)
139 {
140 delete[] fCellNumber;
c8fe2783 141 fCellNumber = NULL;
8d122774 142 }
143
144 if (fAmplitude)
145 {
146 delete[] fAmplitude;
c8fe2783 147 fAmplitude = NULL;
8d122774 148 }
c8fe2783 149
8d122774 150 fNCells = 0;
151 fIsSorted = kFALSE;
152}
153
154void AliAODCaloCells::Sort()
155{
156 // sort the cell array by cell number
157
158 Int_t *idxArray = new Int_t[fNCells];
159 TMath::Sort(fNCells,fCellNumber,idxArray,kFALSE);
160
c8fe2783 161 Short_t *newIndex = new Short_t[fNCells];
8d122774 162 Double32_t *newAmplitude = new Double32_t[fNCells];
163 for (Int_t i=0; i < fNCells; i++) {
c8fe2783 164 newIndex[i] = fCellNumber[idxArray[i]];
8d122774 165 newAmplitude[i] = fAmplitude[idxArray[i]];
166 }
167 delete [] fCellNumber;
168 delete [] fAmplitude;
169 fCellNumber = newIndex;
c8fe2783 170 fAmplitude = newAmplitude;
8d122774 171
172 delete [] idxArray;
173
174 fIsSorted = kTRUE;
175}
176
c8fe2783 177Bool_t AliAODCaloCells::SetCell(Short_t pos, Short_t cellNumber, Double32_t amplitude, Double32_t /*time*/)
8d122774 178{
179 // Sets a cell at the given position
180
181 if (pos>=0 && pos < fNCells) {
182 fCellNumber[pos] = cellNumber;
c8fe2783 183 fAmplitude[pos] = amplitude;
8d122774 184 fIsSorted = kFALSE;
185 return kTRUE;
186 } else {
187 return kFALSE;
188 }
189}