Make SetChi2 method public
[u/mrichter/AliRoot.git] / HLT / global / AliHLTGlobalEsdConverterComponent.cxx
CommitLineData
a1408c4b 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
a0b62fd1 19// @file AliHLTGlobalEsdConverterComponent.cxx
20// @author Matthias Richter
21// @date
22// @brief Global ESD converter component.
23//
a1408c4b 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 "AliHLTGlobalEsdConverterComponent.h"
33#include "AliHLTGlobalBarrelTrack.h"
34#include "AliHLTExternalTrackParam.h"
093b64dc 35#include "AliHLTTrackMCLabel.h"
6117ef63 36#include "AliHLTCTPData.h"
2352edc3 37#include "AliHLTTPCDefinitions.h"
38#include "AliHLTTPCSpacePointData.h"
39#include "AliHLTTPCClusterDataFormat.h"
40#include "AliTPCclusterMI.h"
41#include "AliTPCseed.h"
42#include "AliESDfriend.h"
43#include "AliESDfriendTrack.h"
44#include "AliHLTTPCTransform.h"
331d51c5 45#include "AliHLTErrorGuard.h"
a1408c4b 46#include "AliESDEvent.h"
47#include "AliESDtrack.h"
f064ef44 48#include "AliESDMuonTrack.h"
fe0324de 49#include "AliESDMuonCluster.h"
a1408c4b 50#include "AliCDBEntry.h"
51#include "AliCDBManager.h"
18ada816 52#include "AliPID.h"
a1408c4b 53#include "TTree.h"
54#include "TList.h"
f064ef44 55#include "TClonesArray.h"
f9ce172e 56#include "TTimeStamp.h"
57#include "THnSparse.h"
9a9467ed 58#include "AliHLTESDCaloClusterMaker.h"
59#include "AliHLTCaloClusterDataStruct.h"
60#include "AliHLTCaloClusterReader.h"
61#include "AliESDCaloCluster.h"
331d51c5 62#include "AliESDVZERO.h"
d9386025 63#include "AliHLTGlobalVertexerComponent.h"
b7449dbe 64#include "AliHLTVertexFinderBase.h"
3ccabd94 65#include "AliSysInfo.h"
a1408c4b 66
67/** ROOT macro for the implementation of ROOT specific class methods */
68ClassImp(AliHLTGlobalEsdConverterComponent)
69
70AliHLTGlobalEsdConverterComponent::AliHLTGlobalEsdConverterComponent()
71 : AliHLTProcessor()
a1408c4b 72 , fWriteTree(0)
093b64dc 73 , fVerbosity(0)
8b7a0f3c 74 , fESD(NULL)
accd913d 75 , fESDfriend(NULL)
a8714ffa 76 , fSolenoidBz(-5.00668)
2352edc3 77 , fMakeFriends(1)
57a4102f 78 , fBenchmark("EsdConverter")
a1408c4b 79{
80 // see header file for class documentation
81 // or
82 // refer to README to build package
83 // or
84 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
2352edc3 85 for( int i=0; i<fkNPartition; i++ ){
86 fPartitionClusters[i] = 0;
87 fNPartitionClusters[i] = 0;
88 }
a1408c4b 89}
90
91AliHLTGlobalEsdConverterComponent::~AliHLTGlobalEsdConverterComponent()
92{
93 // see header file for class documentation
accd913d 94 delete fESD;
95 delete fESDfriend;
2352edc3 96 for( int i=0; i<fkNPartition; i++ ){
accd913d 97 delete[] fPartitionClusters[i];
2352edc3 98 }
a1408c4b 99}
100
101int AliHLTGlobalEsdConverterComponent::Configure(const char* arguments)
102{
103 // see header file for class documentation
104 int iResult=0;
105 if (!arguments) return iResult;
106
107 TString allArgs=arguments;
108 TString argument;
109 int bMissingParam=0;
110
111 TObjArray* pTokens=allArgs.Tokenize(" ");
112 if (pTokens) {
113 for (int i=0; i<pTokens->GetEntries() && iResult>=0; i++) {
d7d775b6 114 argument=((TObjString*)pTokens->At(i))->String();
a1408c4b 115 if (argument.IsNull()) continue;
116
117 if (argument.CompareTo("-solenoidBz")==0) {
118 if ((bMissingParam=(++i>=pTokens->GetEntries()))) break;
75970b8d 119 HLTWarning("argument -solenoidBz is deprecated, magnetic field set up globally (%f)", GetBz());
a1408c4b 120 continue;
121 } else {
122 HLTError("unknown argument %s", argument.Data());
123 iResult=-EINVAL;
124 break;
125 }
126 }
127 delete pTokens;
128 }
129 if (bMissingParam) {
130 HLTError("missing parameter for argument %s", argument.Data());
131 iResult=-EINVAL;
132 }
133
134 return iResult;
135}
136
137int AliHLTGlobalEsdConverterComponent::Reconfigure(const char* cdbEntry, const char* chainId)
138{
139 // see header file for class documentation
140 int iResult=0;
75970b8d 141 const char* path=NULL;
a1408c4b 142 const char* defaultNotify="";
143 if (cdbEntry) {
144 path=cdbEntry;
145 defaultNotify=" (default)";
146 }
147 if (path) {
148 HLTInfo("reconfigure from entry %s%s, chain id %s", path, defaultNotify,(chainId!=NULL && chainId[0]!=0)?chainId:"<none>");
149 AliCDBEntry *pEntry = AliCDBManager::Instance()->Get(path/*,GetRunNo()*/);
150 if (pEntry) {
151 TObjString* pString=dynamic_cast<TObjString*>(pEntry->GetObject());
152 if (pString) {
d7d775b6 153 HLTInfo("received configuration object string: \'%s\'", pString->String().Data());
154 iResult=Configure(pString->String().Data());
a1408c4b 155 } else {
156 HLTError("configuration object \"%s\" has wrong type, required TObjString", path);
157 }
158 } else {
159 HLTError("can not fetch object \"%s\" from CDB", path);
160 }
161 }
162
163 return iResult;
164}
165
166void AliHLTGlobalEsdConverterComponent::GetInputDataTypes(AliHLTComponentDataTypeList& list)
167{
168 // see header file for class documentation
169 list.push_back(kAliHLTDataTypeTrack);
170 list.push_back(kAliHLTDataTypeTrackMC);
9a9467ed 171 list.push_back(kAliHLTDataTypeCaloCluster);
0973c527 172 list.push_back(kAliHLTDataTypedEdx );
7f167a74 173 list.push_back(kAliHLTDataTypeESDVertex );
f064ef44 174 list.push_back(kAliHLTDataTypeESDObject);
175 list.push_back(kAliHLTDataTypeTObject);
d9963894 176 list.push_back(kAliHLTDataTypeGlobalVertexer);
b7449dbe 177 list.push_back(kAliHLTDataTypeV0Finder); // array of track ids for V0s
178 list.push_back(kAliHLTDataTypeKFVertex); // KFVertex object from vertexer
179 list.push_back(kAliHLTDataTypePrimaryFinder); // array of track ids for prim vertex
331d51c5 180 list.push_back(kAliHLTDataTypeESDContent);
2352edc3 181 list.push_back( AliHLTTPCDefinitions::fgkClustersDataType );
a1408c4b 182}
183
184AliHLTComponentDataType AliHLTGlobalEsdConverterComponent::GetOutputDataType()
185{
186 // see header file for class documentation
accd913d 187 return kAliHLTMultipleDataType;
188}
189
190int AliHLTGlobalEsdConverterComponent::GetOutputDataTypes(AliHLTComponentDataTypeList& tgtList){
191// see header file for class documentation
192
193 tgtList.clear();
194 tgtList.push_back( kAliHLTDataTypeESDObject|kAliHLTDataOriginOut );
195 tgtList.push_back( kAliHLTDataTypeESDfriendObject|kAliHLTDataOriginOut );
196 return tgtList.size();
a1408c4b 197}
198
199void AliHLTGlobalEsdConverterComponent::GetOutputDataSize(unsigned long& constBase, double& inputMultiplier)
200{
201 // see header file for class documentation
202 constBase=2000000;
203 inputMultiplier=10.0;
204}
205
206int AliHLTGlobalEsdConverterComponent::DoInit(int argc, const char** argv)
207{
208 // see header file for class documentation
209 int iResult=0;
210 TString argument="";
211 int bMissingParam=0;
a1408c4b 212
d57fc872 213 // default list of skiped ESD objects
214 TString skipObjects=
215 // "AliESDRun,"
216 // "AliESDHeader,"
421e1221 217 // "AliESDZDC,"
d57fc872 218 "AliESDFMD,"
219 // "AliESDVZERO,"
220 // "AliESDTZERO,"
221 // "TPCVertex,"
222 // "SPDVertex,"
223 // "PrimaryVertex,"
224 // "AliMultiplicity,"
225 // "PHOSTrigger,"
226 // "EMCALTrigger,"
227 // "SPDPileupVertices,"
228 // "TrkPileupVertices,"
229 "Cascades,"
230 "Kinks,"
231 "AliRawDataErrorLogs,"
232 "AliESDACORDE";
233
f167b631 234 iResult=Reconfigure(NULL, NULL);
235 TString allArgs = "";
236 for ( int i = 0; i < argc; i++ ) {
237 if ( !allArgs.IsNull() ) allArgs += " ";
238 allArgs += argv[i];
239 }
a1408c4b 240
f167b631 241 TObjArray* pTokens=allArgs.Tokenize(" ");
242 if (pTokens) {
243 for (int i=0; i<pTokens->GetEntries() && iResult>=0; i++) {
d7d775b6 244 argument=((TObjString*)pTokens->At(i))->String();
f167b631 245 if (argument.IsNull()) continue;
246
247 // -notree
248 if (argument.CompareTo("-notree")==0) {
249 fWriteTree=0;
250
251 // -tree
252 } else if (argument.CompareTo("-tree")==0) {
253 fWriteTree=1;
254 } else if (argument.CompareTo("-solenoidBz")==0) {
255 if ((bMissingParam=(++i>=pTokens->GetEntries()))) break;
d7d775b6 256 HLTInfo("Magnetic Field set to: %s", ((TObjString*)pTokens->At(i))->String().Data());
d57fc872 257 HLTWarning("argument '-solenoidBz' is deprecated, solenoid field initiaized from CDB settings");
f167b631 258 continue;
d57fc872 259 } else if (argument.Contains("-skipobject=")) {
260 argument.ReplaceAll("-skipobject=", "");
261 skipObjects=argument;
f167b631 262 } else {
263 HLTError("unknown argument %s", argument.Data());
d57fc872 264 iResult=-EINVAL;
f167b631 265 break;
266 }
a1408c4b 267 }
268 }
269 if (bMissingParam) {
270 HLTError("missing parameter for argument %s", argument.Data());
271 iResult=-EINVAL;
272 }
273
75970b8d 274 fSolenoidBz=GetBz();
275
accd913d 276 delete fESD;
277 fESD = NULL;
278 delete fESDfriend;
279 fESDfriend=0;
280
a1408c4b 281 if (iResult>=0) {
a1408c4b 282 fESD = new AliESDEvent;
283 if (fESD) {
284 fESD->CreateStdContent();
d57fc872 285
286 // remove some of the objects which are not needed
287 if (fESD->GetList() && !skipObjects.IsNull()) {
288 pTokens=skipObjects.Tokenize(",");
289 if (pTokens) {
290 const char* id=NULL;
291 TIter next(pTokens);
292 TObject* pObject=NULL;
293 while ((pObject=next())!=NULL) {
d7d775b6 294 id=((TObjString*)pObject)->String().Data();
a0b62fd1 295 TObject* pObj=fESD->GetList()->FindObject(id);
296 if (pObj) {
d57fc872 297 HLTDebug("removing object %s", id);
a0b62fd1 298 fESD->GetList()->Remove(pObj);
299 delete pObj;
d57fc872 300 } else {
301 HLTWarning("failed to remove object '%s' from ESD", id);
302 }
303 }
d57fc872 304 fESD->GetStdContent();
305 delete pTokens;
306 }
307 }
a1408c4b 308 } else {
309 iResult=-ENOMEM;
310 }
6117ef63 311
312 SetupCTPData();
a1408c4b 313 }
accd913d 314
315 if( iResult>=0 && fMakeFriends ){
316 fESDfriend = new AliESDfriend();
317 }
a1408c4b 318
57a4102f 319 fBenchmark.SetTimer(0,"total");
320
a1408c4b 321 return iResult;
322}
323
324int AliHLTGlobalEsdConverterComponent::DoDeinit()
325{
326 // see header file for class documentation
accd913d 327 delete fESD;
a1408c4b 328 fESD=NULL;
accd913d 329 delete fESDfriend;
330 fESDfriend = NULL;
a1408c4b 331 return 0;
332}
333
3ccabd94 334int AliHLTGlobalEsdConverterComponent::DoEvent(const AliHLTComponentEventData& evtData,
6117ef63 335 AliHLTComponentTriggerData& trigData)
a1408c4b 336{
337 // see header file for class documentation
338 int iResult=0;
3ccabd94 339
340
accd913d 341 AliSysInfo::AddStamp("DoEvent.Start", evtData.fStructSize);
3ccabd94 342
f9ce172e 343 bool benchmark = true;
3ccabd94 344
a1408c4b 345 if (!fESD) return -ENODEV;
346
251a2c81 347 if (!IsDataEvent()) return iResult;
348 fBenchmark.StartNewEvent();
57a4102f 349 fBenchmark.Start(0);
350
2352edc3 351 for(Int_t i=0; i<fkNPartition; i++){
352 delete[] fPartitionClusters[i];
353 fPartitionClusters[i] = 0;
354 fNPartitionClusters[i] = 0;
accd913d 355 }
356
2352edc3 357 AliESDEvent* pESD = fESD;
358
a1408c4b 359 pESD->Reset();
360 pESD->SetMagneticField(fSolenoidBz);
6117ef63 361 pESD->SetRunNumber(GetRunNo());
6700298e 362 pESD->SetPeriodNumber(GetPeriodNumber());
363 pESD->SetOrbitNumber(GetOrbitNumber());
364 pESD->SetBunchCrossNumber(GetBunchCrossNumber());
365 pESD->SetTimeStamp(GetTimeStamp());
a1408c4b 366
6117ef63 367 const AliHLTCTPData* pCTPData=CTPData();
368 if (pCTPData) {
16e6f752 369 AliHLTTriggerMask_t mask=pCTPData->ActiveTriggers(trigData);
6117ef63 370 for (int index=0; index<gkNCTPTriggerClasses; index++) {
16e6f752 371 if ((mask&(AliHLTTriggerMask_t(0x1)<<index)) == 0) continue;
6117ef63 372 pESD->SetTriggerClass(pCTPData->Name(index), index);
373 }
16e6f752 374 //first 50 triggers
375 AliHLTTriggerMask_t mask50;
376 mask50.set(); // set all bits
377 mask50 >>= 50; // shift 50 right
378 pESD->SetTriggerMask((mask&mask50).to_ulong());
9eee9fe9 379 //next 50
16e6f752 380 pESD->SetTriggerMaskNext50((mask>>50).to_ulong());
6117ef63 381 }
382
a1408c4b 383 TTree* pTree = NULL;
384 if (fWriteTree)
385 pTree = new TTree("esdTree", "Tree with HLT ESD objects");
386
387 if (pTree) {
388 pTree->SetDirectory(0);
389 }
390
accd913d 391 if( fESDfriend ) fESDfriend->Reset();
392
393 if ((iResult=ProcessBlocks(pTree, pESD, fESDfriend))>=0) {
a1408c4b 394 // TODO: set the specification correctly
395 if (pTree) {
396 // the esd structure is written to the user info and is
397 // needed in te ReadFromTree method to read all objects correctly
398 pTree->GetUserInfo()->Add(pESD);
399 pESD->WriteToTree(pTree);
7a9de6d1 400 iResult=PushBack(pTree, kAliHLTDataTypeESDTree|kAliHLTDataOriginOut, 0);
a1408c4b 401 } else {
c5baab86 402 cout<<"Write ESD block: n tracks "<<pESD->GetNumberOfTracks()<<endl;
7a9de6d1 403 iResult=PushBack(pESD, kAliHLTDataTypeESDObject|kAliHLTDataOriginOut, 0);
a1408c4b 404 }
57a4102f 405 fBenchmark.AddOutput(GetLastObjectSize());
accd913d 406 if( iResult>=0 && fMakeFriends ){
c5baab86 407 cout<<"Write ESD friend block: n friend tracks "<<fESDfriend->GetNumberOfTracks()<<endl;
accd913d 408 iResult=PushBack(fESDfriend, kAliHLTDataTypeESDfriendObject|kAliHLTDataOriginOut, 0);
409 fBenchmark.AddOutput(GetLastObjectSize());
410 }
a1408c4b 411 }
412 if (pTree) {
413 // clear user info list to prevent objects from being deleted
414 pTree->GetUserInfo()->Clear();
415 delete pTree;
416 }
57a4102f 417
418 fBenchmark.Stop(0);
251a2c81 419 HLTWarning( fBenchmark.GetStatistics() );
f9ce172e 420
421
422
423
424
425
426 if(benchmark){
427
3ccabd94 428 Int_t nV0s = pESD->GetNumberOfV0s();
429 Int_t nTracks = pESD->GetNumberOfTracks();
f9ce172e 430
431
432 Double_t statistics[10];
433 TString names[10];
434 fBenchmark.GetStatisticsData(statistics, names);
3ccabd94 435 // statistics[5] = nTracks;
436 // statistics[6] = time;
437 // statistics[7] = nV0s;
f9ce172e 438
3ccabd94 439 // FillBenchmarkHistos( statistics, names);
f9ce172e 440 fBenchmark.Reset();
441
488e1434 442 AliSysInfo::AddStamp("DoEvent.Stop", (int)(statistics[1]), (int)(statistics[2]),pESD->GetNumberOfV0s(),pESD->GetNumberOfTracks() );
f9ce172e 443 }
444
2352edc3 445 for(Int_t i=0; i<fkNPartition; i++){
446 delete[] fPartitionClusters[i];
447 fPartitionClusters[i] = 0;
448 fNPartitionClusters[i] = 0;
449 }
accd913d 450
451 if( fESDfriend ) fESDfriend->Reset();
452 if( fESD ) fESD->Reset();
453
a1408c4b 454 return iResult;
455}
456
accd913d 457int AliHLTGlobalEsdConverterComponent::ProcessBlocks(TTree* pTree, AliESDEvent* pESD, AliESDfriend *pESDfriend )
a1408c4b 458{
459 // see header file for class documentation
460
461 int iResult=0;
462 int iAddedDataBlocks=0;
463
b7449dbe 464 // check if there is an ESD block in the input and copy its content first to the
465 // ESD
466 const TObject* pEsdObj = GetFirstInputObject(kAliHLTDataTypeESDObject, "AliESDEvent");
467 AliESDEvent* pInputESD=NULL;
468 if (pEsdObj) pInputESD=dynamic_cast<AliESDEvent*>(const_cast<TObject*>(pEsdObj));
469 if (pInputESD) {
470 pInputESD->GetStdContent();
471 *pESD=*pInputESD;
472 }
473 if (GetNextInputObject()!=NULL) {
474 HLTWarning("handling of multiple ESD input objects not implemented, skipping input");
475 }
476
a1408c4b 477 // Barrel tracking
e85f2e31 478 // tracks are based on the TPC tracks, and only updated from the ITS information
479 // Sequence:
480 // 1) extract MC information for TPC and ITS from specific data blocks and store in
481 // intermediate vector arrays
482 // 2) extract TPC tracks, update with MC labels if available, the track parameters
483 // are estimated at the first cluster position
484 // 2.1) propagate to last cluster position and update kTPCout, sets also outer param (fOp)
485 // 2.2) update kTPCin, sets also inner param (fIp) and TPC inner param (fTPCInner)
486 // 2.3) update kTPCrefit using the same parameters at the first cluster position
487 // HLT has strictly spoking no refit, but we want the flag to be set
488 // can be changed to be done after all the individual barrel detector parameters
489 // have been updated by looping over the tracks again
490 // 3) extract ITS tracks, the tracks are actually TPC tracks updated from the ITS
491 // tracking information
492 // 3.1) TODO 2010-07-12: handle ITS standalone tracks by updating kITSout before kITSin
493 // 3.2) update with kITSin
494 // TODO 2010-07-12 find out if the kITSrefit has to be set as well
495 // 4) extract TRD tracks and add to ESD
496 // TODO 2010-07-12 at the moment there is no matching or merging of TPC and TRD tracks
331d51c5 497 // 5) Add Trigger Detectors
498 // VZERO, ZDC
e85f2e31 499
2352edc3 500 // read the clusters
501 // ---------- Access to clusters --------------------//
502
503 for(Int_t i=0; i<fkNPartition; i++){
504 delete[] fPartitionClusters[i];
505 fPartitionClusters[i] = 0;
506 fNPartitionClusters[i] = 0;
507 }
508
accd913d 509 if( pESDfriend ){
2352edc3 510
511 int nInputClusters = 0;
512
513 for(const AliHLTComponentBlockData *iter = GetFirstInputBlock(AliHLTTPCDefinitions::fgkClustersDataType); iter != NULL; iter = GetNextInputBlock()){
514
515 if(iter->fDataType != AliHLTTPCDefinitions::fgkClustersDataType) continue;
516 Int_t slice = AliHLTTPCDefinitions::GetMinSliceNr(iter->fSpecification);
517 Int_t partition = AliHLTTPCDefinitions::GetMinPatchNr(iter->fSpecification);
518 Int_t slicepartition = slice*6+partition;
519 if(slicepartition<0 || slicepartition > fkNPartition){
520 HLTWarning("Wrong header of TPC cluster data, slice %d, partition %d", slice, partition );
521 continue;
522 }
523
524 AliHLTTPCClusterData *inPtrSP = ( AliHLTTPCClusterData* )( iter->fPtr );
525 nInputClusters += inPtrSP->fSpacePointCnt;
526
527 delete[] fPartitionClusters[slicepartition];
528 fPartitionClusters[slicepartition] = new AliTPCclusterMI[inPtrSP->fSpacePointCnt];
529 fNPartitionClusters[slicepartition] = inPtrSP->fSpacePointCnt;
530
531 // create offline clusters out of the HLT clusters
532
533 for ( unsigned int i = 0; i < inPtrSP->fSpacePointCnt; i++ ) {
534 AliHLTTPCSpacePointData *chlt = &( inPtrSP->fSpacePoints[i] );
535 AliTPCclusterMI *c = fPartitionClusters[slicepartition]+i;
536 c->SetX(chlt->fX);
537 c->SetY(chlt->fY);
538 c->SetZ(chlt->fZ);
539 c->SetSigmaY2(chlt->fSigmaY2);
540 c->SetSigmaYZ( 0 );
541 c->SetSigmaZ2(chlt->fSigmaZ2);
542 c->SetQ( chlt->fCharge );
543 c->SetMax( chlt->fQMax );
544 Int_t sector, row;
545 Float_t padtime[3] = {0,chlt->fY,chlt->fZ};
546 AliHLTTPCTransform::Slice2Sector(slice,chlt->fPadRow, sector, row);
547 AliHLTTPCTransform::Local2Raw( padtime, sector, row);
548 c->SetDetector( sector );
549 c->SetRow( row );
550 c->SetPad( (Int_t) padtime[1] );
551 c->SetTimeBin( (Int_t) padtime[2] );
552 }
553 } // end of loop over blocks of clusters
554 }
555
e85f2e31 556 // 1) first read MC information (if present)
eb60b0c1 557 std::map<int,int> mcLabelsTPC;
d72d9d99 558 std::map<int,int> mcLabelsITS;
093b64dc 559
560 for (const AliHLTComponentBlockData* pBlock=GetFirstInputBlock(kAliHLTDataTypeTrackMC|kAliHLTDataOriginTPC);
561 pBlock!=NULL; pBlock=GetNextInputBlock()) {
57a4102f 562
563 fBenchmark.AddInput(pBlock->fSize);
564
093b64dc 565 AliHLTTrackMCData* dataPtr = reinterpret_cast<AliHLTTrackMCData*>( pBlock->fPtr );
566 if (sizeof(AliHLTTrackMCData)+dataPtr->fCount*sizeof(AliHLTTrackMCLabel)==pBlock->fSize) {
567 for( unsigned int il=0; il<dataPtr->fCount; il++ ){
568 AliHLTTrackMCLabel &lab = dataPtr->fLabels[il];
eb60b0c1 569 mcLabelsTPC[lab.fTrackID] = lab.fMCLabel;
093b64dc 570 }
571 } else {
572 HLTWarning("data mismatch in block %s (0x%08x): count %d, size %d -> ignoring track MC information",
573 DataType2Text(pBlock->fDataType).c_str(), pBlock->fSpecification,
574 dataPtr->fCount, pBlock->fSize);
575 }
576 }
d72d9d99 577
578 for (const AliHLTComponentBlockData* pBlock=GetFirstInputBlock(kAliHLTDataTypeTrackMC|kAliHLTDataOriginITS);
579 pBlock!=NULL; pBlock=GetNextInputBlock()) {
580
581 fBenchmark.AddInput(pBlock->fSize);
582
583 AliHLTTrackMCData* dataPtr = reinterpret_cast<AliHLTTrackMCData*>( pBlock->fPtr );
584 if (sizeof(AliHLTTrackMCData)+dataPtr->fCount*sizeof(AliHLTTrackMCLabel)==pBlock->fSize) {
585 for( unsigned int il=0; il<dataPtr->fCount; il++ ){
586 AliHLTTrackMCLabel &lab = dataPtr->fLabels[il];
587 mcLabelsITS[lab.fTrackID] = lab.fMCLabel;
588 }
589 } else {
590 HLTWarning("data mismatch in block %s (0x%08x): count %d, size %d -> ignoring track MC information",
591 DataType2Text(pBlock->fDataType).c_str(), pBlock->fSpecification,
592 dataPtr->fCount, pBlock->fSize);
593 }
594 }
595
093b64dc 596
0973c527 597 // read dEdx information (if present)
e85f2e31 598 // TODO 2010-07-12 this needs to be verified
0973c527 599
600 AliHLTFloat32_t *dEdxTPC = 0;
601 Int_t ndEdxTPC = 0;
602 for (const AliHLTComponentBlockData* pBlock=GetFirstInputBlock(kAliHLTDataTypedEdx|kAliHLTDataOriginTPC);
e38918a2 603 pBlock!=NULL; pBlock=NULL/*GetNextInputBlock() there is only one block*/) {
57a4102f 604 fBenchmark.AddInput(pBlock->fSize);
0973c527 605 dEdxTPC = reinterpret_cast<AliHLTFloat32_t*>( pBlock->fPtr );
72a916d9 606 ndEdxTPC = pBlock->fSize / (3*sizeof(AliHLTFloat32_t));
0973c527 607 }
608
e85f2e31 609 // 2) convert the TPC tracks to ESD tracks
a1408c4b 610 for (const AliHLTComponentBlockData* pBlock=GetFirstInputBlock(kAliHLTDataTypeTrack|kAliHLTDataOriginTPC);
611 pBlock!=NULL; pBlock=GetNextInputBlock()) {
b7449dbe 612 if (pInputESD && pInputESD->GetNumberOfTracks()>0) {
613 HLTWarning("Tracks array already filled from the input esd block, additional filling from TPC tracks block might cause inconsistent content");
614 }
57a4102f 615 fBenchmark.AddInput(pBlock->fSize);
a1408c4b 616 vector<AliHLTGlobalBarrelTrack> tracks;
81509fd3 617 if ((iResult=AliHLTGlobalBarrelTrack::ConvertTrackDataArray(reinterpret_cast<const AliHLTTracksData*>(pBlock->fPtr), pBlock->fSize, tracks))>=0) {
c5baab86 618 cout<<"\n\n ESD converter: input "<<tracks.size()<<" TPC tracks"<<endl;
a1408c4b 619 for (vector<AliHLTGlobalBarrelTrack>::iterator element=tracks.begin();
620 element!=tracks.end(); element++) {
621 Float_t points[4] = {
2cb809a5 622 static_cast<Float_t>(element->GetX()),
623 static_cast<Float_t>(element->GetY()),
624 static_cast<Float_t>(element->GetLastPointX()),
625 static_cast<Float_t>(element->GetLastPointY())
a1408c4b 626 };
093b64dc 627
628 Int_t mcLabel = -1;
eb60b0c1 629 if( mcLabelsTPC.find(element->TrackID())!=mcLabelsTPC.end() )
630 mcLabel = mcLabelsTPC[element->TrackID()];
093b64dc 631 element->SetLabel( mcLabel );
632
a1408c4b 633 AliESDtrack iotrack;
550ecaab 634
635 // for the moment, the number of clusters are not set when processing the
636 // kTPCin update, only at kTPCout
637 // there ar emainly three parameters updated for kTPCout
638 // number of clusters
639 // chi2
640 // pid signal
641 // The first one can be updated already at that stage here, while the two others
642 // eventually require to update from the ITS tracks before. The exact scheme
ab700b08 643 // needs to be checked
c3261a7d 644 iotrack.SetID( element->TrackID() );
e85f2e31 645
646 // 2.1 set kTPCout
647 // TODO 2010-07-12 disabled for the moment because of bug
648 // https://savannah.cern.ch/bugs/index.php?69875
649 // the propagation does not work, there is an offset in z
650 // propagate to last cluster and update parameters with flag kTPCout
651 // Note: updating with flag kITSout further down will overwrite the outer
652 // parameter again so this can be done only for ITS standalone tracks, meaning
653 // tracks in the ITS not associated with any TPC track
654 // HLT does not provide such standalone tracking
c3261a7d 655 {
f167b631 656 AliHLTGlobalBarrelTrack outPar(*element);
114e074b 657 //outPar.AliExternalTrackParam::PropagateTo( element->GetLastPointX(), fSolenoidBz );
658 const Int_t N=10; // number of steps.
659 const Float_t xRange = element->GetLastPointX() - element->GetX();
660 const Float_t xStep = xRange / N ;
661 for(int i = 1; i <= N; ++i) {
662 if(!outPar.AliExternalTrackParam::PropagateTo(element->GetX() + xStep * i, fSolenoidBz)) break;
663 }
b9838c05 664 outPar.SetLabel(element->GetLabel());
114e074b 665 iotrack.UpdateTrackParams(&outPar,AliESDtrack::kTPCout);
c3261a7d 666 }
e85f2e31 667 // 2.2 TPC tracking estimates parameters at first cluster
ab700b08 668 iotrack.UpdateTrackParams(&(*element),AliESDtrack::kTPCin);
e85f2e31 669
670 // 2.3 use the same parameters also for kTPCrefit, there is no proper refit in HLT
671 // maybe this can be done later, however also the inner parameter is changed which
672 // is used as a reference point in the display. That point should be at the first
673 // TPC cluster
674 iotrack.UpdateTrackParams(&(*element),AliESDtrack::kTPCrefit);
a1408c4b 675 iotrack.SetTPCPoints(points);
0973c527 676 if( element->TrackID()<ndEdxTPC ){
72a916d9 677 AliHLTFloat32_t *val = &(dEdxTPC[3*element->TrackID()]);
5c2dca91 678 iotrack.SetTPCsignal( val[0], val[1], (UChar_t) val[2] );
7e32fedf 679 //AliTPCseed s;
680 //s.Set( element->GetX(), element->GetAlpha(),
681 //element->GetParameter(), element->GetCovariance() );
72a916d9 682 //s.SetdEdx( val[0] );
7e32fedf 683 //s.CookPID();
684 //iotrack.SetTPCpid(s.TPCrPIDs() );
0973c527 685 } else {
686 if( dEdxTPC ) HLTWarning("Wrong number of dEdx TPC labels");
687 }
b9838c05 688 iotrack.SetLabel(mcLabel);
7fd2e09c 689 pESD->AddTrack(&iotrack);
093b64dc 690 if (fVerbosity>0) element->Print();
2352edc3 691
accd913d 692 if( pESDfriend ){ // create friend track
2352edc3 693
694 AliHLTGlobalBarrelTrack gb(*element);
695 AliTPCseed tTPC;
696 tTPC.Set( gb.GetX(), gb.GetAlpha(), gb.GetParameter(), gb.GetCovariance() );
697 tTPC.SetLabel(mcLabel);
698
699 // set the clusters
700 UInt_t nClusters = element->GetNumberOfPoints();
701 const UInt_t*clusterIDs = element->GetPoints();
702
703 tTPC.SetNumberOfClusters(nClusters);
704
705 for(UInt_t ic=0; ic<nClusters; ic++){
706
707 UInt_t id = clusterIDs[ic];
708 int iSlice = AliHLTTPCSpacePointData::GetSlice(id);
709 int iPartition = AliHLTTPCSpacePointData::GetPatch(id);
710 int iCluster = AliHLTTPCSpacePointData::GetNumber(id);
711
712 if(iSlice<0 || iSlice>36 || iPartition<0 || iPartition>5){
713 HLTError("Corrupted TPC cluster Id: slice %d, partition %d, cluster %d", iSlice, iPartition, iCluster);
714 continue;
715 }
716
717 AliTPCclusterMI *patchClusters = fPartitionClusters[iSlice*6 + iPartition];
718 if(!patchClusters){
719 HLTError("Clusters are missed for slice %d, partition %d", iSlice, iPartition );
720 continue;
721 }
722
723 if(iCluster >= fNPartitionClusters[iSlice*6 + iPartition]){
724 HLTError("TPC slice %d, partition %d: ClusterID==%d >= N Cluaters==%d ", iSlice, iPartition,iCluster, fNPartitionClusters[iSlice*6 + iPartition] );
725 continue;
726 }
727
728 AliTPCclusterMI *c = &(patchClusters[iCluster]);
729 int sec = c->GetDetector();
730 int row = c->GetRow();
731 if(sec >= 36) row = row + AliHLTTPCTransform::GetNRowLow();
732
733 tTPC.SetClusterPointer(row, c);
734
735 AliTPCTrackerPoint &point = *( tTPC.GetTrackPoint( row ) );
736 //tTPC.Propagate( TMath::DegToRad()*(sec%18*20.+10.), c->GetX(), fSolenoidBz );
737 Double_t angle2 = tTPC.GetSnp()*tTPC.GetSnp();
738 angle2 = (angle2<1) ?TMath::Sqrt(angle2/(1-angle2)) :10.;
739 point.SetAngleY( angle2 );
740 point.SetAngleZ( tTPC.GetTgl() );
741 } // end of associated cluster loop
742
743 // Cook dEdx
744
745 AliTPCseed *seed = &(tTPC);
746 //fSeedArray->AddAt( seed, TMath::Abs(seed->GetLabel()) );
747 //fdEdx->Fill( seed->P()*seed->Charge(), seed->CookdEdx(0.02, 0.6) );
748
749 AliESDfriendTrack friendTrack;
750 friendTrack.AddCalibObject(&tTPC);
accd913d 751 pESDfriend->AddTrack(&friendTrack);
2352edc3 752 }
a1408c4b 753 }
2352edc3 754
093b64dc 755 HLTInfo("converted %d track(s) to AliESDtrack and added to ESD", tracks.size());
a1408c4b 756 iAddedDataBlocks++;
757 } else if (iResult<0) {
093b64dc 758 HLTError("can not extract tracks from data block of type %s (specification %08x) of size %d: error %d",
759 DataType2Text(pBlock->fDataType).c_str(), pBlock->fSpecification, pBlock->fSize, iResult);
a1408c4b 760 }
761 }
762
7f167a74 763
764 // Get ITS SPD vertex
57a4102f 765 for( const AliHLTComponentBlockData *i= GetFirstInputBlock(kAliHLTDataTypeESDVertex|kAliHLTDataOriginITS); i!=NULL; i=GetNextInputBlock() ){
766 fBenchmark.AddInput(i->fSize);
767 }
7f167a74 768
769 for ( const TObject *iter = GetFirstInputObject(kAliHLTDataTypeESDVertex|kAliHLTDataOriginITS); iter != NULL; iter = GetNextInputObject() ) {
770 AliESDVertex *vtx = dynamic_cast<AliESDVertex*>(const_cast<TObject*>( iter ) );
771 pESD->SetPrimaryVertexSPD( vtx );
772 }
773
e85f2e31 774 // 3.1. now update ESD tracks with the ITSOut info
775 // updating track parameters with flag kITSout will overwrite parameter set above with flag kTPCout
776 // TODO 2010-07-12 there are some issues with this updating sequence, for the moment update with
777 // flag kITSout is disabled, would require
778 // a) to update kTPCout after kITSout
779 // b) update only for ITS standalone tracks. The HLT ITS tracker does not provide standalone
780 // tracking, every track is related to a TPC track
781 // Furthermore there seems to be a bug as the data blocks describe track parameters around the
782 // vertex, not at the outer ITS
783 // bug https://savannah.cern.ch/bugs/index.php?69872
f167b631 784 for (const AliHLTComponentBlockData* pBlock=GetFirstInputBlock(kAliHLTDataTypeTrack|kAliHLTDataOriginITSOut);
cd60a73f 785 pBlock!=NULL; pBlock=GetNextInputBlock()) {
57a4102f 786 fBenchmark.AddInput(pBlock->fSize);
cd60a73f 787 vector<AliHLTGlobalBarrelTrack> tracks;
788 if ((iResult=AliHLTGlobalBarrelTrack::ConvertTrackDataArray(reinterpret_cast<const AliHLTTracksData*>(pBlock->fPtr), pBlock->fSize, tracks))>0) {
789 for (vector<AliHLTGlobalBarrelTrack>::iterator element=tracks.begin();
790 element!=tracks.end(); element++) {
cd60a73f 791 int tpcID=element->TrackID();
792 // the ITS tracker assigns the TPC track used as seed for a certain track to
793 // the trackID
794 if( tpcID<0 || tpcID>=pESD->GetNumberOfTracks()) continue;
cd60a73f 795 AliESDtrack *tESD = pESD->GetTrack( tpcID );
b9838c05 796 element->SetLabel(tESD->GetLabel());
e85f2e31 797 // 2010-07-12 disabled, see above, bugfix https://savannah.cern.ch/bugs/index.php?69872
798 //if( tESD ) tESD->UpdateTrackParams( &(*element), AliESDtrack::kITSout );
a1408c4b 799 }
cd60a73f 800 }
801 }
18ada816 802
e85f2e31 803 // 3.2. now update ESD tracks with the ITS info
f167b631 804 for (const AliHLTComponentBlockData* pBlock=GetFirstInputBlock(kAliHLTDataTypeTrack|kAliHLTDataOriginITS);
b7ed2eb4 805 pBlock!=NULL; pBlock=GetNextInputBlock()) {
57a4102f 806 fBenchmark.AddInput(pBlock->fSize);
b7ed2eb4 807 vector<AliHLTGlobalBarrelTrack> tracks;
808 if ((iResult=AliHLTGlobalBarrelTrack::ConvertTrackDataArray(reinterpret_cast<const AliHLTTracksData*>(pBlock->fPtr), pBlock->fSize, tracks))>0) {
809 for (vector<AliHLTGlobalBarrelTrack>::iterator element=tracks.begin();
810 element!=tracks.end(); element++) {
b7ed2eb4 811 int tpcID=element->TrackID();
812 // the ITS tracker assigns the TPC track used as seed for a certain track to
813 // the trackID
814 if( tpcID<0 || tpcID>=pESD->GetNumberOfTracks()) continue;
d72d9d99 815 Int_t mcLabel = -1;
816 if( mcLabelsITS.find(element->TrackID())!=mcLabelsITS.end() )
817 mcLabel = mcLabelsITS[element->TrackID()];
b7ed2eb4 818 AliESDtrack *tESD = pESD->GetTrack( tpcID );
b9838c05 819 if (!tESD) continue;
eb60b0c1 820 // the labels for the TPC and ITS tracking params can be different, e.g.
821 // there can be a decay. The ITS label should then be the better one, the
822 // TPC label is saved in a member of AliESDtrack
823 if (mcLabel>=0) {
824 // upadte only if the ITS label is available, otherwise keep TPC label
825 element->SetLabel( mcLabel );
e85f2e31 826 } else {
827 // bugfix https://savannah.cern.ch/bugs/?69713
828 element->SetLabel( tESD->GetLabel() );
b9838c05 829 }
b9838c05 830 tESD->UpdateTrackParams( &(*element), AliESDtrack::kITSin );
831
832 // TODO: add a proper refit
833 //tESD->UpdateTrackParams( &(*element), AliESDtrack::kTPCrefit );
b7ed2eb4 834 }
835 }
836 }
837
d9386025 838 // update with vertices and vertex-fitted tracks
b7449dbe 839 // output of the GlobalVertexerComponent
d9386025 840 for (const AliHLTComponentBlockData* pBlock=GetFirstInputBlock(kAliHLTDataTypeGlobalVertexer);
841 pBlock!=NULL; pBlock=GetNextInputBlock()) {
57a4102f 842 fBenchmark.AddInput(pBlock->fSize);
d9386025 843 AliHLTGlobalVertexerComponent::FillESD( pESD, reinterpret_cast<AliHLTGlobalVertexerComponent::AliHLTGlobalVertexerData* >(pBlock->fPtr) );
844 }
845
b7449dbe 846 // update with vertices and vertex-fitted tracks
847 // output of PrimaryVertexer and V0Finder components
f9ce172e 848
b7449dbe 849 TObject* pBase = (TObject*)GetFirstInputObject(kAliHLTDataTypeKFVertex | kAliHLTDataOriginOut);
850 if (pBase) {
851 AliKFVertex* kfVertex = dynamic_cast<AliKFVertex *>(pBase);
852 if (kfVertex) {
853 const AliHLTComponentBlockData* pP = GetFirstInputBlock(kAliHLTDataTypePrimaryFinder | kAliHLTDataOriginOut);
854 if (pP && pP->fSize && pP->fPtr) {
855 const AliHLTComponentBlockData* pV0 = GetFirstInputBlock(kAliHLTDataTypeV0Finder | kAliHLTDataOriginOut);
856 if (pV0 && pV0->fPtr && pInputESD && pInputESD->GetNumberOfV0s()>0) {
857 const int* v0s = static_cast<const int*>(pV0->fPtr);
858 HLTWarning("V0 array already filled from the input esd block, additional filling from V0 block of %d entries might cause inconsistent content", v0s[0]);
859 }
860 AliHLTVertexFinderBase::FillESD(pESD, kfVertex, pP->fPtr, pV0?pV0->fPtr:NULL);
861 } else
862 HLTWarning("Problem with primary finder's data block");
863 } else {
864 HLTWarning("primary vertex block of wrong type, expecting AliKFVertex instead of %s", pBase->GetName());
865 }
866 } else {
867 // throw an error if there is a V0 data block which can not be handled without
868 // the AliKFVertex object
869 if (GetFirstInputBlock(kAliHLTDataTypeV0Finder | kAliHLTDataOriginOut)!=NULL) {
870 ALIHLTERRORGUARD(1, "missing AliKFVertex object ignoring V0 data block of type %s",
871 DataType2Text(kAliHLTDataTypeV0Finder|kAliHLTDataOriginOut).c_str());
872 }
873 }
874
0d2e4e41 875 // Fill DCA parameters for TPC tracks
e85f2e31 876 // TODO 2010-07-12 this propagates also the TPC inner param to beamline
877 // sounds not very reasonable
878 // https://savannah.cern.ch/bugs/index.php?69873
7fd2e09c 879 for (int i=0; i<pESD->GetNumberOfTracks(); i++) {
0d2e4e41 880 if (!pESD->GetTrack(i) ||
881 !pESD->GetTrack(i)->GetTPCInnerParam() ) continue;
7fd2e09c 882 pESD->GetTrack(i)->RelateToVertexTPC(pESD->GetPrimaryVertexTracks(), fSolenoidBz, 1000 );
0d2e4e41 883 }
884
b9838c05 885 // loop over all tracks and set the TPC refit flag by updating with the
886 // original TPC inner parameter if not yet set
887 // TODO: replace this by a proper refit
888 // code is comented for the moment as it does not fully solve the problems with
889 // the display
e85f2e31 890 // - would set the main parameters to the TPC inner wall again, or
891 // - changes the inner param if the parameters are propagated, so we loose the track
892 // reference point for the display
893 // with the current sequence we have the latter case as the DCA operations above
894 // change the TPC inner parameters
b9838c05 895 /*
896 for (int i=0; i<pESD->GetNumberOfTracks(); i++) {
897 if (!pESD->GetTrack(i) ||
898 !pESD->GetTrack(i)->GetTPCInnerParam() ||
899 pESD->GetTrack(i)->IsOn(AliESDtrack::kTPCrefit)) continue;
900 AliESDtrack* tESD=pESD->GetTrack(i);
901 AliHLTGlobalBarrelTrack inner(*tESD->GetTPCInnerParam());
902 inner.SetLabel(tESD->GetLabel());
903 tESD->UpdateTrackParams(&inner, AliESDtrack::kTPCrefit);
904 }
905 */
b7ed2eb4 906
e85f2e31 907 // 4. convert the HLT TRD tracks to ESD tracks
18ada816 908 for (const AliHLTComponentBlockData* pBlock=GetFirstInputBlock(kAliHLTDataTypeTrack | kAliHLTDataOriginTRD);
909 pBlock!=NULL; pBlock=GetNextInputBlock()) {
57a4102f 910 fBenchmark.AddInput(pBlock->fSize);
18ada816 911 vector<AliHLTGlobalBarrelTrack> tracks;
912 if ((iResult=AliHLTGlobalBarrelTrack::ConvertTrackDataArray(reinterpret_cast<const AliHLTTracksData*>(pBlock->fPtr), pBlock->fSize, tracks))>0) {
913 for (vector<AliHLTGlobalBarrelTrack>::iterator element=tracks.begin();
914 element!=tracks.end(); element++) {
915
916 Double_t TRDpid[AliPID::kSPECIES], eProb(0.2), restProb((1-eProb)/(AliPID::kSPECIES-1)); //eprob(element->GetTRDpid...);
917 for(Int_t i=0; i<AliPID::kSPECIES; i++){
918 switch(i){
919 case AliPID::kElectron: TRDpid[AliPID::kElectron]=eProb; break;
920 default: TRDpid[i]=restProb; break;
921 }
922 }
923
924 AliESDtrack iotrack;
0d096bba 925 iotrack.UpdateTrackParams(&(*element),AliESDtrack::kTRDout);
0b745718 926 iotrack.SetStatus(AliESDtrack::kTRDin);
18ada816 927 iotrack.SetTRDpid(TRDpid);
928
929 pESD->AddTrack(&iotrack);
930 if (fVerbosity>0) element->Print();
931 }
932 HLTInfo("converted %d track(s) to AliESDtrack and added to ESD", tracks.size());
933 iAddedDataBlocks++;
934 } else if (iResult<0) {
935 HLTError("can not extract tracks from data block of type %s (specification %08x) of size %d: error %d",
936 DataType2Text(pBlock->fDataType).c_str(), pBlock->fSpecification, pBlock->fSize, iResult);
937 }
938 }
b4479a87 939 for (const AliHLTComponentBlockData* pBlock=GetFirstInputBlock(kAliHLTDataTypeCaloCluster | kAliHLTDataOriginAny); pBlock!=NULL; pBlock=GetNextInputBlock())
9a9467ed 940 {
57a4102f 941 fBenchmark.AddInput(pBlock->fSize);
9a9467ed 942 AliHLTCaloClusterHeaderStruct *caloClusterHeaderPtr = reinterpret_cast<AliHLTCaloClusterHeaderStruct*>(pBlock->fPtr);
943
944 HLTDebug("%d HLT clusters from spec: 0x%X", caloClusterHeaderPtr->fNClusters, pBlock->fSpecification);
945
2a24cbbe 946 //AliHLTCaloClusterReader reader;
947 //reader.SetMemory(caloClusterHeaderPtr);
9a9467ed 948
949 AliHLTESDCaloClusterMaker clusterMaker;
950
951 int nClusters = clusterMaker.FillESD(pESD, caloClusterHeaderPtr);
2a24cbbe 952
9a9467ed 953 HLTInfo("converted %d cluster(s) to AliESDCaloCluster and added to ESD", nClusters);
954 iAddedDataBlocks++;
955 }
f064ef44 956
331d51c5 957 // 5) Add Trigger Detectors
958 // VZERO, ZDC
959
960 // FIXME: the size of all input blocks can be added in one loop
961 for (const AliHLTComponentBlockData* pBlock=GetFirstInputBlock(kAliHLTDataTypeESDContent|kAliHLTDataOriginVZERO);
962 pBlock!=NULL; pBlock=GetNextInputBlock()) {
963 fBenchmark.AddInput(pBlock->fSize);
964 }
965
966 for ( const TObject *pObject = GetFirstInputObject(kAliHLTDataTypeESDContent|kAliHLTDataOriginVZERO);
967 pObject != NULL; pObject = GetNextInputObject() ) {
968 AliESDVZERO *esdVZERO = dynamic_cast<AliESDVZERO*>(const_cast<TObject*>( pObject ) );
969 if (esdVZERO) {
970 pESD->SetVZEROData( esdVZERO );
971 break;
972 } else {
973 ALIHLTERRORGUARD(1, "input object of data type %s is not of class AliESDVZERO",
974 DataType2Text(kAliHLTDataTypeESDContent|kAliHLTDataOriginVZERO).c_str());
975 }
976 }
977
421e1221 978 // FIXME: the size of all input blocks can be added in one loop
979 for (const AliHLTComponentBlockData* pBlock=GetFirstInputBlock(kAliHLTDataTypeESDContent|kAliHLTDataOriginZDC);
980 pBlock!=NULL; pBlock=GetNextInputBlock()) {
981 fBenchmark.AddInput(pBlock->fSize);
982 }
983 for ( const TObject *pObject = GetFirstInputObject(kAliHLTDataTypeESDContent|kAliHLTDataOriginZDC);
984 pObject != NULL; pObject = GetNextInputObject() ) {
985 AliESDZDC *esdZDC = dynamic_cast<AliESDZDC*>(const_cast<TObject*>( pObject ) );
986 if (esdZDC) {
8cd67fda 987#ifndef HAVE_NOT_ALIZDCRECONSTRUCTOR_r43770
421e1221 988 pESD->SetZDCData( esdZDC );
8cd67fda 989#else
990 ALIHLTERRORGUARD(1, "Processing of ZDC data requires AliRoot r43770m skipping data block of type %s",
991 DataType2Text(kAliHLTDataTypeESDContent|kAliHLTDataOriginZDC).c_str());
992#endif
421e1221 993 break;
994 } else {
995 ALIHLTERRORGUARD(1, "input object of data type %s is not of class AliESDZDC",
996 DataType2Text(kAliHLTDataTypeESDContent|kAliHLTDataOriginZDC).c_str());
997 }
998 }
999
fe0324de 1000 // Add tracks and clusters from MUON.
57a4102f 1001 for( const AliHLTComponentBlockData *i= GetFirstInputBlock(kAliHLTAnyDataType | kAliHLTDataOriginMUON); i!=NULL; i=GetNextInputBlock() ){
1002 fBenchmark.AddInput(i->fSize);
1003 }
1004
f064ef44 1005 for (const TObject* obj = GetFirstInputObject(kAliHLTAnyDataType | kAliHLTDataOriginMUON);
1006 obj != NULL;
1007 obj = GetNextInputObject()
1008 )
1009 {
1010 const TClonesArray* tracklist = NULL;
fe0324de 1011 const TClonesArray* clusterlist = NULL;
f064ef44 1012 if (obj->IsA() == AliESDEvent::Class())
1013 {
1014 const AliESDEvent* event = static_cast<const AliESDEvent*>(obj);
1015 HLTDebug("Received a MUON ESD with specification: 0x%X", GetSpecification(obj));
1016 if (event->GetList() == NULL) continue;
1017 tracklist = dynamic_cast<const TClonesArray*>(event->GetList()->FindObject("MuonTracks"));
1018 if (tracklist == NULL) continue;
fe0324de 1019 clusterlist = dynamic_cast<const TClonesArray*>(event->GetList()->FindObject("MuonClusters"));
1020 if (clusterlist == NULL) continue;
f064ef44 1021 }
1022 else if (obj->IsA() == TClonesArray::Class())
1023 {
fe0324de 1024 if (!strcmp(obj->GetName(), "MuonTracks")) {
1025 tracklist = static_cast<const TClonesArray*>(obj);
1026 HLTDebug("Received a MUON TClonesArray of tracks with specification: 0x%X", GetSpecification(obj));
1027 } else {
1028 clusterlist = static_cast<const TClonesArray*>(obj);
1029 HLTDebug("Received a MUON TClonesArray of clusters with specification: 0x%X", GetSpecification(obj));
1030 }
f064ef44 1031 }
1032 else
1033 {
1034 // Cannot handle this object type.
1035 continue;
1036 }
fe0324de 1037 // copy tracks
1038 if (tracklist) {
1039 HLTDebug("Received %d MUON tracks.", tracklist->GetEntriesFast());
1040 if (tracklist->GetEntriesFast() > 0)
1041 {
1042 const AliESDMuonTrack* track = dynamic_cast<const AliESDMuonTrack*>(tracklist->UncheckedAt(0));
1043 if (track == NULL)
1044 {
1045 HLTError(Form("%s from MUON does not contain AliESDMuonTrack objects.", obj->ClassName()));
1046 continue;
1047 }
1048 }
1049 for (Int_t i = 0; i < tracklist->GetEntriesFast(); ++i)
f064ef44 1050 {
fe0324de 1051 AliESDMuonTrack* track = pESD->NewMuonTrack();
1052 *track = *(static_cast<const AliESDMuonTrack*>(tracklist->UncheckedAt(i)));
a1408c4b 1053 }
f064ef44 1054 }
fe0324de 1055 // copy clusters
1056 if (clusterlist) {
1057 HLTDebug("Received %d MUON clusters.", clusterlist->GetEntriesFast());
1058 if (clusterlist->GetEntriesFast() > 0)
1059 {
1060 const AliESDMuonCluster* cluster = dynamic_cast<const AliESDMuonCluster*>(clusterlist->UncheckedAt(0));
1061 if (cluster == NULL)
1062 {
1063 HLTError(Form("%s from MUON does not contain AliESDMuonCluster objects.", obj->ClassName()));
1064 continue;
1065 }
1066 }
1067 for (Int_t i = 0; i < clusterlist->GetEntriesFast(); ++i)
1068 {
1069 AliESDMuonCluster* cluster = pESD->NewMuonCluster();
1070 *cluster = *(static_cast<const AliESDMuonCluster*>(clusterlist->UncheckedAt(i)));
1071 }
f064ef44 1072 }
1073 }
2352edc3 1074
accd913d 1075 if( fMakeFriends && pESDfriend ){ // create friend track
1076 pESD->SetESDfriend( pESDfriend );
c5baab86 1077 // cout<<"\n\n ESD Friend: "<<pESDfriend->GetNumberOfTracks()<<endl;
1078 }
accd913d 1079
c5baab86 1080
f064ef44 1081 if (iAddedDataBlocks>0 && pTree) {
1082 pTree->Fill();
accd913d 1083 }
a1408c4b 1084
1085 if (iResult>=0) iResult=iAddedDataBlocks;
1086 return iResult;
1087}
f9ce172e 1088
1089
1090
3ccabd94 1091/*
85b2a6cf 1092void AliHLTGlobalEsdConverterComponent::FillBenchmarkHistos(Double_t *statistics, TString *names){
1093return;
f9ce172e 1094
1095// cout<<"Now writing benchmarks to " << fBenchmarkHistosFilename <<endl<<endl;
1096
1097 TFile *f = TFile::Open(fBenchmarkHistosFilename,"UPDATE");
1098 THnSparseD *s = (THnSparseD*)f->Get("benchmarkInformation");
1099 TNamed *t = (TNamed*)f->Get("time");
1100
1101 if(!s){
1102 HLTWarning( "Benchmark Histograms not available!" );
1103 return;
1104 }
1105 s->Fill(statistics);
1106
1107 TList histosList;
1108 histosList.Add(s);
1109 histosList.Add(t);
1110 histosList.SaveAs(fBenchmarkHistosFilename);
f9ce172e 1111}
85b2a6cf 1112*/