]>
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 | #include <TObjArray.h> | |
16 | #include <TMath.h> | |
17 | ||
18 | #include "AliITSMapA1.h" | |
19 | #include "AliITSsegmentation.h" | |
20 | #include "AliITSresponse.h" | |
21 | #include "AliITSdigit.h" | |
22 | ||
23 | //////////////////////////////////////////////////////////////////////// | |
24 | // Map Class for ITS. Implementation A1. In this implementation, the // | |
25 | // 2 dimensional (iz,ix) map is filled with integers values. For each // | |
26 | // cell a corresponding TObject, a hit, can also be stored. // | |
27 | // The detector geometry is accessed via the that detectors // | |
28 | // segmentation class and stored here for conveniance. // | |
29 | //////////////////////////////////////////////////////////////////////// | |
30 | ||
31 | ClassImp(AliITSMapA1) | |
32 | //______________________________________________________________________ | |
33 | AliITSMapA1::AliITSMapA1(){ | |
34 | // default constructor | |
35 | ||
36 | fSegmentation = 0; | |
37 | fNpz = 0; | |
38 | fNpx = 0; | |
39 | fMaxIndex = 0; | |
40 | fHitMap = 0; | |
41 | fObjects = 0; | |
42 | fNobjects = 0; | |
43 | fMapThreshold = 0; | |
44 | } | |
45 | //______________________________________________________________________ | |
46 | AliITSMapA1::AliITSMapA1(AliITSsegmentation *seg){ | |
47 | //constructor | |
48 | ||
49 | fSegmentation = seg; | |
50 | fNpz = fSegmentation->Npz(); | |
51 | fNpx = fSegmentation->Npx(); | |
52 | fMaxIndex = fNpz*fNpx+fNpx; // 2 halves of detector | |
53 | fHitMap = new Int_t[fMaxIndex]; | |
54 | fObjects = 0; | |
55 | fNobjects = 0; | |
56 | fMapThreshold = 0; | |
57 | ClearMap(); | |
58 | } | |
59 | //______________________________________________________________________ | |
60 | AliITSMapA1::AliITSMapA1(AliITSsegmentation *seg, TObjArray *obj){ | |
61 | //constructor | |
62 | ||
63 | fNobjects = 0; | |
64 | fSegmentation = seg; | |
65 | fNpz = fSegmentation->Npz(); | |
66 | fNpx = fSegmentation->Npx(); | |
67 | fMaxIndex = fNpz*fNpx+fNpx; // 2 halves of detector | |
68 | fHitMap = new Int_t[fMaxIndex]; | |
69 | fObjects = obj; | |
70 | if(fObjects) fNobjects = fObjects->GetEntriesFast(); | |
71 | fMapThreshold = 0; | |
72 | ClearMap(); | |
73 | } | |
74 | //______________________________________________________________________ | |
75 | AliITSMapA1::AliITSMapA1(AliITSsegmentation *seg, TObjArray *obj, Int_t thr){ | |
76 | //constructor | |
77 | ||
78 | fNobjects = 0; | |
79 | fSegmentation = seg; | |
80 | fNpz = fSegmentation->Npz(); | |
81 | fNpx = fSegmentation->Npx(); | |
82 | fMaxIndex = fNpz*fNpx+fNpx; // 2 halves of detector | |
83 | fHitMap = new Int_t[fMaxIndex]; | |
84 | fObjects = obj; | |
85 | if(fObjects) fNobjects = fObjects->GetEntriesFast(); | |
86 | fMapThreshold = thr; | |
87 | ClearMap(); | |
88 | } | |
89 | //______________________________________________________________________ | |
90 | AliITSMapA1::~AliITSMapA1(){ | |
91 | //destructor | |
92 | ||
93 | if(fHitMap) delete[] fHitMap; | |
94 | } | |
95 | //_________________________________________________________________________ | |
96 | AliITSMapA1& AliITSMapA1::operator=(const AliITSMapA1 &source) { | |
97 | // Assignment operator | |
98 | ||
99 | if(&source == this) return *this; | |
100 | ||
101 | this->fNpx = source.fNpx; | |
102 | this->fNpz = source.fNpz; | |
103 | this->fObjects = source.fObjects; | |
104 | this->fNobjects = source.fNobjects; | |
105 | this->fMaxIndex = source.fMaxIndex; | |
106 | this->fHitMap = source.fHitMap; | |
107 | this->fMapThreshold = source.fMapThreshold; | |
108 | return *this; | |
109 | } | |
110 | //______________________________________________________________________ | |
111 | AliITSMapA1::AliITSMapA1(const AliITSMapA1 &source){ | |
112 | // Copy Constructor | |
113 | ||
114 | *this = source; | |
115 | } | |
116 | //______________________________________________________________________ | |
117 | void AliITSMapA1::ClearMap(){ | |
118 | //clear array | |
119 | ||
120 | memset(fHitMap,0,sizeof(int)*fMaxIndex); | |
121 | } | |
122 | //______________________________________________________________________ | |
123 | void AliITSMapA1::SetArray(TObjArray *obj){ | |
124 | // set array of objects | |
125 | ||
126 | fObjects = obj; | |
127 | if (fObjects) fNobjects = fObjects->GetEntriesFast(); | |
128 | } | |
129 | //______________________________________________________________________ | |
130 | Int_t AliITSMapA1::CheckedIndex(Int_t iz, Int_t ix){ | |
131 | //check boundaries and return an index in array | |
132 | Int_t index=fNpx*iz+ix; | |
133 | ||
134 | //if (index > fMaxIndex) { | |
135 | if (index > fMaxIndex || index < 0) { | |
136 | printf("\n \n \n Try to read/write outside array !!!!" | |
137 | " \n \n %d %d %d %d %d %d \n",iz,ix,fMaxIndex,index,fNpz,fNpx); | |
138 | // force crash | |
139 | return -1; | |
140 | } else { | |
141 | return index; | |
142 | } // end if index>max or < 0 | |
143 | } | |
144 | //______________________________________________________________________ | |
145 | void AliITSMapA1::FillMap(){ | |
146 | // fill array with digits indices | |
147 | ||
148 | Int_t ndigits = fObjects->GetEntriesFast(); | |
149 | if (!ndigits) return; | |
150 | ||
151 | AliITSdigit *dig; | |
152 | for (Int_t ndig=0; ndig<ndigits; ndig++) { | |
153 | dig = (AliITSdigit*)fObjects->UncheckedAt(ndig); | |
154 | if(dig->fSignal > fMapThreshold) { | |
155 | SetHit(dig->fCoord1,dig->fCoord2,ndig); | |
156 | } // end if fSignal > fMapthreshold | |
157 | } // end for ndig | |
158 | } | |
159 | //______________________________________________________________________ | |
160 | void AliITSMapA1::SetHit(Int_t iz, Int_t ix, Int_t idigit){ | |
161 | // set the digit index at a certain position in array | |
162 | ||
163 | fHitMap[CheckedIndex(iz, ix)]=idigit+1; | |
164 | } | |
165 | //______________________________________________________________________ | |
166 | void AliITSMapA1::DeleteHit(Int_t iz, Int_t ix){ | |
167 | // delete an entry in array | |
168 | ||
169 | fHitMap[CheckedIndex(iz, ix)]=0; | |
170 | } | |
171 | //______________________________________________________________________ | |
172 | void AliITSMapA1::FlagHit(Int_t iz, Int_t ix){ | |
173 | // flag an entry in array | |
174 | ||
175 | fHitMap[CheckedIndex(iz, ix)] = -TMath::Abs(fHitMap[CheckedIndex(iz, ix)]); | |
176 | } | |
177 | //______________________________________________________________________ | |
178 | Int_t AliITSMapA1::GetHitIndex(Int_t iz, Int_t ix){ | |
179 | // return the digit index from a specific entry in array | |
180 | ||
181 | return TMath::Abs(fHitMap[CheckedIndex(iz, ix)])-1; | |
182 | } | |
183 | //______________________________________________________________________ | |
184 | TObject* AliITSMapA1::GetHit(Int_t iz, Int_t ix){ | |
185 | // return the pointer to the digit | |
186 | ||
187 | Int_t index=GetHitIndex(iz,ix); | |
188 | // Force crash if index does not exist ! | |
189 | return (index <0) ? 0 : fObjects->UncheckedAt(GetHitIndex(iz,ix)); | |
190 | } | |
191 | //______________________________________________________________________ | |
192 | Double_t AliITSMapA1::GetSignal(Int_t iz, Int_t ix){ | |
193 | // get a pad signal | |
194 | Double_t signal; | |
195 | ||
196 | AliITSdigit *dig = (AliITSdigit*)GetHit(iz,ix); | |
197 | if(dig) signal=(Double_t)dig->fSignal; | |
198 | else signal=0.; | |
199 | return signal; | |
200 | } | |
201 | //______________________________________________________________________ | |
202 | FlagType AliITSMapA1::TestHit(Int_t iz, Int_t ix){ | |
203 | // check whether the digit has already been flagged | |
204 | ||
205 | if (CheckedIndex(iz, ix) < 0) return kEmpty; | |
206 | Int_t inf=fHitMap[CheckedIndex(iz, ix)]; | |
207 | if (inf < 0) { | |
208 | return kUsed; | |
209 | } else if (inf == 0) { | |
210 | return kEmpty; | |
211 | } else { | |
212 | return kUnused; | |
213 | } // end if inf | |
214 | } | |
215 |