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 simulation //
22 // Authors: F. Reidt (Felix.Reidt@cern.ch) //
24 ////////////////////////////////////////////////////////////////////////////
29 #include "TClonesArray.h"
32 #include "AliRunLoader.h"
34 #include "AliTOFdigit.h"
35 #include "AliRawReader.h" // needed for AliTOFTrigger's raw digit support
36 #include "AliTOFTrigger.h"
38 #include "AliTRDptrgParam.h"
40 #include "AliTRDptrgTLMU.h"
43 ClassImp(AliTRDptrgTLMU)
45 //______________________________________________________________________________
46 AliTRDptrgTLMU::AliTRDptrgTLMU(AliRunLoader *rl)
50 fOperatingMode(kDigits),
58 for (Int_t i = 0; i < 18; i++) {
59 this->fTOFinputBits[i] = 0;
65 //______________________________________________________________________________
66 AliTRDptrgTLMU::AliTRDptrgTLMU(AliRunLoader *rl, AliTRDptrgParam *param,
67 AliTRDptrgOperatingMode_t operatingMode)
71 fOperatingMode(operatingMode),
79 for (Int_t i = 0; i < 18; i++) {
80 this->fTOFinputBits[i] = 0;
86 //______________________________________________________________________________
87 AliTRDptrgTLMU::~AliTRDptrgTLMU()
91 this->fCMatrices = 0x0;
92 this->fMultiplicity = 0x0;
96 //______________________________________________________________________________
97 Int_t* AliTRDptrgTLMU::Simulate()
99 // starts a simulation
101 if (this->fOperatingMode == kDigits) {
104 else if (this->fOperatingMode == kHits) {
108 // which super modules are active? - needed for fast coincidence processing:
109 // M(sm | coincidence condition)>=2
112 for (Int_t iSM = 0; iSM < 18; iSM++) {
118 AliDebug(4, Form("Active supermodules: 0x%x", sm));
121 UInt_t multiplicity = this->GetMultiplicitySum();
122 AliDebug(4, Form("TOF/TLMU multiplicity: %d", multiplicity));
124 Int_t* result = new Int_t[9];
126 for (Int_t iResult = 0; iResult < 8; iResult++) {
127 result[iResult + 1] = 0;
129 // coincidence matrix
130 if (this->fOutput[iResult][0] != -1) {
131 for (Int_t iLine = 0; iLine < 18; iLine++) {
132 AliDebug(5, Form("Entry: %d, matrix: %d, line: %d, output: 0x%x",
133 iResult, this->fOutput[iResult][0], iLine, sm &
134 this->fCMatrices[this->fOutput[iResult][0]][iLine]));
135 if (this->GetBitVectorMultiplicity(
136 sm & this->fCMatrices[this->fOutput[iResult][0]][iLine]) > 1) {
137 result[iResult + 1] = 1;
143 // multiplicity conditions
144 if (this->fOutput[iResult][1] != -1) {
145 AliDebug(5, Form("Entry: %d, slice: %d", iResult,
146 this->fOutput[iResult][1]));
147 if ((this->fMultiplicity[this->fOutput[iResult][1]][0] < multiplicity) &&
148 (this->fMultiplicity[this->fOutput[iResult][1]][1] >= multiplicity)) {
149 result[iResult + 1] = 1;
152 AliDebug(4, Form("TLMU result[%d] = %d", iResult, result[iResult + 1]));
158 //______________________________________________________________________________
159 Int_t AliTRDptrgTLMU::LoadDigits()
161 // loads Digits (for usage with aquired data)
162 this->GetInputBits(); // get bits from AliTOFTrigger
167 //______________________________________________________________________________
168 Bool_t AliTRDptrgTLMU::LoadParams()
170 // load AliTRDprtgParam content
172 if (this->fParam == 0x0) {
173 // no parameter object assigned
174 AliWarning("no parameter object assigned - using default settings!");
177 imask = new UInt_t[18];
178 for (Int_t i = 0; i < 18; i++) {
179 imask[i] = 0xFFFFFFFF;
182 this->fInputMask = imask;
184 // TLMU Coincidence Matrices
185 this->fCMatrices = new UInt_t*[3];
186 this->fCMatrices[0] = new UInt_t[18];
187 this->fCMatrices[1] = new UInt_t[18];
188 this->fCMatrices[2] = new UInt_t[18];
190 // Matrix 0: Back-To-Back
191 // Matrix 1: Back-To-Back +/-1
192 // Matrix 2: Back-To-Back +/-2
193 for (UInt_t iMatrix = 0; iMatrix < 3; iMatrix++) {
194 for (UInt_t iSlice = 0; iSlice < 18; iSlice++) {
197 this->fCMatrices[iMatrix][iSlice] = 0x201 << iSlice;
199 AliDebug(5, Form("fCMatrices[%d][%d]=0x%x",iMatrix,iSlice,
200 this->fCMatrices[iMatrix][iSlice]));
202 // because of symmetrie the other slices are not necessary
204 else if (iMatrix == 1) {
205 // Back-To-Back +/- 1
207 this->fCMatrices[iMatrix][iSlice] = 0x381 << iSlice;
209 else if (iSlice == 8) {
210 this->fCMatrices[iMatrix][iSlice] = 0x30101;
212 else if (iSlice == 9) {
213 this->fCMatrices[iMatrix][iSlice] = 0x20203;
216 this->fCMatrices[iMatrix][iSlice] = 0x407 << (iSlice - 10);
218 AliDebug(5, Form("fCMatrices[%d][%d]=0x%x",iMatrix,iSlice,
219 this->fCMatrices[iMatrix][iSlice]));
221 else if (iMatrix == 2) {
224 this->fCMatrices[iMatrix][iSlice] = 0xF81 << iSlice;
226 else if (iSlice == 7) {
227 this->fCMatrices[iMatrix][iSlice] = 0x3C081;
229 else if (iSlice == 8) {
230 this->fCMatrices[iMatrix][iSlice] = 0x38103;
232 else if (iSlice == 9) {
233 this->fCMatrices[iMatrix][iSlice] = 0x30207;
235 else if (iSlice == 10) {
236 this->fCMatrices[iMatrix][iSlice] = 0x2040F;
239 this->fCMatrices[iMatrix][iSlice] = 0x81F << (iSlice - 11);
241 AliDebug(5, Form("fCMatrices[%d][%d]=0x%x",iMatrix,iSlice,
242 this->fCMatrices[iMatrix][iSlice]));
248 this->fMultiplicity = new UInt_t*[9];
249 for (Int_t i = 0; i < 9; i++) {
250 this->fMultiplicity[i] = new UInt_t[2];
252 this->fMultiplicity[0][0] = 0;
253 this->fMultiplicity[0][1] = 10;
254 this->fMultiplicity[1][0] = 10;
255 this->fMultiplicity[1][1] = 25;
256 this->fMultiplicity[2][0] = 25;
257 this->fMultiplicity[2][1] = 50;
258 this->fMultiplicity[3][0] = 50;
259 this->fMultiplicity[3][1] = 100;
260 this->fMultiplicity[4][0] = 100;
261 this->fMultiplicity[4][1] = 200;
262 this->fMultiplicity[5][0] = 200;
263 this->fMultiplicity[5][1] = 350;
264 this->fMultiplicity[6][0] = 350;
265 this->fMultiplicity[6][1] = 400;
266 this->fMultiplicity[7][0] = 400;
267 this->fMultiplicity[7][1] = 576;
268 this->fMultiplicity[8][0] = 100;
269 this->fMultiplicity[8][1] = 576;
272 this->fOutput = new Int_t*[8];
273 for (Int_t i = 0; i < 9; i++) {
274 this->fOutput[i] = new Int_t[2];
275 this->fOutput[i][0] = -1;
276 this->fOutput[i][1] = -1;
278 this->fOutput[0][0] = 0;
279 this->fOutput[1][0] = 1;
280 this->fOutput[2][0] = 2;
281 this->fOutput[3][1] = 0;
282 this->fOutput[4][1] = 1;
283 this->fOutput[5][1] = 2;
284 this->fOutput[6][1] = 3;
285 this->fOutput[7][1] = 8;
290 // parameter object assigned
292 this->fInputMask = this->fParam->GetTLMUInputMask();
293 // input mask for TOF-bits (18x32=576)
295 this->fCMatrices = this->fParam->GetTLMUcmatrices();
296 // get coincidence matrices
298 this->fMultiplicity = this->fParam->GetTLMUmultiplicity();
299 // get multiplicity slices
301 this->fOutput = this->fParam->GetTLMUoutput();
302 // get output signal assignment
308 //______________________________________________________________________________
309 void AliTRDptrgTLMU::GetInputBits() {
310 // Gets TOF-to-TRD input bits from AliTOFTrigger as Bool_t array
312 AliTOFTrigger *toftrig = new AliTOFTrigger(); // create AliTOFTrigger
313 toftrig->CreateLTMMatrixFromDigits(); // Generate LTMMatrix from AliTOFdigits
317 map = new Bool_t*[72];
318 for (Int_t i=0; i < 72; i++)
319 map[i] = new Bool_t[8];
322 for (Int_t i=0; i < 72; i++)
323 for (Int_t j=0; j < 8; j++)
326 // get 576 TOF-to-TRD bits
327 toftrig->GetTRDmap(map);
330 // used to determine the correct bit assignment
331 AliDebug(5, "AliTOFTrigger->GetTRDmap(map):");
332 for (Int_t i=0; i < 72; i++) {
333 AliDebug(5, Form("%d %d%d%d%d%d%d%d%d", i, map[i][0], map[i][1], map[i][2],
334 map[i][3], map[i][4], map[i][5], map[i][6], map[i][7]));
336 //*/ // end of DEBUG output
338 // initialise fTOFinputBits
339 for (Int_t i=0; i < 18; i++) {
340 this->fTOFinputBits[i] = 0;
344 // transform Bool_t array to UInt_t bitvectors according to
345 // http://www.physi.uni-heidelberg.de/~schicker/cbtof/cbtof_docu.pdf
346 // chapter 1.4 and 2.1 to a supermodule based structured
347 // integer (bit) array
348 Int_t supermodule = -1;
349 UInt_t tempA = 0x00000001;
350 UInt_t tempC = 0x00010000;
351 for (Int_t iLTM = 0; iLTM < (kNLTM / 2); iLTM++) {
352 if (!(iLTM % 2)) { // renew temp vectors, update supermodule
357 // AliDebug(5, Form("(%2d,0x%8x,0x%8x)", iLTM, tempA, tempC));
358 for (Int_t iLTMchan = 0; iLTMchan < 8; iLTMchan++) {
360 if (map[iLTM][iLTMchan]) {
361 this->fTOFinputBits[supermodule] |= tempA;
364 if (map[iLTM + 36][iLTMchan]) {
365 this->fTOFinputBits[supermodule] |= tempC;
367 // change temp vectors
374 for (Int_t iSM = 0; iSM < 18; iSM++) {
375 AliDebug(5, Form("fInputTOFinputBits[%d]=0x%x", iSM,
376 this->fTOFinputBits[iSM]));
377 this->fTOFinputBits[iSM] &= this->fInputMask[iSM];
382 //______________________________________________________________________________
383 Int_t AliTRDptrgTLMU::BackToBack(Int_t iSM, Int_t range) {
384 // Check whether there is an back-to-back particle trace
386 // get the counterpart of supermodule iSM
387 Int_t counterPart = -1;
389 counterPart = iSM - 9;
392 counterPart = iSM + 9;
395 if (this->Or(iSM)) { // is there are active bits in supermodule iSM
397 for (Int_t i = counterPart - range; i <= counterPart + range; i++) {
398 // check whether there are active bits in supermodule i (counterParts)
399 if ((i >= 0) && (i < 18)) {
417 AliDebug(5, Form("BackToBack of %d and %d+-%d\n: %d", iSM, counterPart,
419 return result; // return whether there was a possible back-to-back trace
422 AliDebug(5, Form("BackToBack unsuccessful, not hit in sm%d", iSM));
423 return 0; // iSM did not recognize anything
427 //______________________________________________________________________________
428 Int_t AliTRDptrgTLMU::Coincidence(Int_t iSM1, Int_t iSM2) {
429 // checks whether there is an coincidence in iSM1 and iSM2
431 if (this->Or(iSM1) && this->Or(iSM2)) {
438 //______________________________________________________________________________
439 inline Int_t AliTRDptrgTLMU::Or(Int_t iSM) {
440 // returns 1 if one or more bits are active in supermodule iSM
442 if ((iSM >= 0) && (iSM < 18)) {
443 if (this->fTOFinputBits[iSM] > 0)
453 //______________________________________________________________________________
454 Int_t AliTRDptrgTLMU::GetMultiplicity(Int_t iSM) {
455 // counts how many bits equal one are in class member fTOFinputBits[iSM]
456 // (32bits from TOF to TRD of supermodule iSM)
458 UInt_t temp = this->fTOFinputBits[iSM];
460 Int_t multiplicity = 0;
462 for (int iBit = 0; iBit < 32; iBit++) {
463 if ((mask & temp) != 0x0) { // is the bit equal one?
466 mask <<= 1; // rotate mask to the left after each iteration
468 AliDebug(5, Form("Multiplicity of supermodule %d: %d", iSM, multiplicity));
472 //______________________________________________________________________________
473 Int_t AliTRDptrgTLMU::GetMultiplicitySum() {
474 // returns the multiplicity of the whole detector (all 576bit TOF to TRD bits)
477 for (Int_t i = 0; i < 18; i++) {
478 sum += this->GetMultiplicity(i);
480 AliDebug(5, Form("Whole multiplicity: %d", sum));
484 //______________________________________________________________________________
485 UInt_t AliTRDptrgTLMU::GetBitVectorMultiplicity(UInt_t BitVector) {
486 // returns the multiplicity of a given bit vector
490 for (UInt_t iBit = 0; iBit < 32; iBit++) {
491 if (BitVector & temp) {