3 //**************************************************************************
4 //* This file is property of and copyright by the ALICE HLT Project *
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 AliHLTITSAgent.cxx
20 @author Matthias Richter
22 @brief Agent of the libAliHLTITS library
26 #include "AliHLTITSAgent.h"
27 #include "AliHLTConfiguration.h"
28 #include "AliHLTOUT.h"
29 #include "AliHLTDAQ.h"
31 // header files of library components
33 // header file of the module preprocessor
34 #include "AliHLTITSCompressRawDataSDDComponent.h"
35 #include "AliHLTITSSSDQARecPointsComponent.h"
36 #include "AliHLTITSQAComponent.h"
37 #include "AliHLTITSClusterFinderComponent.h"
38 #include "AliHLTITSClusterHistoComponent.h"
39 #include "AliHLTITSTrackerComponent.h"
40 #include "AliHLTITSVertexerSPDComponent.h"
41 #include "AliHLTITSDigitPublisherComponent.h"
43 /** global instance for agent registration */
44 AliHLTITSAgent gAliHLTITSAgent;
46 /** ROOT macro for the implementation of ROOT specific class methods */
47 ClassImp(AliHLTITSAgent)
49 AliHLTITSAgent::AliHLTITSAgent()
51 AliHLTModuleAgent("ITS"),
54 // see header file for class documentation
56 // refer to README to build package
58 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
61 AliHLTITSAgent::~AliHLTITSAgent()
63 // see header file for class documentation
66 int AliHLTITSAgent::CreateConfigurations(AliHLTConfigurationHandler* handler,
67 AliRawReader* rawReader,
68 AliRunLoader* runloader) const
70 // see header file for class documentation
72 if (!handler) return -EINVAL;
74 ///////////////////////////////////////////////////////////////////////////////////////////////////
75 ///////////////////////////////////////////////////////////////////////////////////////////////////
77 // ITS tracking is currently only working on raw data
78 // to run on digits, a digit publisher needs to be implemented
80 if (rawReader || !runloader) {
81 // AliSimulation: use the AliRawReaderPublisher if the raw reader is available
82 // Alireconstruction: indicated by runloader==NULL, run always on raw data
84 ///////////////////////////////////////////////////////////////////////////////////////////////////
86 // define the ITS cluster finder configurations
93 iResult=CreateCFConfigurations(handler, AliHLTDAQ::DetectorID("ITSSPD"), spdCF);
94 handler->CreateConfiguration("ITS-SPD-CF","BlockFilter",spdCF.Data(),"");
96 iResult=CreateCFConfigurations(handler, AliHLTDAQ::DetectorID("ITSSDD"), sddCF);
97 handler->CreateConfiguration("ITS-SDD-CF","BlockFilter",sddCF.Data(),"");
99 iResult=CreateCFConfigurations(handler, AliHLTDAQ::DetectorID("ITSSSD"), ssdCF);
100 handler->CreateConfiguration("ITS-SSD-CF","BlockFilter",ssdCF.Data(),"");
103 ///////////////////////////////////////////////////////////////////////////////////////////////////
105 // define the SPD vertexer Z configuration
107 handler->CreateConfiguration("ITS-SPD-vertexer","ITSVertexerSPD", "ITS-SPD-CF","");
110 ///////////////////////////////////////////////////////////////////////////////////////////////////
112 // define the ITS tracker configuration
114 TString trackerInput="ITS-SPD-CF ITS-SDD-CF ITS-SSD-CF";
116 if (handler->FindConfiguration("TPC-globalmerger")) {
117 trackerInput+=" TPC-globalmerger";
119 handler->CreateConfiguration("ITS-tracker","ITSTracker",trackerInput.Data(),"");
124 const char* AliHLTITSAgent::GetReconstructionChains(AliRawReader* /*rawReader*/,
125 AliRunLoader* runloader) const
127 // see header file for class documentation
129 // reconstruction chains for AliRoot simulation
130 // Note: run loader is only available while running embedded into
131 // AliRoot simulation
133 // the chain is just defined and can be used as input for subsequent
135 //return "ITS-tracker";
141 const char* AliHLTITSAgent::GetRequiredComponentLibraries() const
143 // see header file for class documentation
144 return "libAliHLTUtil.so libAliHLTRCU.so libAliHLTTPC.so";
147 int AliHLTITSAgent::RegisterComponents(AliHLTComponentHandler* pHandler) const
149 // see header file for class documentation
151 if (!pHandler) return -EINVAL;
152 pHandler->AddComponent(new AliHLTITSCompressRawDataSDDComponent);
153 pHandler->AddComponent(new AliHLTITSSSDQARecPointsComponent);
154 pHandler->AddComponent(new AliHLTITSQAComponent);
155 pHandler->AddComponent(new AliHLTITSClusterFinderComponent(AliHLTITSClusterFinderComponent::kClusterFinderSPD));
156 pHandler->AddComponent(new AliHLTITSClusterFinderComponent(AliHLTITSClusterFinderComponent::kClusterFinderSDD));
157 pHandler->AddComponent(new AliHLTITSClusterFinderComponent(AliHLTITSClusterFinderComponent::kClusterFinderSSD));
158 pHandler->AddComponent(new AliHLTITSClusterFinderComponent(AliHLTITSClusterFinderComponent::kClusterFinderDigits));
159 pHandler->AddComponent(new AliHLTITSClusterHistoComponent);
160 pHandler->AddComponent(new AliHLTITSTrackerComponent);
161 pHandler->AddComponent(new AliHLTITSVertexerSPDComponent);
162 pHandler->AddComponent(new AliHLTITSDigitPublisherComponent);
167 AliHLTModulePreprocessor* AliHLTITSAgent::GetPreprocessor()
169 // see header file for class documentation
173 int AliHLTITSAgent::GetHandlerDescription(AliHLTComponentDataType dt,
175 AliHLTOUTHandlerDesc& desc) const
177 // see header file for class documentation
179 // Handlers for ITS raw data. Even though there are 3 detectors
180 // everything is handled in one module library and one HLTOUT handler.
181 // This assumes that the data blocks are sent with data type
182 // {DDL_RAW :ISDD} and the bit set in the specification corresponding.
183 // to detector DDL id.
184 // An HLTOUT handler is implemented to extract the equipment id from
185 // the specification.
186 // Note: Future versions of the framework will provide a default handler
187 // class with that functionality.
188 if (dt==(kAliHLTDataTypeDDLRaw|kAliHLTDataOriginITSSDD)) {
189 desc=AliHLTOUTHandlerDesc(kRawReader, dt, GetModuleId());
190 HLTInfo("module %s handles data block type %s specification %d (0x%x)",
191 GetModuleId(), AliHLTComponent::DataType2Text(dt).c_str(), spec, spec);
197 AliHLTOUTHandler* AliHLTITSAgent::GetOutputHandler(AliHLTComponentDataType dt,
198 AliHLTUInt32_t /*spec*/)
200 // see header file for class documentation
201 if (dt==(kAliHLTDataTypeDDLRaw|kAliHLTDataOriginITSSDD)) {
202 // use the default handler
203 if (!fRawDataHandler) {
204 fRawDataHandler=new AliHLTOUTSDDRawDataHandler;
206 return fRawDataHandler;
211 int AliHLTITSAgent::DeleteOutputHandler(AliHLTOUTHandler* pInstance)
213 // see header file for class documentation
214 if (pInstance==NULL) return -EINVAL;
216 if (pInstance==fRawDataHandler) {
217 delete fRawDataHandler;
218 fRawDataHandler=NULL;
226 int AliHLTITSAgent::AliHLTOUTSDDRawDataHandler::ProcessData(AliHLTOUT* pData)
228 // see header file for class documentation
229 if (!pData) return -EINVAL;
230 static int errorCount=0;
231 const int maxErrorCount=10;
232 AliHLTComponentDataType dt=kAliHLTVoidDataType;
233 AliHLTUInt32_t spec=kAliHLTVoidDataSpec;
234 int iResult=pData->GetDataBlockDescription(dt, spec);
236 if (dt==(kAliHLTDataTypeDDLRaw|kAliHLTDataOriginITSSDD)) {
237 int ddlOffset=256;//AliDAQ::DdlIDOffset("ITSSDD");
238 int numberOfDDLs=24;//AliDAQ::NumberOfDdls("ITSSDD");
240 for (;ddlNo<32 && ddlNo<numberOfDDLs; ddlNo++) {
241 if (spec&(0x1<<ddlNo)) break;
243 if (ddlNo>=32 || ddlNo>=numberOfDDLs) {
244 HLTError("invalid specification 0x%08x: can not extract DDL id for data block %s", spec, AliHLTComponent::DataType2Text(dt).c_str());
246 } else if (spec^(0x1<<ddlNo)) {
248 HLTError("multiple links set in specification 0x%08x: can not extract DDL id for data block %s", spec, AliHLTComponent::DataType2Text(dt).c_str());
250 iResult=ddlOffset+ddlNo;
253 if (errorCount++<10) {
254 HLTError("wrong data type: expecting %s, got %s; %s",
255 AliHLTComponent::DataType2Text(kAliHLTDataTypeDDLRaw|kAliHLTDataOriginITSSDD).c_str(),
256 AliHLTComponent::DataType2Text(dt).c_str(),
257 errorCount==maxErrorCount?"suppressing further error messages":"");
265 int AliHLTITSAgent::CreateCFConfigurations(AliHLTConfigurationHandler* pHandler, int detectorId, TString& output) const
267 // see header file for class documentation
268 if (!pHandler) return -EINVAL;
270 ///////////////////////////////////////////////////////////////////////////////////////////////////
272 // define the ITS cluster finder components
275 //The spec starts from 0x1 in SPD, SDD and SSD. So 0x1 is ddl 0 for SPD, 0x10 is ddl 1, and so on
276 //in SDD 0x1 is ddl 256, 0x10 is ddl 257, and so on. This means that the spec has to be set to 0x1
277 //before the loops over the clusterfinder
279 TString idString=AliHLTDAQ::DetectorName(detectorId);
280 if (idString.CompareTo("ITSSPD") &&
281 idString.CompareTo("ITSSDD") &&
282 idString.CompareTo("ITSSSD")) {
283 HLTError("invalid detector id %d does not describe any ITS detector", detectorId);
287 int minddl=AliHLTDAQ::DdlIDOffset(detectorId);
288 int maxddl=minddl+AliHLTDAQ::NumberOfDdls(detectorId)-1;
292 TString origin=idString; origin.ReplaceAll("ITS", "I");
293 TString cfBase=idString; cfBase+="_CF";
294 TString componentId=idString; componentId.ReplaceAll("ITS", "ITSClusterFinder");
295 for(ddlno=minddl;ddlno<=maxddl;ddlno++){
296 TString arg, publisher, cf;
298 // the HLT origin defines are 4 chars: ISPD, ISSD, ISDD respectively
299 arg.Form("-minid %d -datatype 'DDL_RAW ' '%s' -dataspec 0x%08x",ddlno, origin.Data(), spec);
300 if (CheckFilter(kHLTLogDebug)) arg+=" -verbose";
301 publisher.Form("ITS-DP_%d", ddlno);
302 pHandler->CreateConfiguration(publisher.Data(), "AliRawReaderPublisher", NULL , arg.Data());
304 cf.Form("%s_%d",cfBase.Data(), ddlno);
305 pHandler->CreateConfiguration(cf.Data(), componentId.Data(), publisher.Data(), "");
307 if (output.Length()>0) output+=" ";