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"
78 /** ROOT macro for the implementation of ROOT specific class methods */
79 ClassImp(AliHLTTPCAgent)
81 AliHLTTPCAgent::AliHLTTPCAgent()
82 : AliHLTModuleAgent("TPC")
83 , fRawDataHandler(NULL)
84 , fTracksegsDataHandler(NULL)
85 , fClustersDataHandler(NULL)
87 // see header file for class documentation
89 // refer to README to build package
91 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
94 AliHLTTPCAgent::~AliHLTTPCAgent()
96 // see header file for class documentation
99 int AliHLTTPCAgent::CreateConfigurations(AliHLTConfigurationHandler* handler,
100 AliRawReader* rawReader,
101 AliRunLoader* runloader) const
103 // see header file for class documentation
106 // This the tracking configuration for the full TPC
107 // - 216 clusterfinders (1 per partition)
108 // - 36 slice trackers
109 // - one global merger
110 // - the esd converter
111 // The ESD is shipped embedded into a TTree
117 TString sinkClusterInput;
119 for (int slice=iMinSlice; slice<=iMaxSlice; slice++) {
120 TString trackerInput;
121 for (int part=iMinPart; part<=iMaxPart; part++) {
122 TString arg, publisher, cf;
124 // digit publisher components
125 publisher.Form("TPC-DP_%02d_%d", slice, part);
126 if (rawReader || !runloader) {
127 // AliSimulation: use the AliRawReaderPublisher if the raw reader is available
128 // Alireconstruction: indicated by runloader==NULL, run always on raw data
130 if (part>1) ddlno+=72+4*slice+(part-2);
131 else ddlno+=2*slice+part;
132 arg.Form("-minid %d -datatype 'DDL_RAW ' 'TPC ' -dataspec 0x%02x%02x%02x%02x -silent", ddlno, slice, slice, part, part);
133 handler->CreateConfiguration(publisher.Data(), "AliRawReaderPublisher", NULL , arg.Data());
135 arg.Form("-slice %d -partition %d", slice, part);
136 handler->CreateConfiguration(publisher.Data(), "TPCDigitPublisher", NULL , arg.Data());
139 // cluster finder components
140 cf.Form("TPC-CF_%02d_%d", slice, part);
141 arg="-release-memory";
142 if (!rawReader && runloader) {
144 handler->CreateConfiguration(cf.Data(), "TPCClusterFinderUnpacked", publisher.Data(), arg.Data());
146 #ifndef HAVE_NOT_ALTRORAWSTREAMV3
147 handler->CreateConfiguration(cf.Data(), "TPCClusterFinder32Bit", publisher.Data(),arg.Data());
149 // using the AltroDecoder if the official V3 decoder is not
150 // available in the offline code
151 handler->CreateConfiguration(cf.Data(), "TPCClusterFinderDecoder", publisher.Data(), arg.Data());
154 if (trackerInput.Length()>0) trackerInput+=" ";
156 if (dEdXInput.Length()>0) dEdXInput+=" ";
158 if (sinkClusterInput.Length()>0) sinkClusterInput+=" ";
159 sinkClusterInput+=cf;
162 // tracker finder components
163 tracker.Form("TPC-TR_%02d", slice);
164 handler->CreateConfiguration(tracker.Data(), "TPCCATracker", trackerInput.Data(), "");
166 if (mergerInput.Length()>0) mergerInput+=" ";
167 mergerInput+=tracker;
171 // GlobalMerger component
172 handler->CreateConfiguration("TPC-globalmerger","TPCCAGlobalMerger",mergerInput.Data(),"");
174 if (dEdXInput.Length()>0) dEdXInput+=" ";
175 dEdXInput+="TPC-globalmerger";
177 handler->CreateConfiguration("TPC-dEdx","TPCdEdx",dEdXInput.Data(),"");
179 // the esd converter configuration
180 TString converterInput="TPC-globalmerger";
181 if (!rawReader && runloader) {
182 // propagate cluster info to the esd converter in order to fill the MC information
183 handler->CreateConfiguration("TPC-clustermc-info", "BlockFilter" , sinkClusterInput.Data(), "-datatype 'CLMCINFO' 'TPC '");
184 handler->CreateConfiguration("TPC-mcTrackMarker","TPCTrackMCMarker","TPC-globalmerger TPC-clustermc-info","" );
186 converterInput+="TPC-mcTrackMarker";
188 handler->CreateConfiguration("TPC-esd-converter", "TPCEsdConverter" , converterInput.Data(), "");
190 // cluster dump collection
191 handler->CreateConfiguration("TPC-clusters", "BlockFilter" , sinkClusterInput.Data(), "-datatype 'CLUSTERS' 'TPC '");
193 /////////////////////////////////////////////////////////////////////////////////////
195 // a kChain HLTOUT configuration for processing of {'TRAKSEGS':'TPC '} data blocks
196 // collects the data blocks, merges the tracks and produces an ESD object
198 // publisher component
199 handler->CreateConfiguration("TPC-hltout-tracksegs-publisher", "AliHLTOUTPublisher" , NULL, "");
201 // GlobalMerger component
202 handler->CreateConfiguration("TPC-hltout-tracksegs-merger", "TPCGlobalMerger", "TPC-hltout-tracksegs-publisher", "");
204 // the esd converter configuration
205 handler->CreateConfiguration("TPC-hltout-tracksegs-esd-converter", "TPCEsdConverter", "TPC-hltout-tracksegs-merger", "");
207 /////////////////////////////////////////////////////////////////////////////////////
209 // a kChain HLTOUT configuration for processing of {'TRACKS ':'TPC '} data blocks
210 // produces an ESD object from the track structure
212 // publisher component
213 handler->CreateConfiguration("TPC-hltout-tracks-publisher", "AliHLTOUTPublisher" , NULL, "");
215 // the esd converter configuration
216 handler->CreateConfiguration("TPC-hltout-tracks-esd-converter", "TPCEsdConverter", "TPC-hltout-tracks-publisher", "");
218 /////////////////////////////////////////////////////////////////////////////////////
220 // a kChain HLTOUT configuration for processing of {'CLUSTERS':'TPC '} data blocks
221 // stores the blocks in file HLT.TPC.Clusters.root in HOMER format
223 // publisher component
224 handler->CreateConfiguration("TPC-hltout-cluster-publisher", "AliHLTOUTPublisher" , NULL, "");
226 // the HLTOUT component collects the blocks and stores the file
227 handler->CreateConfiguration("TPC-hltout-cluster-dump", "HLTOUT", "TPC-hltout-cluster-publisher", "-digitfile HLT.TPC.Clusters.root -rawout=off -links 2");
233 const char* AliHLTTPCAgent::GetReconstructionChains(AliRawReader* /*rawReader*/,
234 AliRunLoader* runloader) const
236 // see header file for class documentation
238 // reconstruction chains for AliRoot simulation
239 // Note: run loader is only available while running embedded into
240 // AliRoot simulation
241 //if (runloader->GetLoader("TPCLoader") != NULL)
242 //return "TPC-esd-converter TPC-clusters";
244 // 2010-10-26 TPC clusters not written to HLTOUT in order to make the simulation
245 // closer to the real data
246 //return "TPC-clusters";
251 const char* AliHLTTPCAgent::GetRequiredComponentLibraries() const
253 // see header file for class documentation
255 // actually, the TPC library has dependencies to Util and RCU
256 // so the two has to be loaded anyhow before we get here
257 //return "libAliHLTUtil.so libAliHLTRCU.so";
258 return "libAliHLTUtil.so";
261 int AliHLTTPCAgent::RegisterComponents(AliHLTComponentHandler* pHandler) const
263 // see header file for class documentation
264 if (!pHandler) return -EINVAL;
266 // pHandler->AddComponent(new AliHLTTPCCalibCEComponent);
267 // pHandler->AddComponent(new AliHLTTPCCalibPulserComponent);
268 // pHandler->AddComponent(new AliHLTTPCCalibPedestalComponent);
269 pHandler->AddComponent(new AliHLTTPCCompModelInflaterComponent);
270 pHandler->AddComponent(new AliHLTTPCCompModelDeflaterComponent);
271 pHandler->AddComponent(new AliHLTTPCCompModelDeconverterComponent);
272 pHandler->AddComponent(new AliHLTTPCCompModelConverterComponent);
273 pHandler->AddComponent(new AliHLTTPCCompDumpComponent);
274 pHandler->AddComponent(new AliHLTTPCCAInputDataCompressorComponent);
275 pHandler->AddComponent(new AliHLTTPCCATrackerComponent);
276 pHandler->AddComponent(new AliHLTTPCCATrackerOutputConverter);
277 pHandler->AddComponent(new AliHLTTPCCAGlobalMergerComponent);
278 pHandler->AddComponent(new AliHLTTPCTrackMCMarkerComponent);
279 pHandler->AddComponent(new AliHLTTPCGlobalMergerComponent);
280 pHandler->AddComponent(new AliHLTTPCdEdxComponent);
281 pHandler->AddComponent(new AliHLTTPCSliceTrackerComponent);
282 pHandler->AddComponent(new AliHLTTPCClusterFinderComponent(AliHLTTPCClusterFinderComponent::kClusterFinderPacked));
283 pHandler->AddComponent(new AliHLTTPCClusterFinderComponent(AliHLTTPCClusterFinderComponent::kClusterFinderUnpacked));
284 pHandler->AddComponent(new AliHLTTPCClusterFinderComponent(AliHLTTPCClusterFinderComponent::kClusterFinderDecoder));
285 pHandler->AddComponent(new AliHLTTPCClusterFinderComponent(AliHLTTPCClusterFinderComponent::kClusterFinder32Bit));
286 pHandler->AddComponent(new AliHLTTPCRawDataUnpackerComponent);
287 pHandler->AddComponent(new AliHLTTPCDigitPublisherComponent);
288 pHandler->AddComponent(new AliHLTTPCDigitDumpComponent);
289 pHandler->AddComponent(new AliHLTTPCClusterDumpComponent);
290 pHandler->AddComponent(new AliHLTTPCEsdWriterComponent::AliWriter);
291 pHandler->AddComponent(new AliHLTTPCEsdWriterComponent::AliConverter);
292 pHandler->AddComponent(new AliHLTTPCOfflineClustererComponent);
293 pHandler->AddComponent(new AliHLTTPCOfflineTrackerComponent);
294 pHandler->AddComponent(new AliHLTTPCOfflineTrackerCalibComponent);
295 pHandler->AddComponent(new AliHLTTPCOfflineCalibrationComponent);
296 pHandler->AddComponent(new AliHLTTPCClusterHistoComponent);
297 pHandler->AddComponent(new AliHLTTPCHistogramHandlerComponent);
298 //pHandler->AddComponent(new AliHLTTPCCalibTracksComponent);
299 pHandler->AddComponent(new AliHLTTPCTrackHistoComponent);
300 pHandler->AddComponent(new AliHLTTPCTrackDumpComponent);
301 pHandler->AddComponent(new AliHLTTPCHWCFDataReverterComponent);
302 pHandler->AddComponent(new AliHLTTPCHWClusterTransformComponent);
303 pHandler->AddComponent(new AliHLTTPCCFComparisonComponent);
304 // pHandler->AddComponent(new AliHLTTPCCalibSeedMakerComponent);
305 // pHandler->AddComponent(new AliHLTTPCCalibTimeComponent);
306 // pHandler->AddComponent(new AliHLTTPCCalibTimeGainComponent);
307 // pHandler->AddComponent(new AliHLTTPCCalibrationComponent);
308 pHandler->AddComponent(new AliHLTTPCDataCheckerComponent);
313 int AliHLTTPCAgent::GetHandlerDescription(AliHLTComponentDataType dt,
315 AliHLTOUTHandlerDesc& desc) const
317 // see header file for class documentation
319 // raw data blocks to be fed into offline reconstruction
320 if (dt==(kAliHLTDataTypeDDLRaw|kAliHLTDataOriginTPC)) {
321 int slice=AliHLTTPCDefinitions::GetMinSliceNr(spec);
322 int part=AliHLTTPCDefinitions::GetMinPatchNr(spec);
323 if (slice==AliHLTTPCDefinitions::GetMaxSliceNr(spec) &&
324 part==AliHLTTPCDefinitions::GetMaxPatchNr(spec)) {
325 desc=AliHLTOUTHandlerDesc(kRawReader, dt, GetModuleId());
328 HLTWarning("handler can not process merged data from multiple ddls:"
329 " min slice %d, max slice %d, min part %d, max part %d",
330 slice, AliHLTTPCDefinitions::GetMaxSliceNr(spec),
331 part, AliHLTTPCDefinitions::GetMaxPatchNr(spec));
336 // dump for {'CLUSTERS':'TPC '} blocks stored in a 'digit' file
337 if (dt==AliHLTTPCDefinitions::fgkClustersDataType) {
338 desc=AliHLTOUTHandlerDesc(kChain, dt, GetModuleId());
342 // afterburner for {'TRAKSEGS':'TPC '} blocks to be converted to ESD format
343 if (dt==AliHLTTPCDefinitions::fgkTrackSegmentsDataType) {
344 desc=AliHLTOUTHandlerDesc(kChain, dt, GetModuleId());
348 // afterburner for {'TRACKS ':'TPC '} block to be converted to ESD format
349 // there is only one data block
350 if (dt==AliHLTTPCDefinitions::fgkTracksDataType) {
351 desc=AliHLTOUTHandlerDesc(kChain, dt, GetModuleId());
357 AliHLTOUTHandler* AliHLTTPCAgent::GetOutputHandler(AliHLTComponentDataType dt,
358 AliHLTUInt32_t /*spec*/)
360 // see header file for class documentation
362 // raw data blocks to be fed into offline reconstruction
363 if (dt==(kAliHLTDataTypeDDLRaw|kAliHLTDataOriginTPC)) {
364 if (!fRawDataHandler) {
365 fRawDataHandler=new AliHLTTPCAgent::AliHLTTPCRawDataHandler;
367 return fRawDataHandler;
370 // dump for {'CLUSTERS':'TPC '}, stored in a file HLT.TPC.Clusters.root in HOMER format
371 if (dt==AliHLTTPCDefinitions::fgkClustersDataType) {
372 if (fClustersDataHandler==NULL)
373 fClustersDataHandler=new AliHLTOUTHandlerChain("chains=TPC-hltout-cluster-dump libHLTsim.so libAliHLTUtil.so");
374 return fClustersDataHandler;
377 // afterburner for {'TRAKSEGS':'TPC '} blocks to be converted to ESD format
378 // in a kChain HLTOUT handler
379 if (dt==AliHLTTPCDefinitions::fgkTrackSegmentsDataType) {
380 if (fTracksegsDataHandler==NULL)
381 fTracksegsDataHandler=new AliHLTOUTHandlerChain("chains=TPC-hltout-tracksegs-esd-converter");
382 return fTracksegsDataHandler;
385 // afterburner for {'TRACKS ':'TPC '} block to be converted to ESD format
386 // there is only one data block
387 if (dt==AliHLTTPCDefinitions::fgkTracksDataType) {
388 return new AliHLTOUTHandlerChain("chains=TPC-hltout-tracks-esd-converter");
394 int AliHLTTPCAgent::DeleteOutputHandler(AliHLTOUTHandler* pInstance)
396 // see header file for class documentation
397 if (pInstance==NULL) return -EINVAL;
399 if (pInstance==fRawDataHandler) {
400 delete fRawDataHandler;
401 fRawDataHandler=NULL;
404 if (pInstance==fTracksegsDataHandler) {
405 delete fTracksegsDataHandler;
406 fTracksegsDataHandler=NULL;
409 if (pInstance==fClustersDataHandler) {
410 delete fClustersDataHandler;
411 fClustersDataHandler=NULL;
417 AliHLTTPCAgent::AliHLTTPCRawDataHandler::AliHLTTPCRawDataHandler()
419 // see header file for class documentation
422 AliHLTTPCAgent::AliHLTTPCRawDataHandler::~AliHLTTPCRawDataHandler()
424 // see header file for class documentation
427 int AliHLTTPCAgent::AliHLTTPCRawDataHandler::ProcessData(AliHLTOUT* pData)
429 // see header file for class documentation
430 if (!pData) return -EINVAL;
431 AliHLTComponentDataType dt=kAliHLTVoidDataType;
432 AliHLTUInt32_t spec=kAliHLTVoidDataSpec;
433 int iResult=pData->GetDataBlockDescription(dt, spec);
435 int slice=AliHLTTPCDefinitions::GetMinSliceNr(spec);
436 int part=AliHLTTPCDefinitions::GetMinPatchNr(spec);
437 if (slice==AliHLTTPCDefinitions::GetMaxSliceNr(spec) &&
438 part==AliHLTTPCDefinitions::GetMaxPatchNr(spec)) {
440 if (part>1) iResult+=72+4*slice+(part-2);
441 else iResult+=2*slice+part;
443 HLTError("handler can not process merged data from multiple ddls:"
444 " min slice %d, max slice %d, min part %d, max part %d",
445 slice, AliHLTTPCDefinitions::GetMaxSliceNr(spec),
446 part, AliHLTTPCDefinitions::GetMaxPatchNr(spec));