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"
42 /** global instance for agent registration */
43 AliHLTITSAgent gAliHLTITSAgent;
45 /** ROOT macro for the implementation of ROOT specific class methods */
46 ClassImp(AliHLTITSAgent)
48 AliHLTITSAgent::AliHLTITSAgent()
50 AliHLTModuleAgent("ITS"),
53 // see header file for class documentation
55 // refer to README to build package
57 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
60 AliHLTITSAgent::~AliHLTITSAgent()
62 // see header file for class documentation
65 int AliHLTITSAgent::CreateConfigurations(AliHLTConfigurationHandler* handler,
66 AliRawReader* rawReader,
67 AliRunLoader* runloader) const
69 // see header file for class documentation
71 if (!handler) return -EINVAL;
73 ///////////////////////////////////////////////////////////////////////////////////////////////////
74 ///////////////////////////////////////////////////////////////////////////////////////////////////
76 // ITS tracking is currently only working on raw data
77 // to run on digits, a digit publisher needs to be implemented
79 if (rawReader || !runloader) {
80 // AliSimulation: use the AliRawReaderPublisher if the raw reader is available
81 // Alireconstruction: indicated by runloader==NULL, run always on raw data
83 ///////////////////////////////////////////////////////////////////////////////////////////////////
85 // define the ITS cluster finder configurations
92 iResult=CreateCFConfigurations(handler, AliHLTDAQ::DetectorID("ITSSPD"), spdCF);
93 handler->CreateConfiguration("ITS-SPD-CF","BlockFilter",spdCF.Data(),"");
95 iResult=CreateCFConfigurations(handler, AliHLTDAQ::DetectorID("ITSSDD"), sddCF);
96 handler->CreateConfiguration("ITS-SDD-CF","BlockFilter",sddCF.Data(),"");
98 iResult=CreateCFConfigurations(handler, AliHLTDAQ::DetectorID("ITSSSD"), ssdCF);
99 handler->CreateConfiguration("ITS-SSD-CF","BlockFilter",ssdCF.Data(),"");
102 ///////////////////////////////////////////////////////////////////////////////////////////////////
104 // define the SPD vertexer Z configuration
106 handler->CreateConfiguration("ITS-SPD-vertexer","ITSVertexerSPD", "ITS-SPD-CF","");
109 ///////////////////////////////////////////////////////////////////////////////////////////////////
111 // define the ITS tracker configuration
113 TString trackerInput="ITS-SPD-CF ITS-SDD-CF ITS-SSD-CF";
115 if (handler->FindConfiguration("TPC-globalmerger")) {
116 trackerInput+=" TPC-globalmerger";
118 handler->CreateConfiguration("ITS-tracker","ITSTracker",trackerInput.Data(),"");
123 const char* AliHLTITSAgent::GetReconstructionChains(AliRawReader* /*rawReader*/,
124 AliRunLoader* runloader) const
126 // see header file for class documentation
128 // reconstruction chains for AliRoot simulation
129 // Note: run loader is only available while running embedded into
130 // AliRoot simulation
132 // the chain is just defined and can be used as input for subsequent
134 //return "ITS-tracker";
140 const char* AliHLTITSAgent::GetRequiredComponentLibraries() const
142 // see header file for class documentation
143 return "libAliHLTUtil.so libAliHLTRCU.so libAliHLTTPC.so";
146 int AliHLTITSAgent::RegisterComponents(AliHLTComponentHandler* pHandler) const
148 // see header file for class documentation
150 if (!pHandler) return -EINVAL;
151 pHandler->AddComponent(new AliHLTITSCompressRawDataSDDComponent);
152 pHandler->AddComponent(new AliHLTITSSSDQARecPointsComponent);
153 pHandler->AddComponent(new AliHLTITSQAComponent);
154 pHandler->AddComponent(new AliHLTITSClusterFinderComponent(AliHLTITSClusterFinderComponent::kClusterFinderSPD));
155 pHandler->AddComponent(new AliHLTITSClusterFinderComponent(AliHLTITSClusterFinderComponent::kClusterFinderSDD));
156 pHandler->AddComponent(new AliHLTITSClusterFinderComponent(AliHLTITSClusterFinderComponent::kClusterFinderSSD));
157 pHandler->AddComponent(new AliHLTITSClusterHistoComponent);
158 pHandler->AddComponent(new AliHLTITSTrackerComponent);
159 pHandler->AddComponent(new AliHLTITSVertexerSPDComponent);
164 AliHLTModulePreprocessor* AliHLTITSAgent::GetPreprocessor()
166 // see header file for class documentation
170 int AliHLTITSAgent::GetHandlerDescription(AliHLTComponentDataType dt,
172 AliHLTOUTHandlerDesc& desc) const
174 // see header file for class documentation
176 // Handlers for ITS raw data. Even though there are 3 detectors
177 // everything is handled in one module library and one HLTOUT handler.
178 // This assumes that the data blocks are sent with data type
179 // {DDL_RAW :ISDD} and the bit set in the specification corresponding.
180 // to detector DDL id.
181 // An HLTOUT handler is implemented to extract the equipment id from
182 // the specification.
183 // Note: Future versions of the framework will provide a default handler
184 // class with that functionality.
185 if (dt==(kAliHLTDataTypeDDLRaw|kAliHLTDataOriginITSSDD)) {
186 desc=AliHLTOUTHandlerDesc(kRawReader, dt, GetModuleId());
187 HLTInfo("module %s handles data block type %s specification %d (0x%x)",
188 GetModuleId(), AliHLTComponent::DataType2Text(dt).c_str(), spec, spec);
194 AliHLTOUTHandler* AliHLTITSAgent::GetOutputHandler(AliHLTComponentDataType dt,
195 AliHLTUInt32_t /*spec*/)
197 // see header file for class documentation
198 if (dt==(kAliHLTDataTypeDDLRaw|kAliHLTDataOriginITSSDD)) {
199 // use the default handler
200 if (!fRawDataHandler) {
201 fRawDataHandler=new AliHLTOUTSDDRawDataHandler;
203 return fRawDataHandler;
208 int AliHLTITSAgent::DeleteOutputHandler(AliHLTOUTHandler* pInstance)
210 // see header file for class documentation
211 if (pInstance==NULL) return -EINVAL;
213 if (pInstance==fRawDataHandler) {
214 delete fRawDataHandler;
215 fRawDataHandler=NULL;
223 int AliHLTITSAgent::AliHLTOUTSDDRawDataHandler::ProcessData(AliHLTOUT* pData)
225 // see header file for class documentation
226 if (!pData) return -EINVAL;
227 static int errorCount=0;
228 const int maxErrorCount=10;
229 AliHLTComponentDataType dt=kAliHLTVoidDataType;
230 AliHLTUInt32_t spec=kAliHLTVoidDataSpec;
231 int iResult=pData->GetDataBlockDescription(dt, spec);
233 if (dt==(kAliHLTDataTypeDDLRaw|kAliHLTDataOriginITSSDD)) {
234 int ddlOffset=256;//AliDAQ::DdlIDOffset("ITSSDD");
235 int numberOfDDLs=24;//AliDAQ::NumberOfDdls("ITSSDD");
237 for (;ddlNo<32 && ddlNo<numberOfDDLs; ddlNo++) {
238 if (spec&(0x1<<ddlNo)) break;
240 if (ddlNo>=32 || ddlNo>=numberOfDDLs) {
241 HLTError("invalid specification 0x%08x: can not extract DDL id for data block %s", spec, AliHLTComponent::DataType2Text(dt).c_str());
243 } else if (spec^(0x1<<ddlNo)) {
245 HLTError("multiple links set in specification 0x%08x: can not extract DDL id for data block %s", spec, AliHLTComponent::DataType2Text(dt).c_str());
247 iResult=ddlOffset+ddlNo;
250 if (errorCount++<10) {
251 HLTError("wrong data type: expecting %s, got %s; %s",
252 AliHLTComponent::DataType2Text(kAliHLTDataTypeDDLRaw|kAliHLTDataOriginITSSDD).c_str(),
253 AliHLTComponent::DataType2Text(dt).c_str(),
254 errorCount==maxErrorCount?"suppressing further error messages":"");
262 int AliHLTITSAgent::CreateCFConfigurations(AliHLTConfigurationHandler* pHandler, int detectorId, TString& output) const
264 // see header file for class documentation
265 if (!pHandler) return -EINVAL;
267 ///////////////////////////////////////////////////////////////////////////////////////////////////
269 // define the ITS cluster finder components
272 //The spec starts from 0x1 in SPD, SDD and SSD. So 0x1 is ddl 0 for SPD, 0x10 is ddl 1, and so on
273 //in SDD 0x1 is ddl 256, 0x10 is ddl 257, and so on. This means that the spec has to be set to 0x1
274 //before the loops over the clusterfinder
276 TString idString=AliHLTDAQ::DetectorName(detectorId);
277 if (idString.CompareTo("ITSSPD") &&
278 idString.CompareTo("ITSSDD") &&
279 idString.CompareTo("ITSSSD")) {
280 HLTError("invalid detector id %d does not describe any ITS detector", detectorId);
284 int minddl=AliHLTDAQ::DdlIDOffset(detectorId);
285 int maxddl=minddl+AliHLTDAQ::NumberOfDdls(detectorId)-1;
289 TString origin=idString; origin.ReplaceAll("ITS", "I");
290 TString cfBase=idString; cfBase+="_CF";
291 TString componentId=idString; componentId.ReplaceAll("ITS", "ITSClusterFinder");
292 for(ddlno=minddl;ddlno<=maxddl;ddlno++){
293 TString arg, publisher, cf;
295 // the HLT origin defines are 4 chars: ISPD, ISSD, ISDD respectively
296 arg.Form("-minid %d -datatype 'DDL_RAW ' '%s' -dataspec 0x%08x -verbose",ddlno, origin.Data(), spec);
297 publisher.Form("ITS-DP_%d", ddlno);
298 pHandler->CreateConfiguration(publisher.Data(), "AliRawReaderPublisher", NULL , arg.Data());
300 cf.Form("%s_%d",cfBase.Data(), ddlno);
301 pHandler->CreateConfiguration(cf.Data(), componentId.Data(), publisher.Data(), "");
303 if (output.Length()>0) output+=" ";