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 **************************************************************************/
15 #include <TObjArray.h>
16 #include "AliITSMapA1.h"
17 #include "AliITSsegmentation.h"
18 #include "AliITSdigit.h"
20 ////////////////////////////////////////////////////////////////////////
21 // Map Class for ITS. Implementation A1. In this implementation, the //
22 // 2 dimensional (iz,ix) map is filled with integers values. For each //
23 // cell a corresponding TObject, a hit, can also be stored. //
24 // The detector geometry is accessed via the that detectors //
25 // segmentation class and stored here for conveniance. //
26 ////////////////////////////////////////////////////////////////////////
29 //______________________________________________________________________
30 AliITSMapA1::AliITSMapA1(){
31 // default constructor
43 //______________________________________________________________________
44 AliITSMapA1::AliITSMapA1(AliITSsegmentation *seg){
48 fNpz = fSegmentation->Npz();
49 fNpx = fSegmentation->Npx();
50 fMaxIndex = fNpz*fNpx+fNpx; // 2 halves of detector
51 fHitMap = new Int_t[fMaxIndex];
58 //______________________________________________________________________
59 AliITSMapA1::AliITSMapA1(AliITSsegmentation *seg, TObjArray *obj){
64 fNpz = fSegmentation->Npz();
65 fNpx = fSegmentation->Npx();
66 fMaxIndex = fNpz*fNpx+fNpx; // 2 halves of detector
67 fHitMap = new Int_t[fMaxIndex];
69 if(fObjects) fNobjects = fObjects->GetEntriesFast();
74 //______________________________________________________________________
75 AliITSMapA1::AliITSMapA1(AliITSsegmentation *seg, TObjArray *obj, Int_t thr){
80 fNpz = fSegmentation->Npz();
81 fNpx = fSegmentation->Npx();
82 fMaxIndex = fNpz*fNpx+fNpx; // 2 halves of detector
83 fHitMap = new Int_t[fMaxIndex];
85 if(fObjects) fNobjects = fObjects->GetEntriesFast();
89 //______________________________________________________________________
90 AliITSMapA1::AliITSMapA1(AliITSsegmentation *seg, TObjArray *obj, TArrayI thr){
95 fNpz = fSegmentation->Npz();
96 fNpx = fSegmentation->Npx();
97 fMaxIndex = fNpz*fNpx+fNpx; // 2 halves of detector
98 fHitMap = new Int_t[fMaxIndex];
100 if(fObjects) fNobjects = fObjects->GetEntriesFast();
102 fMapThresholdArr = thr;
106 //______________________________________________________________________
107 AliITSMapA1::~AliITSMapA1(){
110 if(fHitMap) delete[] fHitMap;
112 //_________________________________________________________________________
113 AliITSMapA1& AliITSMapA1::operator=(const AliITSMapA1 &source) {
114 // Assignment operator
116 if(&source == this) return *this;
118 this->fNpx = source.fNpx;
119 this->fNpz = source.fNpz;
120 this->fObjects = source.fObjects;
121 this->fNobjects = source.fNobjects;
122 this->fMaxIndex = source.fMaxIndex;
123 this->fHitMap = source.fHitMap;
124 this->fMapThreshold = source.fMapThreshold;
125 this->fMapThresholdArr = source.fMapThresholdArr;
128 //______________________________________________________________________
129 AliITSMapA1::AliITSMapA1(const AliITSMapA1 &source) : AliITSMap(source){
134 //______________________________________________________________________
135 void AliITSMapA1::ClearMap(){
138 memset(fHitMap,0,sizeof(int)*fMaxIndex);
140 //______________________________________________________________________
141 void AliITSMapA1::SetArray(TObjArray *obj){
142 // set array of objects
145 if (fObjects) fNobjects = fObjects->GetEntriesFast();
147 //______________________________________________________________________
148 Int_t AliITSMapA1::CheckedIndex(Int_t iz, Int_t ix) const {
149 //check boundaries and return an index in array
150 Int_t index=fNpx*iz+ix;
152 //if (index > fMaxIndex) {
153 if (index > fMaxIndex || index < 0) {
154 printf("\n \n \n Try to read/write outside array !!!!"
155 " \n \n %d %d %d %d %d %d \n",iz,ix,fMaxIndex,index,fNpz,fNpx);
160 } // end if index>max or < 0
162 //______________________________________________________________________
163 void AliITSMapA1::FillMap(){
164 // fill array with digits indices
166 Int_t ndigits = fObjects->GetEntriesFast();
167 if (!ndigits) return;
170 for (Int_t ndig=0; ndig<ndigits; ndig++) {
171 dig = (AliITSdigit*)fObjects->UncheckedAt(ndig);
172 if(dig->GetSignal() > fMapThreshold) {
173 SetHit(dig->GetCoord1(),dig->GetCoord2(),ndig);
174 } // end if fSignal > fMapthreshold
177 //______________________________________________________________________
178 void AliITSMapA1::FillMap2(){
179 // fill array with digits indices
181 Int_t ndigits = fObjects->GetEntriesFast();
182 if (!ndigits) return;
185 for (Int_t ndig=0; ndig<ndigits; ndig++) {
186 dig = (AliITSdigit*)fObjects->UncheckedAt(ndig);
187 if(dig->GetSignal() > fMapThresholdArr[dig->GetCoord1()]) {
188 SetHit(dig->GetCoord1(),dig->GetCoord2(),ndig);
189 } // end if fSignal > fMapthreshold
193 //______________________________________________________________________
194 void AliITSMapA1::SetHit(Int_t iz, Int_t ix, Int_t idigit){
195 // set the digit index at a certain position in array
197 fHitMap[CheckedIndex(iz, ix)]=idigit+1;
199 //______________________________________________________________________
200 void AliITSMapA1::DeleteHit(Int_t iz, Int_t ix){
201 // delete an entry in array
203 fHitMap[CheckedIndex(iz, ix)]=0;
205 //______________________________________________________________________
206 void AliITSMapA1::FlagHit(Int_t iz, Int_t ix){
207 // flag an entry in array
209 fHitMap[CheckedIndex(iz, ix)] = -TMath::Abs(fHitMap[CheckedIndex(iz, ix)]);
211 //______________________________________________________________________
212 Int_t AliITSMapA1::GetHitIndex(Int_t iz, Int_t ix) const {
213 // return the digit index from a specific entry in array
215 return TMath::Abs(fHitMap[CheckedIndex(iz, ix)])-1;
217 //______________________________________________________________________
218 TObject* AliITSMapA1::GetHit(Int_t iz, Int_t ix) const {
219 // return the pointer to the digit
221 Int_t index=GetHitIndex(iz,ix);
222 // Force crash if index does not exist !
223 return (index <0) ? 0 : fObjects->UncheckedAt(GetHitIndex(iz,ix));
225 //______________________________________________________________________
226 Double_t AliITSMapA1::GetSignal(Int_t iz, Int_t ix) const{
230 AliITSdigit *dig = (AliITSdigit*)GetHit(iz,ix);
231 if(dig) signal=(Double_t)dig->GetSignal();
235 //______________________________________________________________________
236 FlagType AliITSMapA1::TestHit(Int_t iz, Int_t ix) {
237 // check whether the digit has already been flagged
239 if (CheckedIndex(iz, ix) < 0) return kEmpty;
240 Int_t inf=fHitMap[CheckedIndex(iz, ix)];
243 } else if (inf == 0) {