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 "AliHLTTPCGlobalMergerComponent.h"
51 #include "AliHLTTPCSliceTrackerComponent.h"
52 #include "AliHLTTPCVertexFinderComponent.h"
53 #include "AliHLTTPCClusterFinderComponent.h"
54 #include "AliHLTTPCRawDataUnpackerComponent.h"
55 #include "AliHLTTPCDigitPublisherComponent.h"
56 #include "AliHLTTPCZeroSuppressionComponent.h"
57 #include "AliHLTTPCDigitDumpComponent.h"
58 #include "AliHLTTPCClusterDumpComponent.h"
59 #include "AliHLTTPCEsdWriterComponent.h"
60 #include "AliHLTTPCOfflineClustererComponent.h"
61 #include "AliHLTTPCOfflineTrackerComponent.h"
62 #include "AliHLTTPCOfflineTrackerCalibComponent.h"
63 #include "AliHLTTPCOfflineCalibrationComponent.h"
64 #include "AliHLTTPCClusterHistoComponent.h"
65 #include "AliHLTTPCNoiseMapComponent.h"
66 #include "AliHLTTPCHistogramHandlerComponent.h"
67 #include "AliHLTTPCCalibTracksComponent.h"
68 #include "AliHLTTPCTrackHistoComponent.h"
69 #include "AliHLTTPCTrackDumpComponent.h"
70 #include "AliHLTTPCHWCFDataReverterComponent.h"
72 /** ROOT macro for the implementation of ROOT specific class methods */
73 ClassImp(AliHLTTPCAgent)
75 AliHLTTPCAgent::AliHLTTPCAgent()
77 AliHLTModuleAgent("TPC"),
78 fRawDataHandler(NULL),
79 fTracksegsDataHandler(NULL)
81 // see header file for class documentation
83 // refer to README to build package
85 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
88 AliHLTTPCAgent::~AliHLTTPCAgent()
90 // see header file for class documentation
93 int AliHLTTPCAgent::CreateConfigurations(AliHLTConfigurationHandler* handler,
94 AliRawReader* rawReader,
95 AliRunLoader* /*runloader*/) const
97 // see header file for class documentation
99 const char* cdbEntry="TPC/Calib/Parameters";
100 AliCDBManager* pMan=AliCDBManager::Instance();
101 AliTPCParam* pTPCParam=NULL;
103 AliCDBEntry *pEntry = pMan->Get(cdbEntry);
105 pEntry->GetObject() &&
106 (pTPCParam=dynamic_cast<AliTPCParam*>(pEntry->GetObject()))) {
108 HLTWarning("can not load AliTPCParam from CDB entry %s", cdbEntry);
112 // This the tracking configuration for the full TPC
113 // - 216 clusterfinders (1 per partition)
114 // - 36 slice trackers
115 // - one global merger
116 // - the esd converter
117 // The ESD is shipped embedded into a TTree
123 TString sinkClusterInput;
124 for (int slice=iMinSlice; slice<=iMaxSlice; slice++) {
125 TString trackerInput;
126 for (int part=iMinPart; part<=iMaxPart; part++) {
127 TString arg, publisher, cf;
129 // digit publisher components
130 publisher.Form("TPC-DP_%02d_%d", slice, part);
132 arg.Form("-slice %d -partition %d", slice, part);
133 handler->CreateConfiguration(publisher.Data(), "TPCDigitPublisher", NULL , arg.Data());
136 if (part>1) ddlno+=72+4*slice+(part-2);
137 else ddlno+=2*slice+part;
138 arg.Form("-minid %d -datatype 'DDL_RAW ' 'TPC ' -dataspec 0x%02x%02x%02x%02x -silent", ddlno, slice, slice, part, part);
139 handler->CreateConfiguration(publisher.Data(), "AliRawReaderPublisher", NULL , arg.Data());
142 // cluster finder components
143 cf.Form("TPC-CF_%02d_%d", slice, part);
146 arg+=" -timebins "; arg+=pTPCParam->GetMaxTBin()+1;
150 handler->CreateConfiguration(cf.Data(), "TPCClusterFinderUnpacked", publisher.Data(), arg.Data());
152 handler->CreateConfiguration(cf.Data(), "TPCClusterFinderDecoder", publisher.Data(), arg.Data());
154 if (trackerInput.Length()>0) trackerInput+=" ";
156 if (sinkClusterInput.Length()>0) sinkClusterInput+=" ";
157 sinkClusterInput+=cf;
160 // tracker finder components
161 tracker.Form("TPC-TR_%02d", slice);
162 handler->CreateConfiguration(tracker.Data(), "TPCSliceTracker", trackerInput.Data(), "-pp-run");
164 if (mergerInput.Length()>0) mergerInput+=" ";
165 mergerInput+=tracker;
169 // GlobalMerger component
170 handler->CreateConfiguration("TPC-globalmerger","TPCGlobalMerger",mergerInput.Data(),"");
172 // the esd converter configuration
173 handler->CreateConfiguration("TPC-esd-converter", "TPCEsdConverter" , "TPC-globalmerger", "");
175 // cluster dump collection
176 handler->CreateConfiguration("TPC-clusters", "BlockFilter" , sinkClusterInput.Data(), "-datatype 'CLUSTERS' 'TPC '");
178 /////////////////////////////////////////////////////////////////////////////////////
180 // a kChain HLTOUT configuration for processing of {'TRAKSEGS':'TPC '} data blocks
181 // collects the data blocks, merges the tracks and produces an ESD object
183 // publisher component
184 handler->CreateConfiguration("TPC-hltout-tracksegs-publisher", "AliHLTOUTPublisher" , NULL, "");
186 // GlobalMerger component
187 handler->CreateConfiguration("TPC-hltout-tracksegs-merger", "TPCGlobalMerger", "TPC-hltout-tracksegs-publisher", "");
189 // the esd converter configuration
190 handler->CreateConfiguration("TPC-hltout-tracksegs-esd-converter", "TPCEsdConverter", "TPC-hltout-tracksegs-merger", "");
192 /////////////////////////////////////////////////////////////////////////////////////
194 // a kChain HLTOUT configuration for processing of {'TRACKS ':'TPC '} data blocks
195 // produces an ESD object from the track structure
197 // publisher component
198 handler->CreateConfiguration("TPC-hltout-tracks-publisher", "AliHLTOUTPublisher" , NULL, "");
200 // the esd converter configuration
201 handler->CreateConfiguration("TPC-hltout-tracks-esd-converter", "TPCEsdConverter", "TPC-hltout-tracks-publisher", "");
206 const char* AliHLTTPCAgent::GetReconstructionChains(AliRawReader* /*rawReader*/,
207 AliRunLoader* runloader) const
209 // see header file for class documentation
211 // reconstruction chains for AliRoot simulation
212 // Note: run loader is only available while running embedded into
213 // AliRoot simulation
214 if (runloader->GetLoader("TPCLoader") != NULL)
215 return "TPC-esd-converter TPC-clusters";
220 const char* AliHLTTPCAgent::GetRequiredComponentLibraries() const
222 // see header file for class documentation
224 // actually, the TPC library has dependencies to Util and RCU
225 // so the two has to be loaded anyhow before we get here
226 //return "libAliHLTUtil.so libAliHLTRCU.so";
230 int AliHLTTPCAgent::RegisterComponents(AliHLTComponentHandler* pHandler) const
232 // see header file for class documentation
233 if (!pHandler) return -EINVAL;
235 pHandler->AddComponent(new AliHLTTPCRunStatisticsProducerComponent);
236 pHandler->AddComponent(new AliHLTTPCEventStatisticsProducerComponent);
237 pHandler->AddComponent(new AliHLTTPCCalibCEComponent);
238 pHandler->AddComponent(new AliHLTTPCCalibPulserComponent);
239 pHandler->AddComponent(new AliHLTTPCCalibPedestalComponent);
240 pHandler->AddComponent(new AliHLTTPCCompModelInflaterComponent);
241 pHandler->AddComponent(new AliHLTTPCCompModelDeflaterComponent);
242 pHandler->AddComponent(new AliHLTTPCCompModelDeconverterComponent);
243 pHandler->AddComponent(new AliHLTTPCCompModelConverterComponent);
244 pHandler->AddComponent(new AliHLTTPCCompDumpComponent);
245 pHandler->AddComponent(new AliHLTTPCCATrackerComponent);
246 pHandler->AddComponent(new AliHLTTPCGlobalMergerComponent);
247 pHandler->AddComponent(new AliHLTTPCSliceTrackerComponent);
248 pHandler->AddComponent(new AliHLTTPCVertexFinderComponent);
249 pHandler->AddComponent(new AliHLTTPCClusterFinderComponent(AliHLTTPCClusterFinderComponent::kClusterFinderPacked));
250 pHandler->AddComponent(new AliHLTTPCClusterFinderComponent(AliHLTTPCClusterFinderComponent::kClusterFinderUnpacked));
251 pHandler->AddComponent(new AliHLTTPCClusterFinderComponent(AliHLTTPCClusterFinderComponent::kClusterFinderDecoder));
252 pHandler->AddComponent(new AliHLTTPCRawDataUnpackerComponent);
253 pHandler->AddComponent(new AliHLTTPCDigitPublisherComponent);
254 pHandler->AddComponent(new AliHLTTPCZeroSuppressionComponent);
255 pHandler->AddComponent(new AliHLTTPCDigitDumpComponent);
256 pHandler->AddComponent(new AliHLTTPCClusterDumpComponent);
257 pHandler->AddComponent(new AliHLTTPCEsdWriterComponent::AliWriter);
258 pHandler->AddComponent(new AliHLTTPCEsdWriterComponent::AliConverter);
259 pHandler->AddComponent(new AliHLTTPCOfflineClustererComponent);
260 pHandler->AddComponent(new AliHLTTPCOfflineTrackerComponent);
261 pHandler->AddComponent(new AliHLTTPCOfflineTrackerCalibComponent);
262 pHandler->AddComponent(new AliHLTTPCOfflineCalibrationComponent);
263 pHandler->AddComponent(new AliHLTTPCClusterHistoComponent);
264 pHandler->AddComponent(new AliHLTTPCNoiseMapComponent);
265 pHandler->AddComponent(new AliHLTTPCHistogramHandlerComponent);
266 pHandler->AddComponent(new AliHLTTPCCalibTracksComponent);
267 pHandler->AddComponent(new AliHLTTPCTrackHistoComponent);
268 pHandler->AddComponent(new AliHLTTPCTrackDumpComponent);
269 pHandler->AddComponent(new AliHLTTPCHWCFDataReverterComponent);
274 int AliHLTTPCAgent::GetHandlerDescription(AliHLTComponentDataType dt,
276 AliHLTOUTHandlerDesc& desc) const
278 // see header file for class documentation
280 // raw data blocks to be fed into offline reconstruction
281 if (dt==(kAliHLTDataTypeDDLRaw|kAliHLTDataOriginTPC)) {
282 int slice=AliHLTTPCDefinitions::GetMinSliceNr(spec);
283 int part=AliHLTTPCDefinitions::GetMinPatchNr(spec);
284 if (slice==AliHLTTPCDefinitions::GetMaxSliceNr(spec) &&
285 part==AliHLTTPCDefinitions::GetMaxPatchNr(spec)) {
286 desc=AliHLTOUTHandlerDesc(kRawReader, dt, GetModuleId());
289 HLTWarning("handler can not process merged data from multiple ddls:"
290 " min slice %d, max slice %d, min part %d, max part %d",
291 slice, AliHLTTPCDefinitions::GetMaxSliceNr(spec),
292 part, AliHLTTPCDefinitions::GetMaxPatchNr(spec));
297 // dump for {'CLUSTERS':'TPC '} currently not used any more
298 if (dt==AliHLTTPCDefinitions::fgkClustersDataType) {
299 desc=AliHLTOUTHandlerDesc(kProprietary, dt, GetModuleId());
303 // afterburner for {'TRAKSEGS':'TPC '} blocks to be converted to ESD format
304 if (dt==AliHLTTPCDefinitions::fgkTrackSegmentsDataType) {
305 desc=AliHLTOUTHandlerDesc(kChain, dt, GetModuleId());
309 // afterburner for {'TRACKS ':'TPC '} block to be converted to ESD format
310 // there is only one data block
311 if (dt==AliHLTTPCDefinitions::fgkTracksDataType) {
312 desc=AliHLTOUTHandlerDesc(kChain, dt, GetModuleId());
318 AliHLTOUTHandler* AliHLTTPCAgent::GetOutputHandler(AliHLTComponentDataType dt,
319 AliHLTUInt32_t /*spec*/)
321 // see header file for class documentation
323 // raw data blocks to be fed into offline reconstruction
324 if (dt==(kAliHLTDataTypeDDLRaw|kAliHLTDataOriginTPC)) {
325 if (!fRawDataHandler) {
326 fRawDataHandler=new AliHLTTPCAgent::AliHLTTPCRawDataHandler;
328 return fRawDataHandler;
331 // afterburner for {'TRAKSEGS':'TPC '} blocks to be converted to ESD format
332 // in a kChain HLTOUT handler
333 if (dt==AliHLTTPCDefinitions::fgkTrackSegmentsDataType) {
334 if (fTracksegsDataHandler==NULL)
335 fTracksegsDataHandler=new AliHLTOUTHandlerChain("chains=TPC-hltout-tracksegs-esd-converter");
336 return fTracksegsDataHandler;
339 // afterburner for {'TRACKS ':'TPC '} block to be converted to ESD format
340 // there is only one data block
341 if (dt==AliHLTTPCDefinitions::fgkTracksDataType) {
342 return new AliHLTOUTHandlerChain("chains=TPC-hltout-tracks-esd-converter");
348 int AliHLTTPCAgent::DeleteOutputHandler(AliHLTOUTHandler* pInstance)
350 // see header file for class documentation
351 if (pInstance==NULL) return -EINVAL;
353 if (pInstance==fRawDataHandler) {
354 delete fRawDataHandler;
355 fRawDataHandler=NULL;
358 if (pInstance==fTracksegsDataHandler) {
359 delete fTracksegsDataHandler;
360 fTracksegsDataHandler=NULL;
365 AliHLTTPCAgent::AliHLTTPCRawDataHandler::AliHLTTPCRawDataHandler()
367 // see header file for class documentation
370 AliHLTTPCAgent::AliHLTTPCRawDataHandler::~AliHLTTPCRawDataHandler()
372 // see header file for class documentation
375 int AliHLTTPCAgent::AliHLTTPCRawDataHandler::ProcessData(AliHLTOUT* pData)
377 // see header file for class documentation
378 if (!pData) return -EINVAL;
379 AliHLTComponentDataType dt=kAliHLTVoidDataType;
380 AliHLTUInt32_t spec=kAliHLTVoidDataSpec;
381 int iResult=pData->GetDataBlockDescription(dt, spec);
383 int slice=AliHLTTPCDefinitions::GetMinSliceNr(spec);
384 int part=AliHLTTPCDefinitions::GetMinPatchNr(spec);
385 if (slice==AliHLTTPCDefinitions::GetMaxSliceNr(spec) &&
386 part==AliHLTTPCDefinitions::GetMaxPatchNr(spec)) {
388 if (part>1) iResult+=72+4*slice+(part-2);
389 else iResult+=2*slice+part;
391 HLTError("handler can not process merged data from multiple ddls:"
392 " min slice %d, max slice %d, min part %d, max part %d",
393 slice, AliHLTTPCDefinitions::GetMaxSliceNr(spec),
394 part, AliHLTTPCDefinitions::GetMaxPatchNr(spec));