]>
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" |
dafa46c6 | 41 | |
dafa46c6 | 42 | /** global instance for agent registration */ |
43 | AliHLTITSAgent gAliHLTITSAgent; | |
44 | ||
45 | /** ROOT macro for the implementation of ROOT specific class methods */ | |
46 | ClassImp(AliHLTITSAgent) | |
47 | ||
48 | AliHLTITSAgent::AliHLTITSAgent() | |
49 | : | |
50 | AliHLTModuleAgent("ITS"), | |
51 | fRawDataHandler(NULL) | |
52 | { | |
53 | // see header file for class documentation | |
54 | // or | |
55 | // refer to README to build package | |
56 | // or | |
57 | // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt | |
58 | } | |
59 | ||
60 | AliHLTITSAgent::~AliHLTITSAgent() | |
61 | { | |
62 | // see header file for class documentation | |
63 | } | |
64 | ||
68315dc4 | 65 | int AliHLTITSAgent::CreateConfigurations(AliHLTConfigurationHandler* handler, |
7c6a3cd3 | 66 | AliRawReader* rawReader, |
67 | AliRunLoader* runloader) const | |
dafa46c6 | 68 | { |
69 | // see header file for class documentation | |
68315dc4 | 70 | int iResult=0; |
71 | if (!handler) return -EINVAL; | |
72 | ||
73 | /////////////////////////////////////////////////////////////////////////////////////////////////// | |
74 | /////////////////////////////////////////////////////////////////////////////////////////////////// | |
75 | // | |
76 | // ITS tracking is currently only working on raw data | |
77 | // to run on digits, a digit publisher needs to be implemented | |
7c6a3cd3 | 78 | |
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 | |
68315dc4 | 82 | |
83 | /////////////////////////////////////////////////////////////////////////////////////////////////// | |
84 | // | |
7c6a3cd3 | 85 | // define the ITS cluster finder configurations |
68315dc4 | 86 | // |
87 | ||
88 | TString trackerInput; | |
89 | for (int detectorId=0; detectorId<3; detectorId++) { | |
90 | iResult=CreateCFConfigurations(handler, detectorId, trackerInput); | |
91 | } | |
7c6a3cd3 | 92 | |
93 | /////////////////////////////////////////////////////////////////////////////////////////////////// | |
94 | // | |
95 | // define the ITS tracker configuration | |
96 | // | |
68315dc4 | 97 | if (handler->FindConfiguration("TPC-globalmerger")) { |
98 | trackerInput+=" TPC-globalmerger"; | |
99 | } | |
100 | handler->CreateConfiguration("ITS-tracker","ITSTracker",trackerInput.Data(),""); | |
101 | } | |
dafa46c6 | 102 | return 0; |
103 | } | |
104 | ||
105 | const char* AliHLTITSAgent::GetReconstructionChains(AliRawReader* /*rawReader*/, | |
68315dc4 | 106 | AliRunLoader* runloader) const |
dafa46c6 | 107 | { |
108 | // see header file for class documentation | |
68315dc4 | 109 | if (runloader) { |
110 | // reconstruction chains for AliRoot simulation | |
111 | // Note: run loader is only available while running embedded into | |
112 | // AliRoot simulation | |
113 | ||
114 | // the chain is just defined and can be used as input for subsequent | |
115 | // components | |
116 | //return "ITS-tracker"; | |
117 | } | |
dafa46c6 | 118 | |
119 | return ""; | |
120 | } | |
121 | ||
122 | const char* AliHLTITSAgent::GetRequiredComponentLibraries() const | |
123 | { | |
124 | // see header file for class documentation | |
68315dc4 | 125 | return "libAliHLTUtil.so libAliHLTRCU.so libAliHLTTPC.so"; |
dafa46c6 | 126 | } |
127 | ||
128 | int AliHLTITSAgent::RegisterComponents(AliHLTComponentHandler* pHandler) const | |
129 | { | |
130 | // see header file for class documentation | |
131 | assert(pHandler); | |
132 | if (!pHandler) return -EINVAL; | |
0c7d42ab | 133 | pHandler->AddComponent(new AliHLTITSCompressRawDataSDDComponent); |
fd091d74 | 134 | pHandler->AddComponent(new AliHLTITSSSDQARecPointsComponent); |
135 | pHandler->AddComponent(new AliHLTITSQAComponent); | |
6b7742a2 | 136 | pHandler->AddComponent(new AliHLTITSClusterFinderComponent(AliHLTITSClusterFinderComponent::kClusterFinderSPD)); |
137 | pHandler->AddComponent(new AliHLTITSClusterFinderComponent(AliHLTITSClusterFinderComponent::kClusterFinderSDD)); | |
138 | pHandler->AddComponent(new AliHLTITSClusterFinderComponent(AliHLTITSClusterFinderComponent::kClusterFinderSSD)); | |
c0b68f8e | 139 | pHandler->AddComponent(new AliHLTITSClusterHistoComponent); |
f2d22774 | 140 | pHandler->AddComponent(new AliHLTITSTrackerComponent); |
7f167a74 | 141 | pHandler->AddComponent(new AliHLTITSVertexerSPDComponent); |
dafa46c6 | 142 | |
143 | return 0; | |
144 | } | |
145 | ||
146 | AliHLTModulePreprocessor* AliHLTITSAgent::GetPreprocessor() | |
147 | { | |
148 | // see header file for class documentation | |
149 | return NULL; | |
150 | } | |
151 | ||
152 | int AliHLTITSAgent::GetHandlerDescription(AliHLTComponentDataType dt, | |
153 | AliHLTUInt32_t spec, | |
154 | AliHLTOUTHandlerDesc& desc) const | |
155 | { | |
156 | // see header file for class documentation | |
157 | ||
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 | |
6b87e199 | 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)) { | |
dafa46c6 | 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); | |
171 | return 1; | |
172 | } | |
173 | return 0; | |
174 | } | |
175 | ||
176 | AliHLTOUTHandler* AliHLTITSAgent::GetOutputHandler(AliHLTComponentDataType dt, | |
177 | AliHLTUInt32_t /*spec*/) | |
178 | { | |
179 | // see header file for class documentation | |
6b87e199 | 180 | if (dt==(kAliHLTDataTypeDDLRaw|kAliHLTDataOriginITSSDD)) { |
dafa46c6 | 181 | // use the default handler |
182 | if (!fRawDataHandler) { | |
6b87e199 | 183 | fRawDataHandler=new AliHLTOUTSDDRawDataHandler; |
dafa46c6 | 184 | } |
185 | return fRawDataHandler; | |
186 | } | |
187 | return NULL; | |
188 | } | |
189 | ||
190 | int AliHLTITSAgent::DeleteOutputHandler(AliHLTOUTHandler* pInstance) | |
191 | { | |
192 | // see header file for class documentation | |
193 | if (pInstance==NULL) return -EINVAL; | |
194 | ||
195 | if (pInstance==fRawDataHandler) { | |
196 | delete fRawDataHandler; | |
197 | fRawDataHandler=NULL; | |
198 | return 0; | |
199 | } | |
200 | ||
201 | delete pInstance; | |
202 | return 0; | |
203 | } | |
6b87e199 | 204 | |
205 | int AliHLTITSAgent::AliHLTOUTSDDRawDataHandler::ProcessData(AliHLTOUT* pData) | |
206 | { | |
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); | |
214 | if (iResult>=0) { | |
215 | if (dt==(kAliHLTDataTypeDDLRaw|kAliHLTDataOriginITSSDD)) { | |
216 | int ddlOffset=256;//AliDAQ::DdlIDOffset("ITSSDD"); | |
217 | int numberOfDDLs=24;//AliDAQ::NumberOfDdls("ITSSDD"); | |
218 | int ddlNo=0; | |
219 | for (;ddlNo<32 && ddlNo<numberOfDDLs; ddlNo++) { | |
220 | if (spec&(0x1<<ddlNo)) break; | |
221 | } | |
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()); | |
224 | iResult=-ENODEV; | |
225 | } else if (spec^(0x1<<ddlNo)) { | |
226 | iResult=-EEXIST; | |
227 | HLTError("multiple links set in specification 0x%08x: can not extract DDL id for data block %s", spec, AliHLTComponent::DataType2Text(dt).c_str()); | |
228 | } else { | |
229 | iResult=ddlOffset+ddlNo; | |
230 | } | |
231 | } else { | |
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":""); | |
237 | } | |
238 | iResult=-EFAULT; | |
239 | } | |
240 | } | |
241 | return iResult; | |
242 | } | |
68315dc4 | 243 | |
244 | int AliHLTITSAgent::CreateCFConfigurations(AliHLTConfigurationHandler* pHandler, int detectorId, TString& output) const | |
245 | { | |
246 | // see header file for class documentation | |
247 | if (!pHandler) return -EINVAL; | |
248 | ||
249 | /////////////////////////////////////////////////////////////////////////////////////////////////// | |
250 | // | |
251 | // define the ITS cluster finder components | |
252 | // | |
253 | ||
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 | |
257 | ||
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); | |
263 | return -ENOENT; | |
264 | } | |
265 | ||
266 | int minddl=AliHLTDAQ::DdlIDOffset(detectorId); | |
267 | int maxddl=minddl+=AliHLTDAQ::NumberOfDdls(detectorId); | |
268 | int spec=0x1; | |
269 | int ddlno=0; | |
270 | ||
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; | |
276 | ||
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()); | |
281 | ||
282 | cf.Form("%s_%d",cfBase.Data(), ddlno); | |
283 | pHandler->CreateConfiguration(cf.Data(), componentId.Data(), publisher.Data(), ""); | |
284 | ||
285 | if (output.Length()>0) output+=" "; | |
286 | output+=cf; | |
287 | ||
288 | spec=spec<<1; | |
289 | } | |
290 | ||
291 | return 0; | |
292 | } |