]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/TPCLib/AliHLTTPCAgent.cxx
registration of AliHLTTPCTrackHistoComponent and AliHLTTPCTrackDumpComponent from...
[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 */
24
25 #include "AliHLTTPCAgent.h"
26 #include "AliHLTConfiguration.h"
27 #include "AliHLTTPCDefinitions.h"
28 #include "AliHLTOUT.h"
29 #include "AliHLTOUTHandlerChain.h"
30 #include "AliRunLoader.h"
31
32 /** global instance for agent registration */
33 AliHLTTPCAgent gAliHLTTPCAgent;
34
35 // component headers
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"
67
68
69 /** ROOT macro for the implementation of ROOT specific class methods */
70 ClassImp(AliHLTTPCAgent)
71
72 AliHLTTPCAgent::AliHLTTPCAgent()
73   :
74   AliHLTModuleAgent("TPC"),
75   fRawDataHandler(NULL),
76   fTracksegsDataHandler(NULL)
77 {
78   // see header file for class documentation
79   // or
80   // refer to README to build package
81   // or
82   // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
83 }
84
85 AliHLTTPCAgent::~AliHLTTPCAgent()
86 {
87   // see header file for class documentation
88 }
89
90 int AliHLTTPCAgent::CreateConfigurations(AliHLTConfigurationHandler* handler,
91                                          AliRawReader* rawReader,
92                                          AliRunLoader* /*runloader*/) const
93 {
94   // see header file for class documentation
95   if (handler) {
96
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
103     int iMinSlice=0; 
104     int iMaxSlice=35;
105     int iMinPart=0;
106     int iMaxPart=5;
107     TString mergerInput;
108     for (int slice=iMinSlice; slice<=iMaxSlice; slice++) {
109       TString trackerInput;
110       for (int part=iMinPart; part<=iMaxPart; part++) {
111         TString arg, publisher, cf;
112
113         // digit publisher components
114         publisher.Form("TPC-DP_%02d_%d", slice, part);
115         if (!rawReader) {
116           arg.Form("-slice %d -partition %d", slice, part);
117           handler->CreateConfiguration(publisher.Data(), "TPCDigitPublisher", NULL , arg.Data());
118         } else {
119           int ddlno=768;
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());
124         }
125
126         // cluster finder components
127         cf.Form("TPC-CF_%02d_%d", slice, part);
128         if (!rawReader) {
129           handler->CreateConfiguration(cf.Data(), "TPCClusterFinderUnpacked", publisher.Data(), "-timebins 446 -sorted");
130         } else {
131           handler->CreateConfiguration(cf.Data(), "TPCClusterFinderDecoder", publisher.Data(), "-timebins 446");
132         }
133         if (trackerInput.Length()>0) trackerInput+=" ";
134         trackerInput+=cf;
135       }
136       TString tracker;
137       // tracker finder components
138       tracker.Form("TPC-TR_%02d", slice);
139       handler->CreateConfiguration(tracker.Data(), "TPCSliceTracker", trackerInput.Data(), "-pp-run -bfield 0.5");
140
141       if (mergerInput.Length()>0) mergerInput+=" ";
142       mergerInput+=tracker;
143
144     }
145
146     // GlobalMerger component
147     handler->CreateConfiguration("TPC-globalmerger","TPCGlobalMerger",mergerInput.Data(),"");
148
149     // the esd converter configuration
150     handler->CreateConfiguration("TPC-esd-converter", "TPCEsdConverter"   , "TPC-globalmerger", "");
151
152     /////////////////////////////////////////////////////////////////////////////////////
153     //
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
156
157     // publisher component
158     handler->CreateConfiguration("TPC-hltout-tracksegs-publisher", "AliHLTOUTPublisher"   , NULL, "");
159
160     // GlobalMerger component
161     handler->CreateConfiguration("TPC-hltout-tracksegs-merger", "TPCGlobalMerger", "TPC-hltout-tracksegs-publisher", "");
162
163     // the esd converter configuration
164     handler->CreateConfiguration("TPC-hltout-tracksegs-esd-converter", "TPCEsdConverter", "TPC-hltout-tracksegs-merger", "");
165
166     /////////////////////////////////////////////////////////////////////////////////////
167     //
168     // a kChain HLTOUT configuration for processing of {'TRACKS  ':'TPC '} data blocks
169     // produces an ESD object from the track structure
170
171     // publisher component
172     handler->CreateConfiguration("TPC-hltout-tracks-publisher", "AliHLTOUTPublisher"   , NULL, "");
173
174     // the esd converter configuration
175     handler->CreateConfiguration("TPC-hltout-tracks-esd-converter", "TPCEsdConverter", "TPC-hltout-tracks-publisher", "");
176   }
177   return 0;
178 }
179
180 const char* AliHLTTPCAgent::GetReconstructionChains(AliRawReader* /*rawReader*/,
181                                                     AliRunLoader* runloader) const
182 {
183   // see header file for class documentation
184   if (runloader) {
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";
190   }
191   return NULL;
192 }
193
194 const char* AliHLTTPCAgent::GetRequiredComponentLibraries() const
195 {
196   // see header file for class documentation
197
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";
201   return NULL;
202 }
203
204 int AliHLTTPCAgent::RegisterComponents(AliHLTComponentHandler* pHandler) const
205 {
206   // see header file for class documentation
207   if (!pHandler) return -EINVAL;
208
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);
243   
244   return 0;
245 }
246
247 int AliHLTTPCAgent::GetHandlerDescription(AliHLTComponentDataType dt,
248                                           AliHLTUInt32_t spec,
249                                           AliHLTOUTHandlerDesc& desc) const
250 {
251   // see header file for class documentation
252
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());
260       return 1;
261     } else {
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));
266       return 0;
267     }
268   }
269
270   // afterburner for {'TRAKSEGS':'TPC '} blocks to be converted to ESD format
271   if (dt==AliHLTTPCDefinitions::fgkTrackSegmentsDataType) {
272       desc=AliHLTOUTHandlerDesc(kChain, dt, GetModuleId());
273       return 1;
274   }
275
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());
280       return 1;
281   }
282   return 0;
283 }
284
285 AliHLTOUTHandler* AliHLTTPCAgent::GetOutputHandler(AliHLTComponentDataType dt,
286                                                    AliHLTUInt32_t /*spec*/)
287 {
288   // see header file for class documentation
289
290   // raw data blocks to be fed into offline reconstruction
291   if (dt==(kAliHLTDataTypeDDLRaw|kAliHLTDataOriginTPC)) {
292     if (!fRawDataHandler) {
293       fRawDataHandler=new AliHLTTPCAgent::AliHLTTPCRawDataHandler;
294     }
295     return fRawDataHandler;
296   }
297
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;
304   }
305
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");
310   }
311
312   return NULL;
313 }
314
315 int AliHLTTPCAgent::DeleteOutputHandler(AliHLTOUTHandler* pInstance)
316 {
317   // see header file for class documentation
318   if (pInstance==NULL) return -EINVAL;
319
320   if (pInstance==fRawDataHandler) {
321     delete fRawDataHandler;
322     fRawDataHandler=NULL;
323   }
324
325   if (pInstance==fTracksegsDataHandler) {
326     delete fTracksegsDataHandler;
327     fTracksegsDataHandler=NULL;
328   }
329   return 0;
330 }
331
332 AliHLTTPCAgent::AliHLTTPCRawDataHandler::AliHLTTPCRawDataHandler()
333 {
334   // see header file for class documentation
335 }
336
337 AliHLTTPCAgent::AliHLTTPCRawDataHandler::~AliHLTTPCRawDataHandler()
338 {
339   // see header file for class documentation
340 }
341
342 int AliHLTTPCAgent::AliHLTTPCRawDataHandler::ProcessData(AliHLTOUT* pData)
343 {
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);
349   if (iResult>=0) {
350     int slice=AliHLTTPCDefinitions::GetMinSliceNr(spec);
351     int part=AliHLTTPCDefinitions::GetMinPatchNr(spec);
352     if (slice==AliHLTTPCDefinitions::GetMaxSliceNr(spec) &&
353         part==AliHLTTPCDefinitions::GetMaxPatchNr(spec)) {
354       iResult=768;
355       if (part>1) iResult+=72+4*slice+(part-2);
356       else iResult+=2*slice+part;
357     } else {
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));
362       iResult=-EBADMSG;
363     }
364   }
365   return iResult;
366 }