]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/TPCLib/macros/rec-hlt-tpc.C
The present commit corresponds to an important change in the way the
[u/mrichter/AliRoot.git] / HLT / TPCLib / macros / rec-hlt-tpc.C
1 // $Id$
2 /*
3  * Example macro to run the HLT Conformal mapping tracker embedded into
4  * AliRoot reconstruction. The reconstruction is done from the TPC raw
5  * data.
6  *
7  * Usage:
8  * <pre>
9  *   aliroot -b -q rec-hlt-tpc.C | tee rec-hlt-tpc.log
10  *   aliroot -b -q rec-hlt-tpc.C'("./","decoder All")' | tee rec-hlt-tpc.log
11  * </pre>
12  *
13  * The macro asumes raw data to be available in the rawx folders, either
14  * simulated or real data. A different input can be specified as parameter
15  * <pre>
16  *   aliroot -b -q rec-hlt-tpc.C'("input.root")'
17  * </pre>
18  *
19  * The second parameter changes which clusterfinder you use:
20  *    - decoder, uses TPCClusterFinderDecoder. This is default.
21  *    - packed, uses TPCClusterFinderPacked
22  *
23  * Also in the second parameter you can set which output you would like to have:
24  *    - ESD, gives you an ESD file. This is default.
25  *    - TrackHistogram, will run the TrackHistogram component, and give 
26  *      root files with histograms.
27  *    - TrackDump, dumps the track struct to a text file.
28  *    - ClusterHisto, gives you histograms of the cluster.
29  *    - ClusterDump, dumps the cluster struct to text flie.
30  *    - All, gives you all 3 output.
31  *
32  * In the first section, an analysis chain is defined. The scale of the
33  * chain can be defined by choosing the range of sectors and partitions.
34  *
35  * The reconstruction is steered by the AliReconstruction object in the
36  * usual way.
37  *
38  * @ingroup alihlt_tpc
39  * @author Matthias.Richter@ift.uib.no
40  */
41 void rec_hlt_tpc(const char* input="./", char* opt="decoder ESD")
42 {
43   
44   if(!gSystem->AccessPathName("galice.root")){
45     cerr << "please delete the galice.root or run at different place." << endl;
46     return;
47   }
48
49   if (!input) {
50     cerr << "please specify input or run without arguments" << endl;
51     return;
52   }
53
54   ///////////////////////////////////////////////////////////////////////////////////////////////////
55   //
56   // init the HLT system in order to define the analysis chain below
57   //
58   gSystem->Load("libHLTrec.so");
59   AliHLTSystem* gHLT=AliHLTReconstructorBase::GetInstance();
60  
61   ///////////////////////////////////////////////////////////////////////////////////////////////////
62   //
63   // Setting up which output to give
64   //
65   Bool_t bUseClusterFinderDecoder=kTRUE;
66   TString option="libAliHLTUtil.so libAliHLTRCU.so libAliHLTTPC.so loglevel=0x7c chains=";
67   Bool_t esdout=kFALSE, dumpout=kFALSE, histout=kFALSE, chout=kFALSE, cdout=kFALSE;
68   TString allArgs=opt;
69   TString argument;
70   TObjArray* pTokens=allArgs.Tokenize(" ");
71   if (pTokens) {
72     for (int i=0; i<pTokens->GetEntries(); i++) {
73       argument=((TObjString*)pTokens->At(i))->GetString();
74       if (argument.IsNull()) continue;
75  
76       if (argument.Contains("-statistics=")) {
77         argument.ReplaceAll("-statistics=", "");
78         if (argument.Contains("root")) {
79           if (option.Length()>0) option+=",";
80           option+="statroot";
81         }
82         if (argument.Contains("raw")) {
83           if (option.Length()>0) option+=",";
84           option+="statraw";
85         }
86         continue;
87       }
88       if (argument.CompareTo("decoder",TString::kIgnoreCase)==0) {
89         bUseClusterFinderDecoder = kTRUE;
90         continue;
91       }
92       if (argument.CompareTo("packed",TString::kIgnoreCase)==0) {
93         bUseClusterFinderDecoder = kFALSE;
94         continue;
95       }
96       if (argument.CompareTo("trackhistogram",TString::kIgnoreCase)==0) {
97         histout = kTRUE;
98         if (option.Length()>0) option+=",";
99         option+="histFile";
100         continue;
101       }
102       if (argument.CompareTo("trackdump",TString::kIgnoreCase)==0) {
103         dumpout = kTRUE;
104         if (option.Length()>0) option+=",";
105         option+="dump";
106         continue;
107       }
108       if (argument.CompareTo("esd",TString::kIgnoreCase)==0) {
109         esdout = kTRUE;
110         if (option.Length()>0) option+=",";
111         option+="sink1";
112         continue;
113       }      
114       if (argument.CompareTo("clusterdump",TString::kIgnoreCase)==0) {
115         cdout = kTRUE;
116         if (option.Length()>0) option+=",";
117         option+="cdump";
118         continue;
119       }      
120       if (argument.CompareTo("clusterhisto",TString::kIgnoreCase)==0) {
121         chout = kTRUE;
122         if (option.Length()>0) option+=",";
123         option+="chhisto";
124         continue;
125       }      
126       if (argument.CompareTo("all",TString::kIgnoreCase)==0) {
127         histout = kTRUE;
128         dumpout = kTRUE;
129         esdout = kTRUE;
130         chout = kTRUE;
131         cdout = kTRUE;
132         if (option.Length()>0) option+=",";
133         option+="sink1,histFile,dump,cdump,chhisto";
134         continue;
135       }
136       else {
137         break;
138       }
139     }
140   }
141   if (!histout && !dumpout && !esdout && !chout && !cdout) {
142     cout << "you need to specify an output option, on or more out of: ESD, TrackHistogram, TrackDump, ClusterHisto, ClusterDump" << endl;
143     return;
144   }
145   if ((option.Contains("statroot") || option.Contains("statraw")) && !esdout) {
146     cout << "!!!!!!!! Warning: HLT statistics are only collected for output type ESD !!!!!!!!" << endl;
147   }
148
149   ///////////////////////////////////////////////////////////////////////////////////////////////////
150   //
151   // define the analysis chain to be run
152   //
153   int iMinSlice=0;
154   int iMaxSlice=35;
155   int iMinPart=0;
156   int iMaxPart=5;
157   TString writerInput;
158   TString mergerInput;
159   TString histoInput;
160   TString histogramHandlerInputClusterFinder;
161   TString cdumpInput;
162   for (int slice=iMinSlice; slice<=iMaxSlice; slice++) {
163     TString trackerInput;
164     for (int part=iMinPart; part<=iMaxPart; part++) {
165       TString arg, publisher, cf;
166       TString clusterHistoOutput;
167       // raw data publisher components
168       int ddlno=768;
169       if (part>1) ddlno+=72+4*slice+(part-2);
170       else ddlno+=2*slice+part;
171       arg.Form("-minid %d -datatype 'DDL_RAW ' 'TPC '  -dataspec 0x%02x%02x%02x%02x -verbose", ddlno, slice, slice, part, part);
172       publisher.Form("DP_%02d_%d", slice, part);
173       AliHLTConfiguration pubconf(publisher.Data(), "AliRawReaderPublisher", NULL , arg.Data());
174
175       // cluster finder components
176       cf.Form("CF_%02d_%d", slice, part);
177       if (bUseClusterFinderDecoder) {
178         AliHLTConfiguration cfconf(cf.Data(), "TPCClusterFinderDecoder", publisher.Data(), "-timebins 1001");
179       } else {
180         AliHLTConfiguration cfconf(cf.Data(), "TPCClusterFinderPacked", publisher.Data(), "-timebins 1001 -sorted");
181       }
182       if (trackerInput.Length()>0) trackerInput+=" ";
183       trackerInput+=cf;
184       if (writerInput.Length()>0) writerInput+=" ";
185       writerInput+=cf;
186       if (histoInput.Length()>0) histoInput+=" ";
187       histoInput+=cf;
188       if (cdumpInput.Length()>0) cdumpInput+=" ";
189       cdumpInput+=cf;
190
191       if(chout){
192         clusterHistoOutput.Form("CH_%02d_%d", slice, part);
193         AliHLTConfiguration cfconf(clusterHistoOutput.Data(), "TPCClusterHisto", cf.Data(), "");
194         if (histogramHandlerInputClusterFinder.Length()>0) histogramHandlerInputClusterFinder+=" ";
195         histogramHandlerInputClusterFinder+=clusterHistoOutput;
196       }
197     }
198     TString tracker;
199     // tracker finder components
200     tracker.Form("TR_%02d", slice);
201     AliHLTConfiguration trackerconf(tracker.Data(), "TPCSliceTracker", trackerInput.Data(), "-pp-run -solenoidBz 0.5");
202     if (writerInput.Length()>0) writerInput+=" ";
203     writerInput+=tracker;
204     if (mergerInput.Length()>0) mergerInput+=" ";
205     mergerInput+=tracker;
206     //add all slice tracks to histo input
207     //if (histoInput.Length()>0) histoInput+=" ";
208     //histoInput+=tracker;
209   }
210
211   // GlobalMerger component
212   AliHLTConfiguration mergerconf("globalmerger","TPCGlobalMerger",mergerInput.Data(),"");
213   
214   //add all global tracks to histo input
215   if (histoInput.Length()>0) histoInput+=" ";
216   histoInput+="globalmerger";
217   
218   // specify whether to write all blocks separately or merge the tracks
219   // and convert to ESD
220   bool writeBlocks=false;
221
222   if(esdout){
223     if (writeBlocks) {
224       // the writer configuration
225       AliHLTConfiguration fwconf("sink1", "FileWriter"   , writerInput.Data(), "-specfmt=_%d -subdir=out_%d -blcknofmt=_0x%x -idfmt=_0x%08x");
226     } else {
227            
228       //AliHLTConfiguration sink("sink1", "TPCEsdWriter"   , "globalmerger", "-datafile AliHLTESDs.root");
229       
230       // the esd converter configuration
231       AliHLTConfiguration esdcconf("esd-converter", "TPCEsdConverter"   , "globalmerger", "");
232       
233       // the root file writer configuration
234       AliHLTConfiguration sink("sink1", "EsdCollector"   , "esd-converter", "-directory hlt-tpc-esd");
235
236       // optional component statistics
237       AliHLTConfiguration statroot("statroot", "StatisticsCollector"   , "esd-converter", "-file HLT.statistics.root -publish 0");
238       AliHLTConfiguration statraw("statraw", "FileWriter"   , "esd-converter", "-datatype COMPSTAT PRIV -datafile HLT.statistics.raw -concatenate-blocks -concatenate-events");
239     }
240   }
241   //Chain with Track Histogram
242   if(histout){
243     AliHLTConfiguration histoconf("histo","TPCTrackHisto",histoInput.Data(),"");  
244     AliHLTConfiguration fwconf("histFile", "ROOTFileWriter"   , "histo", "-datafile TrackHisto -concatenate-events -overwrite");
245   }
246   //Chain with Track Dump
247   if(dumpout){
248     AliHLTConfiguration dumpconf("dump","TPCTrackDump","globalmerger","-directory TrackDump");
249   }
250   if(chout){
251     AliHLTConfiguration cfconf("HHCF", "TPCHistogramHandler", histogramHandlerInputClusterFinder.Data(), "-use-general");
252     AliHLTConfiguration rootFileWriterClusters("chhisto", "ROOTFileWriter", "HHCF" , "-datafile histogramHandlerClusterFinder -concatenate-events -overwrite");
253   }
254   if(cdout){
255     AliHLTConfiguration cdumpconf("cdump","TPCClusterDump",cdumpInput.Data(),"-directory ClusterDump");
256   }
257
258
259   ///////////////////////////////////////////////////////////////////////////////////////////////////
260   //
261   // Init and run the reconstruction
262   // All but HLT reconstructio is switched off
263   //
264   AliReconstruction rec;
265   rec.SetInput(input);
266   rec.SetRunVertexFinder(kFALSE);
267   rec.SetRunLocalReconstruction("HLT");
268   rec.SetRunTracking("");
269   rec.SetLoadAlignFromCDB(0);
270   rec.SetRunQA(":");
271
272   // NOTE: FillESD is a step in the AliReconstruction sequence and has
273   // nothing to do with the fact that this macro writes ESD output
274   // HLT processes the HLTOUT during FillESD and extracts data which
275   // has already been prepared. This step is currently not necessary for
276   // this macro
277   rec.SetFillESD("");
278   rec.SetOption("HLT", option);
279   rec.Run();
280 }