]> git.uio.no Git - u/mrichter/AliRoot.git/blame - ITS/AliITSMapA1.cxx
TRD nSigma OADB related new codes and modifications and OADB root file -- Xianguo Lu
[u/mrichter/AliRoot.git] / ITS / AliITSMapA1.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 **************************************************************************/
766e3066 15#include <TObjArray.h>
e8189707 16#include "AliITSMapA1.h"
17#include "AliITSsegmentation.h"
e8189707 18#include "AliITSdigit.h"
19
766e3066 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////////////////////////////////////////////////////////////////////////
e8189707 27
28ClassImp(AliITSMapA1)
766e3066 29//______________________________________________________________________
e56160b8 30AliITSMapA1::AliITSMapA1():
31fSegmentation(0),
32fNpx(0),
33fNpz(0),
34fObjects(0),
35fNobjects(0),
36fMaxIndex(0),
37fMapThresholdArr(0),
38fHitMap(0),
39fMapThreshold(0){
766e3066 40 // default constructor
41
766e3066 42}
43//______________________________________________________________________
e56160b8 44AliITSMapA1::AliITSMapA1(AliITSsegmentation *seg):
45fSegmentation(seg),
46fNpx(0),
47fNpz(0),
48fObjects(0),
49fNobjects(0),
50fMaxIndex(0),
51fMapThresholdArr(0),
52fHitMap(0),
53fMapThreshold(0){
766e3066 54 //constructor
55
766e3066 56 fNpz = fSegmentation->Npz();
57 fNpx = fSegmentation->Npx();
58 fMaxIndex = fNpz*fNpx+fNpx; // 2 halves of detector
59 fHitMap = new Int_t[fMaxIndex];
766e3066 60 ClearMap();
61}
62//______________________________________________________________________
e56160b8 63AliITSMapA1::AliITSMapA1(AliITSsegmentation *seg, TObjArray *obj):
64fSegmentation(seg),
65fNpx(0),
66fNpz(0),
67fObjects(obj),
68fNobjects(0),
69fMaxIndex(0),
70fMapThresholdArr(0),
71fHitMap(0),
72fMapThreshold(0){
766e3066 73 //constructor
74
e56160b8 75 fNpz = fSegmentation->Npz();
76 fNpx = fSegmentation->Npx();
77 fMaxIndex = fNpz*fNpx+fNpx; // 2 halves of detector
78 fHitMap = new Int_t[fMaxIndex];
79 if(fObjects) fNobjects = fObjects->GetEntriesFast();
80 ClearMap();
766e3066 81}
82//______________________________________________________________________
e56160b8 83AliITSMapA1::AliITSMapA1(AliITSsegmentation *seg, TObjArray *obj, Int_t thr):
84fSegmentation(seg),
85fNpx(0),
86fNpz(0),
87fObjects(obj),
88fNobjects(0),
89fMaxIndex(0),
90fMapThresholdArr(0),
91fHitMap(0),
92fMapThreshold(thr){
766e3066 93 //constructor
94
e56160b8 95 fNpz = fSegmentation->Npz();
96 fNpx = fSegmentation->Npx();
97 fMaxIndex = fNpz*fNpx+fNpx; // 2 halves of detector
98 fHitMap = new Int_t[fMaxIndex];
99 if(fObjects) fNobjects = fObjects->GetEntriesFast();
100 ClearMap();
766e3066 101}
f45f6658 102//______________________________________________________________________
e56160b8 103AliITSMapA1::AliITSMapA1(AliITSsegmentation *seg, TObjArray *obj, TArrayI thr):
104fSegmentation(seg),
105fNpx(0),
106fNpz(0),
107fObjects(obj),
108fNobjects(0),
109fMaxIndex(0),
110fMapThresholdArr(thr),
111fHitMap(0),
112fMapThreshold(0){
f45f6658 113 //constructor
114
e56160b8 115 fNpz = fSegmentation->Npz();
116 fNpx = fSegmentation->Npx();
117 fMaxIndex = fNpz*fNpx+fNpx; // 2 halves of detector
118 fHitMap = new Int_t[fMaxIndex];
119 if(fObjects) fNobjects = fObjects->GetEntriesFast();
120 ClearMap();
f45f6658 121}
122
766e3066 123//______________________________________________________________________
124AliITSMapA1::~AliITSMapA1(){
125 //destructor
126
127 if(fHitMap) delete[] fHitMap;
e8189707 128}
e8189707 129
766e3066 130//______________________________________________________________________
131void AliITSMapA1::ClearMap(){
132 //clear array
e8189707 133
766e3066 134 memset(fHitMap,0,sizeof(int)*fMaxIndex);
135}
136//______________________________________________________________________
137void AliITSMapA1::SetArray(TObjArray *obj){
138 // set array of objects
e8189707 139
766e3066 140 fObjects = obj;
141 if (fObjects) fNobjects = fObjects->GetEntriesFast();
e8189707 142}
766e3066 143//______________________________________________________________________
fb4e90e0 144Int_t AliITSMapA1::CheckedIndex(Int_t iz, Int_t ix) const {
766e3066 145 //check boundaries and return an index in array
146 Int_t index=fNpx*iz+ix;
e8189707 147
766e3066 148 //if (index > fMaxIndex) {
149 if (index > fMaxIndex || index < 0) {
150 printf("\n \n \n Try to read/write outside array !!!!"
151 " \n \n %d %d %d %d %d %d \n",iz,ix,fMaxIndex,index,fNpz,fNpx);
152 // force crash
153 return -1;
154 } else {
155 return index;
156 } // end if index>max or < 0
157}
158//______________________________________________________________________
159void AliITSMapA1::FillMap(){
160 // fill array with digits indices
e8189707 161
766e3066 162 Int_t ndigits = fObjects->GetEntriesFast();
163 if (!ndigits) return;
96f414e9 164
766e3066 165 AliITSdigit *dig;
166 for (Int_t ndig=0; ndig<ndigits; ndig++) {
167 dig = (AliITSdigit*)fObjects->UncheckedAt(ndig);
ecee53fc 168 if(dig->GetSignal() > fMapThreshold) {
169 SetHit(dig->GetCoord1(),dig->GetCoord2(),ndig);
766e3066 170 } // end if fSignal > fMapthreshold
171 } // end for ndig
e8189707 172}
f45f6658 173//______________________________________________________________________
174void AliITSMapA1::FillMap2(){
175 // fill array with digits indices
176
177 Int_t ndigits = fObjects->GetEntriesFast();
178 if (!ndigits) return;
179
180 AliITSdigit *dig;
181 for (Int_t ndig=0; ndig<ndigits; ndig++) {
182 dig = (AliITSdigit*)fObjects->UncheckedAt(ndig);
183 if(dig->GetSignal() > fMapThresholdArr[dig->GetCoord1()]) {
184 SetHit(dig->GetCoord1(),dig->GetCoord2(),ndig);
185 } // end if fSignal > fMapthreshold
186 } // end for ndig
187}
188
766e3066 189//______________________________________________________________________
190void AliITSMapA1::SetHit(Int_t iz, Int_t ix, Int_t idigit){
191 // set the digit index at a certain position in array
e8189707 192
766e3066 193 fHitMap[CheckedIndex(iz, ix)]=idigit+1;
e8189707 194}
766e3066 195//______________________________________________________________________
196void AliITSMapA1::DeleteHit(Int_t iz, Int_t ix){
197 // delete an entry in array
e8189707 198
766e3066 199 fHitMap[CheckedIndex(iz, ix)]=0;
e8189707 200}
766e3066 201//______________________________________________________________________
202void AliITSMapA1::FlagHit(Int_t iz, Int_t ix){
203 // flag an entry in array
e8189707 204
766e3066 205 fHitMap[CheckedIndex(iz, ix)] = -TMath::Abs(fHitMap[CheckedIndex(iz, ix)]);
e8189707 206}
766e3066 207//______________________________________________________________________
fb4e90e0 208Int_t AliITSMapA1::GetHitIndex(Int_t iz, Int_t ix) const {
766e3066 209 // return the digit index from a specific entry in array
e8189707 210
766e3066 211 return TMath::Abs(fHitMap[CheckedIndex(iz, ix)])-1;
e8189707 212}
766e3066 213//______________________________________________________________________
590d15ee 214TObject* AliITSMapA1::GetHit(Int_t iz, Int_t ix) const {
766e3066 215 // return the pointer to the digit
e8189707 216
766e3066 217 Int_t index=GetHitIndex(iz,ix);
218 // Force crash if index does not exist !
219 return (index <0) ? 0 : fObjects->UncheckedAt(GetHitIndex(iz,ix));
e8189707 220}
766e3066 221//______________________________________________________________________
590d15ee 222Double_t AliITSMapA1::GetSignal(Int_t iz, Int_t ix) const{
766e3066 223 // get a pad signal
224 Double_t signal;
e8189707 225
766e3066 226 AliITSdigit *dig = (AliITSdigit*)GetHit(iz,ix);
ecee53fc 227 if(dig) signal=(Double_t)dig->GetSignal();
766e3066 228 else signal=0.;
229 return signal;
e8189707 230}
766e3066 231//______________________________________________________________________
85ac1062 232FlagTypeITS AliITSMapA1::TestHit(Int_t iz, Int_t ix) {
766e3066 233 // check whether the digit has already been flagged
e8189707 234
85ac1062 235 if (CheckedIndex(iz, ix) < 0) return kEmptyITS;
766e3066 236 Int_t inf=fHitMap[CheckedIndex(iz, ix)];
237 if (inf < 0) {
85ac1062 238 return kUsedITS;
766e3066 239 } else if (inf == 0) {
85ac1062 240 return kEmptyITS;
766e3066 241 } else {
85ac1062 242 return kUnusedITS;
766e3066 243 } // end if inf
e8189707 244}
766e3066 245