]>
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 | **************************************************************************/ | |
15 | ||
16 | #include <TH1.h> | |
17 | #include <TObjArray.h> | |
18 | #include <TMath.h> | |
19 | ||
20 | #include "AliITSMapA2.h" | |
21 | #include "AliITSsegmentation.h" | |
22 | #include "AliITSresponse.h" | |
23 | #include "AliITSdigit.h" | |
24 | ||
766e3066 | 25 | //////////////////////////////////////////////////////////////////////// |
26 | // Map Class for ITS. Implementation A2. In this implementation, the // | |
27 | // 2 dimensional (iz,ix) map is filled with Double precision floating // | |
28 | // point values. Since this class is derived for AliITSMapA1 it also // | |
29 | // has all of the functionality of that class as well. For each // | |
30 | // cell a corresponding TObject, a hit, can also be stored. // | |
31 | // The detector geometry is accessed via the that detectors // | |
32 | // segmentation class and stored here for conveniance. // | |
33 | //////////////////////////////////////////////////////////////////////// | |
e8189707 | 34 | |
35 | ClassImp(AliITSMapA2) | |
36 | ||
766e3066 | 37 | //______________________________________________________________________ |
38 | AliITSMapA2::AliITSMapA2(){ | |
39 | // default constructor | |
94d90134 | 40 | |
766e3066 | 41 | fSegmentation = 0; |
42 | fNpz = 0; | |
43 | fNpx = 0; | |
44 | fMaxIndex = 0; | |
45 | fHitMapD = 0; | |
46 | fObjects = 0; | |
47 | fNobjects = 0; | |
48 | fMapThresholdD =0.; | |
e8189707 | 49 | } |
766e3066 | 50 | //______________________________________________________________________ |
51 | AliITSMapA2::AliITSMapA2(AliITSsegmentation *seg){ | |
52 | //constructor | |
e8189707 | 53 | |
766e3066 | 54 | fScaleSizeZ = 1; |
55 | fScaleSizeX = 1; | |
56 | fSegmentation = seg; | |
57 | fNpz = fSegmentation->Npz(); | |
58 | fNpx = fSegmentation->Npx(); | |
59 | fMaxIndex = fNpz*fNpx+fNpx; // 2 halves of detector | |
645ecce9 | 60 | fHitMapD = new Double_t[fMaxIndex+1]; |
766e3066 | 61 | fMapThresholdD = 0.; |
62 | fObjects = 0; | |
63 | fNobjects = 0; | |
64 | ClearMap(); | |
e8189707 | 65 | } |
766e3066 | 66 | //______________________________________________________________________ |
67 | AliITSMapA2::AliITSMapA2(AliITSsegmentation *seg, | |
68 | Int_t scalesizeX, Int_t scalesizeZ){ | |
69 | //constructor | |
e8189707 | 70 | |
766e3066 | 71 | fSegmentation = seg; |
72 | fScaleSizeX = scalesizeX; | |
73 | fScaleSizeZ = scalesizeZ; | |
74 | fNpz = fScaleSizeZ*fSegmentation->Npz(); | |
75 | fNpx = fScaleSizeX*fSegmentation->Npx(); | |
76 | fMaxIndex = fNpz*fNpx+fNpx; // 2 halves of detector | |
e3df8399 | 77 | fHitMapD = new Double_t[fMaxIndex+1]; |
766e3066 | 78 | fMapThresholdD = 0.; |
79 | fObjects = 0; | |
80 | fNobjects = 0; | |
81 | ClearMap(); | |
e8189707 | 82 | } |
766e3066 | 83 | //______________________________________________________________________ |
84 | AliITSMapA2::AliITSMapA2(AliITSsegmentation *seg, TObjArray *obj, | |
85 | Double_t thresh){ | |
86 | //constructor | |
e8189707 | 87 | |
766e3066 | 88 | fNobjects = 0; |
89 | fScaleSizeZ = 1; | |
90 | fScaleSizeX = 1; | |
91 | fSegmentation = seg; | |
92 | fNpz = fSegmentation->Npz(); | |
93 | fNpx = fSegmentation->Npx(); | |
94 | fMaxIndex = fNpz*fNpx+fNpx; // 2 halves of detector | |
e3df8399 | 95 | fHitMapD = new Double_t[fMaxIndex+1]; |
766e3066 | 96 | fObjects = obj; |
97 | if (fObjects) fNobjects = fObjects->GetEntriesFast(); | |
98 | fMapThresholdD = thresh; | |
99 | ClearMap(); | |
e8189707 | 100 | } |
766e3066 | 101 | //______________________________________________________________________ |
102 | AliITSMapA2::~AliITSMapA2(){ | |
103 | //destructor | |
e8189707 | 104 | |
766e3066 | 105 | if (fHitMapD) delete[] fHitMapD; |
e8189707 | 106 | } |
766e3066 | 107 | //______________________________________________________________________ |
ac74f489 | 108 | AliITSMapA2::AliITSMapA2(const AliITSMapA2 &source) : AliITSMapA1(source){ |
766e3066 | 109 | // Copy Constructor |
e8189707 | 110 | |
766e3066 | 111 | if(&source == this) return; |
112 | ||
113 | this->fMapThresholdD = source.fMapThresholdD; | |
114 | this->fScaleSizeX = source.fScaleSizeX; | |
115 | this->fScaleSizeZ = source.fScaleSizeZ; | |
116 | this->fHitMapD = source.fHitMapD; | |
117 | return; | |
e8189707 | 118 | } |
766e3066 | 119 | //______________________________________________________________________ |
120 | AliITSMapA2& AliITSMapA2::operator=(const AliITSMapA2 &source) { | |
121 | // Assignment operator | |
e8189707 | 122 | |
766e3066 | 123 | if(&source == this) return *this; |
124 | ||
125 | this->fMapThresholdD = source.fMapThresholdD; | |
126 | this->fScaleSizeX = source.fScaleSizeX; | |
127 | this->fScaleSizeZ = source.fScaleSizeZ; | |
128 | this->fHitMapD = source.fHitMapD; | |
129 | return *this; | |
e8189707 | 130 | } |
766e3066 | 131 | //______________________________________________________________________ |
132 | void AliITSMapA2::ClearMap(){ | |
133 | //clear array | |
e8189707 | 134 | |
766e3066 | 135 | memset(fHitMapD,0,sizeof(Double_t)*fMaxIndex); |
136 | } | |
137 | //______________________________________________________________________ | |
138 | void AliITSMapA2::FillMap(){ | |
139 | // fills signal map from digits - apply a threshold for signal | |
e8189707 | 140 | |
766e3066 | 141 | if (!fObjects) return; |
142 | ||
143 | Int_t ndigits = fObjects->GetEntriesFast(); | |
144 | if (!ndigits) return; | |
145 | ||
146 | AliITSdigit *dig; | |
147 | for (Int_t ndig=0; ndig<ndigits; ndig++) { | |
148 | dig = (AliITSdigit*)fObjects->UncheckedAt(ndig); | |
ecee53fc | 149 | Double_t signal = (Double_t)(dig->GetSignal()); |
150 | if (signal > fMapThresholdD) SetHit(dig->GetCoord1(),dig->GetCoord2(),signal); | |
766e3066 | 151 | } // end for ndig |
e8189707 | 152 | } |
766e3066 | 153 | //______________________________________________________________________ |
766e3066 | 154 | void AliITSMapA2::FlagHit(Int_t iz, Int_t ix){ |
155 | //flag an entry | |
e8189707 | 156 | |
766e3066 | 157 | fHitMapD[CheckedIndex(iz, ix)]= |
158 | -1000.*TMath::Abs((Int_t)(fHitMapD[CheckedIndex(iz, ix)])+1.); | |
e8189707 | 159 | } |
766e3066 | 160 | //______________________________________________________________________ |
766e3066 | 161 | TObject* AliITSMapA2::GetHit(Int_t i, Int_t dummy){ |
162 | //return a pointer to the 1D histogram | |
e8189707 | 163 | |
ac74f489 | 164 | dummy = 0; // added to remove unused variable warning. |
766e3066 | 165 | if (fObjects) { |
166 | return fObjects->UncheckedAt(i); | |
167 | } else return NULL; | |
e8189707 | 168 | } |
766e3066 | 169 | //______________________________________________________________________ |
170 | Double_t AliITSMapA2::GetSignal(Int_t index){ | |
171 | //get signal in a cell | |
e8189707 | 172 | |
766e3066 | 173 | if (index<fMaxIndex) return (index <0) ? 0. : fHitMapD[index]; |
174 | else return 0.; | |
e8189707 | 175 | } |
766e3066 | 176 | //______________________________________________________________________ |
177 | FlagType AliITSMapA2::TestHit(Int_t iz, Int_t ix){ | |
178 | // check if the entry has already been flagged | |
94d90134 | 179 | |
180 | if (CheckedIndex(iz, ix) < 0) return kEmpty; | |
f50d33af | 181 | Int_t inf=(Int_t)fHitMapD[CheckedIndex(iz, ix)]; |
e8189707 | 182 | |
183 | if (inf <= -1000) { | |
766e3066 | 184 | return kUsed; |
e8189707 | 185 | } else if (inf == 0) { |
766e3066 | 186 | return kEmpty; |
e8189707 | 187 | } else { |
766e3066 | 188 | return kUnused; |
189 | } // end if inf... | |
e8189707 | 190 | } |
766e3066 | 191 | //______________________________________________________________________ |
192 | void AliITSMapA2::FillMapFromHist(){ | |
193 | // fills map from 1D histograms | |
e8189707 | 194 | |
766e3066 | 195 | if (!fObjects) return; |
196 | ||
197 | // an example | |
198 | for( Int_t i=0; i<fNobjects; i++) { | |
199 | TH1F *hist =(TH1F *)fObjects->UncheckedAt(i); | |
200 | Int_t nsamples = hist->GetNbinsX(); | |
201 | for( Int_t j=0; j<nsamples; j++) { | |
202 | Double_t signal = (Double_t)(hist->GetBinContent(j+1)); | |
203 | if (signal > fMapThresholdD) SetHit(i,j,signal); | |
204 | } // end for j | |
205 | } // end for i | |
e8189707 | 206 | } |
766e3066 | 207 | //______________________________________________________________________ |
208 | void AliITSMapA2::FillHist(){ | |
209 | // fill 1D histograms from map | |
210 | ||
211 | if (!fObjects || fScaleSizeX != 1) return; | |
212 | ||
213 | // an example | |
214 | for( Int_t i=0; i<fNobjects; i++) { | |
215 | TH1F *hist =(TH1F *)fObjects->UncheckedAt(i); | |
216 | for( Int_t j=0; j<fNpx; j++) { | |
217 | Double_t signal=GetSignal(i,j); | |
218 | if (signal > fMapThresholdD) hist->Fill((Float_t)j,signal); | |
219 | } // end for j | |
220 | } // end for i | |
e8189707 | 221 | } |
766e3066 | 222 | //______________________________________________________________________ |
223 | void AliITSMapA2::ResetHist(){ | |
224 | // Reset histograms | |
225 | ||
226 | if (!fObjects) return; | |
227 | ||
228 | for( Int_t i=0; i<fNobjects; i++) { | |
229 | if ((*fObjects)[i]) ((TH1F*)(*fObjects)[i])->Reset(); | |
230 | } // end for i | |
e8189707 | 231 | } |
766e3066 | 232 | //______________________________________________________________________ |
233 | void AliITSMapA2::AddSignal(Int_t iz,Int_t ix,Double_t sig){ | |
234 | // Addes sig to cell iz. equivalent to the very common | |
235 | // sig = fMapA2->GetSignal(iz,ix) + sig; fMapA2->SetHit(iz,ix,sig); | |
e8189707 | 236 | |
766e3066 | 237 | |
238 | Int_t index=GetHitIndex(iz,ix); | |
239 | if(index<0) return; | |
240 | fHitMapD[CheckedIndex(iz, ix)] += sig; | |
241 | } |