]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/BASE/AliHLTOUTHandlerDetectorDDL.cxx
HLTHOMER module
[u/mrichter/AliRoot.git] / HLT / BASE / AliHLTOUTHandlerDetectorDDL.cxx
CommitLineData
7c4d1228 1// $Id$
2
3//**************************************************************************
2dfe97e6 4//* This file is property of and copyright by the *
7c4d1228 5//* ALICE Experiment at CERN, All rights reserved. *
6//* *
7//* Primary Authors: Matthias Richter <Matthias.Richter@ift.uib.no> *
8//* for The ALICE HLT Project. *
9//* *
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//**************************************************************************
18
2dfe97e6 19/// @file AliHLTOUTHandlerDetectorDDL.cxx
20/// @author Matthias Richter
21/// @date 2008-09-09
22/// @brief HLTOUT handler returning equipment id from data type and spec.
23///
7c4d1228 24
25#include "AliHLTOUTHandlerDetectorDDL.h"
26#include "AliHLTOUT.h"
27#include "AliHLTDAQ.h"
28
29/** ROOT macro for the implementation of ROOT specific class methods */
30ClassImp(AliHLTOUTHandlerDetectorDDL)
31
32AliHLTOUTHandlerDetectorDDL::AliHLTOUTHandlerDetectorDDL(const char* detector, AliHLTComponentDataType dt)
33 :
34 fDDLOffset(-1),
35 fNumberOfDDLs(-1),
36 fDt(dt)
37{
2dfe97e6 38 // A default handler class for DDL raw data redirection handlers.
39 //
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
44 // sub-detector.
7c4d1228 45
46 fDDLOffset=AliHLTDAQ::DdlIDOffset(detector);
47 fNumberOfDDLs=AliHLTDAQ::NumberOfDdls(detector);
48}
49
50AliHLTOUTHandlerDetectorDDL::~AliHLTOUTHandlerDetectorDDL()
51{
2dfe97e6 52 // destructor
7c4d1228 53}
54
55int AliHLTOUTHandlerDetectorDDL::ProcessData(AliHLTOUT* pData)
56{
2dfe97e6 57 // extract the ddl no from the data specification of the data
58 // block and return it
59 // negative error code if failed
7c4d1228 60 if (!pData) return -EINVAL;
61 if (fDDLOffset<0 || fNumberOfDDLs<0) return -ENODEV;
62
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) {
69 if (dt==fDt) {
70 int ddlNo=0;
71 for (;ddlNo<32 && ddlNo<fNumberOfDDLs; ddlNo++) {
72 if (spec&(0x1<<ddlNo)) break;
73 }
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());
76 iResult=-ENODEV;
77 } else if (spec^(0x1<<ddlNo)) {
78 iResult=-EEXIST;
79 HLTError("multiple links set in specification 0x%08x: can not extract DDL id for data block %s", spec, AliHLTComponent::DataType2Text(dt).c_str());
80 } else {
81 iResult=fDDLOffset+ddlNo;
82 }
83 } else {
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":"");
89 }
90 iResult=-EBADF;
91 }
92 } else {
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":"");
97 }
98 iResult=-ENODATA;
99 }
100 return iResult;
101}