]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/exa/simhlt.C
AliHLTJET module
[u/mrichter/AliRoot.git] / HLT / exa / simhlt.C
1 // $Id$
2
3 #if !defined(__CINT__)
4 #include "TString.h"
5 #include "TGrid.h"
6 #include "AliCDBManager.h"
7 #include "AliSimulation.h"
8 #include <iostream>
9 using namespace std;
10 #endif
11
12 /**
13  * @file simhlt.C
14  * @brief Run HLT reconstruction embedded into AliSimulation
15  *
16  * <pre>
17  * Usage: aliroot -b -q -l \
18  *     aliroot -b -q -l simhlt.C'("hltoption", "rawdataoptions", nofEvents, runNo, "cdbUri")'
19  *
20  * Examples:
21  *     simhlt.C'("loglevel=0x7c chains=GLOBAL-esd-converter")'
22  *       load all default libraries and run the chain 'GLOBAL-esd-converter'
23  *     simhlt.C'("loglevel=0x7c !libAliHLTITS.so")'
24  *       load all default libraries but the libAliHLTITS.so and run the
25  *       default chain, skips the ITS tracking
26  *     simhlt.C'("loglevel=0x7c rawfile=")'
27  *       run explicitly on digit data
28  *
29  * Defaults
30  *     rawdataoptions=""         -> skip generation of raw data
31  *     nofEvents=-1              -> take event count from simulated sample
32  *     runNo=-1                  -> take run number from simulated sample
33  *     cdbUri="local://$ALICE_ROOT/OCDB"
34  *
35  * Running with precompiled macro:
36  *     gSystem->AddIncludePath("-I$ROOTSYS/include -I$ALICE_ROOT/include");
37  *     gROOT->LoadMacro("$ALICE_ROOT/HLT/exa/simhlt.C++");
38  *     simhlt("loglevel=0x7c");
39  *
40  * </pre>
41  *
42  * This macro can be used to run the 'HLT simulation' standalone with an
43  * already simulated data sample. 'HLT simulation' means HLT reconstruction
44  * on simulated data, and is carried out at the end of the AliSimulation
45  * sequence.
46  *
47  * The definition of the HLT reconstruction chain depends on the available
48  * module plugins (component libraries). Each library defines a number of
49  * component configurations identified by a unique string. Here are a couple
50  * of definitions, but the list is by far not complete:
51  * - libAliHLTTPC.so:     TPC-clusters, TPC-globalmerger
52  * - libAliHLTITS.so:     ITS-tracker, ITS-SPD-vertexer
53  * - libAliHLTGlobal.so:  GLOBAL-esd-converter, GLOBAL-vertexhisto
54  * - libAliHLTTrigger.so: GLOBAL-Trigger
55  *
56  * This list will certainly develop over time, it is planned to add some
57  * helper functionality to AliHLTSystem for querying of such information.
58  *
59  * The definition of the chain depends on the availability of simulated raw
60  * data. If raw data is available, the HLT chain runs on this, otherwise on
61  * the digit data. \b NOTE: propagation of MC information is only possible
62  * for the latter case. Raw data generation must be either switched of, i.e.
63  * rawdataoptions is empty, or explicitly explicitly ignored by the HLT
64  * option 'rawfile=' (note the empty argument to the option).
65  *
66  * The output of the simulation are the HLT.Digits.root file and (if enabled)
67  * the HLT raw data files. You must run AliReconstruction in order to extract
68  * the simulated HLT data. A typical test sequence can be like:
69  *
70  * <pre>
71  * cd $ALICE_ROOT/test/ppbench
72  * ./runtest.sh
73  * aliroot -b -q -l simhlt.C'("loglevel=0x7c chains=GLOBAL-esd-converter")' \
74  *         | tee simhlt.C
75  * aliroot -b -q -l rec.C | tee rec.log
76  * </pre>
77  *
78  * @author Matthias.Richter@ift.uib.no
79  * @ingroup alihlt_tutorial
80  */
81 void simhlt(const char *hltOptions,
82             const char *rawDataSelection="",
83             int nofEvents=-1,
84             int runNo=-1,
85             const char *cdbURI="local://$ALICE_ROOT/OCDB"
86             )
87 {
88   ///////////////////////////////////////////////////////////////////////////////////////////////////
89   ///////////////////////////////////////////////////////////////////////////////////////////////////
90   ///////////////////////////////////////////////////////////////////////////////////////////////////
91   //
92   // connect to the GRID if we use a file or OCDB from the GRID
93   TString struri=cdbURI;
94   if (struri.Contains("://") && !struri.Contains("local://")) {
95     TGrid::Connect("alien");
96   }
97
98   // Set the CDB storage location
99   AliCDBManager * man = AliCDBManager::Instance();
100   man->SetDefaultStorage(cdbURI);
101
102   ///////////////////////////////////////////////////////////////////////////////////////////////////
103   ///////////////////////////////////////////////////////////////////////////////////////////////////
104   ///////////////////////////////////////////////////////////////////////////////////////////////////
105   //
106   // Init and run the HLT simulation
107   // All but HLT simulation is switched off
108   //
109   AliSimulation sim;
110  
111   // switch of simulation and data generation
112   // comment all that stuff to also simulate the events and data
113   sim.SetRunGeneration(kFALSE);
114   sim.SetMakeDigits("");
115   sim.SetMakeSDigits("");
116   sim.SetMakeDigitsFromHits("");
117   //sim.SetMakeTrigger("");
118   sim.SetRunQA("HLT:ALL");
119
120   // the normal simulation sets the specific storage for the GRP entry
121   if (gSystem->AccessPathName("GRP/GRP/Data")) {
122     cerr << "*********************************************************" << endl;
123     cerr << "error: no GRP entry found in the currect directory, simulation might be incomplete. Skip setting specific storage for GRP entry" << endl;
124     cerr << "*********************************************************" << endl << endl;
125   } else {
126     sim.SetSpecificStorage("GRP/GRP/Data",
127                            Form("local://%s",gSystem->pwd()));
128   }
129
130   // set the options for writing raw data, possible values e.g. ALL; HLT
131   if (rawDataSelection && rawDataSelection[0]!=0) {
132     sim.SetWriteRawData(rawDataSelection, "raw.root", kTRUE);
133   }
134
135   // set the options for the HLT simulation
136   sim.SetRunHLT(hltOptions);
137
138   if (runNo>=0) sim.SetRunNumber(runNo);
139
140   if (nofEvents>0) sim.Run(nofEvents);
141   else sim.Run();
142 }
143
144 void simhlt()
145 {
146   cout << "recraw-local: Run HLT reconstruction embedded into AliSimulation" << endl;
147   cout << " Usage: aliroot -b -q -l \\" << endl;
148   cout << "     aliroot -q simhlt.C'(\"hltoption\", \"rawdataoptions\", nofEvents, runNo, \"cdbUri\")'" << endl;
149   cout << "" << endl;
150   cout << " Examples:" << endl;
151   cout << "     aliroot -q simhlt.C'(\"loglevel=0x7c chains=GLOBAL-esd-converter\")'" << endl;
152   cout << "     aliroot -q simhlt.C'(\"loglevel=0x7c !libAliHLTITS.so\")'                " << endl;
153   cout << "     aliroot -q simhlt.C'(\"loglevel=0x7c rawfile=\")'                   " << endl;
154   cout << "" << endl;
155   cout << " Defaults" << endl;
156   cout << "     rawdataoptions=\"\"         -> skip generation of raw data         " << endl;
157   cout << "     nofEvents=-1              -> take event count from simulated sample" << endl;
158   cout << "     runNo=-1                  -> take run number from simulated sample " << endl;
159   cout << "     cdbUri=\"local://$ALICE_ROOT/OCDB\"                                " << endl;
160   cout << "" << endl;
161   cout << " The definition of the chain depends on the availability of simulated raw " << endl;
162   cout << " data. If raw data is available, the HLT chain runs on this, otherwise on " << endl;
163   cout << " the digit data. \b NOTE: propagation of MC information is only possible  " << endl;
164   cout << " for the latter case. Raw data generation must be either switched of, i.e." << endl;
165   cout << " rawdataoptions is empty, or explicitly explicitly ignored by the HLT          " << endl;
166   cout << " option 'rawfile=' (note the empty argument to the option).               " << endl;
167 }