- {
- if(fTrigRec)
- delete fTrigRec;
- HLTInfo("dHLT trigrec");
- return 0;
-
- return 0;
- }
-
-int AliHLTMUONTriggerReconstructorComponent::DoEvent( const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks,
- AliHLTComponentTriggerData& trigData, AliHLTUInt8_t* outputPtr,
- AliHLTUInt32_t& size, vector<AliHLTComponentBlockData>& outputBlocks )
- {
- // Process an event
- unsigned long totalSize = 0;
- Logging( kHLTLogInfo, "HLT::MUONTrigRec::DoEvent", "Output percentage set", "Output percentage set to %lu %% and totalSize %lu", fOutputPercentage,totalSize );
-
- // Loop over all input blocks in the event
- for ( unsigned long n = 0; n < evtData.fBlockCnt; n++ )
- {
-
- if ( totalSize > size )
- break;
-
- int totalDDLSize = blocks[n].fSize/4;
- int ddlRawDataSize = totalDDLSize - AliHLTMUONTriggerReconstructor::GetkDDLHeaderSize();
- //cout<<"ddlRawDataSize :"<<ddlRawDataSize<<endl;
- int *buffer = (int *)((int *)blocks[n].fPtr + AliHLTMUONTriggerReconstructor::GetkDDLHeaderSize()) ;
-
- AliHLTMUONTriggerRecordStruct trigRecord[300];
- int nofTrigRec = 300;
-
- if(! (fTrigRec->Run(buffer,&ddlRawDataSize,trigRecord,&nofTrigRec))){
- HLTError("ERROR In Processing of TrigRec Algo ");
- return EIO;
+{
+ ///
+ /// Inherited from AliHLTComponent. Performs a cleanup of the component.
+ ///
+
+ HLTInfo("Deinitialising dHLT trigger reconstructor component.");
+
+ if (fTrigRec != NULL)
+ {
+ delete fTrigRec;
+ fTrigRec = NULL;
+ }
+ return 0;
+}
+
+
+int AliHLTMUONTriggerReconstructorComponent::DoEvent(
+ const AliHLTComponentEventData& evtData,
+ const AliHLTComponentBlockData* blocks,
+ AliHLTComponentTriggerData& /*trigData*/,
+ AliHLTUInt8_t* outputPtr,
+ AliHLTUInt32_t& size,
+ std::vector<AliHLTComponentBlockData>& outputBlocks
+ )
+{
+ ///
+ /// Inherited from AliHLTProcessor. Processes the new event data.
+ ///
+
+ // Process an event
+ unsigned long totalSize = 0; // Amount of memory currently consumed in bytes.
+
+ HLTDebug("Processing event %llu with %u input data blocks.",
+ evtData.fEventID, evtData.fBlockCnt
+ );
+
+ // Loop over all input blocks in the event and run the trigger DDL
+ // reconstruction algorithm on the raw data.
+ for (AliHLTUInt32_t n = 0; n < evtData.fBlockCnt; n++)
+ {
+ HLTDebug("Handling block: %u, with fDataType = '%s', fPtr = %p and fSize = %u bytes.",
+ n, DataType2Text(blocks[n].fDataType).c_str(), blocks[n].fPtr, blocks[n].fSize
+ );
+
+ if (blocks[n].fDataType != AliHLTMUONConstants::DDLRawDataType()
+ or not AliHLTMUONUtils::IsTriggerDDL(blocks[n].fSpecification)
+ )
+ {
+ // Log a message indicating that we got a data block that we
+ // do not know how to handle.
+ if (fWarnForUnexpecedBlock)
+ HLTWarning("Received a data block of a type we cannot handle: '%s', spec: 0x%X",
+ DataType2Text(blocks[n].fDataType).c_str(), blocks[n].fSpecification
+ );
+ else
+ HLTDebug("Received a data block of a type we cannot handle: '%s', spec: 0x%X",
+ DataType2Text(blocks[n].fDataType).c_str(), blocks[n].fSpecification
+ );
+
+ continue;
+ }
+
+ if (fDDL != -1)
+ {
+ bool ddl[22];
+ AliHLTMUONUtils::UnpackSpecBits(blocks[n].fSpecification, ddl);
+ if (not ddl[fDDL])
+ {
+ HLTWarning("Received raw data from an unexpected DDL.");
+ }
+ }
+
+ // Create a new output data block and initialise the header.
+ AliHLTMUONTriggerRecordsBlockWriter block(outputPtr+totalSize, size-totalSize);
+ if (not block.InitCommonHeader())
+ {
+ HLTError("There is not enough space in the output buffer for the new data block.",
+ " We require at least %ufTrigRec->GetkDDLHeaderSize() bytes, but have %u bytes left.",
+ sizeof(AliHLTMUONTriggerRecordsBlockWriter::HeaderType),
+ block.BufferSize()
+ );
+ break;
+ }
+
+ AliHLTUInt32_t totalDDLSize = blocks[n].fSize / sizeof(AliHLTUInt32_t);
+ AliHLTUInt32_t ddlRawDataSize = totalDDLSize - 8;
+ AliHLTUInt32_t* buffer = reinterpret_cast<AliHLTUInt32_t*>(blocks[n].fPtr) + 8;
+ AliHLTUInt32_t nofTrigRec = block.MaxNumberOfEntries();
+
+ bool runOk = fTrigRec->Run(
+ buffer, ddlRawDataSize,
+ block.GetArray(), nofTrigRec,
+ fSuppressPartialTrigs
+ );
+ if (not runOk)
+ {
+ HLTError("Error while processing of trigger DDL reconstruction algorithm.");
+ size = totalSize; // Must tell the framework how much buffer space was used.
+ return -EIO;
+ }
+
+ // nofTrigRec should now contain the number of triggers actually found
+ // and filled into the output data block, so we can set this number.
+ assert( nofTrigRec <= block.MaxNumberOfEntries() );
+ block.SetNumberOfEntries(nofTrigRec);
+
+ HLTDebug("Number of trigger records found is %d", nofTrigRec);
+
+ // Fill a block data structure for our output block.
+ AliHLTComponentBlockData bd;
+ FillBlockData(bd);
+ bd.fPtr = outputPtr;
+ // This block's start (offset) is after all other blocks written so far.
+ bd.fOffset = totalSize;
+ bd.fSize = block.BytesUsed();
+ bd.fDataType = AliHLTMUONConstants::TriggerRecordsBlockDataType();
+ bd.fSpecification = blocks[n].fSpecification;
+ outputBlocks.push_back(bd);
+
+ HLTDebug("Created a new output data block at fPtr = %p,"
+ " with fOffset = %u (0x%.X) and fSize = %u bytes.",
+ bd.fPtr, bd.fOffset, bd.fOffset, bd.fSize
+ );
+
+ // Increase the total amount of data written so far to our output memory.
+ totalSize += block.BytesUsed();