48 #include "StPxlRawHitMaker.h"
49 #include "StPxlRawHit.h"
50 #include "StPxlRawHitCollection.h"
51 #include "StMessMgr.h"
52 #include "StRtsTable.h"
53 #include "StPxlDbMaker/StPxlDb.h"
54 #include "tables/St_pxlControl_Table.h"
59 mPxlRawHitCollection = 0;
63 void StPxlRawHitMaker::Clear(
const Option_t *)
72 Int_t StPxlRawHitMaker::InitRun(Int_t runumber)
80 LOG_ERROR <<
"InitRun : no pxlDb" << endm;
87 mHeaderToken = pxlControlTable[0].headerToken;
88 mSeparatorToken = pxlControlTable[0].separatorToken;
89 mEndToken = pxlControlTable[0].endToken;
100 mSensorGoodStatusMax = pxlControlTable[0].sensorGoodStatusMax;
109 LOG_INFO <<
"StPxlRawHitMaker::Make()" << endm;
114 if (!pxlRawHitDataSet)
116 LOG_INFO <<
" pxlRawHitCollection does NOT exist! Create a new one! " << endm;
121 LOG_INFO <<
" pxlRawHitCollection exists! Append raw hits to this collection!" << endm;
130 mSectorDataLength = rts_table->
GetNRows();
133 LOG_INFO <<
"Found pxl sector raw data at " << hex <<
mSectorData << dec <<
" length in byte: " << mSectorDataLength <<
" in UInt_t: " << mSectorDataLength /
sizeof(UInt_t) << endm;
160 mTrailerDataLength = 0;
163 LOG_WARN <<
"no sector data" << endm;
169 LOG_WARN <<
"no pxl sector header token" << endm;
174 LOG_INFO <<
"sector data header token correct: 0x" << hex <<
mSectorData[0] << dec << endm;
183 LOG_WARN <<
"wrong sector number: " <<
mSector << endm;
189 for(
int i=0; i<32; i++)
191 if(mHeaderData[8] >> i && Debug() > 2)
193 LOG_WARN <<
"sector "<<
mSector<<
" sensor "<<i+1<<
" deserialization error!" << endm;
197 for(
int i=0; i<8; i++)
199 if(mHeaderData[9] >> i && Debug() > 2)
201 LOG_WARN <<
"sector "<<
mSector<<
" sensor "<<i+33<<
" deserialization error!" << endm;
205 if(mHeaderData[9] >> 8)
207 LOG_WARN <<
"sector "<<
mSector<<
" event memory 1 overflow!" << endm;
210 if(mHeaderData[9] >> 9)
212 LOG_WARN <<
"sector "<<
mSector<<
" event memory 2 overflow!" << endm;
215 for(
int i=0; i<32; i++)
217 if(mHeaderData[10] >> i)
219 LOG_WARN <<
"sector "<<
mSector<<
" sensor "<<i+1<<
" trailer or event length error!" << endm;
223 for(
int i=0; i<8; i++)
225 if(mHeaderData[11] >> i)
227 LOG_WARN <<
"sector "<<
mSector<<
" sensor "<<i+33<<
" trailer or event length error!" << endm;
234 LOG_INFO <<
"sector: " <<
mSector <<
" HitsDataLength: " << mHitsDataLength << endm;
241 index += mHitsDataLength;
246 LOG_INFO <<
"sector data separator token correct: 0x" << hex <<
mSectorData[index] << dec << endm;
250 LOG_WARN <<
"sector data separator token wrong: 0x" << hex <<
mSectorData[index] << dec << endm;
258 if (
mSectorData[mSectorDataLength /
sizeof(UInt_t) - 1] == mEndToken) {
260 LOG_INFO <<
"sector data end token corret: 0x" << hex <<
mSectorData[mSectorDataLength /
sizeof(UInt_t) - 1] << dec << endm;
264 LOG_WARN <<
"sector data end token wrong: 0x" << hex <<
mSectorData[mSectorDataLength /
sizeof(UInt_t) - 1] << dec << endm;
269 mTrailerDataLength = mSectorDataLength /
sizeof(UInt_t) - 1 - index;
277 return (a >> 16) + (a & 0xffff);
282 if (mHitsDataLength == 0 || !mHitsData) {
283 LOG_WARN <<
"no hits data" << endm;
289 for (Int_t i = 0; i < mHitsDataLength; i++) {
299 int val1 = val >> 16;
300 int val0 = val & (0xffff);
304 if (chip_id < 1 || chip_id > kNumberOfPxlLaddersPerSector * kNumberOfPxlSensorsPerLadder) {
305 LOG_WARN <<
"wrong chip id: " << chip_id << endm;
308 mLadder = (chip_id - 1) / 10 + 1;
309 mSensor = (chip_id - 1) % 10 + 1;
315 if (row_flag0 == 1) {
327 if (row_flag1 == 1) {
343 buf = input << (32 - end);
344 buf = buf >> (32 - end);
351 UInt_t sd = data >> position;
361 if (Debug() > 2) LOG_WARN <<
"pxl overflow at sector: " <<
mSector <<
" ladder: " <<
mLadder <<
" sensor: " <<
mSensor <<
" row: " <<
mRow[(
mLadder-1)*kNumberOfPxlSensorsPerLadder+
mSensor-1] << endm;
376 for (
int c = 0; c < coding + 1; c++) {
378 if (
mSector > 0 && mSector <= kNumberOfPxlSectors && mLadder > 0 && mLadder <= kNumberOfPxlLaddersPerSector && mSensor > 0 &&
mSensor <= kNumberOfPxlSensorsPerLadder &&
mRow[(
mLadder-1)*kNumberOfPxlSensorsPerLadder+
mSensor-1] >= 0 &&
mRow[(
mLadder-1)*kNumberOfPxlSensorsPerLadder+
mSensor-1] < kNumberOfPxlRowsOnSensor &&
mColumn + c < kNumberOfPxlColumnsOnSensor && mColumn + c >= 0) {
391 if (Debug() > 4) pxlRawHit.
print();
Int_t decodeStateN(Int_t val)
decoding mainly to get fired column numbers in the current row
Int_t elementGetBit(UInt_t data, Int_t position)
get the bit at "position" of "data" word
Short_t mOverflowBit
bit for row overflow (more fired columns than can be read)
StRtsTable * GetNextDaqElement(const char *elementPath)
Query the STAR production chain for the DAQ data.
Short_t mDummyState
dummy state when the last state from a sensor ends on the lower 16 bits of a 32-bit word ...
Class StRTSBaseMaker - is an abstract StMaker to define the interface to access the DAQ data from the...
Int_t mColumn
column 0-959
void decodeSectorData()
decode data of a sector
Short_t mDataEndBit
end bit for "data", which can be row or column number, depending on rowOrColumnFlag ...
void setIdTruth(Int_t idTruth)
set idTruth
Short_t mChipIdStartBit
start bit for chip id
Short_t mRowColumnGoodStatus
row and column good status
void setSensor(Int_t sensor)
set sensor
Int_t mRow[40]
row 0-927, data from 40 sensors on a sector is mixed, need to keep 40 current row numbers ...
const pxlControl_st * pxlControl()
virtual void Clear(Option_t *option="")
User defined functions.
void setLadder(Int_t ladder)
set ladder
Short_t mCodingEndBit
end bit for "coding", which means how many sequential fired columns
UInt_t mid(Int_t start, Int_t end, UInt_t input)
decode the bits between "start" and "end" in the "input" word
void setColumn(Int_t column)
set column
UInt_t * mSectorData
pointers and lengths for data blocks
Int_t mJtagFileVersion
Jtag configure file version.
Int_t pixelHot(Int_t sector, Int_t ladder, Int_t sensor, Int_t row, Int_t column) const
1: hot; 0: good
Short_t mHardwareIdPosition
position for hardware id, including sector number
virtual Long_t GetNRows() const
Returns the number of the used rows for the wrapped table.
Short_t mChipIdEndBit
end bit for chip id
Short_t mChipIdPow
chipId = mChipIdPow*chipIdFromHigher16Bits+chipIdFromLower16Bits
void setSector(Int_t sector)
set sector
Short_t mCodingStartBit
start bit for "coding", which means how many sequential fired columns
void addRawHit(const StPxlRawHit &rawHit)
add a raw hit to the collection
Int_t mSector
current sector, ladder, sensor, row, column that is being worked on
Short_t mHeaderLength
decoding control paramters according to firmware
Short_t mDataStartBit
start bit for "data", which can be row or column number, depending on rowOrColumnFlag ...
Int_t sensorStatus(Int_t sector, Int_t ladder, Int_t sensor) const
status for sensor/row/column
Int_t getHitsDataLength()
get length of the hits data block
Int_t rowStatus(Int_t sector, Int_t ladder, Int_t sensor, Int_t row) const
1: good status
Int_t mOverFlowCount
count for overflow rows
Int_t decodeState0(Int_t val)
decoding mainly to get the row number for the following fired columns
void print()
print all information
Short_t mRowOrColumnFlagBit
bit for rowOrColumnFlag, which determine whether "data" is row or column number
void decodeHitsData()
decode the hits data block of a sector
Int_t columnStatus(Int_t sector, Int_t ladder, Int_t sensor, Int_t column) const
1: good status
const void * At(Int_t i) const
Returns a pointer to the i-th row of the table.
Short_t mSensorGoodStatusMin
sensor good status range
StPxlDb * mPxlDb
pxl db structure containing geometry, db information and so on
virtual TObject * GetObject() const
The depricated method (left here for the sake of the backward compatibility)
void setRow(Int_t row)
set row
StPxlRawHitCollection * mPxlRawHitCollection
generated raw hit collection
Int_t numberOfRawHits(Int_t sector, Int_t ladder, Int_t sensor)
number of raw hits in a sensor
void decodeWord(UInt_t val)
decode a word (32 bits)