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