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