ROOT logo
// $Id$
/**
 * Test macro for the AltroChannelSelector component
 *
 * Usage:
 *   aliroot -b -q altro-channel-selection.C | tee altro-channel-selection.C
 *
 * The macro expects simulated TPC raw data in the form TPC_<ddlno>.dll in the
 * current directory, you might need to start the macro in one of the raw<x>
 * folders. You can easily change the sectors and readout partitions below.
 *
 * The simple test writes a fake file with the list of the selected channels.
 *
 * The function has two switch arguments:
 * - directDump=true/false <br>
 *   determines whether the input data should be forwarded directly. Selection
 *   of channels is disabled if \em true
 * - textDump=true/false   <br>
 *   write output either in ascii text dump using the TPCDigitDump or in
 *   binary data
 *
 * Please note that this macro uses also the TPC module, but this does not
 * imply dependencies to the libAliHLTTPC.
 *
 * @author Matthias.Richter@ift.uib.no
 * @ingroup alihlt_rcu
 */
void altro_channel_selection(bool directDump=false, bool textDump=false)
{
  // this is just a tool to switch the logging systems
  AliHLTLogging log;
  //log.SwitchAliLog(0);

  AliHLTSystem gHLT;
  //gHLT.SetGlobalLoggingLevel(0x7c);

  // load the component library
  gHLT.LoadComponentLibraries("libAliHLTUtil.so");
  gHLT.LoadComponentLibraries("libAliHLTTPC.so");
  gHLT.LoadComponentLibraries("libAliHLTRCU.so");

  // create a dummy pad selection list
  const char* dummySelectionList="/tmp/active-channels.dat";
  FILE* fp = fopen(dummySelectionList, "w");
  if (fp) {
    UShort_t channel=5;
    fwrite(&channel, sizeof(UShort_t), 1, fp);

    UShort_t channel=25;
    fwrite(&channel, sizeof(UShort_t), 1, fp);

    UShort_t channel=56;
    fwrite(&channel, sizeof(UShort_t), 1, fp);

    UShort_t channel=78;
    fwrite(&channel, sizeof(UShort_t), 1, fp);

    UShort_t channel=100;
    fwrite(&channel, sizeof(UShort_t), 1, fp);

    fclose(fp);
  } else {
    cout << "can not open file " << dummySelectionList << " for writing" << endl;
    return;
  }

  // the configuration
  int iMinSlice=0; 
  int iMaxSlice=0;
  int iMinPart=0;
  int iMaxPart=5;
  TString writerInput;
  for (int slice=iMinSlice; slice<=iMaxSlice; slice++) {
    for (int part=iMinPart; part<=iMaxPart; part++) {
      TString arg, publisher, selector, activepads;
      TString selectorInput;

      // raw data publisher components
      int ddlno=768;
      if (part>1) ddlno+=72+4*slice+(part-2);
      else ddlno+=2*slice+part;
      arg.Form("-datatype 'DDL_RAW ' 'TPC ' -dataspec 0x%02x%02x%02x%02x -datafile TPC_%d.ddl", slice, slice, part, part, ddlno);
      publisher.Form("DP_%02d_%d", slice, part);
      AliHLTConfiguration pubconf(publisher.Data(), "FilePublisher", NULL , arg.Data());

      // publisher for a dummy active pad list
      activepads.Form("APP_%02d_%d", slice, part);
      arg.Form("-datatype 'HWADDR16' 'TPC ' -dataspec 0x%02x%02x%02x%02x -datafile %s", slice, slice, part, part, dummySelectionList);
      AliHLTConfiguration appconf(activepads.Data(), "FilePublisher", NULL , arg.Data());


      if (selectorInput.Length()>0) selectorInput+=" ";
      selectorInput+=publisher; selectorInput+=" ";
      selectorInput+=activepads;

      // the selector configuration
      selector.Form("CHANNELSELECT_%02d_%d", slice, part);
      AliHLTConfiguration channelselect(selector.Data(), "AltroChannelSelector", selectorInput.Data(), "");

      // add either the raw file directly to output or the filtered one
      if (writerInput.Length()>0) writerInput+=" ";
      if (directDump) {
	writerInput+=publisher;
      } else {
	writerInput+=selector;
      }
    }
  }

  // the writer configuration
  if (textDump)
    AliHLTConfiguration digitdump("digitdump", "TPCDigitDump"   , writerInput.Data(), "-datafile digit.dump -specfmt=_0x%08x -subdir=out_%d -blcknofmt=_0x%x -idfmt=_0x%08x");
  else
    AliHLTConfiguration digitdump("digitdump", "FileWriter"   , writerInput.Data(), "-datafile RAW.ddl -specfmt=_0x%08x -subdir=out_%d -blcknofmt= -idfmt= -skip-datatype");

  // build the ask list and execute
  gHLT.BuildTaskList("digitdump");
  gHLT.Run();

  // delete temporary file
  TString shellcmd;
  shellcmd.Form("rm %s", dummySelectionList);
  gSystem->Exec(shellcmd.Data());
}
 altro-channel-selection.C:1
 altro-channel-selection.C:2
 altro-channel-selection.C:3
 altro-channel-selection.C:4
 altro-channel-selection.C:5
 altro-channel-selection.C:6
 altro-channel-selection.C:7
 altro-channel-selection.C:8
 altro-channel-selection.C:9
 altro-channel-selection.C:10
 altro-channel-selection.C:11
 altro-channel-selection.C:12
 altro-channel-selection.C:13
 altro-channel-selection.C:14
 altro-channel-selection.C:15
 altro-channel-selection.C:16
 altro-channel-selection.C:17
 altro-channel-selection.C:18
 altro-channel-selection.C:19
 altro-channel-selection.C:20
 altro-channel-selection.C:21
 altro-channel-selection.C:22
 altro-channel-selection.C:23
 altro-channel-selection.C:24
 altro-channel-selection.C:25
 altro-channel-selection.C:26
 altro-channel-selection.C:27
 altro-channel-selection.C:28
 altro-channel-selection.C:29
 altro-channel-selection.C:30
 altro-channel-selection.C:31
 altro-channel-selection.C:32
 altro-channel-selection.C:33
 altro-channel-selection.C:34
 altro-channel-selection.C:35
 altro-channel-selection.C:36
 altro-channel-selection.C:37
 altro-channel-selection.C:38
 altro-channel-selection.C:39
 altro-channel-selection.C:40
 altro-channel-selection.C:41
 altro-channel-selection.C:42
 altro-channel-selection.C:43
 altro-channel-selection.C:44
 altro-channel-selection.C:45
 altro-channel-selection.C:46
 altro-channel-selection.C:47
 altro-channel-selection.C:48
 altro-channel-selection.C:49
 altro-channel-selection.C:50
 altro-channel-selection.C:51
 altro-channel-selection.C:52
 altro-channel-selection.C:53
 altro-channel-selection.C:54
 altro-channel-selection.C:55
 altro-channel-selection.C:56
 altro-channel-selection.C:57
 altro-channel-selection.C:58
 altro-channel-selection.C:59
 altro-channel-selection.C:60
 altro-channel-selection.C:61
 altro-channel-selection.C:62
 altro-channel-selection.C:63
 altro-channel-selection.C:64
 altro-channel-selection.C:65
 altro-channel-selection.C:66
 altro-channel-selection.C:67
 altro-channel-selection.C:68
 altro-channel-selection.C:69
 altro-channel-selection.C:70
 altro-channel-selection.C:71
 altro-channel-selection.C:72
 altro-channel-selection.C:73
 altro-channel-selection.C:74
 altro-channel-selection.C:75
 altro-channel-selection.C:76
 altro-channel-selection.C:77
 altro-channel-selection.C:78
 altro-channel-selection.C:79
 altro-channel-selection.C:80
 altro-channel-selection.C:81
 altro-channel-selection.C:82
 altro-channel-selection.C:83
 altro-channel-selection.C:84
 altro-channel-selection.C:85
 altro-channel-selection.C:86
 altro-channel-selection.C:87
 altro-channel-selection.C:88
 altro-channel-selection.C:89
 altro-channel-selection.C:90
 altro-channel-selection.C:91
 altro-channel-selection.C:92
 altro-channel-selection.C:93
 altro-channel-selection.C:94
 altro-channel-selection.C:95
 altro-channel-selection.C:96
 altro-channel-selection.C:97
 altro-channel-selection.C:98
 altro-channel-selection.C:99
 altro-channel-selection.C:100
 altro-channel-selection.C:101
 altro-channel-selection.C:102
 altro-channel-selection.C:103
 altro-channel-selection.C:104
 altro-channel-selection.C:105
 altro-channel-selection.C:106
 altro-channel-selection.C:107
 altro-channel-selection.C:108
 altro-channel-selection.C:109
 altro-channel-selection.C:110
 altro-channel-selection.C:111
 altro-channel-selection.C:112
 altro-channel-selection.C:113
 altro-channel-selection.C:114
 altro-channel-selection.C:115
 altro-channel-selection.C:116
 altro-channel-selection.C:117
 altro-channel-selection.C:118
 altro-channel-selection.C:119
 altro-channel-selection.C:120
 altro-channel-selection.C:121
 altro-channel-selection.C:122
 altro-channel-selection.C:123
 altro-channel-selection.C:124
 altro-channel-selection.C:125