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