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
89 for (int detectorId=0; detectorId<3; detectorId++) {
90 iResult=CreateCFConfigurations(handler, detectorId, trackerInput);
93 ///////////////////////////////////////////////////////////////////////////////////////////////////
95 // define the ITS tracker configuration
97 if (handler->FindConfiguration("TPC-globalmerger")) {
98 trackerInput+=" TPC-globalmerger";
100 handler->CreateConfiguration("ITS-tracker","ITSTracker",trackerInput.Data(),"");
105 const char* AliHLTITSAgent::GetReconstructionChains(AliRawReader* /*rawReader*/,
106 AliRunLoader* runloader) const
108 // see header file for class documentation
110 // reconstruction chains for AliRoot simulation
111 // Note: run loader is only available while running embedded into
112 // AliRoot simulation
114 // the chain is just defined and can be used as input for subsequent
116 //return "ITS-tracker";
122 const char* AliHLTITSAgent::GetRequiredComponentLibraries() const
124 // see header file for class documentation
125 return "libAliHLTUtil.so libAliHLTRCU.so libAliHLTTPC.so";
128 int AliHLTITSAgent::RegisterComponents(AliHLTComponentHandler* pHandler) const
130 // see header file for class documentation
132 if (!pHandler) return -EINVAL;
133 pHandler->AddComponent(new AliHLTITSCompressRawDataSDDComponent);
134 pHandler->AddComponent(new AliHLTITSSSDQARecPointsComponent);
135 pHandler->AddComponent(new AliHLTITSQAComponent);
136 pHandler->AddComponent(new AliHLTITSClusterFinderComponent(AliHLTITSClusterFinderComponent::kClusterFinderSPD));
137 pHandler->AddComponent(new AliHLTITSClusterFinderComponent(AliHLTITSClusterFinderComponent::kClusterFinderSDD));
138 pHandler->AddComponent(new AliHLTITSClusterFinderComponent(AliHLTITSClusterFinderComponent::kClusterFinderSSD));
139 pHandler->AddComponent(new AliHLTITSClusterHistoComponent);
140 pHandler->AddComponent(new AliHLTITSTrackerComponent);
141 pHandler->AddComponent(new AliHLTITSVertexerSPDComponent);
146 AliHLTModulePreprocessor* AliHLTITSAgent::GetPreprocessor()
148 // see header file for class documentation
152 int AliHLTITSAgent::GetHandlerDescription(AliHLTComponentDataType dt,
154 AliHLTOUTHandlerDesc& desc) const
156 // see header file for class documentation
158 // Handlers for ITS raw data. Even though there are 3 detectors
159 // everything is handled in one module library and one HLTOUT handler.
160 // This assumes that the data blocks are sent with data type
161 // {DDL_RAW :ISDD} and the bit set in the specification corresponding.
162 // to detector DDL id.
163 // An HLTOUT handler is implemented to extract the equipment id from
164 // the specification.
165 // Note: Future versions of the framework will provide a default handler
166 // class with that functionality.
167 if (dt==(kAliHLTDataTypeDDLRaw|kAliHLTDataOriginITSSDD)) {
168 desc=AliHLTOUTHandlerDesc(kRawReader, dt, GetModuleId());
169 HLTInfo("module %s handles data block type %s specification %d (0x%x)",
170 GetModuleId(), AliHLTComponent::DataType2Text(dt).c_str(), spec, spec);
176 AliHLTOUTHandler* AliHLTITSAgent::GetOutputHandler(AliHLTComponentDataType dt,
177 AliHLTUInt32_t /*spec*/)
179 // see header file for class documentation
180 if (dt==(kAliHLTDataTypeDDLRaw|kAliHLTDataOriginITSSDD)) {
181 // use the default handler
182 if (!fRawDataHandler) {
183 fRawDataHandler=new AliHLTOUTSDDRawDataHandler;
185 return fRawDataHandler;
190 int AliHLTITSAgent::DeleteOutputHandler(AliHLTOUTHandler* pInstance)
192 // see header file for class documentation
193 if (pInstance==NULL) return -EINVAL;
195 if (pInstance==fRawDataHandler) {
196 delete fRawDataHandler;
197 fRawDataHandler=NULL;
205 int AliHLTITSAgent::AliHLTOUTSDDRawDataHandler::ProcessData(AliHLTOUT* pData)
207 // see header file for class documentation
208 if (!pData) return -EINVAL;
209 static int errorCount=0;
210 const int maxErrorCount=10;
211 AliHLTComponentDataType dt=kAliHLTVoidDataType;
212 AliHLTUInt32_t spec=kAliHLTVoidDataSpec;
213 int iResult=pData->GetDataBlockDescription(dt, spec);
215 if (dt==(kAliHLTDataTypeDDLRaw|kAliHLTDataOriginITSSDD)) {
216 int ddlOffset=256;//AliDAQ::DdlIDOffset("ITSSDD");
217 int numberOfDDLs=24;//AliDAQ::NumberOfDdls("ITSSDD");
219 for (;ddlNo<32 && ddlNo<numberOfDDLs; ddlNo++) {
220 if (spec&(0x1<<ddlNo)) break;
222 if (ddlNo>=32 || ddlNo>=numberOfDDLs) {
223 HLTError("invalid specification 0x%08x: can not extract DDL id for data block %s", spec, AliHLTComponent::DataType2Text(dt).c_str());
225 } else if (spec^(0x1<<ddlNo)) {
227 HLTError("multiple links set in specification 0x%08x: can not extract DDL id for data block %s", spec, AliHLTComponent::DataType2Text(dt).c_str());
229 iResult=ddlOffset+ddlNo;
232 if (errorCount++<10) {
233 HLTError("wrong data type: expecting %s, got %s; %s",
234 AliHLTComponent::DataType2Text(kAliHLTDataTypeDDLRaw|kAliHLTDataOriginITSSDD).c_str(),
235 AliHLTComponent::DataType2Text(dt).c_str(),
236 errorCount==maxErrorCount?"suppressing further error messages":"");
244 int AliHLTITSAgent::CreateCFConfigurations(AliHLTConfigurationHandler* pHandler, int detectorId, TString& output) const
246 // see header file for class documentation
247 if (!pHandler) return -EINVAL;
249 ///////////////////////////////////////////////////////////////////////////////////////////////////
251 // define the ITS cluster finder components
254 //The spec starts from 0x1 in SPD, SDD and SSD. So 0x1 is ddl 0 for SPD, 0x10 is ddl 1, and so on
255 //in SDD 0x1 is ddl 256, 0x10 is ddl 257, and so on. This means that the spec has to be set to 0x1
256 //before the loops over the clusterfinder
258 TString idString=AliHLTDAQ::DetectorName(detectorId);
259 if (idString.CompareTo("ITSSPD") &&
260 idString.CompareTo("ITSSDD") &&
261 idString.CompareTo("ITSSSD")) {
262 HLTError("invalid detector id %d does not describe any ITS detector", detectorId);
266 int minddl=AliHLTDAQ::DdlIDOffset(detectorId);
267 int maxddl=minddl+=AliHLTDAQ::NumberOfDdls(detectorId);
271 TString origin=idString; origin.ReplaceAll("ITS", "I");
272 TString cfBase=idString; cfBase+="_CF";
273 TString componentId=idString; componentId.ReplaceAll("ITS", "ITSClusterFinder");
274 for(ddlno=minddl;ddlno<=maxddl;ddlno++){
275 TString arg, publisher, cf;
277 // the HLT origin defines are 4 chars: ISPD, ISSD, ISDD respectively
278 arg.Form("-minid %d -datatype 'DDL_RAW ' '%s' -dataspec 0x%08x -verbose",ddlno, origin.Data(), spec);
279 publisher.Form("ITS-DP_%d", ddlno);
280 pHandler->CreateConfiguration(publisher.Data(), "AliRawReaderPublisher", NULL , arg.Data());
282 cf.Form("%s_%d",cfBase.Data(), ddlno);
283 pHandler->CreateConfiguration(cf.Data(), componentId.Data(), publisher.Data(), "");
285 if (output.Length()>0) output+=" ";