3 /** @file AliHLTTPCEsdWriterComponent.cxx
4 @author Matthias Richter
6 @brief Writer component to store tracks of the HLT TPC conformal
7 mapping tracker in the AliESD format
10 #include "AliHLTTPCEsdWriterComponent.h"
13 #include "AliHLTTPCTrack.h"
14 #include "AliHLTTPCTrackArray.h"
15 #include "AliHLTTPCTrackletDataFormat.h"
16 #include "AliHLTTPCDefinitions.h"
18 /** global instance for component registration */
19 AliHLTTPCEsdWriterComponent gTPCEsdWriter;
21 /** ROOT macro for the implementation of ROOT specific class methods */
22 ClassImp(AliHLTTPCEsdWriterComponent)
24 AliHLTTPCEsdWriterComponent::AliHLTTPCEsdWriterComponent()
31 AliHLTTPCEsdWriterComponent::~AliHLTTPCEsdWriterComponent()
35 int AliHLTTPCEsdWriterComponent::InitWriter()
40 fTree = new TTree("esdTree", "Tree with HLT ESD objects");
42 fTree->Branch("ESD", "AliESD", &fESD);
53 int AliHLTTPCEsdWriterComponent::CloseWriter()
57 WriteObject(kAliHLTVoidEventID, fTree);
62 HLTWarning("not initialized");
64 AliHLTRootFileWriterComponent::CloseWriter();
67 int AliHLTTPCEsdWriterComponent::DumpEvent( const AliHLTComponentEventData& evtData,
68 const AliHLTComponentBlockData* blocks,
69 AliHLTComponentTriggerData& trigData )
78 const AliHLTComponentBlockData* iter = NULL;
79 AliHLTTPCTrackArray* tracks=NULL;
80 AliHLTTPCTrackletData* inPtr=NULL;
82 for (int ndx=0; ndx<evtData.fBlockCnt && iResult>=0; ndx++) {
84 if ( iter->fDataType == AliHLTTPCDefinitions::gkTrackSegmentsDataType ) {
86 tracks=new AliHLTTPCTrackArray;
88 inPtr=(AliHLTTPCTrackletData*)iter->fPtr;
89 HLTDebug("reading block %d: %d tracklets", ndx, inPtr->fTrackletCnt);
90 tracks->FillTracks(inPtr->fTrackletCnt, inPtr->fTracklets);
91 if ((iResult=Tracks2ESD(tracks, pESD))>=0) {
98 HLTWarning("can not process more than one track segment data block, "
99 "please put a track merger in between");
100 break; // don't print the warning again
115 int AliHLTTPCEsdWriterComponent::ScanArgument(int argc, const char** argv)
117 int iResult=AliHLTRootFileWriterComponent::ScanArgument(argc, argv);
121 int AliHLTTPCEsdWriterComponent::Tracks2ESD(AliHLTTPCTrackArray* pTracks, AliESD* pESD)
124 if (pTracks && pESD) {
125 HLTDebug("converting %d tracks from track array", pTracks->GetNTracks());
126 for (int i=0; i<pTracks->GetNTracks() && iResult>=0; i++) {
127 AliHLTTPCTrack* pTrack=(*pTracks)[i];
129 int iLocal=pTrack->Convert2AliKalmanTrack();
132 iotrack.UpdateTrackParams(pTrack,AliESDtrack::kTPCin);
133 iotrack.SetTPCPoints(pTrack->GetPoints());
134 pESD->AddTrack(&iotrack);
136 HLTError("conversion to AliKalmanTrack failed for track %d of %d", i, pTracks->GetNTracks());
139 HLTError("internal missmatch in array");