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 "AliHLTTPCDefinitions.h"
27 #include "AliHLTOUT.h"
28 #include "AliHLTOUTHandlerChain.h"
29 #include "AliRunLoader.h"
30 #include "AliCDBManager.h"
31 #include "AliCDBEntry.h"
32 #include "AliTPCParam.h"
34 /** global instance for agent registration */
35 AliHLTTPCAgent gAliHLTTPCAgent;
38 #include "AliHLTTPCRunStatisticsProducerComponent.h"
39 #include "AliHLTTPCEventStatisticsProducerComponent.h"
40 #include "AliHLTTPCCompModelInflaterComponent.h"
41 #include "AliHLTTPCCompModelDeflaterComponent.h"
42 #include "AliHLTTPCCompModelDeconverterComponent.h"
43 #include "AliHLTTPCCompModelConverterComponent.h"
44 #include "AliHLTTPCCompDumpComponent.h"
45 //#include "AliHLTTPCCalibCEComponent.h"
46 //#include "AliHLTTPCCalibPulserComponent.h"
47 //#include "AliHLTTPCCalibPedestalComponent.h"
48 #include "AliHLTTPCCAInputDataCompressorComponent.h"
49 #include "AliHLTTPCCATrackerComponent.h"
50 #include "AliHLTTPCCATrackerOutputConverter.h"
51 #include "AliHLTTPCTrackMCMarkerComponent.h"
52 #include "AliHLTTPCCAGlobalMergerComponent.h"
53 #include "AliHLTTPCdEdxComponent.h"
54 #include "AliHLTTPCGlobalMergerComponent.h"
55 #include "AliHLTTPCSliceTrackerComponent.h"
56 #include "AliHLTTPCVertexFinderComponent.h"
57 #include "AliHLTTPCClusterFinderComponent.h"
58 #include "AliHLTTPCRawDataUnpackerComponent.h"
59 #include "AliHLTTPCDigitPublisherComponent.h"
60 #include "AliHLTTPCZeroSuppressionComponent.h"
61 #include "AliHLTTPCDigitDumpComponent.h"
62 #include "AliHLTTPCClusterDumpComponent.h"
63 #include "AliHLTTPCEsdWriterComponent.h"
64 #include "AliHLTTPCOfflineClustererComponent.h"
65 #include "AliHLTTPCOfflineTrackerComponent.h"
66 #include "AliHLTTPCOfflineTrackerCalibComponent.h"
67 #include "AliHLTTPCOfflineCalibrationComponent.h" // to be added to the calibration library agent
68 #include "AliHLTTPCClusterHistoComponent.h"
69 #include "AliHLTTPCNoiseMapComponent.h"
70 #include "AliHLTTPCHistogramHandlerComponent.h"
71 //#include "AliHLTTPCCalibTracksComponent.h"
72 #include "AliHLTTPCTrackHistoComponent.h"
73 #include "AliHLTTPCTrackDumpComponent.h"
74 #include "AliHLTTPCHWCFDataReverterComponent.h"
75 #include "AliHLTTPCHWClusterTransformComponent.h"
76 #include "AliHLTTPCCFComparisonComponent.h"
77 // #include "AliHLTTPCCalibSeedMakerComponent.h"
78 // #include "AliHLTTPCCalibTimeComponent.h"
79 // #include "AliHLTTPCCalibTimeGainComponent.h"
80 // #include "AliHLTTPCCalibrationComponent.h"
81 #include "AliHLTTPCDataCheckerComponent.h"
83 /** ROOT macro for the implementation of ROOT specific class methods */
84 ClassImp(AliHLTTPCAgent)
86 AliHLTTPCAgent::AliHLTTPCAgent()
87 : AliHLTModuleAgent("TPC")
88 , fRawDataHandler(NULL)
89 , fTracksegsDataHandler(NULL)
90 , fClustersDataHandler(NULL)
92 // see header file for class documentation
94 // refer to README to build package
96 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
99 AliHLTTPCAgent::~AliHLTTPCAgent()
101 // see header file for class documentation
104 int AliHLTTPCAgent::CreateConfigurations(AliHLTConfigurationHandler* handler,
105 AliRawReader* rawReader,
106 AliRunLoader* runloader) const
108 // see header file for class documentation
111 // This the tracking configuration for the full TPC
112 // - 216 clusterfinders (1 per partition)
113 // - 36 slice trackers
114 // - one global merger
115 // - the esd converter
116 // The ESD is shipped embedded into a TTree
122 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);
131 if (rawReader || !runloader) {
132 // AliSimulation: use the AliRawReaderPublisher if the raw reader is available
133 // Alireconstruction: indicated by runloader==NULL, run always on raw 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());
140 arg.Form("-slice %d -partition %d", slice, part);
141 handler->CreateConfiguration(publisher.Data(), "TPCDigitPublisher", NULL , arg.Data());
144 // cluster finder components
145 cf.Form("TPC-CF_%02d_%d", slice, part);
146 arg="-release-memory";
147 if (!rawReader && runloader) {
149 handler->CreateConfiguration(cf.Data(), "TPCClusterFinderUnpacked", publisher.Data(), arg.Data());
151 #ifndef HAVE_NOT_ALTRORAWSTREAMV3
152 handler->CreateConfiguration(cf.Data(), "TPCClusterFinder32Bit", publisher.Data(),arg.Data());
154 // using the AltroDecoder if the official V3 decoder is not
155 // available in the offline code
156 handler->CreateConfiguration(cf.Data(), "TPCClusterFinderDecoder", publisher.Data(), arg.Data());
159 if (trackerInput.Length()>0) trackerInput+=" ";
161 if (dEdXInput.Length()>0) dEdXInput+=" ";
163 if (sinkClusterInput.Length()>0) sinkClusterInput+=" ";
164 sinkClusterInput+=cf;
167 // tracker finder components
168 tracker.Form("TPC-TR_%02d", slice);
169 handler->CreateConfiguration(tracker.Data(), "TPCCATracker", trackerInput.Data(), "");
171 if (mergerInput.Length()>0) mergerInput+=" ";
172 mergerInput+=tracker;
176 // GlobalMerger component
177 handler->CreateConfiguration("TPC-globalmerger","TPCCAGlobalMerger",mergerInput.Data(),"");
179 if (dEdXInput.Length()>0) dEdXInput+=" ";
180 dEdXInput+="TPC-globalmerger";
182 handler->CreateConfiguration("TPC-dEdx","TPCdEdx",dEdXInput.Data(),"");
184 // the esd converter configuration
185 TString converterInput="TPC-globalmerger";
186 if (!rawReader && runloader) {
187 // propagate cluster info to the esd converter in order to fill the MC information
188 handler->CreateConfiguration("TPC-clustermc-info", "BlockFilter" , sinkClusterInput.Data(), "-datatype 'CLMCINFO' 'TPC '");
189 handler->CreateConfiguration("TPC-mcTrackMarker","TPCTrackMCMarker","TPC-globalmerger TPC-clustermc-info","" );
191 converterInput+="TPC-mcTrackMarker";
193 handler->CreateConfiguration("TPC-esd-converter", "TPCEsdConverter" , converterInput.Data(), "");
195 // cluster dump collection
196 handler->CreateConfiguration("TPC-clusters", "BlockFilter" , sinkClusterInput.Data(), "-datatype 'CLUSTERS' 'TPC '");
198 /////////////////////////////////////////////////////////////////////////////////////
200 // a kChain HLTOUT configuration for processing of {'TRAKSEGS':'TPC '} data blocks
201 // collects the data blocks, merges the tracks and produces an ESD object
203 // publisher component
204 handler->CreateConfiguration("TPC-hltout-tracksegs-publisher", "AliHLTOUTPublisher" , NULL, "");
206 // GlobalMerger component
207 handler->CreateConfiguration("TPC-hltout-tracksegs-merger", "TPCGlobalMerger", "TPC-hltout-tracksegs-publisher", "");
209 // the esd converter configuration
210 handler->CreateConfiguration("TPC-hltout-tracksegs-esd-converter", "TPCEsdConverter", "TPC-hltout-tracksegs-merger", "");
212 /////////////////////////////////////////////////////////////////////////////////////
214 // a kChain HLTOUT configuration for processing of {'TRACKS ':'TPC '} data blocks
215 // produces an ESD object from the track structure
217 // publisher component
218 handler->CreateConfiguration("TPC-hltout-tracks-publisher", "AliHLTOUTPublisher" , NULL, "");
220 // the esd converter configuration
221 handler->CreateConfiguration("TPC-hltout-tracks-esd-converter", "TPCEsdConverter", "TPC-hltout-tracks-publisher", "");
223 /////////////////////////////////////////////////////////////////////////////////////
225 // a kChain HLTOUT configuration for processing of {'CLUSTERS':'TPC '} data blocks
226 // stores the blocks in file HLT.TPC.Clusters.root in HOMER format
228 // publisher component
229 handler->CreateConfiguration("TPC-hltout-cluster-publisher", "AliHLTOUTPublisher" , NULL, "");
231 // the HLTOUT component collects the blocks and stores the file
232 handler->CreateConfiguration("TPC-hltout-cluster-dump", "HLTOUT", "TPC-hltout-cluster-publisher", "-digitfile HLT.TPC.Clusters.root -rawout=off -links 2");
238 const char* AliHLTTPCAgent::GetReconstructionChains(AliRawReader* /*rawReader*/,
239 AliRunLoader* runloader) const
241 // see header file for class documentation
243 // reconstruction chains for AliRoot simulation
244 // Note: run loader is only available while running embedded into
245 // AliRoot simulation
246 //if (runloader->GetLoader("TPCLoader") != NULL)
247 //return "TPC-esd-converter TPC-clusters";
249 // 2010-10-26 TPC clusters not written to HLTOUT in order to make the simulation
250 // closer to the real data
251 //return "TPC-clusters";
256 const char* AliHLTTPCAgent::GetRequiredComponentLibraries() const
258 // see header file for class documentation
260 // actually, the TPC library has dependencies to Util and RCU
261 // so the two has to be loaded anyhow before we get here
262 //return "libAliHLTUtil.so libAliHLTRCU.so";
263 return "libAliHLTUtil.so";
266 int AliHLTTPCAgent::RegisterComponents(AliHLTComponentHandler* pHandler) const
268 // see header file for class documentation
269 if (!pHandler) return -EINVAL;
271 pHandler->AddComponent(new AliHLTTPCRunStatisticsProducerComponent);
272 pHandler->AddComponent(new AliHLTTPCEventStatisticsProducerComponent);
273 // pHandler->AddComponent(new AliHLTTPCCalibCEComponent);
274 // pHandler->AddComponent(new AliHLTTPCCalibPulserComponent);
275 // pHandler->AddComponent(new AliHLTTPCCalibPedestalComponent);
276 pHandler->AddComponent(new AliHLTTPCCompModelInflaterComponent);
277 pHandler->AddComponent(new AliHLTTPCCompModelDeflaterComponent);
278 pHandler->AddComponent(new AliHLTTPCCompModelDeconverterComponent);
279 pHandler->AddComponent(new AliHLTTPCCompModelConverterComponent);
280 pHandler->AddComponent(new AliHLTTPCCompDumpComponent);
281 pHandler->AddComponent(new AliHLTTPCCAInputDataCompressorComponent);
282 pHandler->AddComponent(new AliHLTTPCCATrackerComponent);
283 pHandler->AddComponent(new AliHLTTPCCATrackerOutputConverter);
284 pHandler->AddComponent(new AliHLTTPCCAGlobalMergerComponent);
285 pHandler->AddComponent(new AliHLTTPCTrackMCMarkerComponent);
286 pHandler->AddComponent(new AliHLTTPCGlobalMergerComponent);
287 pHandler->AddComponent(new AliHLTTPCdEdxComponent);
288 pHandler->AddComponent(new AliHLTTPCSliceTrackerComponent);
289 pHandler->AddComponent(new AliHLTTPCVertexFinderComponent);
290 pHandler->AddComponent(new AliHLTTPCClusterFinderComponent(AliHLTTPCClusterFinderComponent::kClusterFinderPacked));
291 pHandler->AddComponent(new AliHLTTPCClusterFinderComponent(AliHLTTPCClusterFinderComponent::kClusterFinderUnpacked));
292 pHandler->AddComponent(new AliHLTTPCClusterFinderComponent(AliHLTTPCClusterFinderComponent::kClusterFinderDecoder));
293 pHandler->AddComponent(new AliHLTTPCClusterFinderComponent(AliHLTTPCClusterFinderComponent::kClusterFinder32Bit));
294 pHandler->AddComponent(new AliHLTTPCRawDataUnpackerComponent);
295 pHandler->AddComponent(new AliHLTTPCDigitPublisherComponent);
296 pHandler->AddComponent(new AliHLTTPCZeroSuppressionComponent);
297 pHandler->AddComponent(new AliHLTTPCDigitDumpComponent);
298 pHandler->AddComponent(new AliHLTTPCClusterDumpComponent);
299 pHandler->AddComponent(new AliHLTTPCEsdWriterComponent::AliWriter);
300 pHandler->AddComponent(new AliHLTTPCEsdWriterComponent::AliConverter);
301 pHandler->AddComponent(new AliHLTTPCOfflineClustererComponent);
302 pHandler->AddComponent(new AliHLTTPCOfflineTrackerComponent);
303 pHandler->AddComponent(new AliHLTTPCOfflineTrackerCalibComponent);
304 pHandler->AddComponent(new AliHLTTPCOfflineCalibrationComponent);
305 pHandler->AddComponent(new AliHLTTPCClusterHistoComponent);
306 pHandler->AddComponent(new AliHLTTPCNoiseMapComponent);
307 pHandler->AddComponent(new AliHLTTPCHistogramHandlerComponent);
308 //pHandler->AddComponent(new AliHLTTPCCalibTracksComponent);
309 pHandler->AddComponent(new AliHLTTPCTrackHistoComponent);
310 pHandler->AddComponent(new AliHLTTPCTrackDumpComponent);
311 pHandler->AddComponent(new AliHLTTPCHWCFDataReverterComponent);
312 pHandler->AddComponent(new AliHLTTPCHWClusterTransformComponent);
313 pHandler->AddComponent(new AliHLTTPCCFComparisonComponent);
314 // pHandler->AddComponent(new AliHLTTPCCalibSeedMakerComponent);
315 // pHandler->AddComponent(new AliHLTTPCCalibTimeComponent);
316 // pHandler->AddComponent(new AliHLTTPCCalibTimeGainComponent);
317 // pHandler->AddComponent(new AliHLTTPCCalibrationComponent);
318 pHandler->AddComponent(new AliHLTTPCDataCheckerComponent);
323 int AliHLTTPCAgent::GetHandlerDescription(AliHLTComponentDataType dt,
325 AliHLTOUTHandlerDesc& desc) const
327 // see header file for class documentation
329 // raw data blocks to be fed into offline reconstruction
330 if (dt==(kAliHLTDataTypeDDLRaw|kAliHLTDataOriginTPC)) {
331 int slice=AliHLTTPCDefinitions::GetMinSliceNr(spec);
332 int part=AliHLTTPCDefinitions::GetMinPatchNr(spec);
333 if (slice==AliHLTTPCDefinitions::GetMaxSliceNr(spec) &&
334 part==AliHLTTPCDefinitions::GetMaxPatchNr(spec)) {
335 desc=AliHLTOUTHandlerDesc(kRawReader, dt, GetModuleId());
338 HLTWarning("handler can not process merged data from multiple ddls:"
339 " min slice %d, max slice %d, min part %d, max part %d",
340 slice, AliHLTTPCDefinitions::GetMaxSliceNr(spec),
341 part, AliHLTTPCDefinitions::GetMaxPatchNr(spec));
346 // dump for {'CLUSTERS':'TPC '} blocks stored in a 'digit' file
347 if (dt==AliHLTTPCDefinitions::fgkClustersDataType) {
348 desc=AliHLTOUTHandlerDesc(kChain, dt, GetModuleId());
352 // afterburner for {'TRAKSEGS':'TPC '} blocks to be converted to ESD format
353 if (dt==AliHLTTPCDefinitions::fgkTrackSegmentsDataType) {
354 desc=AliHLTOUTHandlerDesc(kChain, dt, GetModuleId());
358 // afterburner for {'TRACKS ':'TPC '} block to be converted to ESD format
359 // there is only one data block
360 if (dt==AliHLTTPCDefinitions::fgkTracksDataType) {
361 desc=AliHLTOUTHandlerDesc(kChain, dt, GetModuleId());
367 AliHLTOUTHandler* AliHLTTPCAgent::GetOutputHandler(AliHLTComponentDataType dt,
368 AliHLTUInt32_t /*spec*/)
370 // see header file for class documentation
372 // raw data blocks to be fed into offline reconstruction
373 if (dt==(kAliHLTDataTypeDDLRaw|kAliHLTDataOriginTPC)) {
374 if (!fRawDataHandler) {
375 fRawDataHandler=new AliHLTTPCAgent::AliHLTTPCRawDataHandler;
377 return fRawDataHandler;
380 // dump for {'CLUSTERS':'TPC '}, stored in a file HLT.TPC.Clusters.root in HOMER format
381 if (dt==AliHLTTPCDefinitions::fgkClustersDataType) {
382 if (fClustersDataHandler==NULL)
383 fClustersDataHandler=new AliHLTOUTHandlerChain("chains=TPC-hltout-cluster-dump libHLTsim.so libAliHLTUtil.so");
384 return fClustersDataHandler;
387 // afterburner for {'TRAKSEGS':'TPC '} blocks to be converted to ESD format
388 // in a kChain HLTOUT handler
389 if (dt==AliHLTTPCDefinitions::fgkTrackSegmentsDataType) {
390 if (fTracksegsDataHandler==NULL)
391 fTracksegsDataHandler=new AliHLTOUTHandlerChain("chains=TPC-hltout-tracksegs-esd-converter");
392 return fTracksegsDataHandler;
395 // afterburner for {'TRACKS ':'TPC '} block to be converted to ESD format
396 // there is only one data block
397 if (dt==AliHLTTPCDefinitions::fgkTracksDataType) {
398 return new AliHLTOUTHandlerChain("chains=TPC-hltout-tracks-esd-converter");
404 int AliHLTTPCAgent::DeleteOutputHandler(AliHLTOUTHandler* pInstance)
406 // see header file for class documentation
407 if (pInstance==NULL) return -EINVAL;
409 if (pInstance==fRawDataHandler) {
410 delete fRawDataHandler;
411 fRawDataHandler=NULL;
414 if (pInstance==fTracksegsDataHandler) {
415 delete fTracksegsDataHandler;
416 fTracksegsDataHandler=NULL;
419 if (pInstance==fClustersDataHandler) {
420 delete fClustersDataHandler;
421 fClustersDataHandler=NULL;
427 AliHLTTPCAgent::AliHLTTPCRawDataHandler::AliHLTTPCRawDataHandler()
429 // see header file for class documentation
432 AliHLTTPCAgent::AliHLTTPCRawDataHandler::~AliHLTTPCRawDataHandler()
434 // see header file for class documentation
437 int AliHLTTPCAgent::AliHLTTPCRawDataHandler::ProcessData(AliHLTOUT* pData)
439 // see header file for class documentation
440 if (!pData) return -EINVAL;
441 AliHLTComponentDataType dt=kAliHLTVoidDataType;
442 AliHLTUInt32_t spec=kAliHLTVoidDataSpec;
443 int iResult=pData->GetDataBlockDescription(dt, spec);
445 int slice=AliHLTTPCDefinitions::GetMinSliceNr(spec);
446 int part=AliHLTTPCDefinitions::GetMinPatchNr(spec);
447 if (slice==AliHLTTPCDefinitions::GetMaxSliceNr(spec) &&
448 part==AliHLTTPCDefinitions::GetMaxPatchNr(spec)) {
450 if (part>1) iResult+=72+4*slice+(part-2);
451 else iResult+=2*slice+part;
453 HLTError("handler can not process merged data from multiple ddls:"
454 " min slice %d, max slice %d, min part %d, max part %d",
455 slice, AliHLTTPCDefinitions::GetMaxSliceNr(spec),
456 part, AliHLTTPCDefinitions::GetMaxPatchNr(spec));