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 AliHLTTPCEsdWriterComponent.cxx
20 @author Matthias Richter
22 @brief Writer component to store tracks of the HLT TPC conformal
23 mapping tracker in the AliESD format
26 #include "AliHLTTPCEsdWriterComponent.h"
27 #include "AliESDEvent.h"
28 #include "AliESDtrack.h"
30 #include "AliHLTTPCTrack.h"
31 #include "AliHLTTPCTrackArray.h"
32 #include "AliHLTTPCTrackletDataFormat.h"
33 #include "AliHLTTPCDefinitions.h"
35 /** global instance for component registration */
36 AliHLTTPCEsdWriterComponent gTPCEsdWriter;
38 /** ROOT macro for the implementation of ROOT specific class methods */
39 ClassImp(AliHLTTPCEsdWriterComponent)
41 AliHLTTPCEsdWriterComponent::AliHLTTPCEsdWriterComponent()
46 // see header file for class documentation
48 // refer to README to build package
50 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
53 AliHLTTPCEsdWriterComponent::AliHLTTPCEsdWriterComponent(const AliHLTTPCEsdWriterComponent&)
60 AliHLTTPCEsdWriterComponent& AliHLTTPCEsdWriterComponent::operator=(const AliHLTTPCEsdWriterComponent&)
65 AliHLTTPCEsdWriterComponent::~AliHLTTPCEsdWriterComponent()
67 // see header file for class documentation
70 int AliHLTTPCEsdWriterComponent::InitWriter()
72 // see header file for class documentation
74 fESD = new AliESDEvent;
76 fESD->CreateStdContent();
77 fTree = new TTree("esdTree", "Tree with HLT ESD objects");
79 fESD->WriteToTree(fTree);
88 int AliHLTTPCEsdWriterComponent::CloseWriter()
90 // see header file for class documentation
93 WriteObject(kAliHLTVoidEventID, fTree);
98 HLTWarning("not initialized");
100 iResult=AliHLTRootFileWriterComponent::CloseWriter();
104 int AliHLTTPCEsdWriterComponent::DumpEvent( const AliHLTComponentEventData& evtData,
105 const AliHLTComponentBlockData* blocks,
106 AliHLTComponentTriggerData& trigData )
108 // see header file for class documentation
113 AliESDEvent* pESD=fESD;
115 const AliHLTComponentBlockData* iter = NULL;
116 AliHLTTPCTrackletData* inPtr=NULL;
119 for (int ndx=0; ndx<(int)evtData.fBlockCnt && iResult>=0; ndx++) {
121 if ( (bIsTrackSegs=(iter->fDataType == AliHLTTPCDefinitions::fgkTrackSegmentsDataType))==1 ||
122 iter->fDataType == AliHLTTPCDefinitions::fgkTracksDataType ) {
123 Int_t minslice=AliHLTTPCDefinitions::GetMinSliceNr(iter->fSpecification);
124 Int_t maxslice=AliHLTTPCDefinitions::GetMaxSliceNr(iter->fSpecification);
125 if (bIsTrackSegs==0) {
126 // slice parameter and data specification ignored, tracks already in global coordinates
130 //HLTDebug("dataspec %#x minslice %d", iter->fSpecification, minslice);
131 if (minslice >=-1 && minslice<36) {
132 if (minslice!=maxslice) {
133 HLTWarning("data from multiple sectors in one block: "
134 "possible missmatch in treatment of local coordinate system");
136 AliHLTTPCTrackArray tracks;
137 inPtr=(AliHLTTPCTrackletData*)iter->fPtr;
138 HLTDebug("reading block %d (slice %d): %d tracklets", ndx, minslice, inPtr->fTrackletCnt);
139 tracks.FillTracks(inPtr->fTrackletCnt, inPtr->fTracklets, minslice, 0/*don't rotate*/);
140 if ((iResult=Tracks2ESD(&tracks, pESD))>=0) {
143 HLTError("invalid sector number");
160 int AliHLTTPCEsdWriterComponent::ScanArgument(int argc, const char** argv)
162 // see header file for class documentation
163 int iResult=AliHLTRootFileWriterComponent::ScanArgument(argc, argv);
167 int AliHLTTPCEsdWriterComponent::Tracks2ESD(AliHLTTPCTrackArray* pTracks, AliESDEvent* pESD)
169 // see header file for class documentation
171 if (pTracks && pESD) {
172 HLTDebug("converting %d tracks from track array", pTracks->GetNTracks());
173 for (int i=0; i<pTracks->GetNTracks() && iResult>=0; i++) {
174 AliHLTTPCTrack* pTrack=(*pTracks)[i];
176 //HLTDebug("convert track %d", i);
178 int iLocal=pTrack->Convert2AliKalmanTrack();
181 iotrack.UpdateTrackParams(pTrack,AliESDtrack::kTPCin);
182 iotrack.SetTPCPoints(pTrack->GetPoints());
183 pESD->AddTrack(&iotrack);
185 HLTError("conversion to AliKalmanTrack failed for track %d of %d", i, pTracks->GetNTracks());
188 HLTError("internal missmatch in array");