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"
32 /** global instance for agent registration */
33 AliHLTTPCAgent gAliHLTTPCAgent;
36 #include "AliHLTTPCRunStatisticsProducerComponent.h"
37 #include "AliHLTTPCEventStatisticsProducerComponent.h"
38 #include "AliHLTTPCCompModelInflaterComponent.h"
39 #include "AliHLTTPCCompModelDeflaterComponent.h"
40 #include "AliHLTTPCCompModelDeconverterComponent.h"
41 #include "AliHLTTPCCompModelConverterComponent.h"
42 #include "AliHLTTPCCompDumpComponent.h"
43 #include "AliHLTTPCCalibCEComponent.h"
44 #include "AliHLTTPCCalibPulserComponent.h"
45 #include "AliHLTTPCCalibPedestalComponent.h"
46 #include "AliHLTTPCCATrackerComponent.h"
47 #include "AliHLTTPCGlobalMergerComponent.h"
48 #include "AliHLTTPCSliceTrackerComponent.h"
49 #include "AliHLTTPCVertexFinderComponent.h"
50 #include "AliHLTTPCClusterFinderComponent.h"
51 #include "AliHLTTPCRawDataUnpackerComponent.h"
52 #include "AliHLTTPCDigitPublisherComponent.h"
53 #include "AliHLTTPCZeroSuppressionComponent.h"
54 #include "AliHLTTPCDigitDumpComponent.h"
55 #include "AliHLTTPCClusterDumpComponent.h"
56 #include "AliHLTTPCEsdWriterComponent.h"
57 #include "AliHLTTPCOfflineClustererComponent.h"
58 #include "AliHLTTPCOfflineTrackerComponent.h"
59 #include "AliHLTTPCOfflineTrackerCalibComponent.h"
60 #include "AliHLTTPCOfflineCalibrationComponent.h"
61 #include "AliHLTTPCClusterHistoComponent.h"
62 #include "AliHLTTPCNoiseMapComponent.h"
63 #include "AliHLTTPCHistogramHandlerComponent.h"
64 #include "AliHLTTPCCalibTracksComponent.h"
65 #include "AliHLTTPCTrackHistoComponent.h"
66 #include "AliHLTTPCTrackDumpComponent.h"
69 /** ROOT macro for the implementation of ROOT specific class methods */
70 ClassImp(AliHLTTPCAgent)
72 AliHLTTPCAgent::AliHLTTPCAgent()
74 AliHLTModuleAgent("TPC"),
75 fRawDataHandler(NULL),
76 fTracksegsDataHandler(NULL)
78 // see header file for class documentation
80 // refer to README to build package
82 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
85 AliHLTTPCAgent::~AliHLTTPCAgent()
87 // see header file for class documentation
90 int AliHLTTPCAgent::CreateConfigurations(AliHLTConfigurationHandler* handler,
91 AliRawReader* rawReader,
92 AliRunLoader* /*runloader*/) const
94 // see header file for class documentation
97 // This the tracking configuration for the full TPC
98 // - 216 clusterfinders (1 per partition)
99 // - 36 slice trackers
100 // - one global merger
101 // - the esd converter
102 // The ESD is shipped embedded into a TTree
108 for (int slice=iMinSlice; slice<=iMaxSlice; slice++) {
109 TString trackerInput;
110 for (int part=iMinPart; part<=iMaxPart; part++) {
111 TString arg, publisher, cf;
113 // digit publisher components
114 publisher.Form("TPC-DP_%02d_%d", slice, part);
116 arg.Form("-slice %d -partition %d", slice, part);
117 handler->CreateConfiguration(publisher.Data(), "TPCDigitPublisher", NULL , arg.Data());
120 if (part>1) ddlno+=72+4*slice+(part-2);
121 else ddlno+=2*slice+part;
122 arg.Form("-minid %d -datatype 'DDL_RAW ' 'TPC ' -dataspec 0x%02x%02x%02x%02x -silent", ddlno, slice, slice, part, part);
123 handler->CreateConfiguration(publisher.Data(), "AliRawReaderPublisher", NULL , arg.Data());
126 // cluster finder components
127 cf.Form("TPC-CF_%02d_%d", slice, part);
129 handler->CreateConfiguration(cf.Data(), "TPCClusterFinderUnpacked", publisher.Data(), "-timebins 446 -sorted");
131 handler->CreateConfiguration(cf.Data(), "TPCClusterFinderDecoder", publisher.Data(), "-timebins 446");
133 if (trackerInput.Length()>0) trackerInput+=" ";
137 // tracker finder components
138 tracker.Form("TPC-TR_%02d", slice);
139 handler->CreateConfiguration(tracker.Data(), "TPCSliceTracker", trackerInput.Data(), "-pp-run -bfield 0.5");
141 if (mergerInput.Length()>0) mergerInput+=" ";
142 mergerInput+=tracker;
146 // GlobalMerger component
147 handler->CreateConfiguration("TPC-globalmerger","TPCGlobalMerger",mergerInput.Data(),"");
149 // the esd converter configuration
150 handler->CreateConfiguration("TPC-esd-converter", "TPCEsdConverter" , "TPC-globalmerger", "");
152 /////////////////////////////////////////////////////////////////////////////////////
154 // a kChain HLTOUT configuration for processing of {'TRAKSEGS':'TPC '} data blocks
155 // collects the data blocks, merges the tracks and produces an ESD object
157 // publisher component
158 handler->CreateConfiguration("TPC-hltout-tracksegs-publisher", "AliHLTOUTPublisher" , NULL, "");
160 // GlobalMerger component
161 handler->CreateConfiguration("TPC-hltout-tracksegs-merger", "TPCGlobalMerger", "TPC-hltout-tracksegs-publisher", "");
163 // the esd converter configuration
164 handler->CreateConfiguration("TPC-hltout-tracksegs-esd-converter", "TPCEsdConverter", "TPC-hltout-tracksegs-merger", "");
166 /////////////////////////////////////////////////////////////////////////////////////
168 // a kChain HLTOUT configuration for processing of {'TRACKS ':'TPC '} data blocks
169 // produces an ESD object from the track structure
171 // publisher component
172 handler->CreateConfiguration("TPC-hltout-tracks-publisher", "AliHLTOUTPublisher" , NULL, "");
174 // the esd converter configuration
175 handler->CreateConfiguration("TPC-hltout-tracks-esd-converter", "TPCEsdConverter", "TPC-hltout-tracks-publisher", "");
180 const char* AliHLTTPCAgent::GetReconstructionChains(AliRawReader* /*rawReader*/,
181 AliRunLoader* runloader) const
183 // see header file for class documentation
185 // reconstruction chains for AliRoot simulation
186 // Note: run loader is only available while running embedded into
187 // AliRoot simulation
188 if (runloader->GetLoader("TPCLoader") != NULL)
189 return "TPC-esd-converter";
194 const char* AliHLTTPCAgent::GetRequiredComponentLibraries() const
196 // see header file for class documentation
198 // actually, the TPC library has dependencies to Util and RCU
199 // so the two has to be loaded anyhow before we get here
200 //return "libAliHLTUtil.so libAliHLTRCU.so";
204 int AliHLTTPCAgent::RegisterComponents(AliHLTComponentHandler* pHandler) const
206 // see header file for class documentation
207 if (!pHandler) return -EINVAL;
209 pHandler->AddComponent(new AliHLTTPCRunStatisticsProducerComponent);
210 pHandler->AddComponent(new AliHLTTPCEventStatisticsProducerComponent);
211 pHandler->AddComponent(new AliHLTTPCCalibCEComponent);
212 pHandler->AddComponent(new AliHLTTPCCalibPulserComponent);
213 pHandler->AddComponent(new AliHLTTPCCalibPedestalComponent);
214 pHandler->AddComponent(new AliHLTTPCCompModelInflaterComponent);
215 pHandler->AddComponent(new AliHLTTPCCompModelDeflaterComponent);
216 pHandler->AddComponent(new AliHLTTPCCompModelDeconverterComponent);
217 pHandler->AddComponent(new AliHLTTPCCompModelConverterComponent);
218 pHandler->AddComponent(new AliHLTTPCCompDumpComponent);
219 pHandler->AddComponent(new AliHLTTPCCATrackerComponent);
220 pHandler->AddComponent(new AliHLTTPCGlobalMergerComponent);
221 pHandler->AddComponent(new AliHLTTPCSliceTrackerComponent);
222 pHandler->AddComponent(new AliHLTTPCVertexFinderComponent);
223 pHandler->AddComponent(new AliHLTTPCClusterFinderComponent(AliHLTTPCClusterFinderComponent::kClusterFinderPacked));
224 pHandler->AddComponent(new AliHLTTPCClusterFinderComponent(AliHLTTPCClusterFinderComponent::kClusterFinderUnpacked));
225 pHandler->AddComponent(new AliHLTTPCClusterFinderComponent(AliHLTTPCClusterFinderComponent::kClusterFinderDecoder));
226 pHandler->AddComponent(new AliHLTTPCRawDataUnpackerComponent);
227 pHandler->AddComponent(new AliHLTTPCDigitPublisherComponent);
228 pHandler->AddComponent(new AliHLTTPCZeroSuppressionComponent);
229 pHandler->AddComponent(new AliHLTTPCDigitDumpComponent);
230 pHandler->AddComponent(new AliHLTTPCClusterDumpComponent);
231 pHandler->AddComponent(new AliHLTTPCEsdWriterComponent::AliWriter);
232 pHandler->AddComponent(new AliHLTTPCEsdWriterComponent::AliConverter);
233 pHandler->AddComponent(new AliHLTTPCOfflineClustererComponent);
234 pHandler->AddComponent(new AliHLTTPCOfflineTrackerComponent);
235 pHandler->AddComponent(new AliHLTTPCOfflineTrackerCalibComponent);
236 pHandler->AddComponent(new AliHLTTPCOfflineCalibrationComponent);
237 pHandler->AddComponent(new AliHLTTPCClusterHistoComponent);
238 pHandler->AddComponent(new AliHLTTPCNoiseMapComponent);
239 pHandler->AddComponent(new AliHLTTPCHistogramHandlerComponent);
240 pHandler->AddComponent(new AliHLTTPCCalibTracksComponent);
241 pHandler->AddComponent(new AliHLTTPCTrackHistoComponent);
242 pHandler->AddComponent(new AliHLTTPCTrackDumpComponent);
247 int AliHLTTPCAgent::GetHandlerDescription(AliHLTComponentDataType dt,
249 AliHLTOUTHandlerDesc& desc) const
251 // see header file for class documentation
253 // raw data blocks to be fed into offline reconstruction
254 if (dt==(kAliHLTDataTypeDDLRaw|kAliHLTDataOriginTPC)) {
255 int slice=AliHLTTPCDefinitions::GetMinSliceNr(spec);
256 int part=AliHLTTPCDefinitions::GetMinPatchNr(spec);
257 if (slice==AliHLTTPCDefinitions::GetMaxSliceNr(spec) &&
258 part==AliHLTTPCDefinitions::GetMaxPatchNr(spec)) {
259 desc=AliHLTOUTHandlerDesc(kRawReader, dt, GetModuleId());
262 HLTWarning("handler can not process merged data from multiple ddls:"
263 " min slice %d, max slice %d, min part %d, max part %d",
264 slice, AliHLTTPCDefinitions::GetMaxSliceNr(spec),
265 part, AliHLTTPCDefinitions::GetMaxPatchNr(spec));
270 // afterburner for {'TRAKSEGS':'TPC '} blocks to be converted to ESD format
271 if (dt==AliHLTTPCDefinitions::fgkTrackSegmentsDataType) {
272 desc=AliHLTOUTHandlerDesc(kChain, dt, GetModuleId());
276 // afterburner for {'TRACKS ':'TPC '} block to be converted to ESD format
277 // there is only one data block
278 if (dt==AliHLTTPCDefinitions::fgkTracksDataType) {
279 desc=AliHLTOUTHandlerDesc(kChain, dt, GetModuleId());
285 AliHLTOUTHandler* AliHLTTPCAgent::GetOutputHandler(AliHLTComponentDataType dt,
286 AliHLTUInt32_t /*spec*/)
288 // see header file for class documentation
290 // raw data blocks to be fed into offline reconstruction
291 if (dt==(kAliHLTDataTypeDDLRaw|kAliHLTDataOriginTPC)) {
292 if (!fRawDataHandler) {
293 fRawDataHandler=new AliHLTTPCAgent::AliHLTTPCRawDataHandler;
295 return fRawDataHandler;
298 // afterburner for {'TRAKSEGS':'TPC '} blocks to be converted to ESD format
299 // in a kChain HLTOUT handler
300 if (dt==AliHLTTPCDefinitions::fgkTrackSegmentsDataType) {
301 if (fTracksegsDataHandler==NULL)
302 fTracksegsDataHandler=new AliHLTOUTHandlerChain("chains=TPC-hltout-tracksegs-esd-converter");
303 return fTracksegsDataHandler;
306 // afterburner for {'TRACKS ':'TPC '} block to be converted to ESD format
307 // there is only one data block
308 if (dt==AliHLTTPCDefinitions::fgkTracksDataType) {
309 return new AliHLTOUTHandlerChain("chains=TPC-hltout-tracks-esd-converter");
315 int AliHLTTPCAgent::DeleteOutputHandler(AliHLTOUTHandler* pInstance)
317 // see header file for class documentation
318 if (pInstance==NULL) return -EINVAL;
320 if (pInstance==fRawDataHandler) {
321 delete fRawDataHandler;
322 fRawDataHandler=NULL;
325 if (pInstance==fTracksegsDataHandler) {
326 delete fTracksegsDataHandler;
327 fTracksegsDataHandler=NULL;
332 AliHLTTPCAgent::AliHLTTPCRawDataHandler::AliHLTTPCRawDataHandler()
334 // see header file for class documentation
337 AliHLTTPCAgent::AliHLTTPCRawDataHandler::~AliHLTTPCRawDataHandler()
339 // see header file for class documentation
342 int AliHLTTPCAgent::AliHLTTPCRawDataHandler::ProcessData(AliHLTOUT* pData)
344 // see header file for class documentation
345 if (!pData) return -EINVAL;
346 AliHLTComponentDataType dt=kAliHLTVoidDataType;
347 AliHLTUInt32_t spec=kAliHLTVoidDataSpec;
348 int iResult=pData->GetDataBlockDescription(dt, spec);
350 int slice=AliHLTTPCDefinitions::GetMinSliceNr(spec);
351 int part=AliHLTTPCDefinitions::GetMinPatchNr(spec);
352 if (slice==AliHLTTPCDefinitions::GetMaxSliceNr(spec) &&
353 part==AliHLTTPCDefinitions::GetMaxPatchNr(spec)) {
355 if (part>1) iResult+=72+4*slice+(part-2);
356 else iResult+=2*slice+part;
358 HLTError("handler can not process merged data from multiple ddls:"
359 " min slice %d, max slice %d, min part %d, max part %d",
360 slice, AliHLTTPCDefinitions::GetMaxSliceNr(spec),
361 part, AliHLTTPCDefinitions::GetMaxPatchNr(spec));