#ifndef ALIHLTMUONHITRECONSTRUCTOR_H
#define ALIHLTMUONHITRECONSTRUCTOR_H
-/* Copyright(c) 1998-2007, ALICE Experiment at CERN, All rights reserved. *
+/* This file is property of and copyright by the ALICE HLT Project *
+ * ALICE Experiment at CERN, All rights reserved. *
* See cxx source for full Copyright notice */
/* $Id$ */
//Author : Indranil Das, SINP, INDIA
// Sukalyan Chattopadhyay, SINP, INDIA
//
-//
//Email : indra.das@saha.ac.in
// sukalyan.chattopadhyay@saha.ac.in
///////////////////////////////////////////////
-
-
#include <iostream>
#include <cstdio>
#include <fstream>
#include <cstring>
#include <cmath>
#include <map>
+#include <cassert>
+
+#include "TString.h"
+#include "AliHLTLogging.h"
+#include "AliMUONTrackerDDLDecoder.h"
+#include "AliMUONTrackerDDLDecoderEventHandler.h"
+#include "AliHLTMUONDataTypes.h"
-#include <AliHLTLogging.h>
+#include "AliRawDataHeader.h"
-using namespace std;
+#if __GNUC__ && __GNUC__ < 3
+#define std
+#endif
-typedef map<int,int> BusToDetElem ;
-struct AliHLTMUONRecHitStruct;
+extern "C" struct AliHLTMUONRecHitStruct;
+
+typedef std::map<AliHLTInt32_t, AliHLTInt32_t> IdManuChannelToEntry;
class AliHLTMUONHitReconstructor : public AliHLTLogging
{
public:
+
+ AliHLTMUONHitReconstructor();
+ virtual ~AliHLTMUONHitReconstructor(void);
+
+ bool LoadLookUpTable(AliHLTMUONHitRecoLutRow* lookUpTableData, AliHLTInt32_t lookUpTableId);
+ bool SetIdManuChannelToEntry(IdManuChannelToEntry lineToId);
+
+
+ bool Run(
+ const AliHLTUInt32_t* rawData,
+ AliHLTUInt32_t rawDataSize,
+ AliHLTMUONRecHitStruct* recHit,
+ AliHLTUInt32_t& nofHit
+ );
+ void SetDCCut(AliHLTInt32_t dcCut) {fDCCut = dcCut;}
+ //void SetDebugLevel(AliHLTInt32_t debugLevel) {fDebugLevel = debugLevel;} //TODO: remove
+ //int GetDebugLevel() const {return fDebugLevel;} //TODO: remove
+
+ static AliHLTInt32_t GetkDetectorId() { return fgkDetectorId; }
+ static AliHLTInt32_t GetkDDLOffSet() { return fgkDDLOffSet; }
+ static AliHLTInt32_t GetkNofDDL() { return fgkNofDDL; }
+ static AliHLTInt32_t GetkDDLHeaderSize() { return fgkDDLHeaderSize; }
+
+private:
+
+ static const AliHLTInt32_t fgkDetectorId; // DDL Offset
+ static const AliHLTInt32_t fgkDDLOffSet; // DDL Offset
+ static const AliHLTInt32_t fgkNofDDL; // Number of DDL
+ static const AliHLTInt32_t fgkDDLHeaderSize; // DDL header size
+ static const AliHLTInt32_t fgkLutLine; // nof Line in LookupTable
- struct DHLTLut{
- int fIdManuChannel; // Manu channel address
- int fIX,fIY; // The X,Y number of the pad.
- float fRealX,fRealY,fRealZ; // The real coordinate of the pad.
- int fPlane,fPcbZone; // The plane and PCB zone ID numbers.
- };
-
- struct DHLTPad{
- int fDetElemId; // The detector element ID of the pad.
- int fBuspatchId; // The bus patch ID number for the pad.
- int fIdManuChannel; // The Manu channel address.
- int fIX,fIY; // The X,Y number of the pad.
- float fRealX,fRealY,fRealZ; // The real coordinate of the pad.
- int fPlane,fPcbZone; // The plane and PCB zone ID numbers.
- int fCharge; // The charge measured on the pad.
- };
-
-
- AliHLTMUONHitReconstructor();
- virtual ~AliHLTMUONHitReconstructor(void);
-
- bool LoadLookUpTable(DHLTLut* lookUpTableData, int lookUpTableId);
- bool SetBusToDetMap(BusToDetElem busToDetElem);
-
- //bool Init();
- bool Run(int* rawData, int *rawDataSize, AliHLTMUONRecHitStruct recHit[], int *nofHit);
-
- void SetDCCut(int dcCut) {fDCCut = dcCut;}
- void SetDebugLevel(int debugLevel) {fDebugLevel = debugLevel;}
- int GetDebugLevel() const {return fDebugLevel;}
- int GetDEId(int iBusPatch) {return fBusToDetElem[iBusPatch] ;}
-
- int GetLutLine(int iDDL) const;
-
- static int GetkDetectorId() { return fgkDetectorId; }
- static int GetkDDLOffSet() { return fgkDDLOffSet; }
- static int GetkNofDDL() { return fgkNofDDL; }
- static int GetkDDLHeaderSize() { return fgkDDLHeaderSize; }
-
-private:
- static const int fgkDetectorId ; // DDL Offset
- static const int fgkDDLOffSet ; // DDL Offset
- static const int fgkNofDDL ; // Number of DDL
- static const int fgkDDLHeaderSize ; // DDL header size
protected:
- AliHLTMUONHitReconstructor(const AliHLTMUONHitReconstructor& rhs); // copy constructor
- AliHLTMUONHitReconstructor& operator=(const AliHLTMUONHitReconstructor& rhs); // assignment operator
+
+ AliHLTMUONHitReconstructor(const AliHLTMUONHitReconstructor& rhs); // copy constructor
+ AliHLTMUONHitReconstructor& operator=(const AliHLTMUONHitReconstructor& rhs); // assignment operator
+
private:
-
-
- static const int fgkEvenLutSize ; // Size of the LookupTable with event DDLID
- static const int fgkOddLutSize ; // Size of the LookupTable with odd DDLID
- static const int fgkLutLine[2]; // nof Line in LookupTable
-
- static const int fgkMinIdManuChannel[2]; // Minimum value of idManuChannel in LookupTable
- static const int fgkMaxIdManuChannel[2]; // Maximum value of idManuChannel in LookupTable
- static const float fgkHalfPadSize[3]; // pad halflength for the pcb zones
-
-
- int fkBlockHeaderSize ; // Block header size
- int fkDspHeaderSize ; // DSP header size
- int fkBuspatchHeaderSize ; // buspatch header size
-
- int fDCCut; // DC Cut value
-
- DHLTPad* fPadData; // pointer to the array containing the information of each padhits
- DHLTLut* fLookUpTableData; // pointer to the array of Lookuptable data
-
- AliHLTMUONRecHitStruct *fRecPoints; // Reconstructed hits
- int *fRecPointsCount; // nof reconstructed hit
- int fMaxRecPointsCount; // max nof reconstructed hit
-
- int fCentralCountB, fCentralCountNB; // centeral hits
- int fIdOffSet,fDDLId; // DDLId and DDL id offset
- int fDigitPerDDL; // Total nof Digits perDDL
-
- int *fDetManuChannelIdList; // pointer to an array of idManuChannel
- int *fCentralChargeB,*fCentralChargeNB; // pointer to an array of central hit
- float *fRecX,*fRecY; // pointer to an array of reconstructed hit
- float *fAvgChargeX,*fAvgChargeY; // average charge on central pad found using CG method
- int fGetIdTotalData[336][80][2] ; // an array of idManuChannel with argumrnt of centralX,centralY and planeType
- int fNofFiredDetElem,fMaxFiredPerDetElem[13]; // counter for detector elements that are fired
- int fDebugLevel;
- BusToDetElem fBusToDetElem; // Mapping between bus address and detector element ID.
-
- bool ReadDDL(int* rawData, int *rawDataSize);
- void FindCentralHits(int minPadId, int maxPadId);
- bool FindRecHits() ;
- void RecXRecY();
- bool MergeRecHits();
-
- //ClassDef(AliHLTMUONHitReconstructor,0)
-};
+ struct AliHLTMUONPad
+ {
+ AliHLTInt32_t fDetElemId; // The detector element ID of the pad.
+ AliHLTInt32_t fIX, fIY; // The X,Y number of the pad.
+ AliHLTFloat32_t fRealX, fRealY, fRealZ; // The real coordinate of the pad.
+ AliHLTFloat32_t fHalfPadSize; // half padsize in X and Y
+ AliHLTInt32_t fPlane; // The plane and PCB zone ID numbers.
+ AliHLTFloat32_t fCharge; // The charge measured on the pad.
+ };
+
+
+ class AliHLTMUONRawDecoder : public AliMUONTrackerDDLDecoderEventHandler, public AliHLTLogging
+ {
+ public:
+
+ AliHLTMUONRawDecoder();
+ virtual ~AliHLTMUONRawDecoder();
+
+ void OnData(UInt_t dataWord, bool /*parityError*/);
+ void OnNewBusPatch(const AliMUONBusPatchHeaderStruct* header, const void* /*data*/)
+ {
+ fBusPatchId = int(header->fBusPatchId);
+ };
+
+ void OnNewBuffer(const void* buffer, UInt_t /*bufferSize*/)
+ {
+ assert( buffer != NULL );
+ fBufferStart = buffer;
+ fDataCount = 1; // dataCount starts from 1 because the 0-th element of fPadData is used as null value.
+ *fNofFiredDetElem = 0;
+ fPrevDetElemId = 0 ;
+ };
+
+ void OnError(ErrorCode code, const void* location)
+ {
+ long bytepos = long(location) - long(fBufferStart) + sizeof(AliRawDataHeader);
+ HLTError("There is a problem with decoding the raw data. %s (Error code: %d, at byte %d)",
+ ErrorCodeToMessage(code), code, bytepos
+ );
+ };
+
+ void SetDCCut(AliHLTInt32_t dcCut) {fDCCut = dcCut;}
+ void SetPadData(AliHLTMUONPad* padData) {fPadData = padData;}
+ void SetLookUpTable(AliHLTMUONHitRecoLutRow* lookUpTableData) {fLookUpTableData = lookUpTableData;}
+ void SetNofFiredDetElemId(AliHLTInt32_t& nofFiredDetElem) {fNofFiredDetElem = &nofFiredDetElem;}
+ void SetIdManuChannelToEntry(IdManuChannelToEntry idToEntry) {fIdToEntry = idToEntry;}
+ void SetMaxFiredPerDetElem(AliHLTInt32_t* maxFiredPerDetElem) {fMaxFiredPerDetElem = maxFiredPerDetElem;}
+
+ AliHLTInt32_t GetDataCount() {return fDataCount;}
+
+ private:
+ // Do not allow copying of this class.
+ /// Not implemented
+ AliHLTMUONRawDecoder(const AliHLTMUONRawDecoder& rhs); // copy constructor
+ /// Not implemented
+ AliHLTMUONRawDecoder& operator=(const AliHLTMUONRawDecoder& rhs); // assignment operator
+
+ const void* fBufferStart; // Pointer to the start of the current DDL payload buffer.
+ AliHLTInt32_t fBusPatchId; // buspatchId
+ AliHLTInt32_t fDCCut; // DC Cut value
+ AliHLTMUONPad* fPadData; // pointer to the array containing the information of each padhits
+ AliHLTMUONHitRecoLutRow* fLookUpTableData; // pointer to the array of Lookuptable data
+ AliHLTInt32_t* fNofFiredDetElem; // counter for detector elements that are fired
+ AliHLTInt32_t* fMaxFiredPerDetElem; // array for detector elements that are fired
+ IdManuChannelToEntry fIdToEntry; // Mapping between Linenumber to IdManuChannel;
+
+ AliHLTInt32_t fDataCount; // Data Counter
+ AliHLTInt32_t fPrevDetElemId; // previous detection elementId
+ AliHLTInt32_t fPadCharge; // pedestal subtracted pad charge
+ AliHLTFloat32_t fCharge; //calibrated pad charge
+ AliHLTInt32_t fIdManuChannel; // id manu channel
+ AliHLTInt32_t fLutEntry; // i-th entry in lookuptable
+ };
+
+ AliMUONTrackerDDLDecoder<AliHLTMUONRawDecoder> fHLTMUONDecoder; // robust HLTMUON Decoder
+
+ AliHLTInt32_t fkBlockHeaderSize; // Block header size
+ AliHLTInt32_t fkDspHeaderSize; // DSP header size
+ AliHLTInt32_t fkBuspatchHeaderSize; // buspatch header size
+
+ AliHLTInt32_t fDCCut; // DC Cut value
+
+ AliHLTMUONPad* fPadData; // pointer to the array containing the information of each padhits
+ AliHLTMUONHitRecoLutRow* fLookUpTableData; // pointer to the array of Lookuptable data
+
+ AliHLTMUONRecHitStruct* fRecPoints; // Reconstructed hits
+ AliHLTUInt32_t *fRecPointsCount; // nof reconstructed hit
+ AliHLTUInt32_t fMaxRecPointsCount; // max nof reconstructed hit
+
+ AliHLTInt32_t fCentralCountB, fCentralCountNB; // centeral hits
+ AliHLTInt32_t fDDLId; // DDLId
+ AliHLTInt32_t fDigitPerDDL; // Total nof Digits perDDL
+
+ AliHLTInt32_t *fCentralChargeB, *fCentralChargeNB; // pointer to an array of central hit
+ AliHLTFloat32_t *fRecX, *fRecY; // pointer to an array of reconstructed hit
+ AliHLTFloat32_t *fAvgChargeX, *fAvgChargeY; // average charge on central pad found using CG method
+ AliHLTInt32_t *fNofBChannel, *fNofNBChannel; // number of channels bending and non-bending.
+ AliHLTInt32_t fGetIdTotalData[336][237][2]; // an array of idManuChannel with argument of centralX, centralY and planeType.
+ AliHLTInt32_t fNofFiredDetElem,fMaxFiredPerDetElem[13]; // counter for detector elements that are fired
+ AliHLTInt32_t fDebugLevel;
+ IdManuChannelToEntry fIdToEntry; // Mapping between Linenumber to IdManuChannel;
+
+ //bool ReadDDL(const AliHLTUInt32_t* rawData, AliHLTUInt32_t rawDataSize);
+ bool DecodeDDL(const AliHLTUInt32_t* rawData, AliHLTUInt32_t rawDataSize);
+ void FindCentralHits(AliHLTInt32_t minPadId, AliHLTInt32_t maxPadId);
+ bool FindRecHits();
+ bool RecXRecY();
+ bool MergeRecHits();
+ void Clear();
+
+};
#endif // ALIHLTMUONHITRECONSTRUCTOR_H