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 "AliHLTConfiguration.h"
28 #include "AliHLTOUT.h"
29 #include "AliHLTDAQ.h"
31 // header files of library components
32 #include "AliHLTITSCompressRawDataSDDComponent.h"
33 #include "AliHLTITSSSDQARecPointsComponent.h"
34 #include "AliHLTITSQAComponent.h"
35 #include "AliHLTITSClusterFinderComponent.h"
36 #include "AliHLTITSClusterHistoComponent.h"
37 #include "AliHLTITSTrackerComponent.h"
38 #include "AliHLTITSVertexerSPDComponent.h"
39 #include "AliHLTITSDigitPublisherComponent.h"
41 // header file of the module preprocessor
44 /** global instance for agent registration */
45 AliHLTITSAgent gAliHLTITSAgent;
47 /** ROOT macro for the implementation of ROOT specific class methods */
48 ClassImp(AliHLTITSAgent)
50 AliHLTITSAgent::AliHLTITSAgent()
52 AliHLTModuleAgent("ITS"),
55 // see header file for class documentation
57 // refer to README to build package
59 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
62 AliHLTITSAgent::~AliHLTITSAgent()
64 // see header file for class documentation
67 int AliHLTITSAgent::CreateConfigurations(AliHLTConfigurationHandler* handler,
68 AliRawReader* rawReader,
69 AliRunLoader* runloader) const
71 // see header file for class documentation
73 if (!handler) return -EINVAL;
75 ///////////////////////////////////////////////////////////////////////////////////////////////////
76 ///////////////////////////////////////////////////////////////////////////////////////////////////
78 // ITS tracking is currently only working on raw data
79 // to run on digits, a digit publisher needs to be implemented
81 TString trackerInput="";
82 TString vertexerSPDInput="";
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
87 ///////////////////////////////////////////////////////////////////////////////////////////////////
89 // define the ITS cluster finder configurations
96 iResult=CreateCFConfigurations(handler, AliHLTDAQ::DetectorID("ITSSPD"), spdCF);
97 handler->CreateConfiguration("ITS-SPD-CF","BlockFilter",spdCF.Data(),"");
99 iResult=CreateCFConfigurations(handler, AliHLTDAQ::DetectorID("ITSSDD"), sddCF);
100 handler->CreateConfiguration("ITS-SDD-CF","BlockFilter",sddCF.Data(),"");
102 iResult=CreateCFConfigurations(handler, AliHLTDAQ::DetectorID("ITSSSD"), ssdCF);
103 handler->CreateConfiguration("ITS-SSD-CF","BlockFilter",ssdCF.Data(),"");
106 ///////////////////////////////////////////////////////////////////////////////////////////////////
108 // define the SPD vertexer Z input
110 vertexerSPDInput="ITS-SPD-CF";
112 ///////////////////////////////////////////////////////////////////////////////////////////////////
114 // define the ITS tracker input
116 trackerInput="ITS-SPD-CF ITS-SDD-CF ITS-SSD-CF";
118 else if (runloader && !rawReader) {
119 // indicates AliSimulation with no RawReader available -> run on digits
121 ///////////////////////////////////////////////////////////////////////////////////////////////////
123 // define the Digit Publisher and ITS cluster finder configuration
125 handler->CreateConfiguration("DigitPublisher","AliLoaderPublisher",NULL,"-loader ITSLoader -datatype 'ALITREED' 'ITS '");
126 handler->CreateConfiguration("DigitClusterFinder","ITSClusterFinderDigits","DigitPublisher","");
128 ///////////////////////////////////////////////////////////////////////////////////////////////////
130 // define the SPD vertexer Z input.
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";
137 ///////////////////////////////////////////////////////////////////////////////////////////////////
139 // define the ITS tracker input
141 // Currently there is a seg fault in the TTree access from the DigitClusterFinder
142 // needs first to be investigated
143 trackerInput="DigitClusterFinder";
146 ///////////////////////////////////////////////////////////////////////////////////////////////////
148 // define the SPD vertexer Z configuration
150 if (!vertexerSPDInput.IsNull()) {
151 handler->CreateConfiguration("ITS-SPD-vertexer","ITSVertexerSPD", vertexerSPDInput, "");
154 ///////////////////////////////////////////////////////////////////////////////////////////////////
156 // define the ITS tracker configuration
158 if (!trackerInput.IsNull()) {
159 if (handler->FindConfiguration("TPC-globalmerger")) {
160 // add the TPC tracking if available
161 trackerInput+=" TPC-globalmerger";
163 handler->CreateConfiguration("ITS-tracker","ITSTracker",trackerInput.Data(),"");
169 const char* AliHLTITSAgent::GetReconstructionChains(AliRawReader* /*rawReader*/,
170 AliRunLoader* runloader) const
172 // see header file for class documentation
174 // reconstruction chains for AliRoot simulation
175 // Note: run loader is only available while running embedded into
176 // AliRoot simulation
178 // the chain is just defined and can be used as input for subsequent
180 //return "ITS-tracker";
186 const char* AliHLTITSAgent::GetRequiredComponentLibraries() const
188 // see header file for class documentation
189 return "libAliHLTUtil.so libAliHLTRCU.so libAliHLTTPC.so";
192 int AliHLTITSAgent::RegisterComponents(AliHLTComponentHandler* pHandler) const
194 // see header file for class documentation
196 if (!pHandler) return -EINVAL;
197 pHandler->AddComponent(new AliHLTITSCompressRawDataSDDComponent);
198 pHandler->AddComponent(new AliHLTITSSSDQARecPointsComponent);
199 pHandler->AddComponent(new AliHLTITSQAComponent);
200 pHandler->AddComponent(new AliHLTITSClusterFinderComponent(AliHLTITSClusterFinderComponent::kClusterFinderSPD));
201 pHandler->AddComponent(new AliHLTITSClusterFinderComponent(AliHLTITSClusterFinderComponent::kClusterFinderSDD));
202 pHandler->AddComponent(new AliHLTITSClusterFinderComponent(AliHLTITSClusterFinderComponent::kClusterFinderSSD));
203 pHandler->AddComponent(new AliHLTITSClusterFinderComponent(AliHLTITSClusterFinderComponent::kClusterFinderDigits));
204 pHandler->AddComponent(new AliHLTITSClusterHistoComponent);
205 pHandler->AddComponent(new AliHLTITSTrackerComponent);
206 pHandler->AddComponent(new AliHLTITSVertexerSPDComponent);
207 pHandler->AddComponent(new AliHLTITSDigitPublisherComponent);
212 AliHLTModulePreprocessor* AliHLTITSAgent::GetPreprocessor()
214 // see header file for class documentation
218 int AliHLTITSAgent::GetHandlerDescription(AliHLTComponentDataType dt,
220 AliHLTOUTHandlerDesc& desc) const
222 // see header file for class documentation
224 // Handlers for ITS raw data. Even though there are 3 detectors
225 // everything is handled in one module library and one HLTOUT handler.
226 // This assumes that the data blocks are sent with data type
227 // {DDL_RAW :ISDD} and the bit set in the specification corresponding.
228 // to detector DDL id.
229 // An HLTOUT handler is implemented to extract the equipment id from
230 // the specification.
231 // Note: Future versions of the framework will provide a default handler
232 // class with that functionality.
233 if (dt==(kAliHLTDataTypeDDLRaw|kAliHLTDataOriginITSSDD)) {
234 desc=AliHLTOUTHandlerDesc(kRawReader, dt, GetModuleId());
235 HLTInfo("module %s handles data block type %s specification %d (0x%x)",
236 GetModuleId(), AliHLTComponent::DataType2Text(dt).c_str(), spec, spec);
242 AliHLTOUTHandler* AliHLTITSAgent::GetOutputHandler(AliHLTComponentDataType dt,
243 AliHLTUInt32_t /*spec*/)
245 // see header file for class documentation
246 if (dt==(kAliHLTDataTypeDDLRaw|kAliHLTDataOriginITSSDD)) {
247 // use the default handler
248 if (!fRawDataHandler) {
249 fRawDataHandler=new AliHLTOUTSDDRawDataHandler;
251 return fRawDataHandler;
256 int AliHLTITSAgent::DeleteOutputHandler(AliHLTOUTHandler* pInstance)
258 // see header file for class documentation
259 if (pInstance==NULL) return -EINVAL;
261 if (pInstance==fRawDataHandler) {
262 delete fRawDataHandler;
263 fRawDataHandler=NULL;
271 int AliHLTITSAgent::AliHLTOUTSDDRawDataHandler::ProcessData(AliHLTOUT* pData)
273 // see header file for class documentation
274 if (!pData) return -EINVAL;
275 static int errorCount=0;
276 const int maxErrorCount=10;
277 AliHLTComponentDataType dt=kAliHLTVoidDataType;
278 AliHLTUInt32_t spec=kAliHLTVoidDataSpec;
279 int iResult=pData->GetDataBlockDescription(dt, spec);
281 if (dt==(kAliHLTDataTypeDDLRaw|kAliHLTDataOriginITSSDD)) {
282 int ddlOffset=256;//AliDAQ::DdlIDOffset("ITSSDD");
283 int numberOfDDLs=24;//AliDAQ::NumberOfDdls("ITSSDD");
285 for (;ddlNo<32 && ddlNo<numberOfDDLs; ddlNo++) {
286 if (spec&(0x1<<ddlNo)) break;
288 if (ddlNo>=32 || ddlNo>=numberOfDDLs) {
289 HLTError("invalid specification 0x%08x: can not extract DDL id for data block %s", spec, AliHLTComponent::DataType2Text(dt).c_str());
291 } else if (spec^(0x1<<ddlNo)) {
293 HLTError("multiple links set in specification 0x%08x: can not extract DDL id for data block %s", spec, AliHLTComponent::DataType2Text(dt).c_str());
295 iResult=ddlOffset+ddlNo;
298 if (errorCount++<10) {
299 HLTError("wrong data type: expecting %s, got %s; %s",
300 AliHLTComponent::DataType2Text(kAliHLTDataTypeDDLRaw|kAliHLTDataOriginITSSDD).c_str(),
301 AliHLTComponent::DataType2Text(dt).c_str(),
302 errorCount==maxErrorCount?"suppressing further error messages":"");
310 int AliHLTITSAgent::CreateCFConfigurations(AliHLTConfigurationHandler* pHandler, int detectorId, TString& output) const
312 // see header file for class documentation
313 if (!pHandler) return -EINVAL;
315 ///////////////////////////////////////////////////////////////////////////////////////////////////
317 // define the ITS cluster finder components
320 //The spec starts from 0x1 in SPD, SDD and SSD. So 0x1 is ddl 0 for SPD, 0x10 is ddl 1, and so on
321 //in SDD 0x1 is ddl 256, 0x10 is ddl 257, and so on. This means that the spec has to be set to 0x1
322 //before the loops over the clusterfinder
324 TString idString=AliHLTDAQ::DetectorName(detectorId);
325 if (idString.CompareTo("ITSSPD") &&
326 idString.CompareTo("ITSSDD") &&
327 idString.CompareTo("ITSSSD")) {
328 HLTError("invalid detector id %d does not describe any ITS detector", detectorId);
332 int minddl=AliHLTDAQ::DdlIDOffset(detectorId);
333 int maxddl=minddl+AliHLTDAQ::NumberOfDdls(detectorId)-1;
337 bool bOneCFperDDL=false;
338 TString origin=idString; origin.ReplaceAll("ITS", "I");
339 TString cfBase=idString; cfBase+="_CF";
340 TString componentId=idString; componentId.ReplaceAll("ITS", "ITSClusterFinder");
342 for(ddlno=minddl;ddlno<=maxddl;ddlno++){
343 TString arg, publisher;
345 // the HLT origin defines are 4 chars: ISPD, ISSD, ISDD respectively
346 arg.Form("-minid %d -datatype 'DDL_RAW ' '%s' -dataspec 0x%08x",ddlno, origin.Data(), spec);
347 if (CheckFilter(kHLTLogDebug)) arg+=" -verbose";
348 publisher.Form("ITS-DP_%d", ddlno);
349 pHandler->CreateConfiguration(publisher.Data(), "AliRawReaderPublisher", NULL , arg.Data());
351 if (cfinput.Length()>0) cfinput+=" ";
355 cf.Form("%s_%d",cfBase.Data(), ddlno);
356 pHandler->CreateConfiguration(cf.Data(), componentId.Data(), publisher.Data(), "");
358 if (output.Length()>0) output+=" ";
366 cf.Form("%s",cfBase.Data());
367 pHandler->CreateConfiguration(cf.Data(), componentId.Data(), cfinput.Data(), "");
369 if (output.Length()>0) output+=" ";