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: Gaute Ovrebekk <ovrebekk@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 AliHLTTPCTrackDumpComponent.cxx
20 @author Gaute Ovrebekk
22 @brief Special file writer converting TPC tracks input to ASCII. */
25 #include "AliHLTTPCTrackDumpComponent.h"
26 #include "AliHLTTPCTransform.h"
27 #include "AliHLTTPCTrackletDataFormat.h"
28 #include "AliHLTTPCDefinitions.h"
31 /** ROOT macro for the implementation of ROOT specific class methods */
32 ClassImp(AliHLTTPCTrackDumpComponent)
34 AliHLTTPCTrackDumpComponent::AliHLTTPCTrackDumpComponent()
38 // see header file for class documentation
40 // refer to README to build package
42 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
45 AliHLTTPCTrackDumpComponent::~AliHLTTPCTrackDumpComponent()
47 // see header file for class documentation
50 const char* AliHLTTPCTrackDumpComponent::GetComponentID()
52 // see header file for class documentation
53 return "TPCTrackDump";
56 void AliHLTTPCTrackDumpComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list)
58 // see header file for class documentation
60 list.push_back(AliHLTTPCDefinitions::fgkTrackSegmentsDataType);
61 list.push_back(AliHLTTPCDefinitions::fgkTracksDataType);
65 AliHLTComponent* AliHLTTPCTrackDumpComponent::Spawn()
67 // see header file for class documentation
68 return new AliHLTTPCTrackDumpComponent;
71 int AliHLTTPCTrackDumpComponent::InitWriter()
73 // see header file for class documentation
77 int AliHLTTPCTrackDumpComponent::ScanArgument(int /*argc*/, const char** /*argv*/)
79 // see header file for class documentation
85 if (bMissingParam) iResult=-EPROTO;
86 else if (iResult>=0) iResult=i;
91 int AliHLTTPCTrackDumpComponent::CloseWriter()
93 // see header file for class documentation
97 int AliHLTTPCTrackDumpComponent::DumpEvent( const AliHLTComponentEventData& evtData,
98 AliHLTComponentTriggerData& /*trigData*/ )
100 // see header file for class documentation
103 const AliHLTComponentBlockData* pDesc=NULL;
107 if ( GetFirstInputBlock( kAliHLTDataTypeSOR ) || GetFirstInputBlock( kAliHLTDataTypeEOR ) )
110 for (pDesc=GetFirstInputBlock(AliHLTTPCDefinitions::fgkTrackSegmentsDataType); pDesc!=NULL; pDesc=GetNextInputBlock(), blockno++) {
111 HLTDebug("event %Lu block %d: %s 0x%08x size %d", evtData.fEventID, blockno, DataType2Text(pDesc->fDataType).c_str(), pDesc->fSpecification, pDesc->fSize);
113 if(pDesc->fDataType!=AliHLTTPCDefinitions::fgkTrackSegmentsDataType){continue;}
115 iResult=PrintTrack(evtData,pDesc,TotalTracks);
118 for (pDesc=GetFirstInputBlock(AliHLTTPCDefinitions::fgkTracksDataType); pDesc!=NULL; pDesc=GetNextInputBlock(), blockno++) {
119 HLTDebug("event %Lu block %d: %s 0x%08x size %d", evtData.fEventID, blockno, DataType2Text(pDesc->fDataType).c_str(), pDesc->fSpecification, pDesc->fSize);
121 if(pDesc->fDataType!=AliHLTTPCDefinitions::fgkTracksDataType){continue;}
123 iResult=PrintTrack(evtData,pDesc,TotalTracks);
125 HLTInfo("TrackDump found %d Tracks", TotalTracks);
130 int AliHLTTPCTrackDumpComponent::PrintTrack(const AliHLTComponentEventData& evtData,const AliHLTComponentBlockData* bl,Int_t &nT){
132 AliHLTUInt8_t slice = AliHLTTPCDefinitions::GetMinSliceNr( *bl );
133 AliHLTUInt8_t patch = AliHLTTPCDefinitions::GetMinPatchNr( *bl );
136 int iResult=BuildFileName(evtData.fEventID, 0, bl->fDataType, 0, filename);
137 ios::openmode filemode=(ios::openmode)0;
138 if (fCurrentFileName.CompareTo(filename)==0) {
141 fCurrentFileName=filename;
145 ofstream dump(filename.Data(), filemode);
148 HLTDebug ( "Input Data - TPC Tracks - Slice/Patch: %d/%d.", slice, patch );
149 const AliHLTTPCTrackletData* trackData = (const AliHLTTPCTrackletData*) bl->fPtr;
150 AliHLTUInt32_t nTracks = trackData->fTrackletCnt;
151 AliHLTTPCTrackSegmentData *tracks = (AliHLTTPCTrackSegmentData*) trackData->fTracklets;
153 for(AliHLTUInt32_t i=0;i<nTracks;i++){
154 dump << "====================================================================" << endl;
155 dump << "TrackNumber: " << nT+i << endl;
156 dump << "Slice: " << (unsigned int)slice << " Partition: "<<(unsigned int)patch <<endl;
157 dump << "[X,Y,Z]: [" << tracks->fX<<" , "<<tracks->fY<<" , "<<tracks->fZ <<"]"<< endl;
158 dump << "[X,Y,Z](Last): [" << tracks->fLastX<<" , "<<tracks->fLastY<<" , "<<tracks->fLastZ <<"]"<< endl;
159 dump << "pT: " << tracks->fPt <<"\t\tpT Error: " << tracks->fPterr <<endl;
160 dump << "Psi: " << tracks->fPsi <<"\t\tPsi Error: " << tracks->fPsierr <<endl;
161 dump << "Tgl: " << tracks->fPt <<"\t\tTgl Error: " << tracks->fPterr <<endl;
162 dump << "Charge: " << tracks->fCharge << "\t\tnClusters: " << tracks->fNPoints << endl;
163 UChar_t *tmpP = (UChar_t*)tracks;
164 tmpP += sizeof(AliHLTTPCTrackSegmentData)+tracks->fNPoints*sizeof(UInt_t);
165 tracks = (AliHLTTPCTrackSegmentData*)tmpP;
170 HLTError("can not open file %s for writing", fCurrentFileName.Data());