FindFASTJET
[u/mrichter/AliRoot.git] / HLT / exa / extract-ESD.C
CommitLineData
03c875c8 1// $Id$
2/**
3 * @file extract-ESD.C
4 * @brief Tool to extract the HLT ESD from the raw data.
5 *
6 * Usage:
7 * <pre>
8 * aliroot -b -q 'extract-ESD.C("raw.root", cdb, nOfEvents)' | tee extract-ESD.log
9 * aliroot -b -q 'extract-ESD.C("alien:///alice/data/2010/.../.root", "raw://", nOfEvents)' | tee extract-ESD.log
10 * </pre>
11 *
bbf81006 12 * This macro only needs the HLT/Calib/StreamerInfo object to extract the HLT ESD from raw data.
13 * However, it is extremely slow, it even gets slower during running. It should be used as an
14 * emergency solution. HLT/exa/recraw-local.C is the proper and fast way to extract HLT data.
15 *
03c875c8 16 * @author Kalliopi.Kanaki@ift.uib.no
17 * @ingroup alihlt_tutorial
18 */
19void extract_ESD(const char* input, const char *cdbURI, int nofEvents=-1){
20
21 // setup of the RawReader
22 if(!input){
23 cerr << "invalid path" << endl;
24 cerr << "usage: aliroot -b -q extract-ESD.C'(\"raw.root\", \"cdb\", nOfEvents)'" << endl;
25 return;
26 }
27
28 TString strfile = input;
29 TString struri = cdbURI;
30
31 if(strfile.Contains("://") && !strfile.Contains("local://")) TGrid::Connect("alien");
32
33 // Set the CDB storage location
34 AliCDBManager *man = AliCDBManager::Instance();
35 man->SetDefaultStorage(cdbURI);
bbf81006 36
37 AliRawReader *pRawReader = AliRawReader::Create(input);
38 if(!pRawReader){
39 cout << "cannot open RawReader for file " << input << endl;
40 return;
03c875c8 41 }
832c83e8 42
03c875c8 43 if (!pRawReader->NextEvent()){
44 cerr << "no events available" << endl;
45 return;
46 }
832c83e8 47
bbf81006 48 if(!struri.BeginsWith("raw://")) man->SetRun(pRawReader->GetRunNumber());
03c875c8 49
50 // setup of the HLT system
51 AliHLTSystem *pHLT = AliHLTPluginBase::GetInstance();
832c83e8 52 if(!pHLT) cerr << "fatal error: cannot get HLT instance" << endl;
03c875c8 53
54 TString arg;
55 arg.Form("-typeid ALIESDV0");
56 AliHLTConfiguration publisher("hltout-publisher", "AliHLTOUTPublisher" , NULL, arg.Data());
57
f948d3b1 58 arg.Form("-treename HLTesdTree");
03c875c8 59 AliHLTConfiguration collector("sink1","EsdCollector","hltout-publisher", arg.Data());
60
61 // the reconstructor setup
62 AliHLTReconstructor hltRec;
63 hltRec.SetOption("libAliHLTUtil.so loglevel=0x7c chains=sink1 ignore-hltout ignore-ctp");
64 if (hltRec.Init()<0) {
65 cerr << "initialization of reconstructor failed" << endl;
66 return;
67 }
68
69 // the reconstruction loop
70 Int_t event=0;
71 UChar_t* pData=NULL;
72 pRawReader->RewindEvents();
73 while(pRawReader->NextEvent() && (nofEvents<0 || event<nofEvents)){
74 cout << "=======================================================" << endl;
75 cout << "event " << event << endl;
76 cout << "-------------------------------------------------------" << endl;
77 pRawReader->Reset();
78 hltRec.Reconstruct(pRawReader, NULL);
79 event++;
80 }
81}
82
f948d3b1 83void extract_ESD(const char* input, int nofEvents=-1){
84 extract_ESD(input, "raw://", nofEvents);
85}
86
03c875c8 87void extract_ESD(){
88 cerr << "===============================================================" << endl;
89 cerr << "usage: aliroot -b -q extract-ESD.C'(\"raw.root\", \"cdb\", nOfEvents)'"<< endl;
90 cerr <<" aliroot -b -q extract-ESD.C'(\"alien:///alice/data/2010/LHC10../../.root\", \"raw://\", nOfEvents)'"<< endl;
91 cerr << "===============================================================" << endl;
92}