update by Gaute:
[u/mrichter/AliRoot.git] / HLT / ITS / AliHLTITSAgent.cxx
CommitLineData
dafa46c6 1// $Id$
2
3//**************************************************************************
4//* This file is property of and copyright by the ALICE HLT Project *
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
19/** @file AliHLTITSAgent.cxx
20 @author Matthias Richter
21 @date 25.08.2008
22 @brief Agent of the libAliHLTITS library
23*/
24
25#include <cassert>
26#include "AliHLTITSAgent.h"
27#include "AliHLTConfiguration.h"
6b87e199 28#include "AliHLTOUT.h"
29//#include "AliDAQ.h"
dafa46c6 30
31// header files of library components
32
33// header file of the module preprocessor
0c7d42ab 34#include "AliHLTITSCompressRawDataSDDComponent.h"
5f2721d5 35#include "AliHLTITSClusterFinderSPDComponent.h"
36#include "AliHLTITSClusterFinderSSDComponent.h"
c0b68f8e 37#include "AliHLTITSClusterHistoComponent.h"
dafa46c6 38
dafa46c6 39/** global instance for agent registration */
40AliHLTITSAgent gAliHLTITSAgent;
41
42/** ROOT macro for the implementation of ROOT specific class methods */
43ClassImp(AliHLTITSAgent)
44
45AliHLTITSAgent::AliHLTITSAgent()
46 :
47 AliHLTModuleAgent("ITS"),
48 fRawDataHandler(NULL)
49{
50 // see header file for class documentation
51 // or
52 // refer to README to build package
53 // or
54 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
55}
56
57AliHLTITSAgent::~AliHLTITSAgent()
58{
59 // see header file for class documentation
60}
61
62int AliHLTITSAgent::CreateConfigurations(AliHLTConfigurationHandler* /*handler*/,
63 AliRawReader* /*rawReader*/,
64 AliRunLoader* /*runloader*/) const
65{
66 // see header file for class documentation
67 return 0;
68}
69
70const char* AliHLTITSAgent::GetReconstructionChains(AliRawReader* /*rawReader*/,
71 AliRunLoader* /*runloader*/) const
72{
73 // see header file for class documentation
74
75 return "";
76}
77
78const char* AliHLTITSAgent::GetRequiredComponentLibraries() const
79{
80 // see header file for class documentation
81 return "";
82}
83
84int AliHLTITSAgent::RegisterComponents(AliHLTComponentHandler* pHandler) const
85{
86 // see header file for class documentation
87 assert(pHandler);
88 if (!pHandler) return -EINVAL;
0c7d42ab 89 pHandler->AddComponent(new AliHLTITSCompressRawDataSDDComponent);
5f2721d5 90 pHandler->AddComponent(new AliHLTITSClusterFinderSPDComponent);
91 pHandler->AddComponent(new AliHLTITSClusterFinderSSDComponent);
c0b68f8e 92 pHandler->AddComponent(new AliHLTITSClusterHistoComponent);
dafa46c6 93
94 return 0;
95}
96
97AliHLTModulePreprocessor* AliHLTITSAgent::GetPreprocessor()
98{
99 // see header file for class documentation
100 return NULL;
101}
102
103int AliHLTITSAgent::GetHandlerDescription(AliHLTComponentDataType dt,
104 AliHLTUInt32_t spec,
105 AliHLTOUTHandlerDesc& desc) const
106{
107 // see header file for class documentation
108
109 // Handlers for ITS raw data. Even though there are 3 detectors
110 // everything is handled in one module library and one HLTOUT handler.
111 // This assumes that the data blocks are sent with data type
6b87e199 112 // {DDL_RAW :ISDD} and the bit set in the specification corresponding.
113 // to detector DDL id.
114 // An HLTOUT handler is implemented to extract the equipment id from
115 // the specification.
116 // Note: Future versions of the framework will provide a default handler
117 // class with that functionality.
118 if (dt==(kAliHLTDataTypeDDLRaw|kAliHLTDataOriginITSSDD)) {
dafa46c6 119 desc=AliHLTOUTHandlerDesc(kRawReader, dt, GetModuleId());
120 HLTInfo("module %s handles data block type %s specification %d (0x%x)",
121 GetModuleId(), AliHLTComponent::DataType2Text(dt).c_str(), spec, spec);
122 return 1;
123 }
124 return 0;
125}
126
127AliHLTOUTHandler* AliHLTITSAgent::GetOutputHandler(AliHLTComponentDataType dt,
128 AliHLTUInt32_t /*spec*/)
129{
130 // see header file for class documentation
6b87e199 131 if (dt==(kAliHLTDataTypeDDLRaw|kAliHLTDataOriginITSSDD)) {
dafa46c6 132 // use the default handler
133 if (!fRawDataHandler) {
6b87e199 134 fRawDataHandler=new AliHLTOUTSDDRawDataHandler;
dafa46c6 135 }
136 return fRawDataHandler;
137 }
138 return NULL;
139}
140
141int AliHLTITSAgent::DeleteOutputHandler(AliHLTOUTHandler* pInstance)
142{
143 // see header file for class documentation
144 if (pInstance==NULL) return -EINVAL;
145
146 if (pInstance==fRawDataHandler) {
147 delete fRawDataHandler;
148 fRawDataHandler=NULL;
149 return 0;
150 }
151
152 delete pInstance;
153 return 0;
154}
6b87e199 155
156int AliHLTITSAgent::AliHLTOUTSDDRawDataHandler::ProcessData(AliHLTOUT* pData)
157{
158 // see header file for class documentation
159 if (!pData) return -EINVAL;
160 static int errorCount=0;
161 const int maxErrorCount=10;
162 AliHLTComponentDataType dt=kAliHLTVoidDataType;
163 AliHLTUInt32_t spec=kAliHLTVoidDataSpec;
164 int iResult=pData->GetDataBlockDescription(dt, spec);
165 if (iResult>=0) {
166 if (dt==(kAliHLTDataTypeDDLRaw|kAliHLTDataOriginITSSDD)) {
167 int ddlOffset=256;//AliDAQ::DdlIDOffset("ITSSDD");
168 int numberOfDDLs=24;//AliDAQ::NumberOfDdls("ITSSDD");
169 int ddlNo=0;
170 for (;ddlNo<32 && ddlNo<numberOfDDLs; ddlNo++) {
171 if (spec&(0x1<<ddlNo)) break;
172 }
173 if (ddlNo>=32 || ddlNo>=numberOfDDLs) {
174 HLTError("invalid specification 0x%08x: can not extract DDL id for data block %s", spec, AliHLTComponent::DataType2Text(dt).c_str());
175 iResult=-ENODEV;
176 } else if (spec^(0x1<<ddlNo)) {
177 iResult=-EEXIST;
178 HLTError("multiple links set in specification 0x%08x: can not extract DDL id for data block %s", spec, AliHLTComponent::DataType2Text(dt).c_str());
179 } else {
180 iResult=ddlOffset+ddlNo;
181 }
182 } else {
183 if (errorCount++<10) {
184 HLTError("wrong data type: expecting %s, got %s; %s",
185 AliHLTComponent::DataType2Text(kAliHLTDataTypeDDLRaw|kAliHLTDataOriginITSSDD).c_str(),
186 AliHLTComponent::DataType2Text(dt).c_str(),
187 errorCount==maxErrorCount?"suppressing further error messages":"");
188 }
189 iResult=-EFAULT;
190 }
191 }
192 return iResult;
193}