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