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 for (int slice=iMinSlice; slice<=iMaxSlice; slice++) {
124 TString trackerInput;
125 for (int part=iMinPart; part<=iMaxPart; part++) {
126 TString arg, publisher, cf;
128 // digit publisher components
129 publisher.Form("TPC-DP_%02d_%d", slice, part);
131 arg.Form("-slice %d -partition %d", slice, part);
132 handler->CreateConfiguration(publisher.Data(), "TPCDigitPublisher", NULL , arg.Data());
135 if (part>1) ddlno+=72+4*slice+(part-2);
136 else ddlno+=2*slice+part;
137 arg.Form("-minid %d -datatype 'DDL_RAW ' 'TPC ' -dataspec 0x%02x%02x%02x%02x -silent", ddlno, slice, slice, part, part);
138 handler->CreateConfiguration(publisher.Data(), "AliRawReaderPublisher", NULL , arg.Data());
141 // cluster finder components
142 cf.Form("TPC-CF_%02d_%d", slice, part);
145 arg+=" -timebins "; arg+=pTPCParam->GetMaxTBin()+1;
149 handler->CreateConfiguration(cf.Data(), "TPCClusterFinderUnpacked", publisher.Data(), arg.Data());
151 handler->CreateConfiguration(cf.Data(), "TPCClusterFinderDecoder", publisher.Data(), arg.Data());
153 if (trackerInput.Length()>0) trackerInput+=" ";
157 // tracker finder components
158 tracker.Form("TPC-TR_%02d", slice);
159 handler->CreateConfiguration(tracker.Data(), "TPCSliceTracker", trackerInput.Data(), "-pp-run -bfield 0.5");
161 if (mergerInput.Length()>0) mergerInput+=" ";
162 mergerInput+=tracker;
166 // GlobalMerger component
167 handler->CreateConfiguration("TPC-globalmerger","TPCGlobalMerger",mergerInput.Data(),"");
169 // the esd converter configuration
170 handler->CreateConfiguration("TPC-esd-converter", "TPCEsdConverter" , "TPC-globalmerger", "");
172 /////////////////////////////////////////////////////////////////////////////////////
174 // a kChain HLTOUT configuration for processing of {'TRAKSEGS':'TPC '} data blocks
175 // collects the data blocks, merges the tracks and produces an ESD object
177 // publisher component
178 handler->CreateConfiguration("TPC-hltout-tracksegs-publisher", "AliHLTOUTPublisher" , NULL, "");
180 // GlobalMerger component
181 handler->CreateConfiguration("TPC-hltout-tracksegs-merger", "TPCGlobalMerger", "TPC-hltout-tracksegs-publisher", "");
183 // the esd converter configuration
184 handler->CreateConfiguration("TPC-hltout-tracksegs-esd-converter", "TPCEsdConverter", "TPC-hltout-tracksegs-merger", "");
186 /////////////////////////////////////////////////////////////////////////////////////
188 // a kChain HLTOUT configuration for processing of {'TRACKS ':'TPC '} data blocks
189 // produces an ESD object from the track structure
191 // publisher component
192 handler->CreateConfiguration("TPC-hltout-tracks-publisher", "AliHLTOUTPublisher" , NULL, "");
194 // the esd converter configuration
195 handler->CreateConfiguration("TPC-hltout-tracks-esd-converter", "TPCEsdConverter", "TPC-hltout-tracks-publisher", "");
200 const char* AliHLTTPCAgent::GetReconstructionChains(AliRawReader* /*rawReader*/,
201 AliRunLoader* runloader) const
203 // see header file for class documentation
205 // reconstruction chains for AliRoot simulation
206 // Note: run loader is only available while running embedded into
207 // AliRoot simulation
208 if (runloader->GetLoader("TPCLoader") != NULL)
209 return "TPC-esd-converter";
214 const char* AliHLTTPCAgent::GetRequiredComponentLibraries() const
216 // see header file for class documentation
218 // actually, the TPC library has dependencies to Util and RCU
219 // so the two has to be loaded anyhow before we get here
220 //return "libAliHLTUtil.so libAliHLTRCU.so";
224 int AliHLTTPCAgent::RegisterComponents(AliHLTComponentHandler* pHandler) const
226 // see header file for class documentation
227 if (!pHandler) return -EINVAL;
229 pHandler->AddComponent(new AliHLTTPCRunStatisticsProducerComponent);
230 pHandler->AddComponent(new AliHLTTPCEventStatisticsProducerComponent);
231 pHandler->AddComponent(new AliHLTTPCCalibCEComponent);
232 pHandler->AddComponent(new AliHLTTPCCalibPulserComponent);
233 pHandler->AddComponent(new AliHLTTPCCalibPedestalComponent);
234 pHandler->AddComponent(new AliHLTTPCCompModelInflaterComponent);
235 pHandler->AddComponent(new AliHLTTPCCompModelDeflaterComponent);
236 pHandler->AddComponent(new AliHLTTPCCompModelDeconverterComponent);
237 pHandler->AddComponent(new AliHLTTPCCompModelConverterComponent);
238 pHandler->AddComponent(new AliHLTTPCCompDumpComponent);
239 pHandler->AddComponent(new AliHLTTPCCATrackerComponent);
240 pHandler->AddComponent(new AliHLTTPCGlobalMergerComponent);
241 pHandler->AddComponent(new AliHLTTPCSliceTrackerComponent);
242 pHandler->AddComponent(new AliHLTTPCVertexFinderComponent);
243 pHandler->AddComponent(new AliHLTTPCClusterFinderComponent(AliHLTTPCClusterFinderComponent::kClusterFinderPacked));
244 pHandler->AddComponent(new AliHLTTPCClusterFinderComponent(AliHLTTPCClusterFinderComponent::kClusterFinderUnpacked));
245 pHandler->AddComponent(new AliHLTTPCClusterFinderComponent(AliHLTTPCClusterFinderComponent::kClusterFinderDecoder));
246 pHandler->AddComponent(new AliHLTTPCRawDataUnpackerComponent);
247 pHandler->AddComponent(new AliHLTTPCDigitPublisherComponent);
248 pHandler->AddComponent(new AliHLTTPCZeroSuppressionComponent);
249 pHandler->AddComponent(new AliHLTTPCDigitDumpComponent);
250 pHandler->AddComponent(new AliHLTTPCClusterDumpComponent);
251 pHandler->AddComponent(new AliHLTTPCEsdWriterComponent::AliWriter);
252 pHandler->AddComponent(new AliHLTTPCEsdWriterComponent::AliConverter);
253 pHandler->AddComponent(new AliHLTTPCOfflineClustererComponent);
254 pHandler->AddComponent(new AliHLTTPCOfflineTrackerComponent);
255 pHandler->AddComponent(new AliHLTTPCOfflineTrackerCalibComponent);
256 pHandler->AddComponent(new AliHLTTPCOfflineCalibrationComponent);
257 pHandler->AddComponent(new AliHLTTPCClusterHistoComponent);
258 pHandler->AddComponent(new AliHLTTPCNoiseMapComponent);
259 pHandler->AddComponent(new AliHLTTPCHistogramHandlerComponent);
260 pHandler->AddComponent(new AliHLTTPCCalibTracksComponent);
261 pHandler->AddComponent(new AliHLTTPCTrackHistoComponent);
262 pHandler->AddComponent(new AliHLTTPCTrackDumpComponent);
263 pHandler->AddComponent(new AliHLTTPCHWCFDataReverterComponent);
268 int AliHLTTPCAgent::GetHandlerDescription(AliHLTComponentDataType dt,
270 AliHLTOUTHandlerDesc& desc) const
272 // see header file for class documentation
274 // raw data blocks to be fed into offline reconstruction
275 if (dt==(kAliHLTDataTypeDDLRaw|kAliHLTDataOriginTPC)) {
276 int slice=AliHLTTPCDefinitions::GetMinSliceNr(spec);
277 int part=AliHLTTPCDefinitions::GetMinPatchNr(spec);
278 if (slice==AliHLTTPCDefinitions::GetMaxSliceNr(spec) &&
279 part==AliHLTTPCDefinitions::GetMaxPatchNr(spec)) {
280 desc=AliHLTOUTHandlerDesc(kRawReader, dt, GetModuleId());
283 HLTWarning("handler can not process merged data from multiple ddls:"
284 " min slice %d, max slice %d, min part %d, max part %d",
285 slice, AliHLTTPCDefinitions::GetMaxSliceNr(spec),
286 part, AliHLTTPCDefinitions::GetMaxPatchNr(spec));
291 // afterburner for {'TRAKSEGS':'TPC '} blocks to be converted to ESD format
292 if (dt==AliHLTTPCDefinitions::fgkTrackSegmentsDataType) {
293 desc=AliHLTOUTHandlerDesc(kChain, dt, GetModuleId());
297 // afterburner for {'TRACKS ':'TPC '} block to be converted to ESD format
298 // there is only one data block
299 if (dt==AliHLTTPCDefinitions::fgkTracksDataType) {
300 desc=AliHLTOUTHandlerDesc(kChain, dt, GetModuleId());
306 AliHLTOUTHandler* AliHLTTPCAgent::GetOutputHandler(AliHLTComponentDataType dt,
307 AliHLTUInt32_t /*spec*/)
309 // see header file for class documentation
311 // raw data blocks to be fed into offline reconstruction
312 if (dt==(kAliHLTDataTypeDDLRaw|kAliHLTDataOriginTPC)) {
313 if (!fRawDataHandler) {
314 fRawDataHandler=new AliHLTTPCAgent::AliHLTTPCRawDataHandler;
316 return fRawDataHandler;
319 // afterburner for {'TRAKSEGS':'TPC '} blocks to be converted to ESD format
320 // in a kChain HLTOUT handler
321 if (dt==AliHLTTPCDefinitions::fgkTrackSegmentsDataType) {
322 if (fTracksegsDataHandler==NULL)
323 fTracksegsDataHandler=new AliHLTOUTHandlerChain("chains=TPC-hltout-tracksegs-esd-converter");
324 return fTracksegsDataHandler;
327 // afterburner for {'TRACKS ':'TPC '} block to be converted to ESD format
328 // there is only one data block
329 if (dt==AliHLTTPCDefinitions::fgkTracksDataType) {
330 return new AliHLTOUTHandlerChain("chains=TPC-hltout-tracks-esd-converter");
336 int AliHLTTPCAgent::DeleteOutputHandler(AliHLTOUTHandler* pInstance)
338 // see header file for class documentation
339 if (pInstance==NULL) return -EINVAL;
341 if (pInstance==fRawDataHandler) {
342 delete fRawDataHandler;
343 fRawDataHandler=NULL;
346 if (pInstance==fTracksegsDataHandler) {
347 delete fTracksegsDataHandler;
348 fTracksegsDataHandler=NULL;
353 AliHLTTPCAgent::AliHLTTPCRawDataHandler::AliHLTTPCRawDataHandler()
355 // see header file for class documentation
358 AliHLTTPCAgent::AliHLTTPCRawDataHandler::~AliHLTTPCRawDataHandler()
360 // see header file for class documentation
363 int AliHLTTPCAgent::AliHLTTPCRawDataHandler::ProcessData(AliHLTOUT* pData)
365 // see header file for class documentation
366 if (!pData) return -EINVAL;
367 AliHLTComponentDataType dt=kAliHLTVoidDataType;
368 AliHLTUInt32_t spec=kAliHLTVoidDataSpec;
369 int iResult=pData->GetDataBlockDescription(dt, spec);
371 int slice=AliHLTTPCDefinitions::GetMinSliceNr(spec);
372 int part=AliHLTTPCDefinitions::GetMinPatchNr(spec);
373 if (slice==AliHLTTPCDefinitions::GetMaxSliceNr(spec) &&
374 part==AliHLTTPCDefinitions::GetMaxPatchNr(spec)) {
376 if (part>1) iResult+=72+4*slice+(part-2);
377 else iResult+=2*slice+part;
379 HLTError("handler can not process merged data from multiple ddls:"
380 " min slice %d, max slice %d, min part %d, max part %d",
381 slice, AliHLTTPCDefinitions::GetMaxSliceNr(spec),
382 part, AliHLTTPCDefinitions::GetMaxPatchNr(spec));