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