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
179 handler->CreateConfiguration("TPC-clustermc-info", "BlockFilter" , sinkClusterInput.Data(), "-datatype 'CLMCINFO' 'TPC '");
180 handler->CreateConfiguration("TPC-mcTrackMarker","TPCTrackMCMarker","TPC-globalmerger TPC-clustermc-info","" );
182 converterInput+="TPC-mcTrackMarker";
184 handler->CreateConfiguration("TPC-esd-converter", "TPCEsdConverter" , converterInput.Data(), "");
186 // cluster dump collection
187 handler->CreateConfiguration("TPC-clusters", "BlockFilter" , sinkClusterInput.Data(), "-datatype 'CLUSTERS' 'TPC '");
189 /////////////////////////////////////////////////////////////////////////////////////
191 // a kChain HLTOUT configuration for processing of {'TRAKSEGS':'TPC '} data blocks
192 // collects the data blocks, merges the tracks and produces an ESD object
194 // publisher component
195 handler->CreateConfiguration("TPC-hltout-tracksegs-publisher", "AliHLTOUTPublisher" , NULL, "");
197 // GlobalMerger component
198 handler->CreateConfiguration("TPC-hltout-tracksegs-merger", "TPCGlobalMerger", "TPC-hltout-tracksegs-publisher", "");
200 // the esd converter configuration
201 handler->CreateConfiguration("TPC-hltout-tracksegs-esd-converter", "TPCEsdConverter", "TPC-hltout-tracksegs-merger", "");
203 /////////////////////////////////////////////////////////////////////////////////////
205 // a kChain HLTOUT configuration for processing of {'TRACKS ':'TPC '} data blocks
206 // produces an ESD object from the track structure
208 // publisher component
209 handler->CreateConfiguration("TPC-hltout-tracks-publisher", "AliHLTOUTPublisher" , NULL, "");
211 // the esd converter configuration
212 handler->CreateConfiguration("TPC-hltout-tracks-esd-converter", "TPCEsdConverter", "TPC-hltout-tracks-publisher", "");
217 const char* AliHLTTPCAgent::GetReconstructionChains(AliRawReader* /*rawReader*/,
218 AliRunLoader* runloader) const
220 // see header file for class documentation
222 // reconstruction chains for AliRoot simulation
223 // Note: run loader is only available while running embedded into
224 // AliRoot simulation
225 //if (runloader->GetLoader("TPCLoader") != NULL)
226 //return "TPC-esd-converter TPC-clusters";
227 return "TPC-clusters";
232 const char* AliHLTTPCAgent::GetRequiredComponentLibraries() const
234 // see header file for class documentation
236 // actually, the TPC library has dependencies to Util and RCU
237 // so the two has to be loaded anyhow before we get here
238 //return "libAliHLTUtil.so libAliHLTRCU.so";
242 int AliHLTTPCAgent::RegisterComponents(AliHLTComponentHandler* pHandler) const
244 // see header file for class documentation
245 if (!pHandler) return -EINVAL;
247 pHandler->AddComponent(new AliHLTTPCRunStatisticsProducerComponent);
248 pHandler->AddComponent(new AliHLTTPCEventStatisticsProducerComponent);
249 pHandler->AddComponent(new AliHLTTPCCalibCEComponent);
250 pHandler->AddComponent(new AliHLTTPCCalibPulserComponent);
251 pHandler->AddComponent(new AliHLTTPCCalibPedestalComponent);
252 pHandler->AddComponent(new AliHLTTPCCompModelInflaterComponent);
253 pHandler->AddComponent(new AliHLTTPCCompModelDeflaterComponent);
254 pHandler->AddComponent(new AliHLTTPCCompModelDeconverterComponent);
255 pHandler->AddComponent(new AliHLTTPCCompModelConverterComponent);
256 pHandler->AddComponent(new AliHLTTPCCompDumpComponent);
257 pHandler->AddComponent(new AliHLTTPCCATrackerComponent);
258 pHandler->AddComponent(new AliHLTTPCCAGlobalMergerComponent);
259 pHandler->AddComponent(new AliHLTTPCTrackMCMarkerComponent);
260 pHandler->AddComponent(new AliHLTTPCGlobalMergerComponent);
261 pHandler->AddComponent(new AliHLTTPCSliceTrackerComponent);
262 pHandler->AddComponent(new AliHLTTPCVertexFinderComponent);
263 pHandler->AddComponent(new AliHLTTPCClusterFinderComponent(AliHLTTPCClusterFinderComponent::kClusterFinderPacked));
264 pHandler->AddComponent(new AliHLTTPCClusterFinderComponent(AliHLTTPCClusterFinderComponent::kClusterFinderUnpacked));
265 pHandler->AddComponent(new AliHLTTPCClusterFinderComponent(AliHLTTPCClusterFinderComponent::kClusterFinderDecoder));
266 pHandler->AddComponent(new AliHLTTPCClusterFinderComponent(AliHLTTPCClusterFinderComponent::kClusterFinder32Bit));
267 pHandler->AddComponent(new AliHLTTPCRawDataUnpackerComponent);
268 pHandler->AddComponent(new AliHLTTPCDigitPublisherComponent);
269 pHandler->AddComponent(new AliHLTTPCZeroSuppressionComponent);
270 pHandler->AddComponent(new AliHLTTPCDigitDumpComponent);
271 pHandler->AddComponent(new AliHLTTPCClusterDumpComponent);
272 pHandler->AddComponent(new AliHLTTPCEsdWriterComponent::AliWriter);
273 pHandler->AddComponent(new AliHLTTPCEsdWriterComponent::AliConverter);
274 pHandler->AddComponent(new AliHLTTPCOfflineClustererComponent);
275 pHandler->AddComponent(new AliHLTTPCOfflineTrackerComponent);
276 pHandler->AddComponent(new AliHLTTPCOfflineTrackerCalibComponent);
277 pHandler->AddComponent(new AliHLTTPCOfflineCalibrationComponent);
278 pHandler->AddComponent(new AliHLTTPCClusterHistoComponent);
279 pHandler->AddComponent(new AliHLTTPCNoiseMapComponent);
280 pHandler->AddComponent(new AliHLTTPCHistogramHandlerComponent);
281 pHandler->AddComponent(new AliHLTTPCCalibTracksComponent);
282 pHandler->AddComponent(new AliHLTTPCTrackHistoComponent);
283 pHandler->AddComponent(new AliHLTTPCTrackDumpComponent);
284 pHandler->AddComponent(new AliHLTTPCHWCFDataReverterComponent);
285 pHandler->AddComponent(new AliHLTTPCHWClusterTransformComponent);
290 int AliHLTTPCAgent::GetHandlerDescription(AliHLTComponentDataType dt,
292 AliHLTOUTHandlerDesc& desc) const
294 // see header file for class documentation
296 // raw data blocks to be fed into offline reconstruction
297 if (dt==(kAliHLTDataTypeDDLRaw|kAliHLTDataOriginTPC)) {
298 int slice=AliHLTTPCDefinitions::GetMinSliceNr(spec);
299 int part=AliHLTTPCDefinitions::GetMinPatchNr(spec);
300 if (slice==AliHLTTPCDefinitions::GetMaxSliceNr(spec) &&
301 part==AliHLTTPCDefinitions::GetMaxPatchNr(spec)) {
302 desc=AliHLTOUTHandlerDesc(kRawReader, dt, GetModuleId());
305 HLTWarning("handler can not process merged data from multiple ddls:"
306 " min slice %d, max slice %d, min part %d, max part %d",
307 slice, AliHLTTPCDefinitions::GetMaxSliceNr(spec),
308 part, AliHLTTPCDefinitions::GetMaxPatchNr(spec));
313 // dump for {'CLUSTERS':'TPC '} currently not used any more
314 if (dt==AliHLTTPCDefinitions::fgkClustersDataType) {
315 desc=AliHLTOUTHandlerDesc(kProprietary, dt, GetModuleId());
319 // afterburner for {'TRAKSEGS':'TPC '} blocks to be converted to ESD format
320 if (dt==AliHLTTPCDefinitions::fgkTrackSegmentsDataType) {
321 desc=AliHLTOUTHandlerDesc(kChain, dt, GetModuleId());
325 // afterburner for {'TRACKS ':'TPC '} block to be converted to ESD format
326 // there is only one data block
327 if (dt==AliHLTTPCDefinitions::fgkTracksDataType) {
328 desc=AliHLTOUTHandlerDesc(kChain, dt, GetModuleId());
334 AliHLTOUTHandler* AliHLTTPCAgent::GetOutputHandler(AliHLTComponentDataType dt,
335 AliHLTUInt32_t /*spec*/)
337 // see header file for class documentation
339 // raw data blocks to be fed into offline reconstruction
340 if (dt==(kAliHLTDataTypeDDLRaw|kAliHLTDataOriginTPC)) {
341 if (!fRawDataHandler) {
342 fRawDataHandler=new AliHLTTPCAgent::AliHLTTPCRawDataHandler;
344 return fRawDataHandler;
347 // afterburner for {'TRAKSEGS':'TPC '} blocks to be converted to ESD format
348 // in a kChain HLTOUT handler
349 if (dt==AliHLTTPCDefinitions::fgkTrackSegmentsDataType) {
350 if (fTracksegsDataHandler==NULL)
351 fTracksegsDataHandler=new AliHLTOUTHandlerChain("chains=TPC-hltout-tracksegs-esd-converter");
352 return fTracksegsDataHandler;
355 // afterburner for {'TRACKS ':'TPC '} block to be converted to ESD format
356 // there is only one data block
357 if (dt==AliHLTTPCDefinitions::fgkTracksDataType) {
358 return new AliHLTOUTHandlerChain("chains=TPC-hltout-tracks-esd-converter");
364 int AliHLTTPCAgent::DeleteOutputHandler(AliHLTOUTHandler* pInstance)
366 // see header file for class documentation
367 if (pInstance==NULL) return -EINVAL;
369 if (pInstance==fRawDataHandler) {
370 delete fRawDataHandler;
371 fRawDataHandler=NULL;
374 if (pInstance==fTracksegsDataHandler) {
375 delete fTracksegsDataHandler;
376 fTracksegsDataHandler=NULL;
381 AliHLTTPCAgent::AliHLTTPCRawDataHandler::AliHLTTPCRawDataHandler()
383 // see header file for class documentation
386 AliHLTTPCAgent::AliHLTTPCRawDataHandler::~AliHLTTPCRawDataHandler()
388 // see header file for class documentation
391 int AliHLTTPCAgent::AliHLTTPCRawDataHandler::ProcessData(AliHLTOUT* pData)
393 // see header file for class documentation
394 if (!pData) return -EINVAL;
395 AliHLTComponentDataType dt=kAliHLTVoidDataType;
396 AliHLTUInt32_t spec=kAliHLTVoidDataSpec;
397 int iResult=pData->GetDataBlockDescription(dt, spec);
399 int slice=AliHLTTPCDefinitions::GetMinSliceNr(spec);
400 int part=AliHLTTPCDefinitions::GetMinPatchNr(spec);
401 if (slice==AliHLTTPCDefinitions::GetMaxSliceNr(spec) &&
402 part==AliHLTTPCDefinitions::GetMaxPatchNr(spec)) {
404 if (part>1) iResult+=72+4*slice+(part-2);
405 else iResult+=2*slice+part;
407 HLTError("handler can not process merged data from multiple ddls:"
408 " min slice %d, max slice %d, min part %d, max part %d",
409 slice, AliHLTTPCDefinitions::GetMaxSliceNr(spec),
410 part, AliHLTTPCDefinitions::GetMaxPatchNr(spec));