]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/TPCLib/offline/AliHLTTPCOfflineTrackerComponent.cxx
Major update required to handle old and new AliHLTEventDDL structures within HLT...
[u/mrichter/AliRoot.git] / HLT / TPCLib / offline / AliHLTTPCOfflineTrackerComponent.cxx
CommitLineData
1ac82ce6 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//* *
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 AliHLTTPCOfflineTrackerComponent.cxx
1726bb2d 19 @author Jacek Otwinowski & Matthias Richter
1ac82ce6 20 @date
21 @brief Wrapper component to the TPC offline tracker
22*/
23
24#include "AliHLTTPCOfflineTrackerComponent.h"
25#include "TString.h"
89c2e505 26#include "TClonesArray.h"
1ac82ce6 27#include "TObjArray.h"
28#include "TObjString.h"
e642ae99 29#include "AliVParticle.h"
30#include "AliCDBManager.h"
31#include "AliCDBEntry.h"
32#include "AliGeomManager.h"
89c2e505 33#include "AliTPCReconstructor.h"
aa40a4a1 34#include "AliTPCParam.h"
89c2e505 35#include "AliTPCRecoParam.h"
aa40a4a1 36#include "AliTPCParamSR.h"
37#include "AliTPCtrackerMI.h"
38#include "AliTPCClustersRow.h"
89c2e505 39#include "AliTPCseed.h"
aa40a4a1 40#include "AliESDEvent.h"
41#include "AliHLTTPCDefinitions.h"
1ac82ce6 42
43/** ROOT macro for the implementation of ROOT specific class methods */
44ClassImp(AliHLTTPCOfflineTrackerComponent)
45
aa40a4a1 46AliHLTTPCOfflineTrackerComponent::AliHLTTPCOfflineTrackerComponent() : AliHLTProcessor(),
e642ae99 47fGeometryFileName(""),
aa40a4a1 48fTPCGeomParam(0),
49fTracker(0),
0e442a0a 50fESD(0)
1ac82ce6 51{
e642ae99 52 // Default constructor
53 fGeometryFileName = getenv("ALICE_ROOT");
54 fGeometryFileName += "/HLT/TPCLib/offline/geometry.root";
1ac82ce6 55}
56
57AliHLTTPCOfflineTrackerComponent::~AliHLTTPCOfflineTrackerComponent()
58{
59 // see header file for class documentation
60}
61
62const char* AliHLTTPCOfflineTrackerComponent::GetComponentID()
63{
64 // see header file for class documentation
65 return "TPCOfflineTracker";
66}
67
68void AliHLTTPCOfflineTrackerComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list)
69{
aa40a4a1 70 // get input data type
71 list.push_back(kAliHLTDataTypeTObjArray|kAliHLTDataOriginTPC/*AliHLTTPCDefinitions::fgkOfflineClustersDataType*/);
1ac82ce6 72}
73
74AliHLTComponentDataType AliHLTTPCOfflineTrackerComponent::GetOutputDataType()
75{
aa40a4a1 76 // create output data type
77 return kAliHLTDataTypeESDObject|kAliHLTDataOriginTPC/*AliHLTTPCDefinitions::fgkOfflineTrackSegmentsDataType*/;
1ac82ce6 78}
79
80void AliHLTTPCOfflineTrackerComponent::GetOutputDataSize(unsigned long& constBase, double& inputMultiplier)
81{
aa40a4a1 82 // get output data size
83 constBase = 2000000;
e642ae99 84 inputMultiplier = 1;
1ac82ce6 85}
86
87AliHLTComponent* AliHLTTPCOfflineTrackerComponent::Spawn()
88{
aa40a4a1 89 // create instance of the component
1ac82ce6 90 return new AliHLTTPCOfflineTrackerComponent;
91}
92
93int AliHLTTPCOfflineTrackerComponent::DoInit( int argc, const char** argv )
94{
aa40a4a1 95 // init configuration
96 //
1ac82ce6 97 int iResult=0;
c03e064d 98#ifdef HAVE_NOT_TPCOFFLINE_REC
99 HLTFatal("AliRoot version > v4-13-Release required");
100 return -ENOSYS;
aa40a4a1 101#endif
1ac82ce6 102
103 TString argument="";
104 TString configuration="";
105 int bMissingParam=0;
e642ae99 106
107 // loop over input parameters
1ac82ce6 108 for (int i=0; i<argc && iResult>=0; i++) {
109 argument=argv[i];
110 if (argument.IsNull()) continue;
111
e642ae99 112 if (argument.CompareTo("-geometry")==0) {
113 if ((bMissingParam=(++i>=argc))) break;
114
115 HLTInfo("got \'-geometry\' argument: %s", argv[i]);
116 fGeometryFileName = argv[i];
117 HLTInfo("Geometry file is: %s", fGeometryFileName.c_str());
118
119 // the remaining arguments are treated as configuration
120 } else {
121 if (!configuration.IsNull()) configuration+=" ";
122 configuration+=argument;
123 }
124 } // end loop
125
1ac82ce6 126 if (bMissingParam) {
127 HLTError("missing parameter for argument %s", argument.Data());
128 iResult=-EINVAL;
129 }
130
131 if (iResult>=0 && !configuration.IsNull()) {
132 iResult=Configure(configuration.Data());
133 } else {
134 iResult=Reconfigure(NULL, NULL);
135 }
136
e642ae99 137 //
138 // initialisation
139 //
1b56c057 140
e642ae99 141 // Load geometry
e642ae99 142 AliGeomManager::LoadGeometry(fGeometryFileName.c_str());
143 if((AliGeomManager::GetGeometry()) == 0) {
144 HLTError("Cannot load geometry from file %s",fGeometryFileName.c_str());
145 iResult=-EINVAL;
146 }
89c2e505 147
148 // TPC reconstruction parameters
89c2e505 149 AliTPCRecoParam * tpcRecoParam = AliTPCRecoParam::GetHLTParam();
150 if(tpcRecoParam) {
1b56c057 151 tpcRecoParam->SetClusterSharing(kTRUE);
152
7e88424f 153 AliTPCReconstructor tpcReconstructor;
154 tpcReconstructor.SetRecoParam(tpcRecoParam);
89c2e505 155 }
e642ae99 156
aa40a4a1 157 // TPC geometry parameters
158 fTPCGeomParam = new AliTPCParamSR;
159 if (fTPCGeomParam) {
160 fTPCGeomParam->ReadGeoMatrices();
161 }
162
e642ae99 163 // Init tracker
aa40a4a1 164 fTracker = new AliTPCtrackerMI(fTPCGeomParam);
165
166 // AliESDEvent event needed by AliTPCtrackerMI
167 // output of the component
168 fESD = new AliESDEvent();
169 if (fESD) {
170 fESD->CreateStdContent();
488581c1 171 }
172
aa40a4a1 173 if (!fTracker || !fESD || !fTPCGeomParam) {
174 HLTError("failed creating internal objects");
175 iResult=-ENOMEM;
176 }
177
e642ae99 178 if (iResult>=0) {
179 // read the default CDB entries
180 iResult=Reconfigure(NULL, NULL);
181 }
182
1ac82ce6 183 return iResult;
184}
185
186int AliHLTTPCOfflineTrackerComponent::DoDeinit()
187{
aa40a4a1 188 // deinit configuration
189
190 if(fTPCGeomParam) delete fTPCGeomParam; fTPCGeomParam = 0;
191 if(fTracker) delete fTracker; fTracker = 0;
192 if(fESD) delete fESD; fESD = 0;
193
1ac82ce6 194 return 0;
195}
196
197int AliHLTTPCOfflineTrackerComponent::DoEvent( const AliHLTComponentEventData& /*evtData*/, AliHLTComponentTriggerData& /*trigData*/)
198{
aa40a4a1 199 // tracker function
200 HLTInfo("DoEvent processing data");
1ac82ce6 201
aa40a4a1 202 int iResult=0;
89c2e505 203 TClonesArray *clusterArray=0;
e642ae99 204 int slice, patch;
205
206 const AliHLTComponentBlockData* pBlock=GetFirstInputBlock(kAliHLTDataTypeTObjArray|kAliHLTDataOriginTPC);
207 if(!pBlock) {
208 HLTError("Cannot get first data block 0x%08x ",pBlock);
209 iResult=-ENOMEM; return iResult;
210 }
211 int minSlice=AliHLTTPCDefinitions::GetMinSliceNr(pBlock->fSpecification);
212 int maxSlice=AliHLTTPCDefinitions::GetMaxSliceNr(pBlock->fSpecification);
213 int minPatch=AliHLTTPCDefinitions::GetMinPatchNr(pBlock->fSpecification);
214 int maxPatch=AliHLTTPCDefinitions::GetMaxPatchNr(pBlock->fSpecification);
aa40a4a1 215
216 if (fTracker && fESD) {
89c2e505 217 // loop over input data blocks: TClonesArrays of clusters
dcb8a00c 218 for (TObject *pObj = (TObject *)GetFirstInputObject(kAliHLTDataTypeTObjArray|kAliHLTDataOriginTPC/*AliHLTTPCDefinitions::fgkOfflineClustersDataType*/,"TClonesArray",0);
aa40a4a1 219 pObj !=0 && iResult>=0;
220 pObj = (TObject *)GetNextInputObject(0)) {
89c2e505 221 clusterArray = dynamic_cast<TClonesArray*>(pObj);
aa40a4a1 222 if (!clusterArray) continue;
aa40a4a1 223
89c2e505 224 HLTInfo("load %d clusters from block %s 0x%08x", clusterArray->GetEntries(), DataType2Text(GetDataType(pObj)).c_str(), GetSpecification(pObj));
e642ae99 225 slice=AliHLTTPCDefinitions::GetMinSliceNr(GetSpecification(pObj));
226 patch=AliHLTTPCDefinitions::GetMinPatchNr(GetSpecification(pObj));
227
228 if(slice < minSlice) minSlice=slice;
229 if(slice > maxSlice) maxSlice=slice;
230 if(patch < minPatch) minPatch=patch;
231 if(patch > maxPatch) maxPatch=patch;
c03e064d 232#ifndef HAVE_NOT_TPCOFFLINE_REC
aa40a4a1 233 fTracker->LoadClusters(clusterArray);
c03e064d 234#endif //HAVE_NOT_TPCOFFLINE_REC
89c2e505 235
236 clusterArray->Delete();
aa40a4a1 237 }// end loop over input objects
238
89c2e505 239#ifndef HAVE_NOT_TPCOFFLINE_REC
240 // Load outer sectors
241 fTracker->LoadOuterSectors();
242 // Load inner sectors
243 fTracker->LoadInnerSectors();
244#endif
245
488581c1 246 // set magnetic field for the ESD, assumes correct initialization of
247 // the field map
248 fESD->SetMagneticField(AliTracker::GetBz());
89c2e505 249
aa40a4a1 250 // run tracker
251 fTracker->Clusters2Tracks(fESD);
1726bb2d 252
1726bb2d 253 // unload clusters
aa40a4a1 254 fTracker->UnloadClusters();
255
256 Int_t nTracks = fESD->GetNumberOfTracks();
0e442a0a 257 HLTInfo("Number TPC tracks %d", nTracks);
aa40a4a1 258
e642ae99 259 // calculate specification from the specification of input data blocks
260 AliHLTUInt32_t iSpecification = AliHLTTPCDefinitions::EncodeDataSpecification( minSlice, maxSlice, minPatch, maxPatch );
261 HLTInfo("minSlice %d, maxSlice %d, minPatch %d, maxPatch %d", minSlice, maxSlice, minPatch, maxPatch);
aa40a4a1 262
e642ae99 263 // send data
264 PushBack(fESD, kAliHLTDataTypeESDObject|kAliHLTDataOriginTPC, iSpecification);
aa40a4a1 265
89c2e505 266 // reset ESDs and ESDs friends
aa40a4a1 267 fESD->Reset();
e642ae99 268
aa40a4a1 269 } else {
270 HLTError("component not initialized");
271 iResult=-ENOMEM;
272 }
273
274 return iResult;
1ac82ce6 275}
276
277int AliHLTTPCOfflineTrackerComponent::Configure(const char* arguments)
278{
279 // see header file for class documentation
280 int iResult=0;
281 if (!arguments) return iResult;
282
283 TString allArgs=arguments;
284 TString argument;
285 int bMissingParam=0;
286
287 TObjArray* pTokens=allArgs.Tokenize(" ");
288 if (pTokens) {
289 for (int i=0; i<pTokens->GetEntries() && iResult>=0; i++) {
290 argument=((TObjString*)pTokens->At(i))->GetString();
291 if (argument.IsNull()) continue;
292
e642ae99 293 if (argument.CompareTo("-solenoidBz")==0) {
75970b8d 294 if ( ( bMissingParam = ( ++i >= pTokens->GetEntries() ) ) ) break;
295 HLTWarning("argument -solenoidBz is deprecated, magnetic field set up globally (%f)", GetBz());
e642ae99 296 continue;
1ac82ce6 297 } else {
298 HLTError("unknown argument %s", argument.Data());
299 iResult=-EINVAL;
300 break;
301 }
302 }
303 delete pTokens;
304 }
305 if (bMissingParam) {
306 HLTError("missing parameter for argument %s", argument.Data());
307 iResult=-EINVAL;
308 }
309 return iResult;
310}
311
e642ae99 312int AliHLTTPCOfflineTrackerComponent::Reconfigure(const char* cdbEntry, const char* chainId)
1ac82ce6 313{
314 // see header file for class documentation
315 int iResult=0;
e642ae99 316 const char* path=kAliHLTCDBSolenoidBz;
317 const char* defaultNotify="";
318 if (cdbEntry) {
319 path=cdbEntry;
320 defaultNotify=" (default)";
321 }
322 if (path) {
73449074 323 if (chainId) {} // just to get rid of warning, can not comment argument due to debug message
e642ae99 324 HLTDebug("reconfigure from entry %s%s, chain id %s", path, defaultNotify,(chainId!=NULL && chainId[0]!=0)?chainId:"<none>");
325 AliCDBEntry *pEntry = AliCDBManager::Instance()->Get(path/*,GetRunNo()*/);
326 if (pEntry) {
327 TObjString* pString=dynamic_cast<TObjString*>(pEntry->GetObject());
328 if (pString) {
329 HLTDebug("received configuration object string: \'%s\'", pString->GetString().Data());
330 iResult=Configure(pString->GetString().Data());
331 } else {
332 HLTError("configuration object \"%s\" has wrong type, required TObjString", path);
333 }
334 } else {
335 HLTError("can not fetch object \"%s\" from CDB", path);
336 }
337 }
338
1ac82ce6 339 return iResult;
340}