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 AliHLTTPCAgent.cxx
20 @author Matthias Richter
22 @brief Agent of the libAliHLTTPC library
25 #include "AliHLTTPCAgent.h"
26 #include "AliHLTConfiguration.h"
27 #include "AliHLTTPCDefinitions.h"
28 #include "AliHLTOUT.h"
29 #include "AliHLTOUTHandlerChain.h"
30 #include "AliRunLoader.h"
31 #include "AliCDBManager.h"
32 #include "AliCDBEntry.h"
33 #include "AliTPCParam.h"
35 /** global instance for agent registration */
36 AliHLTTPCAgent gAliHLTTPCAgent;
39 #include "AliHLTTPCRunStatisticsProducerComponent.h"
40 #include "AliHLTTPCEventStatisticsProducerComponent.h"
41 #include "AliHLTTPCCompModelInflaterComponent.h"
42 #include "AliHLTTPCCompModelDeflaterComponent.h"
43 #include "AliHLTTPCCompModelDeconverterComponent.h"
44 #include "AliHLTTPCCompModelConverterComponent.h"
45 #include "AliHLTTPCCompDumpComponent.h"
46 #include "AliHLTTPCCalibCEComponent.h"
47 #include "AliHLTTPCCalibPulserComponent.h"
48 #include "AliHLTTPCCalibPedestalComponent.h"
49 #include "AliHLTTPCCATrackerComponent.h"
50 #include "AliHLTTPCTrackMCMarkerComponent.h"
51 #include "AliHLTTPCCAGlobalMergerComponent.h"
52 #include "AliHLTTPCGlobalMergerComponent.h"
53 #include "AliHLTTPCSliceTrackerComponent.h"
54 #include "AliHLTTPCVertexFinderComponent.h"
55 #include "AliHLTTPCClusterFinderComponent.h"
56 #include "AliHLTTPCRawDataUnpackerComponent.h"
57 #include "AliHLTTPCDigitPublisherComponent.h"
58 #include "AliHLTTPCZeroSuppressionComponent.h"
59 #include "AliHLTTPCDigitDumpComponent.h"
60 #include "AliHLTTPCClusterDumpComponent.h"
61 #include "AliHLTTPCEsdWriterComponent.h"
62 #include "AliHLTTPCOfflineClustererComponent.h"
63 #include "AliHLTTPCOfflineTrackerComponent.h"
64 #include "AliHLTTPCOfflineTrackerCalibComponent.h"
65 #include "AliHLTTPCOfflineCalibrationComponent.h"
66 #include "AliHLTTPCClusterHistoComponent.h"
67 #include "AliHLTTPCNoiseMapComponent.h"
68 #include "AliHLTTPCHistogramHandlerComponent.h"
69 #include "AliHLTTPCCalibTracksComponent.h"
70 #include "AliHLTTPCTrackHistoComponent.h"
71 #include "AliHLTTPCTrackDumpComponent.h"
72 #include "AliHLTTPCHWCFDataReverterComponent.h"
73 #include "AliHLTTPCHWClusterTransformComponent.h"
75 /** ROOT macro for the implementation of ROOT specific class methods */
76 ClassImp(AliHLTTPCAgent)
78 AliHLTTPCAgent::AliHLTTPCAgent()
80 AliHLTModuleAgent("TPC"),
81 fRawDataHandler(NULL),
82 fTracksegsDataHandler(NULL)
84 // see header file for class documentation
86 // refer to README to build package
88 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
91 AliHLTTPCAgent::~AliHLTTPCAgent()
93 // see header file for class documentation
96 int AliHLTTPCAgent::CreateConfigurations(AliHLTConfigurationHandler* handler,
97 AliRawReader* rawReader,
98 AliRunLoader* /*runloader*/) const
100 // see header file for class documentation
102 const char* cdbEntry="TPC/Calib/Parameters";
103 AliCDBManager* pMan=AliCDBManager::Instance();
104 AliTPCParam* pTPCParam=NULL;
106 AliCDBEntry *pEntry = pMan->Get(cdbEntry);
108 pEntry->GetObject() &&
109 (pTPCParam=dynamic_cast<AliTPCParam*>(pEntry->GetObject()))) {
111 HLTWarning("can not load AliTPCParam from CDB entry %s", cdbEntry);
115 // This the tracking configuration for the full TPC
116 // - 216 clusterfinders (1 per partition)
117 // - 36 slice trackers
118 // - one global merger
119 // - the esd converter
120 // The ESD is shipped embedded into a TTree
126 TString sinkClusterInput;
127 for (int slice=iMinSlice; slice<=iMaxSlice; slice++) {
128 TString trackerInput;
129 for (int part=iMinPart; part<=iMaxPart; part++) {
130 TString arg, publisher, cf;
132 // digit publisher components
133 publisher.Form("TPC-DP_%02d_%d", slice, part);
135 arg.Form("-slice %d -partition %d", slice, part);
136 handler->CreateConfiguration(publisher.Data(), "TPCDigitPublisher", NULL , arg.Data());
139 if (part>1) ddlno+=72+4*slice+(part-2);
140 else ddlno+=2*slice+part;
141 arg.Form("-minid %d -datatype 'DDL_RAW ' 'TPC ' -dataspec 0x%02x%02x%02x%02x -silent", ddlno, slice, slice, part, part);
142 handler->CreateConfiguration(publisher.Data(), "AliRawReaderPublisher", NULL , arg.Data());
145 // cluster finder components
146 cf.Form("TPC-CF_%02d_%d", slice, part);
149 arg+=" -timebins "; arg+=pTPCParam->GetMaxTBin()+1;
153 handler->CreateConfiguration(cf.Data(), "TPCClusterFinderUnpacked", publisher.Data(), arg.Data());
155 handler->CreateConfiguration(cf.Data(), "TPCClusterFinderDecoder", publisher.Data(), arg.Data());
157 if (trackerInput.Length()>0) trackerInput+=" ";
159 if (sinkClusterInput.Length()>0) sinkClusterInput+=" ";
160 sinkClusterInput+=cf;
163 // tracker finder components
164 tracker.Form("TPC-TR_%02d", slice);
165 handler->CreateConfiguration(tracker.Data(), "TPCCATracker", trackerInput.Data(), "");
167 if (mergerInput.Length()>0) mergerInput+=" ";
168 mergerInput+=tracker;
172 // GlobalMerger component
173 handler->CreateConfiguration("TPC-globalmerger","TPCCAGlobalMerger",mergerInput.Data(),"");
175 // the esd converter configuration
176 TString converterInput="TPC-globalmerger";
178 // propagate cluster info to the esd converter in order to fill the MC information
180 converterInput+=sinkClusterInput;
182 handler->CreateConfiguration("TPC-esd-converter", "TPCEsdConverter" , converterInput.Data(), "");
184 // cluster dump collection
185 handler->CreateConfiguration("TPC-clusters", "BlockFilter" , sinkClusterInput.Data(), "-datatype 'CLUSTERS' 'TPC '");
187 /////////////////////////////////////////////////////////////////////////////////////
189 // a kChain HLTOUT configuration for processing of {'TRAKSEGS':'TPC '} data blocks
190 // collects the data blocks, merges the tracks and produces an ESD object
192 // publisher component
193 handler->CreateConfiguration("TPC-hltout-tracksegs-publisher", "AliHLTOUTPublisher" , NULL, "");
195 // GlobalMerger component
196 handler->CreateConfiguration("TPC-hltout-tracksegs-merger", "TPCGlobalMerger", "TPC-hltout-tracksegs-publisher", "");
198 // the esd converter configuration
199 handler->CreateConfiguration("TPC-hltout-tracksegs-esd-converter", "TPCEsdConverter", "TPC-hltout-tracksegs-merger", "");
201 /////////////////////////////////////////////////////////////////////////////////////
203 // a kChain HLTOUT configuration for processing of {'TRACKS ':'TPC '} data blocks
204 // produces an ESD object from the track structure
206 // publisher component
207 handler->CreateConfiguration("TPC-hltout-tracks-publisher", "AliHLTOUTPublisher" , NULL, "");
209 // the esd converter configuration
210 handler->CreateConfiguration("TPC-hltout-tracks-esd-converter", "TPCEsdConverter", "TPC-hltout-tracks-publisher", "");
215 const char* AliHLTTPCAgent::GetReconstructionChains(AliRawReader* /*rawReader*/,
216 AliRunLoader* runloader) const
218 // see header file for class documentation
220 // reconstruction chains for AliRoot simulation
221 // Note: run loader is only available while running embedded into
222 // AliRoot simulation
223 if (runloader->GetLoader("TPCLoader") != NULL)
224 return "TPC-esd-converter TPC-clusters";
229 const char* AliHLTTPCAgent::GetRequiredComponentLibraries() const
231 // see header file for class documentation
233 // actually, the TPC library has dependencies to Util and RCU
234 // so the two has to be loaded anyhow before we get here
235 //return "libAliHLTUtil.so libAliHLTRCU.so";
239 int AliHLTTPCAgent::RegisterComponents(AliHLTComponentHandler* pHandler) const
241 // see header file for class documentation
242 if (!pHandler) return -EINVAL;
244 pHandler->AddComponent(new AliHLTTPCRunStatisticsProducerComponent);
245 pHandler->AddComponent(new AliHLTTPCEventStatisticsProducerComponent);
246 pHandler->AddComponent(new AliHLTTPCCalibCEComponent);
247 pHandler->AddComponent(new AliHLTTPCCalibPulserComponent);
248 pHandler->AddComponent(new AliHLTTPCCalibPedestalComponent);
249 pHandler->AddComponent(new AliHLTTPCCompModelInflaterComponent);
250 pHandler->AddComponent(new AliHLTTPCCompModelDeflaterComponent);
251 pHandler->AddComponent(new AliHLTTPCCompModelDeconverterComponent);
252 pHandler->AddComponent(new AliHLTTPCCompModelConverterComponent);
253 pHandler->AddComponent(new AliHLTTPCCompDumpComponent);
254 pHandler->AddComponent(new AliHLTTPCCATrackerComponent);
255 pHandler->AddComponent(new AliHLTTPCCAGlobalMergerComponent);
256 pHandler->AddComponent(new AliHLTTPCTrackMCMarkerComponent);
257 pHandler->AddComponent(new AliHLTTPCGlobalMergerComponent);
258 pHandler->AddComponent(new AliHLTTPCSliceTrackerComponent);
259 pHandler->AddComponent(new AliHLTTPCVertexFinderComponent);
260 pHandler->AddComponent(new AliHLTTPCClusterFinderComponent(AliHLTTPCClusterFinderComponent::kClusterFinderPacked));
261 pHandler->AddComponent(new AliHLTTPCClusterFinderComponent(AliHLTTPCClusterFinderComponent::kClusterFinderUnpacked));
262 pHandler->AddComponent(new AliHLTTPCClusterFinderComponent(AliHLTTPCClusterFinderComponent::kClusterFinderDecoder));
263 pHandler->AddComponent(new AliHLTTPCClusterFinderComponent(AliHLTTPCClusterFinderComponent::kClusterFinder32Bit));
264 pHandler->AddComponent(new AliHLTTPCRawDataUnpackerComponent);
265 pHandler->AddComponent(new AliHLTTPCDigitPublisherComponent);
266 pHandler->AddComponent(new AliHLTTPCZeroSuppressionComponent);
267 pHandler->AddComponent(new AliHLTTPCDigitDumpComponent);
268 pHandler->AddComponent(new AliHLTTPCClusterDumpComponent);
269 pHandler->AddComponent(new AliHLTTPCEsdWriterComponent::AliWriter);
270 pHandler->AddComponent(new AliHLTTPCEsdWriterComponent::AliConverter);
271 pHandler->AddComponent(new AliHLTTPCOfflineClustererComponent);
272 pHandler->AddComponent(new AliHLTTPCOfflineTrackerComponent);
273 pHandler->AddComponent(new AliHLTTPCOfflineTrackerCalibComponent);
274 pHandler->AddComponent(new AliHLTTPCOfflineCalibrationComponent);
275 pHandler->AddComponent(new AliHLTTPCClusterHistoComponent);
276 pHandler->AddComponent(new AliHLTTPCNoiseMapComponent);
277 pHandler->AddComponent(new AliHLTTPCHistogramHandlerComponent);
278 pHandler->AddComponent(new AliHLTTPCCalibTracksComponent);
279 pHandler->AddComponent(new AliHLTTPCTrackHistoComponent);
280 pHandler->AddComponent(new AliHLTTPCTrackDumpComponent);
281 pHandler->AddComponent(new AliHLTTPCHWCFDataReverterComponent);
282 pHandler->AddComponent(new AliHLTTPCHWClusterTransformComponent);
287 int AliHLTTPCAgent::GetHandlerDescription(AliHLTComponentDataType dt,
289 AliHLTOUTHandlerDesc& desc) const
291 // see header file for class documentation
293 // raw data blocks to be fed into offline reconstruction
294 if (dt==(kAliHLTDataTypeDDLRaw|kAliHLTDataOriginTPC)) {
295 int slice=AliHLTTPCDefinitions::GetMinSliceNr(spec);
296 int part=AliHLTTPCDefinitions::GetMinPatchNr(spec);
297 if (slice==AliHLTTPCDefinitions::GetMaxSliceNr(spec) &&
298 part==AliHLTTPCDefinitions::GetMaxPatchNr(spec)) {
299 desc=AliHLTOUTHandlerDesc(kRawReader, dt, GetModuleId());
302 HLTWarning("handler can not process merged data from multiple ddls:"
303 " min slice %d, max slice %d, min part %d, max part %d",
304 slice, AliHLTTPCDefinitions::GetMaxSliceNr(spec),
305 part, AliHLTTPCDefinitions::GetMaxPatchNr(spec));
310 // dump for {'CLUSTERS':'TPC '} currently not used any more
311 if (dt==AliHLTTPCDefinitions::fgkClustersDataType) {
312 desc=AliHLTOUTHandlerDesc(kProprietary, dt, GetModuleId());
316 // afterburner for {'TRAKSEGS':'TPC '} blocks to be converted to ESD format
317 if (dt==AliHLTTPCDefinitions::fgkTrackSegmentsDataType) {
318 desc=AliHLTOUTHandlerDesc(kChain, dt, GetModuleId());
322 // afterburner for {'TRACKS ':'TPC '} block to be converted to ESD format
323 // there is only one data block
324 if (dt==AliHLTTPCDefinitions::fgkTracksDataType) {
325 desc=AliHLTOUTHandlerDesc(kChain, dt, GetModuleId());
331 AliHLTOUTHandler* AliHLTTPCAgent::GetOutputHandler(AliHLTComponentDataType dt,
332 AliHLTUInt32_t /*spec*/)
334 // see header file for class documentation
336 // raw data blocks to be fed into offline reconstruction
337 if (dt==(kAliHLTDataTypeDDLRaw|kAliHLTDataOriginTPC)) {
338 if (!fRawDataHandler) {
339 fRawDataHandler=new AliHLTTPCAgent::AliHLTTPCRawDataHandler;
341 return fRawDataHandler;
344 // afterburner for {'TRAKSEGS':'TPC '} blocks to be converted to ESD format
345 // in a kChain HLTOUT handler
346 if (dt==AliHLTTPCDefinitions::fgkTrackSegmentsDataType) {
347 if (fTracksegsDataHandler==NULL)
348 fTracksegsDataHandler=new AliHLTOUTHandlerChain("chains=TPC-hltout-tracksegs-esd-converter");
349 return fTracksegsDataHandler;
352 // afterburner for {'TRACKS ':'TPC '} block to be converted to ESD format
353 // there is only one data block
354 if (dt==AliHLTTPCDefinitions::fgkTracksDataType) {
355 return new AliHLTOUTHandlerChain("chains=TPC-hltout-tracks-esd-converter");
361 int AliHLTTPCAgent::DeleteOutputHandler(AliHLTOUTHandler* pInstance)
363 // see header file for class documentation
364 if (pInstance==NULL) return -EINVAL;
366 if (pInstance==fRawDataHandler) {
367 delete fRawDataHandler;
368 fRawDataHandler=NULL;
371 if (pInstance==fTracksegsDataHandler) {
372 delete fTracksegsDataHandler;
373 fTracksegsDataHandler=NULL;
378 AliHLTTPCAgent::AliHLTTPCRawDataHandler::AliHLTTPCRawDataHandler()
380 // see header file for class documentation
383 AliHLTTPCAgent::AliHLTTPCRawDataHandler::~AliHLTTPCRawDataHandler()
385 // see header file for class documentation
388 int AliHLTTPCAgent::AliHLTTPCRawDataHandler::ProcessData(AliHLTOUT* pData)
390 // see header file for class documentation
391 if (!pData) return -EINVAL;
392 AliHLTComponentDataType dt=kAliHLTVoidDataType;
393 AliHLTUInt32_t spec=kAliHLTVoidDataSpec;
394 int iResult=pData->GetDataBlockDescription(dt, spec);
396 int slice=AliHLTTPCDefinitions::GetMinSliceNr(spec);
397 int part=AliHLTTPCDefinitions::GetMinPatchNr(spec);
398 if (slice==AliHLTTPCDefinitions::GetMaxSliceNr(spec) &&
399 part==AliHLTTPCDefinitions::GetMaxPatchNr(spec)) {
401 if (part>1) iResult+=72+4*slice+(part-2);
402 else iResult+=2*slice+part;
404 HLTError("handler can not process merged data from multiple ddls:"
405 " min slice %d, max slice %d, min part %d, max part %d",
406 slice, AliHLTTPCDefinitions::GetMaxSliceNr(spec),
407 part, AliHLTTPCDefinitions::GetMaxPatchNr(spec));