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 if(fNCells != source.fNCells){
64 CreateContainer(source.fNCells);
67 fNCells = source.fNCells;
68 fIsSorted = source.fIsSorted;
73 for(Int_t i = 0; i < fNCells; i++){
74 fCellNumber[i] = source.fCellNumber[i];
75 fAmplitude[i] = source.fAmplitude[i];
76 fTime[i] = source.fTime[i];
84 void AliESDCaloCells::Copy(TObject &obj) const {
86 // this overwrites the virtual TOBject::Copy()
87 // to allow run time copying without casting
91 AliESDCaloCells *robj = dynamic_cast<AliESDCaloCells*>(&obj);
92 if(!robj)return; // not an AliESDCaloCells
97 //_______________________________________________________________________
98 AliESDCaloCells::~AliESDCaloCells()
105 //_______________________________________________________________________
106 void AliESDCaloCells::CreateContainer(Short_t nCells)
108 // function that creates container to store calorimeter cell data
119 fCellNumber = new Short_t[fNCells];
120 fAmplitude = new Double32_t[fNCells];
121 fTime = new Double32_t[fNCells];
124 //_______________________________________________________________________
125 void AliESDCaloCells::DeleteContainer()
127 // deletes allocated memory
131 delete[] fCellNumber;
151 //_______________________________________________________________________
152 void AliESDCaloCells::Sort()
154 // sort the cell array by cell number
156 Int_t *idxArray = new Int_t[fNCells];
157 TMath::Sort(fNCells,fCellNumber,idxArray,kFALSE);
159 Short_t *newIndex = new Short_t[fNCells];
160 Double32_t *newAmplitude = new Double32_t[fNCells];
161 Double32_t *newTime = new Double32_t[fNCells];
162 for (Int_t i=0; i < fNCells; i++) {
163 newIndex[i] = fCellNumber[idxArray[i]];
164 newAmplitude[i] = fAmplitude[idxArray[i]];
165 newTime[i] = fTime[idxArray[i]];
167 delete [] fCellNumber;
168 delete [] fAmplitude;
170 fCellNumber = newIndex;
171 fAmplitude = newAmplitude;
179 //_______________________________________________________________________
180 Bool_t AliESDCaloCells::SetCell(Short_t pos, Short_t cellNumber, Double32_t amplitude, Double32_t time)
182 // Sets a cell at the given position
184 if (pos>=0 && pos < fNCells) {
185 fCellNumber[pos] = cellNumber;
186 fAmplitude[pos] = amplitude;