Major update required to handle old and new AliHLTEventDDL structures within HLT...
[u/mrichter/AliRoot.git] / HLT / TPCLib / offline / AliHLTTPCOfflineCalibrationComponent.cxx
CommitLineData
e642ae99 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: Jacek Otwinowski <J.Otwinowski@gsi.de> *
8//* *
9//* Permission to use, copy, modify and distribute this software and its *
10//* documentation strictly for non-commercial purposes is hereby granted *
11//* without fee, provided that the above copyright notice appears in all *
12//* copies and that both the copyright notice and this permission notice *
13//* appear in the supporting documentation. The authors make no claims *
14//* about the suitability of this software for any purpose. It is *
15//* provided "as is" without express or implied warranty. *
16//**************************************************************************
17
18/** @file AliHLTTPCOfflineCalibrationComponent.cxx
19 @author Jacek Otwinowski <J.Otwinowski@gsi.de>
20 @date
21 @brief TPC calibration component
22*/
23
24#include "AliHLTTPCOfflineCalibrationComponent.h"
25#include "TString.h"
26#include "TObjArray.h"
27#include "TObjString.h"
28#include "AliTPCcalibAlign.h"
29#include "AliTPCcalibTracksGain.h"
30#include "AliTPCcalibTracks.h"
31#include "AliESDEvent.h"
32#include "AliESDfriend.h"
33#include "AliCDBManager.h"
34#include "AliTPCcalibDB.h"
35#include "AliTPCClusterParam.h"
36#include "AliTPCcalibTracksCuts.h"
37#include "AliTPCseed.h"
38#include "AliTPCcalibTracksCuts.h"
39#include "AliTPCClusterParam.h"
40#include "AliHLTTPCDefinitions.h"
8d53dca2 41#include "AliHLTReadoutList.h"
e642ae99 42
43/** ROOT macro for the implementation of ROOT specific class methods */
44ClassImp(AliHLTTPCOfflineCalibrationComponent)
45
46AliHLTTPCOfflineCalibrationComponent::AliHLTTPCOfflineCalibrationComponent() : AliHLTCalibrationProcessor(),
47fEnableAnalysis(kTRUE),
48fClustParam(0),
49fTrackCuts(0),
50fTPCcalibAlign(0),
51fTPCcalibTracksGain(0),
52fTPCcalibTracks(0)
53{
54 // see header file for class documentation
55 // or
56 // refer to README to build package
57 // or
58 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
59}
60
61AliHLTTPCOfflineCalibrationComponent::~AliHLTTPCOfflineCalibrationComponent()
62{
63 // see header file for class documentation
64}
65
66const char* AliHLTTPCOfflineCalibrationComponent::GetComponentID()
67{
68 // see header file for class documentation
69 return "TPCOfflineCalibration";
70}
71
72void AliHLTTPCOfflineCalibrationComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list)
73{
74 // get input data type
75 list.clear();
0e442a0a 76 list.push_back(kAliHLTDataTypeTObjArray|kAliHLTDataOriginTPC/*TObjArray of seeds*/);
e642ae99 77}
78
79AliHLTComponentDataType AliHLTTPCOfflineCalibrationComponent::GetOutputDataType()
80{
81 // return ouput data type
82 return kAliHLTMultipleDataType;
83}
84
85
86int AliHLTTPCOfflineCalibrationComponent::GetOutputDataTypes(AliHLTComponentDataTypeList& tgtList)
87{
88 // create output data type
89 tgtList.clear();
90 tgtList.push_back(AliHLTTPCDefinitions::fgkOfflineCalibAlignDataType);
91 tgtList.push_back(AliHLTTPCDefinitions::fgkOfflineCalibTracksDataType);
92 tgtList.push_back(AliHLTTPCDefinitions::fgkOfflineCalibTracksGainDataType);
93
94 return tgtList.size();
95}
96
97void AliHLTTPCOfflineCalibrationComponent::GetOutputDataSize(unsigned long& constBase, double& inputMultiplier)
98{
99 // get output data size
100 constBase = 30000000;
101 inputMultiplier = 1;
102}
103
104AliHLTComponent* AliHLTTPCOfflineCalibrationComponent::Spawn()
105{
106 // create instance of the component
107 return new AliHLTTPCOfflineCalibrationComponent;
108}
109
110int AliHLTTPCOfflineCalibrationComponent::InitCalibration()
111{
112 // init configuration
113
114 HLTInfo("init calibration component");
115 int iResult=0;
116
117 //
118 // initialisation
119 //
120
121 // Init parameters and cuts
122 fClustParam = AliTPCcalibDB::Instance()->GetClusterParam();
123 fTrackCuts = new AliTPCcalibTracksCuts(20, 0.4, 0.5, 0.13, 0.018);
124
125 // Init calibration componenets
126 fTPCcalibAlign = new AliTPCcalibAlign("TPCcalibAlign","TPCcalibAlign");
127 fTPCcalibTracksGain = new AliTPCcalibTracksGain("TPCcalibTracksGain","TPCcalibTracksGain",fTrackCuts);
128 fTPCcalibTracks = new AliTPCcalibTracks("TPCcalibTracks","TPCcalibTracks",fClustParam,fTrackCuts);
129
130 if (!fTrackCuts || !fClustParam || !fTPCcalibAlign || !fTPCcalibTracksGain || !fTPCcalibTracks) {
131 HLTError("failed creating internal objects");
132 iResult=-ENOMEM;
133 }
134
135 return iResult;
136}
137
138Int_t AliHLTTPCOfflineCalibrationComponent::DeinitCalibration()
139{
140 // deinit configuration
141 if(fClustParam) delete fClustParam; fClustParam = 0;
142 if(fTrackCuts) delete fTrackCuts; fTrackCuts = 0;
143
144 if(fTPCcalibAlign) delete fTPCcalibAlign; fTPCcalibAlign = 0;
145 if(fTPCcalibTracksGain) delete fTPCcalibTracksGain; fTPCcalibTracksGain = 0;
146 if(fTPCcalibTracks) delete fTPCcalibTracks; fTPCcalibTracks = 0;
147
148 return 0;
149}
150
151Int_t AliHLTTPCOfflineCalibrationComponent::ScanArgument(Int_t argc, const char** argv)
152{
153 int iResult = 0;
154
155 TString argument="";
156 TString configuration="";
157 int bMissingParam=0;
158 for (int i=0; i<argc && iResult>=0; i++) {
159 argument=argv[i];
160 if (argument.IsNull()) continue;
161
162 }
163 if (bMissingParam) {
164 HLTError("missing parameter for argument %s", argument.Data());
165 iResult=-EINVAL;
166 }
167
168 if (iResult>=0 && !configuration.IsNull()) {
169 iResult=Configure(configuration.Data());
170 } else {
171 iResult=Reconfigure(NULL, NULL);
172 }
173
174 return iResult;
175}
176
177int AliHLTTPCOfflineCalibrationComponent::ProcessCalibration(const AliHLTComponentEventData& /*evtData*/, AliHLTComponentTriggerData& /*trigData*/)
178{
179 // calibration function
180 HLTInfo("ProcessCalibration processing data");
181
182 int iResult=0;
0e442a0a 183 TObjArray *pSeedsArray=0;
e642ae99 184 int slice, patch;
185
186 // calculate specification
0e442a0a 187 const AliHLTComponentBlockData* pBlock=GetFirstInputBlock(kAliHLTDataTypeTObjArray|kAliHLTDataOriginTPC);
e642ae99 188 if(!pBlock) {
189 HLTError("Cannot get first data block 0x%08x ",pBlock);
190 iResult=-ENOMEM; return iResult;
191 }
192 int minSlice=AliHLTTPCDefinitions::GetMinSliceNr(pBlock->fSpecification);
193 int maxSlice=AliHLTTPCDefinitions::GetMaxSliceNr(pBlock->fSpecification);
194 int minPatch=AliHLTTPCDefinitions::GetMinPatchNr(pBlock->fSpecification);
195 int maxPatch=AliHLTTPCDefinitions::GetMaxPatchNr(pBlock->fSpecification);
196
197 if (fTPCcalibAlign && fTPCcalibTracksGain && fTPCcalibTracks)
198 {
0e442a0a 199 // loop over input data blocks: TObjArray of TPCseed
200 for (TObject *pObj = (TObject *)GetFirstInputObject(kAliHLTDataTypeTObjArray|kAliHLTDataOriginTPC,"TObjArray",0);
e642ae99 201 pObj !=0 && iResult>=0;
202 pObj = (TObject *)GetNextInputObject(0)) {
1726bb2d 203
0e442a0a 204 pSeedsArray = dynamic_cast<TObjArray*>(pObj);
205 if (!pSeedsArray) continue;
e642ae99 206
207 slice=AliHLTTPCDefinitions::GetMinSliceNr(GetSpecification(pObj));
208 patch=AliHLTTPCDefinitions::GetMinPatchNr(GetSpecification(pObj));
209
210 if(slice < minSlice) minSlice=slice;
211 if(slice > maxSlice) maxSlice=slice;
212 if(patch < minPatch) minPatch=patch;
213 if(patch > maxPatch) maxPatch=patch;
214
e642ae99 215 // get TPC seeds
0e442a0a 216 Int_t nseed = pSeedsArray->GetEntriesFast();
217 HLTInfo("Number TPC seeds %d",nseed);
218
219 for(Int_t i=0; i<nseed; ++i) {
220 AliTPCseed *seed = (AliTPCseed*)pSeedsArray->UncheckedAt(i);
221 if(!seed) continue;
222 HLTInfo("Process calibration on seed 0x%08x", seed);
223 fTPCcalibAlign->Process(seed);
224 fTPCcalibTracksGain->Process(seed);
225 fTPCcalibTracks->Process(seed);
1726bb2d 226 }
0e442a0a 227
e642ae99 228 // calculate specification from the specification of input data blocks
229 AliHLTUInt32_t iSpecification = AliHLTTPCDefinitions::EncodeDataSpecification(minSlice, maxSlice, minPatch, maxPatch);
230
231 // send data
232 PushBack((TObject*)fTPCcalibAlign,AliHLTTPCDefinitions::fgkOfflineCalibAlignDataType,iSpecification);
233 PushBack((TObject*)fTPCcalibTracksGain,AliHLTTPCDefinitions::fgkOfflineCalibTracksGainDataType,iSpecification);
234 PushBack((TObject*)fTPCcalibTracks,AliHLTTPCDefinitions::fgkOfflineCalibTracksDataType,iSpecification);
235
0e442a0a 236 // reset standard ESD content
237 pSeedsArray->Delete();
238
e642ae99 239 }// end loop over input objects
240
241 } else {
242 HLTError("component not initialized");
243 iResult=-ENOMEM;
244 }
245
246 return iResult;
247}
248
249Int_t AliHLTTPCOfflineCalibrationComponent::ShipDataToFXS( const AliHLTComponentEventData& /*evtData*/,
250 AliHLTComponentTriggerData& /*trigData*/ ) {
251// see header file for class documentation
252 if( fEnableAnalysis )
253 {
254 fTPCcalibAlign->Analyze();
255 fTPCcalibTracksGain->Analyze();
256 fTPCcalibTracks->Analyze();
257 }
8d53dca2 258 static AliHLTReadoutList rdList(AliHLTReadoutList::kTPC);
89413559 259 PushToFXS((TObject*)fTPCcalibAlign, "TPC", "TPCcalibAlign", &rdList) ;
260 PushToFXS((TObject*)fTPCcalibTracksGain, "TPC", "TPCcalibTracksGain", &rdList) ;
261 PushToFXS((TObject*)fTPCcalibTracks, "TPC", "TPCcalibTracks", &rdList) ;
e642ae99 262
263return 0;
264}
265
266int AliHLTTPCOfflineCalibrationComponent::Configure(const char* arguments)
267{
268 // see header file for class documentation
269 int iResult=0;
270 if (!arguments) return iResult;
271
272 TString allArgs=arguments;
273 TString argument;
274 int bMissingParam=0;
275
276 TObjArray* pTokens=allArgs.Tokenize(" ");
277 if (pTokens) {
278 for (int i=0; i<pTokens->GetEntries() && iResult>=0; i++) {
279 argument=((TObjString*)pTokens->At(i))->GetString();
280 if (argument.IsNull()) continue;
281
282 if (argument.CompareTo("-something")==0) {
283 if ((bMissingParam=(++i>=pTokens->GetEntries()))) break;
284
285 } else {
286 HLTError("unknown argument %s", argument.Data());
287 iResult=-EINVAL;
288 break;
289 }
290 }
291 delete pTokens;
292 }
293 if (bMissingParam) {
294 HLTError("missing parameter for argument %s", argument.Data());
295 iResult=-EINVAL;
296 }
297 return iResult;
298}
299
300int AliHLTTPCOfflineCalibrationComponent::Reconfigure(const char* /*cdbEntry*/, const char* /*chainId*/)
301{
302 // see header file for class documentation
303 int iResult=0;
304 return iResult;
305}