]>
Commit | Line | Data |
---|---|---|
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 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 | ClassImp(AliTRDptrgLUT) | |
47 | //_____________________________________________________________________________ | |
48 | AliTRDptrgLUT::AliTRDptrgLUT() | |
49 | : TObject(), | |
50 | fLUTData(0), | |
51 | fInputWidth(0), | |
52 | fOutputWidth(0), | |
53 | fTableEntryCount(0), | |
54 | fCopiedTable(kFALSE) | |
55 | { | |
56 | // ctor | |
57 | } | |
58 | ||
59 | //_____________________________________________________________________________ | |
60 | AliTRDptrgLUT::~AliTRDptrgLUT() | |
61 | { | |
62 | // destructor | |
63 | if (this->fCopiedTable) { | |
64 | AliDebug(5, "Deleted LUT data"); | |
65 | if (this->fLUTData != 0x0) { | |
66 | delete[] this->fLUTData; | |
67 | } | |
68 | this->fLUTData = 0x0; | |
69 | } | |
70 | } | |
71 | ||
72 | //_____________________________________________________________________________ | |
73 | Int_t AliTRDptrgLUT::LookUp(UInt_t input) | |
74 | { | |
75 | // perform a look up | |
76 | ||
77 | if (input > (UInt_t)this->fTableEntryCount) { | |
78 | // check whether the input value is out of bounds | |
79 | AliWarning("incorrect LUT input value"); | |
80 | return -1; | |
81 | } | |
82 | return this->fLUTData[input]; // do look up and output | |
83 | } | |
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 | this->fInputWidth = inputWidth; | |
93 | this->fOutputWidth = outputWidth; | |
94 | ||
95 | // calculated table entry count | |
96 | this->fTableEntryCount = 0x1; | |
97 | this->fTableEntryCount <<= inputWidth; | |
98 | AliDebug(5,Form("fTableEntryCount=%d", this->fTableEntryCount)); | |
99 | ||
100 | this->fCopiedTable = copy; | |
101 | ||
102 | if (copy) { | |
103 | this->fLUTData = new Int_t[this->fTableEntryCount]; // allocate data table | |
104 | for (Int_t i=0; i < this->fTableEntryCount; i++) { | |
105 | this->fLUTData[i] = tableData[i]; | |
106 | } | |
107 | } | |
108 | else { // do not copy (due to performace reasons) | |
109 | this->fLUTData = tableData; | |
110 | } | |
111 | return 0; | |
112 | } | |
113 |