]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/TPCLib/AliHLTTPCDigitDumpComponent.cxx
implemented TPCDigitDump and AltroChannelSelector
[u/mrichter/AliRoot.git] / HLT / TPCLib / AliHLTTPCDigitDumpComponent.cxx
CommitLineData
3e6ec852 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: Matthias Richter <Matthias.Richter@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 AliHLTTPCDigitDumpComponent.cxx
20 @author Matthias Richter
21 @date
22 @brief Special file writer converting TPC digit input to ASCII. */
23
24// see header file for class documentation
25// or
26// refer to README to build package
27// or
28// visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
29
e1440dab 30#include <cassert>
3e6ec852 31#include "AliHLTTPCDigitDumpComponent.h"
e1440dab 32#include "AliHLTTPCTransform.h"
33#include "AliHLTTPCDigitReaderRaw.h"
34#include "AliHLTTPCDefinitions.h"
3e6ec852 35
36/** ROOT macro for the implementation of ROOT specific class methods */
37ClassImp(AliHLTTPCDigitDumpComponent)
38
39AliHLTTPCDigitDumpComponent::AliHLTTPCDigitDumpComponent()
40 :
e1440dab 41 AliHLTFileWriter(),
42 fRawreaderMode(0)
3e6ec852 43{
44 // see header file for class documentation
45 // or
46 // refer to README to build package
47 // or
48 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
49}
50
51AliHLTTPCDigitDumpComponent::~AliHLTTPCDigitDumpComponent()
52{
53 // see header file for class documentation
54}
55
56const char* AliHLTTPCDigitDumpComponent::GetComponentID()
57{
58 // see header file for class documentation
59 return "TPCDigitDump";
60}
61
62void AliHLTTPCDigitDumpComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list)
63{
64 // see header file for class documentation
65 list.clear();
66 list.push_back(kAliHLTAnyDataType);
67}
68
69AliHLTComponent* AliHLTTPCDigitDumpComponent::Spawn()
70{
71 // see header file for class documentation
72 return new AliHLTTPCDigitDumpComponent;
73}
74
75int AliHLTTPCDigitDumpComponent::InitWriter()
76{
77 // see header file for class documentation
78 return 0;
79}
80
81int AliHLTTPCDigitDumpComponent::ScanArgument(int argc, const char** argv)
82{
83 // see header file for class documentation
84 int iResult=0;
85 TString argument="";
e1440dab 86 bool bMissingParam=0;
87 int i=0;
88 for (; i<argc && iResult>=0; i++) {
3e6ec852 89 argument=argv[i];
90 if (argument.IsNull()) continue;
91
e1440dab 92 // -rawreadermode
93 if (argument.CompareTo("-rawreadermode")==0) {
94 if ((bMissingParam=(++i>=argc))) break;
95 int mode=AliHLTTPCDigitReaderRaw::DecodeMode(argv[i]);
96 if (mode<0) {
97 HLTError("invalid rawreadermode specifier '%s'", argv[i]);
98 iResult=-EINVAL;
99 } else {
100 fRawreaderMode=static_cast<unsigned>(mode);
101 }
102 break;
3e6ec852 103 }
104 }
105
e1440dab 106 if (bMissingParam) {
107 iResult=-EPROTO;
108 }
109 if (iResult>=0) iResult=i+1;
110
3e6ec852 111 return iResult;
112}
113
114int AliHLTTPCDigitDumpComponent::CloseWriter()
115{
116 // see header file for class documentation
117 return 0;
118}
119
120int AliHLTTPCDigitDumpComponent::DumpEvent( const AliHLTComponentEventData& evtData,
121 const AliHLTComponentBlockData* blocks,
e1440dab 122 AliHLTComponentTriggerData& /*trigData*/ )
3e6ec852 123{
124 // see header file for class documentation
125 int iResult=0;
e1440dab 126 int iPrintedSlice=-1;
127 int iPrintedPart=-1;
128 int blockno=0;
129 HLTDebug("%d blocks", evtData.fBlockCnt);
130 for (; blockno<(int)evtData.fBlockCnt; blockno++ ) {
131 //HLTDebug("event %d block %d: %s 0x%08x size %d", evtData.fEventID, blockno, DataType2Text(blocks[blockno].fDataType).c_str(), blocks[blockno].fSpecification, blocks[blockno].fSize);
132 if (blocks[blockno].fDataType != (kAliHLTDataTypeDDLRaw|kAliHLTDataOriginTPC)) continue;
133
134 TString filename;
135 iResult=BuildFileName(evtData.fEventID, blockno, blocks[blockno].fDataType, blocks[blockno].fSpecification, filename);
136 ios::openmode filemode=(ios::openmode)0;
137 if (fCurrentFileName.CompareTo(filename)==0) {
138 // append to the file
139 filemode=ios::app;
140 } else {
141 // store the file for the next block
142 fCurrentFileName=filename;
143 }
144 if (iResult>=0) {
145 ofstream dump(filename.Data(), filemode);
146 if (dump.good()) {
147 int part=AliHLTTPCDefinitions::GetMinPatchNr(blocks[blockno]);
148 assert(part==AliHLTTPCDefinitions::GetMaxPatchNr(blocks[blockno]));
149 int slice=AliHLTTPCDefinitions::GetMinSliceNr(blocks[blockno]);
150 assert(slice==AliHLTTPCDefinitions::GetMaxSliceNr(blocks[blockno]));
151 int firstRow=AliHLTTPCTransform::GetFirstRow(part);
152 int lastRow=AliHLTTPCTransform::GetLastRow(part);
153 AliHLTTPCDigitReaderRaw reader(fRawreaderMode);
154 reader.InitBlock(blocks[blockno].fPtr,blocks[blockno].fSize,firstRow,lastRow,part,slice);
155
156 int iPrintedRow=-1;
157 int iPrintedPad=-1;
158 int iLastTime=-1;
159 while (reader.Next()) {
160 if (iPrintedSlice!=slice || iPrintedPart!=part) {
161 iPrintedSlice=slice;
162 iPrintedPart=part;
163 dump << "====================================================================" << endl;
164 dump << " Slice: " << iPrintedSlice << " Pad: " << iPrintedPad << endl;
165 }
166 if (iPrintedRow!=reader.GetRow()) {
167 iPrintedRow=reader.GetRow();
168 dump << "--------------------------------------------------------------------" << endl;
169 dump << "Row: " << iPrintedRow << endl;
170 }
171 if (iPrintedPad!=reader.GetPad()) {
172 iPrintedPad=reader.GetPad();
173 dump << " Pad: " << iPrintedPad << endl;
174 }
175 if (iPrintedPad!=reader.GetPad()) {
176 iPrintedPad=reader.GetPad();
177 dump << " Pad: " << iPrintedPad << endl;
178 }
179 if (iLastTime!=reader.GetTime()+1 && iLastTime!=reader.GetTime()-1 ) {
180 dump << endl;
181 dump << " Time: " << reader.GetTime();
182 }
183 iLastTime=reader.GetTime();
184 dump << " " << reader.GetSignal() << endl;
185 }
186 dump << endl << endl;
187 } else {
188 HLTError("can not open file %s for writing", filename.Data());
189 iResult=-EBADF;
190 }
191 dump.close();
192 }
193 }
3e6ec852 194 return iResult;
195}