1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 ////////////////////////////////////////////////////////////////////////////
20 // Pre-Trigger Control-Box bottom class //
22 // Authors: F. Reidt (Felix.Reidt@cern.ch) //
24 ////////////////////////////////////////////////////////////////////////////
30 #include "AliRunLoader.h"
32 #include "AliTRDptrgLUT.h"
33 #include "AliTRDptrgParam.h"
34 #include "AliTRDptrgCBAC.h"
35 #include "AliTRDptrgTLMU.h"
36 #include "AliTRDptrgCBB.h"
38 ClassImp(AliTRDptrgCBB)
40 AliTRDptrgCBB::AliTRDptrgCBB(AliRunLoader *rl)
44 fOperatingMode(AliTRDptrgParam::kDigits),
52 AliError("default ctor - usage not recommended\n");
56 AliTRDptrgCBB::AliTRDptrgCBB(AliRunLoader *rl, AliTRDptrgParam* param,
57 AliTRDptrgParam::AliTRDptrgOperatingMode_t operatingMode)
61 fOperatingMode(operatingMode),
69 this->fCBA = new AliTRDptrgCBAC(rl, AliTRDptrgParam::kA, operatingMode, param);
70 this->fCBC = new AliTRDptrgCBAC(rl, AliTRDptrgParam::kC, operatingMode, param);
71 this->fTLMU = new AliTRDptrgTLMU(rl, param, operatingMode);
76 AliTRDptrgCBB::~AliTRDptrgCBB()
80 if (this->fCBA != 0x0) {
85 if (this->fCBC != 0x0) {
90 if (this->fTLMU != 0x0) {
95 this->fLUTArray.Delete();
99 //______________________________________________________________________________
100 Bool_t AliTRDptrgCBB::LoadParams()
102 // load configuration parameters
104 if (this->fParam != 0x0) {
105 // read AliTRDptrgParam
109 AliTRDptrgLUT* LUT = new AliTRDptrgLUT();
110 LUT->InitTable(12, 12, this->fParam->GetCBLUT(0, 0), kFALSE);
111 // get CB-B_0 and do not copy lut content
112 this->fLUTArray.AddLast(LUT);
115 LUT = new AliTRDptrgLUT();
116 LUT->InitTable(12, 12, this->fParam->GetCBLUT(0, 1), kFALSE);
117 // get CB-B_1 and do not copy lut content
118 this->fLUTArray.AddLast(LUT);
121 LUT = new AliTRDptrgLUT();
122 LUT->InitTable(12, 12, this->fParam->GetCBLUT(0, 2), kFALSE);
123 // get CB-B_2 and do not copy lut content
124 this->fLUTArray.AddLast(LUT);
127 this->fPTmasks = this->fParam->GetPTmasks();
130 // load default parameters
131 // initialize LUTsoutputWidth=<value optimized out>
132 AliTRDptrgLUT* lut = new AliTRDptrgLUT();
133 this->fLUTArray.AddLast(lut);
134 lut = new AliTRDptrgLUT(); // this->fRunLoader
135 this->fLUTArray.AddLast(lut);
136 lut = new AliTRDptrgLUT(); // this->fRunLoader
137 this->fLUTArray.AddLast(lut);
138 // the following lines are only needed for test reasons
139 Int_t* initData = new Int_t[4096]; // 2^12
140 lut = dynamic_cast<AliTRDptrgLUT*>(this->fLUTArray.At(0));
142 for (Int_t i = 0; i < 4096; i++ ) {
145 lut->InitTable(12, 12, initData, kTRUE); // make a copy
147 lut = dynamic_cast<AliTRDptrgLUT*>(this->fLUTArray.At(0));
149 for (Int_t i = 0; i < 4096; i++ ) {
152 lut->InitTable(12, 12, initData, kTRUE); // make a copy
154 lut = dynamic_cast<AliTRDptrgLUT*>(this->fLUTArray.At(1));
156 //for (Int_t i = 4096; i >= 0; i--) {
157 for (Int_t i = 4096; i > 0; i--) {
158 initData[4096 - i] = i; // inverse ramp
160 lut->InitTable(12, 12, initData, kTRUE); // make a copy
164 AliTRDptrgParam::AliTRDptrgPTmasks* masks =
165 new AliTRDptrgParam::AliTRDptrgPTmasks();
166 masks->fLUTs[0] = kTRUE;
167 masks->fLUTs[1] = kTRUE;
168 masks->fLUTs[2] = kTRUE;
169 this->fPTmasks = masks;
174 //______________________________________________________________________________
175 Int_t* AliTRDptrgCBB::Simulate()
177 // Simulate the CBB behavior of event
179 // returns array containing:
180 // 0: array element count
181 // 1..count-2: LUT results
182 // count-1: pretrigger decision
184 Int_t nLUTs = this->fLUTArray.GetEntries();
186 Int_t inputVector = 0x0;
187 // initialize partResults
188 Int_t** partResults = 0x0;
189 partResults = new Int_t* [3]; // CB-A, CB-C, TLMU
192 partResults[0] = this->fCBA->Simulate(); // CB-A
193 partResults[1] = this->fCBC->Simulate(); // CB-C
194 partResults[2] = this->fTLMU->Simulate(); // TLMU
196 // combine partResults and create inputVectors
198 for (Int_t i = 0; i < 3 ; i++) {
199 for (Int_t j = 1; j <= partResults[i][0]; j++) {
200 if (partResults[i][j] > 0) {
201 inputVector |= mask; // Add bit to the inputVector
207 AliDebug(5, Form("Inputvectors: 0x%x", inputVector));
210 Int_t* result = new Int_t[nLUTs + 2]; // generate new return array
211 result[0] = nLUTs + 1; // storage array length in the first array value
212 for (Int_t iLUT = 0; iLUT < nLUTs; iLUT++) {
213 // process the return value for each LUT and store the result in the array
214 AliTRDptrgLUT *lutTmp = dynamic_cast<AliTRDptrgLUT*>(this->fLUTArray[iLUT]);
216 result[iLUT + 1] = lutTmp->LookUp(inputVector);
218 AliDebug(4, Form("CBB result[%d] = 0x%x\n",(iLUT + 1),result[iLUT + 1]));
221 // evaluate PT decision
222 // stored in result[nLUTs + 1]
223 result[nLUTs + 1] = 0;
225 for (Int_t i = 0; i < 2; i++) {
227 if (this->fPTmasks->fCBA[i] && partResults[0][i + 1]) {
231 if (this->fPTmasks->fCBC[i] && partResults[1][i + 1]) {
235 if (this->fPTmasks->fLUTs[i] && result[i + 1]) {
239 if (this->fPTmasks->fLUTs[2] && result[3]) { // CB-B (third own LUT)
244 for (Int_t i = 0; i < 8; i++) {
245 if (this->fPTmasks->fTLMU[i] && partResults[2][i + 1]) {
249 AliDebug(4, Form("CBB TRD Wake up result = %d", result[nLUTs + 1]));
251 delete [] partResults;
257 //______________________________________________________________________________
258 Bool_t AliTRDptrgCBB::GetPT() {
259 // evaluates the pre trigger decision
261 Int_t* LUTresults = this->Simulate();
262 if (LUTresults[(LUTresults[0] - 1)]) {