3 //**************************************************************************
4 //* This file is property of and copyright by the ALICE HLT Project *
5 //* ALICE Experiment at CERN, All rights reserved. *
7 //* Primary Authors: Matthias Richter <Matthias.Richter@ift.uib.no> *
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 //**************************************************************************
18 /** @file AliHLTTPCOfflineTrackerComponent.cxx
19 @author Jacek Otwinowski & Matthias Richter
21 @brief Wrapper component to the TPC offline tracker
24 #include "AliHLTTPCOfflineTrackerComponent.h"
26 #include "TClonesArray.h"
27 #include "TObjArray.h"
28 #include "TObjString.h"
29 #include "AliVParticle.h"
30 #include "AliCDBManager.h"
31 #include "AliCDBEntry.h"
32 #include "AliGeomManager.h"
33 #include "AliMagFMaps.h"
34 #include "AliTPCReconstructor.h"
35 #include "AliTPCParam.h"
36 #include "AliTPCRecoParam.h"
37 #include "AliTPCParamSR.h"
38 #include "AliTPCtrackerMI.h"
39 #include "AliTPCClustersRow.h"
40 #include "AliTPCseed.h"
41 #include "AliESDEvent.h"
42 #include "AliESDfriend.h"
43 #include "AliHLTTPCDefinitions.h"
45 /** ROOT macro for the implementation of ROOT specific class methods */
46 ClassImp(AliHLTTPCOfflineTrackerComponent)
48 AliHLTTPCOfflineTrackerComponent::AliHLTTPCOfflineTrackerComponent() : AliHLTProcessor(),
49 fGeometryFileName(""),
55 // Default constructor
56 fGeometryFileName = getenv("ALICE_ROOT");
57 fGeometryFileName += "/HLT/TPCLib/offline/geometry.root";
60 AliHLTTPCOfflineTrackerComponent::~AliHLTTPCOfflineTrackerComponent()
62 // see header file for class documentation
65 const char* AliHLTTPCOfflineTrackerComponent::GetComponentID()
67 // see header file for class documentation
68 return "TPCOfflineTracker";
71 void AliHLTTPCOfflineTrackerComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list)
73 // get input data type
74 list.push_back(kAliHLTDataTypeTObjArray|kAliHLTDataOriginTPC/*AliHLTTPCDefinitions::fgkOfflineClustersDataType*/);
77 AliHLTComponentDataType AliHLTTPCOfflineTrackerComponent::GetOutputDataType()
79 // create output data type
80 return kAliHLTDataTypeESDObject|kAliHLTDataOriginTPC/*AliHLTTPCDefinitions::fgkOfflineTrackSegmentsDataType*/;
83 void AliHLTTPCOfflineTrackerComponent::GetOutputDataSize(unsigned long& constBase, double& inputMultiplier)
85 // get output data size
90 AliHLTComponent* AliHLTTPCOfflineTrackerComponent::Spawn()
92 // create instance of the component
93 return new AliHLTTPCOfflineTrackerComponent;
96 int AliHLTTPCOfflineTrackerComponent::DoInit( int argc, const char** argv )
101 #ifdef HAVE_NOT_TPCOFFLINE_REC
102 HLTFatal("AliRoot version > v4-13-Release required");
107 TString configuration="";
110 // loop over input parameters
111 for (int i=0; i<argc && iResult>=0; i++) {
113 if (argument.IsNull()) continue;
115 if (argument.CompareTo("-geometry")==0) {
116 if ((bMissingParam=(++i>=argc))) break;
118 HLTInfo("got \'-geometry\' argument: %s", argv[i]);
119 fGeometryFileName = argv[i];
120 HLTInfo("Geometry file is: %s", fGeometryFileName.c_str());
122 // the remaining arguments are treated as configuration
124 if (!configuration.IsNull()) configuration+=" ";
125 configuration+=argument;
130 HLTError("missing parameter for argument %s", argument.Data());
134 if (iResult>=0 && !configuration.IsNull()) {
135 iResult=Configure(configuration.Data());
137 iResult=Reconfigure(NULL, NULL);
145 HLTInfo("Geometry file %s",fGeometryFileName.c_str());
146 AliGeomManager::LoadGeometry(fGeometryFileName.c_str());
147 if((AliGeomManager::GetGeometry()) == 0) {
148 HLTError("Cannot load geometry from file %s",fGeometryFileName.c_str());
152 // TPC reconstruction parameters
153 //AliTPCRecoParam * tpcRecoParam = AliTPCRecoParam::GetLowFluxParam();
154 AliTPCRecoParam * tpcRecoParam = AliTPCRecoParam::GetHLTParam();
156 AliTPCReconstructor::SetRecoParam(tpcRecoParam);
159 // TPC geometry parameters
160 fTPCGeomParam = new AliTPCParamSR;
162 fTPCGeomParam->ReadGeoMatrices();
166 fTracker = new AliTPCtrackerMI(fTPCGeomParam);
168 // AliESDEvent event needed by AliTPCtrackerMI
169 // output of the component
170 fESD = new AliESDEvent();
172 fESD->CreateStdContent();
175 fESDfriend = new AliESDfriend();
176 if(fESDfriend) fESD->AddObject(fESDfriend);
179 if (!fTracker || !fESD || !fTPCGeomParam) {
180 HLTError("failed creating internal objects");
185 // read the default CDB entries
186 iResult=Reconfigure(NULL, NULL);
192 int AliHLTTPCOfflineTrackerComponent::DoDeinit()
194 // deinit configuration
196 if(fTPCGeomParam) delete fTPCGeomParam; fTPCGeomParam = 0;
197 if(fTracker) delete fTracker; fTracker = 0;
198 if(fESD) delete fESD; fESD = 0;
199 //Note: fESD is owner of fESDfriends
204 int AliHLTTPCOfflineTrackerComponent::DoEvent( const AliHLTComponentEventData& /*evtData*/, AliHLTComponentTriggerData& /*trigData*/)
207 HLTInfo("DoEvent processing data");
210 TClonesArray *clusterArray=0;
211 TObjArray *seedArray=0;
214 const AliHLTComponentBlockData* pBlock=GetFirstInputBlock(kAliHLTDataTypeTObjArray|kAliHLTDataOriginTPC);
216 HLTError("Cannot get first data block 0x%08x ",pBlock);
217 iResult=-ENOMEM; return iResult;
219 int minSlice=AliHLTTPCDefinitions::GetMinSliceNr(pBlock->fSpecification);
220 int maxSlice=AliHLTTPCDefinitions::GetMaxSliceNr(pBlock->fSpecification);
221 int minPatch=AliHLTTPCDefinitions::GetMinPatchNr(pBlock->fSpecification);
222 int maxPatch=AliHLTTPCDefinitions::GetMaxPatchNr(pBlock->fSpecification);
224 if (fTracker && fESD) {
225 // loop over input data blocks: TClonesArrays of clusters
226 for (TObject *pObj = (TObject *)GetFirstInputObject(kAliHLTDataTypeTObjArray|kAliHLTDataOriginTPC/*AliHLTTPCDefinitions::fgkOfflineClustersDataType*/,"TClonesArray",0);
227 pObj !=0 && iResult>=0;
228 pObj = (TObject *)GetNextInputObject(0)) {
229 clusterArray = dynamic_cast<TClonesArray*>(pObj);
230 if (!clusterArray) continue;
232 HLTInfo("load %d clusters from block %s 0x%08x", clusterArray->GetEntries(), DataType2Text(GetDataType(pObj)).c_str(), GetSpecification(pObj));
233 slice=AliHLTTPCDefinitions::GetMinSliceNr(GetSpecification(pObj));
234 patch=AliHLTTPCDefinitions::GetMinPatchNr(GetSpecification(pObj));
236 if(slice < minSlice) minSlice=slice;
237 if(slice > maxSlice) maxSlice=slice;
238 if(patch < minPatch) minPatch=patch;
239 if(patch > maxPatch) maxPatch=patch;
240 #ifndef HAVE_NOT_TPCOFFLINE_REC
241 fTracker->LoadClusters(clusterArray);
242 #endif //HAVE_NOT_TPCOFFLINE_REC
244 clusterArray->Delete();
245 }// end loop over input objects
247 #ifndef HAVE_NOT_TPCOFFLINE_REC
248 // Load outer sectors
249 fTracker->LoadOuterSectors();
250 // Load inner sectors
251 fTracker->LoadInnerSectors();
254 // set magnetic field for the ESD, assumes correct initialization of
256 fESD->SetMagneticField(AliTracker::GetBz());
259 fTracker->Clusters2Tracks(fESD);
261 // add TPC seed to the AliESDtrack
262 seedArray = fTracker->GetSeeds();
264 Int_t nseed = seedArray->GetEntriesFast();
265 HLTInfo("Number TPC seeds %d",nseed);
267 for(Int_t i=0; i<nseed; ++i) {
268 AliTPCseed *seed = (AliTPCseed*)seedArray->UncheckedAt(i);
271 //HLTInfo("TPC seed: sec %d, row %d",seed->GetSector(), seed->GetRow());
273 AliESDtrack *esdtrack=fESD->GetTrack(i);
274 if(esdtrack) esdtrack->AddCalibObject((TObject*)seed);
276 HLTInfo("Cannot add TPC seed to AliESDtrack %d", i);
281 // reset ESDs friends (no Reset function!)
282 fESDfriend->~AliESDfriend();
283 new (fESDfriend) AliESDfriend(); // Reset ...
285 // add ESDfriend to AliESDEvent
286 fESD->GetESDfriend(fESDfriend);
289 fTracker->UnloadClusters();
291 Int_t nTracks = fESD->GetNumberOfTracks();
292 HLTInfo("Number of tracks %d", nTracks);
294 // calculate specification from the specification of input data blocks
295 AliHLTUInt32_t iSpecification = AliHLTTPCDefinitions::EncodeDataSpecification( minSlice, maxSlice, minPatch, maxPatch );
296 HLTInfo("minSlice %d, maxSlice %d, minPatch %d, maxPatch %d", minSlice, maxSlice, minPatch, maxPatch);
299 PushBack(fESD, kAliHLTDataTypeESDObject|kAliHLTDataOriginTPC, iSpecification);
301 // reset ESDs and ESDs friends
305 HLTError("component not initialized");
312 int AliHLTTPCOfflineTrackerComponent::Configure(const char* arguments)
314 // see header file for class documentation
316 if (!arguments) return iResult;
318 TString allArgs=arguments;
322 TObjArray* pTokens=allArgs.Tokenize(" ");
324 for (int i=0; i<pTokens->GetEntries() && iResult>=0; i++) {
325 argument=((TObjString*)pTokens->At(i))->GetString();
326 if (argument.IsNull()) continue;
328 if (argument.CompareTo("-solenoidBz")==0) {
329 if ((bMissingParam=(++i>=pTokens->GetEntries()))) break;
330 // TODO: check if there is common functionality in the AliMagF* classes
331 float SolenoidBz=((TObjString*)pTokens->At(i))->GetString().Atof();
332 if (SolenoidBz<kAlmost0Field) SolenoidBz=kAlmost0Field;
334 int map=AliMagFMaps::k2kG;
336 map=AliMagFMaps::k2kG;
338 } else if (SolenoidBz>=3. && SolenoidBz<4.5) {
339 map=AliMagFMaps::k4kG;
342 map=AliMagFMaps::k5kG;
345 // the magnetic field map is not supposed to change
346 // field initialization should be done once in the beginning
347 // TODO: does the factor need adjustment?
348 const AliMagF* currentMap=AliTracker::GetFieldMap();
350 AliMagFMaps* field = new AliMagFMaps("Maps","Maps", 2, 1., 10., map);
351 AliTracker::SetFieldMap(field,kTRUE);
352 HLTInfo("Solenoid Field set to: %f map %d", SolenoidBz, map);
353 } else if (currentMap->Map()!=map) {
354 HLTWarning("omitting request to override field map %s with %s", currentMap->Map(), map);
358 HLTError("unknown argument %s", argument.Data());
366 HLTError("missing parameter for argument %s", argument.Data());
372 int AliHLTTPCOfflineTrackerComponent::Reconfigure(const char* cdbEntry, const char* chainId)
374 // see header file for class documentation
376 const char* path=kAliHLTCDBSolenoidBz;
377 const char* defaultNotify="";
380 defaultNotify=" (default)";
383 if (chainId) {} // just to get rid of warning, can not comment argument due to debug message
384 HLTDebug("reconfigure from entry %s%s, chain id %s", path, defaultNotify,(chainId!=NULL && chainId[0]!=0)?chainId:"<none>");
385 AliCDBEntry *pEntry = AliCDBManager::Instance()->Get(path/*,GetRunNo()*/);
387 TObjString* pString=dynamic_cast<TObjString*>(pEntry->GetObject());
389 HLTDebug("received configuration object string: \'%s\'", pString->GetString().Data());
390 iResult=Configure(pString->GetString().Data());
392 HLTError("configuration object \"%s\" has wrong type, required TObjString", path);
395 HLTError("can not fetch object \"%s\" from CDB", path);