]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/TPCLib/tracking-ca/AliHLTTPCCAHitArea.cxx
Ensure that the ADC array is only called for valid entries (AliTRDmcmSim) and bug...
[u/mrichter/AliRoot.git] / HLT / TPCLib / tracking-ca / AliHLTTPCCAHitArea.cxx
CommitLineData
00d07bcd 1//***************************************************************************
2// This file is property of and copyright by the ALICE HLT Project *
3// ALICE Experiment at CERN, All rights reserved. *
4// *
5// Primary Authors: Sergey Gorbunov <sergey.gorbunov@kip.uni-heidelberg.de> *
6// Ivan Kisel <kisel@kip.uni-heidelberg.de> *
7// for The ALICE HLT Project. *
8// *
9// Permission to use, copy, modify and distribute this software and its *
10// documentation strictly for non-commercial purposes is hereby granted *
11// without fee, provided that the above copyright notice appears in all *
12// copies and that both the copyright notice and this permission notice *
13// appear in the supporting documentation. The authors make no claims *
14// about the suitability of this software for any purpose. It is *
15// provided "as is" without express or implied warranty. *
16//***************************************************************************
17
18#include "AliHLTTPCCAHitArea.h"
19#include "AliHLTTPCCATracker.h"
20#include "AliHLTTPCCAGrid.h"
21#include "AliHLTTPCCAHit.h"
4687b8fc 22#include "AliHLTTPCCARow.h"
00d07bcd 23
693d2443 24/*
4687b8fc 25GPUd() void AliHLTTPCCAHitAreaInit( AliHLTTPCCAHitArea &a, AliHLTTPCCAGrid &grid, UShort_t *content, UInt_t hitoffset, Float_t y, Float_t z, Float_t dy, Float_t dz )
00d07bcd 26{
27 // initialisation
28
00d07bcd 29 a.HitOffset() = hitoffset;
30 a.Y() = y;
31 a.Z() = z;
32 a.MinZ() = z-dz;
33 a.MaxZ() = z+dz;
34 a.MinY() = y-dy;
35 a.MaxY() = y+dy;
36 UInt_t bYmin, bZmin, bYmax;
37 grid.GetBin(a.MinY(), a.MinZ(), bYmin, bZmin);
38 grid.GetBin(a.MaxY(), a.MaxZ(), bYmax, a.BZmax());
39 a.BDY() = bYmax - bYmin + 1;
40 a.Ny() = grid.Ny();
4687b8fc 41 a.IndYmin() = bZmin*a.Ny() + bYmin;
42 a.Iz() = bZmin;
43 a.HitYfst() = content[a.IndYmin()];
44 a.HitYlst() = content[a.IndYmin() + a.BDY()];
00d07bcd 45 a.Ih() = a.HitYfst();
46}
693d2443 47*/
00d07bcd 48
49
693d2443 50GPUd() void AliHLTTPCCAHitArea::Init( const AliHLTTPCCAGrid &grid, UShort_t *content, UInt_t hitoffset, Float_t y, Float_t z, Float_t dy, Float_t dz )
00d07bcd 51{
52 //initialisation
693d2443 53
54 fHitOffset = hitoffset;
55 fY = y;
56 fZ = z;
57 fMinZ = z-dz;
58 fMaxZ = z+dz;
59 fMinY = y-dy;
60 fMaxY = y+dy;
61 UInt_t bYmin, bZmin, bYmax;
62 grid.GetBin( fMinY, fMinZ, bYmin, bZmin);
63 grid.GetBin( fMaxY, fMaxZ, bYmax, fBZmax);
64 fBDY = bYmax - bYmin + 1;
65 fNy = grid.Ny();
66 fIndYmin = bZmin*fNy + bYmin;
67 fIz = bZmin;
68 fHitYfst = content[fIndYmin];
69 fHitYlst = content[fIndYmin + fBDY];
70 fIh = fHitYfst;
00d07bcd 71}
72
693d2443 73
74GPUd() Int_t AliHLTTPCCAHitArea::GetNext(AliHLTTPCCATracker &tracker, const AliHLTTPCCARow &row, UShort_t *content, AliHLTTPCCAHit &h)
00d07bcd 75{
76 // get next hit index
4687b8fc 77 Float_t y0 = row.Grid().YMin();
78 Float_t z0 = row.Grid().ZMin();
79 Float_t stepY = row.HstepY();
80 Float_t stepZ = row.HstepZ();
693d2443 81 const uint4* tmpint4 = tracker.RowData() + row.FullOffset();
82 const ushort2 *hits = reinterpret_cast<const ushort2*>(tmpint4);
4687b8fc 83
00d07bcd 84 Int_t ret = -1;
85 do{
86 while( fIh>=fHitYlst ){
87 if( fIz>=fBZmax ) return -1;
88 fIz++;
89 fIndYmin += fNy;
4687b8fc 90 fHitYfst = content[fIndYmin];
91 fHitYlst = content[fIndYmin + fBDY];
00d07bcd 92 fIh = fHitYfst;
93 }
4687b8fc 94
95 {
96 ushort2 hh = hits[fIh];
693d2443 97 h.SetY( y0 + hh.x*stepY );
98 h.SetZ( z0 + hh.y*stepZ );
4687b8fc 99 }
100 //h = tracker.Hits()[ fHitOffset + fIh ];
00d07bcd 101
693d2443 102 if( 0 && (h.Z()>fMaxZ || h.Z()<fMinZ || h.Y()<fMinY || h.Y()>fMaxY )){ //SG!!!
00d07bcd 103 fIh++;
104 continue;
105 }
106 ret = fIh;
107 fIh++;
108 break;
109 } while(1);
110 return ret;
111}
112
113
114
693d2443 115GPUd() Int_t AliHLTTPCCAHitArea::GetBest(AliHLTTPCCATracker &tracker, const AliHLTTPCCARow &row, UShort_t *content, AliHLTTPCCAHit &h)
00d07bcd 116{
117 // get closest hit in the area
118 Int_t best = -1;
119 Float_t ds = 1.e10;
120 do{
121 AliHLTTPCCAHit hh;
4687b8fc 122 Int_t ih=GetNext( tracker, row, content, hh );
00d07bcd 123 if( ih<0 ) break;
693d2443 124 Float_t dy = hh.Y() - fY;
125 Float_t dz = hh.Z() - fZ;
00d07bcd 126 Float_t dds = dy*dy+dz*dz;
127 if( dds<ds ){
128 ds = dds;
129 best = ih;
130 h = hh;
131 }
132 }while(1);
133
134 return best;
135}
136