5a806c0e |
1 | |
4aa41877 |
2 | #include "AliHLTTrigger.h" |
3 | #include "AliHLTTrackArray.h" |
4 | #include "AliHLTTransform.h" |
5 | #include "AliHLTVertex.h" |
6 | #include "AliHLTDefs.h" |
7 | #include "AliHLTDigitData.h" |
8 | #include "AliHLTLogging.h" |
9 | #include "AliHLTTrack.h" |
10 | #include "AliHLTMemHandler.h" |
5a806c0e |
11 | |
4aa41877 |
12 | ClassImp(AliHLTTrigger) |
5a806c0e |
13 | |
4aa41877 |
14 | AliHLTTrigger::AliHLTTrigger() |
5a806c0e |
15 | { |
16 | fDataSize=0; |
17 | fTracks=0; |
5a806c0e |
18 | fDigitRowData=0; |
19 | fOutput=0; |
20 | fVertex=0; |
21 | } |
22 | |
4aa41877 |
23 | AliHLTTrigger::~AliHLTTrigger() |
5a806c0e |
24 | { |
25 | if(fTracks) |
26 | delete fTracks; |
5a806c0e |
27 | } |
28 | |
4aa41877 |
29 | void AliHLTTrigger::InitTrigger() |
5a806c0e |
30 | { |
31 | if(fTracks) |
32 | delete fTracks; |
4aa41877 |
33 | fTracks = new AliHLTTrackArray(); |
5a806c0e |
34 | } |
35 | |
4aa41877 |
36 | void AliHLTTrigger::InitPatch(Int_t slice,Int_t patch) |
5a806c0e |
37 | { |
38 | fSlice=slice; |
39 | fPatch=patch; |
40 | fTracks->Reset(); |
41 | } |
42 | |
4aa41877 |
43 | void AliHLTTrigger::FillTracks(Int_t ntracks,AliHLTTrackSegmentData *tr) |
5a806c0e |
44 | { |
45 | fTracks->FillTracks(ntracks,tr); |
46 | } |
47 | |
4aa41877 |
48 | void AliHLTTrigger::FillData(AliHLTDigitRowData *data) |
5a806c0e |
49 | { |
50 | fDigitRowData = data; |
51 | } |
52 | |
4aa41877 |
53 | void AliHLTTrigger::SetParameters(Float_t zcut,Int_t timematch,Int_t padmatch) |
5a806c0e |
54 | { |
55 | fZcut=zcut; |
56 | fTimeMatch=timematch; |
57 | fPadMatch=padmatch; |
58 | } |
59 | |
4aa41877 |
60 | void AliHLTTrigger::SetOutputData(AliHLTDigitRowData *ptr) |
5a806c0e |
61 | { |
62 | fOutput=ptr; |
63 | } |
64 | |
4aa41877 |
65 | void AliHLTTrigger::RemovePileupTracks() |
5a806c0e |
66 | { |
67 | Double_t xc,yc,zc; |
68 | for(Int_t i=0; i<fTracks->GetNTracks(); i++) |
69 | { |
4aa41877 |
70 | AliHLTTrack *track = fTracks->GetCheckedTrack(i); |
5a806c0e |
71 | if(!track) continue; |
72 | track->Rotate(fSlice,kTRUE); |
73 | track->CalculateHelix(); |
74 | track->GetClosestPoint(fVertex,xc,yc,zc); |
75 | if(fabs(zc) > fZcut) |
76 | { |
77 | fTracks->Remove(i); |
78 | continue; |
79 | } |
80 | } |
81 | fTracks->Compress(); |
82 | } |
83 | |
4aa41877 |
84 | void AliHLTTrigger::RemovePileupData() |
5a806c0e |
85 | { |
86 | Float_t hit[3]; |
87 | Int_t sector,row; |
88 | struct rowhit {Int_t pad; Int_t time;}; |
89 | rowhit row_cross[(fTracks->GetNTracks())]; |
90 | Int_t digitcount[(NumRows[fPatch])]; |
91 | Int_t totalcount=0; |
4aa41877 |
92 | AliHLTDigitRowData *rowPt = fDigitRowData; |
5a806c0e |
93 | for(Int_t i=NRows[fPatch][0]; i<=NRows[fPatch][1]; i++) |
94 | { |
95 | digitcount[(i-NRows[fPatch][0])]=0; |
96 | for(Int_t j=0; j<fTracks->GetNTracks(); j++) |
97 | { |
4aa41877 |
98 | AliHLTTrack *track = fTracks->GetCheckedTrack(j); |
5a806c0e |
99 | if(!track) continue; |
100 | track->GetCrossingPoint(i,hit); |
4aa41877 |
101 | AliHLTTransform::Slice2Sector(fSlice,i,sector,row); |
102 | AliHLTTransform::Local2Raw(hit,sector,row); |
5a806c0e |
103 | row_cross[j].pad = (Int_t)rint(hit[1]); |
104 | row_cross[j].time = (Int_t)rint(hit[2]); |
105 | } |
4aa41877 |
106 | AliHLTDigitData *digPt = (AliHLTDigitData*)rowPt->fDigitData; |
5a806c0e |
107 | Bool_t mark; |
108 | for(Int_t k=0; k<rowPt->fNDigit; k++) |
109 | { |
110 | mark = kFALSE; |
111 | for(Int_t l=0; l<fTracks->GetNTracks(); l++) |
112 | { |
113 | if(abs((Int_t)digPt[k].fPad-row_cross[l].pad) < fPadMatch && |
114 | abs((Int_t)digPt[k].fTime-row_cross[l].time) < fTimeMatch) |
115 | { |
116 | digitcount[(i-NRows[fPatch][0])]++; |
117 | totalcount++; |
118 | mark=kTRUE; |
119 | break; |
120 | } |
121 | } |
122 | if(mark==kTRUE) |
123 | digPt[k].fCharge=0; |
124 | } |
4aa41877 |
125 | AliHLTMemHandler::UpdateRowPointer(rowPt); |
5a806c0e |
126 | } |
127 | |
4aa41877 |
128 | Int_t size = totalcount*sizeof(AliHLTDigitData) + NumRows[fPatch]*sizeof(AliHLTDigitRowData); |
5a806c0e |
129 | fDataSize = size; |
4aa41877 |
130 | LOG(AliHLTLog::kDebug,"AliHLTTrigger::RemovePileupData","Memory") |
5a806c0e |
131 | <<"Allocating "<<size<<" bytes of data for trigger event"<<ENDLOG; |
132 | Byte_t *data = new Byte_t[size]; |
133 | memset(data,0,size); |
4aa41877 |
134 | AliHLTDigitRowData *tempPt = (AliHLTDigitRowData*)data; |
5a806c0e |
135 | rowPt = fDigitRowData; |
136 | |
137 | Int_t localcount; |
138 | for(Int_t i=NRows[fPatch][0]; i<=NRows[fPatch][1]; i++) |
139 | { |
140 | tempPt->fRow = i; |
141 | tempPt->fNDigit = digitcount[(i-NRows[fPatch][0])]; |
4aa41877 |
142 | AliHLTDigitData *digPt = (AliHLTDigitData*)rowPt->fDigitData; |
5a806c0e |
143 | localcount=0; |
144 | for(Int_t j=0; j<rowPt->fNDigit; j++) |
145 | { |
146 | if(digPt[j].fCharge==0) continue; |
147 | if(localcount >= digitcount[(i-NRows[fPatch][0])]) |
148 | { |
4aa41877 |
149 |