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 TClonesArray 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 "AliITSpList.h"
28 #include "AliITSpListItem.h"
31 //______________________________________________________________________
34 //______________________________________________________________________
35 AliITSpList::AliITSpList(){
36 // Default constructor
42 // A zeroed/empty AliITSpList class.
48 //______________________________________________________________________
49 AliITSpList::AliITSpList(Int_t imax,Int_t jmax){
50 // Standard constructor
56 // A setup AliITSpList class.
61 fa = new TClonesArray("AliITSpListItem",fNi*fNj);
63 //______________________________________________________________________
64 AliITSpList::~AliITSpList(){
71 // a properly destroyed class
84 //______________________________________________________________________
85 void AliITSpList::ClearMap(){
86 // Delete all AliITSpListItems and zero TClonesArray.
92 // A zeroed AliITSpList class.
97 //______________________________________________________________________
98 void AliITSpList::DeleteHit(Int_t i,Int_t j){
99 // Delete a particular AliITSpListItems.
101 // Int_t i Row number
102 // Int_t j Columns number
107 Int_t k = GetIndex(i,j);
112 if(k==fEntries-1) fEntries--;
114 //______________________________________________________________________
115 AliITSpList& AliITSpList::operator=(const AliITSpList &source){
118 // const AliITSpList &source A AliITSpList object.
122 // A copied AliITSpList object.
124 if(this == &source) return *this;
126 if(this->fa!=0){ // if this->fa exists delete it first.
130 } // end if this->fa!=0
131 this->fNi = source.fNi;
132 this->fNj = source.fNj;
133 this->fa = new TClonesArray(*(source.fa));
134 this->fEntries = source.fEntries;
138 //______________________________________________________________________
139 AliITSpList::AliITSpList(const AliITSpList &source) : AliITSMap(source){
144 fa = new TClonesArray(*(source.fa));
145 fEntries = source.fEntries;
147 //______________________________________________________________________
148 void AliITSpList::AddItemTo(Int_t fileIndex, AliITSpListItem *pl) {
149 // Adds the contents of pl to the list with track number off set given by
151 // Creates the AliITSpListItem if needed.
153 // Int_t fileIndex track number offset value
154 // AliITSpListItem *pl an AliITSpListItem to be added to this class.
159 Int_t index = pl->GetIndex();
160 TClonesArray &rfa = *fa;
161 if( fa->At( index ) == 0 ) { // most create AliITSpListItem
162 new(rfa[index])AliITSpListItem(-2,-1,pl->GetModule(),index,0.0);
165 ((AliITSpListItem*)(fa->At(index)))->AddTo( fileIndex,pl);
166 if(index>=fEntries) fEntries = index +1;
168 //______________________________________________________________________
169 void AliITSpList::AddSignal(Int_t i,Int_t j,Int_t trk,Int_t ht,Int_t mod,
171 // Adds a Signal value to the TClonesArray at i,j.
172 // Creates the AliITSpListItem
175 // Int_t i Row number for this signal
176 // Int_t j Column number for this signal
177 // Int_t trk Track number creating this signal
178 // Int_t ht Hit number creating this signal
179 // Int_t mod The module where this signal is in
180 // Double_t signal The signal (ionization)
185 Int_t index = GetIndex(i,j);
187 TClonesArray &rfa = *fa;
188 if(GetpListItem(index)==0){ // must create AliITSpListItem
189 new(rfa[index])AliITSpListItem(trk,ht,mod,index,signal);
190 }else{ // AliITSpListItem exists, just add signal to it.
191 GetpListItem(index)->AddSignal(trk,ht,mod,index,signal);
193 if(index>=fEntries) fEntries = index +1;
195 //______________________________________________________________________
196 void AliITSpList::AddNoise(Int_t i,Int_t j,Int_t mod,Double_t noise){
197 // Adds a noise value to the TClonesArray at i,j.
198 // Creates the AliITSpListItem
201 // Int_t i Row number for this noise
202 // Int_t j Column number for this noise
203 // Double_t noise The noise signal value.
208 Int_t index = GetIndex(i,j);
209 TClonesArray &rfa = *fa;
210 if(GetpListItem(index)==0){ // most create AliITSpListItem
211 new(rfa[index]) AliITSpListItem(mod,index,noise);
212 }else{ // AliITSpListItem exists, just add signal to it.
213 GetpListItem(index)->AddNoise(mod,index,noise);
215 if(index>=fEntries) fEntries = index +1;
217 //______________________________________________________________________
218 void AliITSpList::GetCell(Int_t index,Int_t &i,Int_t &j) const {
219 // returns the i,j index numbers from the linearized index computed
221 if(index<0 || index>=fNi*fNj){
222 Warning("GetCell","Index out of range 0<=index=%d<%d",
231 //______________________________________________________________________
232 Int_t AliITSpList::GetIndex(Int_t i, Int_t j) const {
233 // returns the TClonesArray index for a given set of map indexes.
234 if(i<0||i>=fNi || j<0||j>=fNj){
235 Warning("GetIndex","Index out of range 0<i=%d<%d and 0<0j=%d<%d",i,fNi,j,fNj);