ROOT logo
// $Id$
/*
 * Example macro to run the Offline ITS Cluster Finding in HLT.
 * The reconstruction is done from the ITS raw data.
 *
 * Usage:
 * <pre>
 *   aliroot -b -q rec-its-cluster.C | tee rec-its-cluster.log
 *   aliroot -b -q rec-its-cluster.C'("./","spd")' | tee rec-its-cluster.log
 * </pre>
 *
 * 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 rec-its-cluster.C'("input.root")'
 * </pre>
 *
 * In the second parameter you can change the clusterfinders to run only
 * SPD, SDD, SSD or All:
 *    - SPD runs only Silicon Pixels
 *    - SDD runs only Silicon Drift
 *    - SSD runs only Silicon Stips
 *    - All will run the full ITS
 *
 * All is default. The chain ends in a histogram component. 
 *
 * The reconstruction is steered by the AliReconstruction object in the
 * usual way.
 *
 * @ingroup alihlt_its
 * @author st05886@ift.uib.no
 */

void rec_its_cluster(const char* input="./", char* opt="All")
{

  if(!gSystem->AccessPathName("galice.root")){
    cerr << "please delete the galice.root or run at different place." << endl;
    return;
  }
  
  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();
  int verbosity=1; // 1 higher verbosity, 0 reduced output
 
  ///////////////////////////////////////////////////////////////////////////////////////////////////
  //
  // Setting up which output to give
  //
  TString option;
  option+="libAliHLTUtil.so libAliHLTRCU.so libAliHLTITS.so libAliHLTSample.so ";
  option+="loglevel=";
  option+=verbosity>0?"0x7c":"0x79";
  option+=" chains=";
  Bool_t runspd=kFALSE, runsdd=kFALSE, runssd=kFALSE;
  TString allArgs=opt;
  TString argument;
  TObjArray* pTokens=allArgs.Tokenize(" ");
  if (pTokens) {
    for (int i=0; i<pTokens->GetEntries(); i++) {
      argument=((TObjString*)pTokens->At(i))->GetString();
      if (argument.IsNull()) continue;
 
      if (argument.CompareTo("spd", TString::kIgnoreCase)==0) {
	runspd=kTRUE;
	continue;
      } 
      if (argument.CompareTo("sdd", TString::kIgnoreCase)==0) {
	runsdd=kTRUE;
	continue;
      }
      if (argument.CompareTo("ssd",TString::kIgnoreCase)==0) {
	runssd=kTRUE;
	continue;
      }
      if (argument.CompareTo("all",TString::kIgnoreCase)==0) {
	runspd=kTRUE;
	runsdd=kTRUE;
	runssd=kTRUE;
	continue;
      }
      else {
	break;
      }
    }
  }
  
  ///////////////////////////////////////////////////////////////////////////////////////////////////
  //
  // define the analysis chain to be run
  //
    
  //The spec starts from 0x1 in SPD, SDD and SSD. So 0x1 is ddl 0 for SPD, 0x10 is ddl 1, and so on
  //in SDD 0x1 is ddl 256, 0x10 is ddl 257, and so on. This means that the spec has to be set to 0x1 
  //before the loops over the clusterfinder

  int minddl=0;          //min ddl number for SPD
  int maxddl=19;         //max ddl number for SPD
  int spec=0x1;          //spec for ddl's
  int ddlno=0;
  TString dummyInput="";

  if(runspd){
    for(ddlno=minddl;ddlno<=maxddl;ddlno++){  
      TString arg, publisher, cf;
      
      arg.Form("-minid %d -datatype 'DDL_RAW ' 'ISPD ' -dataspec 0x%08x %s",ddlno, spec, (verbosity>0?" -verbose":""));
      publisher.Form("DP_%d", ddlno);
      AliHLTConfiguration pubconf(publisher.Data(), "AliRawReaderPublisher", NULL , arg.Data());
      
      cf.Form("CF_%d",ddlno);
      AliHLTConfiguration cfconf(cf.Data(), "ITSClusterFinderSPD", publisher.Data(), "");
      
      if (dummyInput.Length()>0) dummyInput+=" ";
      dummyInput+=cf;
      
      spec=spec<<1;
    }
  }
  
  if(runsdd){
    minddl=256;        //min ddl number for SDD    
    maxddl=279;        //max ddl number for SDD
    spec=0x1;          //spec for ddl's
    
    for(ddlno=minddl;ddlno<=maxddl;ddlno++){  
      TString arg, publisher, cf;
      
      arg.Form("-minid %d -datatype 'DDL_RAW ' 'ISDD ' -dataspec 0x%08x %s",ddlno, spec, (verbosity>0?" -verbose":"")); 
      publisher.Form("DP_%d", ddlno);
      AliHLTConfiguration pubconf(publisher.Data(), "AliRawReaderPublisher", NULL , arg.Data());
      
      cf.Form("CF_%d",ddlno);
      AliHLTConfiguration cfconf(cf.Data(), "ITSClusterFinderSDD", publisher.Data(), "");
      
      if (dummyInput.Length()>0) dummyInput+=" ";
      dummyInput+=cf;
      
      spec=spec<<1;
    }
  }

  if(runssd){
    minddl=512;      //min ddl number for SSD     
    maxddl=527;      //max ddl number for SSD
    spec=0x1;        //spec for ddl's
    
    for(ddlno=minddl;ddlno<=maxddl;ddlno++){  
      TString arg, publisher, cf;
      
      arg.Form("-minid %d -datatype 'DDL_RAW ' 'ISSD ' -dataspec 0x%08x %s",ddlno, spec, (verbosity>0?" -verbose":""));
      publisher.Form("DP_%d", ddlno);
      AliHLTConfiguration pubconf(publisher.Data(), "AliRawReaderPublisher", NULL , arg.Data());
      
      cf.Form("CF_%d",ddlno);
      AliHLTConfiguration cfconf(cf.Data(), "ITSClusterFinderSSD", publisher.Data(), "");
      
      if (dummyInput.Length()>0) dummyInput+=" ";
      dummyInput+=cf;
      
      spec=spec<<1;
    }
  }

  AliHLTConfiguration cfconf("clusterHisto","ITSClusterHisto",dummyInput.Data(),"-pushback-period=10");
  AliHLTConfiguration fwconf("histFile","ROOTFileWriter", "clusterHisto","-datafile ClusterHisto -concatenate-events -overwrite");

  option+="histFile";

  ///////////////////////////////////////////////////////////////////////////////////////////////////
  //
  // 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.SetRunQA(":");

  // NOTE: FillESD is a step in the AliReconstruction sequence and has
  // nothing to do with the fact that this macro writes ESD output
  // HLT processes the HLTOUT during FillESD and extracts data which
  // has already been prepared. This step is currently not necessary for
  // this macro
  rec.SetFillESD("");
  rec.SetOption("HLT", option);
  rec.Run();
}



 rec-its-cluster.C:1
 rec-its-cluster.C:2
 rec-its-cluster.C:3
 rec-its-cluster.C:4
 rec-its-cluster.C:5
 rec-its-cluster.C:6
 rec-its-cluster.C:7
 rec-its-cluster.C:8
 rec-its-cluster.C:9
 rec-its-cluster.C:10
 rec-its-cluster.C:11
 rec-its-cluster.C:12
 rec-its-cluster.C:13
 rec-its-cluster.C:14
 rec-its-cluster.C:15
 rec-its-cluster.C:16
 rec-its-cluster.C:17
 rec-its-cluster.C:18
 rec-its-cluster.C:19
 rec-its-cluster.C:20
 rec-its-cluster.C:21
 rec-its-cluster.C:22
 rec-its-cluster.C:23
 rec-its-cluster.C:24
 rec-its-cluster.C:25
 rec-its-cluster.C:26
 rec-its-cluster.C:27
 rec-its-cluster.C:28
 rec-its-cluster.C:29
 rec-its-cluster.C:30
 rec-its-cluster.C:31
 rec-its-cluster.C:32
 rec-its-cluster.C:33
 rec-its-cluster.C:34
 rec-its-cluster.C:35
 rec-its-cluster.C:36
 rec-its-cluster.C:37
 rec-its-cluster.C:38
 rec-its-cluster.C:39
 rec-its-cluster.C:40
 rec-its-cluster.C:41
 rec-its-cluster.C:42
 rec-its-cluster.C:43
 rec-its-cluster.C:44
 rec-its-cluster.C:45
 rec-its-cluster.C:46
 rec-its-cluster.C:47
 rec-its-cluster.C:48
 rec-its-cluster.C:49
 rec-its-cluster.C:50
 rec-its-cluster.C:51
 rec-its-cluster.C:52
 rec-its-cluster.C:53
 rec-its-cluster.C:54
 rec-its-cluster.C:55
 rec-its-cluster.C:56
 rec-its-cluster.C:57
 rec-its-cluster.C:58
 rec-its-cluster.C:59
 rec-its-cluster.C:60
 rec-its-cluster.C:61
 rec-its-cluster.C:62
 rec-its-cluster.C:63
 rec-its-cluster.C:64
 rec-its-cluster.C:65
 rec-its-cluster.C:66
 rec-its-cluster.C:67
 rec-its-cluster.C:68
 rec-its-cluster.C:69
 rec-its-cluster.C:70
 rec-its-cluster.C:71
 rec-its-cluster.C:72
 rec-its-cluster.C:73
 rec-its-cluster.C:74
 rec-its-cluster.C:75
 rec-its-cluster.C:76
 rec-its-cluster.C:77
 rec-its-cluster.C:78
 rec-its-cluster.C:79
 rec-its-cluster.C:80
 rec-its-cluster.C:81
 rec-its-cluster.C:82
 rec-its-cluster.C:83
 rec-its-cluster.C:84
 rec-its-cluster.C:85
 rec-its-cluster.C:86
 rec-its-cluster.C:87
 rec-its-cluster.C:88
 rec-its-cluster.C:89
 rec-its-cluster.C:90
 rec-its-cluster.C:91
 rec-its-cluster.C:92
 rec-its-cluster.C:93
 rec-its-cluster.C:94
 rec-its-cluster.C:95
 rec-its-cluster.C:96
 rec-its-cluster.C:97
 rec-its-cluster.C:98
 rec-its-cluster.C:99
 rec-its-cluster.C:100
 rec-its-cluster.C:101
 rec-its-cluster.C:102
 rec-its-cluster.C:103
 rec-its-cluster.C:104
 rec-its-cluster.C:105
 rec-its-cluster.C:106
 rec-its-cluster.C:107
 rec-its-cluster.C:108
 rec-its-cluster.C:109
 rec-its-cluster.C:110
 rec-its-cluster.C:111
 rec-its-cluster.C:112
 rec-its-cluster.C:113
 rec-its-cluster.C:114
 rec-its-cluster.C:115
 rec-its-cluster.C:116
 rec-its-cluster.C:117
 rec-its-cluster.C:118
 rec-its-cluster.C:119
 rec-its-cluster.C:120
 rec-its-cluster.C:121
 rec-its-cluster.C:122
 rec-its-cluster.C:123
 rec-its-cluster.C:124
 rec-its-cluster.C:125
 rec-its-cluster.C:126
 rec-its-cluster.C:127
 rec-its-cluster.C:128
 rec-its-cluster.C:129
 rec-its-cluster.C:130
 rec-its-cluster.C:131
 rec-its-cluster.C:132
 rec-its-cluster.C:133
 rec-its-cluster.C:134
 rec-its-cluster.C:135
 rec-its-cluster.C:136
 rec-its-cluster.C:137
 rec-its-cluster.C:138
 rec-its-cluster.C:139
 rec-its-cluster.C:140
 rec-its-cluster.C:141
 rec-its-cluster.C:142
 rec-its-cluster.C:143
 rec-its-cluster.C:144
 rec-its-cluster.C:145
 rec-its-cluster.C:146
 rec-its-cluster.C:147
 rec-its-cluster.C:148
 rec-its-cluster.C:149
 rec-its-cluster.C:150
 rec-its-cluster.C:151
 rec-its-cluster.C:152
 rec-its-cluster.C:153
 rec-its-cluster.C:154
 rec-its-cluster.C:155
 rec-its-cluster.C:156
 rec-its-cluster.C:157
 rec-its-cluster.C:158
 rec-its-cluster.C:159
 rec-its-cluster.C:160
 rec-its-cluster.C:161
 rec-its-cluster.C:162
 rec-its-cluster.C:163
 rec-its-cluster.C:164
 rec-its-cluster.C:165
 rec-its-cluster.C:166
 rec-its-cluster.C:167
 rec-its-cluster.C:168
 rec-its-cluster.C:169
 rec-its-cluster.C:170
 rec-its-cluster.C:171
 rec-its-cluster.C:172
 rec-its-cluster.C:173
 rec-its-cluster.C:174
 rec-its-cluster.C:175
 rec-its-cluster.C:176
 rec-its-cluster.C:177
 rec-its-cluster.C:178
 rec-its-cluster.C:179
 rec-its-cluster.C:180
 rec-its-cluster.C:181
 rec-its-cluster.C:182
 rec-its-cluster.C:183
 rec-its-cluster.C:184
 rec-its-cluster.C:185
 rec-its-cluster.C:186
 rec-its-cluster.C:187
 rec-its-cluster.C:188
 rec-its-cluster.C:189
 rec-its-cluster.C:190
 rec-its-cluster.C:191
 rec-its-cluster.C:192
 rec-its-cluster.C:193
 rec-its-cluster.C:194
 rec-its-cluster.C:195
 rec-its-cluster.C:196
 rec-its-cluster.C:197
 rec-its-cluster.C:198
 rec-its-cluster.C:199
 rec-its-cluster.C:200
 rec-its-cluster.C:201
 rec-its-cluster.C:202
 rec-its-cluster.C:203