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> *
8 //* for The ALICE HLT Project. *
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 //**************************************************************************
19 // @file AliHLTGlobalEsdConverterComponent.cxx
20 // @author Matthias Richter
22 // @brief Global ESD converter component.
25 // see header file for class documentation
27 // refer to README to build package
29 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
32 #include "AliHLTGlobalEsdConverterComponent.h"
33 #include "AliHLTGlobalBarrelTrack.h"
34 #include "AliHLTExternalTrackParam.h"
35 #include "AliHLTTrackMCLabel.h"
36 #include "AliHLTCTPData.h"
37 #include "AliHLTErrorGuard.h"
38 #include "AliESDEvent.h"
39 #include "AliESDtrack.h"
40 #include "AliESDMuonTrack.h"
41 #include "AliESDMuonCluster.h"
42 #include "AliCDBEntry.h"
43 #include "AliCDBManager.h"
47 #include "TClonesArray.h"
48 #include "TTimeStamp.h"
49 #include "THnSparse.h"
50 #include "AliHLTESDCaloClusterMaker.h"
51 #include "AliHLTCaloClusterDataStruct.h"
52 #include "AliHLTCaloClusterReader.h"
53 #include "AliESDCaloCluster.h"
54 #include "AliESDVZERO.h"
55 #include "AliHLTGlobalVertexerComponent.h"
56 #include "AliHLTVertexFinderBase.h"
58 /** ROOT macro for the implementation of ROOT specific class methods */
59 ClassImp(AliHLTGlobalEsdConverterComponent)
61 AliHLTGlobalEsdConverterComponent::AliHLTGlobalEsdConverterComponent()
66 , fSolenoidBz(-5.00668)
67 , fBenchmark("EsdConverter")
68 , fBenchmarkHistosFilename("$PWD/histosBenchmark.root")
71 // see header file for class documentation
73 // refer to README to build package
75 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
77 TFile *f = TFile::Open(fBenchmarkHistosFilename,"READ");
79 TNamed *t = (TNamed*)f->Get("time");
81 fInitialTime = atoi(t->GetTitle());
87 AliHLTGlobalEsdConverterComponent::~AliHLTGlobalEsdConverterComponent()
89 // see header file for class documentation
90 if (fESD) delete fESD;
94 int AliHLTGlobalEsdConverterComponent::Configure(const char* arguments)
96 // see header file for class documentation
98 if (!arguments) return iResult;
100 TString allArgs=arguments;
104 TObjArray* pTokens=allArgs.Tokenize(" ");
106 for (int i=0; i<pTokens->GetEntries() && iResult>=0; i++) {
107 argument=((TObjString*)pTokens->At(i))->String();
108 if (argument.IsNull()) continue;
110 if (argument.CompareTo("-solenoidBz")==0) {
111 if ((bMissingParam=(++i>=pTokens->GetEntries()))) break;
112 HLTWarning("argument -solenoidBz is deprecated, magnetic field set up globally (%f)", GetBz());
115 HLTError("unknown argument %s", argument.Data());
123 HLTError("missing parameter for argument %s", argument.Data());
130 int AliHLTGlobalEsdConverterComponent::Reconfigure(const char* cdbEntry, const char* chainId)
132 // see header file for class documentation
134 const char* path=NULL;
135 const char* defaultNotify="";
138 defaultNotify=" (default)";
141 HLTInfo("reconfigure from entry %s%s, chain id %s", path, defaultNotify,(chainId!=NULL && chainId[0]!=0)?chainId:"<none>");
142 AliCDBEntry *pEntry = AliCDBManager::Instance()->Get(path/*,GetRunNo()*/);
144 TObjString* pString=dynamic_cast<TObjString*>(pEntry->GetObject());
146 HLTInfo("received configuration object string: \'%s\'", pString->String().Data());
147 iResult=Configure(pString->String().Data());
149 HLTError("configuration object \"%s\" has wrong type, required TObjString", path);
152 HLTError("can not fetch object \"%s\" from CDB", path);
159 void AliHLTGlobalEsdConverterComponent::GetInputDataTypes(AliHLTComponentDataTypeList& list)
161 // see header file for class documentation
162 list.push_back(kAliHLTDataTypeTrack);
163 list.push_back(kAliHLTDataTypeTrackMC);
164 list.push_back(kAliHLTDataTypeCaloCluster);
165 list.push_back(kAliHLTDataTypedEdx );
166 list.push_back(kAliHLTDataTypeESDVertex );
167 list.push_back(kAliHLTDataTypeESDObject);
168 list.push_back(kAliHLTDataTypeTObject);
169 list.push_back(kAliHLTDataTypeGlobalVertexer);
170 list.push_back(kAliHLTDataTypeV0Finder); // array of track ids for V0s
171 list.push_back(kAliHLTDataTypeKFVertex); // KFVertex object from vertexer
172 list.push_back(kAliHLTDataTypePrimaryFinder); // array of track ids for prim vertex
173 list.push_back(kAliHLTDataTypeESDContent);
176 AliHLTComponentDataType AliHLTGlobalEsdConverterComponent::GetOutputDataType()
178 // see header file for class documentation
179 return kAliHLTDataTypeESDObject|kAliHLTDataOriginOut;
182 void AliHLTGlobalEsdConverterComponent::GetOutputDataSize(unsigned long& constBase, double& inputMultiplier)
184 // see header file for class documentation
186 inputMultiplier=10.0;
189 int AliHLTGlobalEsdConverterComponent::DoInit(int argc, const char** argv)
191 // see header file for class documentation
196 // default list of skiped ESD objects
207 // "AliMultiplicity,"
210 // "SPDPileupVertices,"
211 // "TrkPileupVertices,"
214 "AliRawDataErrorLogs,"
217 iResult=Reconfigure(NULL, NULL);
218 TString allArgs = "";
219 for ( int i = 0; i < argc; i++ ) {
220 if ( !allArgs.IsNull() ) allArgs += " ";
224 TObjArray* pTokens=allArgs.Tokenize(" ");
226 for (int i=0; i<pTokens->GetEntries() && iResult>=0; i++) {
227 argument=((TObjString*)pTokens->At(i))->String();
228 if (argument.IsNull()) continue;
231 if (argument.CompareTo("-notree")==0) {
235 } else if (argument.CompareTo("-tree")==0) {
237 } else if (argument.CompareTo("-solenoidBz")==0) {
238 if ((bMissingParam=(++i>=pTokens->GetEntries()))) break;
239 HLTInfo("Magnetic Field set to: %s", ((TObjString*)pTokens->At(i))->String().Data());
240 HLTWarning("argument '-solenoidBz' is deprecated, solenoid field initiaized from CDB settings");
242 } else if (argument.Contains("-skipobject=")) {
243 argument.ReplaceAll("-skipobject=", "");
244 skipObjects=argument;
246 HLTError("unknown argument %s", argument.Data());
253 HLTError("missing parameter for argument %s", argument.Data());
260 fESD = new AliESDEvent;
262 fESD->CreateStdContent();
264 // remove some of the objects which are not needed
265 if (fESD->GetList() && !skipObjects.IsNull()) {
266 pTokens=skipObjects.Tokenize(",");
270 TObject* pObject=NULL;
271 while ((pObject=next())!=NULL) {
272 id=((TObjString*)pObject)->String().Data();
273 TObject* pObj=fESD->GetList()->FindObject(id);
275 HLTDebug("removing object %s", id);
276 fESD->GetList()->Remove(pObj);
279 HLTWarning("failed to remove object '%s' from ESD", id);
282 fESD->GetStdContent();
293 fBenchmark.SetTimer(0,"total");
298 int AliHLTGlobalEsdConverterComponent::DoDeinit()
300 // see header file for class documentation
301 if (fESD) delete fESD;
307 int AliHLTGlobalEsdConverterComponent::DoEvent(const AliHLTComponentEventData& /*evtData*/,
308 AliHLTComponentTriggerData& trigData)
310 // see header file for class documentation
312 bool benchmark = true;
313 if (!fESD) return -ENODEV;
315 if (!IsDataEvent()) return iResult;
316 fBenchmark.StartNewEvent();
319 AliESDEvent* pESD = fESD;
322 pESD->SetMagneticField(fSolenoidBz);
323 pESD->SetRunNumber(GetRunNo());
324 pESD->SetPeriodNumber(GetPeriodNumber());
325 pESD->SetOrbitNumber(GetOrbitNumber());
326 pESD->SetBunchCrossNumber(GetBunchCrossNumber());
327 pESD->SetTimeStamp(GetTimeStamp());
329 const AliHLTCTPData* pCTPData=CTPData();
331 AliHLTTriggerMask_t mask=pCTPData->ActiveTriggers(trigData);
332 for (int index=0; index<gkNCTPTriggerClasses; index++) {
333 if ((mask&(AliHLTTriggerMask_t(0x1)<<index)) == 0) continue;
334 pESD->SetTriggerClass(pCTPData->Name(index), index);
337 AliHLTTriggerMask_t mask50;
338 mask50.set(); // set all bits
339 mask50 >>= 50; // shift 50 right
340 pESD->SetTriggerMask((mask&mask50).to_ulong());
342 pESD->SetTriggerMaskNext50((mask>>50).to_ulong());
347 pTree = new TTree("esdTree", "Tree with HLT ESD objects");
350 pTree->SetDirectory(0);
353 if ((iResult=ProcessBlocks(pTree, pESD))>=0) {
354 // TODO: set the specification correctly
356 // the esd structure is written to the user info and is
357 // needed in te ReadFromTree method to read all objects correctly
358 pTree->GetUserInfo()->Add(pESD);
359 pESD->WriteToTree(pTree);
360 iResult=PushBack(pTree, kAliHLTDataTypeESDTree|kAliHLTDataOriginOut, 0);
362 iResult=PushBack(pESD, kAliHLTDataTypeESDObject|kAliHLTDataOriginOut, 0);
364 fBenchmark.AddOutput(GetLastObjectSize());
367 // clear user info list to prevent objects from being deleted
368 pTree->GetUserInfo()->Clear();
373 HLTWarning( fBenchmark.GetStatistics() );
383 Double_t time = (Double_t) ts.GetSec() - fInitialTime;
384 Int_t nV0s = pESD->GetNumberOfV0s();
385 Int_t nTracks = pESD->GetNumberOfTracks();
388 Double_t statistics[10];
390 fBenchmark.GetStatisticsData(statistics, names);
391 statistics[5] = nTracks;
392 statistics[6] = time;
393 statistics[7] = nV0s;
395 FillBenchmarkHistos( statistics, names);
396 printf("\nTIME: %.9f \n\n",time);
408 int AliHLTGlobalEsdConverterComponent::ProcessBlocks(TTree* pTree, AliESDEvent* pESD)
410 // see header file for class documentation
413 int iAddedDataBlocks=0;
415 // check if there is an ESD block in the input and copy its content first to the
417 const TObject* pEsdObj = GetFirstInputObject(kAliHLTDataTypeESDObject, "AliESDEvent");
418 AliESDEvent* pInputESD=NULL;
419 if (pEsdObj) pInputESD=dynamic_cast<AliESDEvent*>(const_cast<TObject*>(pEsdObj));
421 pInputESD->GetStdContent();
424 if (GetNextInputObject()!=NULL) {
425 HLTWarning("handling of multiple ESD input objects not implemented, skipping input");
429 // tracks are based on the TPC tracks, and only updated from the ITS information
431 // 1) extract MC information for TPC and ITS from specific data blocks and store in
432 // intermediate vector arrays
433 // 2) extract TPC tracks, update with MC labels if available, the track parameters
434 // are estimated at the first cluster position
435 // 2.1) propagate to last cluster position and update kTPCout, sets also outer param (fOp)
436 // 2.2) update kTPCin, sets also inner param (fIp) and TPC inner param (fTPCInner)
437 // 2.3) update kTPCrefit using the same parameters at the first cluster position
438 // HLT has strictly spoking no refit, but we want the flag to be set
439 // can be changed to be done after all the individual barrel detector parameters
440 // have been updated by looping over the tracks again
441 // 3) extract ITS tracks, the tracks are actually TPC tracks updated from the ITS
442 // tracking information
443 // 3.1) TODO 2010-07-12: handle ITS standalone tracks by updating kITSout before kITSin
444 // 3.2) update with kITSin
445 // TODO 2010-07-12 find out if the kITSrefit has to be set as well
446 // 4) extract TRD tracks and add to ESD
447 // TODO 2010-07-12 at the moment there is no matching or merging of TPC and TRD tracks
448 // 5) Add Trigger Detectors
451 // 1) first read MC information (if present)
452 std::map<int,int> mcLabelsTPC;
453 std::map<int,int> mcLabelsITS;
455 for (const AliHLTComponentBlockData* pBlock=GetFirstInputBlock(kAliHLTDataTypeTrackMC|kAliHLTDataOriginTPC);
456 pBlock!=NULL; pBlock=GetNextInputBlock()) {
458 fBenchmark.AddInput(pBlock->fSize);
460 AliHLTTrackMCData* dataPtr = reinterpret_cast<AliHLTTrackMCData*>( pBlock->fPtr );
461 if (sizeof(AliHLTTrackMCData)+dataPtr->fCount*sizeof(AliHLTTrackMCLabel)==pBlock->fSize) {
462 for( unsigned int il=0; il<dataPtr->fCount; il++ ){
463 AliHLTTrackMCLabel &lab = dataPtr->fLabels[il];
464 mcLabelsTPC[lab.fTrackID] = lab.fMCLabel;
467 HLTWarning("data mismatch in block %s (0x%08x): count %d, size %d -> ignoring track MC information",
468 DataType2Text(pBlock->fDataType).c_str(), pBlock->fSpecification,
469 dataPtr->fCount, pBlock->fSize);
473 for (const AliHLTComponentBlockData* pBlock=GetFirstInputBlock(kAliHLTDataTypeTrackMC|kAliHLTDataOriginITS);
474 pBlock!=NULL; pBlock=GetNextInputBlock()) {
476 fBenchmark.AddInput(pBlock->fSize);
478 AliHLTTrackMCData* dataPtr = reinterpret_cast<AliHLTTrackMCData*>( pBlock->fPtr );
479 if (sizeof(AliHLTTrackMCData)+dataPtr->fCount*sizeof(AliHLTTrackMCLabel)==pBlock->fSize) {
480 for( unsigned int il=0; il<dataPtr->fCount; il++ ){
481 AliHLTTrackMCLabel &lab = dataPtr->fLabels[il];
482 mcLabelsITS[lab.fTrackID] = lab.fMCLabel;
485 HLTWarning("data mismatch in block %s (0x%08x): count %d, size %d -> ignoring track MC information",
486 DataType2Text(pBlock->fDataType).c_str(), pBlock->fSpecification,
487 dataPtr->fCount, pBlock->fSize);
492 // read dEdx information (if present)
493 // TODO 2010-07-12 this needs to be verified
495 AliHLTFloat32_t *dEdxTPC = 0;
497 for (const AliHLTComponentBlockData* pBlock=GetFirstInputBlock(kAliHLTDataTypedEdx|kAliHLTDataOriginTPC);
498 pBlock!=NULL; pBlock=NULL/*GetNextInputBlock() there is only one block*/) {
499 fBenchmark.AddInput(pBlock->fSize);
500 dEdxTPC = reinterpret_cast<AliHLTFloat32_t*>( pBlock->fPtr );
501 ndEdxTPC = pBlock->fSize / (3*sizeof(AliHLTFloat32_t));
504 // 2) convert the TPC tracks to ESD tracks
505 for (const AliHLTComponentBlockData* pBlock=GetFirstInputBlock(kAliHLTDataTypeTrack|kAliHLTDataOriginTPC);
506 pBlock!=NULL; pBlock=GetNextInputBlock()) {
507 if (pInputESD && pInputESD->GetNumberOfTracks()>0) {
508 HLTWarning("Tracks array already filled from the input esd block, additional filling from TPC tracks block might cause inconsistent content");
510 fBenchmark.AddInput(pBlock->fSize);
511 vector<AliHLTGlobalBarrelTrack> tracks;
512 if ((iResult=AliHLTGlobalBarrelTrack::ConvertTrackDataArray(reinterpret_cast<const AliHLTTracksData*>(pBlock->fPtr), pBlock->fSize, tracks))>=0) {
513 for (vector<AliHLTGlobalBarrelTrack>::iterator element=tracks.begin();
514 element!=tracks.end(); element++) {
515 Float_t points[4] = {
516 static_cast<Float_t>(element->GetX()),
517 static_cast<Float_t>(element->GetY()),
518 static_cast<Float_t>(element->GetLastPointX()),
519 static_cast<Float_t>(element->GetLastPointY())
523 if( mcLabelsTPC.find(element->TrackID())!=mcLabelsTPC.end() )
524 mcLabel = mcLabelsTPC[element->TrackID()];
525 element->SetLabel( mcLabel );
529 // for the moment, the number of clusters are not set when processing the
530 // kTPCin update, only at kTPCout
531 // there ar emainly three parameters updated for kTPCout
532 // number of clusters
535 // The first one can be updated already at that stage here, while the two others
536 // eventually require to update from the ITS tracks before. The exact scheme
537 // needs to be checked
538 iotrack.SetID( element->TrackID() );
541 // TODO 2010-07-12 disabled for the moment because of bug
542 // https://savannah.cern.ch/bugs/index.php?69875
543 // the propagation does not work, there is an offset in z
544 // propagate to last cluster and update parameters with flag kTPCout
545 // Note: updating with flag kITSout further down will overwrite the outer
546 // parameter again so this can be done only for ITS standalone tracks, meaning
547 // tracks in the ITS not associated with any TPC track
548 // HLT does not provide such standalone tracking
550 AliHLTGlobalBarrelTrack outPar(*element);
551 //outPar.AliExternalTrackParam::PropagateTo( element->GetLastPointX(), fSolenoidBz );
552 const Int_t N=10; // number of steps.
553 const Float_t xRange = element->GetLastPointX() - element->GetX();
554 const Float_t xStep = xRange / N ;
555 for(int i = 1; i <= N; ++i) {
556 if(!outPar.AliExternalTrackParam::PropagateTo(element->GetX() + xStep * i, fSolenoidBz)) break;
558 outPar.SetLabel(element->GetLabel());
559 iotrack.UpdateTrackParams(&outPar,AliESDtrack::kTPCout);
561 // 2.2 TPC tracking estimates parameters at first cluster
562 iotrack.UpdateTrackParams(&(*element),AliESDtrack::kTPCin);
564 // 2.3 use the same parameters also for kTPCrefit, there is no proper refit in HLT
565 // maybe this can be done later, however also the inner parameter is changed which
566 // is used as a reference point in the display. That point should be at the first
568 iotrack.UpdateTrackParams(&(*element),AliESDtrack::kTPCrefit);
569 iotrack.SetTPCPoints(points);
570 if( element->TrackID()<ndEdxTPC ){
571 AliHLTFloat32_t *val = &(dEdxTPC[3*element->TrackID()]);
572 iotrack.SetTPCsignal( val[0], val[1], (UChar_t) val[2] );
574 //s.Set( element->GetX(), element->GetAlpha(),
575 //element->GetParameter(), element->GetCovariance() );
576 //s.SetdEdx( val[0] );
578 //iotrack.SetTPCpid(s.TPCrPIDs() );
580 if( dEdxTPC ) HLTWarning("Wrong number of dEdx TPC labels");
582 iotrack.SetLabel(mcLabel);
583 pESD->AddTrack(&iotrack);
584 if (fVerbosity>0) element->Print();
586 HLTInfo("converted %d track(s) to AliESDtrack and added to ESD", tracks.size());
588 } else if (iResult<0) {
589 HLTError("can not extract tracks from data block of type %s (specification %08x) of size %d: error %d",
590 DataType2Text(pBlock->fDataType).c_str(), pBlock->fSpecification, pBlock->fSize, iResult);
595 // Get ITS SPD vertex
596 for( const AliHLTComponentBlockData *i= GetFirstInputBlock(kAliHLTDataTypeESDVertex|kAliHLTDataOriginITS); i!=NULL; i=GetNextInputBlock() ){
597 fBenchmark.AddInput(i->fSize);
600 for ( const TObject *iter = GetFirstInputObject(kAliHLTDataTypeESDVertex|kAliHLTDataOriginITS); iter != NULL; iter = GetNextInputObject() ) {
601 AliESDVertex *vtx = dynamic_cast<AliESDVertex*>(const_cast<TObject*>( iter ) );
602 pESD->SetPrimaryVertexSPD( vtx );
605 // 3.1. now update ESD tracks with the ITSOut info
606 // updating track parameters with flag kITSout will overwrite parameter set above with flag kTPCout
607 // TODO 2010-07-12 there are some issues with this updating sequence, for the moment update with
608 // flag kITSout is disabled, would require
609 // a) to update kTPCout after kITSout
610 // b) update only for ITS standalone tracks. The HLT ITS tracker does not provide standalone
611 // tracking, every track is related to a TPC track
612 // Furthermore there seems to be a bug as the data blocks describe track parameters around the
613 // vertex, not at the outer ITS
614 // bug https://savannah.cern.ch/bugs/index.php?69872
615 for (const AliHLTComponentBlockData* pBlock=GetFirstInputBlock(kAliHLTDataTypeTrack|kAliHLTDataOriginITSOut);
616 pBlock!=NULL; pBlock=GetNextInputBlock()) {
617 fBenchmark.AddInput(pBlock->fSize);
618 vector<AliHLTGlobalBarrelTrack> tracks;
619 if ((iResult=AliHLTGlobalBarrelTrack::ConvertTrackDataArray(reinterpret_cast<const AliHLTTracksData*>(pBlock->fPtr), pBlock->fSize, tracks))>0) {
620 for (vector<AliHLTGlobalBarrelTrack>::iterator element=tracks.begin();
621 element!=tracks.end(); element++) {
622 int tpcID=element->TrackID();
623 // the ITS tracker assigns the TPC track used as seed for a certain track to
625 if( tpcID<0 || tpcID>=pESD->GetNumberOfTracks()) continue;
626 AliESDtrack *tESD = pESD->GetTrack( tpcID );
627 element->SetLabel(tESD->GetLabel());
628 // 2010-07-12 disabled, see above, bugfix https://savannah.cern.ch/bugs/index.php?69872
629 //if( tESD ) tESD->UpdateTrackParams( &(*element), AliESDtrack::kITSout );
634 // 3.2. now update ESD tracks with the ITS info
635 for (const AliHLTComponentBlockData* pBlock=GetFirstInputBlock(kAliHLTDataTypeTrack|kAliHLTDataOriginITS);
636 pBlock!=NULL; pBlock=GetNextInputBlock()) {
637 fBenchmark.AddInput(pBlock->fSize);
638 vector<AliHLTGlobalBarrelTrack> tracks;
639 if ((iResult=AliHLTGlobalBarrelTrack::ConvertTrackDataArray(reinterpret_cast<const AliHLTTracksData*>(pBlock->fPtr), pBlock->fSize, tracks))>0) {
640 for (vector<AliHLTGlobalBarrelTrack>::iterator element=tracks.begin();
641 element!=tracks.end(); element++) {
642 int tpcID=element->TrackID();
643 // the ITS tracker assigns the TPC track used as seed for a certain track to
645 if( tpcID<0 || tpcID>=pESD->GetNumberOfTracks()) continue;
647 if( mcLabelsITS.find(element->TrackID())!=mcLabelsITS.end() )
648 mcLabel = mcLabelsITS[element->TrackID()];
649 AliESDtrack *tESD = pESD->GetTrack( tpcID );
651 // the labels for the TPC and ITS tracking params can be different, e.g.
652 // there can be a decay. The ITS label should then be the better one, the
653 // TPC label is saved in a member of AliESDtrack
655 // upadte only if the ITS label is available, otherwise keep TPC label
656 element->SetLabel( mcLabel );
658 // bugfix https://savannah.cern.ch/bugs/?69713
659 element->SetLabel( tESD->GetLabel() );
661 tESD->UpdateTrackParams( &(*element), AliESDtrack::kITSin );
663 // TODO: add a proper refit
664 //tESD->UpdateTrackParams( &(*element), AliESDtrack::kTPCrefit );
669 // update with vertices and vertex-fitted tracks
670 // output of the GlobalVertexerComponent
671 for (const AliHLTComponentBlockData* pBlock=GetFirstInputBlock(kAliHLTDataTypeGlobalVertexer);
672 pBlock!=NULL; pBlock=GetNextInputBlock()) {
673 fBenchmark.AddInput(pBlock->fSize);
674 AliHLTGlobalVertexerComponent::FillESD( pESD, reinterpret_cast<AliHLTGlobalVertexerComponent::AliHLTGlobalVertexerData* >(pBlock->fPtr) );
677 // update with vertices and vertex-fitted tracks
678 // output of PrimaryVertexer and V0Finder components
680 TObject* pBase = (TObject*)GetFirstInputObject(kAliHLTDataTypeKFVertex | kAliHLTDataOriginOut);
682 AliKFVertex* kfVertex = dynamic_cast<AliKFVertex *>(pBase);
684 const AliHLTComponentBlockData* pP = GetFirstInputBlock(kAliHLTDataTypePrimaryFinder | kAliHLTDataOriginOut);
685 if (pP && pP->fSize && pP->fPtr) {
686 const AliHLTComponentBlockData* pV0 = GetFirstInputBlock(kAliHLTDataTypeV0Finder | kAliHLTDataOriginOut);
687 if (pV0 && pV0->fPtr && pInputESD && pInputESD->GetNumberOfV0s()>0) {
688 const int* v0s = static_cast<const int*>(pV0->fPtr);
689 HLTWarning("V0 array already filled from the input esd block, additional filling from V0 block of %d entries might cause inconsistent content", v0s[0]);
691 AliHLTVertexFinderBase::FillESD(pESD, kfVertex, pP->fPtr, pV0?pV0->fPtr:NULL);
693 HLTWarning("Problem with primary finder's data block");
695 HLTWarning("primary vertex block of wrong type, expecting AliKFVertex instead of %s", pBase->GetName());
698 // throw an error if there is a V0 data block which can not be handled without
699 // the AliKFVertex object
700 if (GetFirstInputBlock(kAliHLTDataTypeV0Finder | kAliHLTDataOriginOut)!=NULL) {
701 ALIHLTERRORGUARD(1, "missing AliKFVertex object ignoring V0 data block of type %s",
702 DataType2Text(kAliHLTDataTypeV0Finder|kAliHLTDataOriginOut).c_str());
706 // Fill DCA parameters for TPC tracks
707 // TODO 2010-07-12 this propagates also the TPC inner param to beamline
708 // sounds not very reasonable
709 // https://savannah.cern.ch/bugs/index.php?69873
710 for (int i=0; i<pESD->GetNumberOfTracks(); i++) {
711 if (!pESD->GetTrack(i) ||
712 !pESD->GetTrack(i)->GetTPCInnerParam() ) continue;
713 pESD->GetTrack(i)->RelateToVertexTPC(pESD->GetPrimaryVertexTracks(), fSolenoidBz, 1000 );
716 // loop over all tracks and set the TPC refit flag by updating with the
717 // original TPC inner parameter if not yet set
718 // TODO: replace this by a proper refit
719 // code is comented for the moment as it does not fully solve the problems with
721 // - would set the main parameters to the TPC inner wall again, or
722 // - changes the inner param if the parameters are propagated, so we loose the track
723 // reference point for the display
724 // with the current sequence we have the latter case as the DCA operations above
725 // change the TPC inner parameters
727 for (int i=0; i<pESD->GetNumberOfTracks(); i++) {
728 if (!pESD->GetTrack(i) ||
729 !pESD->GetTrack(i)->GetTPCInnerParam() ||
730 pESD->GetTrack(i)->IsOn(AliESDtrack::kTPCrefit)) continue;
731 AliESDtrack* tESD=pESD->GetTrack(i);
732 AliHLTGlobalBarrelTrack inner(*tESD->GetTPCInnerParam());
733 inner.SetLabel(tESD->GetLabel());
734 tESD->UpdateTrackParams(&inner, AliESDtrack::kTPCrefit);
738 // 4. convert the HLT TRD tracks to ESD tracks
739 for (const AliHLTComponentBlockData* pBlock=GetFirstInputBlock(kAliHLTDataTypeTrack | kAliHLTDataOriginTRD);
740 pBlock!=NULL; pBlock=GetNextInputBlock()) {
741 fBenchmark.AddInput(pBlock->fSize);
742 vector<AliHLTGlobalBarrelTrack> tracks;
743 if ((iResult=AliHLTGlobalBarrelTrack::ConvertTrackDataArray(reinterpret_cast<const AliHLTTracksData*>(pBlock->fPtr), pBlock->fSize, tracks))>0) {
744 for (vector<AliHLTGlobalBarrelTrack>::iterator element=tracks.begin();
745 element!=tracks.end(); element++) {
747 Double_t TRDpid[AliPID::kSPECIES], eProb(0.2), restProb((1-eProb)/(AliPID::kSPECIES-1)); //eprob(element->GetTRDpid...);
748 for(Int_t i=0; i<AliPID::kSPECIES; i++){
750 case AliPID::kElectron: TRDpid[AliPID::kElectron]=eProb; break;
751 default: TRDpid[i]=restProb; break;
756 iotrack.UpdateTrackParams(&(*element),AliESDtrack::kTRDout);
757 iotrack.SetStatus(AliESDtrack::kTRDin);
758 iotrack.SetTRDpid(TRDpid);
760 pESD->AddTrack(&iotrack);
761 if (fVerbosity>0) element->Print();
763 HLTInfo("converted %d track(s) to AliESDtrack and added to ESD", tracks.size());
765 } else if (iResult<0) {
766 HLTError("can not extract tracks from data block of type %s (specification %08x) of size %d: error %d",
767 DataType2Text(pBlock->fDataType).c_str(), pBlock->fSpecification, pBlock->fSize, iResult);
770 for (const AliHLTComponentBlockData* pBlock=GetFirstInputBlock(kAliHLTDataTypeCaloCluster | kAliHLTDataOriginAny); pBlock!=NULL; pBlock=GetNextInputBlock())
772 fBenchmark.AddInput(pBlock->fSize);
773 AliHLTCaloClusterHeaderStruct *caloClusterHeaderPtr = reinterpret_cast<AliHLTCaloClusterHeaderStruct*>(pBlock->fPtr);
775 HLTDebug("%d HLT clusters from spec: 0x%X", caloClusterHeaderPtr->fNClusters, pBlock->fSpecification);
777 //AliHLTCaloClusterReader reader;
778 //reader.SetMemory(caloClusterHeaderPtr);
780 AliHLTESDCaloClusterMaker clusterMaker;
782 int nClusters = clusterMaker.FillESD(pESD, caloClusterHeaderPtr);
784 HLTInfo("converted %d cluster(s) to AliESDCaloCluster and added to ESD", nClusters);
788 // 5) Add Trigger Detectors
791 // FIXME: the size of all input blocks can be added in one loop
792 for (const AliHLTComponentBlockData* pBlock=GetFirstInputBlock(kAliHLTDataTypeESDContent|kAliHLTDataOriginVZERO);
793 pBlock!=NULL; pBlock=GetNextInputBlock()) {
794 fBenchmark.AddInput(pBlock->fSize);
797 for ( const TObject *pObject = GetFirstInputObject(kAliHLTDataTypeESDContent|kAliHLTDataOriginVZERO);
798 pObject != NULL; pObject = GetNextInputObject() ) {
799 AliESDVZERO *esdVZERO = dynamic_cast<AliESDVZERO*>(const_cast<TObject*>( pObject ) );
801 pESD->SetVZEROData( esdVZERO );
804 ALIHLTERRORGUARD(1, "input object of data type %s is not of class AliESDVZERO",
805 DataType2Text(kAliHLTDataTypeESDContent|kAliHLTDataOriginVZERO).c_str());
809 // FIXME: the size of all input blocks can be added in one loop
810 for (const AliHLTComponentBlockData* pBlock=GetFirstInputBlock(kAliHLTDataTypeESDContent|kAliHLTDataOriginZDC);
811 pBlock!=NULL; pBlock=GetNextInputBlock()) {
812 fBenchmark.AddInput(pBlock->fSize);
814 for ( const TObject *pObject = GetFirstInputObject(kAliHLTDataTypeESDContent|kAliHLTDataOriginZDC);
815 pObject != NULL; pObject = GetNextInputObject() ) {
816 AliESDZDC *esdZDC = dynamic_cast<AliESDZDC*>(const_cast<TObject*>( pObject ) );
818 #ifndef HAVE_NOT_ALIZDCRECONSTRUCTOR_r43770
819 pESD->SetZDCData( esdZDC );
821 ALIHLTERRORGUARD(1, "Processing of ZDC data requires AliRoot r43770m skipping data block of type %s",
822 DataType2Text(kAliHLTDataTypeESDContent|kAliHLTDataOriginZDC).c_str());
826 ALIHLTERRORGUARD(1, "input object of data type %s is not of class AliESDZDC",
827 DataType2Text(kAliHLTDataTypeESDContent|kAliHLTDataOriginZDC).c_str());
831 // Add tracks and clusters from MUON.
832 for( const AliHLTComponentBlockData *i= GetFirstInputBlock(kAliHLTAnyDataType | kAliHLTDataOriginMUON); i!=NULL; i=GetNextInputBlock() ){
833 fBenchmark.AddInput(i->fSize);
836 for (const TObject* obj = GetFirstInputObject(kAliHLTAnyDataType | kAliHLTDataOriginMUON);
838 obj = GetNextInputObject()
841 const TClonesArray* tracklist = NULL;
842 const TClonesArray* clusterlist = NULL;
843 if (obj->IsA() == AliESDEvent::Class())
845 const AliESDEvent* event = static_cast<const AliESDEvent*>(obj);
846 HLTDebug("Received a MUON ESD with specification: 0x%X", GetSpecification(obj));
847 if (event->GetList() == NULL) continue;
848 tracklist = dynamic_cast<const TClonesArray*>(event->GetList()->FindObject("MuonTracks"));
849 if (tracklist == NULL) continue;
850 clusterlist = dynamic_cast<const TClonesArray*>(event->GetList()->FindObject("MuonClusters"));
851 if (clusterlist == NULL) continue;
853 else if (obj->IsA() == TClonesArray::Class())
855 if (!strcmp(obj->GetName(), "MuonTracks")) {
856 tracklist = static_cast<const TClonesArray*>(obj);
857 HLTDebug("Received a MUON TClonesArray of tracks with specification: 0x%X", GetSpecification(obj));
859 clusterlist = static_cast<const TClonesArray*>(obj);
860 HLTDebug("Received a MUON TClonesArray of clusters with specification: 0x%X", GetSpecification(obj));
865 // Cannot handle this object type.
870 HLTDebug("Received %d MUON tracks.", tracklist->GetEntriesFast());
871 if (tracklist->GetEntriesFast() > 0)
873 const AliESDMuonTrack* track = dynamic_cast<const AliESDMuonTrack*>(tracklist->UncheckedAt(0));
876 HLTError(Form("%s from MUON does not contain AliESDMuonTrack objects.", obj->ClassName()));
880 for (Int_t i = 0; i < tracklist->GetEntriesFast(); ++i)
882 AliESDMuonTrack* track = pESD->NewMuonTrack();
883 *track = *(static_cast<const AliESDMuonTrack*>(tracklist->UncheckedAt(i)));
888 HLTDebug("Received %d MUON clusters.", clusterlist->GetEntriesFast());
889 if (clusterlist->GetEntriesFast() > 0)
891 const AliESDMuonCluster* cluster = dynamic_cast<const AliESDMuonCluster*>(clusterlist->UncheckedAt(0));
894 HLTError(Form("%s from MUON does not contain AliESDMuonCluster objects.", obj->ClassName()));
898 for (Int_t i = 0; i < clusterlist->GetEntriesFast(); ++i)
900 AliESDMuonCluster* cluster = pESD->NewMuonCluster();
901 *cluster = *(static_cast<const AliESDMuonCluster*>(clusterlist->UncheckedAt(i)));
906 if (iAddedDataBlocks>0 && pTree) {
913 if (iResult>=0) iResult=iAddedDataBlocks;
920 void AliHLTGlobalEsdConverterComponent::FillBenchmarkHistos(Double_t *statistics, TString */*names*/){
923 // cout<<"Now writing benchmarks to " << fBenchmarkHistosFilename <<endl<<endl;
925 TFile *f = TFile::Open(fBenchmarkHistosFilename,"UPDATE");
926 THnSparseD *s = (THnSparseD*)f->Get("benchmarkInformation");
927 TNamed *t = (TNamed*)f->Get("time");
930 HLTWarning( "Benchmark Histograms not available!" );
938 histosList.SaveAs(fBenchmarkHistosFilename);