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 "AliHLTITSSAPTrackerComponent.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 trackerSAPInput="";
83 TString vertexerSPDInput="";
84 if (rawReader || !runloader) {
85 // AliSimulation: use the AliRawReaderPublisher if the raw reader is available
86 // Alireconstruction: indicated by runloader==NULL, run always on raw data
88 ///////////////////////////////////////////////////////////////////////////////////////////////////
90 // define the ITS cluster finder configurations
97 iResult=CreateCFConfigurations(handler, AliHLTDAQ::DetectorID("ITSSPD"), spdCF);
98 handler->CreateConfiguration("ITS-SPD-CF","BlockFilter",spdCF.Data(),"");
100 iResult=CreateCFConfigurations(handler, AliHLTDAQ::DetectorID("ITSSDD"), sddCF);
101 handler->CreateConfiguration("ITS-SDD-CF","BlockFilter",sddCF.Data(),"");
103 iResult=CreateCFConfigurations(handler, AliHLTDAQ::DetectorID("ITSSSD"), ssdCF);
104 handler->CreateConfiguration("ITS-SSD-CF","BlockFilter",ssdCF.Data(),"");
107 ///////////////////////////////////////////////////////////////////////////////////////////////////
109 // define the SPD vertexer Z input
111 vertexerSPDInput="ITS-SPD-CF";
113 ///////////////////////////////////////////////////////////////////////////////////////////////////
115 // define the ITS tracker input
117 trackerInput="ITS-SPD-CF ITS-SDD-CF ITS-SSD-CF";
118 trackerSAPInput="ITS-SPD-CF ITS-SDD-CF ITS-SSD-CF";
120 else if (runloader && !rawReader) {
121 // indicates AliSimulation with no RawReader available -> run on digits
123 ///////////////////////////////////////////////////////////////////////////////////////////////////
125 // define the Digit Publisher and ITS cluster finder configuration
127 handler->CreateConfiguration("DigitPublisher","AliLoaderPublisher",NULL,"-loader ITSLoader -datatype 'ALITREED' 'ITS '");
128 handler->CreateConfiguration("DigitClusterFinder","ITSClusterFinderDigits","DigitPublisher","");
130 ///////////////////////////////////////////////////////////////////////////////////////////////////
132 // define the SPD vertexer Z input.
134 // Can not run on Digit ClusterFinder. Wrong inputtype. And wrong input data.
135 // If this is fixed in the VertexerSPD it needs to implement the data type
136 // handling for the ITS digits and ignore the input from the SDD and SSD
137 //vertexerSPDInput="DigitClusterFinder";
139 ///////////////////////////////////////////////////////////////////////////////////////////////////
141 // define the ITS tracker input
143 // Currently there is a seg fault in the TTree access from the DigitClusterFinder
144 // needs first to be investigated
145 trackerInput="DigitClusterFinder";
146 trackerSAPInput="DigitClusterFinder";
147 vertexerSPDInput="DigitClusterFinder";
150 ///////////////////////////////////////////////////////////////////////////////////////////////////
152 // define the SPD vertexer Z configuration
154 if (!vertexerSPDInput.IsNull()) {
155 handler->CreateConfiguration("ITS-SPD-vertexer","ITSVertexerSPD", vertexerSPDInput, "");
158 ///////////////////////////////////////////////////////////////////////////////////////////////////
160 // define the ITS tracker configuration
162 if (!trackerInput.IsNull()) {
163 if (handler->FindConfiguration("TPC-globalmerger")) {
164 // add the TPC tracking if available
165 trackerInput+=" TPC-globalmerger";
167 if (handler->FindConfiguration("TPC-mcTrackMarker")) {
168 // add the TPC tracking if available
169 trackerInput+=" TPC-mcTrackMarker";
171 handler->CreateConfiguration("ITS-tracker","ITSTracker",trackerInput.Data(),"");
174 if( !trackerSAPInput.IsNull() ) trackerSAPInput+=" ";
175 trackerSAPInput+="ITS-SPD-vertexer";
177 handler->CreateConfiguration("ITS-SAPtracker","ITSSAPTracker",trackerSAPInput.Data(),"");
182 const char* AliHLTITSAgent::GetReconstructionChains(AliRawReader* /*rawReader*/,
183 AliRunLoader* runloader) const
185 // see header file for class documentation
187 // reconstruction chains for AliRoot simulation
188 // Note: run loader is only available while running embedded into
189 // AliRoot simulation
191 // the chain is just defined and can be used as input for subsequent
193 //return "ITS-tracker";
199 const char* AliHLTITSAgent::GetRequiredComponentLibraries() const
201 // see header file for class documentation
202 return "libAliHLTUtil.so libAliHLTRCU.so libAliHLTTPC.so";
205 int AliHLTITSAgent::RegisterComponents(AliHLTComponentHandler* pHandler) const
207 // see header file for class documentation
209 if (!pHandler) return -EINVAL;
210 pHandler->AddComponent(new AliHLTITSCompressRawDataSDDComponent);
211 pHandler->AddComponent(new AliHLTITSSSDQARecPointsComponent);
212 pHandler->AddComponent(new AliHLTITSQAComponent);
213 pHandler->AddComponent(new AliHLTITSClusterFinderComponent(AliHLTITSClusterFinderComponent::kClusterFinderSPD));
214 pHandler->AddComponent(new AliHLTITSClusterFinderComponent(AliHLTITSClusterFinderComponent::kClusterFinderSDD));
215 pHandler->AddComponent(new AliHLTITSClusterFinderComponent(AliHLTITSClusterFinderComponent::kClusterFinderSSD));
216 pHandler->AddComponent(new AliHLTITSClusterFinderComponent(AliHLTITSClusterFinderComponent::kClusterFinderDigits));
217 pHandler->AddComponent(new AliHLTITSClusterHistoComponent);
218 pHandler->AddComponent(new AliHLTITSTrackerComponent);
219 pHandler->AddComponent(new AliHLTITSSAPTrackerComponent);
220 pHandler->AddComponent(new AliHLTITSVertexerSPDComponent);
221 pHandler->AddComponent(new AliHLTITSDigitPublisherComponent);
226 AliHLTModulePreprocessor* AliHLTITSAgent::GetPreprocessor()
228 // see header file for class documentation
232 int AliHLTITSAgent::GetHandlerDescription(AliHLTComponentDataType dt,
234 AliHLTOUTHandlerDesc& desc) const
236 // see header file for class documentation
238 // Handlers for ITS raw data. Even though there are 3 detectors
239 // everything is handled in one module library and one HLTOUT handler.
240 // This assumes that the data blocks are sent with data type
241 // {DDL_RAW :ISDD} and the bit set in the specification corresponding.
242 // to detector DDL id.
243 // An HLTOUT handler is implemented to extract the equipment id from
244 // the specification.
245 // Note: Future versions of the framework will provide a default handler
246 // class with that functionality.
247 if (dt==(kAliHLTDataTypeDDLRaw|kAliHLTDataOriginITSSDD)) {
248 desc=AliHLTOUTHandlerDesc(kRawReader, dt, GetModuleId());
249 HLTInfo("module %s handles data block type %s specification %d (0x%x)",
250 GetModuleId(), AliHLTComponent::DataType2Text(dt).c_str(), spec, spec);
256 AliHLTOUTHandler* AliHLTITSAgent::GetOutputHandler(AliHLTComponentDataType dt,
257 AliHLTUInt32_t /*spec*/)
259 // see header file for class documentation
260 if (dt==(kAliHLTDataTypeDDLRaw|kAliHLTDataOriginITSSDD)) {
261 // use the default handler
262 if (!fRawDataHandler) {
263 fRawDataHandler=new AliHLTOUTSDDRawDataHandler;
265 return fRawDataHandler;
270 int AliHLTITSAgent::DeleteOutputHandler(AliHLTOUTHandler* pInstance)
272 // see header file for class documentation
273 if (pInstance==NULL) return -EINVAL;
275 if (pInstance==fRawDataHandler) {
276 delete fRawDataHandler;
277 fRawDataHandler=NULL;
285 int AliHLTITSAgent::AliHLTOUTSDDRawDataHandler::ProcessData(AliHLTOUT* pData)
287 // see header file for class documentation
288 if (!pData) return -EINVAL;
289 static int errorCount=0;
290 const int maxErrorCount=10;
291 AliHLTComponentDataType dt=kAliHLTVoidDataType;
292 AliHLTUInt32_t spec=kAliHLTVoidDataSpec;
293 int iResult=pData->GetDataBlockDescription(dt, spec);
295 if (dt==(kAliHLTDataTypeDDLRaw|kAliHLTDataOriginITSSDD)) {
296 int ddlOffset=256;//AliDAQ::DdlIDOffset("ITSSDD");
297 int numberOfDDLs=24;//AliDAQ::NumberOfDdls("ITSSDD");
299 for (;ddlNo<32 && ddlNo<numberOfDDLs; ddlNo++) {
300 if (spec&(0x1<<ddlNo)) break;
302 if (ddlNo>=32 || ddlNo>=numberOfDDLs) {
303 HLTError("invalid specification 0x%08x: can not extract DDL id for data block %s", spec, AliHLTComponent::DataType2Text(dt).c_str());
305 } else if (spec^(0x1<<ddlNo)) {
307 HLTError("multiple links set in specification 0x%08x: can not extract DDL id for data block %s", spec, AliHLTComponent::DataType2Text(dt).c_str());
309 iResult=ddlOffset+ddlNo;
312 if (errorCount++<10) {
313 HLTError("wrong data type: expecting %s, got %s; %s",
314 AliHLTComponent::DataType2Text(kAliHLTDataTypeDDLRaw|kAliHLTDataOriginITSSDD).c_str(),
315 AliHLTComponent::DataType2Text(dt).c_str(),
316 errorCount==maxErrorCount?"suppressing further error messages":"");
324 int AliHLTITSAgent::CreateCFConfigurations(AliHLTConfigurationHandler* pHandler, int detectorId, TString& output) const
326 // see header file for class documentation
327 if (!pHandler) return -EINVAL;
329 ///////////////////////////////////////////////////////////////////////////////////////////////////
331 // define the ITS cluster finder components
334 //The spec starts from 0x1 in SPD, SDD and SSD. So 0x1 is ddl 0 for SPD, 0x10 is ddl 1, and so on
335 //in SDD 0x1 is ddl 256, 0x10 is ddl 257, and so on. This means that the spec has to be set to 0x1
336 //before the loops over the clusterfinder
338 TString idString=AliHLTDAQ::DetectorName(detectorId);
339 if (idString.CompareTo("ITSSPD") &&
340 idString.CompareTo("ITSSDD") &&
341 idString.CompareTo("ITSSSD")) {
342 HLTError("invalid detector id %d does not describe any ITS detector", detectorId);
346 int minddl=AliHLTDAQ::DdlIDOffset(detectorId);
347 int maxddl=minddl+AliHLTDAQ::NumberOfDdls(detectorId)-1;
351 // this is a simple switch for experimenting with different configurations
352 // it's supposed to be false for normal compilation
353 bool bOneCFperDDL=false;
354 TString origin=idString; origin.ReplaceAll("ITS", "I");
355 TString cfBase=idString; cfBase+="_CF";
356 TString componentId=idString; componentId.ReplaceAll("ITS", "ITSClusterFinder");
358 for(ddlno=minddl;ddlno<=maxddl;ddlno++){
359 TString arg, publisher;
361 // the HLT origin defines are 4 chars: ISPD, ISSD, ISDD respectively
362 arg.Form("-minid %d -datatype 'DDL_RAW ' '%s' -dataspec 0x%08x",ddlno, origin.Data(), spec);
363 if (CheckFilter(kHLTLogDebug)) arg+=" -verbose";
364 publisher.Form("ITS-DP_%d", ddlno);
365 pHandler->CreateConfiguration(publisher.Data(), "AliRawReaderPublisher", NULL , arg.Data());
367 if (cfinput.Length()>0) cfinput+=" ";
371 cf.Form("%s_%d",cfBase.Data(), ddlno);
372 pHandler->CreateConfiguration(cf.Data(), componentId.Data(), publisher.Data(), "");
374 if (output.Length()>0) output+=" ";
382 cf.Form("%s",cfBase.Data());
383 pHandler->CreateConfiguration(cf.Data(), componentId.Data(), cfinput.Data(), "");
385 if (output.Length()>0) output+=" ";