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 ////////////////////////////////////////////////////////////////////////
19 // AliTOFDigitMap class
21 // digitmap enables fast check if the pad was already hit
22 // The index of a AliTOFdigit is saved in the each hitmap "cell"
23 // (there is an offset +1, because the index can be zero and
24 // zero means empty cell.
25 // In TOF, number of strips varies according plate type, the highest
26 // number is in plate C. For all plates is used this number, so
27 // the size of the digitmap is a little bit greater than necessary, but
28 // it simplifies the access algorithm.
31 // Author: F. Pierella based on AliTOFHitMap
33 ////////////////////////////////////////////////////////////////////////
35 #include <Riostream.h>
38 #include "AliTOFDigitMap.h"
39 #include "AliTOFdigit.h"
40 #include "AliTOFGeometry.h"
43 #include <TClonesArray.h>
45 ClassImp(AliTOFDigitMap)
47 AliTOFDigitMap::AliTOFDigitMap()
56 ////////////////////////////////////////////////////////////////////////
57 AliTOFDigitMap::AliTOFDigitMap(TClonesArray *dig)
62 // of course, these constants must not be hardwired
65 fNSector = AliTOFGeometry::NSectors();
66 fNplate = AliTOFGeometry::NPlates();
67 fNstrip = AliTOFGeometry::NStripC();
68 fNpx = AliTOFGeometry::NpadX();
69 fNpz = AliTOFGeometry::NpadZ();
70 fMaxIndex=fNSector*fNplate*fNstrip*fNpx*fNpz;
71 fDigitMap = new Int_t[fMaxIndex];
76 ////////////////////////////////////////////////////////////////////////
77 AliTOFDigitMap::AliTOFDigitMap(const AliTOFDigitMap & /*digitMap*/)
81 // Dummy copy constructor
87 ////////////////////////////////////////////////////////////////////////
88 AliTOFDigitMap::~AliTOFDigitMap()
93 if (fDigitMap) delete[] fDigitMap;
96 ////////////////////////////////////////////////////////////////////////
97 void AliTOFDigitMap::Clear(const char *)
102 memset(fDigitMap,0,sizeof(int)*fMaxIndex);
105 ////////////////////////////////////////////////////////////////////////
106 Int_t AliTOFDigitMap::CheckedIndex(Int_t *vol) const
109 // Return checked indices for vol
112 (vol[0]/*-1*/)*fNplate*fNstrip*fNpx*fNpz+ // sector
113 (vol[1]/*-1*/)*fNstrip*fNpx*fNpz+ // plate
114 (vol[2]/*-1*/)*fNpx*fNpz+ // strip
115 (vol[3]/*-1*/)*fNpz+ // padx
116 (vol[4]/*-1*/); // padz
118 if (index >= fMaxIndex) {
119 Error("AliTOFDigitMap","CheckedIndex - input outside bounds");
126 ////////////////////////////////////////////////////////////////////////
127 void AliTOFDigitMap::SetHit(Int_t *vol, Int_t idigit)
130 // Assign digit to pad vol
133 // 0 means empty pad, we need to shift indeces by 1
134 fDigitMap[CheckedIndex(vol)]=idigit+1;
137 ////////////////////////////////////////////////////////////////////////
138 void AliTOFDigitMap::SetHit(Int_t *vol)
141 // Assign last digit to pad vol
144 // 0 means empty pad, we need to shift indeces by 1
145 fDigitMap[CheckedIndex(vol)]=fDigits->GetLast()+1;
148 ////////////////////////////////////////////////////////////////////////
149 Int_t AliTOFDigitMap::GetHitIndex(Int_t *vol) const
152 // Get contents of pad vol
155 // 0 means empty pad, we need to shift indeces by 1
156 return fDigitMap[CheckedIndex(vol)]-1;
159 ////////////////////////////////////////////////////////////////////////
160 TObject* AliTOFDigitMap::GetHit(Int_t *vol) const
163 // Get pointer to object at vol
164 // return 0 if vol out of bounds
165 Int_t index=GetHitIndex(vol);
166 return (index <0) ? 0 : fDigits->UncheckedAt(index);
169 ////////////////////////////////////////////////////////////////////////
170 FlagType AliTOFDigitMap::TestHit(Int_t *vol) const
173 // Check if hit cell is empty, used or unused
175 Int_t inf=fDigitMap[CheckedIndex(vol)];
178 } else if (inf == 0) {
185 ////////////////////////////////////////////////////////////////////////
186 AliTOFDigitMap & AliTOFDigitMap::operator = (const AliTOFDigitMap & /*rhs*/)
188 // Dummy assignment operator