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 "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 "AliHLTTPCCAInputDataCompressorComponent.h"
47 #include "AliHLTTPCCATrackerComponent.h"
48 #include "AliHLTTPCCATrackerOutputConverter.h"
49 #include "AliHLTTPCTrackMCMarkerComponent.h"
50 #include "AliHLTTPCCAGlobalMergerComponent.h"
51 #include "AliHLTTPCdEdxComponent.h"
52 #include "AliHLTTPCGlobalMergerComponent.h"
53 #include "AliHLTTPCSliceTrackerComponent.h"
54 #include "AliHLTTPCClusterFinderComponent.h"
55 #include "AliHLTTPCRawDataUnpackerComponent.h"
56 #include "AliHLTTPCDigitPublisherComponent.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" // to be added to the calibration library agent
64 #include "AliHLTTPCClusterHistoComponent.h"
65 #include "AliHLTTPCHistogramHandlerComponent.h"
66 //#include "AliHLTTPCCalibTracksComponent.h"
67 #include "AliHLTTPCTrackHistoComponent.h"
68 #include "AliHLTTPCTrackDumpComponent.h"
69 #include "AliHLTTPCHWCFDataReverterComponent.h"
70 #include "AliHLTTPCHWClusterTransformComponent.h"
71 #include "AliHLTTPCCFComparisonComponent.h"
72 // #include "AliHLTTPCCalibSeedMakerComponent.h"
73 // #include "AliHLTTPCCalibTimeComponent.h"
74 // #include "AliHLTTPCCalibTimeGainComponent.h"
75 // #include "AliHLTTPCCalibrationComponent.h"
76 #include "AliHLTTPCDataCheckerComponent.h"
77 #include "AliHLTTPCHWCFEmulatorComponent.h"
78 #include "AliHLTTPCHWCFConsistencyControlComponent.h"
80 /** ROOT macro for the implementation of ROOT specific class methods */
81 ClassImp(AliHLTTPCAgent)
83 AliHLTTPCAgent::AliHLTTPCAgent()
84 : AliHLTModuleAgent("TPC")
85 , fRawDataHandler(NULL)
86 , fTracksegsDataHandler(NULL)
87 , fClustersDataHandler(NULL)
89 // see header file for class documentation
91 // refer to README to build package
93 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
96 AliHLTTPCAgent::~AliHLTTPCAgent()
98 // see header file for class documentation
101 int AliHLTTPCAgent::CreateConfigurations(AliHLTConfigurationHandler* handler,
102 AliRawReader* rawReader,
103 AliRunLoader* runloader) const
105 // see header file for class documentation
108 // This the tracking configuration for the full TPC
109 // - 216 clusterfinders (1 per partition)
110 // - 36 slice trackers
111 // - one global merger
112 // - the esd converter
113 // The ESD is shipped embedded into a TTree
119 TString sinkClusterInput;
120 TString sinkHWClusterInput;
122 for (int slice=iMinSlice; slice<=iMaxSlice; slice++) {
123 TString trackerInput;
124 for (int part=iMinPart; part<=iMaxPart; part++) {
125 TString arg, publisher, cf;
127 // digit publisher components
128 publisher.Form("TPC-DP_%02d_%d", slice, part);
129 if (rawReader || !runloader) {
130 // AliSimulation: use the AliRawReaderPublisher if the raw reader is available
131 // Alireconstruction: indicated by runloader==NULL, run always on raw data
133 if (part>1) ddlno+=72+4*slice+(part-2);
134 else ddlno+=2*slice+part;
135 arg.Form("-minid %d -datatype 'DDL_RAW ' 'TPC ' -dataspec 0x%02x%02x%02x%02x -silent", ddlno, slice, slice, part, part);
136 handler->CreateConfiguration(publisher.Data(), "AliRawReaderPublisher", NULL , arg.Data());
138 arg.Form("-slice %d -partition %d", slice, part);
139 handler->CreateConfiguration(publisher.Data(), "TPCDigitPublisher", NULL , arg.Data());
142 // cluster finder components
143 cf.Form("TPC-CF_%02d_%d", slice, part);
144 arg="-release-memory -publish-raw";
145 if (!rawReader && runloader) {
147 handler->CreateConfiguration(cf.Data(), "TPCClusterFinderUnpacked", publisher.Data(), arg.Data());
149 handler->CreateConfiguration(cf.Data(), "TPCClusterFinder32Bit", publisher.Data(),arg.Data());
152 // Hardware CF emulator
153 // soon going to replace the software clusterfinder
155 hwcfemu.Form("TPC-HWCFEmu_%02d_%d", slice, part);
156 handler->CreateConfiguration(hwcfemu.Data(), "TPCHWClusterFinderEmulator", publisher.Data(), "-do-mc 1");
158 hwcf.Form("TPC-HWCF_%02d_%d", slice, part);
159 handler->CreateConfiguration(hwcf.Data(), "TPCHWClusterTransform",hwcfemu.Data(), "-publish-raw");
161 if (trackerInput.Length()>0) trackerInput+=" ";
163 if (dEdXInput.Length()>0) dEdXInput+=" ";
165 if (sinkClusterInput.Length()>0) sinkClusterInput+=" ";
166 sinkClusterInput+=cf;
167 if (sinkHWClusterInput.Length()>0) sinkHWClusterInput+=" ";
168 sinkHWClusterInput+=hwcf;
171 // tracker finder components
172 tracker.Form("TPC-TR_%02d", slice);
173 handler->CreateConfiguration(tracker.Data(), "TPCCATracker", trackerInput.Data(), "-minTrackPt 0.0");
175 if (mergerInput.Length()>0) mergerInput+=" ";
176 mergerInput+=tracker;
180 // GlobalMerger component
181 handler->CreateConfiguration("TPC-globalmerger","TPCCAGlobalMerger",mergerInput.Data(),"");
183 if (dEdXInput.Length()>0) dEdXInput+=" ";
184 dEdXInput+="TPC-globalmerger";
186 handler->CreateConfiguration("TPC-dEdx","TPCdEdx",dEdXInput.Data(),"");
188 // the esd converter configuration
189 TString converterInput="TPC-globalmerger";
190 if (!rawReader && runloader) {
191 // propagate cluster info to the esd converter in order to fill the MC information
192 handler->CreateConfiguration("TPC-clustermc-info", "BlockFilter" , sinkClusterInput.Data(), "-datatype 'CLMCINFO' 'TPC '");
193 handler->CreateConfiguration("TPC-mcTrackMarker","TPCTrackMCMarker","TPC-globalmerger TPC-clustermc-info","" );
195 converterInput+="TPC-mcTrackMarker";
197 handler->CreateConfiguration("TPC-esd-converter", "TPCEsdConverter" , converterInput.Data(), "");
199 // cluster dump collection
200 handler->CreateConfiguration("TPC-clusters", "BlockFilter" , sinkClusterInput.Data(), "-datatype 'CLUSTERS' 'TPC ' -datatype 'CLMCINFO' 'TPC '");
201 handler->CreateConfiguration("TPC-raw-clusters", "BlockFilter" , sinkClusterInput.Data(), "-datatype 'CLUSTRAW' 'TPC ' -datatype 'CLMCINFO' 'TPC '");
202 handler->CreateConfiguration("TPC-hwclusters", "BlockFilter" , sinkHWClusterInput.Data(), "-datatype 'CLUSTERS' 'TPC ' -datatype 'CLMCINFO' 'TPC '");
203 handler->CreateConfiguration("TPC-raw-hwclusters", "BlockFilter" , sinkHWClusterInput.Data(), "-datatype 'CLUSTRAW' 'TPC ' -datatype 'CLMCINFO' 'TPC '");
205 /////////////////////////////////////////////////////////////////////////////////////
207 // a kChain HLTOUT configuration for processing of {'TRAKSEGS':'TPC '} data blocks
208 // collects the data blocks, merges the tracks and produces an ESD object
210 // publisher component
211 handler->CreateConfiguration("TPC-hltout-tracksegs-publisher", "AliHLTOUTPublisher" , NULL, "");
213 // GlobalMerger component
214 handler->CreateConfiguration("TPC-hltout-tracksegs-merger", "TPCGlobalMerger", "TPC-hltout-tracksegs-publisher", "");
216 // the esd converter configuration
217 handler->CreateConfiguration("TPC-hltout-tracksegs-esd-converter", "TPCEsdConverter", "TPC-hltout-tracksegs-merger", "");
219 /////////////////////////////////////////////////////////////////////////////////////
221 // a kChain HLTOUT configuration for processing of {'TRACKS ':'TPC '} data blocks
222 // produces an ESD object from the track structure
224 // publisher component
225 handler->CreateConfiguration("TPC-hltout-tracks-publisher", "AliHLTOUTPublisher" , NULL, "");
227 // the esd converter configuration
228 handler->CreateConfiguration("TPC-hltout-tracks-esd-converter", "TPCEsdConverter", "TPC-hltout-tracks-publisher", "");
230 /////////////////////////////////////////////////////////////////////////////////////
232 // a kChain HLTOUT configuration for processing of {'CLUSTERS':'TPC '} data blocks
233 // stores the blocks in file HLT.TPC.Clusters.root in HOMER format
235 // publisher component
236 handler->CreateConfiguration("TPC-hltout-cluster-publisher", "AliHLTOUTPublisher" , NULL, "");
238 // the HLTOUT component collects the blocks and stores the file
239 handler->CreateConfiguration("TPC-hltout-cluster-dump", "HLTOUT", "TPC-hltout-cluster-publisher", "-digitfile HLT.TPC.Clusters.root -rawout=off -links 2");
245 const char* AliHLTTPCAgent::GetReconstructionChains(AliRawReader* /*rawReader*/,
246 AliRunLoader* runloader) const
248 // see header file for class documentation
250 // reconstruction chains for AliRoot simulation
251 // Note: run loader is only available while running embedded into
252 // AliRoot simulation
253 //if (runloader->GetLoader("TPCLoader") != NULL)
254 //return "TPC-esd-converter TPC-clusters";
256 // 2010-10-26 TPC clusters not written to HLTOUT in order to make the simulation
257 // closer to the real data
258 //return "TPC-clusters";
263 const char* AliHLTTPCAgent::GetRequiredComponentLibraries() const
265 // see header file for class documentation
267 // actually, the TPC library has dependencies to Util and RCU
268 // so the two has to be loaded anyhow before we get here
269 //return "libAliHLTUtil.so libAliHLTRCU.so";
270 return "libAliHLTUtil.so";
273 int AliHLTTPCAgent::RegisterComponents(AliHLTComponentHandler* pHandler) const
275 // see header file for class documentation
276 if (!pHandler) return -EINVAL;
278 // pHandler->AddComponent(new AliHLTTPCCalibCEComponent);
279 // pHandler->AddComponent(new AliHLTTPCCalibPulserComponent);
280 // pHandler->AddComponent(new AliHLTTPCCalibPedestalComponent);
281 pHandler->AddComponent(new AliHLTTPCCompModelInflaterComponent);
282 pHandler->AddComponent(new AliHLTTPCCompModelDeflaterComponent);
283 pHandler->AddComponent(new AliHLTTPCCompModelDeconverterComponent);
284 pHandler->AddComponent(new AliHLTTPCCompModelConverterComponent);
285 pHandler->AddComponent(new AliHLTTPCCompDumpComponent);
286 pHandler->AddComponent(new AliHLTTPCCAInputDataCompressorComponent);
287 pHandler->AddComponent(new AliHLTTPCCATrackerComponent);
288 pHandler->AddComponent(new AliHLTTPCCATrackerOutputConverter);
289 pHandler->AddComponent(new AliHLTTPCCAGlobalMergerComponent);
290 pHandler->AddComponent(new AliHLTTPCTrackMCMarkerComponent);
291 pHandler->AddComponent(new AliHLTTPCGlobalMergerComponent);
292 pHandler->AddComponent(new AliHLTTPCdEdxComponent);
293 pHandler->AddComponent(new AliHLTTPCSliceTrackerComponent);
294 pHandler->AddComponent(new AliHLTTPCClusterFinderComponent(AliHLTTPCClusterFinderComponent::kClusterFinderPacked));
295 pHandler->AddComponent(new AliHLTTPCClusterFinderComponent(AliHLTTPCClusterFinderComponent::kClusterFinderUnpacked));
296 pHandler->AddComponent(new AliHLTTPCClusterFinderComponent(AliHLTTPCClusterFinderComponent::kClusterFinderDecoder));
297 pHandler->AddComponent(new AliHLTTPCClusterFinderComponent(AliHLTTPCClusterFinderComponent::kClusterFinder32Bit));
298 pHandler->AddComponent(new AliHLTTPCRawDataUnpackerComponent);
299 pHandler->AddComponent(new AliHLTTPCDigitPublisherComponent);
300 pHandler->AddComponent(new AliHLTTPCDigitDumpComponent);
301 pHandler->AddComponent(new AliHLTTPCClusterDumpComponent);
302 pHandler->AddComponent(new AliHLTTPCEsdWriterComponent::AliWriter);
303 pHandler->AddComponent(new AliHLTTPCEsdWriterComponent::AliConverter);
304 pHandler->AddComponent(new AliHLTTPCOfflineClustererComponent);
305 pHandler->AddComponent(new AliHLTTPCOfflineTrackerComponent);
306 pHandler->AddComponent(new AliHLTTPCOfflineTrackerCalibComponent);
307 pHandler->AddComponent(new AliHLTTPCOfflineCalibrationComponent);
308 pHandler->AddComponent(new AliHLTTPCClusterHistoComponent);
309 pHandler->AddComponent(new AliHLTTPCHistogramHandlerComponent);
310 //pHandler->AddComponent(new AliHLTTPCCalibTracksComponent);
311 pHandler->AddComponent(new AliHLTTPCTrackHistoComponent);
312 pHandler->AddComponent(new AliHLTTPCTrackDumpComponent);
313 pHandler->AddComponent(new AliHLTTPCHWCFDataReverterComponent);
314 pHandler->AddComponent(new AliHLTTPCHWClusterTransformComponent);
315 pHandler->AddComponent(new AliHLTTPCCFComparisonComponent);
316 // pHandler->AddComponent(new AliHLTTPCCalibSeedMakerComponent);
317 // pHandler->AddComponent(new AliHLTTPCCalibTimeComponent);
318 // pHandler->AddComponent(new AliHLTTPCCalibTimeGainComponent);
319 // pHandler->AddComponent(new AliHLTTPCCalibrationComponent);
320 pHandler->AddComponent(new AliHLTTPCDataCheckerComponent);
321 pHandler->AddComponent(new AliHLTTPCHWCFEmulatorComponent);
322 // pHandler->AddComponent(new AliHLTTPCHWCFConsistencyControlComponent); //FIXME: Causes crash: https://savannah.cern.ch/bugs/?83677
326 int AliHLTTPCAgent::GetHandlerDescription(AliHLTComponentDataType dt,
328 AliHLTOUTHandlerDesc& desc) const
330 // see header file for class documentation
332 // raw data blocks to be fed into offline reconstruction
333 if (dt==(kAliHLTDataTypeDDLRaw|kAliHLTDataOriginTPC)) {
334 int slice=AliHLTTPCDefinitions::GetMinSliceNr(spec);
335 int part=AliHLTTPCDefinitions::GetMinPatchNr(spec);
336 if (slice==AliHLTTPCDefinitions::GetMaxSliceNr(spec) &&
337 part==AliHLTTPCDefinitions::GetMaxPatchNr(spec)) {
338 desc=AliHLTOUTHandlerDesc(kRawReader, dt, GetModuleId());
341 HLTWarning("handler can not process merged data from multiple ddls:"
342 " min slice %d, max slice %d, min part %d, max part %d",
343 slice, AliHLTTPCDefinitions::GetMaxSliceNr(spec),
344 part, AliHLTTPCDefinitions::GetMaxPatchNr(spec));
349 // dump for {'CLUSTERS':'TPC '} blocks stored in a 'digit' file
350 if (dt==AliHLTTPCDefinitions::fgkClustersDataType) {
351 desc=AliHLTOUTHandlerDesc(kChain, dt, GetModuleId());
355 // {'CLUSTRAW':'TPC '}
356 if (dt==AliHLTTPCDefinitions::fgkRawClustersDataType) {
357 desc=AliHLTOUTHandlerDesc(kProprietary, dt, GetModuleId());
361 // {'CLMCINFO':'TPC '}
362 if (dt==AliHLTTPCDefinitions::fgkAliHLTDataTypeClusterMCInfo) {
363 desc=AliHLTOUTHandlerDesc(kProprietary, dt, GetModuleId());
367 // afterburner for {'TRAKSEGS':'TPC '} blocks to be converted to ESD format
368 if (dt==AliHLTTPCDefinitions::fgkTrackSegmentsDataType) {
369 desc=AliHLTOUTHandlerDesc(kChain, dt, GetModuleId());
373 // afterburner for {'TRACKS ':'TPC '} block to be converted to ESD format
374 // there is only one data block
375 if (dt==AliHLTTPCDefinitions::fgkTracksDataType) {
376 desc=AliHLTOUTHandlerDesc(kChain, dt, GetModuleId());
382 AliHLTOUTHandler* AliHLTTPCAgent::GetOutputHandler(AliHLTComponentDataType dt,
383 AliHLTUInt32_t /*spec*/)
385 // see header file for class documentation
387 // raw data blocks to be fed into offline reconstruction
388 if (dt==(kAliHLTDataTypeDDLRaw|kAliHLTDataOriginTPC)) {
389 if (!fRawDataHandler) {
390 fRawDataHandler=new AliHLTTPCAgent::AliHLTTPCRawDataHandler;
392 return fRawDataHandler;
395 // dump for {'CLUSTERS':'TPC '}, stored in a file HLT.TPC.Clusters.root in HOMER format
396 if (dt==AliHLTTPCDefinitions::fgkClustersDataType) {
397 if (fClustersDataHandler==NULL)
398 fClustersDataHandler=new AliHLTOUTHandlerChain("chains=TPC-hltout-cluster-dump libHLTsim.so libAliHLTUtil.so");
399 return fClustersDataHandler;
402 // afterburner for {'TRAKSEGS':'TPC '} blocks to be converted to ESD format
403 // in a kChain HLTOUT handler
404 if (dt==AliHLTTPCDefinitions::fgkTrackSegmentsDataType) {
405 if (fTracksegsDataHandler==NULL)
406 fTracksegsDataHandler=new AliHLTOUTHandlerChain("chains=TPC-hltout-tracksegs-esd-converter");
407 return fTracksegsDataHandler;
410 // afterburner for {'TRACKS ':'TPC '} block to be converted to ESD format
411 // there is only one data block
412 if (dt==AliHLTTPCDefinitions::fgkTracksDataType) {
413 return new AliHLTOUTHandlerChain("chains=TPC-hltout-tracks-esd-converter");
419 int AliHLTTPCAgent::DeleteOutputHandler(AliHLTOUTHandler* pInstance)
421 // see header file for class documentation
422 if (pInstance==NULL) return -EINVAL;
424 if (pInstance==fRawDataHandler) {
425 delete fRawDataHandler;
426 fRawDataHandler=NULL;
429 if (pInstance==fTracksegsDataHandler) {
430 delete fTracksegsDataHandler;
431 fTracksegsDataHandler=NULL;
434 if (pInstance==fClustersDataHandler) {
435 delete fClustersDataHandler;
436 fClustersDataHandler=NULL;
442 AliHLTTPCAgent::AliHLTTPCRawDataHandler::AliHLTTPCRawDataHandler()
444 // see header file for class documentation
447 AliHLTTPCAgent::AliHLTTPCRawDataHandler::~AliHLTTPCRawDataHandler()
449 // see header file for class documentation
452 int AliHLTTPCAgent::AliHLTTPCRawDataHandler::ProcessData(AliHLTOUT* pData)
454 // see header file for class documentation
455 if (!pData) return -EINVAL;
456 AliHLTComponentDataType dt=kAliHLTVoidDataType;
457 AliHLTUInt32_t spec=kAliHLTVoidDataSpec;
458 int iResult=pData->GetDataBlockDescription(dt, spec);
460 int slice=AliHLTTPCDefinitions::GetMinSliceNr(spec);
461 int part=AliHLTTPCDefinitions::GetMinPatchNr(spec);
462 if (slice==AliHLTTPCDefinitions::GetMaxSliceNr(spec) &&
463 part==AliHLTTPCDefinitions::GetMaxPatchNr(spec)) {
465 if (part>1) iResult+=72+4*slice+(part-2);
466 else iResult+=2*slice+part;
468 HLTError("handler can not process merged data from multiple ddls:"
469 " min slice %d, max slice %d, min part %d, max part %d",
470 slice, AliHLTTPCDefinitions::GetMaxSliceNr(spec),
471 part, AliHLTTPCDefinitions::GetMaxPatchNr(spec));