ROOT logo
// $Id$
/**
 * @file rec-hlt-tpc-offline.C
 * @brief Test macro for the HLT TPC offline reco wrappers.
 *
 * The macro runs an HLT chain of TPC analysis, using the offline
 * algorithms ans appropriate wrappers.
 *
 * Usage:
 * <pre>
 *   aliroot -b -q rec-hlt-tpc-offline.C | tee rec-hlt-tpc-offline.log
 * </pre>
 *
 * The chain to be run is defined by the macro given to the parameter
 * 'config='
 *
 * The macro asumes raw data to be available in the rawx folders, either
 * simulated or real data. A different input can be specified as parameter
 * <pre>
 *   aliroot -b -q cal-hlt-tpc-offline.C'("input.root")'
 * </pre>
 *
 * In the first section, an analysis chain is defined. The scale of the
 * chain can be defined by choosing the range of sectors and partitions.
 *
 * The reconstruction is steered by the AliReconstruction object in the
 * usual way.
 *
 * @ingroup alihlt_tpc
 * @author Matthias.Richter@ift.uib.no
 */
void rec_hlt_tpc_offline(const char* input="./")
{
  if (!input) {
    cerr << "please specify input or run without arguments" << endl;
    return;
  }
  ///////////////////////////////////////////////////////////////////////////////////////////////////
  //
  // init the HLT system in order to define the analysis chain below
  //
  AliHLTSystem* gHLT=AliHLTPluginBase::GetInstance();

  //gHLT.SwitchAliLog(0);

  ///////////////////////////////////////////////////////////////////////////////////////////////////
  //
  // define the analysis chain to be run
  //

  bool sectorClusterer=true; // run clusterer on sector or DDL level
  // check if the AliRawReaderMemory supports multiple buffers
  TClass* info=TClass::GetClass("AliRawReaderMemory");
  TList* methods=info->GetListOfAllPublicMethods();
  if (sectorClusterer && !methods->FindObject("AddBuffer")) {
    cerr << "warning: AliRawReaderMemory does not support multiple buffers, falling back to run clusterer on DDL level" << endl;
    sectorClusterer=false;
  }
 
  int iMinSlice=0;
  int iMaxSlice=35;
  int iMinPart=0;
  int iMaxPart=5;

  int DDLNoFromSlicePatch(int, int);

  TString writerInput;
  TString trackerInput;
  for (int slice=iMinSlice; slice<=iMaxSlice; slice++) {
    TString arg, clustererInput;
    for (int part=iMinPart; part<=iMaxPart; part++) {
      TString publisher, cf;

      // raw data publisher components
      int ddlno=DDLNoFromSlicePatch(slice, part);
      arg.Form("-minid %d -datatype 'DDL_RAW ' 'TPC '  -dataspec 0x%02x%02x%02x%02x", ddlno, slice, slice, part, part);
      publisher.Form("DP_%02d_%d", slice, part);
      AliHLTConfiguration pubconf(publisher.Data(), "AliRawReaderPublisher", NULL , arg.Data());

      if (!sectorClusterer) {
      // cluster finder components
      cf.Form("CF_%02d_%d", slice, part);
      AliHLTConfiguration cfconf(cf.Data(), "TPCOfflineClusterer", publisher.Data(), "");

      if (trackerInput.Length()>0) trackerInput+=" ";
      trackerInput+=cf;
      //if (writerInput.Length()>0) writerInput+=" ";
      //writerInput+=cf;
      } else {
	if (clustererInput.Length()>0) clustererInput+=" ";
	clustererInput+=publisher;
      }
    }
    if (sectorClusterer) {
      // cluster finder components
      cf.Form("CF_%02d", slice);
      AliHLTConfiguration cfconf(cf.Data(), "TPCOfflineClusterer", clustererInput.Data(), "");

      if (trackerInput.Length()>0) trackerInput+=" ";
      trackerInput+=cf;
    }
  }

  // one global tracker component
  TString tracker;
  tracker.Form("Global_TR");
  AliHLTConfiguration trackerconf(tracker.Data(), "TPCOfflineTracker", trackerInput.Data(), "");
  if (writerInput.Length()>0) writerInput+=" ";
  writerInput+=tracker;

  // the writer configuration
  AliHLTConfiguration esdwconf("sink1", "EsdCollector"   , writerInput.Data(), "-directory hlt-tpc-offline");

  ///////////////////////////////////////////////////////////////////////////////////////////////////
  //
  // Init and run the reconstruction
  // All but HLT reconstructio is switched off
  //
  AliReconstruction rec;
  rec.SetInput(input);
  rec.SetRunVertexFinder(kFALSE);
  rec.SetRunLocalReconstruction("HLT");
  rec.SetRunTracking("");
  rec.SetLoadAlignFromCDB(0);
  rec.SetFillESD("");
  rec.SetRunQA(":");
  rec.SetRunGlobalQA(kFALSE);
  rec.SetFillTriggerESD(kFALSE);
  rec.SetOption("HLT", "libAliHLTUtil.so libAliHLTRCU.so libAliHLTTPC.so loglevel=0x7c chains=sink1");
  rec.Run();
}

