]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/programs/extract-hltout-payload.C
provide OCDB URI as macro argument
[u/mrichter/AliRoot.git] / HLT / programs / extract-hltout-payload.C
1 // $Id$
2 /**
3  * @file extract-hltout-payload.C
4  * @brief Extraction of data blocks from HLTOUT
5  *
6  * <pre>
7  * Usage: aliroot -b -q extract-hltout-payload.C'("raw.root", "selection", nofEvents)' \
8  *            | tee extract-hltout-payload.log
9  *
10  * Defaults
11  *     selection=""      -> no data type selection
12  *     nofEvents=-1      -> all events
13  * </pre>
14  *
15  * The raw input file can be accessed directly from the GRID, e.g
16  * "alien:///alice/data/2010/LHC10b/000115887/raw/10000115887021.20.root"
17  *
18  * The macro stores all data blocks from the HLTOUT payload into separated
19  * folders for each event. The file names are derived from data type and
20  * specification of the block. Data is read from a raw reader. An input
21  * file can be specified as the first argument, default is "./" and reads
22  * ddl files through AliRawReaderFile.
23  *
24  * A selection criterion can be specified as second argument, the format
25  * of the selection string follows the arguments of the 
26  * AliHLTOUTPublisherComponent except from the quote which need to be
27  * replaced by brackets due to CINT, e.g.
28  *
29  * <pre>
30  * aliroot -b -q extract-hltout-payload.C'("raw.root", "-datatype {DDL_RAW } ISDD")'
31  * aliroot -b -q extract-hltout-payload.C'("raw.root", "-origin {TPC }")'
32  * </pre>
33  *
34  * @author Matthias.Richter@ift.uib.no
35  * @ingroup alihlt_programs
36  */
37 void extract_hltout_payload(const char* input, const char* selection="", int maxEvent=-1)
38 {
39   /////////////////////////////////////////////////////////////////////////
40   /////////////////////////////////////////////////////////////////////////
41   //
42   // setup GRID if input is not a local file
43   TString strfile=input;
44   if (strfile.Contains("://") && !strfile.Contains("local://")) {
45     TGrid::Connect("alien");
46   }
47
48   /////////////////////////////////////////////////////////////////////////
49   /////////////////////////////////////////////////////////////////////////
50   //
51   // setup of the HLT system
52   AliHLTSystem* pHLT=AliHLTPluginBase::GetInstance();
53   if (!pHLT) {
54     cerr << "fatal error: can not get HLT instance" << endl;
55   }
56
57   /////////////////////////////////////////////////////////////////////////
58   /////////////////////////////////////////////////////////////////////////
59   //
60   // the configuration chain
61   TString arg;
62
63   // the publisher configuration
64   arg.Form("%s", selection);
65   arg.ReplaceAll("{", "'");
66   arg.ReplaceAll("}", "'");
67   AliHLTConfiguration publisher("hltout-publisher", "AliHLTOUTPublisher" , NULL, arg.Data());
68
69   // the writer configuration
70   arg.Form("-subdir=event_%%d -blocknofmt= -datafile hltout.dat -specfmt");
71   AliHLTConfiguration collector("sink1", "FileWriter"   , "hltout-publisher", arg.Data());
72
73   /////////////////////////////////////////////////////////////////////////
74   /////////////////////////////////////////////////////////////////////////
75   //
76   // setup of the reconstruction
77
78   AliHLTReconstructor hltRec;
79   hltRec.Init("chains=sink1 ignore-ctp");
80
81   AliRawReader* rawreader=AliRawReader::Create(input);
82   if (!rawreader) {
83     return;
84   }
85   rawreader->RewindEvents();
86   int count=0;
87   if (!rawreader->NextEvent()) {
88     cout << "no events found in " << input << endl;
89     return;
90   }
91
92   do {
93     cout << "processing event " << count++ << endl;
94     hltRec.Reconstruct(rawreader, NULL);
95   } while (rawreader->NextEvent() && (maxEvent<0 || count<maxEvent));
96 }
97
98 void extract_hltout_payload()
99 {
100   cerr << "==============================================================================" << endl;
101   cerr << "usage: aliroot -b -q -l extract-hltout-payload.C'(input, selection, maxEvent)'" << endl << endl;
102   cerr << "please provide input, e.g. \"raw.root\", or \"./\"" << endl;
103   cerr << "optional data type selection, e.g \"-datatype {DDL_RAW } ISDD\", " << endl;
104   cerr << "                                  \"-origin {TPC }\", \"-typeid {DDL_RAW }\"" << endl;
105   cerr << "optional max event" << endl;
106   cerr << "==============================================================================" << endl;
107 }