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 const AliHLTComponentBlockData* pDesc=NULL;
131 for (pDesc=GetFirstInputBlock(kAliHLTDataTypeDDLRaw|kAliHLTDataOriginTPC); pDesc!=NULL; pDesc=GetNextInputBlock(), blockno++) {
132 HLTDebug("event %Lu block %d: %s 0x%08x size %d", evtData.fEventID, blockno, DataType2Text(pDesc->fDataType).c_str(), pDesc->fSpecification, pDesc->fSize);
134 iResult=BuildFileName(evtData.fEventID, blockno, pDesc->fDataType, pDesc->fSpecification, filename);
135 ios::openmode filemode=(ios::openmode)0;
136 if (fCurrentFileName.CompareTo(filename)==0) {
137 // append to the file
140 // store the file for the next block
141 fCurrentFileName=filename;
144 ofstream dump(filename.Data(), filemode);
146 int part=AliHLTTPCDefinitions::GetMinPatchNr(*pDesc);
147 assert(part==AliHLTTPCDefinitions::GetMaxPatchNr(*pDesc));
148 int slice=AliHLTTPCDefinitions::GetMinSliceNr(*pDesc);
149 assert(slice==AliHLTTPCDefinitions::GetMaxSliceNr(*pDesc));
150 int firstRow=AliHLTTPCTransform::GetFirstRow(part);
151 int lastRow=AliHLTTPCTransform::GetLastRow(part);
152 AliHLTTPCDigitReaderRaw reader(fRawreaderMode);
153 reader.InitBlock(pDesc->fPtr,pDesc->fSize,firstRow,lastRow,part,slice);
158 while (reader.Next()) {
159 if ((iPrintedSlice!=-1 && iLastTime!=reader.GetTime()+1 && iLastTime!=reader.GetTime()-1) ||
160 (iPrintedPad!=-1 && iPrintedPad!=reader.GetPad()) ||
161 (iPrintedRow!=-1 && iPrintedRow!=reader.GetRow())) {
164 if (iPrintedSlice!=slice || iPrintedPart!=part) {
167 dump << "====================================================================" << endl;
168 dump << " Slice: " << iPrintedSlice << " Partition: " << iPrintedPart << endl;
171 if (iPrintedRow!=reader.GetRow()) {
172 iPrintedRow=reader.GetRow();
173 dump << "--------------------------------------------------------------------" << endl;
174 dump << "Row: " << iPrintedRow << endl;
177 if (iPrintedPad!=reader.GetPad()) {
178 iPrintedPad=reader.GetPad();
179 dump << "Row: " << iPrintedRow << " Pad: " << iPrintedPad << endl;
182 if (iLastTime!=reader.GetTime()+1 && iLastTime!=reader.GetTime()-1 ) {
183 dump << " Time " << reader.GetTime() << ": ";
185 iLastTime=reader.GetTime();
186 dump << " " << reader.GetSignal();
188 dump << endl << endl;
190 HLTError("can not open file %s for writing", filename.Data());