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
89 if (i>=argc || (argument=argv[i]).IsNull()) continue;
92 if (argument.CompareTo("-rawreadermode")==0) {
93 if ((bMissingParam=(++i>=argc))) break;
94 int mode=AliHLTTPCDigitReaderRaw::DecodeMode(argv[i]);
96 HLTError("invalid rawreadermode specifier '%s'", argv[i]);
99 fRawreaderMode=static_cast<unsigned>(mode);
102 } while (0); // just use the do/while here to have the option of breaking
104 if (bMissingParam) iResult=-EPROTO;
105 else if (iResult>=0) iResult=i;
110 int AliHLTTPCDigitDumpComponent::CloseWriter()
112 // see header file for class documentation
116 int AliHLTTPCDigitDumpComponent::DumpEvent( const AliHLTComponentEventData& evtData,
117 const AliHLTComponentBlockData* blocks,
118 AliHLTComponentTriggerData& /*trigData*/ )
120 // see header file for class documentation
122 int iPrintedSlice=-1;
125 const AliHLTComponentBlockData* pDesc=NULL;
127 for (pDesc=GetFirstInputBlock(kAliHLTDataTypeDDLRaw|kAliHLTDataOriginTPC); pDesc!=NULL; pDesc=GetNextInputBlock(), blockno++) {
128 HLTDebug("event %Lu block %d: %s 0x%08x size %d", evtData.fEventID, blockno, DataType2Text(pDesc->fDataType).c_str(), pDesc->fSpecification, pDesc->fSize);
130 iResult=BuildFileName(evtData.fEventID, blockno, pDesc->fDataType, pDesc->fSpecification, filename);
131 ios::openmode filemode=(ios::openmode)0;
132 if (fCurrentFileName.CompareTo(filename)==0) {
133 // append to the file
136 // store the file for the next block
137 fCurrentFileName=filename;
140 ofstream dump(filename.Data(), filemode);
142 int part=AliHLTTPCDefinitions::GetMinPatchNr(*pDesc);
143 assert(part==AliHLTTPCDefinitions::GetMaxPatchNr(*pDesc));
144 int slice=AliHLTTPCDefinitions::GetMinSliceNr(*pDesc);
145 assert(slice==AliHLTTPCDefinitions::GetMaxSliceNr(*pDesc));
146 int firstRow=AliHLTTPCTransform::GetFirstRow(part);
147 int lastRow=AliHLTTPCTransform::GetLastRow(part);
148 AliHLTTPCDigitReaderRaw reader(fRawreaderMode);
149 reader.InitBlock(pDesc->fPtr,pDesc->fSize,firstRow,lastRow,part,slice);
154 while (reader.Next()) {
155 if ((iPrintedSlice!=-1 && iLastTime!=reader.GetTime()+1 && iLastTime!=reader.GetTime()-1) ||
156 (iPrintedPad!=-1 && iPrintedPad!=reader.GetPad()) ||
157 (iPrintedRow!=-1 && iPrintedRow!=reader.GetRow())) {
160 if (iPrintedSlice!=slice || iPrintedPart!=part) {
163 dump << "====================================================================" << endl;
164 dump << " Slice: " << iPrintedSlice << " Partition: " << iPrintedPart << endl;
167 if (iPrintedRow!=reader.GetRow()) {
168 iPrintedRow=reader.GetRow();
169 dump << "--------------------------------------------------------------------" << endl;
170 dump << "Row: " << iPrintedRow << endl;
173 if (iPrintedPad!=reader.GetPad()) {
174 iPrintedPad=reader.GetPad();
175 dump << "Row: " << iPrintedRow << " Pad: " << iPrintedPad << endl;
178 if (iLastTime!=reader.GetTime()+1 && iLastTime!=reader.GetTime()-1 ) {
179 dump << " Time " << reader.GetTime() << ": ";
181 iLastTime=reader.GetTime();
182 dump << " " << reader.GetSignal();
184 dump << endl << endl;
186 HLTError("can not open file %s for writing", filename.Data());