TString fSpecFormat; // see above
/** format string for block no (when added to file name) */
TString fBlcknoFormat; // see above
+ protected:
/** enumeration format string */
TString fCurrentFileName; // see above
+ private:
/** mode specifier, see @ref TWriterMode */
Short_t fMode; // see above
// or
// visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
+#include <cassert>
#include "AliHLTAltroChannelSelectorComponent.h"
+#include "AliHLTTPCTransform.h"
+#include "AliHLTTPCDigitReaderRaw.h"
+#include "AliHLTTPCDefinitions.h"
+#include "AliHLTTPCPadArray.h"
/** ROOT macro for the implementation of ROOT specific class methods */
ClassImp(AliHLTAltroChannelSelectorComponent)
AliHLTAltroChannelSelectorComponent::AliHLTAltroChannelSelectorComponent()
:
- AliHLTProcessor()
+ AliHLTProcessor(),
+ fRawreaderMode(0)
{
// see header file for class documentation
// or
// see header file for class documentation
int iResult=0;
TString argument="";
+ bool bMissingParam=0;
for (int i=0; i<argc && iResult>=0; i++) {
argument=argv[i];
if (argument.IsNull()) continue;
- //
- if (argument.CompareTo("-whatsoever")==0) {
+ // -rawreadermode
+ if (argument.CompareTo("-rawreadermode")==0) {
+ if ((bMissingParam=(++i>=argc))) break;
+ int mode=AliHLTTPCDigitReaderRaw::DecodeMode(argv[i]);
+ if (mode<0) {
+ HLTError("invalid rawreadermode specifier '%s'", argv[i]);
+ iResult=-EINVAL;
+ } else {
+ fRawreaderMode=static_cast<unsigned>(mode);
+ }
} else {
iResult=-EINVAL;
}
}
+ if (bMissingParam) {
+ HLTError("missing parameter for argument %s", argument.Data());
+ iResult=-EINVAL;
+ }
+
return iResult;
}
// see header file for class documentation
int iResult=0;
- // search for the active pad information
- for (int n=0; n<(int)evtData.fBlockCnt; n++ ) {
-// if (blocks[n].fDataType == ...) {
-
-// }
+ // process the DLL input
+ int blockno=0;
+ for (; blockno<(int)evtData.fBlockCnt; blockno++ ) {
+ if (blocks[blockno].fDataType != (kAliHLTDataTypeDDLRaw|kAliHLTDataOriginTPC)) continue;
+
+ // search for the active pad information
+ AliHLTTPCPadArray::AliHLTTPCActivePads* pActivePadsArray=NULL;
+ int iNofActivePads=0;
+ for (int i=0; i<(int)evtData.fBlockCnt; i++ ) {
+ if (blocks[i].fDataType == AliHLTTPCDefinitions::fgkActivePadsDataType &&
+ blocks[i].fSpecification==blocks[blockno].fSpecification) {
+ pActivePadsArray=reinterpret_cast<AliHLTTPCPadArray::AliHLTTPCActivePads*>(blocks[i].fPtr);
+ iNofActivePads=blocks[i].fSize/sizeof(AliHLTTPCPadArray::AliHLTTPCActivePads);
+ }
+ }
+ if (pActivePadsArray==NULL) {
+ HLTWarning("no block of type %s for specification 0x%08x available, data block unchanged",
+ DataType2Text(AliHLTTPCDefinitions::fgkActivePadsDataType).c_str(),
+ blocks[blockno].fSpecification);
+ // forward the whole block
+ outputBlocks.push_back(blocks[blockno]);
+ continue;
+ }
+
+ int part=AliHLTTPCDefinitions::GetMinPatchNr(blocks[blockno]);
+ assert(part==AliHLTTPCDefinitions::GetMaxPatchNr(blocks[blockno]));
+ int slice=AliHLTTPCDefinitions::GetMinSliceNr(blocks[blockno]);
+ assert(slice==AliHLTTPCDefinitions::GetMaxSliceNr(blocks[blockno]));
+ int firstRow=AliHLTTPCTransform::GetFirstRow(part);
+ int lastRow=AliHLTTPCTransform::GetLastRow(part);
+ AliHLTTPCDigitReaderRaw reader(fRawreaderMode);
+ reader.InitBlock(blocks[blockno].fPtr,blocks[blockno].fSize,firstRow,lastRow,part,slice);
+ AliHLTUInt32_t iOutputSize=0;
+ AliHLTUInt32_t iCapacity=size;
+ while (reader.NextAltroBlock()) {
+ int active=0;
+ for (; active<iNofActivePads; active++) {
+ if (pActivePadsArray[active].fRow==reader.GetRow() &&
+ pActivePadsArray[active].fPad==reader.GetPad()) {
+ break;
+ }
+ }
+ if (active>=iNofActivePads) {
+ HLTDebug("ALTRO block Row %d, Pad %d discarded (inactive)", reader.GetRow(), reader.GetPad());
+ continue;
+ }
+
+ void* pChannel=NULL;
+ AliHLTUInt16_t hwAddress=~(AliHLTUInt16_t)0;
+ int channelSize=reader.GetAltroChannelRawData(pChannel, hwAddress);
+ HLTDebug("ALTRO block Row/Pad %d/%d selected (active)", reader.GetRow(), reader.GetPad());
+ if (channelSize>0 && pChannel!=NULL) {
+ if (iOutputSize==0) {
+ // first add the RCU trailer
+ unsigned rcuTrailerLength=reader.GetRCUDataBlockLength();
+ AliHLTUInt8_t* pSrc=reinterpret_cast<AliHLTUInt8_t*>(blocks[blockno].fPtr);
+ pSrc+=blocks[blockno].fSize;
+ if ((iResult=CopyBlockToEnd(outputPtr, iCapacity, iOutputSize, pSrc, rcuTrailerLength))>=0) {
+ assert(iResult==rcuTrailerLength);
+ iOutputSize+=rcuTrailerLength;
+ } else {
+ HLTError("failed to writer RCU trailer of length %d for block %d", rcuTrailerLength, blockno);
+ break;
+ }
+ }
+ }
+ if ((iResult=CopyBlockToEnd(outputPtr, iCapacity, iOutputSize, pChannel, channelSize))>=0) {
+ assert(iResult==channelSize);
+ iOutputSize+=channelSize;
+ } else {
+ HLTError("failed to writer ALTRO channel of length %d for block %d", channelSize, blockno);
+ break;
+ }
+ }
+ if (iResult>=0) {
+ // write the common data header
+ int cdhSize=reader.GetCommonDataHeaderSize();
+ if ((iResult=CopyBlockToEnd(outputPtr, iCapacity, iOutputSize, blocks[blockno].fPtr, cdhSize))>=0) {
+ assert(iResult==cdhSize);
+ iOutputSize+=cdhSize;
+
+ // set new length of the data block
+ AliHLTUInt32_t* pCdhSize=reinterpret_cast<AliHLTUInt32_t*>(outputPtr+iCapacity-iOutputSize+1);
+ *pCdhSize=iOutputSize;
+
+ // insert block descriptor
+ AliHLTComponentBlockData bd;
+ FillBlockData(bd);
+ bd.fOffset=iCapacity-iOutputSize;
+ bd.fSize=iOutputSize;
+ bd.fDataType=blocks[blockno].fDataType;
+ bd.fSpecification=blocks[blockno].fSpecification;
+ outputBlocks.push_back(bd);
+ iCapacity-=iOutputSize;
+ } else {
+ HLTError("failed to write CDH of length %d for block %d", cdhSize, blockno);
+ break;
+ }
+ }
}
- // process the DLL input
- for (int n=0; n<(int)evtData.fBlockCnt; n++ ) {
- if (blocks[n].fDataType != (kAliHLTDataTypeDDLRaw|kAliHLTDataOriginTPC)) continue;
+ if (iResult<0) {
+ outputBlocks.clear();
}
+ // !!! do not change the size since the output buffer is filled from the end !!!
+
+ return iResult;
+}
+
+int AliHLTAltroChannelSelectorComponent::CopyBlockToEnd(AliHLTUInt8_t* pTgt, unsigned capacity, unsigned position, void* pSrc, unsigned size)
+{
+ int iResult=0;
+ if (pTgt==NULL || pSrc==NULL) return -EINVAL;
+ if (capacity-position<size) return -ENOSPC;
+
+ memcpy(pTgt+(capacity-position-size), pSrc, size);
+ iResult=size;
+
return iResult;
}
/** assignment operator prohibited */
AliHLTAltroChannelSelectorComponent& operator=(const AliHLTAltroChannelSelectorComponent&);
+ /**
+ * Copy a data block at the end of a buffer.
+ * The source buffer is inserted at given position relative to the buffer
+ * end.
+ * @param pTgt target buffer
+ * @param capacity capacity (size) of the buffer
+ * @param position porition relative to the END of the buffer
+ * @param pSrc source buffer to be copied
+ * @param size size of the source buffer
+ * @return copied size, neg error code if failed
+ */
+ int CopyBlockToEnd(AliHLTUInt8_t* pTgt, unsigned capacity, unsigned position, void* pSrc, unsigned size);
+
+ /** the mode for the DigitReaderRaw */
+ unsigned fRawreaderMode; //!transient
+
ClassDef(AliHLTAltroChannelSelectorComponent, 0);
};
/** global instance for agent registration */
AliHLTTPCAgent gAliHLTTPCAgent;
+// component headers
+#include "AliHLTAltroChannelSelectorComponent.h"
+#include "AliHLTTPCDigitDumpComponent.h"
+
/** ROOT macro for the implementation of ROOT specific class methods */
ClassImp(AliHLTTPCAgent)
return NULL;
}
-int AliHLTTPCAgent::RegisterComponents(AliHLTComponentHandler* /*pHandler*/) const
+int AliHLTTPCAgent::RegisterComponents(AliHLTComponentHandler* pHandler) const
{
+ // see header file for class documentation
+ if (!pHandler) return -EINVAL;
+ pHandler->AddComponent(new AliHLTAltroChannelSelectorComponent);
+ pHandler->AddComponent(new AliHLTTPCDigitDumpComponent);
return 0;
}
// or
// visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
+#include <cassert>
#include "AliHLTTPCDigitDumpComponent.h"
+#include "AliHLTTPCTransform.h"
+#include "AliHLTTPCDigitReaderRaw.h"
+#include "AliHLTTPCDefinitions.h"
/** ROOT macro for the implementation of ROOT specific class methods */
ClassImp(AliHLTTPCDigitDumpComponent)
AliHLTTPCDigitDumpComponent::AliHLTTPCDigitDumpComponent()
:
- AliHLTFileWriter()
+ AliHLTFileWriter(),
+ fRawreaderMode(0)
{
// see header file for class documentation
// or
// see header file for class documentation
int iResult=0;
TString argument="";
- for (int i=0; i<argc && iResult>=0; i++) {
+ bool bMissingParam=0;
+ int i=0;
+ for (; i<argc && iResult>=0; i++) {
argument=argv[i];
if (argument.IsNull()) continue;
- //
- if (argument.CompareTo("-whatsoever")==0) {
- } else {
- iResult=-EINVAL;
+ // -rawreadermode
+ if (argument.CompareTo("-rawreadermode")==0) {
+ if ((bMissingParam=(++i>=argc))) break;
+ int mode=AliHLTTPCDigitReaderRaw::DecodeMode(argv[i]);
+ if (mode<0) {
+ HLTError("invalid rawreadermode specifier '%s'", argv[i]);
+ iResult=-EINVAL;
+ } else {
+ fRawreaderMode=static_cast<unsigned>(mode);
+ }
+ break;
}
}
+ if (bMissingParam) {
+ iResult=-EPROTO;
+ }
+ if (iResult>=0) iResult=i+1;
+
return iResult;
}
int AliHLTTPCDigitDumpComponent::DumpEvent( const AliHLTComponentEventData& evtData,
const AliHLTComponentBlockData* blocks,
- AliHLTComponentTriggerData& trigData )
+ AliHLTComponentTriggerData& /*trigData*/ )
{
// see header file for class documentation
int iResult=0;
+ int iPrintedSlice=-1;
+ int iPrintedPart=-1;
+ int blockno=0;
+ HLTDebug("%d blocks", evtData.fBlockCnt);
+ for (; blockno<(int)evtData.fBlockCnt; blockno++ ) {
+ //HLTDebug("event %d block %d: %s 0x%08x size %d", evtData.fEventID, blockno, DataType2Text(blocks[blockno].fDataType).c_str(), blocks[blockno].fSpecification, blocks[blockno].fSize);
+ if (blocks[blockno].fDataType != (kAliHLTDataTypeDDLRaw|kAliHLTDataOriginTPC)) continue;
+
+ TString filename;
+ iResult=BuildFileName(evtData.fEventID, blockno, blocks[blockno].fDataType, blocks[blockno].fSpecification, filename);
+ ios::openmode filemode=(ios::openmode)0;
+ if (fCurrentFileName.CompareTo(filename)==0) {
+ // append to the file
+ filemode=ios::app;
+ } else {
+ // store the file for the next block
+ fCurrentFileName=filename;
+ }
+ if (iResult>=0) {
+ ofstream dump(filename.Data(), filemode);
+ if (dump.good()) {
+ int part=AliHLTTPCDefinitions::GetMinPatchNr(blocks[blockno]);
+ assert(part==AliHLTTPCDefinitions::GetMaxPatchNr(blocks[blockno]));
+ int slice=AliHLTTPCDefinitions::GetMinSliceNr(blocks[blockno]);
+ assert(slice==AliHLTTPCDefinitions::GetMaxSliceNr(blocks[blockno]));
+ int firstRow=AliHLTTPCTransform::GetFirstRow(part);
+ int lastRow=AliHLTTPCTransform::GetLastRow(part);
+ AliHLTTPCDigitReaderRaw reader(fRawreaderMode);
+ reader.InitBlock(blocks[blockno].fPtr,blocks[blockno].fSize,firstRow,lastRow,part,slice);
+
+ int iPrintedRow=-1;
+ int iPrintedPad=-1;
+ int iLastTime=-1;
+ while (reader.Next()) {
+ if (iPrintedSlice!=slice || iPrintedPart!=part) {
+ iPrintedSlice=slice;
+ iPrintedPart=part;
+ dump << "====================================================================" << endl;
+ dump << " Slice: " << iPrintedSlice << " Pad: " << iPrintedPad << endl;
+ }
+ if (iPrintedRow!=reader.GetRow()) {
+ iPrintedRow=reader.GetRow();
+ dump << "--------------------------------------------------------------------" << endl;
+ dump << "Row: " << iPrintedRow << endl;
+ }
+ if (iPrintedPad!=reader.GetPad()) {
+ iPrintedPad=reader.GetPad();
+ dump << " Pad: " << iPrintedPad << endl;
+ }
+ if (iPrintedPad!=reader.GetPad()) {
+ iPrintedPad=reader.GetPad();
+ dump << " Pad: " << iPrintedPad << endl;
+ }
+ if (iLastTime!=reader.GetTime()+1 && iLastTime!=reader.GetTime()-1 ) {
+ dump << endl;
+ dump << " Time: " << reader.GetTime();
+ }
+ iLastTime=reader.GetTime();
+ dump << " " << reader.GetSignal() << endl;
+ }
+ dump << endl << endl;
+ } else {
+ HLTError("can not open file %s for writing", filename.Data());
+ iResult=-EBADF;
+ }
+ dump.close();
+ }
+ }
return iResult;
}
/** assignment operator prohibited */
AliHLTTPCDigitDumpComponent& operator=(const AliHLTTPCDigitDumpComponent&);
+ /** the mode for the DigitReaderRaw */
+ unsigned fRawreaderMode; //!transient
+
ClassDef(AliHLTTPCDigitDumpComponent, 0);
};
return GetRealTime();
}
+int AliHLTTPCDigitReaderRaw::GetAltroChannelRawData(void* &pTgt, AliHLTUInt16_t &hwAddress)
+{
+ int iResult;
+ if (fBuffer==NULL) return -ENODATA;
+ if (fAltroBlockPositionBytes-fAltroBlockLengthBytes>GetCommonDataHeaderSize()) {
+ pTgt=fBuffer+(fAltroBlockPositionBytes-fAltroBlockLengthBytes+1);
+ iResult=fAltroBlockLengthBytes;
+ hwAddress=fAltroBlockHWAddress;
+ }
+ return iResult;
+}
+
bool AliHLTTPCDigitReaderRaw::RealNext()
{
// see header file for class documentation
virtual int GetSignal();
virtual int GetTime();
+ /**
+ * Get pointer and size of the data of the current ALTRO channel.
+ * @param pTgt target to receive the pointer to the buffer
+ * @param hwAddress target to receive the hardware address
+ * @return size of the buffer set to pTgt in bytes on success,
+ * neg error code if failed
+ */
+ int GetAltroChannelRawData(void* &pTgt, AliHLTUInt16_t &hwAddress);
+
bool Verify( bool verify )
{
bool old = fVerify;