]>
Commit | Line | Data |
---|---|---|
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" |
68315dc4 | 29 | #include "AliHLTDAQ.h" |
dafa46c6 | 30 | |
31 | // header files of library components | |
32 | ||
33 | // header file of the module preprocessor | |
0c7d42ab | 34 | #include "AliHLTITSCompressRawDataSDDComponent.h" |
fd091d74 | 35 | #include "AliHLTITSSSDQARecPointsComponent.h" |
36 | #include "AliHLTITSQAComponent.h" | |
6b7742a2 | 37 | #include "AliHLTITSClusterFinderComponent.h" |
c0b68f8e | 38 | #include "AliHLTITSClusterHistoComponent.h" |
f2d22774 | 39 | #include "AliHLTITSTrackerComponent.h" |
7f167a74 | 40 | #include "AliHLTITSVertexerSPDComponent.h" |
618f422f | 41 | #include "AliHLTITSDigitPublisherComponent.h" |
dafa46c6 | 42 | |
dafa46c6 | 43 | /** global instance for agent registration */ |
44 | AliHLTITSAgent gAliHLTITSAgent; | |
45 | ||
46 | /** ROOT macro for the implementation of ROOT specific class methods */ | |
47 | ClassImp(AliHLTITSAgent) | |
48 | ||
49 | AliHLTITSAgent::AliHLTITSAgent() | |
50 | : | |
51 | AliHLTModuleAgent("ITS"), | |
52 | fRawDataHandler(NULL) | |
53 | { | |
54 | // see header file for class documentation | |
55 | // or | |
56 | // refer to README to build package | |
57 | // or | |
58 | // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt | |
59 | } | |
60 | ||
61 | AliHLTITSAgent::~AliHLTITSAgent() | |
62 | { | |
63 | // see header file for class documentation | |
64 | } | |
65 | ||
68315dc4 | 66 | int AliHLTITSAgent::CreateConfigurations(AliHLTConfigurationHandler* handler, |
7c6a3cd3 | 67 | AliRawReader* rawReader, |
68 | AliRunLoader* runloader) const | |
dafa46c6 | 69 | { |
70 | // see header file for class documentation | |
68315dc4 | 71 | int iResult=0; |
72 | if (!handler) return -EINVAL; | |
73 | ||
74 | /////////////////////////////////////////////////////////////////////////////////////////////////// | |
75 | /////////////////////////////////////////////////////////////////////////////////////////////////// | |
76 | // | |
77 | // ITS tracking is currently only working on raw data | |
78 | // to run on digits, a digit publisher needs to be implemented | |
7c6a3cd3 | 79 | |
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 | |
68315dc4 | 83 | |
84 | /////////////////////////////////////////////////////////////////////////////////////////////////// | |
85 | // | |
7c6a3cd3 | 86 | // define the ITS cluster finder configurations |
68315dc4 | 87 | // |
88 | ||
be2c9ca9 | 89 | TString spdCF; |
90 | TString ssdCF; | |
91 | TString sddCF; | |
92 | ||
93 | iResult=CreateCFConfigurations(handler, AliHLTDAQ::DetectorID("ITSSPD"), spdCF); | |
94 | handler->CreateConfiguration("ITS-SPD-CF","BlockFilter",spdCF.Data(),""); | |
95 | ||
96 | iResult=CreateCFConfigurations(handler, AliHLTDAQ::DetectorID("ITSSDD"), sddCF); | |
97 | handler->CreateConfiguration("ITS-SDD-CF","BlockFilter",sddCF.Data(),""); | |
98 | ||
99 | iResult=CreateCFConfigurations(handler, AliHLTDAQ::DetectorID("ITSSSD"), ssdCF); | |
100 | handler->CreateConfiguration("ITS-SSD-CF","BlockFilter",ssdCF.Data(),""); | |
101 | ||
102 | ||
103 | /////////////////////////////////////////////////////////////////////////////////////////////////// | |
104 | // | |
105 | // define the SPD vertexer Z configuration | |
106 | // | |
107 | handler->CreateConfiguration("ITS-SPD-vertexer","ITSVertexerSPD", "ITS-SPD-CF",""); | |
108 | ||
7c6a3cd3 | 109 | |
110 | /////////////////////////////////////////////////////////////////////////////////////////////////// | |
111 | // | |
112 | // define the ITS tracker configuration | |
113 | // | |
be2c9ca9 | 114 | TString trackerInput="ITS-SPD-CF ITS-SDD-CF ITS-SSD-CF"; |
115 | ||
68315dc4 | 116 | if (handler->FindConfiguration("TPC-globalmerger")) { |
117 | trackerInput+=" TPC-globalmerger"; | |
118 | } | |
119 | handler->CreateConfiguration("ITS-tracker","ITSTracker",trackerInput.Data(),""); | |
120 | } | |
dafa46c6 | 121 | return 0; |
122 | } | |
123 | ||
124 | const char* AliHLTITSAgent::GetReconstructionChains(AliRawReader* /*rawReader*/, | |
68315dc4 | 125 | AliRunLoader* runloader) const |
dafa46c6 | 126 | { |
127 | // see header file for class documentation | |
68315dc4 | 128 | if (runloader) { |
129 | // reconstruction chains for AliRoot simulation | |
130 | // Note: run loader is only available while running embedded into | |
131 | // AliRoot simulation | |
132 | ||
133 | // the chain is just defined and can be used as input for subsequent | |
134 | // components | |
135 | //return "ITS-tracker"; | |
136 | } | |
dafa46c6 | 137 | |
138 | return ""; | |
139 | } | |
140 | ||
141 | const char* AliHLTITSAgent::GetRequiredComponentLibraries() const | |
142 | { | |
143 | // see header file for class documentation | |
68315dc4 | 144 | return "libAliHLTUtil.so libAliHLTRCU.so libAliHLTTPC.so"; |
dafa46c6 | 145 | } |
146 | ||
147 | int AliHLTITSAgent::RegisterComponents(AliHLTComponentHandler* pHandler) const | |
148 | { | |
149 | // see header file for class documentation | |
150 | assert(pHandler); | |
151 | if (!pHandler) return -EINVAL; | |
0c7d42ab | 152 | pHandler->AddComponent(new AliHLTITSCompressRawDataSDDComponent); |
fd091d74 | 153 | pHandler->AddComponent(new AliHLTITSSSDQARecPointsComponent); |
154 | pHandler->AddComponent(new AliHLTITSQAComponent); | |
6b7742a2 | 155 | pHandler->AddComponent(new AliHLTITSClusterFinderComponent(AliHLTITSClusterFinderComponent::kClusterFinderSPD)); |
156 | pHandler->AddComponent(new AliHLTITSClusterFinderComponent(AliHLTITSClusterFinderComponent::kClusterFinderSDD)); | |
157 | pHandler->AddComponent(new AliHLTITSClusterFinderComponent(AliHLTITSClusterFinderComponent::kClusterFinderSSD)); | |
618f422f | 158 | pHandler->AddComponent(new AliHLTITSClusterFinderComponent(AliHLTITSClusterFinderComponent::kClusterFinderDigits)); |
c0b68f8e | 159 | pHandler->AddComponent(new AliHLTITSClusterHistoComponent); |
f2d22774 | 160 | pHandler->AddComponent(new AliHLTITSTrackerComponent); |
7f167a74 | 161 | pHandler->AddComponent(new AliHLTITSVertexerSPDComponent); |
618f422f | 162 | pHandler->AddComponent(new AliHLTITSDigitPublisherComponent); |
dafa46c6 | 163 | |
164 | return 0; | |
165 | } | |
166 | ||
167 | AliHLTModulePreprocessor* AliHLTITSAgent::GetPreprocessor() | |
168 | { | |
169 | // see header file for class documentation | |
170 | return NULL; | |
171 | } | |
172 | ||
173 | int AliHLTITSAgent::GetHandlerDescription(AliHLTComponentDataType dt, | |
174 | AliHLTUInt32_t spec, | |
175 | AliHLTOUTHandlerDesc& desc) const | |
176 | { | |
177 | // see header file for class documentation | |
178 | ||
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 | |
6b87e199 | 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)) { | |
dafa46c6 | 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); | |
192 | return 1; | |
193 | } | |
194 | return 0; | |
195 | } | |
196 | ||
197 | AliHLTOUTHandler* AliHLTITSAgent::GetOutputHandler(AliHLTComponentDataType dt, | |
198 | AliHLTUInt32_t /*spec*/) | |
199 | { | |
200 | // see header file for class documentation | |
6b87e199 | 201 | if (dt==(kAliHLTDataTypeDDLRaw|kAliHLTDataOriginITSSDD)) { |
dafa46c6 | 202 | // use the default handler |
203 | if (!fRawDataHandler) { | |
6b87e199 | 204 | fRawDataHandler=new AliHLTOUTSDDRawDataHandler; |
dafa46c6 | 205 | } |
206 | return fRawDataHandler; | |
207 | } | |
208 | return NULL; | |
209 | } | |
210 | ||
211 | int AliHLTITSAgent::DeleteOutputHandler(AliHLTOUTHandler* pInstance) | |
212 | { | |
213 | // see header file for class documentation | |
214 | if (pInstance==NULL) return -EINVAL; | |
215 | ||
216 | if (pInstance==fRawDataHandler) { | |
217 | delete fRawDataHandler; | |
218 | fRawDataHandler=NULL; | |
219 | return 0; | |
220 | } | |
221 | ||
222 | delete pInstance; | |
223 | return 0; | |
224 | } | |
6b87e199 | 225 | |
226 | int AliHLTITSAgent::AliHLTOUTSDDRawDataHandler::ProcessData(AliHLTOUT* pData) | |
227 | { | |
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); | |
235 | if (iResult>=0) { | |
236 | if (dt==(kAliHLTDataTypeDDLRaw|kAliHLTDataOriginITSSDD)) { | |
237 | int ddlOffset=256;//AliDAQ::DdlIDOffset("ITSSDD"); | |
238 | int numberOfDDLs=24;//AliDAQ::NumberOfDdls("ITSSDD"); | |
239 | int ddlNo=0; | |
240 | for (;ddlNo<32 && ddlNo<numberOfDDLs; ddlNo++) { | |
241 | if (spec&(0x1<<ddlNo)) break; | |
242 | } | |
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()); | |
245 | iResult=-ENODEV; | |
246 | } else if (spec^(0x1<<ddlNo)) { | |
247 | iResult=-EEXIST; | |
248 | HLTError("multiple links set in specification 0x%08x: can not extract DDL id for data block %s", spec, AliHLTComponent::DataType2Text(dt).c_str()); | |
249 | } else { | |
250 | iResult=ddlOffset+ddlNo; | |
251 | } | |
252 | } else { | |
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":""); | |
258 | } | |
259 | iResult=-EFAULT; | |
260 | } | |
261 | } | |
262 | return iResult; | |
263 | } | |
68315dc4 | 264 | |
265 | int AliHLTITSAgent::CreateCFConfigurations(AliHLTConfigurationHandler* pHandler, int detectorId, TString& output) const | |
266 | { | |
267 | // see header file for class documentation | |
268 | if (!pHandler) return -EINVAL; | |
269 | ||
270 | /////////////////////////////////////////////////////////////////////////////////////////////////// | |
271 | // | |
272 | // define the ITS cluster finder components | |
273 | // | |
274 | ||
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 | |
278 | ||
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); | |
284 | return -ENOENT; | |
285 | } | |
286 | ||
287 | int minddl=AliHLTDAQ::DdlIDOffset(detectorId); | |
be2c9ca9 | 288 | int maxddl=minddl+AliHLTDAQ::NumberOfDdls(detectorId)-1; |
68315dc4 | 289 | int spec=0x1; |
290 | int ddlno=0; | |
291 | ||
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; | |
297 | ||
298 | // the HLT origin defines are 4 chars: ISPD, ISSD, ISDD respectively | |
3b407ff1 | 299 | arg.Form("-minid %d -datatype 'DDL_RAW ' '%s' -dataspec 0x%08x",ddlno, origin.Data(), spec); |
300 | if (CheckFilter(kHLTLogDebug)) arg+=" -verbose"; | |
68315dc4 | 301 | publisher.Form("ITS-DP_%d", ddlno); |
302 | pHandler->CreateConfiguration(publisher.Data(), "AliRawReaderPublisher", NULL , arg.Data()); | |
303 | ||
304 | cf.Form("%s_%d",cfBase.Data(), ddlno); | |
305 | pHandler->CreateConfiguration(cf.Data(), componentId.Data(), publisher.Data(), ""); | |
306 | ||
307 | if (output.Length()>0) output+=" "; | |
308 | output+=cf; | |
309 | ||
310 | spec=spec<<1; | |
311 | } | |
312 | ||
313 | return 0; | |
314 | } |