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"
71 #include "AliHLTTPCHWClusterTransformComponent.h"
73 /** ROOT macro for the implementation of ROOT specific class methods */
74 ClassImp(AliHLTTPCAgent)
76 AliHLTTPCAgent::AliHLTTPCAgent()
78 AliHLTModuleAgent("TPC"),
79 fRawDataHandler(NULL),
80 fTracksegsDataHandler(NULL)
82 // see header file for class documentation
84 // refer to README to build package
86 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
89 AliHLTTPCAgent::~AliHLTTPCAgent()
91 // see header file for class documentation
94 int AliHLTTPCAgent::CreateConfigurations(AliHLTConfigurationHandler* handler,
95 AliRawReader* rawReader,
96 AliRunLoader* /*runloader*/) const
98 // see header file for class documentation
100 const char* cdbEntry="TPC/Calib/Parameters";
101 AliCDBManager* pMan=AliCDBManager::Instance();
102 AliTPCParam* pTPCParam=NULL;
104 AliCDBEntry *pEntry = pMan->Get(cdbEntry);
106 pEntry->GetObject() &&
107 (pTPCParam=dynamic_cast<AliTPCParam*>(pEntry->GetObject()))) {
109 HLTWarning("can not load AliTPCParam from CDB entry %s", cdbEntry);
113 // This the tracking configuration for the full TPC
114 // - 216 clusterfinders (1 per partition)
115 // - 36 slice trackers
116 // - one global merger
117 // - the esd converter
118 // The ESD is shipped embedded into a TTree
124 TString sinkClusterInput;
125 for (int slice=iMinSlice; slice<=iMaxSlice; slice++) {
126 TString trackerInput;
127 for (int part=iMinPart; part<=iMaxPart; part++) {
128 TString arg, publisher, cf;
130 // digit publisher components
131 publisher.Form("TPC-DP_%02d_%d", slice, part);
133 arg.Form("-slice %d -partition %d", slice, part);
134 handler->CreateConfiguration(publisher.Data(), "TPCDigitPublisher", NULL , arg.Data());
137 if (part>1) ddlno+=72+4*slice+(part-2);
138 else ddlno+=2*slice+part;
139 arg.Form("-minid %d -datatype 'DDL_RAW ' 'TPC ' -dataspec 0x%02x%02x%02x%02x -silent", ddlno, slice, slice, part, part);
140 handler->CreateConfiguration(publisher.Data(), "AliRawReaderPublisher", NULL , arg.Data());
143 // cluster finder components
144 cf.Form("TPC-CF_%02d_%d", slice, part);
147 arg+=" -timebins "; arg+=pTPCParam->GetMaxTBin()+1;
151 handler->CreateConfiguration(cf.Data(), "TPCClusterFinderUnpacked", publisher.Data(), arg.Data());
153 handler->CreateConfiguration(cf.Data(), "TPCClusterFinderDecoder", publisher.Data(), arg.Data());
155 if (trackerInput.Length()>0) trackerInput+=" ";
157 if (sinkClusterInput.Length()>0) sinkClusterInput+=" ";
158 sinkClusterInput+=cf;
161 // tracker finder components
162 tracker.Form("TPC-TR_%02d", slice);
163 handler->CreateConfiguration(tracker.Data(), "TPCSliceTracker", trackerInput.Data(), "-pp-run");
165 if (mergerInput.Length()>0) mergerInput+=" ";
166 mergerInput+=tracker;
170 // GlobalMerger component
171 handler->CreateConfiguration("TPC-globalmerger","TPCGlobalMerger",mergerInput.Data(),"");
173 // the esd converter configuration
174 handler->CreateConfiguration("TPC-esd-converter", "TPCEsdConverter" , "TPC-globalmerger", "");
176 // cluster dump collection
177 handler->CreateConfiguration("TPC-clusters", "BlockFilter" , sinkClusterInput.Data(), "-datatype 'CLUSTERS' 'TPC '");
179 /////////////////////////////////////////////////////////////////////////////////////
181 // a kChain HLTOUT configuration for processing of {'TRAKSEGS':'TPC '} data blocks
182 // collects the data blocks, merges the tracks and produces an ESD object
184 // publisher component
185 handler->CreateConfiguration("TPC-hltout-tracksegs-publisher", "AliHLTOUTPublisher" , NULL, "");
187 // GlobalMerger component
188 handler->CreateConfiguration("TPC-hltout-tracksegs-merger", "TPCGlobalMerger", "TPC-hltout-tracksegs-publisher", "");
190 // the esd converter configuration
191 handler->CreateConfiguration("TPC-hltout-tracksegs-esd-converter", "TPCEsdConverter", "TPC-hltout-tracksegs-merger", "");
193 /////////////////////////////////////////////////////////////////////////////////////
195 // a kChain HLTOUT configuration for processing of {'TRACKS ':'TPC '} data blocks
196 // produces an ESD object from the track structure
198 // publisher component
199 handler->CreateConfiguration("TPC-hltout-tracks-publisher", "AliHLTOUTPublisher" , NULL, "");
201 // the esd converter configuration
202 handler->CreateConfiguration("TPC-hltout-tracks-esd-converter", "TPCEsdConverter", "TPC-hltout-tracks-publisher", "");
207 const char* AliHLTTPCAgent::GetReconstructionChains(AliRawReader* /*rawReader*/,
208 AliRunLoader* runloader) const
210 // see header file for class documentation
212 // reconstruction chains for AliRoot simulation
213 // Note: run loader is only available while running embedded into
214 // AliRoot simulation
215 if (runloader->GetLoader("TPCLoader") != NULL)
216 return "TPC-esd-converter TPC-clusters";
221 const char* AliHLTTPCAgent::GetRequiredComponentLibraries() const
223 // see header file for class documentation
225 // actually, the TPC library has dependencies to Util and RCU
226 // so the two has to be loaded anyhow before we get here
227 //return "libAliHLTUtil.so libAliHLTRCU.so";
231 int AliHLTTPCAgent::RegisterComponents(AliHLTComponentHandler* pHandler) const
233 // see header file for class documentation
234 if (!pHandler) return -EINVAL;
236 pHandler->AddComponent(new AliHLTTPCRunStatisticsProducerComponent);
237 pHandler->AddComponent(new AliHLTTPCEventStatisticsProducerComponent);
238 pHandler->AddComponent(new AliHLTTPCCalibCEComponent);
239 pHandler->AddComponent(new AliHLTTPCCalibPulserComponent);
240 pHandler->AddComponent(new AliHLTTPCCalibPedestalComponent);
241 pHandler->AddComponent(new AliHLTTPCCompModelInflaterComponent);
242 pHandler->AddComponent(new AliHLTTPCCompModelDeflaterComponent);
243 pHandler->AddComponent(new AliHLTTPCCompModelDeconverterComponent);
244 pHandler->AddComponent(new AliHLTTPCCompModelConverterComponent);
245 pHandler->AddComponent(new AliHLTTPCCompDumpComponent);
246 // pHandler->AddComponent(new AliHLTTPCCATrackerComponent);
247 pHandler->AddComponent(new AliHLTTPCGlobalMergerComponent);
248 pHandler->AddComponent(new AliHLTTPCSliceTrackerComponent);
249 pHandler->AddComponent(new AliHLTTPCVertexFinderComponent);
250 pHandler->AddComponent(new AliHLTTPCClusterFinderComponent(AliHLTTPCClusterFinderComponent::kClusterFinderPacked));
251 pHandler->AddComponent(new AliHLTTPCClusterFinderComponent(AliHLTTPCClusterFinderComponent::kClusterFinderUnpacked));
252 pHandler->AddComponent(new AliHLTTPCClusterFinderComponent(AliHLTTPCClusterFinderComponent::kClusterFinderDecoder));
253 pHandler->AddComponent(new AliHLTTPCClusterFinderComponent(AliHLTTPCClusterFinderComponent::kClusterFinder32Bit));
254 pHandler->AddComponent(new AliHLTTPCRawDataUnpackerComponent);
255 pHandler->AddComponent(new AliHLTTPCDigitPublisherComponent);
256 pHandler->AddComponent(new AliHLTTPCZeroSuppressionComponent);
257 pHandler->AddComponent(new AliHLTTPCDigitDumpComponent);
258 pHandler->AddComponent(new AliHLTTPCClusterDumpComponent);
259 pHandler->AddComponent(new AliHLTTPCEsdWriterComponent::AliWriter);
260 pHandler->AddComponent(new AliHLTTPCEsdWriterComponent::AliConverter);
261 pHandler->AddComponent(new AliHLTTPCOfflineClustererComponent);
262 pHandler->AddComponent(new AliHLTTPCOfflineTrackerComponent);
263 pHandler->AddComponent(new AliHLTTPCOfflineTrackerCalibComponent);
264 pHandler->AddComponent(new AliHLTTPCOfflineCalibrationComponent);
265 pHandler->AddComponent(new AliHLTTPCClusterHistoComponent);
266 pHandler->AddComponent(new AliHLTTPCNoiseMapComponent);
267 pHandler->AddComponent(new AliHLTTPCHistogramHandlerComponent);
268 pHandler->AddComponent(new AliHLTTPCCalibTracksComponent);
269 pHandler->AddComponent(new AliHLTTPCTrackHistoComponent);
270 pHandler->AddComponent(new AliHLTTPCTrackDumpComponent);
271 pHandler->AddComponent(new AliHLTTPCHWCFDataReverterComponent);
272 pHandler->AddComponent(new AliHLTTPCHWClusterTransformComponent);
277 int AliHLTTPCAgent::GetHandlerDescription(AliHLTComponentDataType dt,
279 AliHLTOUTHandlerDesc& desc) const
281 // see header file for class documentation
283 // raw data blocks to be fed into offline reconstruction
284 if (dt==(kAliHLTDataTypeDDLRaw|kAliHLTDataOriginTPC)) {
285 int slice=AliHLTTPCDefinitions::GetMinSliceNr(spec);
286 int part=AliHLTTPCDefinitions::GetMinPatchNr(spec);
287 if (slice==AliHLTTPCDefinitions::GetMaxSliceNr(spec) &&
288 part==AliHLTTPCDefinitions::GetMaxPatchNr(spec)) {
289 desc=AliHLTOUTHandlerDesc(kRawReader, dt, GetModuleId());
292 HLTWarning("handler can not process merged data from multiple ddls:"
293 " min slice %d, max slice %d, min part %d, max part %d",
294 slice, AliHLTTPCDefinitions::GetMaxSliceNr(spec),
295 part, AliHLTTPCDefinitions::GetMaxPatchNr(spec));
300 // dump for {'CLUSTERS':'TPC '} currently not used any more
301 if (dt==AliHLTTPCDefinitions::fgkClustersDataType) {
302 desc=AliHLTOUTHandlerDesc(kProprietary, dt, GetModuleId());
306 // afterburner for {'TRAKSEGS':'TPC '} blocks to be converted to ESD format
307 if (dt==AliHLTTPCDefinitions::fgkTrackSegmentsDataType) {
308 desc=AliHLTOUTHandlerDesc(kChain, dt, GetModuleId());
312 // afterburner for {'TRACKS ':'TPC '} block to be converted to ESD format
313 // there is only one data block
314 if (dt==AliHLTTPCDefinitions::fgkTracksDataType) {
315 desc=AliHLTOUTHandlerDesc(kChain, dt, GetModuleId());
321 AliHLTOUTHandler* AliHLTTPCAgent::GetOutputHandler(AliHLTComponentDataType dt,
322 AliHLTUInt32_t /*spec*/)
324 // see header file for class documentation
326 // raw data blocks to be fed into offline reconstruction
327 if (dt==(kAliHLTDataTypeDDLRaw|kAliHLTDataOriginTPC)) {
328 if (!fRawDataHandler) {
329 fRawDataHandler=new AliHLTTPCAgent::AliHLTTPCRawDataHandler;
331 return fRawDataHandler;
334 // afterburner for {'TRAKSEGS':'TPC '} blocks to be converted to ESD format
335 // in a kChain HLTOUT handler
336 if (dt==AliHLTTPCDefinitions::fgkTrackSegmentsDataType) {
337 if (fTracksegsDataHandler==NULL)
338 fTracksegsDataHandler=new AliHLTOUTHandlerChain("chains=TPC-hltout-tracksegs-esd-converter");
339 return fTracksegsDataHandler;
342 // afterburner for {'TRACKS ':'TPC '} block to be converted to ESD format
343 // there is only one data block
344 if (dt==AliHLTTPCDefinitions::fgkTracksDataType) {
345 return new AliHLTOUTHandlerChain("chains=TPC-hltout-tracks-esd-converter");
351 int AliHLTTPCAgent::DeleteOutputHandler(AliHLTOUTHandler* pInstance)
353 // see header file for class documentation
354 if (pInstance==NULL) return -EINVAL;
356 if (pInstance==fRawDataHandler) {
357 delete fRawDataHandler;
358 fRawDataHandler=NULL;
361 if (pInstance==fTracksegsDataHandler) {
362 delete fTracksegsDataHandler;
363 fTracksegsDataHandler=NULL;
368 AliHLTTPCAgent::AliHLTTPCRawDataHandler::AliHLTTPCRawDataHandler()
370 // see header file for class documentation
373 AliHLTTPCAgent::AliHLTTPCRawDataHandler::~AliHLTTPCRawDataHandler()
375 // see header file for class documentation
378 int AliHLTTPCAgent::AliHLTTPCRawDataHandler::ProcessData(AliHLTOUT* pData)
380 // see header file for class documentation
381 if (!pData) return -EINVAL;
382 AliHLTComponentDataType dt=kAliHLTVoidDataType;
383 AliHLTUInt32_t spec=kAliHLTVoidDataSpec;
384 int iResult=pData->GetDataBlockDescription(dt, spec);
386 int slice=AliHLTTPCDefinitions::GetMinSliceNr(spec);
387 int part=AliHLTTPCDefinitions::GetMinPatchNr(spec);
388 if (slice==AliHLTTPCDefinitions::GetMaxSliceNr(spec) &&
389 part==AliHLTTPCDefinitions::GetMaxPatchNr(spec)) {
391 if (part>1) iResult+=72+4*slice+(part-2);
392 else iResult+=2*slice+part;
394 HLTError("handler can not process merged data from multiple ddls:"
395 " min slice %d, max slice %d, min part %d, max part %d",
396 slice, AliHLTTPCDefinitions::GetMaxSliceNr(spec),
397 part, AliHLTTPCDefinitions::GetMaxPatchNr(spec));