]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/TPCLib/macros/sim-hlt-tpc.C
bugfix: making reading of MC information in ESDConverter independent of
[u/mrichter/AliRoot.git] / HLT / TPCLib / macros / sim-hlt-tpc.C
CommitLineData
d67ed322 1// $Id$
2/*
488581c1 3 * @file sim-hlt-tpc.C
4 * @brief HLT Conformal mapping tracker embedded into AliRoot simulation.
5 *
d67ed322 6 * Example macro to run the HLT Conformal mapping tracker embedded into
7 * AliRoot simulation. The reconstruction is done from the TPC digits.
8 *
833b3167 9 * Usage: aliroot -b -q sim-hlt-tpc.C | tee sim-hlt-tpc.log
d67ed322 10 *
025ba4dc 11 * The chain to be run is defined within the macro. The input data is
12 * read from the TPC.Digits.
d0545a3c 13 *
14 * The following options can be specified comma separated in a string:
025ba4dc 15 * <pre>
d0545a3c 16 * aliroot -b -q sim-hlt-tpc.C'("options")'
025ba4dc 17 * CA use the cellular automaton tracker and track merger
18 * CM use the conformal mapping tracker and track merger
19 * SORTED use CF pre-sorting and corresponding sequential CF
20 * algorithm, by default the algorithm capable of reading
21 * unsorted data is used
22 * RAW write raw data for all detectors
23 * RAWHLT write raw data only for HLT
24 * MC propagate the MC information
25 * </pre>
d67ed322 26 *
c5123824 27 * The macro asumes the data to be already simulated. If it should run
8f471af0 28 * within the initial simulation, comment the corresponding functions
29 * below (SetRunGeneration etc.)
30 *
488581c1 31 * @author Matthias.Richter@ift.uib.no
32 * @ingroup alihlt_tpc
d67ed322 33 */
d0545a3c 34sim_hlt_tpc(const char* options="CA")
d67ed322 35{
36 // this is just a tool to switch the logging systems
37 AliHLTLogging log;
38 //log.SwitchAliLog(0);
39
d0545a3c 40 ///////////////////////////////////////////////////////////////////////////////////////////////////
41 ///////////////////////////////////////////////////////////////////////////////////////////////////
42 ///////////////////////////////////////////////////////////////////////////////////////////////////
43 //
44 // scanning the options
45 //
025ba4dc 46 bool bUseCA=true; // use the CA tracker and merger
47 bool bCFSort=false; // CF pre-sorting and sequential CF algorithm
48 bool bRawData=false;// raw data for all detectors
49 bool bRawHLTData=false; // raw data only for HLT
50 bool bPropagateMC=false;
d0545a3c 51 TString tsOptions=options;
52 TObjArray* pTokens=tsOptions.Tokenize(",");
53 if (pTokens) {
54 for (int n=0; n<pTokens->GetEntries(); n++) {
55 TString arg=((TObjString*)pTokens->At(n))->GetString();
56 if (arg.CompareTo("ca", TString::kIgnoreCase)==0) {
57 bUseCA=true;
58 } else if (arg.CompareTo("cm", TString::kIgnoreCase)==0) {
59 bUseCA=false;
025ba4dc 60 } else if (arg.CompareTo("sorted", TString::kIgnoreCase)==0) {
61 bCFSort=true;
62 } else if (arg.CompareTo("unsorted", TString::kIgnoreCase)==0) {
63 bCFSort=false;
64 } else if (arg.CompareTo("raw", TString::kIgnoreCase)==0) {
65 bRawData=true;
66 } else if (arg.CompareTo("rawhlt", TString::kIgnoreCase)==0) {
67 bRawHLTData=true;
68 } else if (arg.CompareTo("mc", TString::kIgnoreCase)==0) {
69 bPropagateMC=true;
d0545a3c 70 } else {
71 cout << "unknown argument: " << arg << endl;
72 return 0;
73 }
74 }
75 delete pTokens;
76 }
77 // summary
78 cout << "using " << bUseCA?"CA":"CM" << " tracker" << endl;
79
7bf6c76d 80 ///////////////////////////////////////////////////////////////////////////////////////////////////
81 ///////////////////////////////////////////////////////////////////////////////////////////////////
82 ///////////////////////////////////////////////////////////////////////////////////////////////////
83 //
84 // init the HLT system in order to define the analysis chain below
85 //
86 AliHLTSystem* gHLT=AliHLTPluginBase::GetInstance();
87
88 ///////////////////////////////////////////////////////////////////////////////////////////////////
89 ///////////////////////////////////////////////////////////////////////////////////////////////////
90 ///////////////////////////////////////////////////////////////////////////////////////////////////
91 //
92 // define the analysis chain
93 //
94
95 // load TPCParam from OCDB
96 const char* cdbEntry="TPC/Calib/Parameters";
97 AliCDBManager* pMan=AliCDBManager::Instance();
98 AliTPCParam* pTPCParam=NULL;
99 if (pMan) {
100 if (!pMan->IsDefaultStorageSet()) {
101 pMan->SetDefaultStorage("local://$ALICE_ROOT/OCDB");
102 pMan->SetRun(0);
103 }
104 AliCDBEntry *pEntry = pMan->Get(cdbEntry);
105 if (pEntry &&
106 pEntry->GetObject() &&
107 (pTPCParam=dynamic_cast<AliTPCParam*>(pEntry->GetObject()))) {
108 } else {
109 HLTWarning("can not load AliTPCParam from CDB entry %s", cdbEntry);
110 }
111 }
112
113 int iMinSlice=0;
114 int iMaxSlice=35;
115 int iMinPart=0;
116 int iMaxPart=5;
117 TString mergerInput;
118 TString writerInput;
119 TString sinkClusterInput;
120 for (int slice=iMinSlice; slice<=iMaxSlice; slice++) {
121 TString trackerInput;
122 for (int part=iMinPart; part<=iMaxPart; part++) {
123 TString arg, publisher, cf;
124
125 // digit publisher components
126 arg.Form("-slice %d -partition %d", slice, part);
127 publisher.Form("DP_%02d_%d", slice, part);
128 AliHLTConfiguration pubconf(publisher.Data(), "TPCDigitPublisher", NULL , arg.Data());
129
130 // cluster finder components
131 arg="-timebins ";
132 if (pTPCParam) arg+=pTPCParam->GetMaxTBin()+1;
133 else arg+=446; // old simulated data
025ba4dc 134 if (bCFSort) arg+=" -sorted ";
135 if (bPropagateMC) arg+=" -do-mc ";
7bf6c76d 136 cf.Form("CF_%02d_%d", slice, part);
137 AliHLTConfiguration cfconf(cf.Data(), "TPCClusterFinderUnpacked", publisher.Data(), arg.Data());
138 if (trackerInput.Length()>0) trackerInput+=" ";
139 trackerInput+=cf;
140 if (sinkClusterInput.Length()>0) sinkClusterInput+=" ";
141 sinkClusterInput+=cf;
142 }
d0545a3c 143
7bf6c76d 144 TString tracker;
145 // tracker finder components
146 tracker.Form("TR_%02d", slice);
d0545a3c 147 if (bUseCA) {
025ba4dc 148 AliHLTConfiguration trackerconf(tracker.Data(), "TPCCATracker", trackerInput.Data(), "-newOutputType");
d0545a3c 149 } else {
150 AliHLTConfiguration trackerconf(tracker.Data(), "TPCSliceTracker", trackerInput.Data(), "-pp-run");
151 }
7bf6c76d 152
153 //add all trackers to writer input. Include if you would like all slice tracks written.
154 //if (writerInput.Length()>0) writerInput+=" ";
155 //writerInput+=tracker;
156
157 // add all clusterfinders to the writer input
158 if (writerInput.Length()>0) writerInput+=" ";
159 writerInput+=trackerInput;
160
161 if (mergerInput.Length()>0) mergerInput+=" ";
162 mergerInput+=tracker;
163
164 }
165
166 // GlobalMerger component
d0545a3c 167 if (bUseCA) {
168 AliHLTConfiguration mergerconf("globalmerger","TPCCAGlobalMerger",mergerInput.Data(),"");
169 } else {
170 AliHLTConfiguration mergerconf("globalmerger","TPCGlobalMerger",mergerInput.Data(),"");
171 }
d67ed322 172
025ba4dc 173 // collector for the MC information to be propagated from CFs to ESDConverter
174 AliHLTConfiguration mcinfo("mcinfo", "BlockFilter" , sinkClusterInput.Data(), "-datatype 'CLMCINFO' 'TPC '");
175
7bf6c76d 176 if (writerInput.Length()>0) writerInput+=" ";
177 writerInput+="globalmerger";
178
025ba4dc 179 TString converterInput="globalmerger";
180 if (bPropagateMC) converterInput+=" mcinfo";
181
7bf6c76d 182 //////////////////////////////////////////////////////////////////////////////////////////
183 //
184 // output section
185 //
186
187 //////////////////////////////////////////////////////////////////////////////////////////
188 // sink1: id=sink-writeall write all blocks
189 AliHLTConfiguration sink1("sink-writeall", "FileWriter" , writerInput.Data(), "-specfmt -subdir=event_%d -blcknofmt=_0x%x -idfmt=_0x%08x");
190
191
192 //////////////////////////////////////////////////////////////////////////////////////////
193 // sink2: id=sink-esd-file write ESD using the TPCEsdWriter
025ba4dc 194 AliHLTConfiguration sink2("sink-esd-file", "TPCEsdWriter" , converterInput.Data(), "-datafile AliHLTESDs.root");
7bf6c76d 195
196
197 //////////////////////////////////////////////////////////////////////////////////////////
198 // sink3: id=sink-esd add ESD to HLTOUT using the TPCEsdConverter
199
200 // the esd converter configuration
025ba4dc 201 AliHLTConfiguration sink3("sink-esd", "TPCEsdConverter" , converterInput.Data(), "");
7bf6c76d 202
203 //////////////////////////////////////////////////////////////////////////////////////////
204 // sink4: id=sink-clusters add cluster data blocks to HLTOUT
205 AliHLTConfiguration sink4("sink-clusters", "BlockFilter" , sinkClusterInput.Data(), "-datatype 'CLUSTERS' 'TPC '");
206
207 ///////////////////////////////////////////////////////////////////////////////////////////////////
208 ///////////////////////////////////////////////////////////////////////////////////////////////////
209 ///////////////////////////////////////////////////////////////////////////////////////////////////
210 //
211 // Init and run the HLT simulation
212 // All but HLT simulation is switched off
213 //
214 AliSimulation sim;
215
d67ed322 216 // switch of simulation and data generation
217 // comment all that stuff to also simulate the events and data
218 sim.SetRunGeneration(kFALSE);
219 sim.SetMakeDigits("");
220 sim.SetMakeSDigits("");
221 sim.SetMakeDigitsFromHits("");
222 sim.SetMakeTrigger("");
7bf6c76d 223 sim.SetRunQA(":");
025ba4dc 224 TString rawDataSelection="HLT";
225 if (bRawData) rawDataSelection="ALL";
226 if (bRawHLTData || bRawData) sim.SetWriteRawData(rawDataSelection, "raw.root", kTRUE);
d67ed322 227
228 // set the options for the HLT simulation
833b3167 229 sim.SetRunHLT("libAliHLTUtil.so libAliHLTTPC.so loglevel=0x7c "
7bf6c76d 230 "chains=sink-esd,sink-clusters");
d67ed322 231 sim.Run();
232}