1 #ifndef ALIHLTMUONHITRECONSTRUCTOR_H
2 #define ALIHLTMUONHITRECONSTRUCTOR_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 //Author : Indranil Das, SINP, INDIA
11 // Sukalyan Chattopadhyay, SINP, INDIA
13 //Email : indra.das@saha.ac.in
14 // sukalyan.chattopadhyay@saha.ac.in
15 ///////////////////////////////////////////////
19 #include "AliHLTLogging.h"
20 #include "AliMUONTrackerDDLDecoder.h"
21 #include "AliMUONTrackerDDLDecoderEventHandler.h"
22 #include "AliHLTMUONDataTypes.h"
24 #if __GNUC__ && __GNUC__ < 3
29 extern "C" struct AliHLTMUONRecHitStruct;
30 extern "C" struct AliHLTMUONClusterStruct;
31 extern "C" struct AliHLTMUONChannelStruct;
32 typedef std::map<AliHLTInt32_t, AliHLTInt32_t> IdManuChannelToEntry;
33 typedef IdManuChannelToEntry MaxEntryPerBusPatch;
35 class AliHLTMUONHitReconstructor : public AliHLTLogging
39 AliHLTMUONHitReconstructor();
40 virtual ~AliHLTMUONHitReconstructor(void);
43 const AliHLTMUONHitRecoLutRow* lookupTable,
44 const IdManuChannelToEntry* idToEntry,
45 const MaxEntryPerBusPatch* maxEntryPerBP
48 void SetDCCut(AliHLTInt32_t dcCut) { fDCCut = dcCut; }
49 AliHLTInt32_t GetDCCut() const { return fDCCut; }
52 AliHLTUInt32_t* rawData,
53 AliHLTUInt32_t rawDataSize,
54 AliHLTMUONRecHitStruct* const recHit,
55 AliHLTUInt32_t& nofHit
59 * Fills the output clusters array with the extra cluster information generated.
60 * If the method GenerateClusterInfo(true) was not called, then no cluster information
61 * is generated and this method will not do anything.
62 * \param [out] clusters This is the output array that will be filled.
63 * \param [in,out] nofClusters Initially this contains the maximum number of elements
64 * that can be stored in the clusters array. The method will fill this with
65 * the actual number of elements stored.
66 * \returns true if all elements were copied and false if there is not enough space in
69 bool FillClusterData(AliHLTMUONClusterStruct* clusters, AliHLTUInt32_t& nofClusters);
72 * Fills the output channels array with the extra channel information generated.
73 * If the method GenerateChannelInfo(true) was not called, then no extra channel
74 * information is generated and this method will not do anything.
75 * \param [out] channels This is the output array that will be filled.
76 * \param [in,out] nofChannels Initially this contains the maximum number of elements
77 * that can be stored in the channels array. The method will fill this with
78 * the actual number of elements stored.
79 * \returns true if all elements were copied and false if there is not enough space in
82 bool FillChannelData(AliHLTMUONChannelStruct* channels, AliHLTUInt32_t& nofChannels);
84 static AliHLTInt32_t GetkDetectorId() { return fgkDetectorId; }
85 static AliHLTInt32_t GetkDDLOffSet() { return fgkDDLOffSet; }
86 static AliHLTInt32_t GetkNofDDL() { return fgkNofDDL; }
87 static AliHLTInt32_t GetkDDLHeaderSize() { return fgkDDLHeaderSize; }
88 static AliHLTInt32_t GetkNofDetElemInDDL(Int_t iDDL);
89 static AliHLTInt32_t GetkMinDetElemIdInDDL(Int_t iDDL);
91 /// The error recovery mode used for TryRecover.
94 kDontTryRecover = 0, /// Will not try recover from errors.
95 kRecoverFull, /// Try recover from all errors.
96 kRecoverJustSkip, /// Just skip any corrupt structures.
97 kRecoverFromParityErrorsOnly /// Recover only from parity errors.
100 /// Returns the recovery mode used for the TryRecover option.
101 /// This controls if the decoder is set to enable recovery logic if
102 /// raw data errors are found.
103 ERecoveryMode TryRecover() const { return fRecoveryMode; }
105 /// Sets if the decoder should enable the error recovery logic and how.
106 void TryRecover(ERecoveryMode mode);
108 /// Returns true if ADC digits with parity errors are skipped.
109 bool SkipParityErrors() const { return fHLTMUONDecoder.GetHandler().SkipParityErrors(); }
111 /// Sets the flag indicating if ADC digits with parity errors are skipped.
112 void SkipParityErrors(bool value) { fHLTMUONDecoder.GetHandler().SkipParityErrors(value); }
114 /// Returns true if messages about parity errors are not printed.
115 bool DontPrintParityErrors() const { return fHLTMUONDecoder.GetHandler().DontPrintParityErrors(); }
117 /// Sets the flag indicating if messages about parity errors are not printed.
118 void DontPrintParityErrors(bool value) { fHLTMUONDecoder.GetHandler().DontPrintParityErrors(value); }
120 /// Returns true if the extra cluster information should be generated.
121 bool GenerateClusterInfo() const { return fGenerateClusterInfo; }
123 /// Sets the flag to indicate if the extra cluster information should be generated.
124 void GenerateClusterInfo(bool value) { fGenerateClusterInfo = value; }
126 /// Returns true if the extra channel information should be generated.
127 bool GenerateChannelInfo() const { return fGenerateChannelInfo; }
129 /// Sets the flag to indicate if the extra channel information should be generated.
130 void GenerateChannelInfo(bool value) { fGenerateChannelInfo = value; }
132 /// Returns the maximum channel multiplicity allowed per cluster.
133 bool MaxChannelMultiplicity() const { return fMaxChannelMult; }
135 /// Sets the maximum channel multiplicity allowed per cluster.
136 /// \note This effects the memory allocation required. Generally M*N number of
137 /// channel structures will be allocated, where M = fMaxChannelMult and
138 /// N = the maximum number of hits that can be filled into the output buffers.
139 void MaxChannelMultiplicity(bool value) { fMaxChannelMult = value; }
141 /// Returns the DDL number the component expects data to be received from.
142 AliHLTInt32_t DDLNumber() const { return fDDL; }
144 /// Sets the DDL number the component expects data to be received from.
145 void DDLNumber(AliHLTInt32_t value) { fDDL = (value & 0x1F); } // 0x1F forces value into our required range.
147 bool InitDetElemInDDLArray();
148 bool DeInitDetElemInDDLArray();
152 static const AliHLTInt32_t fgkDetectorId; // DDL Offset
153 static const AliHLTInt32_t fgkDDLOffSet; // DDL Offset
154 static const AliHLTInt32_t fgkNofDDL; // Number of DDL
155 static const AliHLTInt32_t fgkDDLHeaderSize; // DDL header size
156 static const AliHLTInt32_t fgkLutLine; // nof Line in LookupTable
157 static const AliHLTInt32_t fgkMaxNofDataPerDetElem; // maximum allowed data points per detlem
158 static const AliHLTInt32_t fgkNofDetElemInDDL[20] ; // nof Detelem in a given ddl
159 static const AliHLTInt32_t fgkMinDetElemIdInDDL[20] ; // the detelem which has minimum value in ddl
161 AliHLTMUONHitReconstructor(const AliHLTMUONHitReconstructor& rhs); // copy constructor
162 AliHLTMUONHitReconstructor& operator=(const AliHLTMUONHitReconstructor& rhs); // assignment operator
166 AliHLTInt32_t fDetElemId; // The detector element ID of the pad.
167 AliHLTInt32_t fIX, fIY; // The X,Y number of the pad.
168 AliHLTFloat32_t fRealX, fRealY, fRealZ; // The real coordinate of the pad.
169 AliHLTFloat32_t fHalfPadSize; // half padsize in X and Y
170 AliHLTFloat32_t fPadSizeXY; // padsize in Y for bending plane and X for nonbending
171 AliHLTInt32_t fPlane; // The plane and PCB zone ID numbers.
172 AliHLTFloat32_t fCharge; // The charge measured on the pad.
173 AliHLTInt32_t fBusPatch; // The bus patch of the raw data word from the DDL stream.
174 AliHLTUInt32_t fRawData; // The raw data word from the DDL stream.
178 class AliHLTMUONRawDecoder : public AliMUONTrackerDDLDecoderEventHandler, public AliHLTLogging
182 AliHLTMUONRawDecoder();
183 virtual ~AliHLTMUONRawDecoder();
185 void OnData(UInt_t dataWord, bool parityError);
186 void OnNewBusPatch(const AliMUONBusPatchHeaderStruct* header, const void* data) ;
188 void OnNewBuffer(const void* buffer, UInt_t bufferSize);
189 void OnError(ErrorCode code, const void* location);
191 void SetDCCut(AliHLTInt32_t dcCut) {fDCCut = dcCut;}
192 void SetPadData(AliHLTMUONPad* const padData) {fPadData = padData;}
193 void SetLookUpTable(const AliHLTMUONHitRecoLutRow* lookUpTableData) {fkLookUpTableData = lookUpTableData;}
195 void SetIdManuChannelToEntry(const IdManuChannelToEntry* idToEntry) {fkIdToEntry = idToEntry;}
196 void SetMaxEntryPerBusPatch(const MaxEntryPerBusPatch* maxEntryPerBP) {fkMaxEntryPerBusPatch = maxEntryPerBP;}
198 AliHLTInt32_t DDLNumber() const { return fDDL; }
199 void DDLNumber(AliHLTInt32_t value) { fDDL = (value & 0x1F); } // 0x1F forces value into our required range.
200 // The following two methods have to called after set the ddl
201 void SetNofFiredDetElemId(AliHLTUInt16_t* const nofDataInDetElem) {fNofDataInDetElem = nofDataInDetElem;}
202 void SetMaxFiredPerDetElem(AliHLTUInt16_t** const dataCountListPerDetElem) {fDataCountListPerDetElem = dataCountListPerDetElem;}
205 AliHLTInt32_t GetDataCount() const {return fDataCount;}
208 * Returns true if the OnError handler method will only generate warning
209 * messages and rather than error messages.
211 bool WarnOnly() const { return fWarnOnly; }
214 * Sets the flag indicating if the OnError method should only generate
215 * warnings rather than error messages.
217 void WarnOnly(bool value) { fWarnOnly = value; }
220 * Returns true if ADC digits with parity errors are skipped.
222 bool SkipParityErrors() const { return fSkipParityErrors; }
225 * Sets the flag indicating if ADC digits with parity errors are skipped.
227 void SkipParityErrors(bool value) { fSkipParityErrors = value; }
230 * Returns true if messages about parity errors are not printed.
232 bool DontPrintParityErrors() const { return fDontPrintParityErrors; }
235 * Sets the flag indicating if messages about parity errors are not printed.
237 void DontPrintParityErrors(bool value) { fDontPrintParityErrors = value; }
240 * Returns true if parity error messages are printed as warnings.
242 bool PrintParityErrorAsWarning() const { return fPrintParityErrorAsWarning; }
245 * Sets the flag indicating if parity error messages are printed as warnings.
247 void PrintParityErrorAsWarning(bool value) { fPrintParityErrorAsWarning = value; }
250 * Returns true if a parity error was found during the last call to Decode.
252 bool ParityErrorFound() const { return fParityErrorFound; }
255 * Returns true if a non-parity error was found during the last call to Decode.
257 bool NonParityErrorFound() const { return fNonParityErrorFound; }
260 // Do not allow copying of this class.
262 AliHLTMUONRawDecoder(const AliHLTMUONRawDecoder& rhs); // copy constructor
264 AliHLTMUONRawDecoder& operator=(const AliHLTMUONRawDecoder& rhs); // assignment operator
266 const void* fkBufferStart; // Pointer to the start of the current DDL payload buffer.
267 AliHLTInt32_t fBusPatchId; // buspatchId
268 AliHLTInt32_t fDCCut; // DC Cut value
269 AliHLTMUONPad* fPadData; // pointer to the array containing the information of each padhits
270 const AliHLTMUONHitRecoLutRow* fkLookUpTableData; // pointer to the array of Lookuptable data
271 /* AliHLTInt32_t* fNofFiredDetElem; // counter for detector elements that are fired */
272 /* AliHLTInt32_t* fMaxFiredPerDetElem; // array for detector elements that are fired */
273 const IdManuChannelToEntry* fkIdToEntry; // Mapping between Linenumber to IdManuChannel;
274 const MaxEntryPerBusPatch* fkMaxEntryPerBusPatch; // Maximum allowed entry per Buspatch.
276 AliHLTInt32_t fDDL; // DDL number
277 AliHLTInt32_t fDataCount; // Data Counter
278 AliHLTInt32_t fPrevDetElemId; // previous detection elementId
279 AliHLTInt32_t fPadCharge; // pedestal subtracted pad charge
280 AliHLTFloat32_t fCharge; //calibrated pad charge
281 AliHLTInt32_t fIdManuChannel; // id manu channel
282 AliHLTInt32_t fLutEntry; // i-th entry in lookuptable
284 AliHLTUInt16_t **fDataCountListPerDetElem; ///< List of datacounts associated with given ddl
285 AliHLTUInt16_t *fNofDataInDetElem; ///< Nof datacount in a ddl
286 bool fWarnOnly; ///< Flag indicating if the OnError method should generate warnings rather than error messages.
287 bool fSkipParityErrors; ///< Flag indicating if ADC digits with parity errors should be skipped.
288 bool fDontPrintParityErrors; ///< Flag for controlling if messages about parity errors should be printed.
289 bool fPrintParityErrorAsWarning; ///< Flag for controlling if parity error messages are printed as warnings.
290 bool fParityErrorFound; ///< Flag if a parity error was found after a decoding pass.
291 bool fNonParityErrorFound; ///< Flag which indicates if a non parity error code was found after a decoding pass.
292 bool fIsMuchNoisy; ///< tag for noisy buspatch.
295 AliMUONTrackerDDLDecoder<AliHLTMUONRawDecoder> fHLTMUONDecoder; // robust HLTMUON Decoder
297 AliHLTInt32_t fkBlockHeaderSize; // Block header size
298 AliHLTInt32_t fkDspHeaderSize; // DSP header size
299 AliHLTInt32_t fkBuspatchHeaderSize; // buspatch header size
301 AliHLTInt32_t fDCCut; // DC Cut value
303 AliHLTMUONPad* fPadData; // pointer to the array containing the information of each padhits
304 const AliHLTMUONHitRecoLutRow* fkLookUpTableData; // pointer to the array of Lookuptable data (The memory is not owned by this component).
306 AliHLTMUONRecHitStruct* fRecPoints; // Reconstructed hits
307 AliHLTUInt32_t *fRecPointsCount; // nof reconstructed hit.
308 AliHLTUInt32_t fMaxRecPointsCount; // max nof reconstructed hit.
310 AliHLTMUONClusterStruct* fClusters; // Array of output cluster infromation.
311 AliHLTUInt32_t fClusterCount; // Number of elemenets in fClusters.
312 AliHLTUInt32_t fMaxClusters; // Maximum number of clusters in fClusters.
313 bool fGenerateClusterInfo; // Flag indicating if extra cluster information should be generated.
314 AliHLTInt32_t fNewClusterId; // The ID to use for a new cluster structure.
315 AliHLTInt32_t fDDL; // The source DDL number of the raw data.
317 AliHLTMUONChannelStruct* fChannels; // Array of output channel infromation.
318 AliHLTUInt32_t fChannelCount; // Number of elemenets in fChannels.
319 AliHLTUInt32_t fMaxChannels; // Maximum number of channels in fChannels.
320 bool fGenerateChannelInfo; // Flag indicating if extra channel information should be generated.
321 AliHLTUInt32_t fMaxChannelMult; // Indicates the maximum channel multiplicity per cluster allowed.
323 AliHLTInt32_t fCentralCountB, fCentralCountNB; // centeral hits.
324 AliHLTInt32_t fDigitPerDDL; // Total nof Digits perDDL.
326 AliHLTUInt16_t **fDataCountListPerDetElem; // List of datacounts associated with given ddl
327 AliHLTUInt16_t *fNofDataInDetElem; // Nof datacount in a ddl
328 AliHLTInt32_t *fCentralChargeB, *fCentralChargeNB; // pointer to an array of central hit
329 AliHLTFloat32_t *fRecX, *fRecY; // pointer to an array of reconstructed hit
330 AliHLTFloat32_t *fAvgChargeX, *fAvgChargeY; // average charge on central pad found using CG method
331 AliHLTFloat32_t *fTotChargeX, *fTotChargeY; // Total charge in bending and nonbending direction
332 AliHLTInt32_t *fNofBChannel, *fNofNBChannel; // number of channels bending and non-bending.
333 AliHLTInt32_t *fNofYNeighbour; // number of neighbour pad in y direction, needed for y-resolution correction
334 AliHLTInt32_t fGetIdTotalData[336][237][2]; // an array of idManuChannel with argument of centralX, centralY and planeType.
335 //AliHLTInt32_t fNofFiredDetElem,fMaxFiredPerDetElem[130]; // counter for detector elements that are fired
336 const IdManuChannelToEntry* fkIdToEntry; // Mapping between Linenumber to IdManuChannel (The object is not owned by this component).
337 const MaxEntryPerBusPatch* fkMaxEntryPerBusPatch; // Maximum allowed entry per Buspatch.
339 ERecoveryMode fRecoveryMode; ///< The recovery mode for the decoder.
341 bool DecodeDDL(AliHLTUInt32_t* rawData, AliHLTUInt32_t rawDataSize);
342 void FindCentralHits(AliHLTInt32_t iDet);
345 bool MergeSlatRecHits();
346 bool MergeQuadRecHits();
351 #endif // ALIHLTMUONHITRECONSTRUCTOR_H