]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TRD/AliTRDptrgCBB.cxx
Added macros for production using Geant4. 3 different physics lists can be used:...
[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);
7788992c 116 // get CB-B_1 and do not copy lut content
117 this->fLUTArray.AddLast(LUT);
118
119 // 2
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
f9720615 123 this->fLUTArray.AddLast(LUT);
124
125 // masks
126 this->fPTmasks = this->fParam->GetPTmasks();
127 }
128 else {
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);
7788992c 135 LUT = new AliTRDptrgLUT(); // this->fRunLoader
136 this->fLUTArray.AddLast(LUT);
f9720615 137 // the following lines are only needed for test reasons
138 LUT = dynamic_cast<AliTRDptrgLUT*>(this->fLUTArray.At(0));
139 Int_t* initData = new Int_t[4096]; // 2^12
140 for (Int_t i = 0; i < 4096; i++ ) {
141 initData[i] = i;
142 }
143 LUT->InitTable(12, 12, initData, kTRUE); // make a copy
7788992c 144 LUT = dynamic_cast<AliTRDptrgLUT*>(this->fLUTArray.At(0));
145 for (Int_t i = 0; i < 4096; i++ ) {
146 initData[i] = i;
147 }
148 LUT->InitTable(12, 12, initData, kTRUE); // make a copy
f9720615 149 LUT = dynamic_cast<AliTRDptrgLUT*>(this->fLUTArray.At(1));
150 for (Int_t i = 4096; i >= 0; i--) {
151 initData[4096 - i] = i; // inverse ramp
152 }
153 LUT->InitTable(12, 12, initData, kTRUE); // make a copy
154
155 AliTRDptrgParam::AliTRDptrgPTmasks* masks =
156 new AliTRDptrgParam::AliTRDptrgPTmasks();
157 masks->fLUTs[0] = kTRUE;
158 masks->fLUTs[1] = kTRUE;
7788992c 159 masks->fLUTs[2] = kTRUE;
f9720615 160 this->fPTmasks = masks;
161 }
162 return false;
163}
164
165//______________________________________________________________________________
166Int_t* AliTRDptrgCBB::Simulate()
167{
168 // Simulate the CBB behavior of event
169 //
170 // returns array containing:
171 // 0: array element count
172 // 1..count-2: LUT results
173 // count-1: pretrigger decision
174
175 Int_t nLUTs = this->fLUTArray.GetEntries();
176
177 Int_t inputVector = 0x0;
178 // initialize partResults
179 Int_t** partResults = 0x0;
180 partResults = new Int_t* [3]; // CB-A, CB-C, TLMU
181
182 // get partResults
183 partResults[0] = this->fCBA->Simulate(); // CB-A
184 partResults[1] = this->fCBC->Simulate(); // CB-C
185 partResults[2] = this->fTLMU->Simulate(); // TLMU
186
187
188 // combine partResults and create inputVectors
f9720615 189 Int_t mask = 0x1;
190 for (Int_t i = 0; i < 3 ; i++) {
191 for (Int_t j = 1; j <= partResults[i][0]; j++) {
192 if (partResults[i][j] > 0) {
193 inputVector |= mask; // Add bit to the inputVector
194 }
195 mask <<= 1;
196 }
197 }
198
199 AliDebug(5, Form("Inputvectors: 0x%x", inputVector));
200
201 // perform look up
202 Int_t* result = new Int_t[nLUTs + 2]; // generate new return array
203 result[0] = nLUTs + 1; // storage array length in the first array value
204 for (Int_t iLUT = 0; iLUT < nLUTs; iLUT++) {
205 // process the return value for each LUT and store the result in the array
206 result[iLUT + 1] =
207 dynamic_cast<AliTRDptrgLUT*>(this->fLUTArray[iLUT])->LookUp(inputVector);
208 AliDebug(4, Form("CBB result[%d] = 0x%x\n",(iLUT + 1),result[iLUT + 1]));
209 }
210
211 // evaluate PT decision
212 // stored in result[nLUTs + 1]
213 result[nLUTs + 1] = 0;
214
215 for (Int_t i = 0; i < 2; i++) {
216 // CB-A
217 if (this->fPTmasks->fCBA[i] && partResults[0][i + 1]) {
218 result[nLUTs + 1]++;
219 }
220 // CB-C
221 if (this->fPTmasks->fCBC[i] && partResults[1][i + 1]) {
222 result[nLUTs + 1]++;
223 }
224 // CB-B (own LUTs)
225 if (this->fPTmasks->fLUTs[i] && result[i + 1]) {
226 result[nLUTs + 1]++;
227 }
228 }
7788992c 229 if (this->fPTmasks->fLUTs[2] && result[3]) { // CB-B (third own LUT)
230 result[nLUTs + 1]++;
231 }
232
f9720615 233 // TLMU
234 for (Int_t i = 0; i < 8; i++) {
235 if (this->fPTmasks->fTLMU[i] && partResults[2][i + 1]) {
236 result[nLUTs + 1]++;
237 }
238 }
239 AliDebug(4, Form("CBB TRD Wake up result = %d", result[nLUTs + 1]));
240 return result;
241}
242
243//______________________________________________________________________________
244Bool_t AliTRDptrgCBB::GetPT() {
245 // evaluates the pre trigger decision
246
247 Int_t* LUTresults = this->Simulate();
248 if (LUTresults[(LUTresults[0] - 1)]) {
249 delete[] LUTresults;
250 return kTRUE;
251 }
252 else {
253 delete[] LUTresults;
254 return kFALSE;
255 }
256}