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 AliVCaloCells(), 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, VCells_t ttype) :
36 AliVCaloCells(name, title), fNCells(0), fCellNumber(0), fAmplitude(0), fTime(0), fIsSorted(kTRUE), fType(ttype)
38 // AliVCaloCells constructor
41 //_______________________________________________________________________
42 AliESDCaloCells::AliESDCaloCells(const AliESDCaloCells& c) :
43 AliVCaloCells(c), fNCells(c.fNCells), fCellNumber(0), fAmplitude(0), fTime(0), fIsSorted(c.fIsSorted), fType(c.fType)
47 fCellNumber = new Short_t[fNCells];
48 fAmplitude = new Double32_t[fNCells];
50 for(Int_t i = 0; i < fNCells; i++){
51 fCellNumber[i] = c.fCellNumber[i];
52 fAmplitude[i] = c.fAmplitude[i];
53 fTime[i] = c.fTime[i];
54 fAmplitude[i] = c.fAmplitude[i];
59 //_______________________________________________________________________
60 AliESDCaloCells & AliESDCaloCells::operator =(const AliESDCaloCells& source)
62 // assignment operator
64 if(&source == this) return *this;
66 if(fNCells != source.fNCells){
68 CreateContainer(source.fNCells);
71 fNCells = source.fNCells;
72 fIsSorted = source.fIsSorted;
77 for(Int_t i = 0; i < fNCells; i++){
78 fCellNumber[i] = source.fCellNumber[i];
79 fAmplitude[i] = source.fAmplitude[i];
80 fTime[i] = source.fTime[i];
87 //_______________________________________________________________________
88 void AliESDCaloCells::Copy(TObject &obj) const {
90 // this overwrites the virtual TOBject::Copy()
91 // to allow run time copying without casting
95 AliESDCaloCells *robj = dynamic_cast<AliESDCaloCells*>(&obj);
96 if(!robj)return; // not an AliESDCaloCells
101 //_______________________________________________________________________
102 AliVCaloCells* AliESDCaloCells::CopyCaloCells(Bool_t all = kTRUE) const {
104 // copy the calo cells into a new object. If option all=FALSE, just the object type,
107 AliVCaloCells *obj = new AliESDCaloCells();
110 obj->SetName (GetName()) ;
111 obj->SetTitle(GetTitle()) ;
112 obj->SetType (GetType()) ;
114 obj->SetNumberOfCells(fNCells);
115 for (Short_t i = 0; i < fNCells; i++)
116 obj->SetCell(i,fCellNumber[i],fAmplitude[i],fTime[i]);
123 //_______________________________________________________________________
124 AliESDCaloCells::~AliESDCaloCells()
131 //_______________________________________________________________________
132 void AliESDCaloCells::CreateContainer(Short_t nCells)
134 // function that creates container to store calorimeter cell data
145 fCellNumber = new Short_t[fNCells];
146 fAmplitude = new Double32_t[fNCells];
147 fTime = new Double32_t[fNCells];
150 for(int i = 0;i<fNCells;++i){
151 fAmplitude[i] = fCellNumber[i] = 0 ;
155 //_______________________________________________________________________
156 void AliESDCaloCells::DeleteContainer()
158 // deletes allocated memory
162 delete[] fCellNumber;
182 //_______________________________________________________________________
183 void AliESDCaloCells::Sort()
185 // sort the cell array by cell number
187 Int_t *idxArray = new Int_t[fNCells];
188 TMath::Sort(fNCells,fCellNumber,idxArray,kFALSE);
190 Short_t *newIndex = new Short_t[fNCells];
191 Double32_t *newAmplitude = new Double32_t[fNCells];
192 Double32_t *newTime = new Double32_t[fNCells];
193 for (Int_t i=0; i < fNCells; i++) {
194 newIndex[i] = fCellNumber[idxArray[i]];
195 newAmplitude[i] = fAmplitude[idxArray[i]];
196 newTime[i] = fTime[idxArray[i]];
198 delete [] fCellNumber;
199 delete [] fAmplitude;
202 fCellNumber = newIndex;
203 fAmplitude = newAmplitude;
211 //_______________________________________________________________________
212 Bool_t AliESDCaloCells::SetCell(Short_t pos, Short_t cellNumber, Double32_t amplitude, Double32_t time)
214 // Sets a cell at the given position
216 if (pos>=0 && pos < fNCells) {
217 fCellNumber[pos] = cellNumber;
218 fAmplitude[pos] = amplitude;