]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TRD/AliTRDptrgParam.h
Removing man-in-the-middle class
[u/mrichter/AliRoot.git] / TRD / AliTRDptrgParam.h
1 #ifndef ALITRDPTRGPARAM_H
2 #define ALITRDPTRGPARAM_H
3 /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4  * See cxx source for full Copyright notice                               */
5
6 /* $Id$ */
7
8 // --------------------------------------------------------
9 // 
10 // Singleton class to hold the parameters steering the PTRG 
11 // 
12 // --------------------------------------------------------
13 #include "TObject.h"
14
15   enum AliTRDptrgFEBType_t{ kUndefined = (Int_t)0, 
16                             kTZERO = (Int_t)1, 
17                             kVZERO = (Int_t)2 };
18   enum AliTRDptrgOperatingMode_t{ kHits = (Int_t)0, kDigits = (Int_t)1 };
19   enum AliTRDptrgFEBPosition_t{ kB = (Int_t)0, 
20                                 kA = (Int_t)1, 
21                                 kC = (Int_t)2,
22                                 kUnknown = (Int_t)3 };
23
24
25 class AliTRDptrgParam : public TObject {
26  public:
27   struct AliTRDptrgPTmasks {
28     Bool_t fCBA[2]; // contribute CB-A look up results to pretrigger decision?
29     Bool_t fCBC[2]; // contribute CB-C look up results to pretrigger decision?
30     Bool_t fLUTs[2]; // CB-B look up results contribution to pretrigger decision
31     Bool_t fTLMU[8]; // TLMU output signal contribution to pretrigger decisions
32
33     AliTRDptrgPTmasks() {
34       fCBA[0] = kFALSE;
35       fCBA[1] = kFALSE;
36       fCBC[0] = kFALSE;
37       fCBC[1] = kFALSE;
38       fLUTs[0] = kFALSE;
39       fLUTs[1] = kFALSE;
40       for (Int_t i = 0; i < 8; i++) {
41         fTLMU[i] = kFALSE;
42       } 
43     }
44   };
45   virtual ~AliTRDptrgParam();
46
47   static AliTRDptrgParam *Instance(); // Singleton
48   static void Terminate();  // delete Singleton
49   
50   void LoadStandardConfiguration(); // initialize with standard values
51   Bool_t LoadConfigurationFromFile(TString filename); // load file 
52   
53   Int_t GenerateLUTs(); // generates all LUTs
54
55   // --- GETTER FUNCTIONS -----------------------------------------------------
56   // -- TLMU --
57   const UInt_t* GetTLMUInputMask() const { return this->fTLMUInputMask; };
58   // get TLMU input mask
59    
60   UInt_t** GetTLMUcmatrices() const { return this->fTLMUcmatrices; };
61   // get TLMU coincidence matrices
62   
63   UInt_t** GetTLMUmultiplicity() const { return this->fTLMUmultiplicity; };
64   // get TLMU multiplicity slices
65
66   Int_t** GetTLMUoutput() const { return this->fTLMUoutput; };
67   // get TLMU output mux configuration
68
69   // -- T0 --
70   UInt_t* GetFEBT0Thresholds(AliTRDptrgFEBPosition_t FEBposition) const;
71   // get T0 FEB Thresholds
72
73   Int_t* GetFEBT0LUT(AliTRDptrgFEBPosition_t FEBposition, Int_t iLUT); 
74   // get T0 FEB LUTs
75  
76   // -- V0 --
77   UInt_t* GetFEBV0Thresholds(AliTRDptrgFEBPosition_t FEBposition, Int_t iCard) const;
78   // get V0 FEB Thresholds
79
80   Int_t* GetFEBV0LUT(AliTRDptrgFEBPosition_t FEBposition, Int_t iCard, 
81                      Int_t iLUT);
82   // get V0 FEB LUTs
83
84   Int_t* GetCBLUT(UInt_t CB, Int_t LUTid);
85   // returns the corresponding LUT (control boxes only)
86
87   const AliTRDptrgPTmasks* GetPTmasks() const { return &fPTmasks; };
88   // returns the list containing the information which CB-B inputs are masked
89   // out or forwarded as pre trigger output to the CTP
90
91
92   Int_t CheckVariables() const; // returns -1 if a variable is already deleted
93
94  protected:
95   UInt_t GetMultiplicity(UInt_t BitVector) const; 
96   // returns the multiplicity ('1's) 
97   
98   UInt_t GetMultiplicity(Int_t BitVector) const;  
99   // returns the multiplicity ('1's)
100
101   // helper functions for configuration file reading
102   // -----------------------------------------------
103   Bool_t ParseTLMU(TString identifier, TString value);
104   // parses the TLMU configuration parameters
105
106   Bool_t ParseCBB(TString identifier, TString value);
107   // parses the CBB configuration parameters
108   
109   Bool_t ParseCBAC(TString identifier, TString value);
110   // parses the CB-A and CB-C configuration parameters
111
112   Bool_t ParseFEB(TString identifier, TString value);
113   // parses the FEB configuration parameters
114
115   Bool_t ParseMultiplicityCondition(TString condition, UInt_t* threshold,
116                                     UInt_t* mask);
117   // parses a multiplicity condition "M(#mask#)>#threshold#"
118
119   UInt_t BinaryTStringToInt(TString number) const;
120   // converts TString containing a binary number to a unsigned integer
121
122   void SplitUpValues(TString value, TObjArray& arr);
123   // splits a value string which contains multiple values seperated by ' ' 
124   // and '\t'
125
126   TString CleanTString(TString string);
127   // removes ' ' and '\t' in a TString
128
129   void PrepareLine(TString line, TString& identifier, TString& value);
130   // divides identifier and value (seperator is the first ' ' or '\t'  
131
132   
133   // (helper) functions for conversion of logical equations into LUTs 
134   // ----------------------------------------------------------------
135   Int_t LookUp(TString* const identifier) const; // translates an identifier used in a
136   // logical equation into an address bit of the corresponding LUT
137   
138   void MergeResults(TArrayI*& partResult1, TArrayI*& partResult2, 
139                     TArrayI*& results, TArrayI*& signalsInvolved1, 
140                     TArrayI*& signalsInvolved2, TArrayI*& signalsInvolved,
141                     Bool_t useOR);
142   // merges the results of to logical equation parts
143   
144   void ConvertLogicalEqToBitVectors(TString eq, TArrayI*& results,
145                                     TArrayI*& signalsInvolved);
146   // converts logical equations to bit vectors
147   // neglected input signals are for now assumed to be 0!
148   
149   void CheckSignalsInvolved(TArrayI*& results, TArrayI*& signalsInvolved,
150                             Int_t inputWidth);
151   // adds all signal combinations needed to behave correctly in every state of
152   // neglected signals
153   
154   Int_t* GenerateLUTbasedOnEq(TString eq, Int_t inputWidth, Int_t initValue);
155   // generates a lut based on a logical functions (uses the functions above)
156
157   static AliTRDptrgParam *fgInstance; // instance pointer
158
159   // TLMU configuration --------------------------------------------------------
160   UInt_t fTLMUInputMask[18]; // masks TOF-to-TRD bits
161   UInt_t fTLMUInputStretch; // designates how long TLMU input is stretched   
162   UInt_t** fTLMUcmatrices; // [matrix][section] unsigned int values
163   // Bits 0..17 identify supermodules, bits equal 1 are checked for coincidence
164
165   UInt_t** fTLMUmultiplicity; // [slice][0 = lower bound, 1 = upper bound]
166   // use a lower bound above 576 to disable
167   
168   Int_t** fTLMUoutput; // [output][0 = cmatrix, 1 = multslice] 
169   // output bit assignment, -1 disables
170
171   // T0 ------------------------------------------------------------------------
172   // [position][channel] 12 channels at A and C side
173   UInt_t** fFEBT0Thresholds; // threshold for analog value discrimination
174   
175   // [position][LUT][0 = threshold, 1 = bitmask] 2 LUTs at A and C side  
176   UInt_t*** fFEBT0Multiplicities; // multiplicity threshold for T0
177   Int_t*** fFEBT0LUTs; // look up tables [position][LUT][entry]
178     
179   // V0 ------------------------------------------------------------------------
180   // [position][feb][channel] 4x8 channels per side (A and C)
181   UInt_t*** fFEBV0Thresholds; // threshold for analog value discrimation
182
183   // [position][feb][LUT][0 = threshold, 1 = bitmask] 2 LUTs per FEB 
184   // (4 per Side) at each side ( A and C)
185   UInt_t**** fFEBV0Multiplicities; // multiplicity threshold for V0   
186   Int_t**** fFEBV0LUTs; // look up tables [position][feb][LUT][entry] 
187
188   // CB-{A/B/C}
189   // 0 = B, 1 = A, 2 = C
190   Int_t*** fCBLUTs; // control box look up tables
191
192   // CB-A ----------------------------------------------------------------------
193   TString fCBALUTequX; // logical equation used for generation of LUT X of CB-A
194   TString fCBALUTequY; // logical equation used for generation of LUT Y of CB-A
195
196   // CB-C ----------------------------------------------------------------------
197   TString fCBCLUTequX; // logical equation used for generation of LUT X of CB-C
198   TString fCBCLUTequY; // logical equation used for generation of LUT Y of CB-C
199
200   // CBB -----------------------------------------------------------------------
201   TString fCBBLUTequX; // logical equation used for generation of LUT X of CB-B 
202   TString fCBBLUTequY; // logical equation used for generation of LUT Y of CB-B
203
204   // CTP -----------------------------------------------------------------------
205   // PT mask
206   AliTRDptrgPTmasks fPTmasks; 
207   // masks usage of internal signals for the pretrigger wake up signal
208                               
209
210   // CBB-LUT to TriggerInput assignment
211   
212   // class state ---------------------------------------------------------------
213
214  private:
215   AliTRDptrgParam();                         // instance only via Instance()
216   AliTRDptrgParam(const AliTRDptrgParam &rhs); // not implemented
217   AliTRDptrgParam& operator=(const AliTRDptrgParam &rhs); // not implemented
218
219   ClassDef(AliTRDptrgParam, 1);
220 };
221 #endif