]>
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 | ||
513cc3dd | 19 | // @file AliHLTITSAgent.cxx |
20 | // @author Matthias Richter | |
21 | // @date 25.08.2008 | |
22 | // @brief Agent of the libAliHLTITS library | |
23 | // @note | |
dafa46c6 | 24 | |
25 | #include <cassert> | |
26 | #include "AliHLTITSAgent.h" | |
6b87e199 | 27 | #include "AliHLTOUT.h" |
68315dc4 | 28 | #include "AliHLTDAQ.h" |
dafa46c6 | 29 | |
30 | // header files of library components | |
0c7d42ab | 31 | #include "AliHLTITSCompressRawDataSDDComponent.h" |
fd091d74 | 32 | #include "AliHLTITSSSDQARecPointsComponent.h" |
33 | #include "AliHLTITSQAComponent.h" | |
6b7742a2 | 34 | #include "AliHLTITSClusterFinderComponent.h" |
c0b68f8e | 35 | #include "AliHLTITSClusterHistoComponent.h" |
f2d22774 | 36 | #include "AliHLTITSTrackerComponent.h" |
7f167a74 | 37 | #include "AliHLTITSVertexerSPDComponent.h" |
618f422f | 38 | #include "AliHLTITSDigitPublisherComponent.h" |
dafa46c6 | 39 | |
513cc3dd | 40 | // header file of the module preprocessor |
41 | // none at the moment | |
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 | |
513cc3dd | 80 | TString trackerInput=""; |
81 | TString vertexerSPDInput=""; | |
7c6a3cd3 | 82 | if (rawReader || !runloader) { |
83 | // AliSimulation: use the AliRawReaderPublisher if the raw reader is available | |
84 | // Alireconstruction: indicated by runloader==NULL, run always on raw data | |
68315dc4 | 85 | |
86 | /////////////////////////////////////////////////////////////////////////////////////////////////// | |
87 | // | |
7c6a3cd3 | 88 | // define the ITS cluster finder configurations |
68315dc4 | 89 | // |
90 | ||
be2c9ca9 | 91 | TString spdCF; |
92 | TString ssdCF; | |
93 | TString sddCF; | |
94 | ||
95 | iResult=CreateCFConfigurations(handler, AliHLTDAQ::DetectorID("ITSSPD"), spdCF); | |
96 | handler->CreateConfiguration("ITS-SPD-CF","BlockFilter",spdCF.Data(),""); | |
97 | ||
98 | iResult=CreateCFConfigurations(handler, AliHLTDAQ::DetectorID("ITSSDD"), sddCF); | |
99 | handler->CreateConfiguration("ITS-SDD-CF","BlockFilter",sddCF.Data(),""); | |
100 | ||
101 | iResult=CreateCFConfigurations(handler, AliHLTDAQ::DetectorID("ITSSSD"), ssdCF); | |
102 | handler->CreateConfiguration("ITS-SSD-CF","BlockFilter",ssdCF.Data(),""); | |
103 | ||
104 | ||
105 | /////////////////////////////////////////////////////////////////////////////////////////////////// | |
106 | // | |
513cc3dd | 107 | // define the SPD vertexer Z input |
be2c9ca9 | 108 | // |
513cc3dd | 109 | vertexerSPDInput="ITS-SPD-CF"; |
7c6a3cd3 | 110 | |
111 | /////////////////////////////////////////////////////////////////////////////////////////////////// | |
112 | // | |
513cc3dd | 113 | // define the ITS tracker input |
7c6a3cd3 | 114 | // |
513cc3dd | 115 | trackerInput="ITS-SPD-CF ITS-SDD-CF ITS-SSD-CF"; |
116 | } | |
117 | else if (runloader && !rawReader) { | |
118 | // indicates AliSimulation with no RawReader available -> run on digits | |
be2c9ca9 | 119 | |
513cc3dd | 120 | /////////////////////////////////////////////////////////////////////////////////////////////////// |
121 | // | |
122 | // define the Digit Publisher and ITS cluster finder configuration | |
123 | // | |
124 | handler->CreateConfiguration("DigitPublisher","AliLoaderPublisher",NULL,"-loader ITSLoader -datatype 'ALITREED' 'ITS '"); | |
125 | handler->CreateConfiguration("DigitClusterFinder","ITSClusterFinderDigits","DigitPublisher",""); | |
126 | ||
127 | /////////////////////////////////////////////////////////////////////////////////////////////////// | |
128 | // | |
129 | // define the SPD vertexer Z input. | |
130 | // | |
131 | // Can not run on Digit ClusterFinder. Wrong inputtype. And wrong input data. | |
132 | // If this is fixed in the VertexerSPD it needs to implement the data type | |
133 | // handling for the ITS digits and ignore the input from the SDD and SSD | |
134 | //vertexerSPDInput="DigitClusterFinder"; | |
135 | ||
136 | /////////////////////////////////////////////////////////////////////////////////////////////////// | |
137 | // | |
138 | // define the ITS tracker input | |
139 | // | |
140 | // Currently there is a seg fault in the TTree access from the DigitClusterFinder | |
141 | // needs first to be investigated | |
db8932b0 | 142 | trackerInput="DigitClusterFinder"; |
513cc3dd | 143 | } |
144 | ||
145 | /////////////////////////////////////////////////////////////////////////////////////////////////// | |
146 | // | |
147 | // define the SPD vertexer Z configuration | |
148 | // | |
149 | if (!vertexerSPDInput.IsNull()) { | |
150 | handler->CreateConfiguration("ITS-SPD-vertexer","ITSVertexerSPD", vertexerSPDInput, ""); | |
151 | } | |
152 | ||
153 | /////////////////////////////////////////////////////////////////////////////////////////////////// | |
154 | // | |
155 | // define the ITS tracker configuration | |
156 | // | |
157 | if (!trackerInput.IsNull()) { | |
68315dc4 | 158 | if (handler->FindConfiguration("TPC-globalmerger")) { |
513cc3dd | 159 | // add the TPC tracking if available |
68315dc4 | 160 | trackerInput+=" TPC-globalmerger"; |
161 | } | |
d72d9d99 | 162 | if (handler->FindConfiguration("TPC-mcTrackMarker")) { |
163 | // add the TPC tracking if available | |
164 | trackerInput+=" TPC-mcTrackMarker"; | |
165 | } | |
68315dc4 | 166 | handler->CreateConfiguration("ITS-tracker","ITSTracker",trackerInput.Data(),""); |
167 | } | |
513cc3dd | 168 | |
75e6d9eb | 169 | return iResult; |
dafa46c6 | 170 | } |
171 | ||
172 | const char* AliHLTITSAgent::GetReconstructionChains(AliRawReader* /*rawReader*/, | |
68315dc4 | 173 | AliRunLoader* runloader) const |
dafa46c6 | 174 | { |
175 | // see header file for class documentation | |
68315dc4 | 176 | if (runloader) { |
177 | // reconstruction chains for AliRoot simulation | |
178 | // Note: run loader is only available while running embedded into | |
179 | // AliRoot simulation | |
180 | ||
181 | // the chain is just defined and can be used as input for subsequent | |
182 | // components | |
183 | //return "ITS-tracker"; | |
184 | } | |
dafa46c6 | 185 | |
186 | return ""; | |
187 | } | |
188 | ||
189 | const char* AliHLTITSAgent::GetRequiredComponentLibraries() const | |
190 | { | |
191 | // see header file for class documentation | |
68315dc4 | 192 | return "libAliHLTUtil.so libAliHLTRCU.so libAliHLTTPC.so"; |
dafa46c6 | 193 | } |
194 | ||
195 | int AliHLTITSAgent::RegisterComponents(AliHLTComponentHandler* pHandler) const | |
196 | { | |
197 | // see header file for class documentation | |
198 | assert(pHandler); | |
199 | if (!pHandler) return -EINVAL; | |
0c7d42ab | 200 | pHandler->AddComponent(new AliHLTITSCompressRawDataSDDComponent); |
fd091d74 | 201 | pHandler->AddComponent(new AliHLTITSSSDQARecPointsComponent); |
202 | pHandler->AddComponent(new AliHLTITSQAComponent); | |
6b7742a2 | 203 | pHandler->AddComponent(new AliHLTITSClusterFinderComponent(AliHLTITSClusterFinderComponent::kClusterFinderSPD)); |
204 | pHandler->AddComponent(new AliHLTITSClusterFinderComponent(AliHLTITSClusterFinderComponent::kClusterFinderSDD)); | |
205 | pHandler->AddComponent(new AliHLTITSClusterFinderComponent(AliHLTITSClusterFinderComponent::kClusterFinderSSD)); | |
618f422f | 206 | pHandler->AddComponent(new AliHLTITSClusterFinderComponent(AliHLTITSClusterFinderComponent::kClusterFinderDigits)); |
c0b68f8e | 207 | pHandler->AddComponent(new AliHLTITSClusterHistoComponent); |
f2d22774 | 208 | pHandler->AddComponent(new AliHLTITSTrackerComponent); |
7f167a74 | 209 | pHandler->AddComponent(new AliHLTITSVertexerSPDComponent); |
618f422f | 210 | pHandler->AddComponent(new AliHLTITSDigitPublisherComponent); |
dafa46c6 | 211 | |
212 | return 0; | |
213 | } | |
214 | ||
215 | AliHLTModulePreprocessor* AliHLTITSAgent::GetPreprocessor() | |
216 | { | |
217 | // see header file for class documentation | |
218 | return NULL; | |
219 | } | |
220 | ||
221 | int AliHLTITSAgent::GetHandlerDescription(AliHLTComponentDataType dt, | |
222 | AliHLTUInt32_t spec, | |
223 | AliHLTOUTHandlerDesc& desc) const | |
224 | { | |
225 | // see header file for class documentation | |
226 | ||
227 | // Handlers for ITS raw data. Even though there are 3 detectors | |
228 | // everything is handled in one module library and one HLTOUT handler. | |
229 | // This assumes that the data blocks are sent with data type | |
6b87e199 | 230 | // {DDL_RAW :ISDD} and the bit set in the specification corresponding. |
231 | // to detector DDL id. | |
232 | // An HLTOUT handler is implemented to extract the equipment id from | |
233 | // the specification. | |
234 | // Note: Future versions of the framework will provide a default handler | |
235 | // class with that functionality. | |
236 | if (dt==(kAliHLTDataTypeDDLRaw|kAliHLTDataOriginITSSDD)) { | |
dafa46c6 | 237 | desc=AliHLTOUTHandlerDesc(kRawReader, dt, GetModuleId()); |
238 | HLTInfo("module %s handles data block type %s specification %d (0x%x)", | |
239 | GetModuleId(), AliHLTComponent::DataType2Text(dt).c_str(), spec, spec); | |
240 | return 1; | |
241 | } | |
242 | return 0; | |
243 | } | |
244 | ||
245 | AliHLTOUTHandler* AliHLTITSAgent::GetOutputHandler(AliHLTComponentDataType dt, | |
246 | AliHLTUInt32_t /*spec*/) | |
247 | { | |
248 | // see header file for class documentation | |
6b87e199 | 249 | if (dt==(kAliHLTDataTypeDDLRaw|kAliHLTDataOriginITSSDD)) { |
dafa46c6 | 250 | // use the default handler |
251 | if (!fRawDataHandler) { | |
6b87e199 | 252 | fRawDataHandler=new AliHLTOUTSDDRawDataHandler; |
dafa46c6 | 253 | } |
254 | return fRawDataHandler; | |
255 | } | |
256 | return NULL; | |
257 | } | |
258 | ||
259 | int AliHLTITSAgent::DeleteOutputHandler(AliHLTOUTHandler* pInstance) | |
260 | { | |
261 | // see header file for class documentation | |
262 | if (pInstance==NULL) return -EINVAL; | |
263 | ||
264 | if (pInstance==fRawDataHandler) { | |
265 | delete fRawDataHandler; | |
266 | fRawDataHandler=NULL; | |
267 | return 0; | |
268 | } | |
269 | ||
270 | delete pInstance; | |
271 | return 0; | |
272 | } | |
6b87e199 | 273 | |
274 | int AliHLTITSAgent::AliHLTOUTSDDRawDataHandler::ProcessData(AliHLTOUT* pData) | |
275 | { | |
276 | // see header file for class documentation | |
277 | if (!pData) return -EINVAL; | |
278 | static int errorCount=0; | |
279 | const int maxErrorCount=10; | |
280 | AliHLTComponentDataType dt=kAliHLTVoidDataType; | |
281 | AliHLTUInt32_t spec=kAliHLTVoidDataSpec; | |
282 | int iResult=pData->GetDataBlockDescription(dt, spec); | |
283 | if (iResult>=0) { | |
284 | if (dt==(kAliHLTDataTypeDDLRaw|kAliHLTDataOriginITSSDD)) { | |
285 | int ddlOffset=256;//AliDAQ::DdlIDOffset("ITSSDD"); | |
286 | int numberOfDDLs=24;//AliDAQ::NumberOfDdls("ITSSDD"); | |
287 | int ddlNo=0; | |
288 | for (;ddlNo<32 && ddlNo<numberOfDDLs; ddlNo++) { | |
289 | if (spec&(0x1<<ddlNo)) break; | |
290 | } | |
291 | if (ddlNo>=32 || ddlNo>=numberOfDDLs) { | |
292 | HLTError("invalid specification 0x%08x: can not extract DDL id for data block %s", spec, AliHLTComponent::DataType2Text(dt).c_str()); | |
293 | iResult=-ENODEV; | |
294 | } else if (spec^(0x1<<ddlNo)) { | |
295 | iResult=-EEXIST; | |
296 | HLTError("multiple links set in specification 0x%08x: can not extract DDL id for data block %s", spec, AliHLTComponent::DataType2Text(dt).c_str()); | |
297 | } else { | |
298 | iResult=ddlOffset+ddlNo; | |
299 | } | |
300 | } else { | |
301 | if (errorCount++<10) { | |
302 | HLTError("wrong data type: expecting %s, got %s; %s", | |
303 | AliHLTComponent::DataType2Text(kAliHLTDataTypeDDLRaw|kAliHLTDataOriginITSSDD).c_str(), | |
304 | AliHLTComponent::DataType2Text(dt).c_str(), | |
305 | errorCount==maxErrorCount?"suppressing further error messages":""); | |
306 | } | |
307 | iResult=-EFAULT; | |
308 | } | |
309 | } | |
310 | return iResult; | |
311 | } | |
68315dc4 | 312 | |
313 | int AliHLTITSAgent::CreateCFConfigurations(AliHLTConfigurationHandler* pHandler, int detectorId, TString& output) const | |
314 | { | |
315 | // see header file for class documentation | |
316 | if (!pHandler) return -EINVAL; | |
317 | ||
318 | /////////////////////////////////////////////////////////////////////////////////////////////////// | |
319 | // | |
320 | // define the ITS cluster finder components | |
321 | // | |
322 | ||
323 | //The spec starts from 0x1 in SPD, SDD and SSD. So 0x1 is ddl 0 for SPD, 0x10 is ddl 1, and so on | |
324 | //in SDD 0x1 is ddl 256, 0x10 is ddl 257, and so on. This means that the spec has to be set to 0x1 | |
325 | //before the loops over the clusterfinder | |
326 | ||
327 | TString idString=AliHLTDAQ::DetectorName(detectorId); | |
328 | if (idString.CompareTo("ITSSPD") && | |
329 | idString.CompareTo("ITSSDD") && | |
330 | idString.CompareTo("ITSSSD")) { | |
331 | HLTError("invalid detector id %d does not describe any ITS detector", detectorId); | |
332 | return -ENOENT; | |
333 | } | |
334 | ||
335 | int minddl=AliHLTDAQ::DdlIDOffset(detectorId); | |
be2c9ca9 | 336 | int maxddl=minddl+AliHLTDAQ::NumberOfDdls(detectorId)-1; |
68315dc4 | 337 | int spec=0x1; |
338 | int ddlno=0; | |
339 | ||
c40835d0 | 340 | // this is a simple switch for experimenting with different configurations |
341 | // it's supposed to be false for normal compilation | |
513cc3dd | 342 | bool bOneCFperDDL=false; |
68315dc4 | 343 | TString origin=idString; origin.ReplaceAll("ITS", "I"); |
344 | TString cfBase=idString; cfBase+="_CF"; | |
345 | TString componentId=idString; componentId.ReplaceAll("ITS", "ITSClusterFinder"); | |
513cc3dd | 346 | TString cfinput, cf; |
68315dc4 | 347 | for(ddlno=minddl;ddlno<=maxddl;ddlno++){ |
513cc3dd | 348 | TString arg, publisher; |
68315dc4 | 349 | |
350 | // the HLT origin defines are 4 chars: ISPD, ISSD, ISDD respectively | |
3b407ff1 | 351 | arg.Form("-minid %d -datatype 'DDL_RAW ' '%s' -dataspec 0x%08x",ddlno, origin.Data(), spec); |
352 | if (CheckFilter(kHLTLogDebug)) arg+=" -verbose"; | |
68315dc4 | 353 | publisher.Form("ITS-DP_%d", ddlno); |
354 | pHandler->CreateConfiguration(publisher.Data(), "AliRawReaderPublisher", NULL , arg.Data()); | |
355 | ||
513cc3dd | 356 | if (cfinput.Length()>0) cfinput+=" "; |
357 | cfinput+=publisher; | |
358 | ||
359 | if (bOneCFperDDL) { | |
68315dc4 | 360 | cf.Form("%s_%d",cfBase.Data(), ddlno); |
361 | pHandler->CreateConfiguration(cf.Data(), componentId.Data(), publisher.Data(), ""); | |
362 | ||
363 | if (output.Length()>0) output+=" "; | |
364 | output+=cf; | |
513cc3dd | 365 | } |
68315dc4 | 366 | |
367 | spec=spec<<1; | |
368 | } | |
513cc3dd | 369 | |
fbfc5415 | 370 | if (!bOneCFperDDL) { |
513cc3dd | 371 | cf.Form("%s",cfBase.Data()); |
372 | pHandler->CreateConfiguration(cf.Data(), componentId.Data(), cfinput.Data(), ""); | |
373 | ||
374 | if (output.Length()>0) output+=" "; | |
375 | output+=cf; | |
376 | } | |
68315dc4 | 377 | |
378 | return 0; | |
379 | } |