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"
25 ////////////////////////////////////////////////////////////////////////
26 // Map Class for ITS. Implementation A2. In this implementation, the //
27 // 2 dimensional (iz,ix) map is filled with Double precision floating //
28 // point values. Since this class is derived for AliITSMapA1 it also //
29 // has all of the functionality of that class as well. For each //
30 // cell a corresponding TObject, a hit, can also be stored. //
31 // The detector geometry is accessed via the that detectors //
32 // segmentation class and stored here for conveniance. //
33 ////////////////////////////////////////////////////////////////////////
37 //______________________________________________________________________
38 AliITSMapA2::AliITSMapA2(){
39 // default constructor
50 //______________________________________________________________________
51 AliITSMapA2::AliITSMapA2(AliITSsegmentation *seg){
57 fNpz = fSegmentation->Npz();
58 fNpx = fSegmentation->Npx();
59 fMaxIndex = fNpz*fNpx+fNpx; // 2 halves of detector
60 fHitMapD = new Double_t[fMaxIndex+1];
66 //______________________________________________________________________
67 AliITSMapA2::AliITSMapA2(AliITSsegmentation *seg,
68 Int_t scalesizeX, Int_t scalesizeZ){
72 fScaleSizeX = scalesizeX;
73 fScaleSizeZ = scalesizeZ;
74 fNpz = fScaleSizeZ*fSegmentation->Npz();
75 fNpx = fScaleSizeX*fSegmentation->Npx();
76 fMaxIndex = fNpz*fNpx+fNpx; // 2 halves of detector
77 fHitMapD = new Double_t[fMaxIndex+1];
83 //______________________________________________________________________
84 AliITSMapA2::AliITSMapA2(AliITSsegmentation *seg, TObjArray *obj,
92 fNpz = fSegmentation->Npz();
93 fNpx = fSegmentation->Npx();
94 fMaxIndex = fNpz*fNpx+fNpx; // 2 halves of detector
95 fHitMapD = new Double_t[fMaxIndex+1];
97 if (fObjects) fNobjects = fObjects->GetEntriesFast();
98 fMapThresholdD = thresh;
101 //______________________________________________________________________
102 AliITSMapA2::~AliITSMapA2(){
105 if (fHitMapD) delete[] fHitMapD;
107 //______________________________________________________________________
108 AliITSMapA2::AliITSMapA2(const AliITSMapA2 &source){
111 if(&source == this) return;
113 this->fMapThresholdD = source.fMapThresholdD;
114 this->fScaleSizeX = source.fScaleSizeX;
115 this->fScaleSizeZ = source.fScaleSizeZ;
116 this->fHitMapD = source.fHitMapD;
119 //______________________________________________________________________
120 AliITSMapA2& AliITSMapA2::operator=(const AliITSMapA2 &source) {
121 // Assignment operator
123 if(&source == this) return *this;
125 this->fMapThresholdD = source.fMapThresholdD;
126 this->fScaleSizeX = source.fScaleSizeX;
127 this->fScaleSizeZ = source.fScaleSizeZ;
128 this->fHitMapD = source.fHitMapD;
131 //______________________________________________________________________
132 void AliITSMapA2::ClearMap(){
135 memset(fHitMapD,0,sizeof(Double_t)*fMaxIndex);
137 //______________________________________________________________________
138 void AliITSMapA2::FillMap(){
139 // fills signal map from digits - apply a threshold for signal
141 if (!fObjects) return;
143 Int_t ndigits = fObjects->GetEntriesFast();
144 if (!ndigits) return;
147 for (Int_t ndig=0; ndig<ndigits; ndig++) {
148 dig = (AliITSdigit*)fObjects->UncheckedAt(ndig);
149 Double_t signal = (Double_t)(dig->fSignal);
150 if (signal > fMapThresholdD) SetHit(dig->fCoord1,dig->fCoord2,signal);
153 //______________________________________________________________________
154 void AliITSMapA2::FlagHit(Int_t iz, Int_t ix){
157 fHitMapD[CheckedIndex(iz, ix)]=
158 -1000.*TMath::Abs((Int_t)(fHitMapD[CheckedIndex(iz, ix)])+1.);
160 //______________________________________________________________________
161 TObject* AliITSMapA2::GetHit(Int_t i, Int_t dummy){
162 //return a pointer to the 1D histogram
165 return fObjects->UncheckedAt(i);
168 //______________________________________________________________________
169 Double_t AliITSMapA2::GetSignal(Int_t index){
170 //get signal in a cell
172 if (index<fMaxIndex) return (index <0) ? 0. : fHitMapD[index];
175 //______________________________________________________________________
176 FlagType AliITSMapA2::TestHit(Int_t iz, Int_t ix){
177 // check if the entry has already been flagged
179 if (CheckedIndex(iz, ix) < 0) return kEmpty;
180 Int_t inf=(Int_t)fHitMapD[CheckedIndex(iz, ix)];
184 } else if (inf == 0) {
190 //______________________________________________________________________
191 void AliITSMapA2::FillMapFromHist(){
192 // fills map from 1D histograms
194 if (!fObjects) return;
197 for( Int_t i=0; i<fNobjects; i++) {
198 TH1F *hist =(TH1F *)fObjects->UncheckedAt(i);
199 Int_t nsamples = hist->GetNbinsX();
200 for( Int_t j=0; j<nsamples; j++) {
201 Double_t signal = (Double_t)(hist->GetBinContent(j+1));
202 if (signal > fMapThresholdD) SetHit(i,j,signal);
206 //______________________________________________________________________
207 void AliITSMapA2::FillHist(){
208 // fill 1D histograms from map
210 if (!fObjects || fScaleSizeX != 1) return;
213 for( Int_t i=0; i<fNobjects; i++) {
214 TH1F *hist =(TH1F *)fObjects->UncheckedAt(i);
215 for( Int_t j=0; j<fNpx; j++) {
216 Double_t signal=GetSignal(i,j);
217 if (signal > fMapThresholdD) hist->Fill((Float_t)j,signal);
221 //______________________________________________________________________
222 void AliITSMapA2::ResetHist(){
225 if (!fObjects) return;
227 for( Int_t i=0; i<fNobjects; i++) {
228 if ((*fObjects)[i]) ((TH1F*)(*fObjects)[i])->Reset();
231 //______________________________________________________________________
232 void AliITSMapA2::AddSignal(Int_t iz,Int_t ix,Double_t sig){
233 // Addes sig to cell iz. equivalent to the very common
234 // sig = fMapA2->GetSignal(iz,ix) + sig; fMapA2->SetHit(iz,ix,sig);
237 Int_t index=GetHitIndex(iz,ix);
239 fHitMapD[CheckedIndex(iz, ix)] += sig;