]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/TPCLib/AliHLTTPCAgent.cxx
added new helper components to libAliHLTUtil (EsdCollector and AliHLTOUTPublisher...
[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 "AliRunLoader.h"
30
31 /** global instance for agent registration */
32 AliHLTTPCAgent gAliHLTTPCAgent;
33
34 // component headers
35 #include "AliHLTTPCRunStatisticsProducerComponent.h"
36 #include "AliHLTTPCEventStatisticsProducerComponent.h"
37 #include "AliHLTTPCCompModelInflaterComponent.h"
38 #include "AliHLTTPCCompModelDeflaterComponent.h"
39 #include "AliHLTTPCCompModelDeconverterComponent.h"
40 #include "AliHLTTPCCompModelConverterComponent.h"
41 #include "AliHLTTPCCompDumpComponent.h"
42 #include "AliHLTTPCCalibCEComponent.h"
43 #include "AliHLTTPCCalibPulserComponent.h"
44 #include "AliHLTTPCCalibPedestalComponent.h"
45 #include "AliHLTTPCCATrackerComponent.h"
46 #include "AliHLTTPCGlobalMergerComponent.h"
47 #include "AliHLTTPCSliceTrackerComponent.h"
48 #include "AliHLTTPCVertexFinderComponent.h"
49 #include "AliHLTTPCClusterFinderComponent.h"
50 #include "AliHLTTPCRawDataUnpackerComponent.h"
51 #include "AliHLTTPCDigitPublisherComponent.h"
52 #include "AliHLTTPCZeroSuppressionComponent.h"
53 #include "AliHLTTPCDigitDumpComponent.h"
54 #include "AliHLTTPCClusterDumpComponent.h"
55 #include "AliHLTTPCEsdWriterComponent.h"
56 #include "AliHLTTPCOfflineClustererComponent.h"
57 #include "AliHLTTPCOfflineTrackerComponent.h"
58 #include "AliHLTTPCClusterHistoComponent.h"
59
60 /** ROOT macro for the implementation of ROOT specific class methods */
61 ClassImp(AliHLTTPCAgent)
62
63 AliHLTTPCAgent::AliHLTTPCAgent()
64   :
65   AliHLTModuleAgent("TPC"),
66   fRawDataHandler(NULL),
67   fNofRawDataHandler(0)
68 {
69   // see header file for class documentation
70   // or
71   // refer to README to build package
72   // or
73   // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
74 }
75
76 AliHLTTPCAgent::~AliHLTTPCAgent()
77 {
78   // see header file for class documentation
79 }
80
81 int AliHLTTPCAgent::CreateConfigurations(AliHLTConfigurationHandler* handler,
82                                          AliRawReader* /*rawReader*/,
83                                          AliRunLoader* /*runloader*/) const
84 {
85   // see header file for class documentation
86   if (handler) {
87
88     // This the tracking configuration for the full TPC
89     // - 216 clusterfinders (1 per partition)
90     // - 36 slice trackers
91     // - one global merger
92     // - the esd converter
93     // The ESD is shipped embedded into a TTree
94     int iMinSlice=0; 
95     int iMaxSlice=35;
96     int iMinPart=0;
97     int iMaxPart=5;
98     TString mergerInput;
99     for (int slice=iMinSlice; slice<=iMaxSlice; slice++) {
100       TString trackerInput;
101       for (int part=iMinPart; part<=iMaxPart; part++) {
102         TString arg, publisher, cf;
103
104         // digit publisher components
105         arg.Form("-slice %d -partition %d", slice, part);
106         publisher.Form("TPC-DP_%02d_%d", slice, part);
107         handler->CreateConfiguration(publisher.Data(), "TPCDigitPublisher", NULL , arg.Data());
108
109         // cluster finder components
110         cf.Form("TPC-CF_%02d_%d", slice, part);
111         handler->CreateConfiguration(cf.Data(), "TPCClusterFinderUnpacked", publisher.Data(), "pp-run timebins 446");
112         if (trackerInput.Length()>0) trackerInput+=" ";
113         trackerInput+=cf;
114       }
115       TString tracker;
116       // tracker finder components
117       tracker.Form("TPC-TR_%02d", slice);
118       handler->CreateConfiguration(tracker.Data(), "TPCSliceTracker", trackerInput.Data(), "-pp-run -bfield 0.5");
119
120       if (mergerInput.Length()>0) mergerInput+=" ";
121       mergerInput+=tracker;
122
123     }
124
125     // GlobalMerger component
126     handler->CreateConfiguration("TPC-globalmerger","TPCGlobalMerger",mergerInput.Data(),"");
127
128     // the esd converter configuration
129     handler->CreateConfiguration("TPC-esd-converter", "TPCEsdConverter"   , "TPC-globalmerger", "-tree");
130   }
131   return 0;
132 }
133
134 const char* AliHLTTPCAgent::GetReconstructionChains(AliRawReader* /*rawReader*/,
135                                                     AliRunLoader* runloader) const
136 {
137   // see header file for class documentation
138   if (runloader) {
139     // reconstruction chains for AliRoot simulation
140     // Note: run loader is only available while running embedded into
141     // AliRoot simulation
142     if (runloader->GetLoader("TPCLoader") != NULL)
143       return "TPC-esd-converter";
144   }
145   return NULL;
146 }
147
148 const char* AliHLTTPCAgent::GetRequiredComponentLibraries() const
149 {
150   // see header file for class documentation
151
152   // actually, the TPC library has dependencies to Util and RCU
153   // so the two has to be loaded anyhow before we get here
154   //return "libAliHLTUtil.so libAliHLTRCU.so";
155   return NULL;
156 }
157
158 int AliHLTTPCAgent::RegisterComponents(AliHLTComponentHandler* pHandler) const
159 {
160   // see header file for class documentation
161   if (!pHandler) return -EINVAL;
162
163   pHandler->AddComponent(new AliHLTTPCRunStatisticsProducerComponent);
164   pHandler->AddComponent(new AliHLTTPCEventStatisticsProducerComponent);
165   pHandler->AddComponent(new AliHLTTPCCalibCEComponent);
166   pHandler->AddComponent(new AliHLTTPCCalibPulserComponent);
167   pHandler->AddComponent(new AliHLTTPCCalibPedestalComponent);
168   pHandler->AddComponent(new AliHLTTPCCompModelInflaterComponent);
169   pHandler->AddComponent(new AliHLTTPCCompModelDeflaterComponent);
170   pHandler->AddComponent(new AliHLTTPCCompModelDeconverterComponent);
171   pHandler->AddComponent(new AliHLTTPCCompModelConverterComponent);
172   pHandler->AddComponent(new AliHLTTPCCompDumpComponent);
173   pHandler->AddComponent(new AliHLTTPCCATrackerComponent);
174   pHandler->AddComponent(new AliHLTTPCGlobalMergerComponent);
175   pHandler->AddComponent(new AliHLTTPCSliceTrackerComponent);
176   pHandler->AddComponent(new AliHLTTPCVertexFinderComponent);
177   pHandler->AddComponent(new AliHLTTPCClusterFinderComponent(AliHLTTPCClusterFinderComponent::kClusterFinderPacked));
178   pHandler->AddComponent(new AliHLTTPCClusterFinderComponent(AliHLTTPCClusterFinderComponent::kClusterFinderUnpacked));
179   pHandler->AddComponent(new AliHLTTPCClusterFinderComponent(AliHLTTPCClusterFinderComponent::kClusterFinderDecoder));
180   pHandler->AddComponent(new AliHLTTPCRawDataUnpackerComponent);
181   pHandler->AddComponent(new AliHLTTPCDigitPublisherComponent);
182   pHandler->AddComponent(new AliHLTTPCZeroSuppressionComponent);
183   pHandler->AddComponent(new AliHLTTPCDigitDumpComponent);
184   pHandler->AddComponent(new AliHLTTPCClusterDumpComponent);
185   pHandler->AddComponent(new AliHLTTPCEsdWriterComponent::AliWriter);
186   pHandler->AddComponent(new AliHLTTPCEsdWriterComponent::AliConverter);
187   pHandler->AddComponent(new AliHLTTPCOfflineClustererComponent);
188   pHandler->AddComponent(new AliHLTTPCOfflineTrackerComponent);
189   pHandler->AddComponent(new AliHLTTPCClusterHistoComponent);
190
191   return 0;
192 }
193
194 int AliHLTTPCAgent::GetHandlerDescription(AliHLTComponentDataType dt,
195                                           AliHLTUInt32_t spec,
196                                           AliHLTOUTHandlerDesc& desc) const
197 {
198   // see header file for class documentation
199   if (dt==(kAliHLTDataTypeDDLRaw|kAliHLTDataOriginTPC)) {
200     int slice=AliHLTTPCDefinitions::GetMinSliceNr(spec);
201     int part=AliHLTTPCDefinitions::GetMinPatchNr(spec);
202     if (slice==AliHLTTPCDefinitions::GetMaxSliceNr(spec) &&
203         part==AliHLTTPCDefinitions::GetMaxPatchNr(spec)) {
204       desc=AliHLTOUTHandlerDesc(kRawReader, dt, GetModuleId());
205       return 1;
206     } else {
207       HLTWarning("handler can not process merged data from multiple ddls:"
208                  " min slice %d, max slice %d, min part %d, max part %d",
209                  slice, AliHLTTPCDefinitions::GetMaxSliceNr(spec),
210                  part, AliHLTTPCDefinitions::GetMaxPatchNr(spec));
211       return 0;
212     }
213   }
214   return 0;
215 }
216
217 AliHLTOUTHandler* AliHLTTPCAgent::GetOutputHandler(AliHLTComponentDataType dt,
218                                                    AliHLTUInt32_t /*spec*/)
219 {
220   // see header file for class documentation
221   if (dt==(kAliHLTDataTypeDDLRaw|kAliHLTDataOriginTPC)) {
222     if (!fRawDataHandler) {
223       fRawDataHandler=new AliHLTTPCAgent::AliHLTTPCRawDataHandler;
224     }
225     fNofRawDataHandler++;
226     return fRawDataHandler;
227   }
228   return NULL;
229 }
230
231 int AliHLTTPCAgent::DeleteOutputHandler(AliHLTOUTHandler* pInstance)
232 {
233   // see header file for class documentation
234   if (pInstance==NULL) return -EINVAL;
235
236   if (pInstance==fRawDataHandler) {
237     if (--fNofRawDataHandler<=0) {
238       delete fRawDataHandler;
239       fRawDataHandler=NULL;
240     }
241   }
242   return 0;
243 }
244
245 AliHLTTPCAgent::AliHLTTPCRawDataHandler::AliHLTTPCRawDataHandler()
246 {
247   // see header file for class documentation
248 }
249
250 AliHLTTPCAgent::AliHLTTPCRawDataHandler::~AliHLTTPCRawDataHandler()
251 {
252   // see header file for class documentation
253 }
254
255 int AliHLTTPCAgent::AliHLTTPCRawDataHandler::ProcessData(AliHLTOUT* pData)
256 {
257   // see header file for class documentation
258   if (!pData) return -EINVAL;
259   AliHLTComponentDataType dt=kAliHLTVoidDataType;
260   AliHLTUInt32_t spec=kAliHLTVoidDataSpec;
261   int iResult=pData->GetDataBlockDescription(dt, spec);
262   if (iResult>=0) {
263     int slice=AliHLTTPCDefinitions::GetMinSliceNr(spec);
264     int part=AliHLTTPCDefinitions::GetMinPatchNr(spec);
265     if (slice==AliHLTTPCDefinitions::GetMaxSliceNr(spec) &&
266         part==AliHLTTPCDefinitions::GetMaxPatchNr(spec)) {
267       iResult=768;
268       if (part>1) iResult+=72+4*slice+(part-2);
269       else iResult+=2*slice+part;
270     } else {
271       HLTError("handler can not process merged data from multiple ddls:"
272                " min slice %d, max slice %d, min part %d, max part %d",
273                slice, AliHLTTPCDefinitions::GetMaxSliceNr(spec),
274                part, AliHLTTPCDefinitions::GetMaxPatchNr(spec));
275       iResult=-EBADMSG;
276     }
277   }
278   return iResult;
279 }