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_0 and do not copy lut content
117 this->fLUTArray.AddLast(LUT);
120 this->fPTmasks = this->fParam->GetPTmasks();
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++ ) {
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
140 LUT->InitTable(12, 12, initData, kTRUE); // make a copy
142 AliTRDptrgParam::AliTRDptrgPTmasks* masks =
143 new AliTRDptrgParam::AliTRDptrgPTmasks();
144 masks->fLUTs[0] = kTRUE;
145 masks->fLUTs[1] = kTRUE;
146 this->fPTmasks = masks;
151 //______________________________________________________________________________
152 Int_t* AliTRDptrgCBB::Simulate()
154 // Simulate the CBB behavior of event
156 // returns array containing:
157 // 0: array element count
158 // 1..count-2: LUT results
159 // count-1: pretrigger decision
161 Int_t nLUTs = this->fLUTArray.GetEntries();
163 Int_t inputVector = 0x0;
164 // initialize partResults
165 Int_t** partResults = 0x0;
166 partResults = new Int_t* [3]; // CB-A, CB-C, TLMU
169 partResults[0] = this->fCBA->Simulate(); // CB-A
170 partResults[1] = this->fCBC->Simulate(); // CB-C
171 partResults[2] = this->fTLMU->Simulate(); // TLMU
174 // combine partResults and create inputVectors
176 for (Int_t i = 0; i < 3 ; i++) {
177 for (Int_t j = 1; j <= partResults[i][0]; j++) {
178 if (partResults[i][j] > 0) {
179 inputVector |= mask; // Add bit to the inputVector
185 AliDebug(5, Form("Inputvectors: 0x%x", inputVector));
188 Int_t* result = new Int_t[nLUTs + 2]; // generate new return array
189 result[0] = nLUTs + 1; // storage array length in the first array value
190 for (Int_t iLUT = 0; iLUT < nLUTs; iLUT++) {
191 // process the return value for each LUT and store the result in the array
193 dynamic_cast<AliTRDptrgLUT*>(this->fLUTArray[iLUT])->LookUp(inputVector);
194 AliDebug(4, Form("CBB result[%d] = 0x%x\n",(iLUT + 1),result[iLUT + 1]));
197 // evaluate PT decision
198 // stored in result[nLUTs + 1]
199 result[nLUTs + 1] = 0;
201 for (Int_t i = 0; i < 2; i++) {
203 if (this->fPTmasks->fCBA[i] && partResults[0][i + 1]) {
207 if (this->fPTmasks->fCBC[i] && partResults[1][i + 1]) {
211 if (this->fPTmasks->fLUTs[i] && result[i + 1]) {
216 for (Int_t i = 0; i < 8; i++) {
217 if (this->fPTmasks->fTLMU[i] && partResults[2][i + 1]) {
221 AliDebug(4, Form("CBB TRD Wake up result = %d", result[nLUTs + 1]));
225 //______________________________________________________________________________
226 Bool_t AliTRDptrgCBB::GetPT() {
227 // evaluates the pre trigger decision
229 Int_t* LUTresults = this->Simulate();
230 if (LUTresults[(LUTresults[0] - 1)]) {