3 //**************************************************************************
4 //* This file is property of and copyright by the ALICE HLT Project *
5 //* ALICE Experiment at CERN, All rights reserved. *
7 //* Primary Authors: Matthias Richter <Matthias.Richter@ift.uib.no> *
8 //* for The ALICE HLT Project. *
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 //**************************************************************************
19 // @file AliHLTITSAgent.cxx
20 // @author Matthias Richter
22 // @brief Agent of the libAliHLTITS library
26 #include "AliHLTITSAgent.h"
27 #include "AliHLTOUT.h"
28 #include "AliHLTDAQ.h"
30 // header files of library components
31 #include "AliHLTITSCompressRawDataSDDComponent.h"
32 #include "AliHLTITSSSDQARecPointsComponent.h"
33 #include "AliHLTITSQAComponent.h"
34 #include "AliHLTITSClusterFinderComponent.h"
35 #include "AliHLTITSClusterHistoComponent.h"
36 #include "AliHLTITSTrackerComponent.h"
37 #include "AliHLTITSVertexerSPDComponent.h"
38 #include "AliHLTITSDigitPublisherComponent.h"
40 // header file of the module preprocessor
43 /** global instance for agent registration */
44 AliHLTITSAgent gAliHLTITSAgent;
46 /** ROOT macro for the implementation of ROOT specific class methods */
47 ClassImp(AliHLTITSAgent)
49 AliHLTITSAgent::AliHLTITSAgent()
51 AliHLTModuleAgent("ITS"),
54 // see header file for class documentation
56 // refer to README to build package
58 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
61 AliHLTITSAgent::~AliHLTITSAgent()
63 // see header file for class documentation
66 int AliHLTITSAgent::CreateConfigurations(AliHLTConfigurationHandler* handler,
67 AliRawReader* rawReader,
68 AliRunLoader* runloader) const
70 // see header file for class documentation
72 if (!handler) return -EINVAL;
74 ///////////////////////////////////////////////////////////////////////////////////////////////////
75 ///////////////////////////////////////////////////////////////////////////////////////////////////
77 // ITS tracking is currently only working on raw data
78 // to run on digits, a digit publisher needs to be implemented
80 TString trackerInput="";
81 TString vertexerSPDInput="";
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
86 ///////////////////////////////////////////////////////////////////////////////////////////////////
88 // define the ITS cluster finder configurations
95 iResult=CreateCFConfigurations(handler, AliHLTDAQ::DetectorID("ITSSPD"), spdCF);
96 handler->CreateConfiguration("ITS-SPD-CF","BlockFilter",spdCF.Data(),"");
98 iResult=CreateCFConfigurations(handler, AliHLTDAQ::DetectorID("ITSSDD"), sddCF);
99 handler->CreateConfiguration("ITS-SDD-CF","BlockFilter",sddCF.Data(),"");
101 iResult=CreateCFConfigurations(handler, AliHLTDAQ::DetectorID("ITSSSD"), ssdCF);
102 handler->CreateConfiguration("ITS-SSD-CF","BlockFilter",ssdCF.Data(),"");
105 ///////////////////////////////////////////////////////////////////////////////////////////////////
107 // define the SPD vertexer Z input
109 vertexerSPDInput="ITS-SPD-CF";
111 ///////////////////////////////////////////////////////////////////////////////////////////////////
113 // define the ITS tracker input
115 trackerInput="ITS-SPD-CF ITS-SDD-CF ITS-SSD-CF";
117 else if (runloader && !rawReader) {
118 // indicates AliSimulation with no RawReader available -> run on digits
120 ///////////////////////////////////////////////////////////////////////////////////////////////////
122 // define the Digit Publisher and ITS cluster finder configuration
124 handler->CreateConfiguration("DigitPublisher","AliLoaderPublisher",NULL,"-loader ITSLoader -datatype 'ALITREED' 'ITS '");
125 handler->CreateConfiguration("DigitClusterFinder","ITSClusterFinderDigits","DigitPublisher","");
127 ///////////////////////////////////////////////////////////////////////////////////////////////////
129 // define the SPD vertexer Z input.
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";
136 ///////////////////////////////////////////////////////////////////////////////////////////////////
138 // define the ITS tracker input
140 // Currently there is a seg fault in the TTree access from the DigitClusterFinder
141 // needs first to be investigated
142 trackerInput="DigitClusterFinder";
145 ///////////////////////////////////////////////////////////////////////////////////////////////////
147 // define the SPD vertexer Z configuration
149 if (!vertexerSPDInput.IsNull()) {
150 handler->CreateConfiguration("ITS-SPD-vertexer","ITSVertexerSPD", vertexerSPDInput, "");
153 ///////////////////////////////////////////////////////////////////////////////////////////////////
155 // define the ITS tracker configuration
157 if (!trackerInput.IsNull()) {
158 if (handler->FindConfiguration("TPC-globalmerger")) {
159 // add the TPC tracking if available
160 trackerInput+=" TPC-globalmerger";
162 if (handler->FindConfiguration("TPC-mcTrackMarker")) {
163 // add the TPC tracking if available
164 trackerInput+=" TPC-mcTrackMarker";
166 handler->CreateConfiguration("ITS-tracker","ITSTracker",trackerInput.Data(),"");
172 const char* AliHLTITSAgent::GetReconstructionChains(AliRawReader* /*rawReader*/,
173 AliRunLoader* runloader) const
175 // see header file for class documentation
177 // reconstruction chains for AliRoot simulation
178 // Note: run loader is only available while running embedded into
179 // AliRoot simulation
181 // the chain is just defined and can be used as input for subsequent
183 //return "ITS-tracker";
189 const char* AliHLTITSAgent::GetRequiredComponentLibraries() const
191 // see header file for class documentation
192 return "libAliHLTUtil.so libAliHLTRCU.so libAliHLTTPC.so";
195 int AliHLTITSAgent::RegisterComponents(AliHLTComponentHandler* pHandler) const
197 // see header file for class documentation
199 if (!pHandler) return -EINVAL;
200 pHandler->AddComponent(new AliHLTITSCompressRawDataSDDComponent);
201 pHandler->AddComponent(new AliHLTITSSSDQARecPointsComponent);
202 pHandler->AddComponent(new AliHLTITSQAComponent);
203 pHandler->AddComponent(new AliHLTITSClusterFinderComponent(AliHLTITSClusterFinderComponent::kClusterFinderSPD));
204 pHandler->AddComponent(new AliHLTITSClusterFinderComponent(AliHLTITSClusterFinderComponent::kClusterFinderSDD));
205 pHandler->AddComponent(new AliHLTITSClusterFinderComponent(AliHLTITSClusterFinderComponent::kClusterFinderSSD));
206 pHandler->AddComponent(new AliHLTITSClusterFinderComponent(AliHLTITSClusterFinderComponent::kClusterFinderDigits));
207 pHandler->AddComponent(new AliHLTITSClusterHistoComponent);
208 pHandler->AddComponent(new AliHLTITSTrackerComponent);
209 pHandler->AddComponent(new AliHLTITSVertexerSPDComponent);
210 pHandler->AddComponent(new AliHLTITSDigitPublisherComponent);
215 AliHLTModulePreprocessor* AliHLTITSAgent::GetPreprocessor()
217 // see header file for class documentation
221 int AliHLTITSAgent::GetHandlerDescription(AliHLTComponentDataType dt,
223 AliHLTOUTHandlerDesc& desc) const
225 // see header file for class documentation
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
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)) {
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);
245 AliHLTOUTHandler* AliHLTITSAgent::GetOutputHandler(AliHLTComponentDataType dt,
246 AliHLTUInt32_t /*spec*/)
248 // see header file for class documentation
249 if (dt==(kAliHLTDataTypeDDLRaw|kAliHLTDataOriginITSSDD)) {
250 // use the default handler
251 if (!fRawDataHandler) {
252 fRawDataHandler=new AliHLTOUTSDDRawDataHandler;
254 return fRawDataHandler;
259 int AliHLTITSAgent::DeleteOutputHandler(AliHLTOUTHandler* pInstance)
261 // see header file for class documentation
262 if (pInstance==NULL) return -EINVAL;
264 if (pInstance==fRawDataHandler) {
265 delete fRawDataHandler;
266 fRawDataHandler=NULL;
274 int AliHLTITSAgent::AliHLTOUTSDDRawDataHandler::ProcessData(AliHLTOUT* pData)
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);
284 if (dt==(kAliHLTDataTypeDDLRaw|kAliHLTDataOriginITSSDD)) {
285 int ddlOffset=256;//AliDAQ::DdlIDOffset("ITSSDD");
286 int numberOfDDLs=24;//AliDAQ::NumberOfDdls("ITSSDD");
288 for (;ddlNo<32 && ddlNo<numberOfDDLs; ddlNo++) {
289 if (spec&(0x1<<ddlNo)) break;
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());
294 } else if (spec^(0x1<<ddlNo)) {
296 HLTError("multiple links set in specification 0x%08x: can not extract DDL id for data block %s", spec, AliHLTComponent::DataType2Text(dt).c_str());
298 iResult=ddlOffset+ddlNo;
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":"");
313 int AliHLTITSAgent::CreateCFConfigurations(AliHLTConfigurationHandler* pHandler, int detectorId, TString& output) const
315 // see header file for class documentation
316 if (!pHandler) return -EINVAL;
318 ///////////////////////////////////////////////////////////////////////////////////////////////////
320 // define the ITS cluster finder components
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
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);
335 int minddl=AliHLTDAQ::DdlIDOffset(detectorId);
336 int maxddl=minddl+AliHLTDAQ::NumberOfDdls(detectorId)-1;
340 // this is a simple switch for experimenting with different configurations
341 // it's supposed to be false for normal compilation
342 bool bOneCFperDDL=false;
343 TString origin=idString; origin.ReplaceAll("ITS", "I");
344 TString cfBase=idString; cfBase+="_CF";
345 TString componentId=idString; componentId.ReplaceAll("ITS", "ITSClusterFinder");
347 for(ddlno=minddl;ddlno<=maxddl;ddlno++){
348 TString arg, publisher;
350 // the HLT origin defines are 4 chars: ISPD, ISSD, ISDD respectively
351 arg.Form("-minid %d -datatype 'DDL_RAW ' '%s' -dataspec 0x%08x",ddlno, origin.Data(), spec);
352 if (CheckFilter(kHLTLogDebug)) arg+=" -verbose";
353 publisher.Form("ITS-DP_%d", ddlno);
354 pHandler->CreateConfiguration(publisher.Data(), "AliRawReaderPublisher", NULL , arg.Data());
356 if (cfinput.Length()>0) cfinput+=" ";
360 cf.Form("%s_%d",cfBase.Data(), ddlno);
361 pHandler->CreateConfiguration(cf.Data(), componentId.Data(), publisher.Data(), "");
363 if (output.Length()>0) output+=" ";
371 cf.Form("%s",cfBase.Data());
372 pHandler->CreateConfiguration(cf.Data(), componentId.Data(), cfinput.Data(), "");
374 if (output.Length()>0) output+=" ";