int DDLNoFromSlicePatch(int slice, int part)
{
  int ddlno=768;
  if (part>1) ddlno+=72+4*slice+(part-2);
  else ddlno+=2*slice+part;

  return ddlno;
}
 rec-hlt-tpc-offline.C:1
 rec-hlt-tpc-offline.C:2
 rec-hlt-tpc-offline.C:3
 rec-hlt-tpc-offline.C:4
 rec-hlt-tpc-offline.C:5
 rec-hlt-tpc-offline.C:6
 rec-hlt-tpc-offline.C:7
 rec-hlt-tpc-offline.C:8
 rec-hlt-tpc-offline.C:9
 rec-hlt-tpc-offline.C:10
 rec-hlt-tpc-offline.C:11
 rec-hlt-tpc-offline.C:12
 rec-hlt-tpc-offline.C:13
 rec-hlt-tpc-offline.C:14
 rec-hlt-tpc-offline.C:15
 rec-hlt-tpc-offline.C:16
 rec-hlt-tpc-offline.C:17
 rec-hlt-tpc-offline.C:18
 rec-hlt-tpc-offline.C:19
 rec-hlt-tpc-offline.C:20
 rec-hlt-tpc-offline.C:21
 rec-hlt-tpc-offline.C:22
 rec-hlt-tpc-offline.C:23
 rec-hlt-tpc-offline.C:24
 rec-hlt-tpc-offline.C:25
 rec-hlt-tpc-offline.C:26
 rec-hlt-tpc-offline.C:27
 rec-hlt-tpc-offline.C:28
 rec-hlt-tpc-offline.C:29
 rec-hlt-tpc-offline.C:30
 rec-hlt-tpc-offline.C:31
 rec-hlt-tpc-offline.C:32
 rec-hlt-tpc-offline.C:33
 rec-hlt-tpc-offline.C:34
 rec-hlt-tpc-offline.C:35
 rec-hlt-tpc-offline.C:36
 rec-hlt-tpc-offline.C:37
 rec-hlt-tpc-offline.C:38
 rec-hlt-tpc-offline.C:39
 rec-hlt-tpc-offline.C:40
 rec-hlt-tpc-offline.C:41
 rec-hlt-tpc-offline.C:42
 rec-hlt-tpc-offline.C:43
 rec-hlt-tpc-offline.C:44
 rec-hlt-tpc-offline.C:45
 rec-hlt-tpc-offline.C:46
 rec-hlt-tpc-offline.C:47
 rec-hlt-tpc-offline.C:48
 rec-hlt-tpc-offline.C:49
 rec-hlt-tpc-offline.C:50
 rec-hlt-tpc-offline.C:51
 rec-hlt-tpc-offline.C:52
 rec-hlt-tpc-offline.C:53
 rec-hlt-tpc-offline.C:54
 rec-hlt-tpc-offline.C:55
 rec-hlt-tpc-offline.C:56
 rec-hlt-tpc-offline.C:57
 rec-hlt-tpc-offline.C:58
 rec-hlt-tpc-offline.C:59
 rec-hlt-tpc-offline.C:60
 rec-hlt-tpc-offline.C:61
 rec-hlt-tpc-offline.C:62
 rec-hlt-tpc-offline.C:63
 rec-hlt-tpc-offline.C:64
 rec-hlt-tpc-offline.C:65
 rec-hlt-tpc-offline.C:66
 rec-hlt-tpc-offline.C:67
 rec-hlt-tpc-offline.C:68
 rec-hlt-tpc-offline.C:69
 rec-hlt-tpc-offline.C:70
 rec-hlt-tpc-offline.C:71
 rec-hlt-tpc-offline.C:72
 rec-hlt-tpc-offline.C:73
 rec-hlt-tpc-offline.C:74
 rec-hlt-tpc-offline.C:75
 rec-hlt-tpc-offline.C:76
 rec-hlt-tpc-offline.C:77
 rec-hlt-tpc-offline.C:78
 rec-hlt-tpc-offline.C:79
 rec-hlt-tpc-offline.C:80
 rec-hlt-tpc-offline.C:81
 rec-hlt-tpc-offline.C:82
 rec-hlt-tpc-offline.C:83
 rec-hlt-tpc-offline.C:84
 rec-hlt-tpc-offline.C:85
 rec-hlt-tpc-offline.C:86
 rec-hlt-tpc-offline.C:87
 rec-hlt-tpc-offline.C:88
 rec-hlt-tpc-offline.C:89
 rec-hlt-tpc-offline.C:90
 rec-hlt-tpc-offline.C:91
 rec-hlt-tpc-offline.C:92
 rec-hlt-tpc-offline.C:93
 rec-hlt-tpc-offline.C:94
 rec-hlt-tpc-offline.C:95
 rec-hlt-tpc-offline.C:96
 rec-hlt-tpc-offline.C:97
 rec-hlt-tpc-offline.C:98
 rec-hlt-tpc-offline.C:99
 rec-hlt-tpc-offline.C:100
 rec-hlt-tpc-offline.C:101
 rec-hlt-tpc-offline.C:102
 rec-hlt-tpc-offline.C:103
 rec-hlt-tpc-offline.C:104
 rec-hlt-tpc-offline.C:105
 rec-hlt-tpc-offline.C:106
 rec-hlt-tpc-offline.C:107
 rec-hlt-tpc-offline.C:108
 rec-hlt-tpc-offline.C:109
 rec-hlt-tpc-offline.C:110
 rec-hlt-tpc-offline.C:111
 rec-hlt-tpc-offline.C:112
 rec-hlt-tpc-offline.C:113
 rec-hlt-tpc-offline.C:114
 rec-hlt-tpc-offline.C:115
 rec-hlt-tpc-offline.C:116
 rec-hlt-tpc-offline.C:117
 rec-hlt-tpc-offline.C:118
 rec-hlt-tpc-offline.C:119
 rec-hlt-tpc-offline.C:120
 rec-hlt-tpc-offline.C:121
 rec-hlt-tpc-offline.C:122
 rec-hlt-tpc-offline.C:123
 rec-hlt-tpc-offline.C:124
 rec-hlt-tpc-offline.C:125
 rec-hlt-tpc-offline.C:126
 rec-hlt-tpc-offline.C:127
 rec-hlt-tpc-offline.C:128
 rec-hlt-tpc-offline.C:129
 rec-hlt-tpc-offline.C:130
 rec-hlt-tpc-offline.C:131
 rec-hlt-tpc-offline.C:132
 rec-hlt-tpc-offline.C:133
 rec-hlt-tpc-offline.C:134
 rec-hlt-tpc-offline.C:135
 rec-hlt-tpc-offline.C:136
 rec-hlt-tpc-offline.C:137
 rec-hlt-tpc-offline.C:138
 rec-hlt-tpc-offline.C:139
 rec-hlt-tpc-offline.C:140
 rec-hlt-tpc-offline.C:141