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>
19 #include "AliITSMapA2.h"
20 #include "AliITSsegmentation.h"
21 #include "AliITSdigit.h"
23 ////////////////////////////////////////////////////////////////////////
24 // Map Class for ITS. Implementation A2. In this implementation, the //
25 // 2 dimensional (iz,ix) map is filled with Double precision floating //
26 // point values. Since this class is derived for AliITSMapA1 it also //
27 // has all of the functionality of that class as well. For each //
28 // cell a corresponding TObject, a hit, can also be stored. //
29 // The detector geometry is accessed via the that detectors //
30 // segmentation class and stored here for conveniance. //
31 ////////////////////////////////////////////////////////////////////////
35 //______________________________________________________________________
36 AliITSMapA2::AliITSMapA2():
41 // default constructor
50 //______________________________________________________________________
51 AliITSMapA2::AliITSMapA2(AliITSsegmentation *seg):
59 fNpz = fSegmentation->Npz();
60 fNpx = fSegmentation->Npx();
61 fMaxIndex = fNpz*fNpx+fNpx; // 2 halves of detector
62 fHitMapD = new Double_t[fMaxIndex+1];
67 //______________________________________________________________________
68 AliITSMapA2::AliITSMapA2(AliITSsegmentation *seg,
69 Int_t scalesizeX, Int_t scalesizeZ):
72 fScaleSizeX(scalesizeX),
73 fScaleSizeZ(scalesizeZ){
77 fNpz = fScaleSizeZ*fSegmentation->Npz();
78 fNpx = fScaleSizeX*fSegmentation->Npx();
79 fMaxIndex = fNpz*fNpx+fNpx; // 2 halves of detector
80 fHitMapD = new Double_t[fMaxIndex+1];
85 //______________________________________________________________________
86 AliITSMapA2::AliITSMapA2(AliITSsegmentation *seg, TObjArray *obj,
89 fMapThresholdD(thresh),
96 fNpz = fSegmentation->Npz();
97 fNpx = fSegmentation->Npx();
98 fMaxIndex = fNpz*fNpx+fNpx; // 2 halves of detector
99 fHitMapD = new Double_t[fMaxIndex+1];
101 if (fObjects) fNobjects = fObjects->GetEntriesFast();
104 //______________________________________________________________________
105 AliITSMapA2::~AliITSMapA2(){
108 if (fHitMapD) delete[] fHitMapD;
112 //______________________________________________________________________
113 void AliITSMapA2::ClearMap(){
116 memset(fHitMapD,0,sizeof(Double_t)*fMaxIndex);
118 //______________________________________________________________________
119 void AliITSMapA2::FillMap(){
120 // fills signal map from digits - apply a threshold for signal
122 if (!fObjects) return;
124 Int_t ndigits = fObjects->GetEntriesFast();
125 if (!ndigits) return;
128 for (Int_t ndig=0; ndig<ndigits; ndig++) {
129 dig = (AliITSdigit*)fObjects->UncheckedAt(ndig);
130 Double_t signal = (Double_t)(dig->GetSignal());
131 if (signal > fMapThresholdD) SetHit(dig->GetCoord1(),dig->GetCoord2(),signal);
134 //______________________________________________________________________
135 void AliITSMapA2::FlagHit(Int_t iz, Int_t ix){
138 fHitMapD[CheckedIndex(iz, ix)]=
139 -1000.*TMath::Abs((Int_t)(fHitMapD[CheckedIndex(iz, ix)])+1.);
141 //______________________________________________________________________
142 TObject* AliITSMapA2::GetHit(Int_t i, Int_t /* dummy */) const {
143 //return a pointer to the 1D histogram
146 return fObjects->UncheckedAt(i);
149 //______________________________________________________________________
150 Double_t AliITSMapA2::GetSignal(Int_t index) const {
151 //get signal in a cell
153 if (index<fMaxIndex) return (index <0) ? 0. : fHitMapD[index];
156 //______________________________________________________________________
157 FlagType AliITSMapA2::TestHit(Int_t iz, Int_t ix){
158 // check if the entry has already been flagged
160 if (CheckedIndex(iz, ix) < 0) return kEmpty;
161 Int_t inf=(Int_t)fHitMapD[CheckedIndex(iz, ix)];
165 } else if (inf == 0) {
171 //______________________________________________________________________
172 void AliITSMapA2::FillMapFromHist(){
173 // fills map from 1D histograms
175 if (!fObjects) return;
178 for( Int_t i=0; i<fNobjects; i++) {
179 TH1F *hist =(TH1F *)fObjects->UncheckedAt(i);
180 Int_t nsamples = hist->GetNbinsX();
181 for( Int_t j=0; j<nsamples; j++) {
182 Double_t signal = (Double_t)(hist->GetBinContent(j+1));
183 if (signal > fMapThresholdD) SetHit(i,j,signal);
187 //______________________________________________________________________
188 void AliITSMapA2::FillHist(){
189 // fill 1D histograms from map
191 if (!fObjects || fScaleSizeX != 1) return;
194 for( Int_t i=0; i<fNobjects; i++) {
195 TH1F *hist =(TH1F *)fObjects->UncheckedAt(i);
196 for( Int_t j=0; j<fNpx; j++) {
197 Double_t signal=GetSignal(i,j);
198 if (signal > fMapThresholdD) hist->Fill((Float_t)j,signal);
202 //______________________________________________________________________
203 void AliITSMapA2::ResetHist(){
206 if (!fObjects) return;
208 for( Int_t i=0; i<fNobjects; i++) {
209 if ((*fObjects)[i]) ((TH1F*)(*fObjects)[i])->Reset();
212 //______________________________________________________________________
213 void AliITSMapA2::AddSignal(Int_t iz,Int_t ix,Double_t sig){
214 // Addes sig to cell iz. equivalent to the very common
215 // sig = fMapA2->GetSignal(iz,ix) + sig; fMapA2->SetHit(iz,ix,sig);
218 Int_t index=GetHitIndex(iz,ix);
220 fHitMapD[CheckedIndex(iz, ix)] += sig;