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 "AliHLTTPCCAGlobalMergerComponent.h"
51 #include "AliHLTTPCGlobalMergerComponent.h"
52 #include "AliHLTTPCSliceTrackerComponent.h"
53 #include "AliHLTTPCVertexFinderComponent.h"
54 #include "AliHLTTPCClusterFinderComponent.h"
55 #include "AliHLTTPCRawDataUnpackerComponent.h"
56 #include "AliHLTTPCDigitPublisherComponent.h"
57 #include "AliHLTTPCZeroSuppressionComponent.h"
58 #include "AliHLTTPCDigitDumpComponent.h"
59 #include "AliHLTTPCClusterDumpComponent.h"
60 #include "AliHLTTPCEsdWriterComponent.h"
61 #include "AliHLTTPCOfflineClustererComponent.h"
62 #include "AliHLTTPCOfflineTrackerComponent.h"
63 #include "AliHLTTPCOfflineTrackerCalibComponent.h"
64 #include "AliHLTTPCOfflineCalibrationComponent.h"
65 #include "AliHLTTPCClusterHistoComponent.h"
66 #include "AliHLTTPCNoiseMapComponent.h"
67 #include "AliHLTTPCHistogramHandlerComponent.h"
68 #include "AliHLTTPCCalibTracksComponent.h"
69 #include "AliHLTTPCTrackHistoComponent.h"
70 #include "AliHLTTPCTrackDumpComponent.h"
71 #include "AliHLTTPCHWCFDataReverterComponent.h"
72 #include "AliHLTTPCHWClusterTransformComponent.h"
74 /** ROOT macro for the implementation of ROOT specific class methods */
75 ClassImp(AliHLTTPCAgent)
77 AliHLTTPCAgent::AliHLTTPCAgent()
79 AliHLTModuleAgent("TPC"),
80 fRawDataHandler(NULL),
81 fTracksegsDataHandler(NULL)
83 // see header file for class documentation
85 // refer to README to build package
87 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
90 AliHLTTPCAgent::~AliHLTTPCAgent()
92 // see header file for class documentation
95 int AliHLTTPCAgent::CreateConfigurations(AliHLTConfigurationHandler* handler,
96 AliRawReader* rawReader,
97 AliRunLoader* /*runloader*/) const
99 // see header file for class documentation
101 const char* cdbEntry="TPC/Calib/Parameters";
102 AliCDBManager* pMan=AliCDBManager::Instance();
103 AliTPCParam* pTPCParam=NULL;
105 AliCDBEntry *pEntry = pMan->Get(cdbEntry);
107 pEntry->GetObject() &&
108 (pTPCParam=dynamic_cast<AliTPCParam*>(pEntry->GetObject()))) {
110 HLTWarning("can not load AliTPCParam from CDB entry %s", cdbEntry);
114 // This the tracking configuration for the full TPC
115 // - 216 clusterfinders (1 per partition)
116 // - 36 slice trackers
117 // - one global merger
118 // - the esd converter
119 // The ESD is shipped embedded into a TTree
125 TString sinkClusterInput;
126 for (int slice=iMinSlice; slice<=iMaxSlice; slice++) {
127 TString trackerInput;
128 for (int part=iMinPart; part<=iMaxPart; part++) {
129 TString arg, publisher, cf;
131 // digit publisher components
132 publisher.Form("TPC-DP_%02d_%d", slice, part);
134 arg.Form("-slice %d -partition %d", slice, part);
135 handler->CreateConfiguration(publisher.Data(), "TPCDigitPublisher", NULL , arg.Data());
138 if (part>1) ddlno+=72+4*slice+(part-2);
139 else ddlno+=2*slice+part;
140 arg.Form("-minid %d -datatype 'DDL_RAW ' 'TPC ' -dataspec 0x%02x%02x%02x%02x -silent", ddlno, slice, slice, part, part);
141 handler->CreateConfiguration(publisher.Data(), "AliRawReaderPublisher", NULL , arg.Data());
144 // cluster finder components
145 cf.Form("TPC-CF_%02d_%d", slice, part);
148 arg+=" -timebins "; arg+=pTPCParam->GetMaxTBin()+1;
152 handler->CreateConfiguration(cf.Data(), "TPCClusterFinderUnpacked", publisher.Data(), arg.Data());
154 handler->CreateConfiguration(cf.Data(), "TPCClusterFinderDecoder", publisher.Data(), arg.Data());
156 if (trackerInput.Length()>0) trackerInput+=" ";
158 if (sinkClusterInput.Length()>0) sinkClusterInput+=" ";
159 sinkClusterInput+=cf;
162 // tracker finder components
163 tracker.Form("TPC-TR_%02d", slice);
164 handler->CreateConfiguration(tracker.Data(), "TPCCATracker", trackerInput.Data(), "");
166 if (mergerInput.Length()>0) mergerInput+=" ";
167 mergerInput+=tracker;
171 // GlobalMerger component
172 handler->CreateConfiguration("TPC-globalmerger","TPCCAGlobalMerger",mergerInput.Data(),"");
174 // the esd converter configuration
175 handler->CreateConfiguration("TPC-esd-converter", "TPCEsdConverter" , "TPC-globalmerger", "");
177 // cluster dump collection
178 handler->CreateConfiguration("TPC-clusters", "BlockFilter" , sinkClusterInput.Data(), "-datatype 'CLUSTERS' 'TPC '");
180 /////////////////////////////////////////////////////////////////////////////////////
182 // a kChain HLTOUT configuration for processing of {'TRAKSEGS':'TPC '} data blocks
183 // collects the data blocks, merges the tracks and produces an ESD object
185 // publisher component
186 handler->CreateConfiguration("TPC-hltout-tracksegs-publisher", "AliHLTOUTPublisher" , NULL, "");
188 // GlobalMerger component
189 handler->CreateConfiguration("TPC-hltout-tracksegs-merger", "TPCGlobalMerger", "TPC-hltout-tracksegs-publisher", "");
191 // the esd converter configuration
192 handler->CreateConfiguration("TPC-hltout-tracksegs-esd-converter", "TPCEsdConverter", "TPC-hltout-tracksegs-merger", "");
194 /////////////////////////////////////////////////////////////////////////////////////
196 // a kChain HLTOUT configuration for processing of {'TRACKS ':'TPC '} data blocks
197 // produces an ESD object from the track structure
199 // publisher component
200 handler->CreateConfiguration("TPC-hltout-tracks-publisher", "AliHLTOUTPublisher" , NULL, "");
202 // the esd converter configuration
203 handler->CreateConfiguration("TPC-hltout-tracks-esd-converter", "TPCEsdConverter", "TPC-hltout-tracks-publisher", "");
208 const char* AliHLTTPCAgent::GetReconstructionChains(AliRawReader* /*rawReader*/,
209 AliRunLoader* runloader) const
211 // see header file for class documentation
213 // reconstruction chains for AliRoot simulation
214 // Note: run loader is only available while running embedded into
215 // AliRoot simulation
216 if (runloader->GetLoader("TPCLoader") != NULL)
217 return "TPC-esd-converter TPC-clusters";
222 const char* AliHLTTPCAgent::GetRequiredComponentLibraries() const
224 // see header file for class documentation
226 // actually, the TPC library has dependencies to Util and RCU
227 // so the two has to be loaded anyhow before we get here
228 //return "libAliHLTUtil.so libAliHLTRCU.so";
232 int AliHLTTPCAgent::RegisterComponents(AliHLTComponentHandler* pHandler) const
234 // see header file for class documentation
235 if (!pHandler) return -EINVAL;
237 pHandler->AddComponent(new AliHLTTPCRunStatisticsProducerComponent);
238 pHandler->AddComponent(new AliHLTTPCEventStatisticsProducerComponent);
239 pHandler->AddComponent(new AliHLTTPCCalibCEComponent);
240 pHandler->AddComponent(new AliHLTTPCCalibPulserComponent);
241 pHandler->AddComponent(new AliHLTTPCCalibPedestalComponent);
242 pHandler->AddComponent(new AliHLTTPCCompModelInflaterComponent);
243 pHandler->AddComponent(new AliHLTTPCCompModelDeflaterComponent);
244 pHandler->AddComponent(new AliHLTTPCCompModelDeconverterComponent);
245 pHandler->AddComponent(new AliHLTTPCCompModelConverterComponent);
246 pHandler->AddComponent(new AliHLTTPCCompDumpComponent);
247 pHandler->AddComponent(new AliHLTTPCCATrackerComponent);
248 pHandler->AddComponent(new AliHLTTPCCAGlobalMergerComponent);
249 pHandler->AddComponent(new AliHLTTPCGlobalMergerComponent);
250 pHandler->AddComponent(new AliHLTTPCSliceTrackerComponent);
251 pHandler->AddComponent(new AliHLTTPCVertexFinderComponent);
252 pHandler->AddComponent(new AliHLTTPCClusterFinderComponent(AliHLTTPCClusterFinderComponent::kClusterFinderPacked));
253 pHandler->AddComponent(new AliHLTTPCClusterFinderComponent(AliHLTTPCClusterFinderComponent::kClusterFinderUnpacked));
254 pHandler->AddComponent(new AliHLTTPCClusterFinderComponent(AliHLTTPCClusterFinderComponent::kClusterFinderDecoder));
255 pHandler->AddComponent(new AliHLTTPCClusterFinderComponent(AliHLTTPCClusterFinderComponent::kClusterFinder32Bit));
256 pHandler->AddComponent(new AliHLTTPCRawDataUnpackerComponent);
257 pHandler->AddComponent(new AliHLTTPCDigitPublisherComponent);
258 pHandler->AddComponent(new AliHLTTPCZeroSuppressionComponent);
259 pHandler->AddComponent(new AliHLTTPCDigitDumpComponent);
260 pHandler->AddComponent(new AliHLTTPCClusterDumpComponent);
261 pHandler->AddComponent(new AliHLTTPCEsdWriterComponent::AliWriter);
262 pHandler->AddComponent(new AliHLTTPCEsdWriterComponent::AliConverter);
263 pHandler->AddComponent(new AliHLTTPCOfflineClustererComponent);
264 pHandler->AddComponent(new AliHLTTPCOfflineTrackerComponent);
265 pHandler->AddComponent(new AliHLTTPCOfflineTrackerCalibComponent);
266 pHandler->AddComponent(new AliHLTTPCOfflineCalibrationComponent);
267 pHandler->AddComponent(new AliHLTTPCClusterHistoComponent);
268 pHandler->AddComponent(new AliHLTTPCNoiseMapComponent);
269 pHandler->AddComponent(new AliHLTTPCHistogramHandlerComponent);
270 pHandler->AddComponent(new AliHLTTPCCalibTracksComponent);
271 pHandler->AddComponent(new AliHLTTPCTrackHistoComponent);
272 pHandler->AddComponent(new AliHLTTPCTrackDumpComponent);
273 pHandler->AddComponent(new AliHLTTPCHWCFDataReverterComponent);
274 pHandler->AddComponent(new AliHLTTPCHWClusterTransformComponent);
279 int AliHLTTPCAgent::GetHandlerDescription(AliHLTComponentDataType dt,
281 AliHLTOUTHandlerDesc& desc) const
283 // see header file for class documentation
285 // raw data blocks to be fed into offline reconstruction
286 if (dt==(kAliHLTDataTypeDDLRaw|kAliHLTDataOriginTPC)) {
287 int slice=AliHLTTPCDefinitions::GetMinSliceNr(spec);
288 int part=AliHLTTPCDefinitions::GetMinPatchNr(spec);
289 if (slice==AliHLTTPCDefinitions::GetMaxSliceNr(spec) &&
290 part==AliHLTTPCDefinitions::GetMaxPatchNr(spec)) {
291 desc=AliHLTOUTHandlerDesc(kRawReader, dt, GetModuleId());
294 HLTWarning("handler can not process merged data from multiple ddls:"
295 " min slice %d, max slice %d, min part %d, max part %d",
296 slice, AliHLTTPCDefinitions::GetMaxSliceNr(spec),
297 part, AliHLTTPCDefinitions::GetMaxPatchNr(spec));
302 // dump for {'CLUSTERS':'TPC '} currently not used any more
303 if (dt==AliHLTTPCDefinitions::fgkClustersDataType) {
304 desc=AliHLTOUTHandlerDesc(kProprietary, dt, GetModuleId());
308 // afterburner for {'TRAKSEGS':'TPC '} blocks to be converted to ESD format
309 if (dt==AliHLTTPCDefinitions::fgkTrackSegmentsDataType) {
310 desc=AliHLTOUTHandlerDesc(kChain, dt, GetModuleId());
314 // afterburner for {'TRACKS ':'TPC '} block to be converted to ESD format
315 // there is only one data block
316 if (dt==AliHLTTPCDefinitions::fgkTracksDataType) {
317 desc=AliHLTOUTHandlerDesc(kChain, dt, GetModuleId());
323 AliHLTOUTHandler* AliHLTTPCAgent::GetOutputHandler(AliHLTComponentDataType dt,
324 AliHLTUInt32_t /*spec*/)
326 // see header file for class documentation
328 // raw data blocks to be fed into offline reconstruction
329 if (dt==(kAliHLTDataTypeDDLRaw|kAliHLTDataOriginTPC)) {
330 if (!fRawDataHandler) {
331 fRawDataHandler=new AliHLTTPCAgent::AliHLTTPCRawDataHandler;
333 return fRawDataHandler;
336 // afterburner for {'TRAKSEGS':'TPC '} blocks to be converted to ESD format
337 // in a kChain HLTOUT handler
338 if (dt==AliHLTTPCDefinitions::fgkTrackSegmentsDataType) {
339 if (fTracksegsDataHandler==NULL)
340 fTracksegsDataHandler=new AliHLTOUTHandlerChain("chains=TPC-hltout-tracksegs-esd-converter");
341 return fTracksegsDataHandler;
344 // afterburner for {'TRACKS ':'TPC '} block to be converted to ESD format
345 // there is only one data block
346 if (dt==AliHLTTPCDefinitions::fgkTracksDataType) {
347 return new AliHLTOUTHandlerChain("chains=TPC-hltout-tracks-esd-converter");
353 int AliHLTTPCAgent::DeleteOutputHandler(AliHLTOUTHandler* pInstance)
355 // see header file for class documentation
356 if (pInstance==NULL) return -EINVAL;
358 if (pInstance==fRawDataHandler) {
359 delete fRawDataHandler;
360 fRawDataHandler=NULL;
363 if (pInstance==fTracksegsDataHandler) {
364 delete fTracksegsDataHandler;
365 fTracksegsDataHandler=NULL;
370 AliHLTTPCAgent::AliHLTTPCRawDataHandler::AliHLTTPCRawDataHandler()
372 // see header file for class documentation
375 AliHLTTPCAgent::AliHLTTPCRawDataHandler::~AliHLTTPCRawDataHandler()
377 // see header file for class documentation
380 int AliHLTTPCAgent::AliHLTTPCRawDataHandler::ProcessData(AliHLTOUT* pData)
382 // see header file for class documentation
383 if (!pData) return -EINVAL;
384 AliHLTComponentDataType dt=kAliHLTVoidDataType;
385 AliHLTUInt32_t spec=kAliHLTVoidDataSpec;
386 int iResult=pData->GetDataBlockDescription(dt, spec);
388 int slice=AliHLTTPCDefinitions::GetMinSliceNr(spec);
389 int part=AliHLTTPCDefinitions::GetMinPatchNr(spec);
390 if (slice==AliHLTTPCDefinitions::GetMaxSliceNr(spec) &&
391 part==AliHLTTPCDefinitions::GetMaxPatchNr(spec)) {
393 if (part>1) iResult+=72+4*slice+(part-2);
394 else iResult+=2*slice+part;
396 HLTError("handler can not process merged data from multiple ddls:"
397 " min slice %d, max slice %d, min part %d, max part %d",
398 slice, AliHLTTPCDefinitions::GetMaxSliceNr(spec),
399 part, AliHLTTPCDefinitions::GetMaxPatchNr(spec));