]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/TPCLib/AliHLTTPCAgent.cxx
removing unused classes: 1st prototype of TPC vertexer
[u/mrichter/AliRoot.git] / HLT / TPCLib / AliHLTTPCAgent.cxx
1 // $Id$
2
3 //**************************************************************************
4 //* This file is property of and copyright by the ALICE HLT Project        * 
5 //* ALICE Experiment at CERN, All rights reserved.                         *
6 //*                                                                        *
7 //* Primary Authors: Matthias Richter <Matthias.Richter@ift.uib.no>        *
8 //*                  for The ALICE HLT Project.                            *
9 //*                                                                        *
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 //**************************************************************************
18
19 //  @file   AliHLTTPCAgent.cxx
20 //  @author Matthias Richter
21 //  @date   
22 //  @brief  Agent of the libAliHLTTPC library
23 //  @note   
24
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"
33
34 /** global instance for agent registration */
35 AliHLTTPCAgent gAliHLTTPCAgent;
36
37 // component headers
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
78 /** ROOT macro for the implementation of ROOT specific class methods */
79 ClassImp(AliHLTTPCAgent)
80
81 AliHLTTPCAgent::AliHLTTPCAgent()
82   : AliHLTModuleAgent("TPC")
83   , fRawDataHandler(NULL)
84   , fTracksegsDataHandler(NULL)
85   , fClustersDataHandler(NULL)
86 {
87   // see header file for class documentation
88   // or
89   // refer to README to build package
90   // or
91   // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
92 }
93
94 AliHLTTPCAgent::~AliHLTTPCAgent()
95 {
96   // see header file for class documentation
97 }
98
99 int AliHLTTPCAgent::CreateConfigurations(AliHLTConfigurationHandler* handler,
100                                          AliRawReader* rawReader,
101                                          AliRunLoader* runloader) const
102 {
103   // see header file for class documentation
104   if (handler) {
105
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
112     int iMinSlice=0; 
113     int iMaxSlice=35;
114     int iMinPart=0;
115     int iMaxPart=5;
116     TString mergerInput;
117     TString sinkClusterInput;
118     TString dEdXInput;
119     for (int slice=iMinSlice; slice<=iMaxSlice; slice++) {
120       TString trackerInput;
121       for (int part=iMinPart; part<=iMaxPart; part++) {
122         TString arg, publisher, cf;
123
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
129           int ddlno=768;
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());
134         } else {
135           arg.Form("-slice %d -partition %d", slice, part);
136           handler->CreateConfiguration(publisher.Data(), "TPCDigitPublisher", NULL , arg.Data());
137         }
138
139         // cluster finder components
140         cf.Form("TPC-CF_%02d_%d", slice, part);
141         arg="-release-memory";
142         if (!rawReader && runloader) {
143           arg+=" -do-mc";
144           handler->CreateConfiguration(cf.Data(), "TPCClusterFinderUnpacked", publisher.Data(), arg.Data());
145         } else {
146 #ifndef HAVE_NOT_ALTRORAWSTREAMV3
147           handler->CreateConfiguration(cf.Data(), "TPCClusterFinder32Bit", publisher.Data(),arg.Data());
148 #else
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());
152 #endif 
153         }
154         if (trackerInput.Length()>0) trackerInput+=" ";
155         trackerInput+=cf;
156         if (dEdXInput.Length()>0) dEdXInput+=" ";
157         dEdXInput+=cf;
158         if (sinkClusterInput.Length()>0) sinkClusterInput+=" ";
159         sinkClusterInput+=cf;
160       }
161       TString tracker;
162       // tracker finder components
163       tracker.Form("TPC-TR_%02d", slice);
164       handler->CreateConfiguration(tracker.Data(), "TPCCATracker", trackerInput.Data(), "");
165
166       if (mergerInput.Length()>0) mergerInput+=" ";
167       mergerInput+=tracker;
168
169     }
170
171     // GlobalMerger component
172     handler->CreateConfiguration("TPC-globalmerger","TPCCAGlobalMerger",mergerInput.Data(),"");
173
174     if (dEdXInput.Length()>0) dEdXInput+=" ";
175     dEdXInput+="TPC-globalmerger";
176
177     handler->CreateConfiguration("TPC-dEdx","TPCdEdx",dEdXInput.Data(),"");
178
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","" );
185       converterInput+=" ";
186       converterInput+="TPC-mcTrackMarker";
187     }
188     handler->CreateConfiguration("TPC-esd-converter", "TPCEsdConverter"   , converterInput.Data(), "");
189
190     // cluster dump collection
191     handler->CreateConfiguration("TPC-clusters", "BlockFilter"   , sinkClusterInput.Data(), "-datatype 'CLUSTERS' 'TPC '");
192
193     /////////////////////////////////////////////////////////////////////////////////////
194     //
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
197
198     // publisher component
199     handler->CreateConfiguration("TPC-hltout-tracksegs-publisher", "AliHLTOUTPublisher"   , NULL, "");
200
201     // GlobalMerger component
202     handler->CreateConfiguration("TPC-hltout-tracksegs-merger", "TPCGlobalMerger", "TPC-hltout-tracksegs-publisher", "");
203
204     // the esd converter configuration
205     handler->CreateConfiguration("TPC-hltout-tracksegs-esd-converter", "TPCEsdConverter", "TPC-hltout-tracksegs-merger", "");
206
207     /////////////////////////////////////////////////////////////////////////////////////
208     //
209     // a kChain HLTOUT configuration for processing of {'TRACKS  ':'TPC '} data blocks
210     // produces an ESD object from the track structure
211
212     // publisher component
213     handler->CreateConfiguration("TPC-hltout-tracks-publisher", "AliHLTOUTPublisher"   , NULL, "");
214
215     // the esd converter configuration
216     handler->CreateConfiguration("TPC-hltout-tracks-esd-converter", "TPCEsdConverter", "TPC-hltout-tracks-publisher", "");
217
218     /////////////////////////////////////////////////////////////////////////////////////
219     //
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
222
223     // publisher component
224     handler->CreateConfiguration("TPC-hltout-cluster-publisher", "AliHLTOUTPublisher"   , NULL, "");
225
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");
228   }
229
230   return 0;
231 }
232
233 const char* AliHLTTPCAgent::GetReconstructionChains(AliRawReader* /*rawReader*/,
234                                                     AliRunLoader* runloader) const
235 {
236   // see header file for class documentation
237   if (runloader) {
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";
243
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";
247   }
248   return NULL;
249 }
250
251 const char* AliHLTTPCAgent::GetRequiredComponentLibraries() const
252 {
253   // see header file for class documentation
254
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";
259 }
260
261 int AliHLTTPCAgent::RegisterComponents(AliHLTComponentHandler* pHandler) const
262 {
263   // see header file for class documentation
264   if (!pHandler) return -EINVAL;
265
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);
309
310   return 0;
311 }
312
313 int AliHLTTPCAgent::GetHandlerDescription(AliHLTComponentDataType dt,
314                                           AliHLTUInt32_t spec,
315                                           AliHLTOUTHandlerDesc& desc) const
316 {
317   // see header file for class documentation
318
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());
326       return 1;
327     } else {
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));
332       return 0;
333     }
334   }
335
336   // dump for {'CLUSTERS':'TPC '} blocks stored in a 'digit' file
337   if (dt==AliHLTTPCDefinitions::fgkClustersDataType) {
338       desc=AliHLTOUTHandlerDesc(kChain, dt, GetModuleId());
339       return 1;
340   }
341
342   // afterburner for {'TRAKSEGS':'TPC '} blocks to be converted to ESD format
343   if (dt==AliHLTTPCDefinitions::fgkTrackSegmentsDataType) {
344       desc=AliHLTOUTHandlerDesc(kChain, dt, GetModuleId());
345       return 1;
346   }
347
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());
352       return 1;
353   }
354   return 0;
355 }
356
357 AliHLTOUTHandler* AliHLTTPCAgent::GetOutputHandler(AliHLTComponentDataType dt,
358                                                    AliHLTUInt32_t /*spec*/)
359 {
360   // see header file for class documentation
361
362   // raw data blocks to be fed into offline reconstruction
363   if (dt==(kAliHLTDataTypeDDLRaw|kAliHLTDataOriginTPC)) {
364     if (!fRawDataHandler) {
365       fRawDataHandler=new AliHLTTPCAgent::AliHLTTPCRawDataHandler;
366     }
367     return fRawDataHandler;
368   }
369
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;
375   }
376
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;
383   }
384
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");
389   }
390
391   return NULL;
392 }
393
394 int AliHLTTPCAgent::DeleteOutputHandler(AliHLTOUTHandler* pInstance)
395 {
396   // see header file for class documentation
397   if (pInstance==NULL) return -EINVAL;
398
399   if (pInstance==fRawDataHandler) {
400     delete fRawDataHandler;
401     fRawDataHandler=NULL;
402   }
403
404   if (pInstance==fTracksegsDataHandler) {
405     delete fTracksegsDataHandler;
406     fTracksegsDataHandler=NULL;
407   }
408
409   if (pInstance==fClustersDataHandler) {
410     delete fClustersDataHandler;
411     fClustersDataHandler=NULL;
412   }
413
414   return 0;
415 }
416
417 AliHLTTPCAgent::AliHLTTPCRawDataHandler::AliHLTTPCRawDataHandler()
418 {
419   // see header file for class documentation
420 }
421
422 AliHLTTPCAgent::AliHLTTPCRawDataHandler::~AliHLTTPCRawDataHandler()
423 {
424   // see header file for class documentation
425 }
426
427 int AliHLTTPCAgent::AliHLTTPCRawDataHandler::ProcessData(AliHLTOUT* pData)
428 {
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);
434   if (iResult>=0) {
435     int slice=AliHLTTPCDefinitions::GetMinSliceNr(spec);
436     int part=AliHLTTPCDefinitions::GetMinPatchNr(spec);
437     if (slice==AliHLTTPCDefinitions::GetMaxSliceNr(spec) &&
438         part==AliHLTTPCDefinitions::GetMaxPatchNr(spec)) {
439       iResult=768;
440       if (part>1) iResult+=72+4*slice+(part-2);
441       else iResult+=2*slice+part;
442     } else {
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));
447       iResult=-EBADMSG;
448     }
449   }
450   return iResult;
451 }