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
42 //______________________________________________________________________
43 AliITSMapA1::AliITSMapA1(AliITSsegmentation *seg){
47 fNpz = fSegmentation->Npz();
48 fNpx = fSegmentation->Npx();
49 fMaxIndex = fNpz*fNpx+fNpx; // 2 halves of detector
50 fHitMap = new Int_t[fMaxIndex];
56 //______________________________________________________________________
57 AliITSMapA1::AliITSMapA1(AliITSsegmentation *seg, TObjArray *obj){
62 fNpz = fSegmentation->Npz();
63 fNpx = fSegmentation->Npx();
64 fMaxIndex = fNpz*fNpx+fNpx; // 2 halves of detector
65 fHitMap = new Int_t[fMaxIndex];
67 if(fObjects) fNobjects = fObjects->GetEntriesFast();
71 //______________________________________________________________________
72 AliITSMapA1::AliITSMapA1(AliITSsegmentation *seg, TObjArray *obj, Int_t thr){
77 fNpz = fSegmentation->Npz();
78 fNpx = fSegmentation->Npx();
79 fMaxIndex = fNpz*fNpx+fNpx; // 2 halves of detector
80 fHitMap = new Int_t[fMaxIndex];
82 if(fObjects) fNobjects = fObjects->GetEntriesFast();
86 //______________________________________________________________________
87 AliITSMapA1::~AliITSMapA1(){
90 if(fHitMap) delete[] fHitMap;
92 //_________________________________________________________________________
93 AliITSMapA1& AliITSMapA1::operator=(const AliITSMapA1 &source) {
94 // Assignment operator
96 if(&source == this) return *this;
98 this->fNpx = source.fNpx;
99 this->fNpz = source.fNpz;
100 this->fObjects = source.fObjects;
101 this->fNobjects = source.fNobjects;
102 this->fMaxIndex = source.fMaxIndex;
103 this->fHitMap = source.fHitMap;
104 this->fMapThreshold = source.fMapThreshold;
107 //______________________________________________________________________
108 AliITSMapA1::AliITSMapA1(const AliITSMapA1 &source) : AliITSMap(source){
113 //______________________________________________________________________
114 void AliITSMapA1::ClearMap(){
117 memset(fHitMap,0,sizeof(int)*fMaxIndex);
119 //______________________________________________________________________
120 void AliITSMapA1::SetArray(TObjArray *obj){
121 // set array of objects
124 if (fObjects) fNobjects = fObjects->GetEntriesFast();
126 //______________________________________________________________________
127 Int_t AliITSMapA1::CheckedIndex(Int_t iz, Int_t ix) const {
128 //check boundaries and return an index in array
129 Int_t index=fNpx*iz+ix;
131 //if (index > fMaxIndex) {
132 if (index > fMaxIndex || index < 0) {
133 printf("\n \n \n Try to read/write outside array !!!!"
134 " \n \n %d %d %d %d %d %d \n",iz,ix,fMaxIndex,index,fNpz,fNpx);
139 } // end if index>max or < 0
141 //______________________________________________________________________
142 void AliITSMapA1::FillMap(){
143 // fill array with digits indices
145 Int_t ndigits = fObjects->GetEntriesFast();
146 if (!ndigits) return;
149 for (Int_t ndig=0; ndig<ndigits; ndig++) {
150 dig = (AliITSdigit*)fObjects->UncheckedAt(ndig);
151 if(dig->GetSignal() > fMapThreshold) {
152 SetHit(dig->GetCoord1(),dig->GetCoord2(),ndig);
153 } // end if fSignal > fMapthreshold
156 //______________________________________________________________________
157 void AliITSMapA1::SetHit(Int_t iz, Int_t ix, Int_t idigit){
158 // set the digit index at a certain position in array
160 fHitMap[CheckedIndex(iz, ix)]=idigit+1;
162 //______________________________________________________________________
163 void AliITSMapA1::DeleteHit(Int_t iz, Int_t ix){
164 // delete an entry in array
166 fHitMap[CheckedIndex(iz, ix)]=0;
168 //______________________________________________________________________
169 void AliITSMapA1::FlagHit(Int_t iz, Int_t ix){
170 // flag an entry in array
172 fHitMap[CheckedIndex(iz, ix)] = -TMath::Abs(fHitMap[CheckedIndex(iz, ix)]);
174 //______________________________________________________________________
175 Int_t AliITSMapA1::GetHitIndex(Int_t iz, Int_t ix) const {
176 // return the digit index from a specific entry in array
178 return TMath::Abs(fHitMap[CheckedIndex(iz, ix)])-1;
180 //______________________________________________________________________
181 TObject* AliITSMapA1::GetHit(Int_t iz, Int_t ix){
182 // return the pointer to the digit
184 Int_t index=GetHitIndex(iz,ix);
185 // Force crash if index does not exist !
186 return (index <0) ? 0 : fObjects->UncheckedAt(GetHitIndex(iz,ix));
188 //______________________________________________________________________
189 Double_t AliITSMapA1::GetSignal(Int_t iz, Int_t ix){
193 AliITSdigit *dig = (AliITSdigit*)GetHit(iz,ix);
194 if(dig) signal=(Double_t)dig->GetSignal();
198 //______________________________________________________________________
199 FlagType AliITSMapA1::TestHit(Int_t iz, Int_t ix) {
200 // check whether the digit has already been flagged
202 if (CheckedIndex(iz, ix) < 0) return kEmpty;
203 Int_t inf=fHitMap[CheckedIndex(iz, ix)];
206 } else if (inf == 0) {