]>
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 | ||
31 | // this is a global object used for automatic component registration, do not use this | |
32 | //AliHLTTPCQHistoComponent gAliHLTTPCQHistoComponent; | |
33 | ||
34 | /** ROOT macro for the implementation of ROOT specific class methods */ | |
35 | ClassImp(AliHLTTPCTrackDumpComponent) | |
36 | ||
37 | AliHLTTPCTrackDumpComponent::AliHLTTPCTrackDumpComponent() | |
38 | : | |
39 | AliHLTFileWriter() | |
40 | { | |
41 | // see header file for class documentation | |
42 | // or | |
43 | // refer to README to build package | |
44 | // or | |
45 | // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt | |
46 | } | |
47 | ||
48 | AliHLTTPCTrackDumpComponent::~AliHLTTPCTrackDumpComponent() | |
49 | { | |
50 | // see header file for class documentation | |
51 | } | |
52 | ||
53 | const char* AliHLTTPCTrackDumpComponent::GetComponentID() | |
54 | { | |
55 | // see header file for class documentation | |
56 | return "TPCTrackDump"; | |
57 | } | |
58 | ||
59 | void AliHLTTPCTrackDumpComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list) | |
60 | { | |
61 | // see header file for class documentation | |
62 | list.clear(); | |
63 | list.push_back(AliHLTTPCDefinitions::fgkTrackSegmentsDataType); | |
64 | list.push_back(AliHLTTPCDefinitions::fgkTracksDataType); | |
65 | ||
66 | } | |
67 | ||
68 | AliHLTComponent* AliHLTTPCTrackDumpComponent::Spawn() | |
69 | { | |
70 | // see header file for class documentation | |
71 | return new AliHLTTPCTrackDumpComponent; | |
72 | } | |
73 | ||
74 | int AliHLTTPCTrackDumpComponent::InitWriter() | |
75 | { | |
76 | // see header file for class documentation | |
77 | return 0; | |
78 | } | |
79 | ||
80 | int AliHLTTPCTrackDumpComponent::ScanArgument(int argc, const char** argv) | |
81 | { | |
82 | // see header file for class documentation | |
83 | int iResult=0; | |
84 | TString argument=""; | |
85 | bool bMissingParam=0; | |
86 | int i=0; | |
87 | ||
88 | if (bMissingParam) iResult=-EPROTO; | |
89 | else if (iResult>=0) iResult=i; | |
90 | ||
91 | return iResult; | |
92 | } | |
93 | ||
94 | int AliHLTTPCTrackDumpComponent::CloseWriter() | |
95 | { | |
96 | // see header file for class documentation | |
97 | return 0; | |
98 | } | |
99 | ||
100 | int AliHLTTPCTrackDumpComponent::DumpEvent( const AliHLTComponentEventData& evtData, | |
101 | AliHLTComponentTriggerData& /*trigData*/ ) | |
102 | { | |
103 | // see header file for class documentation | |
104 | int iResult=0; | |
105 | int blockno=0; | |
106 | const AliHLTComponentBlockData* pDesc=NULL; | |
107 | ||
108 | Int_t TotalTracks=0; | |
109 | ||
110 | if ( GetFirstInputBlock( kAliHLTDataTypeSOR ) || GetFirstInputBlock( kAliHLTDataTypeEOR ) ) | |
111 | return 0; | |
112 | ||
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); | |
115 | ||
116 | if(pDesc->fDataType!=AliHLTTPCDefinitions::fgkTrackSegmentsDataType){continue;} | |
117 | ||
118 | iResult=PrintTrack(evtData,pDesc,TotalTracks); | |
119 | } | |
120 | ||
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); | |
123 | ||
124 | if(pDesc->fDataType!=AliHLTTPCDefinitions::fgkTracksDataType){continue;} | |
125 | ||
126 | iResult=PrintTrack(evtData,pDesc,TotalTracks); | |
127 | } | |
128 | HLTInfo("TrackDump found %d Tracks", TotalTracks); | |
129 | ||
130 | return iResult; | |
131 | } | |
132 | ||
133 | int AliHLTTPCTrackDumpComponent::PrintTrack(const AliHLTComponentEventData& evtData,const AliHLTComponentBlockData* bl,Int_t &nT){ | |
134 | ||
135 | AliHLTUInt8_t slice = AliHLTTPCDefinitions::GetMinSliceNr( *bl ); | |
136 | AliHLTUInt8_t patch = AliHLTTPCDefinitions::GetMinPatchNr( *bl ); | |
137 | ||
138 | TString filename; | |
139 | int iResult=BuildFileName(evtData.fEventID, 0, bl->fDataType, 0, filename); | |
140 | ios::openmode filemode=(ios::openmode)0; | |
141 | if (fCurrentFileName.CompareTo(filename)==0) { | |
142 | filemode=ios::app; | |
143 | } else { | |
144 | fCurrentFileName=filename; | |
145 | } | |
146 | ||
147 | if (iResult>=0) { | |
148 | ofstream dump(filename.Data(), filemode); | |
149 | if (dump.good()) { | |
150 | ||
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; | |
155 | ||
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; | |
169 | } | |
170 | nT+=nTracks; | |
171 | } | |
172 | else { | |
173 | HLTError("can not open file %s for writing", fCurrentFileName.Data()); | |
174 | iResult=-EBADF; | |
175 | } | |
176 | dump.close(); | |
177 | } | |
178 | return iResult; | |
179 | } |