]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/exa/sampleRawAnalysis.C
- macro to extract the HLT ESD from raw data without the need of the irrelevant OCDB...
[u/mrichter/AliRoot.git] / HLT / exa / sampleRawAnalysis.C
1 // $Id$
2 void sampleRawAnalysis();
3 /**
4  * @file sampleRawAnalysis.C
5  * @brief Example macro to run the AliHLTSampleRawAnalysisComponent in
6  * AliReconstruction.
7  *
8  * The component subscribes to DDL raw data published by the
9  * AliHLTRawReaderPublisherComponent. The macros requires a raw data file
10  * and a corresponding GRP entry.
11  *
12  * <pre>
13  * Usage: aliroot -b -q -l \
14  *     sampleRawAnalysis.C'("rawfile", "cdb", minEvent, maxEvent)'
15  *
16  * Examples:
17  *     sampleRawAnalysis.C'("raw.root", minEvent, MaxEvent)'
18  *     sampleRawAnalysis.C'("./", minEvent, MaxEvent)'
19  *     sampleRawAnalysis.C'("alien:///alice/data/2010/.../raw/....root")' 
20  *
21  * Defaults
22  *     cdb="local://$ALICE_ROOT/OCDB" -> take local OCDB from distribution
23  *     minEvent=-1   -> no lower event selection
24  *     maxEvent=-1   -> no upper event selection
25  *
26  * </pre>
27  *
28  * The input file can be a local raw.root file but also a file from the
29  * GRID. The separate DDL files generated in simulation can be accessed
30  * using AliRawReaderFile by speficying "directory/".
31  *
32  * Since the macro runs AliReconstruction the OCDB needs to be set up, in
33  * particular the GRP entry. If testing with a local OCDB you have to
34  * simulate some events and run the macro in the folder of the simulation.
35  * Also HLT components configure from objects in the OCDB.
36  *
37  * Note: You need a valid GRID token, if you want to access files directly
38  * from the Grid, use 'alien-token-init' of your alien installation.
39  *
40  * @author Matthias.Richter@ift.uib.no
41  * @ingroup alihlt_tutorial
42  */
43 void sampleRawAnalysis(const char *filename,
44                        const char *cdbURI,
45                        int minEvent=-1,
46                        int maxEvent=-1)
47 {
48   if(!gSystem->AccessPathName("galice.root")){
49     cerr << "AliReconstruction on raw data requires to delete galice.root, or run at different place." << endl;
50     cerr << "!!! DO NOT DELETE the galice.root of your simulation, but create a subfolder !!!!" << endl;
51     return;
52   }
53
54   if (gSystem->AccessPathName(filename)) {
55     cerr << "can not find file " << filename << endl;
56     return;
57   }
58
59   // connect to the GRID if we use a file or OCDB from the GRID
60   TString struri=cdbURI;
61   TString strfile=filename;
62   if (struri.BeginsWith("raw://") ||
63       strfile.Contains("://") && !strfile.Contains("local://")) {
64     TGrid::Connect("alien");
65   }
66
67   // Set the CDB storage location
68   AliCDBManager * man = AliCDBManager::Instance();
69   man->SetDefaultStorage(cdbURI);
70   if (struri.BeginsWith("local://")) {
71     // set specific storage for GRP entry
72     // search in the working directory and one level above, the latter
73     // follows the standard simulation setup like e.g. in test/ppbench
74     if (!gSystem->AccessPathName("GRP/GRP/Data")) {
75       man->SetSpecificStorage("GRP/GRP/Data", "local://$PWD");
76     } else if (!gSystem->AccessPathName("../GRP/GRP/Data")) {
77       man->SetSpecificStorage("GRP/GRP/Data", "local://$PWD/..");      
78     } else {
79       cerr << "can not find a GRP entry, please run the macro in the folder" << endl;
80       cerr << "of a simulated data sample, or specify a GRID OCDB" << endl;
81       sampleRawAnalysis();      
82       return;
83     }
84   }
85
86   //////////////////////////////////////////////////////////////////////////////////////
87   //
88   // Reconstruction settings
89   AliReconstruction rec;
90
91   if (minEvent>=0 || maxEvent>minEvent) {
92     if (minEvent<0) minEvent=0;
93     if (maxEvent<minEvent) maxEvent=minEvent;
94     rec.SetEventRange(minEvent,maxEvent);
95   }
96   rec.SetRunReconstruction("HLT");
97   rec.SetLoadAlignFromCDB(kFALSE);
98   rec.SetWriteESDfriend(kFALSE);
99   // due to bug ...
100   // StopOnError needs to be disabled
101   rec.SetStopOnError(kFALSE);
102   rec.SetRunVertexFinder(kFALSE);
103   rec.SetInput(filename);
104
105   // QA options
106   rec.SetRunQA(":") ;
107   //rec.SetQARefDefaultStorage("local://$ALICE_ROOT/QAref") ;
108
109   //////////////////////////////////////////////////////////////////////////////////////
110   //
111   // setup the HLT system
112   AliHLTSystem* pHLT=AliHLTPluginBase::GetInstance();
113
114   // define a data publisher configuration
115   // arguments:
116   //  1) id of the configuartion, later used to refer to this configuration
117   //  2) id of the component to run
118   //  3) parents, no parents for publisher components
119   //  4) optional component arguments
120   //              publish link #512, the first link (numbered 0) of SSD
121   AliHLTConfiguration publisher("RAW-Publisher", 
122                                 "AliRawReaderPublisher", 
123                                 "", 
124                                 "-minid 512 "
125                                 "-datatype 'DDL_RAW ' 'ISSD' "
126                                 "-dataspec 0x01"
127                                 );
128
129   // define configuration of the SampleRawAnalyis component
130   // arguments:
131   //  1) id of the configuartion, later used to refer to this configuration
132   //  2) id of the component to run
133   //  3) parents, here the publisher configuration defined above
134   //  4) optional component arguments
135   AliHLTConfiguration rawanalysis("RAW-Analysis", 
136                                   "SampleRawAnalysis", 
137                                   "RAW-Publisher", 
138                                   "-mandatory1 test "
139                                   "-verbose"
140                                   );
141
142   // set option for the HLT module in AliReconstruction
143   // arguments
144   //  - ignore-hltout : ignore the HLTOUT payload from the HLT DDLs
145   //  - libraries to be used as plugins
146   //  - loglevel=0x7c : Important, Info, Warning, Error, Fatal
147   //  - chains=RAW-Analysis : chains to be run
148   rec.SetOption("HLT",
149                 "ignore-hltout " 
150                 "libAliHLTUtil.so libAliHLTSample.so "
151                 "loglevel=0x7c "
152                 "chains=RAW-Analysis "
153                 );
154
155   rec.SetRunPlaneEff(kFALSE);
156
157   // switch off cleanESD
158   rec.SetCleanESD(kFALSE);
159
160   AliLog::Flush();
161   rec.Run();
162
163 }
164
165 void sampleRawAnalysis(const char *filename,
166                        int minEvent=-1,
167                        int maxEvent=-1)
168 {
169   sampleRawAnalysis(filename, "local://$ALICE_ROOT/OCDB", minEvent, maxEvent);
170 }
171
172 void sampleRawAnalysis()
173 {
174   cout << "sampleRawAnalysis: Run HLT component 'SampleRawAnalyis' in AliReconstruction" << endl;
175   cout << " Usage: aliroot -b -q -l \\" << endl;
176   cout << "     sampleRawAnalysis.C'(\"file\", \"cdb\", minEvent, maxEvent)'" << endl;
177   cout << "" << endl;
178   cout << " Examples:" << endl;
179   cout << "     sampleRawAnalysis.C'(\"raw.root\", minEvent, MaxEvent)'" << endl;
180   cout << "     sampleRawAnalysis.C'(\"./\", minEvent, MaxEvent)'" << endl;
181   cout << "     sampleRawAnalysis.C'(\"alien:///alice/data/2010/.../raw/....root\")' " << endl;
182   cout << "" << endl;
183   cout << " Defaults" << endl;
184   cout << "     cdb=\"local://$ALICE_ROOT/OCDB\"  -> take local OCDB" << endl;
185   cout << "     minEvent=-1   -> no lower event selection" << endl;
186   cout << "     maxEvent=-1   -> no upper event selection" << endl;
187 }