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