]> git.uio.no Git - u/mrichter/AliRoot.git/blame - ITS/AliITSpList.cxx
Fixes related to the placement of the SPD ladders w.r.t. the half staves (A. Dainese)
[u/mrichter/AliRoot.git] / ITS / AliITSpList.cxx
CommitLineData
2134176d 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
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 **************************************************************************/
15/* $Id$ */
16
fb4e90e0 17//***********************************************************************
18//
9881a682 19// It consist of a TClonesArray of
fb4e90e0 20// AliITSpListItem objects
21// This array can be accessed via 2 indexed
22// it is used at digitization level by
23// all the 3 ITS subdetectors
24//
25// ***********************************************************************
26
2134176d 27#include "AliITSpList.h"
fb4e90e0 28#include "AliITSpListItem.h"
29
2134176d 30
31//______________________________________________________________________
32
925e6570 33ClassImp(AliITSpList)
2134176d 34//______________________________________________________________________
e56160b8 35AliITSpList::AliITSpList():
36fNi(0),
37fNj(0),
38fa(0),
39fEntries(0){
2134176d 40 // Default constructor
c7d528c6 41 // Inputs:
42 // none.
43 // Outputs:
44 // none.
45 // Return:
46 // A zeroed/empty AliITSpList class.
2134176d 47
2134176d 48}
49//______________________________________________________________________
e56160b8 50AliITSpList::AliITSpList(Int_t imax,Int_t jmax):
51fNi(imax),
52fNj(jmax),
53fa(0),
54fEntries(0){
2134176d 55 // Standard constructor
c7d528c6 56 // Inputs:
57 // none.
58 // Outputs:
59 // none.
60 // Return:
61 // A setup AliITSpList class.
2134176d 62
9881a682 63 fa = new TClonesArray("AliITSpListItem",fNi*fNj);
2134176d 64}
65//______________________________________________________________________
66AliITSpList::~AliITSpList(){
67 // Default destructor
c7d528c6 68 // Inputs:
69 // none.
70 // Outputs:
71 // none.
72 // Return:
73 // a properly destroyed class
2134176d 74
9881a682 75 if(fa){
76 fa->Delete();
77 delete fa;
78 fa = 0;
79 }
2134176d 80 fNi = 0;
81 fNj = 0;
9881a682 82
83 fEntries = 0;
2134176d 84}
fb4e90e0 85
2134176d 86//______________________________________________________________________
87void AliITSpList::ClearMap(){
9881a682 88 // Delete all AliITSpListItems and zero TClonesArray.
c7d528c6 89 // Inputs:
90 // none.
91 // Outputs:
92 // none.
93 // Return:
94 // A zeroed AliITSpList class.
2134176d 95
9ce4d38b 96 fa->Delete();
9881a682 97 fEntries = 0;
2134176d 98}
99//______________________________________________________________________
100void AliITSpList::DeleteHit(Int_t i,Int_t j){
9881a682 101 // Delete a particular AliITSpListItems.
c7d528c6 102 // Inputs:
103 // Int_t i Row number
104 // Int_t j Columns number
105 // Outputs:
106 // none.
107 // Return:
108 // none.
2134176d 109 Int_t k = GetIndex(i,j);
110
111 if(fa->At(k)!=0){
9881a682 112 fa->RemoveAt(k);
2134176d 113 } // end for i && if
9881a682 114 if(k==fEntries-1) fEntries--;
2134176d 115}
116//______________________________________________________________________
117AliITSpList& AliITSpList::operator=(const AliITSpList &source){
118 // = operator
c7d528c6 119 // Inputs:
120 // const AliITSpList &source A AliITSpList object.
121 // Outputs:
122 // none.
123 // Return:
124 // A copied AliITSpList object.
2134176d 125
e56160b8 126 this->~AliITSpList();
127 new(this) AliITSpList(source);
128 return *this;
2134176d 129}
130//______________________________________________________________________
e56160b8 131AliITSpList::AliITSpList(const AliITSpList &source) : AliITSMap(source),
132fNi(source.fNi),fNj(source.fNj),fa(0),fEntries(source.fEntries){
fb4e90e0 133 // Copy constructor
2134176d 134
9881a682 135 fa = new TClonesArray(*(source.fa));
2134176d 136}
137//______________________________________________________________________
c7d528c6 138void AliITSpList::AddItemTo(Int_t fileIndex, AliITSpListItem *pl) {
139 // Adds the contents of pl to the list with track number off set given by
140 // fileIndex.
141 // Creates the AliITSpListItem if needed.
142 // Inputs:
143 // Int_t fileIndex track number offset value
144 // AliITSpListItem *pl an AliITSpListItem to be added to this class.
145 // Outputs:
146 // none.
147 // Return:
148 // none.
149 Int_t index = pl->GetIndex();
9881a682 150 TClonesArray &rfa = *fa;
c7d528c6 151 if( fa->At( index ) == 0 ) { // most create AliITSpListItem
9881a682 152 new(rfa[index])AliITSpListItem(-2,-1,pl->GetModule(),index,0.0);
c7d528c6 153 } // end if
154
cab0142f 155 ((AliITSpListItem*)(fa->At(index)))->AddTo( fileIndex,pl);
9881a682 156 if(index>=fEntries) fEntries = index +1;
c7d528c6 157}
158//______________________________________________________________________
2134176d 159void AliITSpList::AddSignal(Int_t i,Int_t j,Int_t trk,Int_t ht,Int_t mod,
c7d528c6 160 Double_t signal){
9881a682 161 // Adds a Signal value to the TClonesArray at i,j.
162 // Creates the AliITSpListItem
2134176d 163 // if needed.
c7d528c6 164 // Inputs:
165 // Int_t i Row number for this signal
166 // Int_t j Column number for this signal
167 // Int_t trk Track number creating this signal
168 // Int_t ht Hit number creating this signal
169 // Int_t mod The module where this signal is in
170 // Double_t signal The signal (ionization)
171 // Outputs:
172 // none.
173 // Return:
174 // none.
9ce4d38b 175 Int_t index = GetIndex(i,j);
d7f298dd 176 if (index<0) return;
9881a682 177 TClonesArray &rfa = *fa;
178 if(GetpListItem(index)==0){ // must create AliITSpListItem
179 new(rfa[index])AliITSpListItem(trk,ht,mod,index,signal);
2134176d 180 }else{ // AliITSpListItem exists, just add signal to it.
9ce4d38b 181 GetpListItem(index)->AddSignal(trk,ht,mod,index,signal);
2134176d 182 } // end if
9881a682 183 if(index>=fEntries) fEntries = index +1;
2134176d 184}
185//______________________________________________________________________
186void AliITSpList::AddNoise(Int_t i,Int_t j,Int_t mod,Double_t noise){
9881a682 187 // Adds a noise value to the TClonesArray at i,j.
188 // Creates the AliITSpListItem
2134176d 189 // if needed.
c7d528c6 190 // Inputs:
191 // Int_t i Row number for this noise
192 // Int_t j Column number for this noise
193 // Double_t noise The noise signal value.
194 // Outputs:
195 // none.
196 // Return:
197 // none.
9ce4d38b 198 Int_t index = GetIndex(i,j);
9881a682 199 TClonesArray &rfa = *fa;
9ce4d38b 200 if(GetpListItem(index)==0){ // most create AliITSpListItem
9881a682 201 new(rfa[index]) AliITSpListItem(mod,index,noise);
2134176d 202 }else{ // AliITSpListItem exists, just add signal to it.
9ce4d38b 203 GetpListItem(index)->AddNoise(mod,index,noise);
2134176d 204 } // end if
9881a682 205 if(index>=fEntries) fEntries = index +1;
2134176d 206}
207//______________________________________________________________________
fb4e90e0 208void AliITSpList::GetCell(Int_t index,Int_t &i,Int_t &j) const {
209 // returns the i,j index numbers from the linearized index computed
210 // with GetIndex
211 if(index<0 || index>=fNi*fNj){
212 Warning("GetCell","Index out of range 0<=index=%d<%d",
213 index,fNi*fNj);
214 i=-1;j=-1;
2134176d 215 return;
fb4e90e0 216 } // end if
217 i = index/fNj;
218 j = index - fNj*i;
219 return;
220}
221//______________________________________________________________________
222Int_t AliITSpList::GetIndex(Int_t i, Int_t j) const {
9881a682 223 // returns the TClonesArray index for a given set of map indexes.
fb4e90e0 224 if(i<0||i>=fNi || j<0||j>=fNj){
225 Warning("GetIndex","Index out of range 0<i=%d<%d and 0<0j=%d<%d",i,fNi,j,fNj);
226 return -1;
227 }
228 else {
229 return fNj*i+j;
230 }
2134176d 231}