]> git.uio.no Git - u/mrichter/AliRoot.git/blame - ITS/AliITSMapA2.cxx
Latest Fixes from M.Bondila
[u/mrichter/AliRoot.git] / ITS / AliITSMapA2.cxx
CommitLineData
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
25
26ClassImp(AliITSMapA2)
27
28 AliITSMapA2::AliITSMapA2(AliITSsegmentation *seg)
29{
30 //constructor
31 fScaleSizeZ=1;
32 fScaleSizeX=1;
33 fSegmentation = seg;
34 fNpz=fSegmentation->Npz();
35 fNpx=fSegmentation->Npx();
36 fMaxIndex=fNpz*fNpx+fNpx; // 2 halves of detector
37
38 fHitMap = new Double_t[fMaxIndex];
39 fMapThreshold=0.;
40 ClearMap();
41}
42//--------------------------------------
43 AliITSMapA2::AliITSMapA2(AliITSsegmentation *seg, Int_t scalesizeX, Int_t scalesizeZ)
44{
45 //constructor
46 fSegmentation = seg;
47 fScaleSizeX=scalesizeX;
48 fScaleSizeZ=scalesizeZ;
49 fNpz=fScaleSizeZ*fSegmentation->Npz();
50 fNpx=fScaleSizeX*fSegmentation->Npx();
51 fMaxIndex=fNpz*fNpx+fNpx; // 2 halves of detector
52
53 fHitMap = new Double_t[fMaxIndex];
54 fMapThreshold=0.;
55 ClearMap();
56}
57
58//--------------------------------------
59AliITSMapA2::AliITSMapA2(AliITSsegmentation *seg, TObjArray *obj, Double_t thresh)
60{
61 //constructor
62 fScaleSizeZ=1;
63 fScaleSizeX=1;
64 fSegmentation = seg;
65 fNpz=fSegmentation->Npz();
66 fNpx=fSegmentation->Npx();
67 fMaxIndex=fNpz*fNpx+fNpx; // 2 halves of detector
68
69 fHitMap = new Double_t[fMaxIndex];
70 fObjects = obj;
71 if (fObjects) fNobjects = fObjects->GetEntriesFast();
72 fMapThreshold = thresh;
73 ClearMap();
74}
75//--------------------------------------
76
77
78AliITSMapA2::~AliITSMapA2()
79{
80 //destructor
81 if (fHitMap) delete[] fHitMap;
82}
83//--------------------------------------
84
85//__________________________________________________________________________
86AliITSMapA2::AliITSMapA2(const AliITSMapA2 &source){
87 // Copy Constructor
88 if(&source == this) return;
89 this->fMapThreshold = source.fMapThreshold;
90 this->fScaleSizeX = source.fScaleSizeX;
91 this->fScaleSizeZ = source.fScaleSizeZ;
92 this->fHitMap = source.fHitMap;
93 return;
94}
95
96//_________________________________________________________________________
97AliITSMapA2&
98 AliITSMapA2::operator=(const AliITSMapA2 &source) {
99 // Assignment operator
100 if(&source == this) return *this;
101 this->fMapThreshold = source.fMapThreshold;
102 this->fScaleSizeX = source.fScaleSizeX;
103 this->fScaleSizeZ = source.fScaleSizeZ;
104 this->fHitMap = source.fHitMap;
105 return *this;
106}
107
108//_________________________________________________________________________
109void AliITSMapA2::ClearMap()
110{
111 //clear array
112 memset(fHitMap,0,sizeof(Double_t)*fMaxIndex);
113}
114
115//--------------------------------------
116void AliITSMapA2::FillMap()
117{
118
119 // fills signal map from digits - apply a threshold for signal
120
121 if (!fObjects) return;
122
123 Int_t ndigits = fObjects->GetEntriesFast();
124 if (!ndigits) return;
125
126 AliITSdigit *dig;
127 for (Int_t ndig=0; ndig<ndigits; ndig++) {
128 dig = (AliITSdigit*)fObjects->UncheckedAt(ndig);
129 Double_t signal = (Double_t)(dig->fSignal);
130 if (signal >= fMapThreshold) SetHit(dig->fCoord1,dig->fCoord2,signal);
131 }
132}
133
134//--------------------------------------
135void AliITSMapA2::SetHit(Int_t iz, Int_t ix, Double_t signal)
136{
137 // set signal at a certain position in array
138 fHitMap[CheckedIndex(iz, ix)]=signal;
139
140}
141
142//--------------------------------------
143void AliITSMapA2::DeleteHit(Int_t iz, Int_t ix)
144{
145 //set the entry value to zero
146 fHitMap[CheckedIndex(iz, ix)]=0;
147}
148
149//--------------------------------------
150void AliITSMapA2::FlagHit(Int_t iz, Int_t ix)
151{
152 //flag an entry
153 fHitMap[CheckedIndex(iz, ix)]=
154 -1000.*TMath::Abs((Int_t)(fHitMap[CheckedIndex(iz, ix)])+1.);
155
156}
157
158//--------------------------------------
159Int_t AliITSMapA2::GetHitIndex(Int_t iz, Int_t ix)
160{
161 //return the index of an entry in array
162 return CheckedIndex(iz, ix);
163}
164
165//--------------------------------------
166TObject* AliITSMapA2::GetHit(Int_t i, Int_t dummy)
167{
168
169 //return a pointer to the 1D histogram
170 if (fObjects) {
171
172 return fObjects->UncheckedAt(i);
173
174 } else return NULL;
175
176}
177
178//--------------------------------------
179Double_t AliITSMapA2::GetSignal(Int_t iz, Int_t ix)
180{
181 //get signal in a cell
182 Int_t index=GetHitIndex(iz,ix);
183 return (index <0) ? 0. : fHitMap[CheckedIndex(iz, ix)];
184}
185
186//--------------------------------------
187Double_t AliITSMapA2::GetSignal(Int_t index)
188{
189 //get signal in a cell
190 if (index<fMaxIndex) return (index <0) ? 0. : fHitMap[index];
191 else return 0.;
192}
193//--------------------------------------
194FlagType AliITSMapA2::TestHit(Int_t iz, Int_t ix)
195{
196 // check if the entry has already been flagged
197 Int_t inf=(Int_t)fHitMap[CheckedIndex(iz, ix)];
198
199 if (inf <= -1000) {
200 return kUsed;
201 } else if (inf == 0) {
202 return kEmpty;
203 } else {
204 return kUnused;
205 }
206}
207
208//--------------------------------------
209void AliITSMapA2::FillMapFromHist()
210{
211
212 // fills map from 1D histograms
213
214 if (!fObjects) return;
215
216 // an example
217 for( Int_t i=0; i<fNobjects; i++) {
218 TH1F *hist =(TH1F *)fObjects->UncheckedAt(i);
219 Int_t nsamples = hist->GetNbinsX();
220 for( Int_t j=0; j<nsamples; j++) {
221 Double_t signal = (Double_t)(hist->GetBinContent(j+1));
222 if (signal >= fMapThreshold) SetHit(i,j,signal);
223 }
224 }
225
226}
227//--------------------------------------
228void AliITSMapA2::FillHist()
229{
230
231 // fill 1D histograms from map
232 if (!fObjects || fScaleSizeX != 1) return;
233
234 // an example
235 for( Int_t i=0; i<fNobjects; i++) {
236 TH1F *hist =(TH1F *)fObjects->UncheckedAt(i);
237 for( Int_t j=0; j<fNpx; j++) {
238 Double_t signal=GetSignal(i,j);
239 if (signal >= fMapThreshold) hist->Fill((Float_t)j,signal);
240 }
241 }
242
243}
244//--------------------------------------
245void AliITSMapA2::ResetHist()
246{
247 //
248 // Reset histograms
249 //
250
251 if (!fObjects) return;
252
253 for( Int_t i=0; i<fNobjects; i++) {
254 if ((*fObjects)[i]) ((TH1F*)(*fObjects)[i])->Reset();
255 }
256
257}
258