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: Matthias Richter <Matthias.Richter@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 AliHLTTPCDigitDumpComponent.cxx
20 @author Matthias Richter
22 @brief Special file writer converting TPC digit input to ASCII. */
24 // see header file for class documentation
26 // refer to README to build package
28 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
31 #include "AliHLTTPCDigitDumpComponent.h"
32 #include "AliHLTTPCTransform.h"
33 #include "AliHLTTPCDigitReaderRaw.h"
34 #include "AliHLTTPCDefinitions.h"
36 /** ROOT macro for the implementation of ROOT specific class methods */
37 ClassImp(AliHLTTPCDigitDumpComponent)
39 AliHLTTPCDigitDumpComponent::AliHLTTPCDigitDumpComponent()
44 // see header file for class documentation
46 // refer to README to build package
48 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
51 AliHLTTPCDigitDumpComponent::~AliHLTTPCDigitDumpComponent()
53 // see header file for class documentation
56 const char* AliHLTTPCDigitDumpComponent::GetComponentID()
58 // see header file for class documentation
59 return "TPCDigitDump";
62 void AliHLTTPCDigitDumpComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list)
64 // see header file for class documentation
66 list.push_back(kAliHLTAnyDataType);
69 AliHLTComponent* AliHLTTPCDigitDumpComponent::Spawn()
71 // see header file for class documentation
72 return new AliHLTTPCDigitDumpComponent;
75 int AliHLTTPCDigitDumpComponent::InitWriter()
77 // see header file for class documentation
81 int AliHLTTPCDigitDumpComponent::ScanArgument(int argc, const char** argv)
83 // see header file for class documentation
88 for (; i<argc && iResult>=0; i++) {
90 if (argument.IsNull()) continue;
93 if (argument.CompareTo("-rawreadermode")==0) {
94 if ((bMissingParam=(++i>=argc))) break;
95 int mode=AliHLTTPCDigitReaderRaw::DecodeMode(argv[i]);
97 HLTError("invalid rawreadermode specifier '%s'", argv[i]);
100 fRawreaderMode=static_cast<unsigned>(mode);
109 if (iResult>=0) iResult=i+1;
114 int AliHLTTPCDigitDumpComponent::CloseWriter()
116 // see header file for class documentation
120 int AliHLTTPCDigitDumpComponent::DumpEvent( const AliHLTComponentEventData& evtData,
121 const AliHLTComponentBlockData* blocks,
122 AliHLTComponentTriggerData& /*trigData*/ )
124 // see header file for class documentation
126 int iPrintedSlice=-1;
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;
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
141 // store the file for the next block
142 fCurrentFileName=filename;
145 ofstream dump(filename.Data(), filemode);
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);
159 while (reader.Next()) {
160 if (iPrintedSlice!=slice || iPrintedPart!=part) {
163 dump << "====================================================================" << endl;
164 dump << " Slice: " << iPrintedSlice << " Pad: " << iPrintedPad << endl;
166 if (iPrintedRow!=reader.GetRow()) {
167 iPrintedRow=reader.GetRow();
168 dump << "--------------------------------------------------------------------" << endl;
169 dump << "Row: " << iPrintedRow << endl;
171 if (iPrintedPad!=reader.GetPad()) {
172 iPrintedPad=reader.GetPad();
173 dump << " Pad: " << iPrintedPad << endl;
175 if (iPrintedPad!=reader.GetPad()) {
176 iPrintedPad=reader.GetPad();
177 dump << " Pad: " << iPrintedPad << endl;
179 if (iLastTime!=reader.GetTime()+1 && iLastTime!=reader.GetTime()-1 ) {
181 dump << " Time: " << reader.GetTime();
183 iLastTime=reader.GetTime();
184 dump << " " << reader.GetSignal() << endl;
186 dump << endl << endl;
188 HLTError("can not open file %s for writing", filename.Data());