3 //**************************************************************************
4 //* This file is property of and copyright by the *
5 //* ALICE Experiment at CERN, All rights reserved. *
7 //* Primary Authors: Matthias Richter <Matthias.Richter@ift.uib.no> *
8 //* for The ALICE HLT Project. *
10 //* Permission to use, copy, modify and distribute this software and its *
11 //* documentation strictly for non-commercial purposes is hereby granted *
12 //* without fee, provided that the above copyright notice appears in all *
13 //* copies and that both the copyright notice and this permission notice *
14 //* appear in the supporting documentation. The authors make no claims *
15 //* about the suitability of this software for any purpose. It is *
16 //* provided "as is" without express or implied warranty. *
17 //**************************************************************************
19 /// @file AliHLTOUTHandlerDetectorDDL.cxx
20 /// @author Matthias Richter
22 /// @brief HLTOUT handler returning equipment id from data type and spec.
25 #include "AliHLTOUTHandlerDetectorDDL.h"
26 #include "AliHLTOUT.h"
27 #include "AliHLTDAQ.h"
29 /** ROOT macro for the implementation of ROOT specific class methods */
30 ClassImp(AliHLTOUTHandlerDetectorDDL)
32 AliHLTOUTHandlerDetectorDDL::AliHLTOUTHandlerDetectorDDL(const char* detector, AliHLTComponentDataType dt)
38 // A default handler class for DDL raw data redirection handlers.
40 // This class implements an AliHLTOUTHandlerEquId which extracts the
41 // equipment Id from the bit pattern in the specification. All detectors
42 // with up to 32 DDL links follow this convention. The bit no in the
43 // data specification word corresponds to the DDL number within the
46 fDDLOffset=AliHLTDAQ::DdlIDOffset(detector);
47 fNumberOfDDLs=AliHLTDAQ::NumberOfDdls(detector);
50 AliHLTOUTHandlerDetectorDDL::~AliHLTOUTHandlerDetectorDDL()
55 int AliHLTOUTHandlerDetectorDDL::ProcessData(AliHLTOUT* pData)
57 // extract the ddl no from the data specification of the data
58 // block and return it
59 // negative error code if failed
60 if (!pData) return -EINVAL;
61 if (fDDLOffset<0 || fNumberOfDDLs<0) return -ENODEV;
63 static int errorCount=0;
64 const int maxErrorCount=10;
65 AliHLTComponentDataType dt=kAliHLTVoidDataType;
66 AliHLTUInt32_t spec=kAliHLTVoidDataSpec;
67 int iResult=pData->GetDataBlockDescription(dt, spec);
68 if (iResult>=0 && dt!=kAliHLTVoidDataType && spec!=kAliHLTVoidDataSpec) {
71 for (;ddlNo<32 && ddlNo<fNumberOfDDLs; ddlNo++) {
72 if (spec&(0x1<<ddlNo)) break;
74 if (ddlNo>=32 || ddlNo>=fNumberOfDDLs) {
75 HLTError("invalid specification 0x%08x: can not extract DDL id for data block %s", spec, AliHLTComponent::DataType2Text(dt).c_str());
77 } else if (spec^(0x1<<ddlNo)) {
79 HLTError("multiple links set in specification 0x%08x: can not extract DDL id for data block %s", spec, AliHLTComponent::DataType2Text(dt).c_str());
81 iResult=fDDLOffset+ddlNo;
84 if (errorCount++<10) {
85 HLTError("wrong data type: expecting %s, got %s%s",
86 AliHLTComponent::DataType2Text(fDt).c_str(),
87 AliHLTComponent::DataType2Text(dt).c_str(),
88 errorCount==maxErrorCount?"; suppressing further error messages":"");
93 if (errorCount++<10) {
94 HLTError("can not get a valid data type and specification from HLTOUT: type %s, specification 0x%08x%s",
95 AliHLTComponent::DataType2Text(dt).c_str(), spec,
96 errorCount==maxErrorCount?"; suppressing further error messages":"");