Line data Source code
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 simulation
21 : //
22 : // Authors: F. Reidt (Felix.Reidt@cern.ch)
23 : //
24 : //
25 : // Limitations: input/output width: 32 bits (UInt_t)
26 : //
27 : // Annotation: That LUT is usually used to provide a single output bit
28 : // In that case every output value bigger 0 means true
29 : //
30 : ////////////////////////////////////////////////////////////////////////////////
31 :
32 : #include <stdio.h>
33 : #include <fstream>
34 : #include <string>
35 : #include <math.h>
36 :
37 : #include "TFile.h"
38 : #include "TROOT.h"
39 :
40 : #include "AliRun.h"
41 : #include "AliRunLoader.h"
42 : #include "AliLog.h"
43 :
44 : #include "AliTRDptrgLUT.h"
45 :
46 12 : ClassImp(AliTRDptrgLUT)
47 : //_____________________________________________________________________________
48 : AliTRDptrgLUT::AliTRDptrgLUT()
49 108 : : TObject(),
50 108 : fLUTData(0),
51 108 : fInputWidth(0),
52 108 : fOutputWidth(0),
53 108 : fTableEntryCount(0),
54 108 : fCopiedTable(kFALSE)
55 540 : {
56 : // ctor
57 216 : }
58 :
59 : //_____________________________________________________________________________
60 : AliTRDptrgLUT::~AliTRDptrgLUT()
61 648 : {
62 : // destructor
63 108 : if (this->fCopiedTable) {
64 0 : AliDebug(5, "Deleted LUT data");
65 0 : if (this->fLUTData != 0x0) {
66 0 : delete[] this->fLUTData;
67 : }
68 0 : this->fLUTData = 0x0;
69 0 : }
70 324 : }
71 :
72 : //_____________________________________________________________________________
73 : Int_t AliTRDptrgLUT::LookUp(UInt_t input)
74 : {
75 : // perform a look up
76 :
77 216 : if (input > (UInt_t)this->fTableEntryCount) {
78 : // check whether the input value is out of bounds
79 0 : AliWarning("incorrect LUT input value");
80 0 : return -1;
81 : }
82 108 : return this->fLUTData[input]; // do look up and output
83 108 : }
84 :
85 : //______________________________________________________________________________
86 : Int_t AliTRDptrgLUT::InitTable(Int_t inputWidth, Int_t outputWidth,
87 : Int_t *tableData, Bool_t copy)
88 : {
89 : // load and initialize the look up table
90 :
91 : // assign width
92 108 : this->fInputWidth = inputWidth;
93 108 : this->fOutputWidth = outputWidth;
94 :
95 : // calculated table entry count
96 108 : this->fTableEntryCount = 0x1;
97 108 : this->fTableEntryCount <<= inputWidth;
98 324 : AliDebug(5,Form("fTableEntryCount=%d", this->fTableEntryCount));
99 :
100 108 : this->fCopiedTable = copy;
101 :
102 108 : if (copy) {
103 0 : this->fLUTData = new Int_t[this->fTableEntryCount]; // allocate data table
104 0 : for (Int_t i=0; i < this->fTableEntryCount; i++) {
105 0 : this->fLUTData[i] = tableData[i];
106 : }
107 0 : }
108 : else { // do not copy (due to performace reasons)
109 108 : this->fLUTData = tableData;
110 : }
111 108 : return 0;
112 : }
113 :
|