]>
Commit | Line | Data |
---|---|---|
b12fe461 | 1 | #ifndef ALIHLTMUONHITRECONSTRUCTOR_H |
2 | #define ALIHLTMUONHITRECONSTRUCTOR_H | |
ee3678d3 | 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 */ | |
b12fe461 | 6 | |
7 | /* $Id$ */ | |
8 | ||
9 | /////////////////////////////////////////////// | |
10 | //Author : Indranil Das, SINP, INDIA | |
11 | // Sukalyan Chattopadhyay, SINP, INDIA | |
12 | // | |
b12fe461 | 13 | //Email : indra.das@saha.ac.in |
14 | // sukalyan.chattopadhyay@saha.ac.in | |
15 | /////////////////////////////////////////////// | |
16 | ||
b12fe461 | 17 | #include <iostream> |
18 | #include <cstdio> | |
19 | #include <fstream> | |
20 | #include <cstring> | |
21 | #include <cmath> | |
22 | #include <map> | |
ee3678d3 | 23 | #include <cassert> |
b12fe461 | 24 | |
ee3678d3 | 25 | #include "TString.h" |
26 | #include "AliHLTLogging.h" | |
27 | #include "AliMUONTrackerDDLDecoder.h" | |
28 | #include "AliMUONTrackerDDLDecoderEventHandler.h" | |
29 | #include "AliHLTMUONDataTypes.h" | |
960d54ad | 30 | |
ee3678d3 | 31 | #include "AliRawDataHeader.h" |
b12fe461 | 32 | |
e29a165d | 33 | #if __GNUC__ && __GNUC__ < 3 |
960d54ad | 34 | #define std |
35 | #endif | |
b12fe461 | 36 | |
960d54ad | 37 | |
960d54ad | 38 | extern "C" struct AliHLTMUONRecHitStruct; |
83d66053 | 39 | extern "C" struct AliHLTMUONClusterStruct; |
40 | extern "C" struct AliHLTMUONChannelStruct; | |
ee3678d3 | 41 | typedef std::map<AliHLTInt32_t, AliHLTInt32_t> IdManuChannelToEntry; |
83d66053 | 42 | typedef IdManuChannelToEntry MaxEntryPerBusPatch; |
b12fe461 | 43 | |
44 | class AliHLTMUONHitReconstructor : public AliHLTLogging | |
45 | { | |
46 | public: | |
ee3678d3 | 47 | |
48 | AliHLTMUONHitReconstructor(); | |
49 | virtual ~AliHLTMUONHitReconstructor(void); | |
ee3678d3 | 50 | |
93a75941 | 51 | void SetLookUpTable( |
52 | const AliHLTMUONHitRecoLutRow* lookupTable, | |
83d66053 | 53 | const IdManuChannelToEntry* idToEntry, |
54 | const MaxEntryPerBusPatch* maxEntryPerBP | |
93a75941 | 55 | ); |
56 | ||
57 | void SetDCCut(AliHLTInt32_t dcCut) { fDCCut = dcCut; } | |
ffc1a6f6 | 58 | AliHLTInt32_t GetDCCut() const { return fDCCut; } |
ee3678d3 | 59 | |
60 | bool Run( | |
61 | const AliHLTUInt32_t* rawData, | |
62 | AliHLTUInt32_t rawDataSize, | |
63 | AliHLTMUONRecHitStruct* recHit, | |
64 | AliHLTUInt32_t& nofHit | |
65 | ); | |
ee3678d3 | 66 | |
83d66053 | 67 | /** |
68 | * Fills the output clusters array with the extra cluster information generated. | |
69 | * If the method GenerateClusterInfo(true) was not called, then no cluster information | |
70 | * is generated and this method will not do anything. | |
71 | * [out] \param clusters This is the output array that will be filled. | |
72 | * [in/out] \param nofClusters Initially this contains the maximum number of elements | |
73 | * that can be stored in the clusters array. The method will fill this with | |
74 | * the actual number of elements stored. | |
75 | * \returns true if all elements were copied and false if there is not enough space in | |
76 | * the output array. | |
77 | */ | |
78 | bool FillClusterData(AliHLTMUONClusterStruct* clusters, AliHLTUInt32_t& nofClusters); | |
79 | ||
80 | /** | |
81 | * Fills the output channels array with the extra channel information generated. | |
82 | * If the method GenerateChannelInfo(true) was not called, then no extra channel | |
83 | * information is generated and this method will not do anything. | |
84 | * [out] \param channels This is the output array that will be filled. | |
85 | * [in/out] \param nofChannels Initially this contains the maximum number of elements | |
86 | * that can be stored in the channels array. The method will fill this with | |
87 | * the actual number of elements stored. | |
88 | * \returns true if all elements were copied and false if there is not enough space in | |
89 | * the output array. | |
90 | */ | |
91 | bool FillChannelData(AliHLTMUONChannelStruct* channels, AliHLTUInt32_t& nofChannels); | |
92 | ||
ee3678d3 | 93 | static AliHLTInt32_t GetkDetectorId() { return fgkDetectorId; } |
94 | static AliHLTInt32_t GetkDDLOffSet() { return fgkDDLOffSet; } | |
95 | static AliHLTInt32_t GetkNofDDL() { return fgkNofDDL; } | |
96 | static AliHLTInt32_t GetkDDLHeaderSize() { return fgkDDLHeaderSize; } | |
a5d4696f | 97 | |
a9afae73 | 98 | /// The error recovery mode used for TryRecover. |
99 | enum ERecoveryMode | |
100 | { | |
101 | kDontTryRecover = 0, /// Will not try recover from errors. | |
102 | kRecoverFull, /// Try recover from all errors. | |
103 | kRecoverJustSkip, /// Just skip any corrupt structures. | |
104 | kRecoverFromParityErrorsOnly /// Recover only from parity errors. | |
105 | }; | |
106 | ||
107 | /// Returns the recovery mode used for the TryRecover option. | |
108 | /// This controls if the decoder is set to enable recovery logic if | |
a5d4696f | 109 | /// raw data errors are found. |
a9afae73 | 110 | ERecoveryMode TryRecover() const { return fRecoveryMode; } |
111 | ||
112 | /// Sets if the decoder should enable the error recovery logic and how. | |
113 | void TryRecover(ERecoveryMode mode); | |
a5d4696f | 114 | |
a9afae73 | 115 | /// Returns true if ADC digits with parity errors are skipped. |
116 | bool SkipParityErrors() const { return fHLTMUONDecoder.GetHandler().SkipParityErrors(); } | |
117 | ||
118 | /// Sets the flag indicating if ADC digits with parity errors are skipped. | |
119 | void SkipParityErrors(bool value) { fHLTMUONDecoder.GetHandler().SkipParityErrors(value); } | |
120 | ||
121 | /// Returns true if messages about parity errors are not printed. | |
122 | bool DontPrintParityErrors() const { return fHLTMUONDecoder.GetHandler().DontPrintParityErrors(); } | |
123 | ||
124 | /// Sets the flag indicating if messages about parity errors are not printed. | |
125 | void DontPrintParityErrors(bool value) { fHLTMUONDecoder.GetHandler().DontPrintParityErrors(value); } | |
83d66053 | 126 | |
127 | /// Returns true if the extra cluster information should be generated. | |
128 | bool GenerateClusterInfo() const { return fGenerateClusterInfo; } | |
129 | ||
130 | /// Sets the flag to indicate if the extra cluster information should be generated. | |
131 | void GenerateClusterInfo(bool value) { fGenerateClusterInfo = value; } | |
132 | ||
133 | /// Returns true if the extra channel information should be generated. | |
134 | bool GenerateChannelInfo() const { return fGenerateChannelInfo; } | |
135 | ||
136 | /// Sets the flag to indicate if the extra channel information should be generated. | |
137 | void GenerateChannelInfo(bool value) { fGenerateChannelInfo = value; } | |
138 | ||
139 | /// Returns the maximum channel multiplicity allowed per cluster. | |
140 | bool MaxChannelMultiplicity() const { return fMaxChannelMult; } | |
141 | ||
142 | /// Sets the maximum channel multiplicity allowed per cluster. | |
143 | /// \note This effects the memory allocation required. Generally M*N number of | |
144 | /// channel structures will be allocated, where M = fMaxChannelMult and | |
145 | /// N = the maximum number of hits that can be filled into the output buffers. | |
146 | void MaxChannelMultiplicity(bool value) { fMaxChannelMult = value; } | |
147 | ||
148 | /// Returns the DDL number the component expects data to be received from. | |
149 | AliHLTInt32_t DDLNumber() const { return fDDL; } | |
150 | ||
151 | /// Sets the DDL number the component expects data to be received from. | |
152 | void DDLNumber(AliHLTInt32_t value) { fDDL = (value & 0x1F); } // 0x1F forces value into our required range. | |
ee3678d3 | 153 | |
154 | private: | |
155 | ||
156 | static const AliHLTInt32_t fgkDetectorId; // DDL Offset | |
157 | static const AliHLTInt32_t fgkDDLOffSet; // DDL Offset | |
158 | static const AliHLTInt32_t fgkNofDDL; // Number of DDL | |
159 | static const AliHLTInt32_t fgkDDLHeaderSize; // DDL header size | |
160 | static const AliHLTInt32_t fgkLutLine; // nof Line in LookupTable | |
b12fe461 | 161 | |
b12fe461 | 162 | protected: |
ee3678d3 | 163 | |
164 | AliHLTMUONHitReconstructor(const AliHLTMUONHitReconstructor& rhs); // copy constructor | |
165 | AliHLTMUONHitReconstructor& operator=(const AliHLTMUONHitReconstructor& rhs); // assignment operator | |
166 | ||
960d54ad | 167 | private: |
b12fe461 | 168 | |
ee3678d3 | 169 | struct AliHLTMUONPad |
170 | { | |
171 | AliHLTInt32_t fDetElemId; // The detector element ID of the pad. | |
172 | AliHLTInt32_t fIX, fIY; // The X,Y number of the pad. | |
173 | AliHLTFloat32_t fRealX, fRealY, fRealZ; // The real coordinate of the pad. | |
174 | AliHLTFloat32_t fHalfPadSize; // half padsize in X and Y | |
175 | AliHLTInt32_t fPlane; // The plane and PCB zone ID numbers. | |
176 | AliHLTFloat32_t fCharge; // The charge measured on the pad. | |
66622a82 | 177 | AliHLTInt32_t fBusPatch; // The bus patch of the raw data word from the DDL stream. |
178 | AliHLTUInt32_t fRawData; // The raw data word from the DDL stream. | |
ee3678d3 | 179 | }; |
180 | ||
181 | ||
182 | class AliHLTMUONRawDecoder : public AliMUONTrackerDDLDecoderEventHandler, public AliHLTLogging | |
183 | { | |
184 | public: | |
185 | ||
186 | AliHLTMUONRawDecoder(); | |
187 | virtual ~AliHLTMUONRawDecoder(); | |
188 | ||
189 | void OnData(UInt_t dataWord, bool /*parityError*/); | |
190 | void OnNewBusPatch(const AliMUONBusPatchHeaderStruct* header, const void* /*data*/) | |
191 | { | |
83d66053 | 192 | fBusPatchId = int(header->fBusPatchId); |
193 | MaxEntryPerBusPatch& maxEntryPerBusPatch | |
194 | = * const_cast<MaxEntryPerBusPatch*>(fMaxEntryPerBusPatch); | |
195 | fIsMuchNoisy = false; | |
196 | if(AliHLTInt32_t(header->fLength)> maxEntryPerBusPatch[fBusPatchId]) | |
197 | fIsMuchNoisy = true; | |
198 | ||
ee3678d3 | 199 | }; |
200 | ||
878cb83d | 201 | void OnNewBuffer(const void* buffer, UInt_t bufferSize); |
202 | void OnError(ErrorCode code, const void* location); | |
ee3678d3 | 203 | |
204 | void SetDCCut(AliHLTInt32_t dcCut) {fDCCut = dcCut;} | |
205 | void SetPadData(AliHLTMUONPad* padData) {fPadData = padData;} | |
93a75941 | 206 | void SetLookUpTable(const AliHLTMUONHitRecoLutRow* lookUpTableData) {fLookUpTableData = lookUpTableData;} |
ee3678d3 | 207 | void SetNofFiredDetElemId(AliHLTInt32_t& nofFiredDetElem) {fNofFiredDetElem = &nofFiredDetElem;} |
93a75941 | 208 | void SetIdManuChannelToEntry(const IdManuChannelToEntry* idToEntry) {fIdToEntry = idToEntry;} |
83d66053 | 209 | void SetMaxEntryPerBusPatch(const MaxEntryPerBusPatch* maxEntryPerBP) {fMaxEntryPerBusPatch = maxEntryPerBP;} |
ee3678d3 | 210 | void SetMaxFiredPerDetElem(AliHLTInt32_t* maxFiredPerDetElem) {fMaxFiredPerDetElem = maxFiredPerDetElem;} |
211 | ||
212 | AliHLTInt32_t GetDataCount() {return fDataCount;} | |
a5d4696f | 213 | |
214 | /** | |
215 | * Returns true if the OnError handler method will only generate warning | |
216 | * messages and rather than error messages. | |
217 | */ | |
218 | bool WarnOnly() const { return fWarnOnly; } | |
219 | ||
220 | /** | |
221 | * Sets the flag indicating if the OnError method should only generate | |
222 | * warnings rather than error messages. | |
223 | */ | |
224 | void WarnOnly(bool value) { fWarnOnly = value; } | |
a9afae73 | 225 | |
226 | /** | |
227 | * Returns true if ADC digits with parity errors are skipped. | |
228 | */ | |
229 | bool SkipParityErrors() const { return fSkipParityErrors; } | |
230 | ||
231 | /** | |
232 | * Sets the flag indicating if ADC digits with parity errors are skipped. | |
233 | */ | |
234 | void SkipParityErrors(bool value) { fSkipParityErrors = value; } | |
235 | ||
236 | /** | |
237 | * Returns true if messages about parity errors are not printed. | |
238 | */ | |
239 | bool DontPrintParityErrors() const { return fDontPrintParityErrors; } | |
240 | ||
241 | /** | |
242 | * Sets the flag indicating if messages about parity errors are not printed. | |
243 | */ | |
244 | void DontPrintParityErrors(bool value) { fDontPrintParityErrors = value; } | |
245 | ||
246 | /** | |
247 | * Returns true if parity error messages are printed as warnings. | |
248 | */ | |
249 | bool PrintParityErrorAsWarning() const { return fPrintParityErrorAsWarning; } | |
250 | ||
251 | /** | |
252 | * Sets the flag indicating if parity error messages are printed as warnings. | |
253 | */ | |
254 | void PrintParityErrorAsWarning(bool value) { fPrintParityErrorAsWarning = value; } | |
255 | ||
256 | /** | |
257 | * Returns true if a non-parity error was found during the last call to Decode. | |
258 | */ | |
259 | bool NonParityErrorFound() const { return fNonParityErrorFound; } | |
ee3678d3 | 260 | |
261 | private: | |
262 | // Do not allow copying of this class. | |
263 | /// Not implemented | |
264 | AliHLTMUONRawDecoder(const AliHLTMUONRawDecoder& rhs); // copy constructor | |
265 | /// Not implemented | |
266 | AliHLTMUONRawDecoder& operator=(const AliHLTMUONRawDecoder& rhs); // assignment operator | |
267 | ||
268 | const void* fBufferStart; // Pointer to the start of the current DDL payload buffer. | |
93a75941 | 269 | AliHLTInt32_t fBusPatchId; // buspatchId |
270 | AliHLTInt32_t fDCCut; // DC Cut value | |
271 | AliHLTMUONPad* fPadData; // pointer to the array containing the information of each padhits | |
272 | const AliHLTMUONHitRecoLutRow* fLookUpTableData; // pointer to the array of Lookuptable data | |
273 | AliHLTInt32_t* fNofFiredDetElem; // counter for detector elements that are fired | |
274 | AliHLTInt32_t* fMaxFiredPerDetElem; // array for detector elements that are fired | |
275 | const IdManuChannelToEntry* fIdToEntry; // Mapping between Linenumber to IdManuChannel; | |
83d66053 | 276 | const MaxEntryPerBusPatch* fMaxEntryPerBusPatch; // Maximum allowed entry per Buspatch. |
ee3678d3 | 277 | |
93a75941 | 278 | AliHLTInt32_t fDataCount; // Data Counter |
279 | AliHLTInt32_t fPrevDetElemId; // previous detection elementId | |
280 | AliHLTInt32_t fPadCharge; // pedestal subtracted pad charge | |
281 | AliHLTFloat32_t fCharge; //calibrated pad charge | |
282 | AliHLTInt32_t fIdManuChannel; // id manu channel | |
283 | AliHLTInt32_t fLutEntry; // i-th entry in lookuptable | |
a5d4696f | 284 | |
285 | bool fWarnOnly; ///< Flag indicating if the OnError method should generate warnings rather than error messages. | |
a9afae73 | 286 | bool fSkipParityErrors; ///< Flag indicating if ADC digits with parity errors should be skipped. |
287 | bool fDontPrintParityErrors; ///< Flag for controlling if messages about parity errors should be printed. | |
288 | bool fPrintParityErrorAsWarning; ///< Flag for controlling if parity error messages are printed as warnings. | |
289 | bool fNonParityErrorFound; ///< Flag which indicates if a non parity error code was found after a decoding pass. | |
83d66053 | 290 | |
291 | bool fIsMuchNoisy; ///< tag for noisy buspatch. | |
ee3678d3 | 292 | }; |
293 | ||
294 | AliMUONTrackerDDLDecoder<AliHLTMUONRawDecoder> fHLTMUONDecoder; // robust HLTMUON Decoder | |
295 | ||
93a75941 | 296 | AliHLTInt32_t fkBlockHeaderSize; // Block header size |
297 | AliHLTInt32_t fkDspHeaderSize; // DSP header size | |
298 | AliHLTInt32_t fkBuspatchHeaderSize; // buspatch header size | |
ee3678d3 | 299 | |
93a75941 | 300 | AliHLTInt32_t fDCCut; // DC Cut value |
ee3678d3 | 301 | |
93a75941 | 302 | AliHLTMUONPad* fPadData; // pointer to the array containing the information of each padhits |
303 | const AliHLTMUONHitRecoLutRow* fLookUpTableData; // pointer to the array of Lookuptable data (The memory is not owned by this component). | |
ee3678d3 | 304 | |
93a75941 | 305 | AliHLTMUONRecHitStruct* fRecPoints; // Reconstructed hits |
306 | AliHLTUInt32_t *fRecPointsCount; // nof reconstructed hit. | |
307 | AliHLTUInt32_t fMaxRecPointsCount; // max nof reconstructed hit. | |
ee3678d3 | 308 | |
83d66053 | 309 | AliHLTMUONClusterStruct* fClusters; // Array of output cluster infromation. |
310 | AliHLTUInt32_t fClusterCount; // Number of elemenets in fClusters. | |
311 | AliHLTUInt32_t fMaxClusters; // Maximum number of clusters in fClusters. | |
312 | bool fGenerateClusterInfo; // Flag indicating if extra cluster information should be generated. | |
313 | AliHLTInt32_t fNewClusterId; // The ID to use for a new cluster structure. | |
314 | AliHLTInt32_t fDDL; // The source DDL number of the raw data. | |
315 | ||
316 | AliHLTMUONChannelStruct* fChannels; // Array of output channel infromation. | |
317 | AliHLTUInt32_t fChannelCount; // Number of elemenets in fChannels. | |
318 | AliHLTUInt32_t fMaxChannels; // Maximum number of channels in fChannels. | |
319 | bool fGenerateChannelInfo; // Flag indicating if extra channel information should be generated. | |
320 | AliHLTUInt32_t fMaxChannelMult; // Indicates the maximum channel multiplicity per cluster allowed. | |
321 | ||
93a75941 | 322 | AliHLTInt32_t fCentralCountB, fCentralCountNB; // centeral hits. |
323 | AliHLTInt32_t fDigitPerDDL; // Total nof Digits perDDL. | |
ee3678d3 | 324 | |
93a75941 | 325 | AliHLTInt32_t *fCentralChargeB, *fCentralChargeNB; // pointer to an array of central hit |
326 | AliHLTFloat32_t *fRecX, *fRecY; // pointer to an array of reconstructed hit | |
327 | AliHLTFloat32_t *fAvgChargeX, *fAvgChargeY; // average charge on central pad found using CG method | |
83d66053 | 328 | AliHLTFloat32_t *fTotChargeX, *fTotChargeY; // Total charge in bending and nonbending direction |
93a75941 | 329 | AliHLTInt32_t *fNofBChannel, *fNofNBChannel; // number of channels bending and non-bending. |
330 | AliHLTInt32_t fGetIdTotalData[336][237][2]; // an array of idManuChannel with argument of centralX, centralY and planeType. | |
90af8855 | 331 | AliHLTInt32_t fNofFiredDetElem,fMaxFiredPerDetElem[130]; // counter for detector elements that are fired |
93a75941 | 332 | const IdManuChannelToEntry* fIdToEntry; // Mapping between Linenumber to IdManuChannel (The object is not owned by this component). |
83d66053 | 333 | const MaxEntryPerBusPatch* fMaxEntryPerBusPatch; // Maximum allowed entry per Buspatch. |
ee3678d3 | 334 | |
a9afae73 | 335 | ERecoveryMode fRecoveryMode; ///< The recovery mode for the decoder. |
336 | ||
ee3678d3 | 337 | bool DecodeDDL(const AliHLTUInt32_t* rawData, AliHLTUInt32_t rawDataSize); |
338 | void FindCentralHits(AliHLTInt32_t minPadId, AliHLTInt32_t maxPadId); | |
339 | bool FindRecHits(); | |
878cb83d | 340 | void RecXRecY(); |
ee3678d3 | 341 | bool MergeRecHits(); |
342 | void Clear(); | |
343 | ||
b12fe461 | 344 | }; |
345 | ||
b12fe461 | 346 | #endif // ALIHLTMUONHITRECONSTRUCTOR_H |