]> git.uio.no Git - u/mrichter/AliRoot.git/blame - ITS/AliITSMapA2.cxx
EffC++ warnings corrected.
[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>
e8189707 18
19#include "AliITSMapA2.h"
20#include "AliITSsegmentation.h"
e8189707 21#include "AliITSdigit.h"
22
766e3066 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////////////////////////////////////////////////////////////////////////
e8189707 32
33ClassImp(AliITSMapA2)
34
766e3066 35//______________________________________________________________________
36AliITSMapA2::AliITSMapA2(){
37 // default constructor
94d90134 38
766e3066 39 fSegmentation = 0;
40 fNpz = 0;
41 fNpx = 0;
42 fMaxIndex = 0;
43 fHitMapD = 0;
44 fObjects = 0;
45 fNobjects = 0;
46 fMapThresholdD =0.;
e8189707 47}
766e3066 48//______________________________________________________________________
49AliITSMapA2::AliITSMapA2(AliITSsegmentation *seg){
50 //constructor
e8189707 51
766e3066 52 fScaleSizeZ = 1;
53 fScaleSizeX = 1;
54 fSegmentation = seg;
55 fNpz = fSegmentation->Npz();
56 fNpx = fSegmentation->Npx();
57 fMaxIndex = fNpz*fNpx+fNpx; // 2 halves of detector
645ecce9 58 fHitMapD = new Double_t[fMaxIndex+1];
766e3066 59 fMapThresholdD = 0.;
60 fObjects = 0;
61 fNobjects = 0;
62 ClearMap();
e8189707 63}
766e3066 64//______________________________________________________________________
65AliITSMapA2::AliITSMapA2(AliITSsegmentation *seg,
66 Int_t scalesizeX, Int_t scalesizeZ){
67 //constructor
e8189707 68
766e3066 69 fSegmentation = seg;
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
e3df8399 75 fHitMapD = new Double_t[fMaxIndex+1];
766e3066 76 fMapThresholdD = 0.;
77 fObjects = 0;
78 fNobjects = 0;
79 ClearMap();
e8189707 80}
766e3066 81//______________________________________________________________________
82AliITSMapA2::AliITSMapA2(AliITSsegmentation *seg, TObjArray *obj,
83 Double_t thresh){
84 //constructor
e8189707 85
766e3066 86 fNobjects = 0;
87 fScaleSizeZ = 1;
88 fScaleSizeX = 1;
89 fSegmentation = seg;
90 fNpz = fSegmentation->Npz();
91 fNpx = fSegmentation->Npx();
92 fMaxIndex = fNpz*fNpx+fNpx; // 2 halves of detector
e3df8399 93 fHitMapD = new Double_t[fMaxIndex+1];
766e3066 94 fObjects = obj;
95 if (fObjects) fNobjects = fObjects->GetEntriesFast();
96 fMapThresholdD = thresh;
97 ClearMap();
e8189707 98}
766e3066 99//______________________________________________________________________
100AliITSMapA2::~AliITSMapA2(){
101 //destructor
e8189707 102
766e3066 103 if (fHitMapD) delete[] fHitMapD;
e8189707 104}
766e3066 105//______________________________________________________________________
ac74f489 106AliITSMapA2::AliITSMapA2(const AliITSMapA2 &source) : AliITSMapA1(source){
766e3066 107 // Copy Constructor
e8189707 108
766e3066 109 if(&source == this) return;
110
111 this->fMapThresholdD = source.fMapThresholdD;
112 this->fScaleSizeX = source.fScaleSizeX;
113 this->fScaleSizeZ = source.fScaleSizeZ;
114 this->fHitMapD = source.fHitMapD;
115 return;
e8189707 116}
766e3066 117//______________________________________________________________________
118AliITSMapA2& AliITSMapA2::operator=(const AliITSMapA2 &source) {
119 // Assignment operator
e8189707 120
766e3066 121 if(&source == this) return *this;
122
123 this->fMapThresholdD = source.fMapThresholdD;
124 this->fScaleSizeX = source.fScaleSizeX;
125 this->fScaleSizeZ = source.fScaleSizeZ;
126 this->fHitMapD = source.fHitMapD;
127 return *this;
e8189707 128}
766e3066 129//______________________________________________________________________
130void AliITSMapA2::ClearMap(){
131 //clear array
e8189707 132
766e3066 133 memset(fHitMapD,0,sizeof(Double_t)*fMaxIndex);
134}
135//______________________________________________________________________
136void AliITSMapA2::FillMap(){
137 // fills signal map from digits - apply a threshold for signal
e8189707 138
766e3066 139 if (!fObjects) return;
140
141 Int_t ndigits = fObjects->GetEntriesFast();
142 if (!ndigits) return;
143
144 AliITSdigit *dig;
145 for (Int_t ndig=0; ndig<ndigits; ndig++) {
146 dig = (AliITSdigit*)fObjects->UncheckedAt(ndig);
ecee53fc 147 Double_t signal = (Double_t)(dig->GetSignal());
148 if (signal > fMapThresholdD) SetHit(dig->GetCoord1(),dig->GetCoord2(),signal);
766e3066 149 } // end for ndig
e8189707 150}
766e3066 151//______________________________________________________________________
766e3066 152void AliITSMapA2::FlagHit(Int_t iz, Int_t ix){
153 //flag an entry
e8189707 154
766e3066 155 fHitMapD[CheckedIndex(iz, ix)]=
156 -1000.*TMath::Abs((Int_t)(fHitMapD[CheckedIndex(iz, ix)])+1.);
e8189707 157}
766e3066 158//______________________________________________________________________
590d15ee 159TObject* AliITSMapA2::GetHit(Int_t i, Int_t dummy) const {
766e3066 160 //return a pointer to the 1D histogram
e8189707 161
ac74f489 162 dummy = 0; // added to remove unused variable warning.
766e3066 163 if (fObjects) {
164 return fObjects->UncheckedAt(i);
165 } else return NULL;
e8189707 166}
766e3066 167//______________________________________________________________________
590d15ee 168Double_t AliITSMapA2::GetSignal(Int_t index) const {
766e3066 169 //get signal in a cell
e8189707 170
766e3066 171 if (index<fMaxIndex) return (index <0) ? 0. : fHitMapD[index];
172 else return 0.;
e8189707 173}
766e3066 174//______________________________________________________________________
175FlagType AliITSMapA2::TestHit(Int_t iz, Int_t ix){
176 // check if the entry has already been flagged
94d90134 177
178 if (CheckedIndex(iz, ix) < 0) return kEmpty;
f50d33af 179 Int_t inf=(Int_t)fHitMapD[CheckedIndex(iz, ix)];
e8189707 180
181 if (inf <= -1000) {
766e3066 182 return kUsed;
e8189707 183 } else if (inf == 0) {
766e3066 184 return kEmpty;
e8189707 185 } else {
766e3066 186 return kUnused;
187 } // end if inf...
e8189707 188}
766e3066 189//______________________________________________________________________
190void AliITSMapA2::FillMapFromHist(){
191 // fills map from 1D histograms
e8189707 192
766e3066 193 if (!fObjects) return;
194
195 // an example
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);
202 } // end for j
203 } // end for i
e8189707 204}
766e3066 205//______________________________________________________________________
206void AliITSMapA2::FillHist(){
207 // fill 1D histograms from map
208
209 if (!fObjects || fScaleSizeX != 1) return;
210
211 // an example
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);
217 } // end for j
218 } // end for i
e8189707 219}
766e3066 220//______________________________________________________________________
221void AliITSMapA2::ResetHist(){
222 // Reset histograms
223
224 if (!fObjects) return;
225
226 for( Int_t i=0; i<fNobjects; i++) {
227 if ((*fObjects)[i]) ((TH1F*)(*fObjects)[i])->Reset();
228 } // end for i
e8189707 229}
766e3066 230//______________________________________________________________________
231void 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);
e8189707 234
766e3066 235
236 Int_t index=GetHitIndex(iz,ix);
237 if(index<0) return;
238 fHitMapD[CheckedIndex(iz, ix)] += sig;
239}