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"
41 /** global instance for agent registration */
42 AliHLTITSAgent gAliHLTITSAgent;
44 /** ROOT macro for the implementation of ROOT specific class methods */
45 ClassImp(AliHLTITSAgent)
47 AliHLTITSAgent::AliHLTITSAgent()
49 AliHLTModuleAgent("ITS"),
52 // see header file for class documentation
54 // refer to README to build package
56 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
59 AliHLTITSAgent::~AliHLTITSAgent()
61 // see header file for class documentation
64 int AliHLTITSAgent::CreateConfigurations(AliHLTConfigurationHandler* handler,
65 AliRawReader* rawReader,
66 AliRunLoader* runloader) const
68 // see header file for class documentation
70 if (!handler) return -EINVAL;
72 ///////////////////////////////////////////////////////////////////////////////////////////////////
73 ///////////////////////////////////////////////////////////////////////////////////////////////////
75 // ITS tracking is currently only working on raw data
76 // to run on digits, a digit publisher needs to be implemented
78 if (rawReader || !runloader) {
79 // AliSimulation: use the AliRawReaderPublisher if the raw reader is available
80 // Alireconstruction: indicated by runloader==NULL, run always on raw data
82 ///////////////////////////////////////////////////////////////////////////////////////////////////
84 // define the ITS cluster finder configurations
88 for (int detectorId=0; detectorId<3; detectorId++) {
89 iResult=CreateCFConfigurations(handler, detectorId, trackerInput);
92 ///////////////////////////////////////////////////////////////////////////////////////////////////
94 // define the ITS tracker configuration
96 if (handler->FindConfiguration("TPC-globalmerger")) {
97 trackerInput+=" TPC-globalmerger";
99 handler->CreateConfiguration("ITS-tracker","ITSTracker",trackerInput.Data(),"");
104 const char* AliHLTITSAgent::GetReconstructionChains(AliRawReader* /*rawReader*/,
105 AliRunLoader* runloader) const
107 // see header file for class documentation
109 // reconstruction chains for AliRoot simulation
110 // Note: run loader is only available while running embedded into
111 // AliRoot simulation
113 // the chain is just defined and can be used as input for subsequent
115 //return "ITS-tracker";
121 const char* AliHLTITSAgent::GetRequiredComponentLibraries() const
123 // see header file for class documentation
124 return "libAliHLTUtil.so libAliHLTRCU.so libAliHLTTPC.so";
127 int AliHLTITSAgent::RegisterComponents(AliHLTComponentHandler* pHandler) const
129 // see header file for class documentation
131 if (!pHandler) return -EINVAL;
132 pHandler->AddComponent(new AliHLTITSCompressRawDataSDDComponent);
133 pHandler->AddComponent(new AliHLTITSSSDQARecPointsComponent);
134 pHandler->AddComponent(new AliHLTITSQAComponent);
135 pHandler->AddComponent(new AliHLTITSClusterFinderComponent(AliHLTITSClusterFinderComponent::kClusterFinderSPD));
136 pHandler->AddComponent(new AliHLTITSClusterFinderComponent(AliHLTITSClusterFinderComponent::kClusterFinderSDD));
137 pHandler->AddComponent(new AliHLTITSClusterFinderComponent(AliHLTITSClusterFinderComponent::kClusterFinderSSD));
138 pHandler->AddComponent(new AliHLTITSClusterHistoComponent);
139 pHandler->AddComponent(new AliHLTITSTrackerComponent);
144 AliHLTModulePreprocessor* AliHLTITSAgent::GetPreprocessor()
146 // see header file for class documentation
150 int AliHLTITSAgent::GetHandlerDescription(AliHLTComponentDataType dt,
152 AliHLTOUTHandlerDesc& desc) const
154 // see header file for class documentation
156 // Handlers for ITS raw data. Even though there are 3 detectors
157 // everything is handled in one module library and one HLTOUT handler.
158 // This assumes that the data blocks are sent with data type
159 // {DDL_RAW :ISDD} and the bit set in the specification corresponding.
160 // to detector DDL id.
161 // An HLTOUT handler is implemented to extract the equipment id from
162 // the specification.
163 // Note: Future versions of the framework will provide a default handler
164 // class with that functionality.
165 if (dt==(kAliHLTDataTypeDDLRaw|kAliHLTDataOriginITSSDD)) {
166 desc=AliHLTOUTHandlerDesc(kRawReader, dt, GetModuleId());
167 HLTInfo("module %s handles data block type %s specification %d (0x%x)",
168 GetModuleId(), AliHLTComponent::DataType2Text(dt).c_str(), spec, spec);
174 AliHLTOUTHandler* AliHLTITSAgent::GetOutputHandler(AliHLTComponentDataType dt,
175 AliHLTUInt32_t /*spec*/)
177 // see header file for class documentation
178 if (dt==(kAliHLTDataTypeDDLRaw|kAliHLTDataOriginITSSDD)) {
179 // use the default handler
180 if (!fRawDataHandler) {
181 fRawDataHandler=new AliHLTOUTSDDRawDataHandler;
183 return fRawDataHandler;
188 int AliHLTITSAgent::DeleteOutputHandler(AliHLTOUTHandler* pInstance)
190 // see header file for class documentation
191 if (pInstance==NULL) return -EINVAL;
193 if (pInstance==fRawDataHandler) {
194 delete fRawDataHandler;
195 fRawDataHandler=NULL;
203 int AliHLTITSAgent::AliHLTOUTSDDRawDataHandler::ProcessData(AliHLTOUT* pData)
205 // see header file for class documentation
206 if (!pData) return -EINVAL;
207 static int errorCount=0;
208 const int maxErrorCount=10;
209 AliHLTComponentDataType dt=kAliHLTVoidDataType;
210 AliHLTUInt32_t spec=kAliHLTVoidDataSpec;
211 int iResult=pData->GetDataBlockDescription(dt, spec);
213 if (dt==(kAliHLTDataTypeDDLRaw|kAliHLTDataOriginITSSDD)) {
214 int ddlOffset=256;//AliDAQ::DdlIDOffset("ITSSDD");
215 int numberOfDDLs=24;//AliDAQ::NumberOfDdls("ITSSDD");
217 for (;ddlNo<32 && ddlNo<numberOfDDLs; ddlNo++) {
218 if (spec&(0x1<<ddlNo)) break;
220 if (ddlNo>=32 || ddlNo>=numberOfDDLs) {
221 HLTError("invalid specification 0x%08x: can not extract DDL id for data block %s", spec, AliHLTComponent::DataType2Text(dt).c_str());
223 } else if (spec^(0x1<<ddlNo)) {
225 HLTError("multiple links set in specification 0x%08x: can not extract DDL id for data block %s", spec, AliHLTComponent::DataType2Text(dt).c_str());
227 iResult=ddlOffset+ddlNo;
230 if (errorCount++<10) {
231 HLTError("wrong data type: expecting %s, got %s; %s",
232 AliHLTComponent::DataType2Text(kAliHLTDataTypeDDLRaw|kAliHLTDataOriginITSSDD).c_str(),
233 AliHLTComponent::DataType2Text(dt).c_str(),
234 errorCount==maxErrorCount?"suppressing further error messages":"");
242 int AliHLTITSAgent::CreateCFConfigurations(AliHLTConfigurationHandler* pHandler, int detectorId, TString& output) const
244 // see header file for class documentation
245 if (!pHandler) return -EINVAL;
247 ///////////////////////////////////////////////////////////////////////////////////////////////////
249 // define the ITS cluster finder components
252 //The spec starts from 0x1 in SPD, SDD and SSD. So 0x1 is ddl 0 for SPD, 0x10 is ddl 1, and so on
253 //in SDD 0x1 is ddl 256, 0x10 is ddl 257, and so on. This means that the spec has to be set to 0x1
254 //before the loops over the clusterfinder
256 TString idString=AliHLTDAQ::DetectorName(detectorId);
257 if (idString.CompareTo("ITSSPD") &&
258 idString.CompareTo("ITSSDD") &&
259 idString.CompareTo("ITSSSD")) {
260 HLTError("invalid detector id %d does not describe any ITS detector", detectorId);
264 int minddl=AliHLTDAQ::DdlIDOffset(detectorId);
265 int maxddl=minddl+=AliHLTDAQ::NumberOfDdls(detectorId);
269 TString origin=idString; origin.ReplaceAll("ITS", "I");
270 TString cfBase=idString; cfBase+="_CF";
271 TString componentId=idString; componentId.ReplaceAll("ITS", "ITSClusterFinder");
272 for(ddlno=minddl;ddlno<=maxddl;ddlno++){
273 TString arg, publisher, cf;
275 // the HLT origin defines are 4 chars: ISPD, ISSD, ISDD respectively
276 arg.Form("-minid %d -datatype 'DDL_RAW ' '%s' -dataspec 0x%08x -verbose",ddlno, origin.Data(), spec);
277 publisher.Form("ITS-DP_%d", ddlno);
278 pHandler->CreateConfiguration(publisher.Data(), "AliRawReaderPublisher", NULL , arg.Data());
280 cf.Form("%s_%d",cfBase.Data(), ddlno);
281 pHandler->CreateConfiguration(cf.Data(), componentId.Data(), publisher.Data(), "");
283 if (output.Length()>0) output+=" ";