]>
Commit | Line | Data |
---|---|---|
dadc7068 | 1 | // $Id$ |
2 | ||
3 | //************************************************************************** | |
4 | //* This file is property of and copyright by the ALICE HLT Project * | |
5 | //* ALICE Experiment at CERN, All rights reserved. * | |
6 | //* * | |
7 | //* Primary Authors: Gaute Ovrebekk <ovrebekk@ift.uib.no> * | |
8 | //* for The ALICE HLT Project. * | |
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 | ||
19 | /** @file AliHLTTPCTrackDumpComponent.cxx | |
20 | @author Gaute Ovrebekk | |
21 | @date | |
22 | @brief Special file writer converting TPC tracks input to ASCII. */ | |
23 | ||
24 | #include <cassert> | |
25 | #include "AliHLTTPCTrackDumpComponent.h" | |
26 | #include "AliHLTTPCTransform.h" | |
27 | #include "AliHLTTPCTrackletDataFormat.h" | |
28 | #include "AliHLTTPCDefinitions.h" | |
29 | #include <TSystem.h> | |
30 | ||
dadc7068 | 31 | /** ROOT macro for the implementation of ROOT specific class methods */ |
32 | ClassImp(AliHLTTPCTrackDumpComponent) | |
33 | ||
34 | AliHLTTPCTrackDumpComponent::AliHLTTPCTrackDumpComponent() | |
35 | : | |
36 | AliHLTFileWriter() | |
37 | { | |
38 | // see header file for class documentation | |
39 | // or | |
40 | // refer to README to build package | |
41 | // or | |
42 | // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt | |
43 | } | |
44 | ||
45 | AliHLTTPCTrackDumpComponent::~AliHLTTPCTrackDumpComponent() | |
46 | { | |
47 | // see header file for class documentation | |
48 | } | |
49 | ||
50 | const char* AliHLTTPCTrackDumpComponent::GetComponentID() | |
51 | { | |
52 | // see header file for class documentation | |
53 | return "TPCTrackDump"; | |
54 | } | |
55 | ||
56 | void AliHLTTPCTrackDumpComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list) | |
57 | { | |
58 | // see header file for class documentation | |
59 | list.clear(); | |
60 | list.push_back(AliHLTTPCDefinitions::fgkTrackSegmentsDataType); | |
61 | list.push_back(AliHLTTPCDefinitions::fgkTracksDataType); | |
62 | ||
63 | } | |
64 | ||
65 | AliHLTComponent* AliHLTTPCTrackDumpComponent::Spawn() | |
66 | { | |
67 | // see header file for class documentation | |
68 | return new AliHLTTPCTrackDumpComponent; | |
69 | } | |
70 | ||
71 | int AliHLTTPCTrackDumpComponent::InitWriter() | |
72 | { | |
73 | // see header file for class documentation | |
74 | return 0; | |
75 | } | |
76 | ||
900fdfb2 | 77 | int AliHLTTPCTrackDumpComponent::ScanArgument(int /*argc*/, const char** /*argv*/) |
dadc7068 | 78 | { |
79 | // see header file for class documentation | |
80 | int iResult=0; | |
81 | TString argument=""; | |
82 | bool bMissingParam=0; | |
83 | int i=0; | |
84 | ||
85 | if (bMissingParam) iResult=-EPROTO; | |
86 | else if (iResult>=0) iResult=i; | |
87 | ||
88 | return iResult; | |
89 | } | |
90 | ||
91 | int AliHLTTPCTrackDumpComponent::CloseWriter() | |
92 | { | |
93 | // see header file for class documentation | |
94 | return 0; | |
95 | } | |
96 | ||
97 | int AliHLTTPCTrackDumpComponent::DumpEvent( const AliHLTComponentEventData& evtData, | |
98 | AliHLTComponentTriggerData& /*trigData*/ ) | |
99 | { | |
100 | // see header file for class documentation | |
101 | int iResult=0; | |
102 | int blockno=0; | |
103 | const AliHLTComponentBlockData* pDesc=NULL; | |
104 | ||
105 | Int_t TotalTracks=0; | |
106 | ||
107 | if ( GetFirstInputBlock( kAliHLTDataTypeSOR ) || GetFirstInputBlock( kAliHLTDataTypeEOR ) ) | |
108 | return 0; | |
109 | ||
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); | |
112 | ||
113 | if(pDesc->fDataType!=AliHLTTPCDefinitions::fgkTrackSegmentsDataType){continue;} | |
114 | ||
115 | iResult=PrintTrack(evtData,pDesc,TotalTracks); | |
116 | } | |
117 | ||
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); | |
120 | ||
121 | if(pDesc->fDataType!=AliHLTTPCDefinitions::fgkTracksDataType){continue;} | |
122 | ||
123 | iResult=PrintTrack(evtData,pDesc,TotalTracks); | |
124 | } | |
125 | HLTInfo("TrackDump found %d Tracks", TotalTracks); | |
126 | ||
127 | return iResult; | |
128 | } | |
129 | ||
130 | int AliHLTTPCTrackDumpComponent::PrintTrack(const AliHLTComponentEventData& evtData,const AliHLTComponentBlockData* bl,Int_t &nT){ | |
131 | ||
132 | AliHLTUInt8_t slice = AliHLTTPCDefinitions::GetMinSliceNr( *bl ); | |
133 | AliHLTUInt8_t patch = AliHLTTPCDefinitions::GetMinPatchNr( *bl ); | |
134 | ||
135 | TString filename; | |
136 | int iResult=BuildFileName(evtData.fEventID, 0, bl->fDataType, 0, filename); | |
137 | ios::openmode filemode=(ios::openmode)0; | |
138 | if (fCurrentFileName.CompareTo(filename)==0) { | |
139 | filemode=ios::app; | |
140 | } else { | |
141 | fCurrentFileName=filename; | |
142 | } | |
143 | ||
144 | if (iResult>=0) { | |
145 | ofstream dump(filename.Data(), filemode); | |
146 | if (dump.good()) { | |
147 | ||
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; | |
152 | ||
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; | |
166 | } | |
167 | nT+=nTracks; | |
168 | } | |
169 | else { | |
170 | HLTError("can not open file %s for writing", fCurrentFileName.Data()); | |
171 | iResult=-EBADF; | |
172 | } | |
173 | dump.close(); | |
174 | } | |
175 | return iResult; | |
176 | } |