]>
Commit | Line | Data |
---|---|---|
6efe69e7 | 1 | #ifndef AliHLTMUONTRIGGERRECONSTRUCTOR_H |
2 | #define AliHLTMUONTRIGGERRECONSTRUCTOR_H | |
b39b98c8 | 3 | /* This file is property of and copyright by the ALICE HLT Project * |
4 | * ALICE Experiment at CERN, All rights reserved. * | |
5 | * See cxx source for full Copyright notice */ | |
6efe69e7 | 6 | |
1d8ae082 | 7 | // $Id$ |
6efe69e7 | 8 | |
9 | /********************************************************************** | |
10 | Created on : 16/05/2007 | |
11 | Purpose : This class is supposed to read the trigger DDL files and | |
12 | give the output AliHLTMUONTriggerRecordStruct | |
13 | Author : Indranil Das, HEP Division, SINP | |
14 | Email : indra.das@saha.ac.in | indra.ehep@gmail.com | |
b39b98c8 | 15 | |
16 | Artur Szostak <artursz@iafrica.com>: | |
17 | Completely reimplemented the lookup table to a simplified format. | |
6efe69e7 | 18 | **********************************************************************/ |
19 | ||
69c14678 | 20 | /// |
21 | /// @file AliHLTMUONTriggerReconstructor.h | |
22 | /// @author Indranil Das <indra.das@saha.ac.in>, | |
23 | /// Artur Szostak <artursz@iafrica.com> | |
24 | /// @date 16 May 2007 | |
25 | /// @brief Declaration of the AliHLTMUONTriggerReconstructor class for processing trigger DDL data. | |
26 | /// | |
27 | ||
227e7192 | 28 | #include "AliHLTLogging.h" |
c95cf30c | 29 | #include "AliHLTMUONDataTypes.h" |
69c14678 | 30 | #include "AliMUONTriggerDDLDecoder.h" |
31 | #include "AliMUONTriggerDDLDecoderEventHandler.h" | |
c95cf30c | 32 | |
a3d4b6ba | 33 | extern "C" struct AliHLTMUONRecHitStruct; |
c95cf30c | 34 | extern "C" struct AliHLTMUONTriggerRecordStruct; |
960d54ad | 35 | |
6efe69e7 | 36 | |
37 | class AliHLTMUONTriggerReconstructor : public AliHLTLogging | |
38 | { | |
80590aa1 | 39 | public: |
40 | ||
80590aa1 | 41 | AliHLTMUONTriggerReconstructor(); |
42 | virtual ~AliHLTMUONTriggerReconstructor(); | |
43 | ||
80590aa1 | 44 | bool Run( |
69c14678 | 45 | const AliHLTUInt8_t* rawData, |
80590aa1 | 46 | AliHLTUInt32_t rawDataSize, |
a5d4696f | 47 | bool scalarEvent, |
80590aa1 | 48 | AliHLTMUONTriggerRecordStruct* trigRecord, |
a3d4b6ba | 49 | AliHLTUInt32_t& nofTrigRec |
80590aa1 | 50 | ); |
51 | ||
69c14678 | 52 | /** |
53 | * Returns a pointer to the lookup table used to map between channel | |
54 | * addresses and geometrical strip positions. | |
55 | */ | |
56 | AliHLTMUONTriggerRecoLookupTable* LookupTableBuffer() { return fDecoder.GetHandler().LookupTableBuffer(); } | |
57 | ||
58 | /// Returns the size of the lookup table. | |
59 | size_t LookupTableSize() const { return fDecoder.GetHandler().LookupTableSize(); } | |
a5d4696f | 60 | |
61 | /// Returns true if the decoder is set to enable recovery logic if | |
62 | /// raw data errors are found. | |
63 | bool TryRecover() const { return fDecoder.TryRecover(); }; | |
64 | ||
65 | /// Sets if the decoder should enable the error recovery logic. | |
66 | void TryRecover(bool value); | |
406c5bc3 | 67 | |
68 | /** | |
69 | * Sets the DDL bit according to the DDL value given. | |
70 | * It is used to keep the trigger record IDs unique. | |
71 | */ | |
72 | void SetDDL(AliHLTInt32_t ddl) { fDecoder.GetHandler().SetDDL(ddl); } | |
73 | ||
a3d4b6ba | 74 | /** |
75 | * Returns true if the output buffer was overflowed in the last call to Run. | |
76 | */ | |
77 | bool OverflowedOutputBuffer() const { return fDecoder.GetHandler().OverflowedOutputBuffer(); } | |
78 | ||
79 | /** | |
80 | * Returns the flag specifying if we should suppress partial trigger records. | |
81 | * Partial triggers do not pass the 3/4'ths coincidence requirement. | |
82 | */ | |
83 | bool SuppressPartialTriggers() const { return fDecoder.GetHandler().SuppressPartialTriggers(); } | |
84 | ||
85 | /** | |
86 | * Sets the flag specifying if we should suppress partial trigger records. | |
87 | * Partial triggers do not pass the 3/4'ths coincidence requirement. | |
88 | */ | |
89 | void SuppressPartialTriggers(bool s) { fDecoder.GetHandler().SuppressPartialTriggers(s); } | |
90 | ||
91 | /** | |
92 | * Returns true if the crate ID as found in the regional header | |
93 | * will be used for lookups in the LUT, rather than the sequencial | |
94 | * index number of the header. | |
95 | */ | |
96 | bool UseCrateId() const { return fDecoder.GetHandler().UseCrateId(); } | |
97 | ||
98 | /** | |
99 | * Sets the flag indicating if the crate ID as found in the regional | |
100 | * header should be used for lookups in the LUT, rather than the | |
101 | * sequencial index number of the header. | |
102 | */ | |
103 | void UseCrateId(bool value) { fDecoder.GetHandler().UseCrateId(value); } | |
104 | ||
2b7af22a | 105 | /** |
106 | * Returns true if the local board ID as found in the local structure | |
107 | * will be used for lookups in the LUT, rather than the sequencial | |
108 | * index number of the structure. | |
109 | */ | |
110 | bool UseLocalId() const { return fDecoder.GetHandler().UseLocalId(); } | |
111 | ||
112 | /** | |
113 | * Sets the flag indicating if the local board ID as found in the local | |
114 | * structure should be used for lookups in the LUT, rather than the | |
115 | * sequencial index number of the structure. | |
116 | */ | |
117 | void UseLocalId(bool value) { fDecoder.GetHandler().UseLocalId(value); } | |
118 | ||
b39b98c8 | 119 | private: |
80590aa1 | 120 | |
69c14678 | 121 | class AliDecoderHandler : public AliMUONTriggerDDLDecoderEventHandler, public AliHLTLogging |
122 | { | |
123 | public: | |
124 | ||
125 | AliDecoderHandler(); | |
126 | ||
127 | /// Default destructor. | |
128 | virtual ~AliDecoderHandler() {} | |
129 | ||
130 | /// Returns a pointer to the lookup table. | |
131 | AliHLTMUONTriggerRecoLookupTable* LookupTableBuffer() { return &fLookupTable; } | |
132 | ||
133 | /// Returns the size of the lookup table. | |
134 | size_t LookupTableSize() const { return sizeof(fLookupTable); } | |
135 | ||
136 | /** | |
137 | * Returns the maximum number of trigger records that can be | |
138 | * written to the output buffer. | |
139 | */ | |
140 | AliHLTUInt32_t MaxOutputTrigRecs() const { return fMaxOutputTrigRecs; } | |
141 | ||
142 | /** | |
143 | * Sets the maximum number of trigger records that can be | |
144 | * written to the output buffer. | |
145 | */ | |
146 | void MaxOutputTrigRecs(AliHLTUInt32_t n) { fMaxOutputTrigRecs = n; } | |
147 | ||
148 | /** | |
149 | * Returns the number of reconstructed trigger records actually | |
150 | * stored in the output buffer. | |
151 | */ | |
152 | AliHLTUInt32_t OutputTrigRecsCount() const { return fOutputTrigRecsCount; } | |
153 | ||
154 | /** | |
155 | * Returns the pointer to the output buffer which stores reconstructed | |
156 | * trigger records. | |
157 | */ | |
158 | AliHLTMUONTriggerRecordStruct* OutputTrigRecs() const { return fOutputTrigRecs; } | |
159 | ||
160 | /** | |
161 | * Sets the pointer to the output buffer which stores reconstructed | |
162 | * trigger records. Also resets the number of trigger records stored. | |
163 | */ | |
164 | void OutputTrigRecs(AliHLTMUONTriggerRecordStruct* buf) | |
165 | { | |
166 | fOutputTrigRecs = buf; | |
167 | fOutputTrigRecsCount = 0; | |
168 | fOverflowed = false; | |
169 | } | |
170 | ||
171 | /** | |
172 | * Returns the flag specifying if we should suppress partial trigger records. | |
173 | */ | |
174 | bool SuppressPartialTriggers() const { return fSuppressPartialTriggers; } | |
175 | ||
176 | /** | |
177 | * Sets the flag specifying if we should suppress partial trigger records. | |
178 | */ | |
179 | void SuppressPartialTriggers(bool s) { fSuppressPartialTriggers = s; } | |
180 | ||
181 | /** | |
182 | * Returns true if the output buffer was overflowed. | |
183 | */ | |
184 | bool OverflowedOutputBuffer() const { return fOverflowed; } | |
185 | ||
a5d4696f | 186 | /** |
187 | * Returns true if the OnError handler method will only generate warning | |
188 | * messages and rather than error messages. | |
189 | */ | |
190 | bool WarnOnly() const { return fWarnOnly; } | |
191 | ||
192 | /** | |
193 | * Sets the flag indicating if the OnError method should only generate | |
194 | * warnings rather than error messages. | |
195 | */ | |
196 | void WarnOnly(bool value) { fWarnOnly = value; } | |
69c14678 | 197 | |
a3d4b6ba | 198 | /** |
199 | * Returns true if the crate ID as found in the regional header | |
200 | * will be used for lookups in the LUT, rather than the sequencial | |
201 | * index number of the header. | |
202 | */ | |
203 | bool UseCrateId() const { return fUseCrateId; } | |
204 | ||
205 | /** | |
206 | * Sets the flag indicating if the crate ID as found in the regional | |
207 | * header should be used for lookups in the LUT, rather than the | |
208 | * sequencial index number of the header. | |
209 | */ | |
210 | void UseCrateId(bool value) { fUseCrateId = value; } | |
211 | ||
2b7af22a | 212 | /** |
213 | * Returns true if the local board ID as found in the local structure | |
214 | * will be used for lookups in the LUT, rather than the sequencial | |
215 | * index number of the structure. | |
216 | */ | |
217 | bool UseLocalId() const { return fUseLocalId; } | |
218 | ||
219 | /** | |
220 | * Sets the flag indicating if the local board ID as found in the local | |
221 | * structure should be used for lookups in the LUT, rather than the | |
222 | * sequencial index number of the structure. | |
223 | */ | |
224 | void UseLocalId(bool value) { fUseLocalId = value; } | |
225 | ||
406c5bc3 | 226 | /** |
227 | * Sets the DDL bit according to the DDL value given. | |
228 | */ | |
229 | void SetDDL(AliHLTInt32_t ddl) { fDDLBit = (ddl == 20 ? 0x00 : 0x80); } | |
230 | ||
a3d4b6ba | 231 | /** |
232 | * Generates reconstructed hits from strip information. | |
233 | */ | |
234 | bool GenerateHits( | |
235 | AliHLTMUONRecHitStruct* outputBuffer, | |
236 | AliHLTUInt32_t& maxEntries | |
237 | ); | |
69c14678 | 238 | |
a3d4b6ba | 239 | // Methods inherited from AliMUONTriggerDDLDecoderEventHandler: |
69c14678 | 240 | |
a3d4b6ba | 241 | /// Called for each new buffer. Just remember the start location of the buffer. |
242 | void OnNewBuffer(const void* buffer, UInt_t /*bufferSize*/) | |
69c14678 | 243 | { |
a3d4b6ba | 244 | assert( buffer != NULL ); |
245 | fBufferStart = buffer; | |
69c14678 | 246 | } |
247 | ||
a3d4b6ba | 248 | /** |
249 | * Sets the regional structure sequencial number and decodes the crate ID. | |
250 | * if fUseCrateId is false then we use the sequencial number instead. This | |
251 | * might be necessary for for incorrectly generated or buggy raw data. | |
252 | */ | |
253 | void OnNewRegionalStructV2( | |
254 | UInt_t num, | |
255 | const AliMUONRegionalHeaderStruct* regionalStruct, | |
69c14678 | 256 | const AliMUONRegionalScalarsStruct* /*scalars*/, |
257 | const void* /*data*/ | |
258 | ) | |
259 | { | |
a3d4b6ba | 260 | fCurrentRegional = num; |
261 | fCurrentCrateId = (fUseCrateId ? GetRegionalId(regionalStruct) : num); | |
69c14678 | 262 | } |
263 | ||
264 | /// Converts a local trigger structure from the L0 into a trigger record. | |
a3d4b6ba | 265 | void OnLocalStructV2( |
266 | UInt_t num, | |
69c14678 | 267 | const AliMUONLocalInfoStruct* localStruct, |
268 | const AliMUONLocalScalarsStruct* scalars | |
269 | ); | |
270 | ||
271 | /// Logs an error message if there was a decoding problem with the DDL payload. | |
272 | void OnError(ErrorCode code, const void* location); | |
273 | ||
274 | private: | |
275 | // Do not allow copying of this class. | |
276 | /// Not implemented | |
277 | AliDecoderHandler(const AliDecoderHandler& rhs); // copy constructor | |
278 | /// Not implemented | |
279 | AliDecoderHandler& operator = (const AliDecoderHandler& rhs); // assignment operator | |
280 | ||
a3d4b6ba | 281 | /** |
282 | * Finds the strip bits / positions on MT1 that were fired given | |
283 | * the local trigger structure decision. | |
284 | */ | |
285 | bool FindStripsOnMT1( | |
286 | const AliMUONLocalInfoStruct* localStruct, | |
287 | AliHLTInt32_t& xPos, AliHLTInt32_t& yPos | |
288 | ); | |
289 | ||
290 | /** | |
291 | * Tries to find the fired X strips for chambers 11 to 14. | |
292 | */ | |
293 | void FindXStrips( | |
294 | const AliMUONLocalInfoStruct* localStruct, | |
295 | AliHLTInt32_t startPos, AliHLTInt32_t pos[4] | |
296 | ); | |
297 | ||
298 | /** | |
299 | * Tries to find the fired Y strips for chambers 11 to 14. | |
300 | */ | |
301 | void FindYStrips( | |
302 | const AliMUONLocalInfoStruct* localStruct, | |
303 | AliHLTInt32_t startPos, AliHLTInt32_t pos[4] | |
304 | ); | |
305 | ||
306 | /** | |
307 | * Reconstructs a hit with global position coordinates from strip | |
308 | * information on a given chamber. | |
309 | */ | |
310 | void ReconstructHit( | |
311 | AliHLTUInt32_t xStrips, AliHLTUInt32_t yStrips, | |
312 | AliHLTInt32_t xPos, AliHLTInt32_t yPos, | |
313 | AliHLTUInt8_t crateId, AliHLTUInt8_t locId, | |
314 | AliHLTUInt8_t chamber, AliHLTMUONRecHitStruct& hit | |
315 | ); | |
316 | ||
69c14678 | 317 | AliHLTMUONTriggerRecoLookupTable fLookupTable; ///< The lookup table used for mapping between channel addresses and geometrical information. |
318 | const void* fBufferStart; ///< Pointer to the start of the current DDL payload buffer. | |
319 | AliHLTUInt32_t fMaxOutputTrigRecs; ///< Maximum number of reconstructed trigger records that can be stored in fOutputTrigRecs. | |
320 | AliHLTUInt32_t fOutputTrigRecsCount; ///< The number of reconstructed trigger records actually stored in fOutputTrigRecs. | |
321 | AliHLTMUONTriggerRecordStruct* fOutputTrigRecs; ///< Pointer to the output buffer of trigger records structures. | |
322 | AliHLTInt32_t fTrigRecId; ///< A running counter for the trigger record ID. | |
406c5bc3 | 323 | AliHLTInt32_t fDDLBit; ///< The DDL bit used to generate unique trigger record IDs. |
69c14678 | 324 | bool fSuppressPartialTriggers; ///< Flag to indicate if we should suppres partial triggers. |
325 | bool fOverflowed; ///< Flag to indicate if we overflowed the output buffer. | |
a5d4696f | 326 | bool fWarnOnly; ///< Flag indicating if the OnError method should generate warnings rather than error messages. |
2b7af22a | 327 | bool fUseLocalId; ///< Flag to indicate if the local structure ID as found in the local structures should be used or not. |
a3d4b6ba | 328 | bool fUseCrateId; ///< Flag to indicate if the crate ID as found in the regional header structures should be used or not. |
329 | AliHLTInt8_t fCurrentCrateId; ///< The current trigger crate ID number from the regional header. | |
330 | UInt_t fCurrentRegional; ///< Index number of current regional structure being decoded. | |
69c14678 | 331 | }; |
332 | ||
333 | /// Not implemented | |
80590aa1 | 334 | AliHLTMUONTriggerReconstructor(const AliHLTMUONTriggerReconstructor& rhs); // copy constructor |
69c14678 | 335 | /// Not implemented |
336 | AliHLTMUONTriggerReconstructor& operator = (const AliHLTMUONTriggerReconstructor& rhs); // assignment operator | |
80590aa1 | 337 | |
69c14678 | 338 | AliMUONTriggerDDLDecoder<AliDecoderHandler> fDecoder; ///< Raw DDL data decoder. |
6efe69e7 | 339 | }; |
340 | ||
341 | #endif // AliHLTMUONTRIGGERRECONSTRUCTOR_H |