]>
Commit | Line | Data |
---|---|---|
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 | */ | |
37513ae4 | 26 | #include <cassert> |
3cde846d | 27 | #include "AliHLTTPCEsdWriterComponent.h" |
af885e0f | 28 | #include "AliESDEvent.h" |
d523f52c | 29 | #include "AliESDtrack.h" |
3cde846d | 30 | #include "TTree.h" |
31 | #include "AliHLTTPCTrack.h" | |
32 | #include "AliHLTTPCTrackArray.h" | |
33 | #include "AliHLTTPCTrackletDataFormat.h" | |
34 | #include "AliHLTTPCDefinitions.h" | |
37513ae4 | 35 | #include "AliHLTTPCTransform.h" |
3cde846d | 36 | |
37 | /** global instance for component registration */ | |
37513ae4 | 38 | AliHLTTPCEsdWriterComponent::AliWriter gTPCEsdWriter; |
39 | AliHLTTPCEsdWriterComponent::AliConverter gTPCEsdConverter; | |
3cde846d | 40 | |
41 | /** ROOT macro for the implementation of ROOT specific class methods */ | |
42 | ClassImp(AliHLTTPCEsdWriterComponent) | |
43 | ||
44 | AliHLTTPCEsdWriterComponent::AliHLTTPCEsdWriterComponent() | |
37513ae4 | 45 | { |
46 | // see header file for class documentation | |
47 | // or | |
48 | // refer to README to build package | |
49 | // or | |
50 | // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt | |
51 | } | |
52 | ||
53 | AliHLTTPCEsdWriterComponent::~AliHLTTPCEsdWriterComponent() | |
54 | { | |
55 | // see header file for class documentation | |
56 | } | |
57 | ||
58 | AliHLTTPCEsdWriterComponent::AliWriter::AliWriter() | |
3cde846d | 59 | : |
60 | fTree(NULL), | |
37513ae4 | 61 | fESD(NULL), |
62 | fBase(new AliHLTTPCEsdWriterComponent) | |
3cde846d | 63 | { |
2a083ac4 | 64 | // see header file for class documentation |
65 | // or | |
66 | // refer to README to build package | |
67 | // or | |
68 | // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt | |
3cde846d | 69 | } |
70 | ||
37513ae4 | 71 | AliHLTTPCEsdWriterComponent::AliWriter::~AliWriter() |
72 | { | |
73 | // see header file for class documentation | |
74 | if (fBase) delete fBase; | |
75 | fBase=NULL; | |
76 | } | |
77 | ||
78 | void AliHLTTPCEsdWriterComponent::AliWriter::GetInputDataTypes(AliHLTComponentDataTypeList& list) | |
3cde846d | 79 | { |
2a083ac4 | 80 | // see header file for class documentation |
37513ae4 | 81 | list.push_back(AliHLTTPCDefinitions::fgkTrackSegmentsDataType); |
3cde846d | 82 | } |
83 | ||
37513ae4 | 84 | int AliHLTTPCEsdWriterComponent::AliWriter::InitWriter() |
3cde846d | 85 | { |
2a083ac4 | 86 | // see header file for class documentation |
3cde846d | 87 | int iResult=0; |
af885e0f | 88 | fESD = new AliESDEvent; |
3cde846d | 89 | if (fESD) { |
76e61c6e | 90 | fESD->CreateStdContent(); |
3cde846d | 91 | fTree = new TTree("esdTree", "Tree with HLT ESD objects"); |
92 | if (fTree) { | |
af885e0f | 93 | fESD->WriteToTree(fTree); |
3cde846d | 94 | } |
3cde846d | 95 | } |
96 | if (fTree==NULL) { | |
97 | iResult=-ENOMEM; | |
98 | } | |
99 | return iResult; | |
100 | } | |
101 | ||
37513ae4 | 102 | int AliHLTTPCEsdWriterComponent::AliWriter::CloseWriter() |
3cde846d | 103 | { |
2a083ac4 | 104 | // see header file for class documentation |
3cde846d | 105 | int iResult=0; |
106 | if (fTree) { | |
107 | WriteObject(kAliHLTVoidEventID, fTree); | |
108 | TTree* pTree=fTree; | |
109 | fTree=NULL; | |
110 | delete pTree; | |
111 | } else { | |
112 | HLTWarning("not initialized"); | |
113 | } | |
2a083ac4 | 114 | iResult=AliHLTRootFileWriterComponent::CloseWriter(); |
115 | return iResult; | |
3cde846d | 116 | } |
117 | ||
37513ae4 | 118 | int AliHLTTPCEsdWriterComponent::AliWriter::DumpEvent( const AliHLTComponentEventData& evtData, |
3cde846d | 119 | const AliHLTComponentBlockData* blocks, |
5d2abf3b | 120 | AliHLTComponentTriggerData& /*trigData*/ ) |
3cde846d | 121 | { |
2a083ac4 | 122 | // see header file for class documentation |
3cde846d | 123 | int iResult=0; |
124 | TTree* pTree=fTree; | |
37513ae4 | 125 | assert(fBase); |
126 | if (pTree && fBase) { | |
3cde846d | 127 | if (fESD) { |
af885e0f | 128 | AliESDEvent* pESD=fESD; |
3cde846d | 129 | |
37513ae4 | 130 | iResult=fBase->ProcessBlocks(pTree, pESD, blocks, (int)evtData.fBlockCnt); |
131 | ||
132 | } else { | |
133 | iResult=-ENOMEM; | |
134 | } | |
135 | } | |
136 | return iResult; | |
137 | } | |
138 | ||
139 | int AliHLTTPCEsdWriterComponent::AliWriter::ScanArgument(int argc, const char** argv) | |
140 | { | |
141 | // see header file for class documentation | |
142 | int iResult=AliHLTRootFileWriterComponent::ScanArgument(argc, argv); | |
143 | return iResult; | |
144 | } | |
145 | ||
146 | int AliHLTTPCEsdWriterComponent::ProcessBlocks(TTree* pTree, AliESDEvent* pESD, | |
147 | const AliHLTComponentBlockData* blocks, | |
148 | int nBlocks, int* pMinSlice, | |
149 | int* pMaxSlice) | |
150 | { | |
151 | // see header file for class documentation | |
152 | int iResult=0; | |
153 | if (pTree && pESD && blocks) { | |
3cde846d | 154 | const AliHLTComponentBlockData* iter = NULL; |
3cde846d | 155 | AliHLTTPCTrackletData* inPtr=NULL; |
de554e07 | 156 | int bIsTrackSegs=0; |
3cde846d | 157 | |
37513ae4 | 158 | for (int ndx=0; ndx<nBlocks && iResult>=0; ndx++) { |
3cde846d | 159 | iter = blocks+ndx; |
96bda103 | 160 | if ( (bIsTrackSegs=(iter->fDataType == AliHLTTPCDefinitions::fgkTrackSegmentsDataType))==1 || |
161 | iter->fDataType == AliHLTTPCDefinitions::fgkTracksDataType ) { | |
4fdaad1e | 162 | Int_t minslice=AliHLTTPCDefinitions::GetMinSliceNr(iter->fSpecification); |
163 | Int_t maxslice=AliHLTTPCDefinitions::GetMaxSliceNr(iter->fSpecification); | |
de554e07 | 164 | if (bIsTrackSegs==0) { |
165 | // slice parameter and data specification ignored, tracks already in global coordinates | |
b09663cd | 166 | minslice=-1; |
167 | maxslice=-1; | |
37513ae4 | 168 | if (pMinSlice) *pMinSlice=0; |
169 | if (pMaxSlice) *pMaxSlice=AliHLTTPCTransform::GetNSlice()-1; | |
170 | } else { | |
171 | if (pMinSlice && (*pMinSlice==-1 || *pMinSlice>minslice)) *pMinSlice=minslice; | |
172 | if (pMaxSlice && (*pMaxSlice==-1 || *pMaxSlice<maxslice)) *pMaxSlice=maxslice; | |
de554e07 | 173 | } |
4fdaad1e | 174 | //HLTDebug("dataspec %#x minslice %d", iter->fSpecification, minslice); |
37513ae4 | 175 | if (minslice >=-1 && minslice<AliHLTTPCTransform::GetNSlice()) { |
4fdaad1e | 176 | if (minslice!=maxslice) { |
177 | HLTWarning("data from multiple sectors in one block: " | |
178 | "possible missmatch in treatment of local coordinate system"); | |
179 | } | |
180 | AliHLTTPCTrackArray tracks; | |
181 | inPtr=(AliHLTTPCTrackletData*)iter->fPtr; | |
182 | HLTDebug("reading block %d (slice %d): %d tracklets", ndx, minslice, inPtr->fTrackletCnt); | |
183 | tracks.FillTracks(inPtr->fTrackletCnt, inPtr->fTracklets, minslice, 0/*don't rotate*/); | |
184 | if ((iResult=Tracks2ESD(&tracks, pESD))>=0) { | |
3cde846d | 185 | } |
186 | } else { | |
4fdaad1e | 187 | HLTError("invalid sector number"); |
188 | iResult=-EBADF; | |
3cde846d | 189 | } |
190 | } | |
191 | } | |
4fdaad1e | 192 | if (iResult>=0) { |
193 | pTree->Fill(); | |
194 | } | |
3cde846d | 195 | |
37513ae4 | 196 | pESD->Reset(); |
197 | ||
198 | } else { | |
199 | iResult=-EINVAL; | |
3cde846d | 200 | } |
201 | return iResult; | |
202 | } | |
203 | ||
af885e0f | 204 | int AliHLTTPCEsdWriterComponent::Tracks2ESD(AliHLTTPCTrackArray* pTracks, AliESDEvent* pESD) |
3cde846d | 205 | { |
2a083ac4 | 206 | // see header file for class documentation |
3cde846d | 207 | int iResult=0; |
208 | if (pTracks && pESD) { | |
209 | HLTDebug("converting %d tracks from track array", pTracks->GetNTracks()); | |
210 | for (int i=0; i<pTracks->GetNTracks() && iResult>=0; i++) { | |
211 | AliHLTTPCTrack* pTrack=(*pTracks)[i]; | |
212 | if (pTrack) { | |
04dbc9e4 | 213 | //HLTDebug("convert track %d", i); |
214 | //pTrack->Print(); | |
3cde846d | 215 | int iLocal=pTrack->Convert2AliKalmanTrack(); |
216 | if (iLocal>=0) { | |
217 | AliESDtrack iotrack; | |
218 | iotrack.UpdateTrackParams(pTrack,AliESDtrack::kTPCin); | |
219 | iotrack.SetTPCPoints(pTrack->GetPoints()); | |
220 | pESD->AddTrack(&iotrack); | |
221 | } else { | |
222 | HLTError("conversion to AliKalmanTrack failed for track %d of %d", i, pTracks->GetNTracks()); | |
223 | } | |
224 | } else { | |
225 | HLTError("internal missmatch in array"); | |
226 | iResult=-EFAULT; | |
227 | } | |
228 | } | |
229 | ||
230 | } else { | |
231 | iResult=-EINVAL; | |
232 | } | |
233 | return iResult; | |
234 | } | |
37513ae4 | 235 | |
236 | AliHLTTPCEsdWriterComponent::AliConverter::AliConverter() | |
237 | : | |
238 | fBase(new AliHLTTPCEsdWriterComponent) | |
239 | { | |
240 | // see header file for class documentation | |
241 | // or | |
242 | // refer to README to build package | |
243 | // or | |
244 | // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt | |
245 | } | |
246 | ||
247 | AliHLTTPCEsdWriterComponent::AliConverter::~AliConverter() | |
248 | { | |
249 | // see header file for class documentation | |
250 | if (fBase) delete fBase; | |
251 | fBase=NULL; | |
252 | } | |
253 | ||
254 | void AliHLTTPCEsdWriterComponent::AliConverter::GetInputDataTypes(AliHLTComponentDataTypeList& list) | |
255 | { | |
256 | // see header file for class documentation | |
257 | list.push_back(AliHLTTPCDefinitions::fgkTrackSegmentsDataType); | |
258 | } | |
259 | ||
260 | AliHLTComponentDataType AliHLTTPCEsdWriterComponent::AliConverter::GetOutputDataType() | |
261 | { | |
262 | // see header file for class documentation | |
263 | return kAliHLTDataTypeESDTree; | |
264 | } | |
265 | ||
266 | void AliHLTTPCEsdWriterComponent::AliConverter::GetOutputDataSize(unsigned long& constBase, double& inputMultiplier) | |
267 | { | |
268 | // see header file for class documentation | |
269 | constBase=1000000; | |
270 | inputMultiplier=1.0; | |
271 | } | |
272 | ||
273 | int AliHLTTPCEsdWriterComponent::AliConverter::DoInit(int argc, const char** argv) | |
274 | { | |
275 | // see header file for class documentation | |
276 | return 0; | |
277 | } | |
278 | ||
279 | int AliHLTTPCEsdWriterComponent::AliConverter::DoDeinit() | |
280 | { | |
281 | // see header file for class documentation | |
282 | return 0; | |
283 | } | |
284 | ||
285 | int AliHLTTPCEsdWriterComponent::AliConverter::DoEvent(const AliHLTComponentEventData& evtData, | |
286 | const AliHLTComponentBlockData* blocks, | |
287 | AliHLTComponentTriggerData& /*trigData*/, | |
288 | AliHLTUInt8_t* /*outputPtr*/, | |
289 | AliHLTUInt32_t& /*size*/, | |
290 | AliHLTComponentBlockDataList& /*outputBlocks*/ ) | |
291 | { | |
292 | // see header file for class documentation | |
293 | int iResult=0; | |
294 | assert(fBase); | |
295 | AliESDEvent* pESD = new AliESDEvent; | |
296 | if (pESD && fBase) { | |
297 | pESD->CreateStdContent(); | |
298 | TTree* pTree = new TTree("esdTree", "Tree with HLT ESD objects"); | |
299 | if (pTree) { | |
300 | pESD->WriteToTree(pTree); | |
301 | ||
302 | if ((iResult=fBase->ProcessBlocks(pTree, pESD, blocks, (int)evtData.fBlockCnt))>=0) { | |
303 | // TODO: set the specification correctly | |
304 | iResult=PushBack(pTree, kAliHLTDataTypeESDTree|kAliHLTDataOriginTPC, 0); | |
305 | } | |
306 | delete pTree; | |
307 | } | |
308 | delete pESD; | |
309 | } | |
310 | return iResult; | |
311 | } | |
312 |