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 #ifndef HAVE_NOT_ALIMAGF30848
35 #else // keeping the <30489 code for backward compatibility, to be merged at some point
36 #include "AliMagFMaps.h"
38 #include "AliTPCReconstructor.h"
39 #include "AliTPCParam.h"
40 #include "AliTPCRecoParam.h"
41 #include "AliTPCParamSR.h"
42 #include "AliTPCtrackerMI.h"
43 #include "AliTPCClustersRow.h"
44 #include "AliTPCseed.h"
45 #include "AliESDEvent.h"
46 #include "AliHLTTPCDefinitions.h"
48 /** ROOT macro for the implementation of ROOT specific class methods */
49 ClassImp(AliHLTTPCOfflineTrackerComponent)
51 AliHLTTPCOfflineTrackerComponent::AliHLTTPCOfflineTrackerComponent() : AliHLTProcessor(),
52 fGeometryFileName(""),
57 // Default constructor
58 fGeometryFileName = getenv("ALICE_ROOT");
59 fGeometryFileName += "/HLT/TPCLib/offline/geometry.root";
62 AliHLTTPCOfflineTrackerComponent::~AliHLTTPCOfflineTrackerComponent()
64 // see header file for class documentation
67 const char* AliHLTTPCOfflineTrackerComponent::GetComponentID()
69 // see header file for class documentation
70 return "TPCOfflineTracker";
73 void AliHLTTPCOfflineTrackerComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list)
75 // get input data type
76 list.push_back(kAliHLTDataTypeTObjArray|kAliHLTDataOriginTPC/*AliHLTTPCDefinitions::fgkOfflineClustersDataType*/);
79 AliHLTComponentDataType AliHLTTPCOfflineTrackerComponent::GetOutputDataType()
81 // create output data type
82 return kAliHLTDataTypeESDObject|kAliHLTDataOriginTPC/*AliHLTTPCDefinitions::fgkOfflineTrackSegmentsDataType*/;
85 void AliHLTTPCOfflineTrackerComponent::GetOutputDataSize(unsigned long& constBase, double& inputMultiplier)
87 // get output data size
92 AliHLTComponent* AliHLTTPCOfflineTrackerComponent::Spawn()
94 // create instance of the component
95 return new AliHLTTPCOfflineTrackerComponent;
98 int AliHLTTPCOfflineTrackerComponent::DoInit( int argc, const char** argv )
100 // init configuration
103 #ifdef HAVE_NOT_TPCOFFLINE_REC
104 HLTFatal("AliRoot version > v4-13-Release required");
109 TString configuration="";
112 // loop over input parameters
113 for (int i=0; i<argc && iResult>=0; i++) {
115 if (argument.IsNull()) continue;
117 if (argument.CompareTo("-geometry")==0) {
118 if ((bMissingParam=(++i>=argc))) break;
120 HLTInfo("got \'-geometry\' argument: %s", argv[i]);
121 fGeometryFileName = argv[i];
122 HLTInfo("Geometry file is: %s", fGeometryFileName.c_str());
124 // the remaining arguments are treated as configuration
126 if (!configuration.IsNull()) configuration+=" ";
127 configuration+=argument;
132 HLTError("missing parameter for argument %s", argument.Data());
136 if (iResult>=0 && !configuration.IsNull()) {
137 iResult=Configure(configuration.Data());
139 iResult=Reconfigure(NULL, NULL);
147 AliGeomManager::LoadGeometry(fGeometryFileName.c_str());
148 if((AliGeomManager::GetGeometry()) == 0) {
149 HLTError("Cannot load geometry from file %s",fGeometryFileName.c_str());
153 // TPC reconstruction parameters
154 AliTPCRecoParam * tpcRecoParam = AliTPCRecoParam::GetHLTParam();
156 tpcRecoParam->SetClusterSharing(kTRUE);
158 AliTPCReconstructor tpcReconstructor;
159 tpcReconstructor.SetRecoParam(tpcRecoParam);
162 // TPC geometry parameters
163 fTPCGeomParam = new AliTPCParamSR;
165 fTPCGeomParam->ReadGeoMatrices();
169 fTracker = new AliTPCtrackerMI(fTPCGeomParam);
171 // AliESDEvent event needed by AliTPCtrackerMI
172 // output of the component
173 fESD = new AliESDEvent();
175 fESD->CreateStdContent();
178 if (!fTracker || !fESD || !fTPCGeomParam) {
179 HLTError("failed creating internal objects");
184 // read the default CDB entries
185 iResult=Reconfigure(NULL, NULL);
191 int AliHLTTPCOfflineTrackerComponent::DoDeinit()
193 // deinit configuration
195 if(fTPCGeomParam) delete fTPCGeomParam; fTPCGeomParam = 0;
196 if(fTracker) delete fTracker; fTracker = 0;
197 if(fESD) delete fESD; fESD = 0;
202 int AliHLTTPCOfflineTrackerComponent::DoEvent( const AliHLTComponentEventData& /*evtData*/, AliHLTComponentTriggerData& /*trigData*/)
205 HLTInfo("DoEvent processing data");
208 TClonesArray *clusterArray=0;
211 const AliHLTComponentBlockData* pBlock=GetFirstInputBlock(kAliHLTDataTypeTObjArray|kAliHLTDataOriginTPC);
213 HLTError("Cannot get first data block 0x%08x ",pBlock);
214 iResult=-ENOMEM; return iResult;
216 int minSlice=AliHLTTPCDefinitions::GetMinSliceNr(pBlock->fSpecification);
217 int maxSlice=AliHLTTPCDefinitions::GetMaxSliceNr(pBlock->fSpecification);
218 int minPatch=AliHLTTPCDefinitions::GetMinPatchNr(pBlock->fSpecification);
219 int maxPatch=AliHLTTPCDefinitions::GetMaxPatchNr(pBlock->fSpecification);
221 if (fTracker && fESD) {
222 // loop over input data blocks: TClonesArrays of clusters
223 for (TObject *pObj = (TObject *)GetFirstInputObject(kAliHLTDataTypeTObjArray|kAliHLTDataOriginTPC/*AliHLTTPCDefinitions::fgkOfflineClustersDataType*/,"TClonesArray",0);
224 pObj !=0 && iResult>=0;
225 pObj = (TObject *)GetNextInputObject(0)) {
226 clusterArray = dynamic_cast<TClonesArray*>(pObj);
227 if (!clusterArray) continue;
229 HLTInfo("load %d clusters from block %s 0x%08x", clusterArray->GetEntries(), DataType2Text(GetDataType(pObj)).c_str(), GetSpecification(pObj));
230 slice=AliHLTTPCDefinitions::GetMinSliceNr(GetSpecification(pObj));
231 patch=AliHLTTPCDefinitions::GetMinPatchNr(GetSpecification(pObj));
233 if(slice < minSlice) minSlice=slice;
234 if(slice > maxSlice) maxSlice=slice;
235 if(patch < minPatch) minPatch=patch;
236 if(patch > maxPatch) maxPatch=patch;
237 #ifndef HAVE_NOT_TPCOFFLINE_REC
238 fTracker->LoadClusters(clusterArray);
239 #endif //HAVE_NOT_TPCOFFLINE_REC
241 clusterArray->Delete();
242 }// end loop over input objects
244 #ifndef HAVE_NOT_TPCOFFLINE_REC
245 // Load outer sectors
246 fTracker->LoadOuterSectors();
247 // Load inner sectors
248 fTracker->LoadInnerSectors();
251 // set magnetic field for the ESD, assumes correct initialization of
253 fESD->SetMagneticField(AliTracker::GetBz());
256 fTracker->Clusters2Tracks(fESD);
259 fTracker->UnloadClusters();
261 Int_t nTracks = fESD->GetNumberOfTracks();
262 HLTInfo("Number TPC tracks %d", nTracks);
264 // calculate specification from the specification of input data blocks
265 AliHLTUInt32_t iSpecification = AliHLTTPCDefinitions::EncodeDataSpecification( minSlice, maxSlice, minPatch, maxPatch );
266 HLTInfo("minSlice %d, maxSlice %d, minPatch %d, maxPatch %d", minSlice, maxSlice, minPatch, maxPatch);
269 PushBack(fESD, kAliHLTDataTypeESDObject|kAliHLTDataOriginTPC, iSpecification);
271 // reset ESDs and ESDs friends
275 HLTError("component not initialized");
282 int AliHLTTPCOfflineTrackerComponent::Configure(const char* arguments)
284 // see header file for class documentation
286 if (!arguments) return iResult;
288 TString allArgs=arguments;
292 TObjArray* pTokens=allArgs.Tokenize(" ");
294 for (int i=0; i<pTokens->GetEntries() && iResult>=0; i++) {
295 argument=((TObjString*)pTokens->At(i))->GetString();
296 if (argument.IsNull()) continue;
298 if (argument.CompareTo("-solenoidBz")==0) {
299 #ifndef HAVE_NOT_ALIMAGF30848
300 if ((bMissingParam=(++i>=pTokens->GetEntries()))) break;
301 // TODO: Matthias 2009-05-08 this changes below look weird to me
302 // maybe this was not correctly done by Federico in r 30849
303 float SolenoidBz=((TObjString*)pTokens->At(i))->GetString().Atof();
304 if (SolenoidBz<kAlmost0Field) SolenoidBz=kAlmost0Field;
305 float factor=SolenoidBz/5;
307 AliMagF::BMap_t map = AliMagF::k5kG;
311 } /*else if (SolenoidBz>=3. && SolenoidBz<4.5) {
312 map=AliMagFMaps::k4kG;
316 map=AliMagFMaps::k5kG;
319 // the magnetic field map is not supposed to change
320 // field initialization should be done once in the beginning
321 // TODO: does the factor need adjustment?
322 const AliMagF* currentMap = (AliMagF*)TGeoGlobalMagField::Instance()->GetField();
324 AliMagF* field = new AliMagF("MagneticFieldMap", "BMap", 2, 1., 1., 10., map);
325 TGeoGlobalMagField::Instance()->SetField(field);
326 HLTInfo("Solenoid Field set to: %f map %d", SolenoidBz, map);
327 } else if (currentMap->GetMapType()!=map) {
328 HLTWarning("omitting request to override field map %d with %d", currentMap->GetMapType(), map);
330 #else // keeping the <30489 code for backward compatibility, to be merged at some point
331 if ((bMissingParam=(++i>=pTokens->GetEntries()))) break;
332 // TODO: check if there is common functionality in the AliMagF* classes
333 float SolenoidBz=((TObjString*)pTokens->At(i))->GetString().Atof();
334 if (SolenoidBz<kAlmost0Field) SolenoidBz=kAlmost0Field;
336 int map=AliMagFMaps::k2kG;
338 map=AliMagFMaps::k2kG;
340 } else if (SolenoidBz>=3. && SolenoidBz<4.5) {
341 map=AliMagFMaps::k4kG;
344 map=AliMagFMaps::k5kG;
347 // the magnetic field map is not supposed to change
348 // field initialization should be done once in the beginning
349 // TODO: does the factor need adjustment?
350 const AliMagF* currentMap=AliTracker::GetFieldMap();
352 AliMagFMaps* field = new AliMagFMaps("Maps","Maps", 2, 1., 10., map);
353 AliTracker::SetFieldMap(field,kFALSE);
354 HLTInfo("Solenoid Field set to: %f map %d", SolenoidBz, map);
355 } else if (currentMap->Map()!=map) {
356 HLTWarning("omitting request to override field map %s with %s", currentMap->Map(), map);
361 HLTError("unknown argument %s", argument.Data());
369 HLTError("missing parameter for argument %s", argument.Data());
375 int AliHLTTPCOfflineTrackerComponent::Reconfigure(const char* cdbEntry, const char* chainId)
377 // see header file for class documentation
379 const char* path=kAliHLTCDBSolenoidBz;
380 const char* defaultNotify="";
383 defaultNotify=" (default)";
386 if (chainId) {} // just to get rid of warning, can not comment argument due to debug message
387 HLTDebug("reconfigure from entry %s%s, chain id %s", path, defaultNotify,(chainId!=NULL && chainId[0]!=0)?chainId:"<none>");
388 AliCDBEntry *pEntry = AliCDBManager::Instance()->Get(path/*,GetRunNo()*/);
390 TObjString* pString=dynamic_cast<TObjString*>(pEntry->GetObject());
392 HLTDebug("received configuration object string: \'%s\'", pString->GetString().Data());
393 iResult=Configure(pString->GetString().Data());
395 HLTError("configuration object \"%s\" has wrong type, required TObjString", path);
398 HLTError("can not fetch object \"%s\" from CDB", path);