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 "AliHLTTPCCAInputDataCompressorComponent.h"
50 #include "AliHLTTPCCATrackerComponent.h"
51 #include "AliHLTTPCTrackMCMarkerComponent.h"
52 #include "AliHLTTPCCAGlobalMergerComponent.h"
53 #include "AliHLTTPCGlobalMergerComponent.h"
54 #include "AliHLTTPCSliceTrackerComponent.h"
55 #include "AliHLTTPCVertexFinderComponent.h"
56 #include "AliHLTTPCClusterFinderComponent.h"
57 #include "AliHLTTPCRawDataUnpackerComponent.h"
58 #include "AliHLTTPCDigitPublisherComponent.h"
59 #include "AliHLTTPCZeroSuppressionComponent.h"
60 #include "AliHLTTPCDigitDumpComponent.h"
61 #include "AliHLTTPCClusterDumpComponent.h"
62 #include "AliHLTTPCEsdWriterComponent.h"
63 #include "AliHLTTPCOfflineClustererComponent.h"
64 #include "AliHLTTPCOfflineTrackerComponent.h"
65 #include "AliHLTTPCOfflineTrackerCalibComponent.h"
66 #include "AliHLTTPCOfflineCalibrationComponent.h" // to be added to the calibration library agent
67 #include "AliHLTTPCClusterHistoComponent.h"
68 #include "AliHLTTPCNoiseMapComponent.h"
69 #include "AliHLTTPCHistogramHandlerComponent.h"
70 //#include "AliHLTTPCCalibTracksComponent.h"
71 #include "AliHLTTPCTrackHistoComponent.h"
72 #include "AliHLTTPCTrackDumpComponent.h"
73 #include "AliHLTTPCHWCFDataReverterComponent.h"
74 #include "AliHLTTPCHWClusterTransformComponent.h"
75 // #include "AliHLTTPCCalibSeedMakerComponent.h"
76 // #include "AliHLTTPCCalibTimeComponent.h"
77 // #include "AliHLTTPCCalibTimeGainComponent.h"
78 // #include "AliHLTTPCCalibrationComponent.h"
80 /** ROOT macro for the implementation of ROOT specific class methods */
81 ClassImp(AliHLTTPCAgent)
83 AliHLTTPCAgent::AliHLTTPCAgent()
85 AliHLTModuleAgent("TPC"),
86 fRawDataHandler(NULL),
87 fTracksegsDataHandler(NULL)
89 // see header file for class documentation
91 // refer to README to build package
93 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
96 AliHLTTPCAgent::~AliHLTTPCAgent()
98 // see header file for class documentation
101 int AliHLTTPCAgent::CreateConfigurations(AliHLTConfigurationHandler* handler,
102 AliRawReader* rawReader,
103 AliRunLoader* runloader) const
105 // see header file for class documentation
107 const char* cdbEntry="TPC/Calib/Parameters";
108 AliCDBManager* pMan=AliCDBManager::Instance();
109 AliTPCParam* pTPCParam=NULL;
111 AliCDBEntry *pEntry = pMan->Get(cdbEntry);
113 pEntry->GetObject() &&
114 (pTPCParam=dynamic_cast<AliTPCParam*>(pEntry->GetObject()))) {
116 HLTWarning("can not load AliTPCParam from CDB entry %s", cdbEntry);
120 // This the tracking configuration for the full TPC
121 // - 216 clusterfinders (1 per partition)
122 // - 36 slice trackers
123 // - one global merger
124 // - the esd converter
125 // The ESD is shipped embedded into a TTree
131 TString sinkClusterInput;
132 for (int slice=iMinSlice; slice<=iMaxSlice; slice++) {
133 TString trackerInput;
134 for (int part=iMinPart; part<=iMaxPart; part++) {
135 TString arg, publisher, cf;
137 // digit publisher components
138 publisher.Form("TPC-DP_%02d_%d", slice, part);
139 if (rawReader || !runloader) {
140 // AliSimulation: use the AliRawReaderPublisher if the raw reader is available
141 // Alireconstruction: indicated by runloader==NULL, run always on raw data
143 if (part>1) ddlno+=72+4*slice+(part-2);
144 else ddlno+=2*slice+part;
145 arg.Form("-minid %d -datatype 'DDL_RAW ' 'TPC ' -dataspec 0x%02x%02x%02x%02x -silent", ddlno, slice, slice, part, part);
146 handler->CreateConfiguration(publisher.Data(), "AliRawReaderPublisher", NULL , arg.Data());
148 arg.Form("-slice %d -partition %d", slice, part);
149 handler->CreateConfiguration(publisher.Data(), "TPCDigitPublisher", NULL , arg.Data());
152 // cluster finder components
153 cf.Form("TPC-CF_%02d_%d", slice, part);
156 arg+=" -timebins "; arg+=pTPCParam->GetMaxTBin()+1;
158 if (!rawReader && runloader) {
160 handler->CreateConfiguration(cf.Data(), "TPCClusterFinderUnpacked", publisher.Data(), arg.Data());
162 #ifndef HAVE_NOT_ALTRORAWSTREAMV3
163 handler->CreateConfiguration(cf.Data(), "TPCClusterFinder32Bit", publisher.Data(), arg.Data());
165 // using the AltroDecoder if the official V3 decoder is not
166 // available in the offline code
167 handler->CreateConfiguration(cf.Data(), "TPCClusterFinderDecoder", publisher.Data(), arg.Data());
170 if (trackerInput.Length()>0) trackerInput+=" ";
172 if (sinkClusterInput.Length()>0) sinkClusterInput+=" ";
173 sinkClusterInput+=cf;
176 // tracker finder components
177 tracker.Form("TPC-TR_%02d", slice);
178 handler->CreateConfiguration(tracker.Data(), "TPCCATracker", trackerInput.Data(), "");
180 if (mergerInput.Length()>0) mergerInput+=" ";
181 mergerInput+=tracker;
185 // GlobalMerger component
186 handler->CreateConfiguration("TPC-globalmerger","TPCCAGlobalMerger",mergerInput.Data(),"");
188 // the esd converter configuration
189 TString converterInput="TPC-globalmerger";
190 if (!rawReader && runloader) {
191 // propagate cluster info to the esd converter in order to fill the MC information
192 handler->CreateConfiguration("TPC-clustermc-info", "BlockFilter" , sinkClusterInput.Data(), "-datatype 'CLMCINFO' 'TPC '");
193 handler->CreateConfiguration("TPC-mcTrackMarker","TPCTrackMCMarker","TPC-globalmerger TPC-clustermc-info","" );
195 converterInput+="TPC-mcTrackMarker";
197 handler->CreateConfiguration("TPC-esd-converter", "TPCEsdConverter" , converterInput.Data(), "");
199 // cluster dump collection
200 handler->CreateConfiguration("TPC-clusters", "BlockFilter" , sinkClusterInput.Data(), "-datatype 'CLUSTERS' 'TPC '");
202 /////////////////////////////////////////////////////////////////////////////////////
204 // a kChain HLTOUT configuration for processing of {'TRAKSEGS':'TPC '} data blocks
205 // collects the data blocks, merges the tracks and produces an ESD object
207 // publisher component
208 handler->CreateConfiguration("TPC-hltout-tracksegs-publisher", "AliHLTOUTPublisher" , NULL, "");
210 // GlobalMerger component
211 handler->CreateConfiguration("TPC-hltout-tracksegs-merger", "TPCGlobalMerger", "TPC-hltout-tracksegs-publisher", "");
213 // the esd converter configuration
214 handler->CreateConfiguration("TPC-hltout-tracksegs-esd-converter", "TPCEsdConverter", "TPC-hltout-tracksegs-merger", "");
216 /////////////////////////////////////////////////////////////////////////////////////
218 // a kChain HLTOUT configuration for processing of {'TRACKS ':'TPC '} data blocks
219 // produces an ESD object from the track structure
221 // publisher component
222 handler->CreateConfiguration("TPC-hltout-tracks-publisher", "AliHLTOUTPublisher" , NULL, "");
224 // the esd converter configuration
225 handler->CreateConfiguration("TPC-hltout-tracks-esd-converter", "TPCEsdConverter", "TPC-hltout-tracks-publisher", "");
230 const char* AliHLTTPCAgent::GetReconstructionChains(AliRawReader* /*rawReader*/,
231 AliRunLoader* runloader) const
233 // see header file for class documentation
235 // reconstruction chains for AliRoot simulation
236 // Note: run loader is only available while running embedded into
237 // AliRoot simulation
238 //if (runloader->GetLoader("TPCLoader") != NULL)
239 //return "TPC-esd-converter TPC-clusters";
240 return "TPC-clusters";
245 const char* AliHLTTPCAgent::GetRequiredComponentLibraries() const
247 // see header file for class documentation
249 // actually, the TPC library has dependencies to Util and RCU
250 // so the two has to be loaded anyhow before we get here
251 //return "libAliHLTUtil.so libAliHLTRCU.so";
252 return "libAliHLTUtil.so";
255 int AliHLTTPCAgent::RegisterComponents(AliHLTComponentHandler* pHandler) const
257 // see header file for class documentation
258 if (!pHandler) return -EINVAL;
260 pHandler->AddComponent(new AliHLTTPCRunStatisticsProducerComponent);
261 pHandler->AddComponent(new AliHLTTPCEventStatisticsProducerComponent);
262 // pHandler->AddComponent(new AliHLTTPCCalibCEComponent);
263 // pHandler->AddComponent(new AliHLTTPCCalibPulserComponent);
264 // pHandler->AddComponent(new AliHLTTPCCalibPedestalComponent);
265 pHandler->AddComponent(new AliHLTTPCCompModelInflaterComponent);
266 pHandler->AddComponent(new AliHLTTPCCompModelDeflaterComponent);
267 pHandler->AddComponent(new AliHLTTPCCompModelDeconverterComponent);
268 pHandler->AddComponent(new AliHLTTPCCompModelConverterComponent);
269 pHandler->AddComponent(new AliHLTTPCCompDumpComponent);
270 pHandler->AddComponent(new AliHLTTPCCAInputDataCompressorComponent);
271 pHandler->AddComponent(new AliHLTTPCCATrackerComponent);
272 pHandler->AddComponent(new AliHLTTPCCAGlobalMergerComponent);
273 pHandler->AddComponent(new AliHLTTPCTrackMCMarkerComponent);
274 pHandler->AddComponent(new AliHLTTPCGlobalMergerComponent);
275 pHandler->AddComponent(new AliHLTTPCSliceTrackerComponent);
276 pHandler->AddComponent(new AliHLTTPCVertexFinderComponent);
277 pHandler->AddComponent(new AliHLTTPCClusterFinderComponent(AliHLTTPCClusterFinderComponent::kClusterFinderPacked));
278 pHandler->AddComponent(new AliHLTTPCClusterFinderComponent(AliHLTTPCClusterFinderComponent::kClusterFinderUnpacked));
279 pHandler->AddComponent(new AliHLTTPCClusterFinderComponent(AliHLTTPCClusterFinderComponent::kClusterFinderDecoder));
280 pHandler->AddComponent(new AliHLTTPCClusterFinderComponent(AliHLTTPCClusterFinderComponent::kClusterFinder32Bit));
281 pHandler->AddComponent(new AliHLTTPCRawDataUnpackerComponent);
282 pHandler->AddComponent(new AliHLTTPCDigitPublisherComponent);
283 pHandler->AddComponent(new AliHLTTPCZeroSuppressionComponent);
284 pHandler->AddComponent(new AliHLTTPCDigitDumpComponent);
285 pHandler->AddComponent(new AliHLTTPCClusterDumpComponent);
286 pHandler->AddComponent(new AliHLTTPCEsdWriterComponent::AliWriter);
287 pHandler->AddComponent(new AliHLTTPCEsdWriterComponent::AliConverter);
288 pHandler->AddComponent(new AliHLTTPCOfflineClustererComponent);
289 pHandler->AddComponent(new AliHLTTPCOfflineTrackerComponent);
290 pHandler->AddComponent(new AliHLTTPCOfflineTrackerCalibComponent);
291 pHandler->AddComponent(new AliHLTTPCOfflineCalibrationComponent);
292 pHandler->AddComponent(new AliHLTTPCClusterHistoComponent);
293 pHandler->AddComponent(new AliHLTTPCNoiseMapComponent);
294 pHandler->AddComponent(new AliHLTTPCHistogramHandlerComponent);
295 //pHandler->AddComponent(new AliHLTTPCCalibTracksComponent);
296 pHandler->AddComponent(new AliHLTTPCTrackHistoComponent);
297 pHandler->AddComponent(new AliHLTTPCTrackDumpComponent);
298 pHandler->AddComponent(new AliHLTTPCHWCFDataReverterComponent);
299 pHandler->AddComponent(new AliHLTTPCHWClusterTransformComponent);
300 // pHandler->AddComponent(new AliHLTTPCCalibSeedMakerComponent);
301 // pHandler->AddComponent(new AliHLTTPCCalibTimeComponent);
302 // pHandler->AddComponent(new AliHLTTPCCalibTimeGainComponent);
303 // pHandler->AddComponent(new AliHLTTPCCalibrationComponent);
308 int AliHLTTPCAgent::GetHandlerDescription(AliHLTComponentDataType dt,
310 AliHLTOUTHandlerDesc& desc) const
312 // see header file for class documentation
314 // raw data blocks to be fed into offline reconstruction
315 if (dt==(kAliHLTDataTypeDDLRaw|kAliHLTDataOriginTPC)) {
316 int slice=AliHLTTPCDefinitions::GetMinSliceNr(spec);
317 int part=AliHLTTPCDefinitions::GetMinPatchNr(spec);
318 if (slice==AliHLTTPCDefinitions::GetMaxSliceNr(spec) &&
319 part==AliHLTTPCDefinitions::GetMaxPatchNr(spec)) {
320 desc=AliHLTOUTHandlerDesc(kRawReader, dt, GetModuleId());
323 HLTWarning("handler can not process merged data from multiple ddls:"
324 " min slice %d, max slice %d, min part %d, max part %d",
325 slice, AliHLTTPCDefinitions::GetMaxSliceNr(spec),
326 part, AliHLTTPCDefinitions::GetMaxPatchNr(spec));
331 // dump for {'CLUSTERS':'TPC '} currently not used any more
332 if (dt==AliHLTTPCDefinitions::fgkClustersDataType) {
333 desc=AliHLTOUTHandlerDesc(kProprietary, dt, GetModuleId());
337 // afterburner for {'TRAKSEGS':'TPC '} blocks to be converted to ESD format
338 if (dt==AliHLTTPCDefinitions::fgkTrackSegmentsDataType) {
339 desc=AliHLTOUTHandlerDesc(kChain, dt, GetModuleId());
343 // afterburner for {'TRACKS ':'TPC '} block to be converted to ESD format
344 // there is only one data block
345 if (dt==AliHLTTPCDefinitions::fgkTracksDataType) {
346 desc=AliHLTOUTHandlerDesc(kChain, dt, GetModuleId());
352 AliHLTOUTHandler* AliHLTTPCAgent::GetOutputHandler(AliHLTComponentDataType dt,
353 AliHLTUInt32_t /*spec*/)
355 // see header file for class documentation
357 // raw data blocks to be fed into offline reconstruction
358 if (dt==(kAliHLTDataTypeDDLRaw|kAliHLTDataOriginTPC)) {
359 if (!fRawDataHandler) {
360 fRawDataHandler=new AliHLTTPCAgent::AliHLTTPCRawDataHandler;
362 return fRawDataHandler;
365 // afterburner for {'TRAKSEGS':'TPC '} blocks to be converted to ESD format
366 // in a kChain HLTOUT handler
367 if (dt==AliHLTTPCDefinitions::fgkTrackSegmentsDataType) {
368 if (fTracksegsDataHandler==NULL)
369 fTracksegsDataHandler=new AliHLTOUTHandlerChain("chains=TPC-hltout-tracksegs-esd-converter");
370 return fTracksegsDataHandler;
373 // afterburner for {'TRACKS ':'TPC '} block to be converted to ESD format
374 // there is only one data block
375 if (dt==AliHLTTPCDefinitions::fgkTracksDataType) {
376 return new AliHLTOUTHandlerChain("chains=TPC-hltout-tracks-esd-converter");
382 int AliHLTTPCAgent::DeleteOutputHandler(AliHLTOUTHandler* pInstance)
384 // see header file for class documentation
385 if (pInstance==NULL) return -EINVAL;
387 if (pInstance==fRawDataHandler) {
388 delete fRawDataHandler;
389 fRawDataHandler=NULL;
392 if (pInstance==fTracksegsDataHandler) {
393 delete fTracksegsDataHandler;
394 fTracksegsDataHandler=NULL;
399 AliHLTTPCAgent::AliHLTTPCRawDataHandler::AliHLTTPCRawDataHandler()
401 // see header file for class documentation
404 AliHLTTPCAgent::AliHLTTPCRawDataHandler::~AliHLTTPCRawDataHandler()
406 // see header file for class documentation
409 int AliHLTTPCAgent::AliHLTTPCRawDataHandler::ProcessData(AliHLTOUT* pData)
411 // see header file for class documentation
412 if (!pData) return -EINVAL;
413 AliHLTComponentDataType dt=kAliHLTVoidDataType;
414 AliHLTUInt32_t spec=kAliHLTVoidDataSpec;
415 int iResult=pData->GetDataBlockDescription(dt, spec);
417 int slice=AliHLTTPCDefinitions::GetMinSliceNr(spec);
418 int part=AliHLTTPCDefinitions::GetMinPatchNr(spec);
419 if (slice==AliHLTTPCDefinitions::GetMaxSliceNr(spec) &&
420 part==AliHLTTPCDefinitions::GetMaxPatchNr(spec)) {
422 if (part>1) iResult+=72+4*slice+(part-2);
423 else iResult+=2*slice+part;
425 HLTError("handler can not process merged data from multiple ddls:"
426 " min slice %d, max slice %d, min part %d, max part %d",
427 slice, AliHLTTPCDefinitions::GetMaxSliceNr(spec),
428 part, AliHLTTPCDefinitions::GetMaxPatchNr(spec));