]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/TPCLib/AliHLTTPCEsdWriterComponent.cxx
documentation
[u/mrichter/AliRoot.git] / HLT / TPCLib / AliHLTTPCEsdWriterComponent.cxx
CommitLineData
3cde846d 1// @(#) $Id$
2
2a083ac4 3/**************************************************************************
9be2600f 4 * This file is property of and copyright by the ALICE HLT Project *
5 * ALICE Experiment at CERN, All rights reserved. *
2a083ac4 6 * *
9be2600f 7 * Primary Authors: Matthias Richter <Matthias.Richter@ift.uib.no> *
8 * for The ALICE HLT Project. *
2a083ac4 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
3cde846d 19/** @file AliHLTTPCEsdWriterComponent.cxx
20 @author Matthias Richter
21 @date
22 @brief Writer component to store tracks of the HLT TPC conformal
23 mapping tracker in the AliESD format
24
25 */
26#include "AliHLTTPCEsdWriterComponent.h"
27#include "AliESD.h"
28#include "TTree.h"
29#include "AliHLTTPCTrack.h"
30#include "AliHLTTPCTrackArray.h"
31#include "AliHLTTPCTrackletDataFormat.h"
32#include "AliHLTTPCDefinitions.h"
33
34/** global instance for component registration */
35AliHLTTPCEsdWriterComponent gTPCEsdWriter;
36
37/** ROOT macro for the implementation of ROOT specific class methods */
38ClassImp(AliHLTTPCEsdWriterComponent)
39
40AliHLTTPCEsdWriterComponent::AliHLTTPCEsdWriterComponent()
41 :
42 fTree(NULL),
43 fESD(NULL)
44{
2a083ac4 45 // see header file for class documentation
46 // or
47 // refer to README to build package
48 // or
49 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
3cde846d 50}
51
52AliHLTTPCEsdWriterComponent::~AliHLTTPCEsdWriterComponent()
53{
2a083ac4 54 // see header file for class documentation
3cde846d 55}
56
57int AliHLTTPCEsdWriterComponent::InitWriter()
58{
2a083ac4 59 // see header file for class documentation
3cde846d 60 int iResult=0;
61 fESD = new AliESD;
62 if (fESD) {
63 fTree = new TTree("esdTree", "Tree with HLT ESD objects");
64 if (fTree) {
65 fTree->Branch("ESD", "AliESD", &fESD);
66 }
67 delete fESD;
68 fESD=NULL;
69 }
70 if (fTree==NULL) {
71 iResult=-ENOMEM;
72 }
73 return iResult;
74}
75
76int AliHLTTPCEsdWriterComponent::CloseWriter()
77{
2a083ac4 78 // see header file for class documentation
3cde846d 79 int iResult=0;
80 if (fTree) {
81 WriteObject(kAliHLTVoidEventID, fTree);
82 TTree* pTree=fTree;
83 fTree=NULL;
84 delete pTree;
85 } else {
86 HLTWarning("not initialized");
87 }
2a083ac4 88 iResult=AliHLTRootFileWriterComponent::CloseWriter();
89 return iResult;
3cde846d 90}
91
92int AliHLTTPCEsdWriterComponent::DumpEvent( const AliHLTComponentEventData& evtData,
93 const AliHLTComponentBlockData* blocks,
94 AliHLTComponentTriggerData& trigData )
95{
2a083ac4 96 // see header file for class documentation
3cde846d 97 int iResult=0;
98 TTree* pTree=fTree;
99 if (pTree) {
100 fESD = new AliESD;
101 if (fESD) {
102 AliESD* pESD=fESD;
103
104 const AliHLTComponentBlockData* iter = NULL;
3cde846d 105 AliHLTTPCTrackletData* inPtr=NULL;
de554e07 106 int bIsTrackSegs=0;
3cde846d 107
2a083ac4 108 for (int ndx=0; ndx<(int)evtData.fBlockCnt && iResult>=0; ndx++) {
3cde846d 109 iter = blocks+ndx;
96bda103 110 if ( (bIsTrackSegs=(iter->fDataType == AliHLTTPCDefinitions::fgkTrackSegmentsDataType))==1 ||
111 iter->fDataType == AliHLTTPCDefinitions::fgkTracksDataType ) {
4fdaad1e 112 Int_t minslice=AliHLTTPCDefinitions::GetMinSliceNr(iter->fSpecification);
113 Int_t maxslice=AliHLTTPCDefinitions::GetMaxSliceNr(iter->fSpecification);
de554e07 114 if (bIsTrackSegs==0) {
115 // slice parameter and data specification ignored, tracks already in global coordinates
116 minslice=0;
117 maxslice=0;
118 }
4fdaad1e 119 //HLTDebug("dataspec %#x minslice %d", iter->fSpecification, minslice);
120 if (minslice >=0 && minslice<36) {
121 if (minslice!=maxslice) {
122 HLTWarning("data from multiple sectors in one block: "
123 "possible missmatch in treatment of local coordinate system");
124 }
125 AliHLTTPCTrackArray tracks;
126 inPtr=(AliHLTTPCTrackletData*)iter->fPtr;
127 HLTDebug("reading block %d (slice %d): %d tracklets", ndx, minslice, inPtr->fTrackletCnt);
128 tracks.FillTracks(inPtr->fTrackletCnt, inPtr->fTracklets, minslice, 0/*don't rotate*/);
129 if ((iResult=Tracks2ESD(&tracks, pESD))>=0) {
3cde846d 130 }
131 } else {
4fdaad1e 132 HLTError("invalid sector number");
133 iResult=-EBADF;
3cde846d 134 }
135 }
136 }
4fdaad1e 137 if (iResult>=0) {
138 pTree->Fill();
139 }
3cde846d 140
141 fESD=NULL;
142 delete pESD;
143 } else {
144 iResult=-ENOMEM;
145 }
146 }
147 return iResult;
148}
149
150int AliHLTTPCEsdWriterComponent::ScanArgument(int argc, const char** argv)
151{
2a083ac4 152 // see header file for class documentation
3cde846d 153 int iResult=AliHLTRootFileWriterComponent::ScanArgument(argc, argv);
154 return iResult;
155}
156
157int AliHLTTPCEsdWriterComponent::Tracks2ESD(AliHLTTPCTrackArray* pTracks, AliESD* pESD)
158{
2a083ac4 159 // see header file for class documentation
3cde846d 160 int iResult=0;
161 if (pTracks && pESD) {
162 HLTDebug("converting %d tracks from track array", pTracks->GetNTracks());
163 for (int i=0; i<pTracks->GetNTracks() && iResult>=0; i++) {
164 AliHLTTPCTrack* pTrack=(*pTracks)[i];
165 if (pTrack) {
04dbc9e4 166 //HLTDebug("convert track %d", i);
167 //pTrack->Print();
3cde846d 168 int iLocal=pTrack->Convert2AliKalmanTrack();
169 if (iLocal>=0) {
170 AliESDtrack iotrack;
171 iotrack.UpdateTrackParams(pTrack,AliESDtrack::kTPCin);
172 iotrack.SetTPCPoints(pTrack->GetPoints());
173 pESD->AddTrack(&iotrack);
174 } else {
175 HLTError("conversion to AliKalmanTrack failed for track %d of %d", i, pTracks->GetNTracks());
176 }
177 } else {
178 HLTError("internal missmatch in array");
179 iResult=-EFAULT;
180 }
181 }
182
183 } else {
184 iResult=-EINVAL;
185 }
186 return iResult;
187}