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()
30 // default constructor
42 AliITSMapA2::AliITSMapA2(AliITSsegmentation *seg)
48 fNpz=fSegmentation->Npz();
49 fNpx=fSegmentation->Npx();
50 fMaxIndex=fNpz*fNpx+fNpx; // 2 halves of detector
52 fHitMap = new Double_t[fMaxIndex];
58 //--------------------------------------
59 AliITSMapA2::AliITSMapA2(AliITSsegmentation *seg, Int_t scalesizeX, Int_t scalesizeZ)
63 fScaleSizeX=scalesizeX;
64 fScaleSizeZ=scalesizeZ;
65 fNpz=fScaleSizeZ*fSegmentation->Npz();
66 fNpx=fScaleSizeX*fSegmentation->Npx();
67 fMaxIndex=fNpz*fNpx+fNpx; // 2 halves of detector
69 fHitMap = new Double_t[fMaxIndex];
76 //--------------------------------------
77 AliITSMapA2::AliITSMapA2(AliITSsegmentation *seg, TObjArray *obj, Double_t thresh)
84 fNpz=fSegmentation->Npz();
85 fNpx=fSegmentation->Npx();
86 fMaxIndex=fNpz*fNpx+fNpx; // 2 halves of detector
88 fHitMap = new Double_t[fMaxIndex];
90 if (fObjects) fNobjects = fObjects->GetEntriesFast();
91 fMapThreshold = thresh;
94 //--------------------------------------
97 AliITSMapA2::~AliITSMapA2()
100 if (fHitMap) delete[] fHitMap;
102 //--------------------------------------
104 //__________________________________________________________________________
105 AliITSMapA2::AliITSMapA2(const AliITSMapA2 &source){
107 if(&source == this) return;
108 this->fMapThreshold = source.fMapThreshold;
109 this->fScaleSizeX = source.fScaleSizeX;
110 this->fScaleSizeZ = source.fScaleSizeZ;
111 this->fHitMap = source.fHitMap;
115 //_________________________________________________________________________
117 AliITSMapA2::operator=(const AliITSMapA2 &source) {
118 // Assignment operator
119 if(&source == this) return *this;
120 this->fMapThreshold = source.fMapThreshold;
121 this->fScaleSizeX = source.fScaleSizeX;
122 this->fScaleSizeZ = source.fScaleSizeZ;
123 this->fHitMap = source.fHitMap;
127 //_________________________________________________________________________
128 void AliITSMapA2::ClearMap()
131 memset(fHitMap,0,sizeof(Double_t)*fMaxIndex);
134 //--------------------------------------
135 void AliITSMapA2::FillMap()
138 // fills signal map from digits - apply a threshold for signal
140 if (!fObjects) return;
142 Int_t ndigits = fObjects->GetEntriesFast();
143 if (!ndigits) return;
146 for (Int_t ndig=0; ndig<ndigits; ndig++) {
147 dig = (AliITSdigit*)fObjects->UncheckedAt(ndig);
148 Double_t signal = (Double_t)(dig->fSignal);
149 if (signal > fMapThreshold) SetHit(dig->fCoord1,dig->fCoord2,signal);
153 //--------------------------------------
154 void AliITSMapA2::SetHit(Int_t iz, Int_t ix, Double_t signal)
156 // set signal at a certain position in array
157 fHitMap[CheckedIndex(iz, ix)]=signal;
161 //--------------------------------------
162 void AliITSMapA2::DeleteHit(Int_t iz, Int_t ix)
164 //set the entry value to zero
165 fHitMap[CheckedIndex(iz, ix)]=0;
168 //--------------------------------------
169 void AliITSMapA2::FlagHit(Int_t iz, Int_t ix)
172 fHitMap[CheckedIndex(iz, ix)]=
173 -1000.*TMath::Abs((Int_t)(fHitMap[CheckedIndex(iz, ix)])+1.);
177 //--------------------------------------
178 Int_t AliITSMapA2::GetHitIndex(Int_t iz, Int_t ix)
180 //return the index of an entry in array
181 return CheckedIndex(iz, ix);
184 //--------------------------------------
185 TObject* AliITSMapA2::GetHit(Int_t i, Int_t dummy)
188 //return a pointer to the 1D histogram
191 return fObjects->UncheckedAt(i);
197 //--------------------------------------
198 Double_t AliITSMapA2::GetSignal(Int_t iz, Int_t ix)
200 //get signal in a cell
201 Int_t index=GetHitIndex(iz,ix);
202 return (index <0) ? 0. : fHitMap[CheckedIndex(iz, ix)];
205 //--------------------------------------
206 Double_t AliITSMapA2::GetSignal(Int_t index)
208 //get signal in a cell
209 if (index<fMaxIndex) return (index <0) ? 0. : fHitMap[index];
212 //--------------------------------------
213 FlagType AliITSMapA2::TestHit(Int_t iz, Int_t ix)
215 // check if the entry has already been flagged
217 if (CheckedIndex(iz, ix) < 0) return kEmpty;
218 Int_t inf=(Int_t)fHitMap[CheckedIndex(iz, ix)];
222 } else if (inf == 0) {
229 //--------------------------------------
230 void AliITSMapA2::FillMapFromHist()
233 // fills map from 1D histograms
235 if (!fObjects) return;
238 for( Int_t i=0; i<fNobjects; i++) {
239 TH1F *hist =(TH1F *)fObjects->UncheckedAt(i);
240 Int_t nsamples = hist->GetNbinsX();
241 for( Int_t j=0; j<nsamples; j++) {
242 Double_t signal = (Double_t)(hist->GetBinContent(j+1));
243 if (signal > fMapThreshold) SetHit(i,j,signal);
248 //--------------------------------------
249 void AliITSMapA2::FillHist()
252 // fill 1D histograms from map
253 if (!fObjects || fScaleSizeX != 1) return;
256 for( Int_t i=0; i<fNobjects; i++) {
257 TH1F *hist =(TH1F *)fObjects->UncheckedAt(i);
258 for( Int_t j=0; j<fNpx; j++) {
259 Double_t signal=GetSignal(i,j);
260 if (signal > fMapThreshold) hist->Fill((Float_t)j,signal);
265 //--------------------------------------
266 void AliITSMapA2::ResetHist()
272 if (!fObjects) return;
274 for( Int_t i=0; i<fNobjects; i++) {
275 if ((*fObjects)[i]) ((TH1F*)(*fObjects)[i])->Reset();