]>
Commit | Line | Data |
---|---|---|
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 | ||
17 | //*********************************************************************** | |
18 | // | |
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 | |
24 | // | |
25 | // *********************************************************************** | |
26 | ||
27 | #include "AliITSpList.h" | |
28 | #include "AliITSpListItem.h" | |
29 | ||
30 | ||
31 | //______________________________________________________________________ | |
32 | ||
33 | ClassImp(AliITSpList) | |
34 | //______________________________________________________________________ | |
35 | AliITSpList::AliITSpList(): | |
36 | fNi(0), | |
37 | fNj(0), | |
38 | fa(0), | |
39 | fEntries(0){ | |
40 | // Default constructor | |
41 | // Inputs: | |
42 | // none. | |
43 | // Outputs: | |
44 | // none. | |
45 | // Return: | |
46 | // A zeroed/empty AliITSpList class. | |
47 | ||
48 | } | |
49 | //______________________________________________________________________ | |
50 | AliITSpList::AliITSpList(Int_t imax,Int_t jmax): | |
51 | fNi(imax), | |
52 | fNj(jmax), | |
53 | fa(0), | |
54 | fEntries(0){ | |
55 | // Standard constructor | |
56 | // Inputs: | |
57 | // none. | |
58 | // Outputs: | |
59 | // none. | |
60 | // Return: | |
61 | // A setup AliITSpList class. | |
62 | ||
63 | fa = new TClonesArray("AliITSpListItem",fNi*fNj); | |
64 | } | |
65 | //______________________________________________________________________ | |
66 | AliITSpList::~AliITSpList(){ | |
67 | // Default destructor | |
68 | // Inputs: | |
69 | // none. | |
70 | // Outputs: | |
71 | // none. | |
72 | // Return: | |
73 | // a properly destroyed class | |
74 | ||
75 | if(fa){ | |
76 | fa->Delete(); | |
77 | delete fa; | |
78 | fa = 0; | |
79 | } | |
80 | fNi = 0; | |
81 | fNj = 0; | |
82 | ||
83 | fEntries = 0; | |
84 | } | |
85 | ||
86 | //______________________________________________________________________ | |
87 | void AliITSpList::ClearMap(){ | |
88 | // Delete all AliITSpListItems and zero TClonesArray. | |
89 | // Inputs: | |
90 | // none. | |
91 | // Outputs: | |
92 | // none. | |
93 | // Return: | |
94 | // A zeroed AliITSpList class. | |
95 | ||
96 | fa->Delete(); | |
97 | fEntries = 0; | |
98 | } | |
99 | //______________________________________________________________________ | |
100 | void AliITSpList::DeleteHit(Int_t i,Int_t j){ | |
101 | // Delete a particular AliITSpListItems. | |
102 | // Inputs: | |
103 | // Int_t i Row number | |
104 | // Int_t j Columns number | |
105 | // Outputs: | |
106 | // none. | |
107 | // Return: | |
108 | // none. | |
109 | Int_t k = GetIndex(i,j); | |
110 | ||
111 | if(fa->At(k)!=0){ | |
112 | fa->RemoveAt(k); | |
113 | } // end for i && if | |
114 | if(k==fEntries-1) fEntries--; | |
115 | } | |
116 | //______________________________________________________________________ | |
117 | AliITSpList& AliITSpList::operator=(const AliITSpList &source){ | |
118 | // = operator | |
119 | // Inputs: | |
120 | // const AliITSpList &source A AliITSpList object. | |
121 | // Outputs: | |
122 | // none. | |
123 | // Return: | |
124 | // A copied AliITSpList object. | |
125 | ||
126 | this->~AliITSpList(); | |
127 | new(this) AliITSpList(source); | |
128 | return *this; | |
129 | } | |
130 | //______________________________________________________________________ | |
131 | AliITSpList::AliITSpList(const AliITSpList &source) : AliITSMap(source), | |
132 | fNi(source.fNi),fNj(source.fNj),fa(0),fEntries(source.fEntries){ | |
133 | // Copy constructor | |
134 | ||
135 | fa = new TClonesArray(*(source.fa)); | |
136 | } | |
137 | //______________________________________________________________________ | |
138 | void 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(); | |
150 | TClonesArray &rfa = *fa; | |
151 | if( fa->At( index ) == 0 ) { // most create AliITSpListItem | |
152 | new(rfa[index])AliITSpListItem(-2,-1,pl->GetModule(),index,0.0); | |
153 | } // end if | |
154 | ||
155 | ((AliITSpListItem*)(fa->At(index)))->AddTo( fileIndex,pl); | |
156 | if(index>=fEntries) fEntries = index +1; | |
157 | } | |
158 | //______________________________________________________________________ | |
159 | void AliITSpList::AddSignal(Int_t i,Int_t j,Int_t trk,Int_t ht,Int_t mod, | |
160 | Double_t signal){ | |
161 | // Adds a Signal value to the TClonesArray at i,j. | |
162 | // Creates the AliITSpListItem | |
163 | // if needed. | |
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. | |
175 | Int_t index = GetIndex(i,j); | |
176 | if (index<0) return; | |
177 | TClonesArray &rfa = *fa; | |
178 | if(GetpListItem(index)==0){ // must create AliITSpListItem | |
179 | new(rfa[index])AliITSpListItem(trk,ht,mod,index,signal); | |
180 | }else{ // AliITSpListItem exists, just add signal to it. | |
181 | GetpListItem(index)->AddSignal(trk,ht,mod,index,signal); | |
182 | } // end if | |
183 | if(index>=fEntries) fEntries = index +1; | |
184 | } | |
185 | //______________________________________________________________________ | |
186 | void AliITSpList::AddNoise(Int_t i,Int_t j,Int_t mod,Double_t noise){ | |
187 | // Adds a noise value to the TClonesArray at i,j. | |
188 | // Creates the AliITSpListItem | |
189 | // if needed. | |
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. | |
198 | Int_t index = GetIndex(i,j); | |
199 | TClonesArray &rfa = *fa; | |
200 | if(GetpListItem(index)==0){ // most create AliITSpListItem | |
201 | new(rfa[index]) AliITSpListItem(mod,index,noise); | |
202 | }else{ // AliITSpListItem exists, just add signal to it. | |
203 | GetpListItem(index)->AddNoise(mod,index,noise); | |
204 | } // end if | |
205 | if(index>=fEntries) fEntries = index +1; | |
206 | } | |
207 | //______________________________________________________________________ | |
208 | void 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; | |
215 | return; | |
216 | } // end if | |
217 | i = index/fNj; | |
218 | j = index - fNj*i; | |
219 | return; | |
220 | } | |
221 | //______________________________________________________________________ | |
222 | Int_t AliITSpList::GetIndex(Int_t i, Int_t j) const { | |
223 | // returns the TClonesArray index for a given set of map indexes. | |
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 | } | |
231 | } |