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