]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TRD/AliTRDptrgCBB.cxx
TRD pretrigger simulation based on digits of T0, V0 and TOF, simulation control is...
[u/mrichter/AliRoot.git] / TRD / AliTRDptrgCBB.cxx
CommitLineData
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 bottom class //
21// //
22// Authors: F. Reidt (Felix.Reidt@cern.ch) //
23// //
24////////////////////////////////////////////////////////////////////////////
25
26
27#include "TROOT.h"
28
29#include "AliRun.h"
30#include "AliRunLoader.h"
31
32#include "AliTRDptrgLUT.h"
33#include "AliTRDptrgParam.h"
34#include "AliTRDptrgCBAC.h"
35#include "AliTRDptrgTLMU.h"
36#include "AliTRDptrgCBB.h"
37ClassImp(AliTRDptrgCBB)
38
39AliTRDptrgCBB::AliTRDptrgCBB(AliRunLoader *rl)
40 : TObject(),
41 fRunLoader(rl),
42 fParam(0),
43 fOperatingMode(kDigits),
44 fCBA(0),
45 fCBC(0),
46 fTLMU(0),
47 fLUTArray(0),
48 fPTmasks(0x0)
49{
50 // default ctor
51 AliError("default ctor - usage not recommended\n");
52}
53
54
55AliTRDptrgCBB::AliTRDptrgCBB(AliRunLoader *rl, AliTRDptrgParam* param,
56 AliTRDptrgOperatingMode_t operatingMode)
57 : TObject(),
58 fRunLoader(rl),
59 fParam(param),
60 fOperatingMode(operatingMode),
61 fCBA(0),
62 fCBC(0),
63 fTLMU(0),
64 fLUTArray(0),
65 fPTmasks(0x0)
66{
67 // recommended ctor
68 this->fCBA = new AliTRDptrgCBAC(rl, kA, operatingMode, param);
69 this->fCBC = new AliTRDptrgCBAC(rl, kC, operatingMode, param);
70 this->fTLMU = new AliTRDptrgTLMU(rl, param, operatingMode);
71
72 this->LoadParams();
73}
74
75AliTRDptrgCBB::~AliTRDptrgCBB()
76{
77 // destructor
78
79 if (this->fCBA != 0x0) {
80 delete this->fCBA;
81 this->fCBA = 0x0;
82 }
83
84 if (this->fCBC != 0x0) {
85 delete this->fCBC;
86 this->fCBC = 0x0;
87 }
88
89 if (this->fTLMU != 0x0) {
90 delete this->fTLMU;
91 this->fTLMU = 0x0;
92 }
93
94 this->fLUTArray.Delete();
95}
96
97
98//______________________________________________________________________________
99Bool_t AliTRDptrgCBB::LoadParams()
100{
101 // load configuration parameters
102
103 if (this->fParam != 0x0) {
104 // read AliTRDptrgParam
105
106 // get LUTs
107 // 0
108 AliTRDptrgLUT* LUT = new AliTRDptrgLUT();
109 LUT->InitTable(12, 12, this->fParam->GetCBLUT(0, 0), kFALSE);
110 // get CB-B_0 and do not copy lut content
111 this->fLUTArray.AddLast(LUT);
112
113 // 1
114 LUT = new AliTRDptrgLUT();
115 LUT->InitTable(12, 12, this->fParam->GetCBLUT(0, 1), kFALSE);
116 // get CB-B_0 and do not copy lut content
117 this->fLUTArray.AddLast(LUT);
118
119 // masks
120 this->fPTmasks = this->fParam->GetPTmasks();
121 }
122 else {
123 // load default parameters
124 // initialize LUTsoutputWidth=<value optimized out>
125 AliTRDptrgLUT* LUT = new AliTRDptrgLUT();
126 this->fLUTArray.AddLast(LUT);
127 LUT = new AliTRDptrgLUT(); // this->fRunLoader
128 this->fLUTArray.AddLast(LUT);
129 // the following lines are only needed for test reasons
130 LUT = dynamic_cast<AliTRDptrgLUT*>(this->fLUTArray.At(0));
131 Int_t* initData = new Int_t[4096]; // 2^12
132 for (Int_t i = 0; i < 4096; i++ ) {
133 initData[i] = i;
134 }
135 LUT->InitTable(12, 12, initData, kTRUE); // make a copy
136 LUT = dynamic_cast<AliTRDptrgLUT*>(this->fLUTArray.At(1));
137 for (Int_t i = 4096; i >= 0; i--) {
138 initData[4096 - i] = i; // inverse ramp
139 }
140 LUT->InitTable(12, 12, initData, kTRUE); // make a copy
141
142 AliTRDptrgParam::AliTRDptrgPTmasks* masks =
143 new AliTRDptrgParam::AliTRDptrgPTmasks();
144 masks->fLUTs[0] = kTRUE;
145 masks->fLUTs[1] = kTRUE;
146 this->fPTmasks = masks;
147 }
148 return false;
149}
150
151//______________________________________________________________________________
152Int_t* AliTRDptrgCBB::Simulate()
153{
154 // Simulate the CBB behavior of event
155 //
156 // returns array containing:
157 // 0: array element count
158 // 1..count-2: LUT results
159 // count-1: pretrigger decision
160
161 Int_t nLUTs = this->fLUTArray.GetEntries();
162
163 Int_t inputVector = 0x0;
164 // initialize partResults
165 Int_t** partResults = 0x0;
166 partResults = new Int_t* [3]; // CB-A, CB-C, TLMU
167
168 // get partResults
169 partResults[0] = this->fCBA->Simulate(); // CB-A
170 partResults[1] = this->fCBC->Simulate(); // CB-C
171 partResults[2] = this->fTLMU->Simulate(); // TLMU
172
173
174 // combine partResults and create inputVectors
175 // TODO make assignment configurable
176 Int_t mask = 0x1;
177 for (Int_t i = 0; i < 3 ; i++) {
178 for (Int_t j = 1; j <= partResults[i][0]; j++) {
179 if (partResults[i][j] > 0) {
180 inputVector |= mask; // Add bit to the inputVector
181 }
182 mask <<= 1;
183 }
184 }
185
186 AliDebug(5, Form("Inputvectors: 0x%x", inputVector));
187
188 // perform look up
189 Int_t* result = new Int_t[nLUTs + 2]; // generate new return array
190 result[0] = nLUTs + 1; // storage array length in the first array value
191 for (Int_t iLUT = 0; iLUT < nLUTs; iLUT++) {
192 // process the return value for each LUT and store the result in the array
193 result[iLUT + 1] =
194 dynamic_cast<AliTRDptrgLUT*>(this->fLUTArray[iLUT])->LookUp(inputVector);
195 AliDebug(4, Form("CBB result[%d] = 0x%x\n",(iLUT + 1),result[iLUT + 1]));
196 }
197
198 // evaluate PT decision
199 // stored in result[nLUTs + 1]
200 result[nLUTs + 1] = 0;
201
202 for (Int_t i = 0; i < 2; i++) {
203 // CB-A
204 if (this->fPTmasks->fCBA[i] && partResults[0][i + 1]) {
205 result[nLUTs + 1]++;
206 }
207 // CB-C
208 if (this->fPTmasks->fCBC[i] && partResults[1][i + 1]) {
209 result[nLUTs + 1]++;
210 }
211 // CB-B (own LUTs)
212 if (this->fPTmasks->fLUTs[i] && result[i + 1]) {
213 result[nLUTs + 1]++;
214 }
215 }
216 // TLMU
217 for (Int_t i = 0; i < 8; i++) {
218 if (this->fPTmasks->fTLMU[i] && partResults[2][i + 1]) {
219 result[nLUTs + 1]++;
220 }
221 }
222 AliDebug(4, Form("CBB TRD Wake up result = %d", result[nLUTs + 1]));
223 return result;
224}
225
226//______________________________________________________________________________
227Bool_t AliTRDptrgCBB::GetPT() {
228 // evaluates the pre trigger decision
229
230 Int_t* LUTresults = this->Simulate();
231 if (LUTresults[(LUTresults[0] - 1)]) {
232 delete[] LUTresults;
233 return kTRUE;
234 }
235 else {
236 delete[] LUTresults;
237 return kFALSE;
238 }
239}