1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
17 #include <TObjArray.h>
20 #include "AliITSMapA2.h"
21 #include "AliITSsegmentation.h"
22 #include "AliITSresponse.h"
23 #include "AliITSdigit.h"
28 AliITSMapA2::AliITSMapA2(AliITSsegmentation *seg)
34 fNpz=fSegmentation->Npz();
35 fNpx=fSegmentation->Npx();
36 fMaxIndex=fNpz*fNpx+fNpx; // 2 halves of detector
38 fHitMap = new Double_t[fMaxIndex];
42 //--------------------------------------
43 AliITSMapA2::AliITSMapA2(AliITSsegmentation *seg, Int_t scalesizeX, Int_t scalesizeZ)
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
53 fHitMap = new Double_t[fMaxIndex];
58 //--------------------------------------
59 AliITSMapA2::AliITSMapA2(AliITSsegmentation *seg, TObjArray *obj, Double_t thresh)
65 fNpz=fSegmentation->Npz();
66 fNpx=fSegmentation->Npx();
67 fMaxIndex=fNpz*fNpx+fNpx; // 2 halves of detector
69 fHitMap = new Double_t[fMaxIndex];
71 if (fObjects) fNobjects = fObjects->GetEntriesFast();
72 fMapThreshold = thresh;
75 //--------------------------------------
78 AliITSMapA2::~AliITSMapA2()
81 if (fHitMap) delete[] fHitMap;
83 //--------------------------------------
85 //__________________________________________________________________________
86 AliITSMapA2::AliITSMapA2(const AliITSMapA2 &source){
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;
96 //_________________________________________________________________________
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;
108 //_________________________________________________________________________
109 void AliITSMapA2::ClearMap()
112 memset(fHitMap,0,sizeof(Double_t)*fMaxIndex);
115 //--------------------------------------
116 void AliITSMapA2::FillMap()
119 // fills signal map from digits - apply a threshold for signal
121 if (!fObjects) return;
123 Int_t ndigits = fObjects->GetEntriesFast();
124 if (!ndigits) return;
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);
134 //--------------------------------------
135 void AliITSMapA2::SetHit(Int_t iz, Int_t ix, Double_t signal)
137 // set signal at a certain position in array
138 fHitMap[CheckedIndex(iz, ix)]=signal;
142 //--------------------------------------
143 void AliITSMapA2::DeleteHit(Int_t iz, Int_t ix)
145 //set the entry value to zero
146 fHitMap[CheckedIndex(iz, ix)]=0;
149 //--------------------------------------
150 void AliITSMapA2::FlagHit(Int_t iz, Int_t ix)
153 fHitMap[CheckedIndex(iz, ix)]=
154 -1000.*TMath::Abs((Int_t)(fHitMap[CheckedIndex(iz, ix)])+1.);
158 //--------------------------------------
159 Int_t AliITSMapA2::GetHitIndex(Int_t iz, Int_t ix)
161 //return the index of an entry in array
162 return CheckedIndex(iz, ix);
165 //--------------------------------------
166 TObject* AliITSMapA2::GetHit(Int_t i, Int_t dummy)
169 //return a pointer to the 1D histogram
172 return fObjects->UncheckedAt(i);
178 //--------------------------------------
179 Double_t AliITSMapA2::GetSignal(Int_t iz, Int_t ix)
181 //get signal in a cell
182 Int_t index=GetHitIndex(iz,ix);
183 return (index <0) ? 0. : fHitMap[CheckedIndex(iz, ix)];
186 //--------------------------------------
187 Double_t AliITSMapA2::GetSignal(Int_t index)
189 //get signal in a cell
190 if (index<fMaxIndex) return (index <0) ? 0. : fHitMap[index];
193 //--------------------------------------
194 FlagType AliITSMapA2::TestHit(Int_t iz, Int_t ix)
196 // check if the entry has already been flagged
197 Int_t inf=(Int_t)fHitMap[CheckedIndex(iz, ix)];
201 } else if (inf == 0) {
208 //--------------------------------------
209 void AliITSMapA2::FillMapFromHist()
212 // fills map from 1D histograms
214 if (!fObjects) return;
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);
227 //--------------------------------------
228 void AliITSMapA2::FillHist()
231 // fill 1D histograms from map
232 if (!fObjects || fScaleSizeX != 1) return;
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);
244 //--------------------------------------
245 void AliITSMapA2::ResetHist()
251 if (!fObjects) return;
253 for( Int_t i=0; i<fNobjects; i++) {
254 if ((*fObjects)[i]) ((TH1F*)(*fObjects)[i])->Reset();