]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/TPCLib/AliHLTTPCAgent.cxx
- introduced module Ids for agents
[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 "AliHLTTPCDigitDumpComponent.h"
35 #include "AliHLTTPCEsdWriterComponent.h"
36
37 /** ROOT macro for the implementation of ROOT specific class methods */
38 ClassImp(AliHLTTPCAgent)
39
40 AliHLTTPCAgent::AliHLTTPCAgent()
41   :
42   AliHLTModuleAgent("TPC"),
43   fRawDataHandler(NULL),
44   fNofRawDataHandler(0)
45 {
46   // see header file for class documentation
47   // or
48   // refer to README to build package
49   // or
50   // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
51 }
52
53 AliHLTTPCAgent::~AliHLTTPCAgent()
54 {
55   // see header file for class documentation
56 }
57
58 int AliHLTTPCAgent::CreateConfigurations(AliHLTConfigurationHandler* handler,
59                                          AliRawReader* /*rawReader*/,
60                                          AliRunLoader* /*runloader*/) const
61 {
62   // see header file for class documentation
63   if (handler) {
64     int iMinSlice=0; 
65     int iMaxSlice=1;
66     int iMinPart=0;
67     int iMaxPart=1;
68     TString fileWriterInput;
69     TString esdWriterInput;
70     for (int slice=iMinSlice; slice<=iMaxSlice; slice++) {
71       TString trackerInput;
72       for (int part=iMinPart; part<=iMaxPart; part++) {
73         TString arg, publisher, cf;
74
75         // digit publisher components
76         arg.Form("-slice %d -partition %d", slice, part);
77         publisher.Form("DP_%02d_%d", slice, part);
78         handler->CreateConfiguration(publisher.Data(), "TPCDigitPublisher", NULL , arg.Data());
79
80         // cluster finder components
81         cf.Form("CF_%02d_%d", slice, part);
82         handler->CreateConfiguration(cf.Data(), "TPCClusterFinderUnpacked", publisher.Data(), "pp-run timebins 446");
83         if (trackerInput.Length()>0) trackerInput+=" ";
84         trackerInput+=cf;
85       }
86       TString tracker;
87       // tracker finder components
88       tracker.Form("TR_%02d", slice);
89       handler->CreateConfiguration(tracker.Data(), "TPCSliceTracker", trackerInput.Data(), "pp-run bfield 0.5");
90
91       // input for the global file writer
92       if (fileWriterInput.Length()>0) fileWriterInput+=" ";
93       fileWriterInput+=trackerInput;
94
95       // input for the esd writer
96       if (esdWriterInput.Length()>0) esdWriterInput+=" ";
97       esdWriterInput+=tracker;
98     }
99
100     // the writer configuration
101     handler->CreateConfiguration("sink1", "FileWriter"   , fileWriterInput.Data(), "-specfmt -subdir=test_%d -blcknofmt=_0x%x -idfmt=_0x%08x");
102     // the esd writer configuration
103     handler->CreateConfiguration("esd-writer", "TPCEsdWriter"   , esdWriterInput.Data(), "-datafile AliESDs.root");
104   }
105   return 0;
106 }
107
108 const char* AliHLTTPCAgent::GetReconstructionChains(AliRawReader* /*rawReader*/,
109                                                     AliRunLoader* /*runloader*/) const
110 {
111   // see header file for class documentation
112   return NULL;
113   //return "sink1";
114   //return "esd-writer";
115 }
116
117 const char* AliHLTTPCAgent::GetRequiredComponentLibraries() const
118 {
119   // see header file for class documentation
120   return NULL;
121 }
122
123 int AliHLTTPCAgent::RegisterComponents(AliHLTComponentHandler* pHandler) const
124 {
125   // see header file for class documentation
126   if (!pHandler) return -EINVAL;
127   pHandler->AddComponent(new AliHLTTPCDigitDumpComponent);
128   pHandler->AddComponent(new AliHLTTPCEsdWriterComponent::AliWriter);
129   pHandler->AddComponent(new AliHLTTPCEsdWriterComponent::AliConverter);
130
131   return 0;
132 }
133
134 int AliHLTTPCAgent::GetHandlerDescription(AliHLTComponentDataType dt,
135                                           AliHLTUInt32_t spec,
136                                           AliHLTOUTHandlerDesc& desc) const
137 {
138   // see header file for class documentation
139   if (dt==(kAliHLTDataTypeDDLRaw|kAliHLTDataOriginTPC)) {
140     int slice=AliHLTTPCDefinitions::GetMinSliceNr(spec);
141     int part=AliHLTTPCDefinitions::GetMinPatchNr(spec);
142     if (slice==AliHLTTPCDefinitions::GetMaxSliceNr(spec) &&
143         part==AliHLTTPCDefinitions::GetMaxPatchNr(spec)) {
144       desc=AliHLTOUTHandlerDesc(kRawReader, dt, GetModuleId());
145       return 1;
146     } else {
147       HLTWarning("handler can not process merged data from multiple ddls:"
148                  " min slice %d, max slice %d, min part %d, max part %d",
149                  slice, AliHLTTPCDefinitions::GetMaxSliceNr(spec),
150                  part, AliHLTTPCDefinitions::GetMaxPatchNr(spec));
151       return 0;
152     }
153   }
154   return 0;
155 }
156
157 AliHLTOUTHandler* AliHLTTPCAgent::GetOutputHandler(AliHLTComponentDataType dt,
158                                                    AliHLTUInt32_t spec)
159 {
160   // see header file for class documentation
161   if (dt==(kAliHLTDataTypeDDLRaw|kAliHLTDataOriginTPC)) {
162     if (!fRawDataHandler) {
163       fRawDataHandler=new AliHLTTPCAgent::AliHLTTPCRawDataHandler;
164     }
165     fNofRawDataHandler++;
166     return fRawDataHandler;
167   }
168   return NULL;
169 }
170
171 int AliHLTTPCAgent::DeleteOutputHandler(AliHLTOUTHandler* pInstance)
172 {
173   // see header file for class documentation
174   if (pInstance==NULL) return -EINVAL;
175
176   if (pInstance==fRawDataHandler) {
177     if (--fNofRawDataHandler<=0) {
178       delete fRawDataHandler;
179       fRawDataHandler=NULL;
180     }
181   }
182   return 0;
183 }
184
185 AliHLTTPCAgent::AliHLTTPCRawDataHandler::AliHLTTPCRawDataHandler()
186 {
187   // see header file for class documentation
188 }
189
190 AliHLTTPCAgent::AliHLTTPCRawDataHandler::~AliHLTTPCRawDataHandler()
191 {
192   // see header file for class documentation
193 }
194
195 int AliHLTTPCAgent::AliHLTTPCRawDataHandler::ProcessData(AliHLTOUT* pData)
196 {
197   // see header file for class documentation
198   if (!pData) return -EINVAL;
199   AliHLTComponentDataType dt=kAliHLTVoidDataType;
200   AliHLTUInt32_t spec=kAliHLTVoidDataSpec;
201   int iResult=pData->GetDataBlockDescription(dt, spec);
202   if (iResult>=0) {
203     int slice=AliHLTTPCDefinitions::GetMinSliceNr(spec);
204     int part=AliHLTTPCDefinitions::GetMinPatchNr(spec);
205     if (slice==AliHLTTPCDefinitions::GetMaxSliceNr(spec) &&
206         part==AliHLTTPCDefinitions::GetMaxPatchNr(spec)) {
207       iResult=768;
208       if (part>1) iResult+=72+4*slice+(part-2);
209       else iResult+=2*slice+part;
210     } else {
211       HLTError("handler can not process merged data from multiple ddls:"
212                " min slice %d, max slice %d, min part %d, max part %d",
213                slice, AliHLTTPCDefinitions::GetMaxSliceNr(spec),
214                part, AliHLTTPCDefinitions::GetMaxPatchNr(spec));
215       iResult=-EBADMSG;
216     }
217   }
218   return iResult;
219 }