3 /**************************************************************************
4 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
6 * Authors: Matthias Richter <Matthias.Richter@ift.uib.no> *
7 * for The ALICE Off-line Project. *
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 **************************************************************************/
18 /** @file AliHLTTPCEsdWriterComponent.cxx
19 @author Matthias Richter
21 @brief Writer component to store tracks of the HLT TPC conformal
22 mapping tracker in the AliESD format
25 #include "AliHLTTPCEsdWriterComponent.h"
28 #include "AliHLTTPCTrack.h"
29 #include "AliHLTTPCTrackArray.h"
30 #include "AliHLTTPCTrackletDataFormat.h"
31 #include "AliHLTTPCDefinitions.h"
33 /** global instance for component registration */
34 AliHLTTPCEsdWriterComponent gTPCEsdWriter;
36 /** ROOT macro for the implementation of ROOT specific class methods */
37 ClassImp(AliHLTTPCEsdWriterComponent)
39 AliHLTTPCEsdWriterComponent::AliHLTTPCEsdWriterComponent()
44 // see header file for class documentation
46 // refer to README to build package
48 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
51 AliHLTTPCEsdWriterComponent::~AliHLTTPCEsdWriterComponent()
53 // see header file for class documentation
56 int AliHLTTPCEsdWriterComponent::InitWriter()
58 // see header file for class documentation
62 fTree = new TTree("esdTree", "Tree with HLT ESD objects");
64 fTree->Branch("ESD", "AliESD", &fESD);
75 int AliHLTTPCEsdWriterComponent::CloseWriter()
77 // see header file for class documentation
80 WriteObject(kAliHLTVoidEventID, fTree);
85 HLTWarning("not initialized");
87 iResult=AliHLTRootFileWriterComponent::CloseWriter();
91 int AliHLTTPCEsdWriterComponent::DumpEvent( const AliHLTComponentEventData& evtData,
92 const AliHLTComponentBlockData* blocks,
93 AliHLTComponentTriggerData& trigData )
95 // see header file for class documentation
103 const AliHLTComponentBlockData* iter = NULL;
104 AliHLTTPCTrackletData* inPtr=NULL;
107 for (int ndx=0; ndx<(int)evtData.fBlockCnt && iResult>=0; ndx++) {
109 if ( (bIsTrackSegs=(iter->fDataType == AliHLTTPCDefinitions::fgkTrackSegmentsDataType))==1 ||
110 iter->fDataType == AliHLTTPCDefinitions::fgkTracksDataType ) {
111 Int_t minslice=AliHLTTPCDefinitions::GetMinSliceNr(iter->fSpecification);
112 Int_t maxslice=AliHLTTPCDefinitions::GetMaxSliceNr(iter->fSpecification);
113 if (bIsTrackSegs==0) {
114 // slice parameter and data specification ignored, tracks already in global coordinates
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");
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) {
131 HLTError("invalid sector number");
149 int AliHLTTPCEsdWriterComponent::ScanArgument(int argc, const char** argv)
151 // see header file for class documentation
152 int iResult=AliHLTRootFileWriterComponent::ScanArgument(argc, argv);
156 int AliHLTTPCEsdWriterComponent::Tracks2ESD(AliHLTTPCTrackArray* pTracks, AliESD* pESD)
158 // see header file for class documentation
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];
165 //HLTDebug("convert track %d", i);
167 int iLocal=pTrack->Convert2AliKalmanTrack();
170 iotrack.UpdateTrackParams(pTrack,AliESDtrack::kTPCin);
171 iotrack.SetTPCPoints(pTrack->GetPoints());
172 pESD->AddTrack(&iotrack);
174 HLTError("conversion to AliKalmanTrack failed for track %d of %d", i, pTracks->GetNTracks());
177 HLTError("internal missmatch in array");