]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/exa/extract-ddlraw.C
Debug msg
[u/mrichter/AliRoot.git] / HLT / exa / extract-ddlraw.C
CommitLineData
5aebebf7 1// $Id$
2/**
3 * @file extract-ddlraw.C
4 * @brief Tool to extract DDL raw data.
5 *
6 * Usage:
7 * <pre>
8 * aliroot -b -q 'extract-ddlraw.C("raw.root", 768, 769)' | tee extract-ddlraw.log
9 * </pre>
10 *
11 * This macro is an example for the AliHLTRawReaderPublisherComponent.
12 * It extracts the DDL payload from an AliRawReader in a given equipment
13 * range. Input can be either a root file or the path to the directory
14 * containing the 'rawx' sub folders.
15 *
16 * A light-weight AliReconstruction-like setup creates the appropriate
17 * RawReader for the specified input and uses the standard AliHLTReconstructor
18 * to run a small HLT chain. The chain utilizes the AliRawReaderPublisher
19 * to extract the payload of the equipments and writes this to files.
20 *
21 * @note In this example the AliHLTRawReaderPublisherComponent does not set any data
22 * type nor specification for the published data blocks. Please remember
23 * to provide appropriate arguments via '-datatype' and '-dataspec'
24 * arguments (see AliHLTRawReaderPublisherComponent).
25 *
26 * @author Matthias.Richter@ift.uib.no
27 * @ingroup alihlt_tutorial
28 */
0c409657 29void extract_ddlraw(const char* input, int iMinDDLno, int iMaxDDLno, int nofEvents=-1)
5aebebf7 30{
31 /////////////////////////////////////////////////////////////////////////
32 /////////////////////////////////////////////////////////////////////////
33 //
34 // some defaults
35 const char* baseName="RAW.ddl";
36
37 /////////////////////////////////////////////////////////////////////////
38 /////////////////////////////////////////////////////////////////////////
39 //
40 // setup of the RawReader
41 if (!input) {
42 cerr << "invalid path" << endl;
43 cerr << "usage: aliroot -b -q 'extract-ddlraw.C(\"raw.root\", 768, 769)'" << endl;
44 return;
45 }
46
0c409657 47 TString strfile=input;
48 if (strfile.Contains("://") && !strfile.Contains("local://")) {
49 TGrid::Connect("alien");
50 }
51
5aebebf7 52 AliRawReader* pRawReader=AliRawReader::Create(input);
53 if (!pRawReader) {
54 cout << "can not open RawReader for file " << input << endl;
55 return;
56 }
0c409657 57
5aebebf7 58 if (!pRawReader->NextEvent()) {
59 cerr << "no events available" << endl;
60 return;
61 }
62
63 /////////////////////////////////////////////////////////////////////////
64 /////////////////////////////////////////////////////////////////////////
65 //
66 // setup of the HLT system
7bf6c76d 67 AliHLTSystem* pHLT=AliHLTPluginBase::GetInstance();
5aebebf7 68 if (!pHLT) {
69 cerr << "fatal error: can not get HLT instance" << endl;
70 }
71
72 /////////////////////////////////////////////////////////////////////////
73 /////////////////////////////////////////////////////////////////////////
74 //
75 // the configuration chain
76 // we show two possible configurations:
77 // 1. having one publisher for each ddl, the configurations are created
78 // in a loop
79 // 2. all in one publisher
80 // can be easily switched with the following
0c409657 81 bool bAllInOne=true;
5aebebf7 82
83 TString writerInput;
84 TString arg;
85
86 if (!bAllInOne) {
87 // create one publisher for each ddl
88 for (int ddlno=iMinDDLno; ddlno<=iMaxDDLno; ddlno++) {
89 TString arg, publisher;
90
91 // raw data publisher components
03df9065 92 arg.Form("-minid %d -skipempty -verbose", ddlno);
5aebebf7 93 publisher.Form("DP_%d", ddlno);
94 // see AliHLTRawReaderPublisherComponent
95 AliHLTConfiguration pubconf(publisher.Data(), "AliRawReaderPublisher", NULL , arg.Data());
96
97 if (!writerInput.IsNull()) writerInput+=" ";
98 writerInput+=publisher;
99 }
100 } else {
101 // publish all ddls by the same component, this is much more
102 // effective as it avoids repeated parsing through the data
03df9065 103 arg.Form("-minid %d -maxid %d -skipempty -verbose", iMinDDLno, iMaxDDLno);
5aebebf7 104 // see AliHLTRawReaderPublisherComponent
105 AliHLTConfiguration pubconf("publisher", "AliRawReaderPublisher", NULL , arg.Data());
106 if (!writerInput.IsNull()) writerInput+=" ";
107 writerInput+="publisher";
108 }
109
110 // the writer configuration is the same for both
111 arg.Form("-specfmt=_%%d -subdir=raw%%d -blcknofmt= -idfmt= -datafile %s", baseName);
112 // see AliHLTFileWriter
113 AliHLTConfiguration fwconf("sink1", "FileWriter" , writerInput.Data(), arg.Data());
114
115
116 /////////////////////////////////////////////////////////////////////////
117 /////////////////////////////////////////////////////////////////////////
118 //
119 // the reconstructor setup
120 AliHLTReconstructor hltRec;
0c409657 121 hltRec.SetOption("libAliHLTUtil.so loglevel=0x7c chains=sink1 ignore-hltout ignore-ctp");
5aebebf7 122 if (hltRec.Init()<0) {
123 cerr << "initialization of reconstructor failed" << endl;
124 return;
125 }
126
127 // this is just a dummy ESD to provide valid parameters to the
128 // reconstructor
129 AliESDEvent* pESD = new AliESDEvent;
130 pESD->CreateStdContent();
131
132 /////////////////////////////////////////////////////////////////////////
133 /////////////////////////////////////////////////////////////////////////
134 //
135 // the reconstruction loop
136 Int_t event=0;
137 UChar_t* pData=NULL;
138 pRawReader->RewindEvents();
0c409657 139 while (pRawReader->NextEvent() &&
140 (nofEvents<0 || event<nofEvents)) {
5aebebf7 141 cout << "=======================================================" << endl;
142 cout << "event " << event << endl;
143 cout << "-------------------------------------------------------" << endl;
144 pRawReader->Reset();
7384319f 145 hltRec.Reconstruct(pRawReader, NULL);
5aebebf7 146 event++;
147 }
148
149 delete pESD;
150}
151
152void extract_ddlraw()
153{
154 cerr << "===============================================================" << endl;
155 cerr << "usage: aliroot -b -q 'extract-ddlraw.C(\"raw.root\", 768, 769)'" << endl << endl;
156 cerr << "please provide input, min and max equipment id" << endl;
157 cerr << "===============================================================" << endl;
158}