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"
29 #include "AliHLTTPCTrack.h"
30 #include "AliHLTTPCTrackArray.h"
31 #include "AliHLTTPCTrackletDataFormat.h"
32 #include "AliHLTTPCDefinitions.h"
34 /** global instance for component registration */
35 AliHLTTPCEsdWriterComponent gTPCEsdWriter;
37 /** ROOT macro for the implementation of ROOT specific class methods */
38 ClassImp(AliHLTTPCEsdWriterComponent)
40 AliHLTTPCEsdWriterComponent::AliHLTTPCEsdWriterComponent()
45 // see header file for class documentation
47 // refer to README to build package
49 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
52 AliHLTTPCEsdWriterComponent::~AliHLTTPCEsdWriterComponent()
54 // see header file for class documentation
57 int AliHLTTPCEsdWriterComponent::InitWriter()
59 // see header file for class documentation
63 fTree = new TTree("esdTree", "Tree with HLT ESD objects");
65 fTree->Branch("ESD", "AliESD", &fESD);
76 int AliHLTTPCEsdWriterComponent::CloseWriter()
78 // see header file for class documentation
81 WriteObject(kAliHLTVoidEventID, fTree);
86 HLTWarning("not initialized");
88 iResult=AliHLTRootFileWriterComponent::CloseWriter();
92 int AliHLTTPCEsdWriterComponent::DumpEvent( const AliHLTComponentEventData& evtData,
93 const AliHLTComponentBlockData* blocks,
94 AliHLTComponentTriggerData& trigData )
96 // see header file for class documentation
104 const AliHLTComponentBlockData* iter = NULL;
105 AliHLTTPCTrackletData* inPtr=NULL;
108 for (int ndx=0; ndx<(int)evtData.fBlockCnt && iResult>=0; ndx++) {
110 if ( (bIsTrackSegs=(iter->fDataType == AliHLTTPCDefinitions::fgkTrackSegmentsDataType))==1 ||
111 iter->fDataType == AliHLTTPCDefinitions::fgkTracksDataType ) {
112 Int_t minslice=AliHLTTPCDefinitions::GetMinSliceNr(iter->fSpecification);
113 Int_t maxslice=AliHLTTPCDefinitions::GetMaxSliceNr(iter->fSpecification);
114 if (bIsTrackSegs==0) {
115 // slice parameter and data specification ignored, tracks already in global coordinates
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");
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) {
132 HLTError("invalid sector number");
150 int AliHLTTPCEsdWriterComponent::ScanArgument(int argc, const char** argv)
152 // see header file for class documentation
153 int iResult=AliHLTRootFileWriterComponent::ScanArgument(argc, argv);
157 int AliHLTTPCEsdWriterComponent::Tracks2ESD(AliHLTTPCTrackArray* pTracks, AliESD* pESD)
159 // see header file for class documentation
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];
166 //HLTDebug("convert track %d", i);
168 int iLocal=pTrack->Convert2AliKalmanTrack();
171 iotrack.UpdateTrackParams(pTrack,AliESDtrack::kTPCin);
172 iotrack.SetTPCPoints(pTrack->GetPoints());
173 pESD->AddTrack(&iotrack);
175 HLTError("conversion to AliKalmanTrack failed for track %d of %d", i, pTracks->GetNTracks());
178 HLTError("internal missmatch in array");