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