1 /**************************************************************************
2 * Copyright(c) 1998-1999, 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 **************************************************************************/
17 //***********************************************************************
19 // It consist of a TObjectArray of
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
25 // ***********************************************************************
27 #include <TObjArray.h>
29 #include "AliITSpList.h"
30 #include "AliITSpListItem.h"
33 //______________________________________________________________________
35 ClassImp(AliITSpList);
36 //______________________________________________________________________
37 AliITSpList::AliITSpList(){
38 // Default constructor
44 // A zeroed/empty AliITSpList class.
50 //______________________________________________________________________
51 AliITSpList::AliITSpList(Int_t imax,Int_t jmax){
52 // Standard constructor
58 // A setup AliITSpList class.
63 fa = new TObjArray(fNi*fNj); // elements are zeroed by
66 //______________________________________________________________________
67 AliITSpList::~AliITSpList(){
74 // a properly destroyed class
76 for(Int_t i=0;i<GetMaxIndex();i++) if(fa->At(i)!=0){
78 fa->AddAt(0,i); // zero content
87 //______________________________________________________________________
88 void AliITSpList::ClearMap(){
89 // Delete all AliITSpListItems and zero TObjArray.
95 // A zeroed AliITSpList class.
99 for(Int_t i=0;i<GetMaxIndex();i++) if(fa->At(i)!=0){
101 fa->AddAt(0,i); // zero content
106 //______________________________________________________________________
107 void AliITSpList::DeleteHit(Int_t i,Int_t j){
108 // Delete a particular AliITSpListItems and zero TObjArray.
110 // Int_t i Row number
111 // Int_t j Columns number
116 Int_t k = GetIndex(i,j);
120 fa->AddAt(0,k); // zero content
122 if(k==fEnteries-1) fEnteries--;
124 //______________________________________________________________________
125 AliITSpList& AliITSpList::operator=(const AliITSpList &source){
128 // const AliITSpList &source A AliITSpList object.
132 // A copied AliITSpList object.
134 if(this == &source) return *this;
136 if(this->fa!=0){ // if this->fa exists delete it first.
137 for(Int_t i=0;i<GetMaxIndex();i++) if(fa->At(i)!=0){
139 fa->AddAt(0,i); // zero content
142 } // end if this->fa!=0
143 this->fNi = source.fNi;
144 this->fNj = source.fNj;
145 this->fa = new TObjArray(*(source.fa));
146 this->fEnteries = source.fEnteries;
150 //______________________________________________________________________
151 AliITSpList::AliITSpList(const AliITSpList &source) : AliITSMap(source){
156 fa = new TObjArray(*(source.fa));
157 fEnteries = source.fEnteries;
159 //______________________________________________________________________
160 void AliITSpList::AddItemTo(Int_t fileIndex, AliITSpListItem *pl) {
161 // Adds the contents of pl to the list with track number off set given by
163 // Creates the AliITSpListItem if needed.
165 // Int_t fileIndex track number offset value
166 // AliITSpListItem *pl an AliITSpListItem to be added to this class.
171 Int_t index = pl->GetIndex();
173 if( fa->At( index ) == 0 ) { // most create AliITSpListItem
174 fa->AddAt(new AliITSpListItem(-2,-1,pl->GetModule(),index,0.0),index);
177 ((AliITSpListItem*)(fa->At(index)))->AddTo( fileIndex,pl);
178 if(index>=fEnteries) fEnteries = index +1;
180 //______________________________________________________________________
181 void AliITSpList::AddSignal(Int_t i,Int_t j,Int_t trk,Int_t ht,Int_t mod,
183 // Adds a Signal value to the TObjArray at i,j. Creates the AliITSpListItem
186 // Int_t i Row number for this signal
187 // Int_t j Column number for this signal
188 // Int_t trk Track number creating this signal
189 // Int_t ht Hit number creating this signal
190 // Int_t mod The module where this signal is in
191 // Double_t signal The signal (ionization)
196 Int_t index = GetIndex(i,j);
198 if(GetpListItem(index)==0){ // most create AliITSpListItem
199 fa->AddAt(new AliITSpListItem(trk,ht,mod,index,signal),index);
200 }else{ // AliITSpListItem exists, just add signal to it.
201 GetpListItem(index)->AddSignal(trk,ht,mod,index,signal);
203 if(index>=fEnteries) fEnteries = index +1;
205 //______________________________________________________________________
206 void AliITSpList::AddNoise(Int_t i,Int_t j,Int_t mod,Double_t noise){
207 // Adds a noise value to the TObjArray at i,j. Creates the AliITSpListItem
210 // Int_t i Row number for this noise
211 // Int_t j Column number for this noise
212 // Double_t noise The noise signal value.
217 Int_t index = GetIndex(i,j);
219 if(GetpListItem(index)==0){ // most create AliITSpListItem
220 fa->AddAt(new AliITSpListItem(mod,index,noise),index);
221 }else{ // AliITSpListItem exists, just add signal to it.
222 GetpListItem(index)->AddNoise(mod,index,noise);
224 if(index>=fEnteries) fEnteries = index +1;
226 //______________________________________________________________________
227 void AliITSpList::GetCell(Int_t index,Int_t &i,Int_t &j) const {
228 // returns the i,j index numbers from the linearized index computed
230 if(index<0 || index>=fNi*fNj){
231 Warning("GetCell","Index out of range 0<=index=%d<%d",
240 //______________________________________________________________________
241 Int_t AliITSpList::GetIndex(Int_t i, Int_t j) const {
242 // returns the TObjArray index for a given set of map indexes.
243 if(i<0||i>=fNi || j<0||j>=fNj){
244 Warning("GetIndex","Index out of range 0<i=%d<%d and 0<0j=%d<%d",i,fNi,j,fNj);