]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/global/AliHLTGlobalFlatEsdConverterComponent.cxx
give fileName of friengs to FlatESDConverter
[u/mrichter/AliRoot.git] / HLT / global / AliHLTGlobalFlatEsdConverterComponent.cxx
CommitLineData
251a2c81 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//* for The ALICE HLT Project. *
9//* *
10//* Permission to use, copy, modify and distribute this software and its *
11//* documentation strictly for non-commercial purposes is hereby granted *
12//* without fee, provided that the above copyright notice appears in all *
13//* copies and that both the copyright notice and this permission notice *
14//* appear in the supporting documentation. The authors make no claims *
15//* about the suitability of this software for any purpose. It is *
16//* provided "as is" without express or implied warranty. *
17//**************************************************************************
18
19// @file AliHLTGlobalFlatEsdConverterComponent.cxx
20// @author Matthias Richter
21// @date
22// @brief Global ESD converter component.
23//
24
25// see header file for class documentation
26// or
27// refer to README to build package
28// or
29// visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
30
31#include <cassert>
32#include "AliHLTGlobalFlatEsdConverterComponent.h"
33#include "AliFlatESDEvent.h"
34#include "AliFlatESDTrack.h"
35#include "AliFlatExternalTrackParam.h"
36#include "AliExternalTrackParam.h"
37
38#include "AliHLTGlobalBarrelTrack.h"
39#include "AliHLTExternalTrackParam.h"
40#include "AliHLTTrackMCLabel.h"
41#include "AliHLTCTPData.h"
42#include "AliHLTErrorGuard.h"
43#include "AliESDEvent.h"
44#include "AliESDtrack.h"
45#include "AliESDMuonTrack.h"
46#include "AliESDMuonCluster.h"
47#include "AliCDBEntry.h"
48#include "AliCDBManager.h"
49#include "AliPID.h"
50#include "TTree.h"
51#include "TList.h"
52#include "TClonesArray.h"
53//#include "AliHLTESDCaloClusterMaker.h"
54//#include "AliHLTCaloClusterDataStruct.h"
55//#include "AliHLTCaloClusterReader.h"
56//#include "AliESDCaloCluster.h"
57//#include "AliESDVZERO.h"
58#include "AliHLTGlobalVertexerComponent.h"
59#include "AliHLTVertexFinderBase.h"
60#include "AliHLTTPCSpacePointData.h"
61#include "AliHLTTPCClusterDataFormat.h"
62#include "AliHLTTPCDefinitions.h"
63#include "AliHLTTPCClusterMCData.h"
64#include "AliHLTTPCTransform.h"
65
66/** ROOT macro for the implementation of ROOT specific class methods */
67ClassImp(AliHLTGlobalFlatEsdConverterComponent)
68
69AliHLTGlobalFlatEsdConverterComponent::AliHLTGlobalFlatEsdConverterComponent()
70 : AliHLTProcessor()
71 , fWriteClusters(0)
72 , fVerbosity(0)
73 , fSolenoidBz(-5.00668)
74 , fBenchmark("FlatEsdConverter")
45ab7544 75 , fBenchmarkHistosFilename("$HERAFOLDER/flatDev/rawToFlat/histosBenchmark.root")
251a2c81 76{
77 // see header file for class documentation
78 // or
79 // refer to README to build package
80 // or
81 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
82}
83
84AliHLTGlobalFlatEsdConverterComponent::~AliHLTGlobalFlatEsdConverterComponent()
85{
86 // see header file for class documentation
87}
88
89int AliHLTGlobalFlatEsdConverterComponent::Configure(const char* arguments)
90{
91 // see header file for class documentation
92 int iResult=0;
93 if (!arguments) return iResult;
94
95 TString allArgs=arguments;
96 TString argument;
97 int bMissingParam=0;
98
99 TObjArray* pTokens=allArgs.Tokenize(" ");
100 if (pTokens) {
101 for (int i=0; i<pTokens->GetEntries() && iResult>=0; i++) {
102 argument=((TObjString*)pTokens->At(i))->String();
103 if (argument.IsNull()) continue;
104 HLTError("unknown argument %s", argument.Data());
105 iResult=-EINVAL;
106 break;
107 }
108 delete pTokens;
109 }
110 if (bMissingParam) {
111 HLTError("missing parameter for argument %s", argument.Data());
112 iResult=-EINVAL;
113 }
114
115 return iResult;
116}
117
118int AliHLTGlobalFlatEsdConverterComponent::Reconfigure(const char* cdbEntry, const char* chainId)
119{
120 // see header file for class documentation
121 int iResult=0;
122 const char* path=NULL;
123 const char* defaultNotify="";
124 if (cdbEntry) {
125 path=cdbEntry;
126 defaultNotify=" (default)";
127 }
128 if (path) {
129 HLTInfo("reconfigure from entry %s%s, chain id %s", path, defaultNotify,(chainId!=NULL && chainId[0]!=0)?chainId:"<none>");
130 AliCDBEntry *pEntry = AliCDBManager::Instance()->Get(path/*,GetRunNo()*/);
131 if (pEntry) {
132 TObjString* pString=dynamic_cast<TObjString*>(pEntry->GetObject());
133 if (pString) {
134 HLTInfo("received configuration object string: \'%s\'", pString->String().Data());
135 iResult=Configure(pString->String().Data());
136 } else {
137 HLTError("configuration object \"%s\" has wrong type, required TObjString", path);
138 }
139 } else {
140 HLTError("can not fetch object \"%s\" from CDB", path);
141 }
142 }
143
144 return iResult;
145}
146
147void AliHLTGlobalFlatEsdConverterComponent::GetInputDataTypes(AliHLTComponentDataTypeList& list)
148{
149 // see header file for class documentation
150 list.push_back(kAliHLTDataTypeTrack);
151 list.push_back(kAliHLTDataTypeTrackMC);
152 list.push_back(kAliHLTDataTypeCaloCluster);
153 list.push_back(kAliHLTDataTypedEdx );
154 list.push_back(kAliHLTDataTypeESDVertex );
155 list.push_back(kAliHLTDataTypeESDObject);
156 list.push_back(kAliHLTDataTypeTObject);
157 list.push_back(kAliHLTDataTypeGlobalVertexer);
158 list.push_back(kAliHLTDataTypeV0Finder); // array of track ids for V0s
159 list.push_back(kAliHLTDataTypeKFVertex); // KFVertex object from vertexer
160 list.push_back(kAliHLTDataTypePrimaryFinder); // array of track ids for prim vertex
161 list.push_back(kAliHLTDataTypeESDContent);
162 list.push_back(AliHLTTPCDefinitions::fgkClustersDataType| kAliHLTDataOriginTPC);
163 list.push_back(AliHLTTPCDefinitions::fgkAliHLTDataTypeClusterMCInfo| kAliHLTDataOriginTPC);
164}
165
166AliHLTComponentDataType AliHLTGlobalFlatEsdConverterComponent::GetOutputDataType()
167{
168 // see header file for class documentation
169 return kAliHLTDataTypeFlatESD|kAliHLTDataOriginOut;
170}
171
172void AliHLTGlobalFlatEsdConverterComponent::GetOutputDataSize(unsigned long& constBase, double& inputMultiplier)
173{
174 // see header file for class documentation
175 constBase=2000000;
176 inputMultiplier=10.0;
177}
178
179int AliHLTGlobalFlatEsdConverterComponent::DoInit(int argc, const char** argv)
180{
181 // see header file for class documentation
182 int iResult=0;
183 TString argument="";
184 int bMissingParam=0;
185
186 // default list of skiped ESD objects
187 TString skipObjects=
188 // "AliESDRun,"
189 // "AliESDHeader,"
190 // "AliESDZDC,"
191 "AliESDFMD,"
192 // "AliESDVZERO,"
193 // "AliESDTZERO,"
194 // "TPCVertex,"
195 // "SPDVertex,"
196 // "PrimaryVertex,"
197 // "AliMultiplicity,"
198 // "PHOSTrigger,"
199 // "EMCALTrigger,"
200 // "SPDPileupVertices,"
201 // "TrkPileupVertices,"
202 "Cascades,"
203 "Kinks,"
204 "AliRawDataErrorLogs,"
205 "AliESDACORDE";
206
207 iResult=Reconfigure(NULL, NULL);
208 TString allArgs = "";
209 for ( int i = 0; i < argc; i++ ) {
210 if ( !allArgs.IsNull() ) allArgs += " ";
211 allArgs += argv[i];
212 }
213
214 TObjArray* pTokens=allArgs.Tokenize(" ");
215 if (pTokens) {
216 for (int i=0; i<pTokens->GetEntries() && iResult>=0; i++) {
217 argument=((TObjString*)pTokens->At(i))->String();
218 if (argument.IsNull()) continue;
219
220 // -noclusters
221 if (argument.CompareTo("-noclusters")==0) {
222 fWriteClusters=0;
223 // -clusters
224 } else if (argument.CompareTo("-clusters")==0) {
225 fWriteClusters=1;
226 } else if (argument.Contains("-skipobject=")) {
227 argument.ReplaceAll("-skipobject=", "");
228 skipObjects=argument;
229 } else {
230 HLTError("unknown argument %s", argument.Data());
231 iResult=-EINVAL;
232 break;
233 }
234 }
235 }
236 if (bMissingParam) {
237 HLTError("missing parameter for argument %s", argument.Data());
238 iResult=-EINVAL;
239 }
240
241 fSolenoidBz=GetBz();
242
243 if (iResult>=0) {
244 SetupCTPData();
245 }
246
247 fBenchmark.SetTimer(0,"total");
248
249 return iResult;
250}
251
252int AliHLTGlobalFlatEsdConverterComponent::DoDeinit()
253{
254 // see header file for class documentation
255
256 return 0;
257}
258
27595dcc 259int AliHLTGlobalFlatEsdConverterComponent::DoEvent( const AliHLTComponentEventData& /*evtData*/,
260 const AliHLTComponentBlockData* /*blocks*/,
261 AliHLTComponentTriggerData& /*trigData*/,
251a2c81 262 AliHLTUInt8_t* outputPtr,
263 AliHLTUInt32_t& size,
eb70c0fb 264 AliHLTComponentBlockDataList& outputBlocks)
251a2c81 265{
266 // see header file for class documentation
267 int iResult=0;
eb70c0fb 268 bool benchmark = true;
251a2c81 269
270 if (!IsDataEvent()) return iResult;
271
eb70c0fb 272
273 fBenchmark.Reset();
251a2c81 274 fBenchmark.StartNewEvent();
275 fBenchmark.Start(0);
276
277 size_t maxOutputSize = size;
278 size = 0;
279
280 AliFlatESDEvent *flatEsd = reinterpret_cast<AliFlatESDEvent*>(outputPtr);
281 new (flatEsd) AliFlatESDEvent;
282
283 /*
284 pESD->Reset();
285 pESD->SetMagneticField(fSolenoidBz);
286 pESD->SetRunNumber(GetRunNo());
287 pESD->SetPeriodNumber(GetPeriodNumber());
288 pESD->SetOrbitNumber(GetOrbitNumber());
289 pESD->SetBunchCrossNumber(GetBunchCrossNumber());
290 pESD->SetTimeStamp(GetTimeStamp());
291
292 const AliHLTCTPData* pCTPData=CTPData();
293 if (pCTPData) {
294 AliHLTUInt64_t mask=pCTPData->ActiveTriggers(trigData);
295 for (int index=0; index<gkNCTPTriggerClasses; index++) {
296 if ((mask&((AliHLTUInt64_t)0x1<<index)) == 0) continue;
297 pESD->SetTriggerClass(pCTPData->Name(index), index);
298 }
299 pESD->SetTriggerMask(mask);
300 }
301 */
302
303 // Barrel tracking
304 // tracks are based on the TPC tracks, and only updated from the ITS information
305 // Sequence:
306 // 1) extract MC information for TPC and ITS from specific data blocks and store in
307 // intermediate vector arrays
308 // 2) extract TPC tracks, update with MC labels if available, the track parameters
309 // are estimated at the first cluster position
310 // 2.1) propagate to last cluster position and update kTPCout, sets also outer param (fOp)
311 // 2.2) update kTPCin, sets also inner param (fIp) and TPC inner param (fTPCInner)
312 // 2.3) update kTPCrefit using the same parameters at the first cluster position
313 // HLT has strictly spoking no refit, but we want the flag to be set
314 // can be changed to be done after all the individual barrel detector parameters
315 // have been updated by looping over the tracks again
316 // 3) extract ITS tracks, the tracks are actually TPC tracks updated from the ITS
317 // tracking information
318 // 3.1) TODO 2010-07-12: handle ITS standalone tracks by updating kITSout before kITSin
319 // 3.2) update with kITSin
320 // TODO 2010-07-12 find out if the kITSrefit has to be set as well
321 // 4) extract TRD tracks and add to ESD
322 // TODO 2010-07-12 at the moment there is no matching or merging of TPC and TRD tracks
323 // 5) Add Trigger Detectors
324 // VZERO, ZDC
325
326 // 1) first read MC information (if present)
327
328 std::map<int,int> mcLabelsTPC;
329 std::map<int,int> mcLabelsITS;
330
331 for (const AliHLTComponentBlockData* pBlock=GetFirstInputBlock(kAliHLTDataTypeTrackMC|kAliHLTDataOriginTPC);
332 pBlock!=NULL; pBlock=GetNextInputBlock()) {
333 fBenchmark.AddInput(pBlock->fSize);
334 AliHLTTrackMCData* dataPtr = reinterpret_cast<AliHLTTrackMCData*>( pBlock->fPtr );
335 if (sizeof(AliHLTTrackMCData)+dataPtr->fCount*sizeof(AliHLTTrackMCLabel)==pBlock->fSize) {
336 for( unsigned int il=0; il<dataPtr->fCount; il++ ){
337 AliHLTTrackMCLabel &lab = dataPtr->fLabels[il];
338 mcLabelsTPC[lab.fTrackID] = lab.fMCLabel;
339 }
340 } else {
341 HLTWarning("data mismatch in block %s (0x%08x): count %d, size %d -> ignoring track MC information",
342 DataType2Text(pBlock->fDataType).c_str(), pBlock->fSpecification,
343 dataPtr->fCount, pBlock->fSize);
344 }
345 }
346
347 for (const AliHLTComponentBlockData* pBlock=GetFirstInputBlock(kAliHLTDataTypeTrackMC|kAliHLTDataOriginITS);
348 pBlock!=NULL; pBlock=GetNextInputBlock()) {
349 fBenchmark.AddInput(pBlock->fSize);
350 AliHLTTrackMCData* dataPtr = reinterpret_cast<AliHLTTrackMCData*>( pBlock->fPtr );
351 if (sizeof(AliHLTTrackMCData)+dataPtr->fCount*sizeof(AliHLTTrackMCLabel)==pBlock->fSize) {
352 for( unsigned int il=0; il<dataPtr->fCount; il++ ){
353 AliHLTTrackMCLabel &lab = dataPtr->fLabels[il];
354 mcLabelsITS[lab.fTrackID] = lab.fMCLabel;
355 }
356 } else {
357 HLTWarning("data mismatch in block %s (0x%08x): count %d, size %d -> ignoring track MC information",
358 DataType2Text(pBlock->fDataType).c_str(), pBlock->fSpecification,
359 dataPtr->fCount, pBlock->fSize);
360 }
361 }
362
363 // 2) read dEdx information (if present)
364
365 AliHLTFloat32_t *dEdxTPC = 0;
366 Int_t ndEdxTPC = 0;
367 for (const AliHLTComponentBlockData* pBlock=GetFirstInputBlock(kAliHLTDataTypedEdx|kAliHLTDataOriginTPC);
368 pBlock!=NULL; pBlock=NULL/*GetNextInputBlock() there is only one block*/) {
369 fBenchmark.AddInput(pBlock->fSize);
370 dEdxTPC = reinterpret_cast<AliHLTFloat32_t*>( pBlock->fPtr );
371 ndEdxTPC = pBlock->fSize / (3*sizeof(AliHLTFloat32_t));
372 }
373
374 // 3) read TPC tracks
375
376 vector<AliHLTGlobalBarrelTrack> tracksTPC;
377
378 { // there is only one block of TPC data expected
379 const AliHLTComponentBlockData* pBlock=GetFirstInputBlock(kAliHLTDataTypeTrack|kAliHLTDataOriginTPC);
380 if( pBlock ){
381 fBenchmark.AddInput(pBlock->fSize);
382 iResult=AliHLTGlobalBarrelTrack::ConvertTrackDataArray(reinterpret_cast<const AliHLTTracksData*>(pBlock->fPtr), pBlock->fSize, tracksTPC);
383 }
384 if( iResult>=0 ){
385 HLTWarning("converted %d track(s) to AliESDtrack and added to ESD", tracksTPC.size());
386 } else if (iResult<0) {
387 HLTError("can not extract tracks from data block of type %s (specification %08x) of size %d: error %d",
388 DataType2Text(pBlock->fDataType).c_str(), pBlock->fSpecification, pBlock->fSize, iResult);
389 }
390 }
391
392 // 4) read ITS refitted tracks
393
394 vector<AliHLTGlobalBarrelTrack> tracksITS;
395 vector<AliHLTGlobalBarrelTrack> tracksITSOut;
396
397 if( iResult>=0 ) { // there is only one block of ITS tracks expected
398 const AliHLTComponentBlockData* pBlock=GetFirstInputBlock(kAliHLTDataTypeTrack|kAliHLTDataOriginITS);
399 if( pBlock ){
400 fBenchmark.AddInput(pBlock->fSize);
401 iResult=AliHLTGlobalBarrelTrack::ConvertTrackDataArray(reinterpret_cast<const AliHLTTracksData*>(pBlock->fPtr), pBlock->fSize, tracksITS);
402 }
403 }
404
405 if( iResult>=0 ) { // there is only one block of ITS tracks expected
406 const AliHLTComponentBlockData* pBlock=GetFirstInputBlock(kAliHLTDataTypeTrack|kAliHLTDataOriginITSOut);
407 if( pBlock ){
408 fBenchmark.AddInput(pBlock->fSize);
409 iResult=AliHLTGlobalBarrelTrack::ConvertTrackDataArray(reinterpret_cast<const AliHLTTracksData*>(pBlock->fPtr), pBlock->fSize, tracksITS);
410 }
411 }
412
413
414 // read TPC clusters
27595dcc 415 const UInt_t kNSlices = 36;
416 const UInt_t kNPatches = 6;
251a2c81 417
418 const AliHLTTPCClusterData *clustersTPC[kNSlices][kNPatches];
419 const AliHLTTPCClusterMCLabel *clustersTPCMC[kNSlices][kNPatches];
27595dcc 420 for( UInt_t i=0; i<kNSlices; i++){
421 for( UInt_t j=0; j<kNPatches; j++){
251a2c81 422 clustersTPC[i][j] = 0;
423 clustersTPCMC[i][j] =0;
424 }
425 }
426
427 fWriteClusters = 1;
428
429 if( fWriteClusters ){
430
431 for (const AliHLTComponentBlockData* pBlock=GetFirstInputBlock(AliHLTTPCDefinitions::fgkClustersDataType| kAliHLTDataOriginTPC);
432 pBlock!=NULL; pBlock=GetNextInputBlock()) {
433 //fBenchmark.AddInput(pBlock->fSize);
434 UInt_t slice = AliHLTTPCDefinitions::GetMinSliceNr(*pBlock);
435 UInt_t patch = AliHLTTPCDefinitions::GetMinPatchNr(*pBlock);
436 if( slice >= kNSlices || patch>= kNPatches ){
437 HLTWarning("Wrong slice / patch number of cluster block");
438 continue;
439 }
440 clustersTPC[slice][patch] = reinterpret_cast <const AliHLTTPCClusterData*> ( pBlock->fPtr );
441 }
442
443 for (const AliHLTComponentBlockData* pBlock=GetFirstInputBlock(AliHLTTPCDefinitions::fgkAliHLTDataTypeClusterMCInfo| kAliHLTDataOriginTPC);
444 pBlock!=NULL; pBlock=GetNextInputBlock()) {
445 //fBenchmark.AddInput(pBlock->fSize);
446 UInt_t slice = AliHLTTPCDefinitions::GetMinSliceNr(*pBlock);
447 UInt_t patch = AliHLTTPCDefinitions::GetMinPatchNr(*pBlock);
448 if( slice >= kNSlices || patch>= kNPatches ){
449 HLTWarning("Wrong slice / patch number of cluster MC block");
450 continue;
451 }
452 clustersTPCMC[slice][patch] = reinterpret_cast <const AliHLTTPCClusterMCLabel*> ( pBlock->fPtr );
453 }
454
455 }
456
457 // Fill vertex information to the flat ESD
458
459 const AliESDVertex *primaryVertex = 0;
460 {
461 const AliESDVertex *primaryVertexSPD = dynamic_cast<const AliESDVertex*>( GetFirstInputObject( kAliHLTDataTypeESDVertex|kAliHLTDataOriginITS ) );
462 const AliESDVertex *primaryVertexTracks = dynamic_cast<const AliESDVertex*>( GetFirstInputObject( kAliHLTDataTypeESDVertex|kAliHLTDataOriginOut ) );
463
464 cout<<endl<<" Primary vertex Tracks: "<<primaryVertexTracks<<", SPD: "<< primaryVertexSPD <<endl<<endl;
465
466 flatEsd->FillPrimaryVertices( primaryVertexSPD, primaryVertexTracks );
467
468 primaryVertex = primaryVertexTracks;
469 if( !primaryVertex ) primaryVertex = primaryVertexSPD;
470 }
471
472 // Fill the track information to the flat ESD structure
473 {
474 UInt_t itsIter = 0;
475 UInt_t itsOutIter = 0;
476 for( UInt_t tpcIter=0; tpcIter < tracksTPC.size(); tpcIter++) {
477
478 const AliHLTGlobalBarrelTrack *tpcTrack = &(tracksTPC[tpcIter]);
479 /*
480 Float_t points[4] = {
481 static_cast<Float_t>(tpcTrack->GetX()),
482 static_cast<Float_t>(tpcTrack->GetY()),
483 static_cast<Float_t>(tpcTrack->GetLastPointX()),
484 static_cast<Float_t>(tpcTrack->GetLastPointY())
485 };
486 */
487 Int_t tpcLabel = -1;
488 if( mcLabelsTPC.find(tpcTrack->TrackID())!=mcLabelsTPC.end() )
489 tpcLabel = mcLabelsTPC[tpcTrack->TrackID()];
490
491 //tpcTrack->SetLabel( tpcLabel );
492 // iotrack.SetID( tpcTrack->TrackID() );
493
494 // set kTPCout - just propagate to the outermost TPC cluster
495
496 AliHLTGlobalBarrelTrack outPar(*tpcTrack);
497 {
498 //outPar.AliExternalTrackParam::PropagateTo( tpcTrack->GetLastPointX(), fSolenoidBz );
499 const Int_t N=10; // number of steps.
500 const Float_t xRange = tpcTrack->GetLastPointX() - tpcTrack->GetX();
501 const Float_t xStep = xRange / N ;
502 for(int i = 1; i <= N; ++i) {
503 if(!outPar.AliExternalTrackParam::PropagateTo(tpcTrack->GetX() + xStep * i, fSolenoidBz)) break;
504 }
505 }
506
507 //iotrack.SetTPCPoints(points);
508 /*
509 if( tpcTrack->TrackID()<ndEdxTPC ){
510 AliHLTFloat32_t *val = &(dEdxTPC[3*tpcTrack->TrackID()]);
511 iotrack.SetTPCsignal( val[0], val[1], (UChar_t) val[2] );
512 //AliTPCseed s;
513 //s.Set( tpcTrack->GetX(), tpcTrack->GetAlpha(),
514 //tpcTrack->GetParameter(), tpcTrack->GetCovariance() );
515 //s.SetdEdx( val[0] );
516 //s.CookPID();
517 //iotrack.SetTPCpid(s.TPCrPIDs() );
518 } else {
519 if( dEdxTPC ) HLTWarning("Wrong number of dEdx TPC labels");
520 }
521 */
522 //iotrack.SetLabel(mcLabel);
523
524 // ITS track
525
526 AliHLTGlobalBarrelTrack *itsRefit=0;
527 Int_t itsLabel = -1;
528
529 for(; itsIter< tracksITS.size() && tracksITS[itsIter].TrackID()<(int) tpcIter; itsIter++ );
530
531 if( itsIter< tracksITS.size() && tracksITS[itsIter].TrackID() == (int) tpcIter ){
532 itsRefit = &(tracksITS[itsIter]);
533 if( mcLabelsITS.find(tpcIter)!=mcLabelsITS.end() ) itsLabel = mcLabelsITS[tpcIter];
534 itsIter++;
535 }
536
537 // ITS Out track
538
539 AliHLTGlobalBarrelTrack *itsOut=0;
540
541 for(; itsOutIter< tracksITSOut.size() && tracksITSOut[itsOutIter].TrackID()<(int) tpcIter; itsOutIter++ );
542
543 if( itsOutIter< tracksITSOut.size() && tracksITSOut[itsOutIter].TrackID() == (int) tpcIter ){
544 itsOut = &(tracksITSOut[itsOutIter]);
545 itsOutIter++;
546 }
547
548 // Fill DCA parameters for TPC tracks
549 AliESDtrack cP;
550
551 if( primaryVertex ){
552 cP.UpdateTrackParams( (itsRefit ?itsRefit :tpcTrack), AliESDtrack::kTPCin );
553 cP.RelateToVertex( primaryVertex, fSolenoidBz, 1000 );
554 }
555
556 AliFlatESDTrack *flatTrack = flatEsd->GetNextTrackPointer();
557
558 UInt_t nClustersTPC = tpcTrack->GetNumberOfPoints();
559 UInt_t nClustersITS = itsRefit ?itsRefit->GetNumberOfPoints() :0;
560
561 flatTrack->SetNumberOfITSClusters( nClustersITS );
562
563 if( flatEsd->GetSize() + flatTrack->EstimateSize( kTRUE, nClustersTPC ) >= maxOutputSize ){
564 cout<<endl<<endl<<"NOT ENOUGH MEMORY!!!!"<<endl<<endl;
565 iResult=-ENOMEM;
566 break;
567 }
568
569 flatTrack->FillExternalTrackParam( itsRefit, NULL, tpcTrack, &outPar, cP.GetConstrainedParam(), itsOut);
570
571 if( fWriteClusters && tpcTrack->GetPoints() ){
572 const UInt_t* clusterIDs = tpcTrack->GetPoints();
573 for( UInt_t i=0; i<nClustersTPC; i++ ){
574 UInt_t id = clusterIDs[i];
575 UInt_t iSlice = AliHLTTPCSpacePointData::GetSlice(id);
576 UInt_t iPatch = AliHLTTPCSpacePointData::GetPatch(id);
577 UInt_t iCluster = AliHLTTPCSpacePointData::GetNumber(id);
578 if( iSlice >= kNSlices || iPatch>= kNPatches ){
579 HLTWarning("Wrong slice / patch number of TPC cluster");
580 continue;
581 }
582 const AliHLTTPCClusterData *clusterBlock = clustersTPC[iSlice][iPatch];
583 if( !clusterBlock ){
584 HLTWarning("no cluster block found for slice %d, patch %d",iSlice,iPatch);
585 continue;
586 }
587 if( iCluster>= clusterBlock->fSpacePointCnt ){
588 HLTWarning("no cluster block found for slice %d, patch %d, cluster %d",iSlice,iPatch,iCluster);
589 continue;
590 }
591 const AliHLTTPCSpacePointData &cIn = clusterBlock->fSpacePoints[iCluster];
592 AliFlatTPCCluster *c= flatTrack->GetNextTPCClusterPointer();
593 c->fX = cIn.GetX();
594 c->fY = cIn.GetY();
595 c->fZ = cIn.GetZ();
596 c->fPadRow = cIn.GetPadRow() + AliHLTTPCTransform::GetFirstRow(iPatch);
597 c->fSigmaY2 = cIn.GetSigmaY2();
598 c->fSigmaZ2 = cIn.GetSigmaZ2();
599 c->fCharge = cIn.GetCharge();
600 c->fQMax = cIn.GetQMax();
601 flatTrack->StoreLastTPCCluster();
602 }
603 }
604
605
606 flatEsd->StoreLastTrack();
607
608 if (fVerbosity>0) tpcTrack->Print();
609 }
610 }
611
612 // Fill v0's
613
614 {
615 int nV0s =0;
616 const AliHLTComponentBlockData* pP = GetFirstInputBlock(kAliHLTDataTypeGlobalVertexer|kAliHLTDataOriginOut);
617 if (pP && pP->fSize && pP->fPtr) {
618 const AliHLTGlobalVertexerComponent::AliHLTGlobalVertexerData *data = reinterpret_cast<AliHLTGlobalVertexerComponent::AliHLTGlobalVertexerData*>(pP->fPtr);
619 const int* v0s = data->fTrackIndices + data->fNPrimTracks;
620 nV0s = data->fNV0s;
621 for (int i = 0; i < nV0s; ++i) {
622 AliFlatESDV0 *v0 = flatEsd->GetNextV0Pointer();
623 v0->fNegTrackID = v0s[2 * i];
624 v0->fPosTrackID = v0s[2 * i + 1];
625 flatEsd->StoreLastV0();
626 }
627 } else {
628 HLTWarning("xxx No V0 data block");
629 }
630 cout<<"\nxxxx Found "<<nV0s<<" V0's\n"<<endl;
631 }
632
633 // Get ITS SPD vertex
634 for( const AliHLTComponentBlockData *i= GetFirstInputBlock(kAliHLTDataTypeESDVertex|kAliHLTDataOriginITS); i!=NULL; i=GetNextInputBlock() ){
635 fBenchmark.AddInput(i->fSize);
636 }
637
638 /*
639 for ( const TObject *iter = GetFirstInputObject(kAliHLTDataTypeESDVertex|kAliHLTDataOriginITS); iter != NULL; iter = GetNextInputObject() ) {
640 AliESDVertex *vtx = dynamic_cast<AliESDVertex*>(const_cast<TObject*>( iter ) );
641 pESD->SetPrimaryVertexSPD( vtx );
642 }
643
644
645 // update with vertices and vertex-fitted tracks
646 // output of the GlobalVertexerComponent
647 for (const AliHLTComponentBlockData* pBlock=GetFirstInputBlock(kAliHLTDataTypeGlobalVertexer);
648 pBlock!=NULL; pBlock=GetNextInputBlock()) {
649 fBenchmark.AddInput(pBlock->fSize);
650 AliHLTGlobalVertexerComponent::FillESD( pESD, reinterpret_cast<AliHLTGlobalVertexerComponent::AliHLTGlobalVertexerData* >(pBlock->fPtr) );
651 }
652
653 // update with vertices and vertex-fitted tracks
654 // output of PrimaryVertexer and V0Finder components
655 TObject* pBase = (TObject*)GetFirstInputObject(kAliHLTDataTypeKFVertex | kAliHLTDataOriginOut);
656 if (pBase) {
657 AliKFVertex* kfVertex = dynamic_cast<AliKFVertex *>(pBase);
658 if (kfVertex) {
659 const AliHLTComponentBlockData* pP = GetFirstInputBlock(kAliHLTDataTypePrimaryFinder | kAliHLTDataOriginOut);
660 if (pP && pP->fSize && pP->fPtr) {
661 const AliHLTComponentBlockData* pV0 = GetFirstInputBlock(kAliHLTDataTypeV0Finder | kAliHLTDataOriginOut);
662 if (pV0 && pV0->fPtr && pInputESD && pInputESD->GetNumberOfV0s()>0) {
663 const int* v0s = static_cast<const int*>(pV0->fPtr);
664 HLTWarning("V0 array already filled from the input esd block, additional filling from V0 block of %d entries might cause inconsistent content", v0s[0]);
665 }
666 AliHLTVertexFinderBase::FillESD(pESD, kfVertex, pP->fPtr, pV0?pV0->fPtr:NULL);
667 } else
668 HLTWarning("Problem with primary finder's data block");
669 } else {
670 HLTWarning("primary vertex block of wrong type, expecting AliKFVertex instead of %s", pBase->GetName());
671 }
672 } else {
673 // throw an error if there is a V0 data block which can not be handled without
674 // the AliKFVertex object
675 if (GetFirstInputBlock(kAliHLTDataTypeV0Finder | kAliHLTDataOriginOut)!=NULL) {
676 ALIHLTERRORGUARD(1, "missing AliKFVertex object ignoring V0 data block of type %s",
677 DataType2Text(kAliHLTDataTypeV0Finder|kAliHLTDataOriginOut).c_str());
678 }
679 }
680 */
681
682
683 // loop over all tracks and set the TPC refit flag by updating with the
684 // original TPC inner parameter if not yet set
685 // TODO: replace this by a proper refit
686 // code is comented for the moment as it does not fully solve the problems with
687 // the display
688 // - would set the main parameters to the TPC inner wall again, or
689 // - changes the inner param if the parameters are propagated, so we loose the track
690 // reference point for the display
691 // with the current sequence we have the latter case as the DCA operations above
692 // change the TPC inner parameters
693 /*
694 for (int i=0; i<pESD->GetNumberOfTracks(); i++) {
695 if (!pESD->GetTrack(i) ||
696 !pESD->GetTrack(i)->GetTPCInnerParam() ||
697 pESD->GetTrack(i)->IsOn(AliESDtrack::kTPCrefit)) continue;
698 AliESDtrack* tESD=pESD->GetTrack(i);
699 AliHLTGlobalBarrelTrack inner(*tESD->GetTPCInnerParam());
700 inner.SetLabel(tESD->GetLabel());
701 tESD->UpdateTrackParams(&inner, AliESDtrack::kTPCrefit);
702 }
703 */
704
705 if (iResult>=0) {
706
707 AliHLTComponentBlockData outBlock;
708 FillBlockData( outBlock );
709 outBlock.fOffset = size;
710 outBlock.fSize = flatEsd->GetSize();
711 outBlock.fDataType = kAliHLTDataTypeFlatESD|kAliHLTDataOriginOut;
712 outBlock.fSpecification = AliHLTTPCDefinitions::EncodeDataSpecification( 0, 35, 0, 5 );
713
714 outputBlocks.push_back( outBlock );
715
716 fBenchmark.AddOutput(outBlock.fSize);
717
718 size += outBlock.fSize;
719 }
720
721 fBenchmark.Stop(0);
722 HLTWarning( fBenchmark.GetStatistics() );
eb70c0fb 723
724
725
726
727 if(benchmark){
728
729 Double_t* statistics=0x0;
730 TString* names=0x0;
731 fBenchmark.GetStatisticsData(statistics, names);
732 FillBenchmarkHistos( statistics, names);
733
734 }
251a2c81 735 return iResult;
736}
737
eb70c0fb 738
45ab7544 739void AliHLTGlobalFlatEsdConverterComponent::FillBenchmarkHistos(Double_t *statistics, TString */*names*/){
eb70c0fb 740
741
45ab7544 742 TString outputFilename = fBenchmarkHistosFilename; ;
eb70c0fb 743 TH2F* hCpuTimeVsSize;
744 TH2F* hRealTimeVsSize;
45ab7544 745
eb70c0fb 746
747
748 TFile *outFile = TFile::Open(outputFilename,"UPDATE");
749 hCpuTimeVsSize = (TH2F*)outFile->Get("cpuTimeVsSize");
750 hRealTimeVsSize = (TH2F*)outFile->Get("realTimeVsSize");
751
752 if(!hCpuTimeVsSize || !hRealTimeVsSize){
45ab7544 753 HLTWarning( "Benchmark Histograms not available!" );
754 return;
eb70c0fb 755 }
756
757
758 Double_t realTimePerEvent = statistics[5];
759 Double_t cpuTimePerEvent = statistics[5];
760 Double_t sizePerEvent = statistics[1];
761
762 hCpuTimeVsSize->Fill(sizePerEvent, cpuTimePerEvent);
763 hRealTimeVsSize->Fill(sizePerEvent, realTimePerEvent);
764
45ab7544 765 TList histosList;
766 histosList.Add(hCpuTimeVsSize);
767 histosList.Add(hRealTimeVsSize);
eb70c0fb 768
45ab7544 769 histosList.SaveAs(outputFilename);
eb70c0fb 770
771}