]>
Commit | Line | Data |
---|---|---|
f9720615 | 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 | **************************************************************************/ | |
15 | ||
16 | /* $Id$ */ | |
17 | ||
18 | //////////////////////////////////////////////////////////////////////////// | |
19 | // // | |
20 | // Pre-Trigger Control-Box A or C for simulation // | |
21 | // // | |
22 | // Authors: F. Reidt (Felix.Reidt@cern.ch) // | |
23 | // // | |
24 | //////////////////////////////////////////////////////////////////////////// | |
25 | ||
26 | #include <stdio.h> | |
27 | ||
28 | #include "AliRun.h" | |
29 | #include "AliRunLoader.h" | |
30 | ||
31 | #include "AliLog.h" | |
32 | ||
33 | #include "AliTRDptrgParam.h" | |
34 | #include "AliTRDptrgFEB.h" | |
35 | #include "AliTRDptrgLUT.h" | |
36 | ||
37 | #include "AliTRDptrgCBAC.h" | |
38 | ||
39 | ClassImp(AliTRDptrgCBAC) | |
40 | ||
41 | //______________________________________________________________________________ | |
42 | AliTRDptrgCBAC::AliTRDptrgCBAC(AliRunLoader *rl) | |
43 | : TObject(), | |
44 | fRunLoader(rl), | |
45 | fLUTArray(), | |
46 | fFEBArray(), | |
47 | fPosition(kUnknown), | |
48 | fOperatingMode(kDigits), | |
49 | fParam(0x0) | |
50 | { | |
51 | // ctor | |
52 | AliError("default ctor - usage not recommended"); | |
53 | } | |
54 | ||
55 | //______________________________________________________________________________ | |
56 | AliTRDptrgCBAC::AliTRDptrgCBAC(AliRunLoader *rl, | |
57 | AliTRDptrgFEBPosition_t position, | |
58 | AliTRDptrgOperatingMode_t operatingMode, | |
59 | AliTRDptrgParam *param) | |
60 | : TObject(), | |
61 | fRunLoader(rl), | |
62 | fLUTArray(), | |
63 | fFEBArray(), | |
64 | fPosition(position), | |
65 | fOperatingMode(operatingMode), | |
66 | fParam(param) | |
67 | { | |
68 | // ctor | |
69 | this->LoadParams(); // load parameters | |
70 | ||
71 | // T0 | |
72 | AliTRDptrgFEB *FEB = new AliTRDptrgFEB(this->fRunLoader, kTZERO, | |
73 | this->fOperatingMode, this->fPosition, | |
74 | 0, this->fParam); | |
75 | this->fFEBArray.AddLast(FEB); | |
76 | ||
77 | // V0-1 | |
78 | FEB = new AliTRDptrgFEB(this->fRunLoader, kVZERO, this->fOperatingMode, | |
79 | this->fPosition, 1, this->fParam); | |
80 | this->fFEBArray.AddLast(FEB); | |
81 | ||
82 | // V0-2 | |
83 | FEB = new AliTRDptrgFEB(this->fRunLoader, kVZERO, this->fOperatingMode, | |
84 | this->fPosition, 2, this->fParam); | |
85 | this->fFEBArray.AddLast(FEB); | |
86 | ||
87 | // V0-3 | |
88 | FEB = new AliTRDptrgFEB(this->fRunLoader, kVZERO, this->fOperatingMode, | |
89 | this->fPosition, 3, this->fParam); | |
90 | this->fFEBArray.AddLast(FEB); | |
91 | ||
92 | // V0-4 | |
93 | FEB = new AliTRDptrgFEB(this->fRunLoader, kVZERO, this->fOperatingMode, | |
94 | this->fPosition, 4, this->fParam); | |
95 | this->fFEBArray.AddLast(FEB); | |
96 | ||
97 | } | |
98 | ||
99 | //______________________________________________________________________________ | |
100 | Bool_t AliTRDptrgCBAC::LoadParams() | |
101 | { | |
102 | // load configuration parameters | |
103 | ||
104 | if (this->fParam != 0x0) { | |
105 | // read AliTRDptrgParam | |
106 | ||
107 | // get LUTs | |
108 | AliTRDptrgLUT* LUT = new AliTRDptrgLUT(); | |
109 | // 0 | |
110 | LUT = new AliTRDptrgLUT(); | |
111 | LUT->InitTable(10, 10, this->fParam->GetCBLUT(this->fPosition, 0), kFALSE); | |
112 | // do not copy table data | |
113 | this->fLUTArray.AddLast(LUT); | |
114 | // 1 | |
115 | LUT = new AliTRDptrgLUT(); | |
116 | LUT->InitTable(10, 10, this->fParam->GetCBLUT(this->fPosition, 1), kFALSE); | |
e51605d9 | 117 | // do not copy table data |
f9720615 | 118 | this->fLUTArray.AddLast(LUT); |
119 | } | |
120 | else { | |
121 | // load default parameters | |
122 | AliTRDptrgLUT* LUT = new AliTRDptrgLUT(); | |
123 | this->fLUTArray.AddLast(LUT); | |
124 | LUT = new AliTRDptrgLUT(); | |
125 | this->fLUTArray.AddLast(LUT); | |
e51605d9 | 126 | // the following lines are only needed for test reasons |
f9720615 | 127 | LUT = dynamic_cast<AliTRDptrgLUT*>(this->fLUTArray.At(0)); |
128 | Int_t* initData = new Int_t[1024]; // 2^10 | |
129 | for (Int_t i = 0; i < 1024; i++ ) { | |
130 | initData[i] = i; | |
131 | } | |
132 | LUT->InitTable(10, 10, initData, kTRUE); // copy initData | |
133 | LUT = dynamic_cast<AliTRDptrgLUT*>(this->fLUTArray.At(1)); | |
134 | for (Int_t i = 1023; i >= 0; i--) { | |
135 | initData[31 - i] = i; // inverse ramp | |
136 | } | |
137 | LUT->InitTable(10, 10, initData, kTRUE); // copy initData | |
138 | } | |
139 | return false; | |
140 | } | |
141 | ||
142 | //______________________________________________________________________________ | |
143 | AliTRDptrgCBAC::~AliTRDptrgCBAC() | |
144 | { | |
145 | // destructor | |
146 | ||
147 | this->fLUTArray.Delete(); | |
148 | this->fFEBArray.Delete(); | |
149 | } | |
150 | ||
151 | //______________________________________________________________________________ | |
152 | Int_t* AliTRDptrgCBAC::Simulate() | |
e51605d9 | 153 | { |
f9720615 | 154 | // Simulate the CBAC behavior of event |
155 | Int_t nFEBs = this->fFEBArray.GetEntries(); | |
156 | Int_t nLUTs = this->fLUTArray.GetEntries(); | |
157 | ||
158 | Int_t inputVector = 0x0; | |
159 | ||
160 | Int_t** partResults = 0x0; | |
161 | partResults = new Int_t* [nFEBs]; | |
162 | ||
163 | ||
164 | for (Int_t iFEB = 0; iFEB < nFEBs; iFEB++) { | |
165 | partResults[iFEB] = | |
166 | dynamic_cast<AliTRDptrgFEB*>(this->fFEBArray.At(iFEB))->Simulate(); | |
167 | } | |
168 | ||
169 | // combine partResults and create inputVector | |
170 | Int_t iBit = 0; | |
171 | Int_t mask = 0x1; | |
172 | for (Int_t iFEB = 0; iFEB < nFEBs ; iFEB++) { | |
173 | for (Int_t j = 1; j <= partResults[iFEB][0]; j++) { | |
e51605d9 | 174 | if ((iBit > |
f9720615 | 175 | dynamic_cast<AliTRDptrgLUT*>(this->fLUTArray[0])->GetInputWidth()) |
e51605d9 | 176 | || (iBit > |
f9720615 | 177 | dynamic_cast<AliTRDptrgLUT*>(this->fLUTArray[0])->GetInputWidth())) { |
178 | AliError("FEB result width does not match CB-A/C input with!"); | |
179 | } | |
e51605d9 | 180 | iBit++; |
f9720615 | 181 | if (partResults[iFEB][j] > 0) { |
182 | inputVector |= mask; // Add bit to the corresponding inputVector | |
183 | mask <<= 1; | |
184 | } | |
185 | } | |
186 | } | |
f9720615 | 187 | |
188 | AliDebug(5, Form("Inputvector: 0x%x", inputVector)); | |
189 | ||
190 | // perform look up | |
191 | Int_t* result = new Int_t[nLUTs + 1]; // generate new return array | |
192 | result[0] = nLUTs; // storage array length in the first array value | |
193 | for (Int_t iLUT = 0; iLUT < nLUTs; iLUT++) { | |
194 | // process the return value for each LUT and store the result in the array | |
195 | result[iLUT + 1] = | |
196 | dynamic_cast<AliTRDptrgLUT*>( | |
197 | this->fLUTArray[iLUT])->LookUp(inputVector); | |
198 | AliDebug(4, Form("CBAC result[%d] = 0x%x",(iLUT + 1),result[iLUT + 1])); | |
199 | } | |
200 | ||
201 | return result; | |
202 | } | |
203 | ||
204 | ||
205 |