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