1 /**************************************************************************
2 * Copyright(c) 1998-2007, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 //-------------------------------------------------------------------------
19 // ESD class to store calorimeter cell data
20 // Clone of AliAODCaloCells made by Markus Oldenburg, CERN
21 // Author: Gustavo Conesa Balbastre INFN-LNF
22 //-------------------------------------------------------------------------
24 #include "AliESDCaloCells.h"
26 ClassImp(AliESDCaloCells)
28 //_______________________________________________________________________
29 AliESDCaloCells::AliESDCaloCells() :
30 TNamed(), fNCells(0), fCellNumber(0), fAmplitude(0), fTime(0), fIsSorted(kTRUE), fType(kUndef)
32 // default constructor
34 //_______________________________________________________________________
35 AliESDCaloCells::AliESDCaloCells(const char* name, const char* title, ESDCells_t ttype) :
36 TNamed(name, title), fNCells(0), fCellNumber(0), fAmplitude(0), fTime(0), fIsSorted(kTRUE), fType(ttype)
41 //_______________________________________________________________________
42 AliESDCaloCells::AliESDCaloCells(const AliESDCaloCells& c) :
43 TNamed(c), fNCells(c.fNCells), fCellNumber(), fAmplitude(), fTime(), fIsSorted(c.fIsSorted), fType(c.fType)
47 for(Int_t i = 0; i < fNCells; i++){
48 fCellNumber[i] = c.fCellNumber[i];
49 fAmplitude[i] = c.fAmplitude[i];
50 fTime[i] = c.fTime[i];
54 //_______________________________________________________________________
55 AliESDCaloCells & AliESDCaloCells::operator =(const AliESDCaloCells& source)
57 // assignment operator
59 if(&source == this) return *this;
60 TNamed::operator=(source);
62 fNCells = source.fNCells;
63 fIsSorted = source.fIsSorted;
66 for(Int_t i = 0; i < fNCells; i++){
67 fCellNumber[i] = source.fCellNumber[i];
68 fAmplitude[i] = source.fAmplitude[i];
69 fTime[i] = source.fTime[i];
76 //_______________________________________________________________________
77 AliESDCaloCells::~AliESDCaloCells()
84 //_______________________________________________________________________
85 void AliESDCaloCells::CreateContainer(Short_t nCells)
87 // function that creates container to store calorimeter cell data
98 fCellNumber = new Short_t[fNCells];
99 fAmplitude = new Double32_t[fNCells];
100 fTime = new Double32_t[fNCells];
103 //_______________________________________________________________________
104 void AliESDCaloCells::DeleteContainer()
106 // deletes allocated memory
110 delete[] fCellNumber;
130 //_______________________________________________________________________
131 void AliESDCaloCells::Sort()
133 // sort the cell array by cell number
135 Int_t *idxArray = new Int_t[fNCells];
136 TMath::Sort(fNCells,fCellNumber,idxArray,kFALSE);
138 Short_t *newIndex = new Short_t[fNCells];
139 Double32_t *newAmplitude = new Double32_t[fNCells];
140 Double32_t *newTime = new Double32_t[fNCells];
141 for (Int_t i=0; i < fNCells; i++) {
142 newIndex[i] = fCellNumber[idxArray[i]];
143 newAmplitude[i] = fAmplitude[idxArray[i]];
144 newTime[i] = fTime[idxArray[i]];
146 delete [] fCellNumber;
147 delete [] fAmplitude;
149 fCellNumber = newIndex;
150 fAmplitude = newAmplitude;
158 //_______________________________________________________________________
159 Bool_t AliESDCaloCells::SetCell(Short_t pos, Short_t cellNumber, Double32_t amplitude, Double32_t time)
161 // Sets a cell at the given position
163 if (pos>=0 && pos < fNCells) {
164 fCellNumber[pos] = cellNumber;
165 fAmplitude[pos] = amplitude;