ROOT logo
// $Id$
/**
 * @file compareDigitReaders.C
 * @brief Translate TPC DDL file into an ascii dump
 *
 * Usage:
 * <pre>
 *   aliroot -b -q -l raw2ascii.C'("infile", "outfile", slice, patch, "reader")' | tee compareDigitReaders.log
 * </pre>
 *
 * The macro translates a TPC DDL raw data file into an ascii dump using
 * a small chain with the AliHLTTPCDigitDumpComponent. The only mandatory
 * parameter is the input file.
 *   - outfile might be skipped -> default infile.ascii
 *   - optional parameter 'slice':
 *     can be skipped if infile obeys DDL naming rule
 *   - optional parameter 'patch':
 *     can be skipped if infile obeys DDL naming rule
 *   - optional parameter 'reader': default 'decoder'
 *     packed (AliRawStream), decoder (AliAltroDecoder)
 *
 * @ingroup alihlt_tpc
 * @author Matthias.Richter@ift.uib.no
 */
void usage();

int raw2ascii(const char* infile, const char* outfile=NULL, int slice=-1, int part=-1, const char* reader="decoder")
{

  if (!infile) {
    usage();
    return 0;
  }

  AliHLTSystem gHLT(0x79);
  gHLT.LoadComponentLibraries("libAliHLTUtil.so libAliHLTRCU.so libAliHLTTPC.so");

  TString outFile;
  if (outfile) outFile=outfile;
  else outFile.Form("%s.ascii", infile);

  if (slice<0 || part<0) {
    TString number=infile;
    if (number.EndsWith(".ddl")) {
      number.ReplaceAll(".ddl", "");
      TObjArray* pTokens=number.Tokenize("_");
      if (pTokens) {
	if (pTokens->GetEntries()>1) {
	  number=((TObjString*)pTokens->At(pTokens->GetEntries()-1))->GetString();
	}
      }
      if (number.IsDigit()) {
	int ddlid=number.Atoi();
	if (ddlid<840) {
	  slice=(ddlid-768)/2;
	  part=ddlid%2; 
	} else {
	  slice=(ddlid-840)/4;
	  part=(ddlid%4)+2;
	}
      }
    }
    if (slice<0 || part<0) {
      cout << "error: can not derive slice and partition number from file name " << infile << endl;
      return -1;
    }
  }

  TString arg;
  arg.Form("-datatype 'DDL_RAW ' 'TPC '  -dataspec 0x%02x%02x%02x%02x -datafile %s ", slice, slice, part, part, infile);
  AliHLTConfiguration pubconf("publisher", "FilePublisher", NULL , arg.Data());

  arg.Form("-datafile %s -digitreader %s -concatenate-blocks -idfmt= -unsorted", outFile.Data(), reader);
  AliHLTConfiguration dump("dump", "TPCDigitDump", "publisher", arg.Data());

  gHLT.BuildTaskList("dump");
  gHLT.Run();
}

int raw2ascii()
{
  usage();
  return 0;
}

void usage() {
  cout << "raw2ascii.C: translate TPC DDL file into an ascii dump" << endl << endl;
  cout << "    usage: aliroot -b -q -l raw2ascii.C'(\"infile\", \"outfile\", slice, patch, \"reader\")'" << endl;
  cout << "           outfile might be skipped -> default infile.ascii" << endl;
  cout << "           optional parameter 'slice':  can be skipped if infile obeys DDL naming rule" << endl;
  cout << "           optional parameter 'patch':  can be skipped if infile obeys DDL naming rule" << endl;
  cout << "           optional parameter 'reader': packed (AliRawStream), decoder (AliAltroDecoder)" << endl;
}

 raw2ascii.C:1
 raw2ascii.C:2
 raw2ascii.C:3
 raw2ascii.C:4
 raw2ascii.C:5
 raw2ascii.C:6
 raw2ascii.C:7
 raw2ascii.C:8
 raw2ascii.C:9
 raw2ascii.C:10
 raw2ascii.C:11
 raw2ascii.C:12
 raw2ascii.C:13
 raw2ascii.C:14
 raw2ascii.C:15
 raw2ascii.C:16
 raw2ascii.C:17
 raw2ascii.C:18
 raw2ascii.C:19
 raw2ascii.C:20
 raw2ascii.C:21
 raw2ascii.C:22
 raw2ascii.C:23
 raw2ascii.C:24
 raw2ascii.C:25
 raw2ascii.C:26
 raw2ascii.C:27
 raw2ascii.C:28
 raw2ascii.C:29
 raw2ascii.C:30
 raw2ascii.C:31
 raw2ascii.C:32
 raw2ascii.C:33
 raw2ascii.C:34
 raw2ascii.C:35
 raw2ascii.C:36
 raw2ascii.C:37
 raw2ascii.C:38
 raw2ascii.C:39
 raw2ascii.C:40
 raw2ascii.C:41
 raw2ascii.C:42
 raw2ascii.C:43
 raw2ascii.C:44
 raw2ascii.C:45
 raw2ascii.C:46
 raw2ascii.C:47
 raw2ascii.C:48
 raw2ascii.C:49
 raw2ascii.C:50
 raw2ascii.C:51
 raw2ascii.C:52
 raw2ascii.C:53
 raw2ascii.C:54
 raw2ascii.C:55
 raw2ascii.C:56
 raw2ascii.C:57
 raw2ascii.C:58
 raw2ascii.C:59
 raw2ascii.C:60
 raw2ascii.C:61
 raw2ascii.C:62
 raw2ascii.C:63
 raw2ascii.C:64
 raw2ascii.C:65
 raw2ascii.C:66
 raw2ascii.C:67
 raw2ascii.C:68
 raw2ascii.C:69
 raw2ascii.C:70
 raw2ascii.C:71
 raw2ascii.C:72
 raw2ascii.C:73
 raw2ascii.C:74
 raw2ascii.C:75
 raw2ascii.C:76
 raw2ascii.C:77
 raw2ascii.C:78
 raw2ascii.C:79
 raw2ascii.C:80
 raw2ascii.C:81
 raw2ascii.C:82
 raw2ascii.C:83
 raw2ascii.C:84
 raw2ascii.C:85
 raw2ascii.C:86
 raw2ascii.C:87
 raw2ascii.C:88
 raw2ascii.C:89
 raw2ascii.C:90
 raw2ascii.C:91
 raw2ascii.C:92
 raw2ascii.C:93
 raw2ascii.C:94
 raw2ascii.C:95