]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/AliITSMapA1.cxx
Possibility to calculate the DCA between two ESD track. The V0 and cascade vertexes...
[u/mrichter/AliRoot.git] / ITS / AliITSMapA1.cxx
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 #include <TObjArray.h>
16 #include "AliITSMapA1.h"
17 #include "AliITSsegmentation.h"
18 #include "AliITSdigit.h"
19
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 ////////////////////////////////////////////////////////////////////////
27
28 ClassImp(AliITSMapA1)
29 //______________________________________________________________________
30 AliITSMapA1::AliITSMapA1(){
31     // default constructor
32
33     fSegmentation = 0;
34     fNpz          = 0;
35     fNpx          = 0;
36     fMaxIndex     = 0;
37     fHitMap       = 0;
38     fObjects      = 0;
39     fNobjects     = 0;
40     fMapThreshold = 0;
41 }
42 //______________________________________________________________________
43 AliITSMapA1::AliITSMapA1(AliITSsegmentation *seg){
44     //constructor
45
46     fSegmentation = seg;
47     fNpz          = fSegmentation->Npz();
48     fNpx          = fSegmentation->Npx();
49     fMaxIndex     = fNpz*fNpx+fNpx;             // 2 halves of detector
50     fHitMap       = new Int_t[fMaxIndex];
51     fObjects      = 0;
52     fNobjects     = 0;
53     fMapThreshold = 0;
54     ClearMap();
55 }
56 //______________________________________________________________________
57 AliITSMapA1::AliITSMapA1(AliITSsegmentation *seg, TObjArray *obj){
58     //constructor
59
60     fNobjects     = 0;
61     fSegmentation = seg;
62     fNpz          = fSegmentation->Npz();
63     fNpx          = fSegmentation->Npx();
64     fMaxIndex     = fNpz*fNpx+fNpx;             // 2 halves of detector
65     fHitMap       = new Int_t[fMaxIndex];
66     fObjects      =  obj;
67     if(fObjects) fNobjects = fObjects->GetEntriesFast();
68     fMapThreshold = 0;
69     ClearMap();
70 }
71 //______________________________________________________________________
72 AliITSMapA1::AliITSMapA1(AliITSsegmentation *seg, TObjArray *obj, Int_t thr){
73     //constructor
74
75     fNobjects     = 0;
76     fSegmentation = seg;
77     fNpz          = fSegmentation->Npz();
78     fNpx          = fSegmentation->Npx();
79     fMaxIndex     = fNpz*fNpx+fNpx;             // 2 halves of detector
80     fHitMap       = new Int_t[fMaxIndex];
81     fObjects      =  obj;
82     if(fObjects) fNobjects = fObjects->GetEntriesFast();
83     fMapThreshold = thr;
84     ClearMap();
85 }
86 //______________________________________________________________________
87 AliITSMapA1::~AliITSMapA1(){
88     //destructor
89
90     if(fHitMap) delete[] fHitMap;
91 }
92 //_________________________________________________________________________
93 AliITSMapA1& AliITSMapA1::operator=(const AliITSMapA1 &source) {
94     //    Assignment operator
95
96     if(&source == this) return *this;
97
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;
105     return *this;
106 }
107 //______________________________________________________________________
108 AliITSMapA1::AliITSMapA1(const AliITSMapA1 &source) : AliITSMap(source){
109     //     Copy Constructor
110
111     *this = source;
112 }
113 //______________________________________________________________________
114 void AliITSMapA1::ClearMap(){
115     //clear array
116
117     memset(fHitMap,0,sizeof(int)*fMaxIndex);
118 }
119 //______________________________________________________________________
120 void AliITSMapA1::SetArray(TObjArray *obj){
121     // set array of objects
122
123     fObjects =  obj;
124     if (fObjects) fNobjects = fObjects->GetEntriesFast();
125 }
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;
130
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);
135         // force crash
136         return  -1;
137     } else {
138         return index;
139     } // end if index>max or < 0
140 }
141 //______________________________________________________________________
142 void  AliITSMapA1::FillMap(){
143     // fill array with digits indices
144
145     Int_t ndigits = fObjects->GetEntriesFast();
146     if (!ndigits) return;
147
148     AliITSdigit *dig;
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
154     } // end for ndig
155 }
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
159
160     fHitMap[CheckedIndex(iz, ix)]=idigit+1;
161 }
162 //______________________________________________________________________
163 void AliITSMapA1::DeleteHit(Int_t iz, Int_t ix){
164     // delete an entry in array
165
166     fHitMap[CheckedIndex(iz, ix)]=0;
167 }
168 //______________________________________________________________________
169 void AliITSMapA1::FlagHit(Int_t iz, Int_t ix){
170     // flag an entry in array
171
172     fHitMap[CheckedIndex(iz, ix)] = -TMath::Abs(fHitMap[CheckedIndex(iz, ix)]);
173 }
174 //______________________________________________________________________
175 Int_t AliITSMapA1::GetHitIndex(Int_t iz, Int_t ix) const {
176     // return the digit index from a specific entry in array
177
178     return TMath::Abs(fHitMap[CheckedIndex(iz, ix)])-1;
179 }
180 //______________________________________________________________________
181 TObject* AliITSMapA1::GetHit(Int_t iz, Int_t ix){
182     // return the pointer to the digit 
183
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));
187 }
188 //______________________________________________________________________
189 Double_t AliITSMapA1::GetSignal(Int_t iz, Int_t ix){
190     // get a pad signal
191     Double_t signal;
192
193     AliITSdigit *dig = (AliITSdigit*)GetHit(iz,ix);
194     if(dig) signal=(Double_t)dig->GetSignal();
195     else signal=0.;
196     return signal;
197 }
198 //______________________________________________________________________
199 FlagType AliITSMapA1::TestHit(Int_t iz, Int_t ix) {
200     // check whether the digit has already been flagged
201
202     if (CheckedIndex(iz, ix) < 0) return kEmpty;
203     Int_t inf=fHitMap[CheckedIndex(iz, ix)]; 
204     if (inf < 0) {
205         return kUsed;
206     } else if (inf == 0) {
207         return kEmpty;
208     } else {
209         return kUnused;
210     } // end if inf
211 }
212