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 // AOD class to store calorimeter cell data
20 // Author: Markus Oldenburg, CERN
21 //-------------------------------------------------------------------------
23 #include "AliAODCaloCells.h"
25 ClassImp(AliAODCaloCells)
27 AliAODCaloCells::AliAODCaloCells() : TNamed(), fNCells(0), fCellNumber(0), fAmplitude(0), fIsSorted(kTRUE), fType(kUndef)
29 // default constructor
32 AliAODCaloCells::AliAODCaloCells(const char* name, const char* title, AODCells_t ttype) : TNamed(name, title), fNCells(0), fCellNumber(0), fAmplitude(0), fIsSorted(kTRUE), fType(ttype)
37 AliAODCaloCells::AliAODCaloCells(const AliAODCaloCells& cells) :
39 fNCells(cells.fNCells),
42 fIsSorted(cells.fIsSorted),
47 fCellNumber = new Short_t[fNCells];
48 fAmplitude = new Double32_t[fNCells];
50 for (Int_t i = 0; i < fNCells; i++) {
51 fCellNumber[i] = cells.fCellNumber[i];
52 fAmplitude[i] = cells.fAmplitude[i];
56 AliAODCaloCells& AliAODCaloCells::operator=(const AliAODCaloCells& cells)
58 // Assignment operator
59 if(&cells == this) return *this;
60 TNamed::operator=(cells);
61 fNCells = cells.fNCells;
62 for (Int_t i = 0; i < fNCells; i++) {
63 fCellNumber[i] = cells.fCellNumber[i];
64 fAmplitude[i] = cells.fAmplitude[i];
69 AliAODCaloCells::~AliAODCaloCells()
76 void AliAODCaloCells::CreateContainer(Short_t nCells)
78 // function that creates container to store calorimeter cell data
89 fCellNumber = new Short_t[fNCells];
90 fAmplitude = new Double32_t[fNCells];
92 for(int i = 0;i<fNCells;++i){
93 fAmplitude[i] = fCellNumber[i] = 0;
97 void AliAODCaloCells::DeleteContainer()
99 // deletes allocated memory
103 delete[] fCellNumber;
117 void AliAODCaloCells::Sort()
119 // sort the cell array by cell number
121 Int_t *idxArray = new Int_t[fNCells];
122 TMath::Sort(fNCells,fCellNumber,idxArray,kFALSE);
124 Short_t *newIndex = new Short_t[fNCells];
125 Double32_t *newAmplitude = new Double32_t[fNCells];
126 for (Int_t i=0; i < fNCells; i++) {
127 newIndex[i] = fCellNumber[idxArray[i]];
128 newAmplitude[i] = fAmplitude[idxArray[i]];
130 delete [] fCellNumber;
131 delete [] fAmplitude;
132 fCellNumber = newIndex;
133 fAmplitude = newAmplitude;
140 Bool_t AliAODCaloCells::SetCell(Short_t pos, Short_t cellNumber, Double32_t amplitude)
142 // Sets a cell at the given position
144 if (pos>=0 && pos < fNCells) {
145 fCellNumber[pos] = cellNumber;
146 fAmplitude[pos] = amplitude;