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() : AliVCaloCells(), fNCells(0), fCellNumber(0), fAmplitude(0), fIsSorted(kTRUE), fType(kUndef)
29 // default constructor
32 AliAODCaloCells::AliAODCaloCells(const char* name, const char* title, VCells_t ttype) :
33 AliVCaloCells(name, title), fNCells(0), fCellNumber(0), fAmplitude(0), fIsSorted(kTRUE), fType(ttype)
38 AliAODCaloCells::AliAODCaloCells(const AliAODCaloCells& cells) :
40 fNCells(cells.fNCells),
43 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 fNCells = cells.fNCells;
61 for (Int_t i = 0; i < fNCells; i++) {
62 fCellNumber[i] = cells.fCellNumber[i];
63 fAmplitude[i] = cells.fAmplitude[i];
65 SetName(cells.GetName()) ;
66 SetTitle(cells.GetTitle()) ;
70 AliAODCaloCells::~AliAODCaloCells()
77 void AliAODCaloCells::Clear(const Option_t*)
84 void AliAODCaloCells::Copy(TObject &obj) const {
86 // this overwrites the virtual TOBject::Copy()
87 // to allow run time copying without casting
91 AliAODCaloCells *robj = dynamic_cast<AliAODCaloCells*>(&obj);
92 if(!robj)return; // not an AliAODCaloCells
97 AliVCaloCells *AliAODCaloCells::CopyCaloCells(Bool_t all = kTRUE) const {
99 // copy the calo cells into a new object. If option all=FALSE, just the object type,
102 AliVCaloCells *obj = new AliAODCaloCells();
105 obj->SetName (GetName()) ;
106 obj->SetTitle(GetTitle()) ;
107 obj->SetType (GetType()) ;
109 obj->SetNumberOfCells(fNCells);
110 for (Short_t i = 0; i < fNCells; i++)
111 obj->SetCell(i,fCellNumber[i],fAmplitude[i],-1);
118 void AliAODCaloCells::CreateContainer(Short_t nCells)
120 // function that creates container to store calorimeter cell data
131 fCellNumber = new Short_t[fNCells];
132 fAmplitude = new Double32_t[fNCells];
135 for(int i = 0;i<fNCells;++i){
136 fAmplitude[i] = fCellNumber[i] = 0 ;
140 void AliAODCaloCells::DeleteContainer()
142 // deletes allocated memory
146 delete[] fCellNumber;
160 void AliAODCaloCells::Sort()
162 // sort the cell array by cell number
164 Int_t *idxArray = new Int_t[fNCells];
165 TMath::Sort(fNCells,fCellNumber,idxArray,kFALSE);
167 Short_t *newIndex = new Short_t[fNCells];
168 Double32_t *newAmplitude = new Double32_t[fNCells];
169 for (Int_t i=0; i < fNCells; i++) {
170 newIndex[i] = fCellNumber[idxArray[i]];
171 newAmplitude[i] = fAmplitude[idxArray[i]];
173 delete [] fCellNumber;
174 delete [] fAmplitude;
175 fCellNumber = newIndex;
176 fAmplitude = newAmplitude;
183 Bool_t AliAODCaloCells::SetCell(Short_t pos, Short_t cellNumber, Double32_t amplitude, Double32_t /*time*/)
185 // Sets a cell at the given position
187 if (pos>=0 && pos < fNCells) {
188 fCellNumber[pos] = cellNumber;
189 fAmplitude[pos] = amplitude;