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 Matthias Richter
21 @brief Wrapper component to the TPC offline tracker
24 #include "AliHLTTPCOfflineTrackerComponent.h"
26 #include "TObjArray.h"
27 #include "TObjString.h"
28 #include "AliTPCParam.h"
29 #include "AliTPCParamSR.h"
30 #include "AliTPCtrackerMI.h"
31 #include "AliTPCClustersRow.h"
32 #include "AliESDEvent.h"
33 #include "AliHLTTPCDefinitions.h"
34 #include "AliTracker.h"
35 #include "AliMagFMaps.h"
37 /** ROOT macro for the implementation of ROOT specific class methods */
38 ClassImp(AliHLTTPCOfflineTrackerComponent)
40 AliHLTTPCOfflineTrackerComponent::AliHLTTPCOfflineTrackerComponent() : AliHLTProcessor(),
41 fOutputPercentage(100),
46 // see header file for class documentation
48 // refer to README to build package
50 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
53 AliHLTTPCOfflineTrackerComponent::~AliHLTTPCOfflineTrackerComponent()
55 // see header file for class documentation
58 const char* AliHLTTPCOfflineTrackerComponent::GetComponentID()
60 // see header file for class documentation
61 return "TPCOfflineTracker";
64 void AliHLTTPCOfflineTrackerComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list)
66 // get input data type
67 list.push_back(kAliHLTDataTypeTObjArray|kAliHLTDataOriginTPC/*AliHLTTPCDefinitions::fgkOfflineClustersDataType*/);
70 AliHLTComponentDataType AliHLTTPCOfflineTrackerComponent::GetOutputDataType()
72 // create output data type
73 return kAliHLTDataTypeESDObject|kAliHLTDataOriginTPC/*AliHLTTPCDefinitions::fgkOfflineTrackSegmentsDataType*/;
76 void AliHLTTPCOfflineTrackerComponent::GetOutputDataSize(unsigned long& constBase, double& inputMultiplier)
78 // get output data size
80 inputMultiplier = ((double)fOutputPercentage)/100.0;
83 AliHLTComponent* AliHLTTPCOfflineTrackerComponent::Spawn()
85 // create instance of the component
86 return new AliHLTTPCOfflineTrackerComponent;
89 int AliHLTTPCOfflineTrackerComponent::DoInit( int argc, const char** argv )
94 #ifdef HAVE_NOT_TPCOFFLINE_REC
95 HLTFatal("AliRoot version > v4-13-Release required");
100 TString configuration="";
102 for (int i=0; i<argc && iResult>=0; i++) {
104 if (argument.IsNull()) continue;
108 HLTError("missing parameter for argument %s", argument.Data());
112 if (iResult>=0 && !configuration.IsNull()) {
113 iResult=Configure(configuration.Data());
115 iResult=Reconfigure(NULL, NULL);
118 // TPC geometry parameters
119 fTPCGeomParam = new AliTPCParamSR;
121 fTPCGeomParam->ReadGeoMatrices();
125 fTracker = new AliTPCtrackerMI(fTPCGeomParam);
127 // AliESDEvent event needed by AliTPCtrackerMI
128 // output of the component
129 fESD = new AliESDEvent();
131 fESD->CreateStdContent();
134 // TODO: set the magnetic field correctly
135 // the tracker needs the field map correctly initialized in AliTracker.
136 // init from HLT/ConfigHLT/SolenoidBz or other appropriate CDB entry.
137 // temporarily set to 5kG
138 if (!AliTracker::GetFieldMap()) {
139 // this instance must never be deleted, the AliRoot framework and the design
140 // of AliTracker just does not support this. That's why we do not keep the
141 // pointer. The memory leak is relativly small.
142 AliMagFMaps* field = new AliMagFMaps("Maps","Maps", 2, 1., 10., AliMagFMaps::k5kG);
143 AliTracker::SetFieldMap(field,kTRUE);
146 if (!fTracker || !fESD || !fTPCGeomParam) {
147 HLTError("failed creating internal objects");
154 int AliHLTTPCOfflineTrackerComponent::DoDeinit()
156 // deinit configuration
158 if(fTPCGeomParam) delete fTPCGeomParam; fTPCGeomParam = 0;
159 if(fTracker) delete fTracker; fTracker = 0;
160 if(fESD) delete fESD; fESD = 0;
165 int AliHLTTPCOfflineTrackerComponent::DoEvent( const AliHLTComponentEventData& /*evtData*/, AliHLTComponentTriggerData& /*trigData*/)
168 HLTInfo("DoEvent processing data");
170 // Logging(kHLTLogDebug, "AliHLTTPCOfflineTrackerComponent::DoEvent", "Trigger data received",
171 // "Struct size %d Data size %d Data location 0x%x", trigData.fStructSize, trigData.fDataSize, (UInt_t*)trigData.fData);
173 TObjArray *clusterArray = 0;
177 if (fTracker && fESD) {
178 // loop over input data blocks: TObjArrays of clusters
179 for (TObject *pObj = (TObject *)GetFirstInputObject(kAliHLTDataTypeTObjArray|kAliHLTDataOriginTPC/*AliHLTTPCDefinitions::fgkOfflineClustersDataType*/,"TObjArray",0);
180 pObj !=0 && iResult>=0;
181 pObj = (TObject *)GetNextInputObject(0)) {
182 clusterArray = dynamic_cast<TObjArray*>(pObj);
183 if (!clusterArray) continue;
184 // int lower=clusterArray->LowerBound();
185 // int entries=clusterArray->GetEntries();
186 // if (entries<=lower) continue;
187 // if (clusterArray->At(lower)==NULL) continue;
188 // if (dynamic_cast<AliTPCClustersRow*>(clusterArray->At(lower))==NULL) continue;
190 HLTInfo("load %d cluster rows from block %s 0x%08x", clusterArray->GetEntries(), DataType2Text(GetDataType(pObj)).c_str(), GetSpecification(pObj));
191 #ifndef HAVE_NOT_TPCOFFLINE_REC
192 fTracker->LoadClusters(clusterArray);
193 #endif //HAVE_NOT_TPCOFFLINE_REC
194 }// end loop over input objects
196 // set magnetic field for the ESD, assumes correct initialization of
198 fESD->SetMagneticField(AliTracker::GetBz());
201 fTracker->Clusters2Tracks(fESD);
202 fTracker->UnloadClusters();
204 Int_t nTracks = fESD->GetNumberOfTracks();
205 HLTInfo("Number of tracks %d", nTracks);
207 // TODO: calculate specification from the specification of input data blocks
208 PushBack(fESD, kAliHLTDataTypeESDObject|kAliHLTDataOriginTPC, 0);
210 // Alternatively: Push back tracks
211 // for (Int_t it = 0; it < nTracks; it++) {
212 // AliESDtrack* track = fESD->GetTrack(it);
213 // PushBack(track, AliHLTTPCDefinitions::fgkOfflineTrackSegmentsDataType, 0);
216 // is this necessary? If yes, we have to keep all the created TObjArrays
217 // from the loop above
219 //clusterArray->Clear();
220 //clusterArray->Delete();
225 HLTError("component not initialized");
232 int AliHLTTPCOfflineTrackerComponent::Configure(const char* arguments)
234 // see header file for class documentation
236 if (!arguments) return iResult;
238 TString allArgs=arguments;
242 TObjArray* pTokens=allArgs.Tokenize(" ");
244 for (int i=0; i<pTokens->GetEntries() && iResult>=0; i++) {
245 argument=((TObjString*)pTokens->At(i))->GetString();
246 if (argument.IsNull()) continue;
248 if (argument.CompareTo("-something")==0) {
249 if ((bMissingParam=(++i>=pTokens->GetEntries()))) break;
252 HLTError("unknown argument %s", argument.Data());
260 HLTError("missing parameter for argument %s", argument.Data());
266 int AliHLTTPCOfflineTrackerComponent::Reconfigure(const char* /*cdbEntry*/, const char* /*chainId*/)
268 // see header file for class documentation