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"
37 ClassImp(AliTRDptrgCBB)
39 AliTRDptrgCBB::AliTRDptrgCBB(AliRunLoader *rl)
43 fOperatingMode(kDigits),
51 AliError("default ctor - usage not recommended\n");
55 AliTRDptrgCBB::AliTRDptrgCBB(AliRunLoader *rl, AliTRDptrgParam* param,
56 AliTRDptrgOperatingMode_t operatingMode)
60 fOperatingMode(operatingMode),
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);
75 AliTRDptrgCBB::~AliTRDptrgCBB()
79 if (this->fCBA != 0x0) {
84 if (this->fCBC != 0x0) {
89 if (this->fTLMU != 0x0) {
94 this->fLUTArray.Delete();
98 //______________________________________________________________________________
99 Bool_t AliTRDptrgCBB::LoadParams()
101 // load configuration parameters
103 if (this->fParam != 0x0) {
104 // read AliTRDptrgParam
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);
114 LUT = new AliTRDptrgLUT();
115 LUT->InitTable(12, 12, this->fParam->GetCBLUT(0, 1), kFALSE);
116 // get CB-B_1 and do not copy lut content
117 this->fLUTArray.AddLast(LUT);
120 LUT = new AliTRDptrgLUT();
121 LUT->InitTable(12, 12, this->fParam->GetCBLUT(0, 2), kFALSE);
122 // get CB-B_2 and do not copy lut content
123 this->fLUTArray.AddLast(LUT);
126 this->fPTmasks = this->fParam->GetPTmasks();
129 // load default parameters
130 // initialize LUTsoutputWidth=<value optimized out>
131 AliTRDptrgLUT* lut = new AliTRDptrgLUT();
132 this->fLUTArray.AddLast(lut);
133 lut = new AliTRDptrgLUT(); // this->fRunLoader
134 this->fLUTArray.AddLast(lut);
135 lut = new AliTRDptrgLUT(); // this->fRunLoader
136 this->fLUTArray.AddLast(lut);
137 // the following lines are only needed for test reasons
138 Int_t* initData = new Int_t[4096]; // 2^12
139 lut = dynamic_cast<AliTRDptrgLUT*>(this->fLUTArray.At(0));
141 for (Int_t i = 0; i < 4096; i++ ) {
144 lut->InitTable(12, 12, initData, kTRUE); // make a copy
146 lut = dynamic_cast<AliTRDptrgLUT*>(this->fLUTArray.At(0));
148 for (Int_t i = 0; i < 4096; i++ ) {
151 lut->InitTable(12, 12, initData, kTRUE); // make a copy
153 lut = dynamic_cast<AliTRDptrgLUT*>(this->fLUTArray.At(1));
155 //for (Int_t i = 4096; i >= 0; i--) {
156 for (Int_t i = 4096; i > 0; i--) {
157 initData[4096 - i] = i; // inverse ramp
159 lut->InitTable(12, 12, initData, kTRUE); // make a copy
163 AliTRDptrgParam::AliTRDptrgPTmasks* masks =
164 new AliTRDptrgParam::AliTRDptrgPTmasks();
165 masks->fLUTs[0] = kTRUE;
166 masks->fLUTs[1] = kTRUE;
167 masks->fLUTs[2] = kTRUE;
168 this->fPTmasks = masks;
173 //______________________________________________________________________________
174 Int_t* AliTRDptrgCBB::Simulate()
176 // Simulate the CBB behavior of event
178 // returns array containing:
179 // 0: array element count
180 // 1..count-2: LUT results
181 // count-1: pretrigger decision
183 Int_t nLUTs = this->fLUTArray.GetEntries();
185 Int_t inputVector = 0x0;
186 // initialize partResults
187 Int_t** partResults = 0x0;
188 partResults = new Int_t* [3]; // CB-A, CB-C, TLMU
191 partResults[0] = this->fCBA->Simulate(); // CB-A
192 partResults[1] = this->fCBC->Simulate(); // CB-C
193 partResults[2] = this->fTLMU->Simulate(); // TLMU
195 // combine partResults and create inputVectors
197 for (Int_t i = 0; i < 3 ; i++) {
198 for (Int_t j = 1; j <= partResults[i][0]; j++) {
199 if (partResults[i][j] > 0) {
200 inputVector |= mask; // Add bit to the inputVector
206 AliDebug(5, Form("Inputvectors: 0x%x", inputVector));
209 Int_t* result = new Int_t[nLUTs + 2]; // generate new return array
210 result[0] = nLUTs + 1; // storage array length in the first array value
211 for (Int_t iLUT = 0; iLUT < nLUTs; iLUT++) {
212 // process the return value for each LUT and store the result in the array
213 AliTRDptrgLUT *lutTmp = dynamic_cast<AliTRDptrgLUT*>(this->fLUTArray[iLUT]);
215 result[iLUT + 1] = lutTmp->LookUp(inputVector);
217 AliDebug(4, Form("CBB result[%d] = 0x%x\n",(iLUT + 1),result[iLUT + 1]));
220 // evaluate PT decision
221 // stored in result[nLUTs + 1]
222 result[nLUTs + 1] = 0;
224 for (Int_t i = 0; i < 2; i++) {
226 if (this->fPTmasks->fCBA[i] && partResults[0][i + 1]) {
230 if (this->fPTmasks->fCBC[i] && partResults[1][i + 1]) {
234 if (this->fPTmasks->fLUTs[i] && result[i + 1]) {
238 if (this->fPTmasks->fLUTs[2] && result[3]) { // CB-B (third own LUT)
243 for (Int_t i = 0; i < 8; i++) {
244 if (this->fPTmasks->fTLMU[i] && partResults[2][i + 1]) {
248 AliDebug(4, Form("CBB TRD Wake up result = %d", result[nLUTs + 1]));
250 delete [] partResults;
256 //______________________________________________________________________________
257 Bool_t AliTRDptrgCBB::GetPT() {
258 // evaluates the pre trigger decision
260 Int_t* LUTresults = this->Simulate();
261 if (LUTresults[(LUTresults[0] - 1)]) {