]>
Commit | Line | Data |
---|---|---|
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 | |
19 | @author Matthias Richter | |
20 | @date | |
21 | @brief Wrapper component to the TPC offline tracker | |
22 | */ | |
23 | ||
24 | #include "AliHLTTPCOfflineTrackerComponent.h" | |
25 | #include "TString.h" | |
26 | #include "TObjArray.h" | |
27 | #include "TObjString.h" | |
aa40a4a1 | 28 | #include "AliTPCParam.h" |
29 | #include "AliTPCParamSR.h" | |
30 | #include "AliTPCtrackerMI.h" | |
31 | #include "AliTPCClustersRow.h" | |
32 | #include "AliESDEvent.h" | |
33 | #include "AliHLTTPCDefinitions.h" | |
1ac82ce6 | 34 | |
35 | /** ROOT macro for the implementation of ROOT specific class methods */ | |
36 | ClassImp(AliHLTTPCOfflineTrackerComponent) | |
37 | ||
aa40a4a1 | 38 | AliHLTTPCOfflineTrackerComponent::AliHLTTPCOfflineTrackerComponent() : AliHLTProcessor(), |
39 | fOutputPercentage(100), | |
40 | fTPCGeomParam(0), | |
41 | fTracker(0), | |
42 | fESD(0) | |
1ac82ce6 | 43 | { |
44 | // see header file for class documentation | |
45 | // or | |
46 | // refer to README to build package | |
47 | // or | |
48 | // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt | |
49 | } | |
50 | ||
51 | AliHLTTPCOfflineTrackerComponent::~AliHLTTPCOfflineTrackerComponent() | |
52 | { | |
53 | // see header file for class documentation | |
54 | } | |
55 | ||
56 | const char* AliHLTTPCOfflineTrackerComponent::GetComponentID() | |
57 | { | |
58 | // see header file for class documentation | |
59 | return "TPCOfflineTracker"; | |
60 | } | |
61 | ||
62 | void AliHLTTPCOfflineTrackerComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list) | |
63 | { | |
aa40a4a1 | 64 | // get input data type |
65 | list.push_back(kAliHLTDataTypeTObjArray|kAliHLTDataOriginTPC/*AliHLTTPCDefinitions::fgkOfflineClustersDataType*/); | |
1ac82ce6 | 66 | } |
67 | ||
68 | AliHLTComponentDataType AliHLTTPCOfflineTrackerComponent::GetOutputDataType() | |
69 | { | |
aa40a4a1 | 70 | // create output data type |
71 | return kAliHLTDataTypeESDObject|kAliHLTDataOriginTPC/*AliHLTTPCDefinitions::fgkOfflineTrackSegmentsDataType*/; | |
1ac82ce6 | 72 | } |
73 | ||
74 | void AliHLTTPCOfflineTrackerComponent::GetOutputDataSize(unsigned long& constBase, double& inputMultiplier) | |
75 | { | |
aa40a4a1 | 76 | // get output data size |
77 | constBase = 2000000; | |
78 | inputMultiplier = ((double)fOutputPercentage)/100.0; | |
1ac82ce6 | 79 | } |
80 | ||
81 | AliHLTComponent* AliHLTTPCOfflineTrackerComponent::Spawn() | |
82 | { | |
aa40a4a1 | 83 | // create instance of the component |
1ac82ce6 | 84 | return new AliHLTTPCOfflineTrackerComponent; |
85 | } | |
86 | ||
87 | int AliHLTTPCOfflineTrackerComponent::DoInit( int argc, const char** argv ) | |
88 | { | |
aa40a4a1 | 89 | // init configuration |
90 | // | |
1ac82ce6 | 91 | int iResult=0; |
aa40a4a1 | 92 | #ifdef HAVE_NOT_TPC_LOAD_CLUSTERS |
93 | HLTError("AliRoot version > v4-13-Release required"); | |
94 | return -EFAULT; | |
95 | #endif | |
1ac82ce6 | 96 | |
97 | TString argument=""; | |
98 | TString configuration=""; | |
99 | int bMissingParam=0; | |
100 | for (int i=0; i<argc && iResult>=0; i++) { | |
101 | argument=argv[i]; | |
102 | if (argument.IsNull()) continue; | |
103 | ||
104 | } | |
105 | if (bMissingParam) { | |
106 | HLTError("missing parameter for argument %s", argument.Data()); | |
107 | iResult=-EINVAL; | |
108 | } | |
109 | ||
110 | if (iResult>=0 && !configuration.IsNull()) { | |
111 | iResult=Configure(configuration.Data()); | |
112 | } else { | |
113 | iResult=Reconfigure(NULL, NULL); | |
114 | } | |
115 | ||
aa40a4a1 | 116 | // TPC geometry parameters |
117 | fTPCGeomParam = new AliTPCParamSR; | |
118 | if (fTPCGeomParam) { | |
119 | fTPCGeomParam->ReadGeoMatrices(); | |
120 | } | |
121 | ||
122 | // Init clusterer | |
123 | fTracker = new AliTPCtrackerMI(fTPCGeomParam); | |
124 | ||
125 | // AliESDEvent event needed by AliTPCtrackerMI | |
126 | // output of the component | |
127 | fESD = new AliESDEvent(); | |
128 | if (fESD) { | |
129 | fESD->CreateStdContent(); | |
130 | } | |
131 | ||
132 | if (!fTracker || !fESD || !fTPCGeomParam) { | |
133 | HLTError("failed creating internal objects"); | |
134 | iResult=-ENOMEM; | |
135 | } | |
136 | ||
1ac82ce6 | 137 | return iResult; |
138 | } | |
139 | ||
140 | int AliHLTTPCOfflineTrackerComponent::DoDeinit() | |
141 | { | |
aa40a4a1 | 142 | // deinit configuration |
143 | ||
144 | if(fTPCGeomParam) delete fTPCGeomParam; fTPCGeomParam = 0; | |
145 | if(fTracker) delete fTracker; fTracker = 0; | |
146 | if(fESD) delete fESD; fESD = 0; | |
147 | ||
1ac82ce6 | 148 | return 0; |
149 | } | |
150 | ||
151 | int AliHLTTPCOfflineTrackerComponent::DoEvent( const AliHLTComponentEventData& /*evtData*/, AliHLTComponentTriggerData& /*trigData*/) | |
152 | { | |
aa40a4a1 | 153 | // tracker function |
154 | HLTInfo("DoEvent processing data"); | |
1ac82ce6 | 155 | |
aa40a4a1 | 156 | // Logging(kHLTLogDebug, "AliHLTTPCOfflineTrackerComponent::DoEvent", "Trigger data received", |
157 | // "Struct size %d Data size %d Data location 0x%x", trigData.fStructSize, trigData.fDataSize, (UInt_t*)trigData.fData); | |
158 | ||
159 | TObjArray *clusterArray = 0; | |
160 | ||
161 | int iResult=0; | |
162 | ||
163 | if (fTracker && fESD) { | |
164 | // loop over input data blocks: TObjArrays of clusters | |
165 | for (TObject *pObj = (TObject *)GetFirstInputObject(kAliHLTDataTypeTObjArray|kAliHLTDataOriginTPC/*AliHLTTPCDefinitions::fgkOfflineClustersDataType*/,"TObjArray",0); | |
166 | pObj !=0 && iResult>=0; | |
167 | pObj = (TObject *)GetNextInputObject(0)) { | |
168 | clusterArray = dynamic_cast<TObjArray*>(pObj); | |
169 | if (!clusterArray) continue; | |
170 | // int lower=clusterArray->LowerBound(); | |
171 | // int entries=clusterArray->GetEntries(); | |
172 | // if (entries<=lower) continue; | |
173 | // if (clusterArray->At(lower)==NULL) continue; | |
174 | // if (dynamic_cast<AliTPCClustersRow*>(clusterArray->At(lower))==NULL) continue; | |
175 | ||
176 | HLTInfo("load %d cluster rows from block %s 0x%08x", clusterArray->GetEntries(), DataType2Text(GetDataType(pObj)).c_str(), GetSpecification(pObj)); | |
177 | #ifndef HAVE_NOT_TPC_LOAD_CLUSTERS | |
178 | fTracker->LoadClusters(clusterArray); | |
179 | #endif //HAVE_NOT_TPC_LOAD_CLUSTERS | |
180 | }// end loop over input objects | |
181 | ||
182 | // run tracker | |
183 | fTracker->Clusters2Tracks(fESD); | |
184 | fTracker->UnloadClusters(); | |
185 | ||
186 | Int_t nTracks = fESD->GetNumberOfTracks(); | |
187 | HLTInfo("Number of tracks %d", nTracks); | |
188 | ||
189 | // TODO: calculate specification from the specification of input data blocks | |
190 | PushBack(fESD, kAliHLTDataTypeESDObject|kAliHLTDataOriginTPC, 0); | |
191 | ||
192 | // Alternatively: Push back tracks | |
193 | // for (Int_t it = 0; it < nTracks; it++) { | |
194 | // AliESDtrack* track = fESD->GetTrack(it); | |
195 | // PushBack(track, AliHLTTPCDefinitions::fgkOfflineTrackSegmentsDataType, 0); | |
196 | // } | |
197 | ||
198 | // is this necessary? If yes, we have to keep all the created TObjArrays | |
199 | // from the loop above | |
200 | // clear clusters | |
201 | //clusterArray->Clear(); | |
202 | //clusterArray->Delete(); | |
203 | ||
204 | // reset ESDs | |
205 | fESD->Reset(); | |
206 | } else { | |
207 | HLTError("component not initialized"); | |
208 | iResult=-ENOMEM; | |
209 | } | |
210 | ||
211 | return iResult; | |
1ac82ce6 | 212 | } |
213 | ||
214 | int AliHLTTPCOfflineTrackerComponent::Configure(const char* arguments) | |
215 | { | |
216 | // see header file for class documentation | |
217 | int iResult=0; | |
218 | if (!arguments) return iResult; | |
219 | ||
220 | TString allArgs=arguments; | |
221 | TString argument; | |
222 | int bMissingParam=0; | |
223 | ||
224 | TObjArray* pTokens=allArgs.Tokenize(" "); | |
225 | if (pTokens) { | |
226 | for (int i=0; i<pTokens->GetEntries() && iResult>=0; i++) { | |
227 | argument=((TObjString*)pTokens->At(i))->GetString(); | |
228 | if (argument.IsNull()) continue; | |
229 | ||
230 | if (argument.CompareTo("-something")==0) { | |
231 | if ((bMissingParam=(++i>=pTokens->GetEntries()))) break; | |
232 | ||
233 | } else { | |
234 | HLTError("unknown argument %s", argument.Data()); | |
235 | iResult=-EINVAL; | |
236 | break; | |
237 | } | |
238 | } | |
239 | delete pTokens; | |
240 | } | |
241 | if (bMissingParam) { | |
242 | HLTError("missing parameter for argument %s", argument.Data()); | |
243 | iResult=-EINVAL; | |
244 | } | |
245 | return iResult; | |
246 | } | |
247 | ||
248 | int AliHLTTPCOfflineTrackerComponent::Reconfigure(const char* /*cdbEntry*/, const char* /*chainId*/) | |
249 | { | |
250 | // see header file for class documentation | |
251 | int iResult=0; | |
252 | return iResult; | |
253 | } |