]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/exa/extract-hltout-payload.C
- cleaning up the programs folder and removing old deprecated files
[u/mrichter/AliRoot.git] / HLT / exa / 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")' | 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  */
29 void extract_hltout_payload(const char* input, const char* selection="", int maxEvent=-1)
30 {
31   /////////////////////////////////////////////////////////////////////////
32   /////////////////////////////////////////////////////////////////////////
33   //
34   // setup of the HLT system
35   AliHLTSystem* pHLT=AliHLTPluginBase::GetInstance();
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);
78   } while (rawreader->NextEvent() && (maxEvent<0 || count<maxEvent));
79 }
80
81 void 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 }