1 #ifndef AliHLTMUONTRIGGERRECONSTRUCTOR_H
2 #define AliHLTMUONTRIGGERRECONSTRUCTOR_H
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 */
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
16 Artur Szostak <artursz@iafrica.com>:
17 Completely reimplemented the lookup table to a simplified format.
18 **********************************************************************/
21 /// @file AliHLTMUONTriggerReconstructor.h
22 /// @author Indranil Das <indra.das@saha.ac.in>,
23 /// Artur Szostak <artursz@iafrica.com>
25 /// @brief Declaration of the AliHLTMUONTriggerReconstructor class for processing trigger DDL data.
28 #include "AliHLTLogging.h"
29 #include "AliHLTMUONDataTypes.h"
30 #include "AliMUONTriggerDDLDecoder.h"
31 #include "AliMUONTriggerDDLDecoderEventHandler.h"
33 extern "C" struct AliHLTMUONRecHitStruct;
34 extern "C" struct AliHLTMUONTriggerRecordStruct;
37 class AliHLTMUONTriggerReconstructor : public AliHLTLogging
41 AliHLTMUONTriggerReconstructor();
42 virtual ~AliHLTMUONTriggerReconstructor();
45 const AliHLTUInt8_t* rawData,
46 AliHLTUInt32_t rawDataSize,
48 AliHLTMUONTriggerRecordStruct* trigRecord,
49 AliHLTUInt32_t& nofTrigRec
53 * Returns a pointer to the lookup table used to map between channel
54 * addresses and geometrical strip positions.
56 AliHLTMUONTriggerRecoLookupTable* LookupTableBuffer() { return fDecoder.GetHandler().LookupTableBuffer(); }
58 /// Returns the size of the lookup table.
59 size_t LookupTableSize() const { return fDecoder.GetHandler().LookupTableSize(); }
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(); };
65 /// Sets if the decoder should enable the error recovery logic.
66 void TryRecover(bool value);
69 * Sets the DDL bit according to the DDL value given.
70 * It is used to keep the trigger record IDs unique.
72 void SetDDL(AliHLTInt32_t ddl) { fDecoder.GetHandler().SetDDL(ddl); }
75 * Returns true if the output buffer was overflowed in the last call to Run.
77 bool OverflowedOutputBuffer() const { return fDecoder.GetHandler().OverflowedOutputBuffer(); }
80 * Returns the flag specifying if we should suppress partial trigger records.
81 * Partial triggers do not pass the 3/4'ths coincidence requirement.
83 bool SuppressPartialTriggers() const { return fDecoder.GetHandler().SuppressPartialTriggers(); }
86 * Sets the flag specifying if we should suppress partial trigger records.
87 * Partial triggers do not pass the 3/4'ths coincidence requirement.
89 void SuppressPartialTriggers(bool s) { fDecoder.GetHandler().SuppressPartialTriggers(s); }
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.
96 bool UseCrateId() const { return fDecoder.GetHandler().UseCrateId(); }
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.
103 void UseCrateId(bool value) { fDecoder.GetHandler().UseCrateId(value); }
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.
110 bool UseLocalId() const { return fDecoder.GetHandler().UseLocalId(); }
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.
117 void UseLocalId(bool value) { fDecoder.GetHandler().UseLocalId(value); }
121 class AliDecoderHandler : public AliMUONTriggerDDLDecoderEventHandler, public AliHLTLogging
127 /// Default destructor.
128 virtual ~AliDecoderHandler() {}
130 /// Returns a pointer to the lookup table.
131 AliHLTMUONTriggerRecoLookupTable* LookupTableBuffer() { return &fLookupTable; }
133 /// Returns the size of the lookup table.
134 size_t LookupTableSize() const { return sizeof(fLookupTable); }
137 * Returns the maximum number of trigger records that can be
138 * written to the output buffer.
140 AliHLTUInt32_t MaxOutputTrigRecs() const { return fMaxOutputTrigRecs; }
143 * Sets the maximum number of trigger records that can be
144 * written to the output buffer.
146 void MaxOutputTrigRecs(AliHLTUInt32_t n) { fMaxOutputTrigRecs = n; }
149 * Returns the number of reconstructed trigger records actually
150 * stored in the output buffer.
152 AliHLTUInt32_t OutputTrigRecsCount() const { return fOutputTrigRecsCount; }
155 * Returns the pointer to the output buffer which stores reconstructed
158 AliHLTMUONTriggerRecordStruct* OutputTrigRecs() const { return fOutputTrigRecs; }
161 * Sets the pointer to the output buffer which stores reconstructed
162 * trigger records. Also resets the number of trigger records stored.
164 void OutputTrigRecs(AliHLTMUONTriggerRecordStruct* buf)
166 fOutputTrigRecs = buf;
167 fOutputTrigRecsCount = 0;
172 * Returns the flag specifying if we should suppress partial trigger records.
174 bool SuppressPartialTriggers() const { return fSuppressPartialTriggers; }
177 * Sets the flag specifying if we should suppress partial trigger records.
179 void SuppressPartialTriggers(bool s) { fSuppressPartialTriggers = s; }
182 * Returns true if the output buffer was overflowed.
184 bool OverflowedOutputBuffer() const { return fOverflowed; }
187 * Returns true if the OnError handler method will only generate warning
188 * messages and rather than error messages.
190 bool WarnOnly() const { return fWarnOnly; }
193 * Sets the flag indicating if the OnError method should only generate
194 * warnings rather than error messages.
196 void WarnOnly(bool value) { fWarnOnly = value; }
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.
203 bool UseCrateId() const { return fUseCrateId; }
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.
210 void UseCrateId(bool value) { fUseCrateId = value; }
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.
217 bool UseLocalId() const { return fUseLocalId; }
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.
224 void UseLocalId(bool value) { fUseLocalId = value; }
227 * Sets the DDL bit according to the DDL value given.
229 void SetDDL(AliHLTInt32_t ddl) { fDDLBit = (ddl == 20 ? 0x00 : 0x80); }
232 * Generates reconstructed hits from strip information.
235 AliHLTMUONRecHitStruct* outputBuffer,
236 AliHLTUInt32_t& maxEntries
239 // Methods inherited from AliMUONTriggerDDLDecoderEventHandler:
241 /// Called for each new buffer. Just remember the start location of the buffer.
242 void OnNewBuffer(const void* buffer, UInt_t /*bufferSize*/)
244 assert( buffer != NULL );
245 fBufferStart = buffer;
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.
253 void OnNewRegionalStructV2(
255 const AliMUONRegionalHeaderStruct* regionalStruct,
256 const AliMUONRegionalScalarsStruct* /*scalars*/,
260 fCurrentRegional = num;
261 fCurrentCrateId = (fUseCrateId ? GetRegionalId(regionalStruct) : num);
264 /// Converts a local trigger structure from the L0 into a trigger record.
265 void OnLocalStructV2(
267 const AliMUONLocalInfoStruct* localStruct,
268 const AliMUONLocalScalarsStruct* scalars
271 /// Logs an error message if there was a decoding problem with the DDL payload.
272 void OnError(ErrorCode code, const void* location);
275 // Do not allow copying of this class.
277 AliDecoderHandler(const AliDecoderHandler& rhs); // copy constructor
279 AliDecoderHandler& operator = (const AliDecoderHandler& rhs); // assignment operator
282 * Finds the strip bits / positions on MT1 that were fired given
283 * the local trigger structure decision.
285 bool FindStripsOnMT1(
286 const AliMUONLocalInfoStruct* localStruct,
287 AliHLTInt32_t& xPos, AliHLTInt32_t& yPos
291 * Tries to find the fired X strips for chambers 11 to 14.
294 const AliMUONLocalInfoStruct* localStruct,
295 AliHLTInt32_t startPos, AliHLTInt32_t pos[4]
299 * Tries to find the fired Y strips for chambers 11 to 14.
302 const AliMUONLocalInfoStruct* localStruct,
303 AliHLTInt32_t startPos, AliHLTInt32_t pos[4]
307 * Reconstructs a hit with global position coordinates from strip
308 * information on a given chamber.
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
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.
323 AliHLTInt32_t fDDLBit; ///< The DDL bit used to generate unique trigger record IDs.
324 bool fSuppressPartialTriggers; ///< Flag to indicate if we should suppres partial triggers.
325 bool fOverflowed; ///< Flag to indicate if we overflowed the output buffer.
326 bool fWarnOnly; ///< Flag indicating if the OnError method should generate warnings rather than error messages.
327 bool fUseLocalId; ///< Flag to indicate if the local structure ID as found in the local structures should be used or not.
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.
334 AliHLTMUONTriggerReconstructor(const AliHLTMUONTriggerReconstructor& rhs); // copy constructor
336 AliHLTMUONTriggerReconstructor& operator = (const AliHLTMUONTriggerReconstructor& rhs); // assignment operator
338 AliMUONTriggerDDLDecoder<AliDecoderHandler> fDecoder; ///< Raw DDL data decoder.
341 #endif // AliHLTMUONTRIGGERRECONSTRUCTOR_H