]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/exa/extract-ddlraw.C
changing default verbosity of AliRawReaderPublisher to 'silent' in order to avoid...
[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 */
29void extract_ddlraw(const char* input, int iMinDDLno, int iMaxDDLno)
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
47 AliRawReader* pRawReader=AliRawReader::Create(input);
48 if (!pRawReader) {
49 cout << "can not open RawReader for file " << input << endl;
50 return;
51 }
52 if (!pRawReader->NextEvent()) {
53 cerr << "no events available" << endl;
54 return;
55 }
56
57 /////////////////////////////////////////////////////////////////////////
58 /////////////////////////////////////////////////////////////////////////
59 //
60 // setup of the HLT system
61 gSystem->Load("libHLTrec");
62 AliHLTSystem* pHLT=AliHLTReconstructorBase::GetInstance();
63 if (!pHLT) {
64 cerr << "fatal error: can not get HLT instance" << endl;
65 }
66
67 /////////////////////////////////////////////////////////////////////////
68 /////////////////////////////////////////////////////////////////////////
69 //
70 // the configuration chain
71 // we show two possible configurations:
72 // 1. having one publisher for each ddl, the configurations are created
73 // in a loop
74 // 2. all in one publisher
75 // can be easily switched with the following
76 bool bAllInOne=false;
77
78 TString writerInput;
79 TString arg;
80
81 if (!bAllInOne) {
82 // create one publisher for each ddl
83 for (int ddlno=iMinDDLno; ddlno<=iMaxDDLno; ddlno++) {
84 TString arg, publisher;
85
86 // raw data publisher components
03df9065 87 arg.Form("-minid %d -skipempty -verbose", ddlno);
5aebebf7 88 publisher.Form("DP_%d", ddlno);
89 // see AliHLTRawReaderPublisherComponent
90 AliHLTConfiguration pubconf(publisher.Data(), "AliRawReaderPublisher", NULL , arg.Data());
91
92 if (!writerInput.IsNull()) writerInput+=" ";
93 writerInput+=publisher;
94 }
95 } else {
96 // publish all ddls by the same component, this is much more
97 // effective as it avoids repeated parsing through the data
03df9065 98 arg.Form("-minid %d -maxid %d -skipempty -verbose", iMinDDLno, iMaxDDLno);
5aebebf7 99 // see AliHLTRawReaderPublisherComponent
100 AliHLTConfiguration pubconf("publisher", "AliRawReaderPublisher", NULL , arg.Data());
101 if (!writerInput.IsNull()) writerInput+=" ";
102 writerInput+="publisher";
103 }
104
105 // the writer configuration is the same for both
106 arg.Form("-specfmt=_%%d -subdir=raw%%d -blcknofmt= -idfmt= -datafile %s", baseName);
107 // see AliHLTFileWriter
108 AliHLTConfiguration fwconf("sink1", "FileWriter" , writerInput.Data(), arg.Data());
109
110
111 /////////////////////////////////////////////////////////////////////////
112 /////////////////////////////////////////////////////////////////////////
113 //
114 // the reconstructor setup
115 AliHLTReconstructor hltRec;
116 hltRec.SetOption("libAliHLTUtil.so loglevel=0x7c chains=sink1");
117 if (hltRec.Init()<0) {
118 cerr << "initialization of reconstructor failed" << endl;
119 return;
120 }
121
122 // this is just a dummy ESD to provide valid parameters to the
123 // reconstructor
124 AliESDEvent* pESD = new AliESDEvent;
125 pESD->CreateStdContent();
126
127 /////////////////////////////////////////////////////////////////////////
128 /////////////////////////////////////////////////////////////////////////
129 //
130 // the reconstruction loop
131 Int_t event=0;
132 UChar_t* pData=NULL;
133 pRawReader->RewindEvents();
134 while (pRawReader->NextEvent()) {
135 cout << "=======================================================" << endl;
136 cout << "event " << event << endl;
137 cout << "-------------------------------------------------------" << endl;
138 pRawReader->Reset();
7384319f 139 hltRec.Reconstruct(pRawReader, NULL);
5aebebf7 140 event++;
141 }
142
143 delete pESD;
144}
145
146void extract_ddlraw()
147{
148 cerr << "===============================================================" << endl;
149 cerr << "usage: aliroot -b -q 'extract-ddlraw.C(\"raw.root\", 768, 769)'" << endl << endl;
150 cerr << "please provide input, min and max equipment id" << endl;
151 cerr << "===============================================================" << endl;
152}