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, int nofEvents=-1)
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 TString strfile=input;
48 if (strfile.Contains("://") && !strfile.Contains("local://")) {
49 TGrid::Connect("alien");
52 AliRawReader* pRawReader=AliRawReader::Create(input);
54 cout << "can not open RawReader for file " << input << endl;
58 if (!pRawReader->NextEvent()) {
59 cerr << "no events available" << endl;
63 /////////////////////////////////////////////////////////////////////////
64 /////////////////////////////////////////////////////////////////////////
66 // setup of the HLT system
67 AliHLTSystem* pHLT=AliHLTPluginBase::GetInstance();
69 cerr << "fatal error: can not get HLT instance" << endl;
72 /////////////////////////////////////////////////////////////////////////
73 /////////////////////////////////////////////////////////////////////////
75 // the configuration chain
76 // we show two possible configurations:
77 // 1. having one publisher for each ddl, the configurations are created
79 // 2. all in one publisher
80 // can be easily switched with the following
87 // create one publisher for each ddl
88 for (int ddlno=iMinDDLno; ddlno<=iMaxDDLno; ddlno++) {
89 TString arg, publisher;
91 // raw data publisher components
92 arg.Form("-minid %d -skipempty -verbose", ddlno);
93 publisher.Form("DP_%d", ddlno);
94 // see AliHLTRawReaderPublisherComponent
95 AliHLTConfiguration pubconf(publisher.Data(), "AliRawReaderPublisher", NULL , arg.Data());
97 if (!writerInput.IsNull()) writerInput+=" ";
98 writerInput+=publisher;
101 // publish all ddls by the same component, this is much more
102 // effective as it avoids repeated parsing through the data
103 arg.Form("-minid %d -maxid %d -skipempty -verbose", iMinDDLno, iMaxDDLno);
104 // see AliHLTRawReaderPublisherComponent
105 AliHLTConfiguration pubconf("publisher", "AliRawReaderPublisher", NULL , arg.Data());
106 if (!writerInput.IsNull()) writerInput+=" ";
107 writerInput+="publisher";
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());
116 /////////////////////////////////////////////////////////////////////////
117 /////////////////////////////////////////////////////////////////////////
119 // the reconstructor setup
120 AliHLTReconstructor hltRec;
121 hltRec.SetOption("libAliHLTUtil.so loglevel=0x7c chains=sink1 ignore-hltout ignore-ctp");
122 if (hltRec.Init()<0) {
123 cerr << "initialization of reconstructor failed" << endl;
127 // this is just a dummy ESD to provide valid parameters to the
129 AliESDEvent* pESD = new AliESDEvent;
130 pESD->CreateStdContent();
132 /////////////////////////////////////////////////////////////////////////
133 /////////////////////////////////////////////////////////////////////////
135 // the reconstruction loop
138 pRawReader->RewindEvents();
139 while (pRawReader->NextEvent() &&
140 (nofEvents<0 || event<nofEvents)) {
141 cout << "=======================================================" << endl;
142 cout << "event " << event << endl;
143 cout << "-------------------------------------------------------" << endl;
145 hltRec.Reconstruct(pRawReader, NULL);
152 void extract_ddlraw()
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;