3 * @file extract-ddlraw.C
4 * @brief Tool to extract DDL raw data.
8 * aliroot -b -q 'extract-ddlraw.C("raw.root", 768, 769)' | tee extract-ddlraw.log
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.
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.
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).
26 * @author Matthias.Richter@ift.uib.no
27 * @ingroup alihlt_tutorial
29 void extract_ddlraw(const char* input, int iMinDDLno, int iMaxDDLno)
31 /////////////////////////////////////////////////////////////////////////
32 /////////////////////////////////////////////////////////////////////////
35 const char* baseName="RAW.ddl";
37 /////////////////////////////////////////////////////////////////////////
38 /////////////////////////////////////////////////////////////////////////
40 // setup of the RawReader
42 cerr << "invalid path" << endl;
43 cerr << "usage: aliroot -b -q 'extract-ddlraw.C(\"raw.root\", 768, 769)'" << endl;
47 AliRawReader* pRawReader=AliRawReader::Create(input);
49 cout << "can not open RawReader for file " << input << endl;
52 if (!pRawReader->NextEvent()) {
53 cerr << "no events available" << endl;
57 /////////////////////////////////////////////////////////////////////////
58 /////////////////////////////////////////////////////////////////////////
60 // setup of the HLT system
61 AliHLTSystem* pHLT=AliHLTPluginBase::GetInstance();
63 cerr << "fatal error: can not get HLT instance" << endl;
66 /////////////////////////////////////////////////////////////////////////
67 /////////////////////////////////////////////////////////////////////////
69 // the configuration chain
70 // we show two possible configurations:
71 // 1. having one publisher for each ddl, the configurations are created
73 // 2. all in one publisher
74 // can be easily switched with the following
81 // create one publisher for each ddl
82 for (int ddlno=iMinDDLno; ddlno<=iMaxDDLno; ddlno++) {
83 TString arg, publisher;
85 // raw data publisher components
86 arg.Form("-minid %d -skipempty -verbose", ddlno);
87 publisher.Form("DP_%d", ddlno);
88 // see AliHLTRawReaderPublisherComponent
89 AliHLTConfiguration pubconf(publisher.Data(), "AliRawReaderPublisher", NULL , arg.Data());
91 if (!writerInput.IsNull()) writerInput+=" ";
92 writerInput+=publisher;
95 // publish all ddls by the same component, this is much more
96 // effective as it avoids repeated parsing through the data
97 arg.Form("-minid %d -maxid %d -skipempty -verbose", iMinDDLno, iMaxDDLno);
98 // see AliHLTRawReaderPublisherComponent
99 AliHLTConfiguration pubconf("publisher", "AliRawReaderPublisher", NULL , arg.Data());
100 if (!writerInput.IsNull()) writerInput+=" ";
101 writerInput+="publisher";
104 // the writer configuration is the same for both
105 arg.Form("-specfmt=_%%d -subdir=raw%%d -blcknofmt= -idfmt= -datafile %s", baseName);
106 // see AliHLTFileWriter
107 AliHLTConfiguration fwconf("sink1", "FileWriter" , writerInput.Data(), arg.Data());
110 /////////////////////////////////////////////////////////////////////////
111 /////////////////////////////////////////////////////////////////////////
113 // the reconstructor setup
114 AliHLTReconstructor hltRec;
115 hltRec.SetOption("libAliHLTUtil.so loglevel=0x7c chains=sink1");
116 if (hltRec.Init()<0) {
117 cerr << "initialization of reconstructor failed" << endl;
121 // this is just a dummy ESD to provide valid parameters to the
123 AliESDEvent* pESD = new AliESDEvent;
124 pESD->CreateStdContent();
126 /////////////////////////////////////////////////////////////////////////
127 /////////////////////////////////////////////////////////////////////////
129 // the reconstruction loop
132 pRawReader->RewindEvents();
133 while (pRawReader->NextEvent()) {
134 cout << "=======================================================" << endl;
135 cout << "event " << event << endl;
136 cout << "-------------------------------------------------------" << endl;
138 hltRec.Reconstruct(pRawReader, NULL);
145 void extract_ddlraw()
147 cerr << "===============================================================" << endl;
148 cerr << "usage: aliroot -b -q 'extract-ddlraw.C(\"raw.root\", 768, 769)'" << endl << endl;
149 cerr << "please provide input, min and max equipment id" << endl;
150 cerr << "===============================================================" << endl;