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(){
37 // default constructor
48 //______________________________________________________________________
49 AliITSMapA2::AliITSMapA2(AliITSsegmentation *seg){
55 fNpz = fSegmentation->Npz();
56 fNpx = fSegmentation->Npx();
57 fMaxIndex = fNpz*fNpx+fNpx; // 2 halves of detector
58 fHitMapD = new Double_t[fMaxIndex+1];
64 //______________________________________________________________________
65 AliITSMapA2::AliITSMapA2(AliITSsegmentation *seg,
66 Int_t scalesizeX, Int_t scalesizeZ){
70 fScaleSizeX = scalesizeX;
71 fScaleSizeZ = scalesizeZ;
72 fNpz = fScaleSizeZ*fSegmentation->Npz();
73 fNpx = fScaleSizeX*fSegmentation->Npx();
74 fMaxIndex = fNpz*fNpx+fNpx; // 2 halves of detector
75 fHitMapD = new Double_t[fMaxIndex+1];
81 //______________________________________________________________________
82 AliITSMapA2::AliITSMapA2(AliITSsegmentation *seg, TObjArray *obj,
90 fNpz = fSegmentation->Npz();
91 fNpx = fSegmentation->Npx();
92 fMaxIndex = fNpz*fNpx+fNpx; // 2 halves of detector
93 fHitMapD = new Double_t[fMaxIndex+1];
95 if (fObjects) fNobjects = fObjects->GetEntriesFast();
96 fMapThresholdD = thresh;
99 //______________________________________________________________________
100 AliITSMapA2::~AliITSMapA2(){
103 if (fHitMapD) delete[] fHitMapD;
105 //______________________________________________________________________
106 AliITSMapA2::AliITSMapA2(const AliITSMapA2 &source) : AliITSMapA1(source){
109 if(&source == this) return;
111 this->fMapThresholdD = source.fMapThresholdD;
112 this->fScaleSizeX = source.fScaleSizeX;
113 this->fScaleSizeZ = source.fScaleSizeZ;
114 this->fHitMapD = source.fHitMapD;
117 //______________________________________________________________________
118 AliITSMapA2& AliITSMapA2::operator=(const AliITSMapA2 &source) {
119 // Assignment operator
121 if(&source == this) return *this;
123 this->fMapThresholdD = source.fMapThresholdD;
124 this->fScaleSizeX = source.fScaleSizeX;
125 this->fScaleSizeZ = source.fScaleSizeZ;
126 this->fHitMapD = source.fHitMapD;
129 //______________________________________________________________________
130 void AliITSMapA2::ClearMap(){
133 memset(fHitMapD,0,sizeof(Double_t)*fMaxIndex);
135 //______________________________________________________________________
136 void AliITSMapA2::FillMap(){
137 // fills signal map from digits - apply a threshold for signal
139 if (!fObjects) return;
141 Int_t ndigits = fObjects->GetEntriesFast();
142 if (!ndigits) return;
145 for (Int_t ndig=0; ndig<ndigits; ndig++) {
146 dig = (AliITSdigit*)fObjects->UncheckedAt(ndig);
147 Double_t signal = (Double_t)(dig->GetSignal());
148 if (signal > fMapThresholdD) SetHit(dig->GetCoord1(),dig->GetCoord2(),signal);
151 //______________________________________________________________________
152 void AliITSMapA2::FlagHit(Int_t iz, Int_t ix){
155 fHitMapD[CheckedIndex(iz, ix)]=
156 -1000.*TMath::Abs((Int_t)(fHitMapD[CheckedIndex(iz, ix)])+1.);
158 //______________________________________________________________________
159 TObject* AliITSMapA2::GetHit(Int_t i, Int_t dummy) const {
160 //return a pointer to the 1D histogram
162 dummy = 0; // added to remove unused variable warning.
164 return fObjects->UncheckedAt(i);
167 //______________________________________________________________________
168 Double_t AliITSMapA2::GetSignal(Int_t index) const {
169 //get signal in a cell
171 if (index<fMaxIndex) return (index <0) ? 0. : fHitMapD[index];
174 //______________________________________________________________________
175 FlagType AliITSMapA2::TestHit(Int_t iz, Int_t ix){
176 // check if the entry has already been flagged
178 if (CheckedIndex(iz, ix) < 0) return kEmpty;
179 Int_t inf=(Int_t)fHitMapD[CheckedIndex(iz, ix)];
183 } else if (inf == 0) {
189 //______________________________________________________________________
190 void AliITSMapA2::FillMapFromHist(){
191 // fills map from 1D histograms
193 if (!fObjects) return;
196 for( Int_t i=0; i<fNobjects; i++) {
197 TH1F *hist =(TH1F *)fObjects->UncheckedAt(i);
198 Int_t nsamples = hist->GetNbinsX();
199 for( Int_t j=0; j<nsamples; j++) {
200 Double_t signal = (Double_t)(hist->GetBinContent(j+1));
201 if (signal > fMapThresholdD) SetHit(i,j,signal);
205 //______________________________________________________________________
206 void AliITSMapA2::FillHist(){
207 // fill 1D histograms from map
209 if (!fObjects || fScaleSizeX != 1) return;
212 for( Int_t i=0; i<fNobjects; i++) {
213 TH1F *hist =(TH1F *)fObjects->UncheckedAt(i);
214 for( Int_t j=0; j<fNpx; j++) {
215 Double_t signal=GetSignal(i,j);
216 if (signal > fMapThresholdD) hist->Fill((Float_t)j,signal);
220 //______________________________________________________________________
221 void AliITSMapA2::ResetHist(){
224 if (!fObjects) return;
226 for( Int_t i=0; i<fNobjects; i++) {
227 if ((*fObjects)[i]) ((TH1F*)(*fObjects)[i])->Reset();
230 //______________________________________________________________________
231 void AliITSMapA2::AddSignal(Int_t iz,Int_t ix,Double_t sig){
232 // Addes sig to cell iz. equivalent to the very common
233 // sig = fMapA2->GetSignal(iz,ix) + sig; fMapA2->SetHit(iz,ix,sig);
236 Int_t index=GetHitIndex(iz,ix);
238 fHitMapD[CheckedIndex(iz, ix)] += sig;