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