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 // this is a global object used for automatic component registration, do not use this
32 //AliHLTTPCQHistoComponent gAliHLTTPCQHistoComponent;
34 /** ROOT macro for the implementation of ROOT specific class methods */
35 ClassImp(AliHLTTPCTrackDumpComponent)
37 AliHLTTPCTrackDumpComponent::AliHLTTPCTrackDumpComponent()
41 // see header file for class documentation
43 // refer to README to build package
45 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
48 AliHLTTPCTrackDumpComponent::~AliHLTTPCTrackDumpComponent()
50 // see header file for class documentation
53 const char* AliHLTTPCTrackDumpComponent::GetComponentID()
55 // see header file for class documentation
56 return "TPCTrackDump";
59 void AliHLTTPCTrackDumpComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list)
61 // see header file for class documentation
63 list.push_back(AliHLTTPCDefinitions::fgkTrackSegmentsDataType);
64 list.push_back(AliHLTTPCDefinitions::fgkTracksDataType);
68 AliHLTComponent* AliHLTTPCTrackDumpComponent::Spawn()
70 // see header file for class documentation
71 return new AliHLTTPCTrackDumpComponent;
74 int AliHLTTPCTrackDumpComponent::InitWriter()
76 // see header file for class documentation
80 int AliHLTTPCTrackDumpComponent::ScanArgument(int /*argc*/, const char** /*argv*/)
82 // see header file for class documentation
88 if (bMissingParam) iResult=-EPROTO;
89 else if (iResult>=0) iResult=i;
94 int AliHLTTPCTrackDumpComponent::CloseWriter()
96 // see header file for class documentation
100 int AliHLTTPCTrackDumpComponent::DumpEvent( const AliHLTComponentEventData& evtData,
101 AliHLTComponentTriggerData& /*trigData*/ )
103 // see header file for class documentation
106 const AliHLTComponentBlockData* pDesc=NULL;
110 if ( GetFirstInputBlock( kAliHLTDataTypeSOR ) || GetFirstInputBlock( kAliHLTDataTypeEOR ) )
113 for (pDesc=GetFirstInputBlock(AliHLTTPCDefinitions::fgkTrackSegmentsDataType); pDesc!=NULL; pDesc=GetNextInputBlock(), blockno++) {
114 HLTDebug("event %Lu block %d: %s 0x%08x size %d", evtData.fEventID, blockno, DataType2Text(pDesc->fDataType).c_str(), pDesc->fSpecification, pDesc->fSize);
116 if(pDesc->fDataType!=AliHLTTPCDefinitions::fgkTrackSegmentsDataType){continue;}
118 iResult=PrintTrack(evtData,pDesc,TotalTracks);
121 for (pDesc=GetFirstInputBlock(AliHLTTPCDefinitions::fgkTracksDataType); pDesc!=NULL; pDesc=GetNextInputBlock(), blockno++) {
122 HLTDebug("event %Lu block %d: %s 0x%08x size %d", evtData.fEventID, blockno, DataType2Text(pDesc->fDataType).c_str(), pDesc->fSpecification, pDesc->fSize);
124 if(pDesc->fDataType!=AliHLTTPCDefinitions::fgkTracksDataType){continue;}
126 iResult=PrintTrack(evtData,pDesc,TotalTracks);
128 HLTInfo("TrackDump found %d Tracks", TotalTracks);
133 int AliHLTTPCTrackDumpComponent::PrintTrack(const AliHLTComponentEventData& evtData,const AliHLTComponentBlockData* bl,Int_t &nT){
135 AliHLTUInt8_t slice = AliHLTTPCDefinitions::GetMinSliceNr( *bl );
136 AliHLTUInt8_t patch = AliHLTTPCDefinitions::GetMinPatchNr( *bl );
139 int iResult=BuildFileName(evtData.fEventID, 0, bl->fDataType, 0, filename);
140 ios::openmode filemode=(ios::openmode)0;
141 if (fCurrentFileName.CompareTo(filename)==0) {
144 fCurrentFileName=filename;
148 ofstream dump(filename.Data(), filemode);
151 HLTDebug ( "Input Data - TPC Tracks - Slice/Patch: %d/%d.", slice, patch );
152 const AliHLTTPCTrackletData* trackData = (const AliHLTTPCTrackletData*) bl->fPtr;
153 AliHLTUInt32_t nTracks = trackData->fTrackletCnt;
154 AliHLTTPCTrackSegmentData *tracks = (AliHLTTPCTrackSegmentData*) trackData->fTracklets;
156 for(AliHLTUInt32_t i=0;i<nTracks;i++){
157 dump << "====================================================================" << endl;
158 dump << "TrackNumber: " << nT+i << endl;
159 dump << "Slice: " << (unsigned int)slice << " Partition: "<<(unsigned int)patch <<endl;
160 dump << "[X,Y,Z]: [" << tracks->fX<<" , "<<tracks->fY<<" , "<<tracks->fZ <<"]"<< endl;
161 dump << "[X,Y,Z](Last): [" << tracks->fLastX<<" , "<<tracks->fLastY<<" , "<<tracks->fLastZ <<"]"<< endl;
162 dump << "pT: " << tracks->fPt <<"\t\tpT Error: " << tracks->fPterr <<endl;
163 dump << "Psi: " << tracks->fPsi <<"\t\tPsi Error: " << tracks->fPsierr <<endl;
164 dump << "Tgl: " << tracks->fPt <<"\t\tTgl Error: " << tracks->fPterr <<endl;
165 dump << "Charge: " << tracks->fCharge << "\t\tnClusters: " << tracks->fNPoints << endl;
166 UChar_t *tmpP = (UChar_t*)tracks;
167 tmpP += sizeof(AliHLTTPCTrackSegmentData)+tracks->fNPoints*sizeof(UInt_t);
168 tracks = (AliHLTTPCTrackSegmentData*)tmpP;
173 HLTError("can not open file %s for writing", fCurrentFileName.Data());