]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/MUON/OnlineAnalysis/AliHLTMUONTriggerReconstructor.h
Fixing problem with duplicated structure IDs per event.
[u/mrichter/AliRoot.git] / HLT / MUON / OnlineAnalysis / AliHLTMUONTriggerReconstructor.h
CommitLineData
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
7/* $Id$ */
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
33extern "C" struct AliHLTMUONTriggerRecordStruct;
960d54ad 34
6efe69e7 35
36class AliHLTMUONTriggerReconstructor : public AliHLTLogging
37{
80590aa1 38public:
39
80590aa1 40 AliHLTMUONTriggerReconstructor();
41 virtual ~AliHLTMUONTriggerReconstructor();
42
80590aa1 43 bool Run(
69c14678 44 const AliHLTUInt8_t* rawData,
80590aa1 45 AliHLTUInt32_t rawDataSize,
a5d4696f 46 bool scalarEvent,
80590aa1 47 AliHLTMUONTriggerRecordStruct* trigRecord,
48 AliHLTUInt32_t& nofTrigRec,
49 bool suppressPartialTrigs = false
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
b39b98c8 74private:
80590aa1 75
69c14678 76 class AliDecoderHandler : public AliMUONTriggerDDLDecoderEventHandler, public AliHLTLogging
77 {
78 public:
79
80 AliDecoderHandler();
81
82 /// Default destructor.
83 virtual ~AliDecoderHandler() {}
84
85 /// Returns a pointer to the lookup table.
86 AliHLTMUONTriggerRecoLookupTable* LookupTableBuffer() { return &fLookupTable; }
87
88 /// Returns the size of the lookup table.
89 size_t LookupTableSize() const { return sizeof(fLookupTable); }
90
91 /**
92 * Returns the maximum number of trigger records that can be
93 * written to the output buffer.
94 */
95 AliHLTUInt32_t MaxOutputTrigRecs() const { return fMaxOutputTrigRecs; }
96
97 /**
98 * Sets the maximum number of trigger records that can be
99 * written to the output buffer.
100 */
101 void MaxOutputTrigRecs(AliHLTUInt32_t n) { fMaxOutputTrigRecs = n; }
102
103 /**
104 * Returns the number of reconstructed trigger records actually
105 * stored in the output buffer.
106 */
107 AliHLTUInt32_t OutputTrigRecsCount() const { return fOutputTrigRecsCount; }
108
109 /**
110 * Returns the pointer to the output buffer which stores reconstructed
111 * trigger records.
112 */
113 AliHLTMUONTriggerRecordStruct* OutputTrigRecs() const { return fOutputTrigRecs; }
114
115 /**
116 * Sets the pointer to the output buffer which stores reconstructed
117 * trigger records. Also resets the number of trigger records stored.
118 */
119 void OutputTrigRecs(AliHLTMUONTriggerRecordStruct* buf)
120 {
121 fOutputTrigRecs = buf;
122 fOutputTrigRecsCount = 0;
123 fOverflowed = false;
124 }
125
126 /**
127 * Returns the flag specifying if we should suppress partial trigger records.
128 */
129 bool SuppressPartialTriggers() const { return fSuppressPartialTriggers; }
130
131 /**
132 * Sets the flag specifying if we should suppress partial trigger records.
133 */
134 void SuppressPartialTriggers(bool s) { fSuppressPartialTriggers = s; }
135
136 /**
137 * Returns true if the output buffer was overflowed.
138 */
139 bool OverflowedOutputBuffer() const { return fOverflowed; }
140
a5d4696f 141 /**
142 * Returns true if the OnError handler method will only generate warning
143 * messages and rather than error messages.
144 */
145 bool WarnOnly() const { return fWarnOnly; }
146
147 /**
148 * Sets the flag indicating if the OnError method should only generate
149 * warnings rather than error messages.
150 */
151 void WarnOnly(bool value) { fWarnOnly = value; }
69c14678 152
406c5bc3 153 /**
154 * Sets the DDL bit according to the DDL value given.
155 */
156 void SetDDL(AliHLTInt32_t ddl) { fDDLBit = (ddl == 20 ? 0x00 : 0x80); }
157
69c14678 158 // Methods inherited from AliMUONTriggerDDLDecoderEventHandler:
159
160 /// Called for each new buffer.
161 void OnNewBuffer(const void* buffer, UInt_t /*bufferSize*/);
162
163 /// Increments a counter for every new regional structure.
164 void OnNewRegionalStruct(
165 const AliMUONRegionalHeaderStruct* /*regionalStruct*/,
166 const AliMUONRegionalScalarsStruct* /*scalars*/,
167 const void* /*data*/
168 )
169 {
170 fCurrentRegional++;
171 }
172
173 /// Reset the counter for every new regional structure.
174 void OnEndOfRegionalStruct(
175 const AliMUONRegionalHeaderStruct* /*regionalStruct*/,
176 const AliMUONRegionalScalarsStruct* /*scalars*/,
177 const void* /*data*/
178 )
179 {
180 // Start from -1 since we increment immediately in OnLocalStruct.
181 fCurrentLocal = -1;
182 }
183
184 /// Converts a local trigger structure from the L0 into a trigger record.
185 void OnLocalStruct(
186 const AliMUONLocalInfoStruct* localStruct,
187 const AliMUONLocalScalarsStruct* scalars
188 );
189
190 /// Logs an error message if there was a decoding problem with the DDL payload.
191 void OnError(ErrorCode code, const void* location);
192
193 private:
194 // Do not allow copying of this class.
195 /// Not implemented
196 AliDecoderHandler(const AliDecoderHandler& rhs); // copy constructor
197 /// Not implemented
198 AliDecoderHandler& operator = (const AliDecoderHandler& rhs); // assignment operator
199
200 AliHLTMUONTriggerRecoLookupTable fLookupTable; ///< The lookup table used for mapping between channel addresses and geometrical information.
201 const void* fBufferStart; ///< Pointer to the start of the current DDL payload buffer.
202 AliHLTUInt32_t fMaxOutputTrigRecs; ///< Maximum number of reconstructed trigger records that can be stored in fOutputTrigRecs.
203 AliHLTUInt32_t fOutputTrigRecsCount; ///< The number of reconstructed trigger records actually stored in fOutputTrigRecs.
204 AliHLTMUONTriggerRecordStruct* fOutputTrigRecs; ///< Pointer to the output buffer of trigger records structures.
205 AliHLTInt32_t fTrigRecId; ///< A running counter for the trigger record ID.
406c5bc3 206 AliHLTInt32_t fDDLBit; ///< The DDL bit used to generate unique trigger record IDs.
69c14678 207 AliHLTInt32_t fCurrentRegional; ///< The current regional trigger structure number.
208 AliHLTInt32_t fCurrentLocal; ///< The current local trigger structure number.
209 bool fSuppressPartialTriggers; ///< Flag to indicate if we should suppres partial triggers.
210 bool fOverflowed; ///< Flag to indicate if we overflowed the output buffer.
a5d4696f 211 bool fWarnOnly; ///< Flag indicating if the OnError method should generate warnings rather than error messages.
69c14678 212 };
213
214 /// Not implemented
80590aa1 215 AliHLTMUONTriggerReconstructor(const AliHLTMUONTriggerReconstructor& rhs); // copy constructor
69c14678 216 /// Not implemented
217 AliHLTMUONTriggerReconstructor& operator = (const AliHLTMUONTriggerReconstructor& rhs); // assignment operator
80590aa1 218
69c14678 219 AliMUONTriggerDDLDecoder<AliDecoderHandler> fDecoder; ///< Raw DDL data decoder.
6efe69e7 220};
221
222#endif // AliHLTMUONTRIGGERRECONSTRUCTOR_H