Error insted of Fatal
[u/mrichter/AliRoot.git] / MONITOR / deroot.cxx
CommitLineData
36470d8d 1// Author: Filimon Roukoutakis 02/08/2006
2
3/******************************************************************************
4 MOOD - Monitor Of On-line Data and Detector Debugger for ALICE Experiment
5******************************************************************************/
6
7#include <TError.h>
8#include <TSysEvtHandler.h>
9#ifdef ALI_DATE
10#include "deroot.h"
11
12int deroot(const char *rootFileName, const char *dateFileName);
13
14int deroot(const char *rootFileName, const char *dateFileName) {
15
16 unsigned char *dateEvent=new unsigned char [100000000];
17
18 FILE *dateFile;
19 size_t gdcCounter, gdcSize;
20 TFile rootFile(rootFileName);
21 TTree *t=(TTree *)rootFile.Get("RAW");
22 if(!t) {
23 cerr << "Error getting RAW tree" << endl;
24 return(1);
25 }
26 AliRawEvent *rootEvent=NULL;
27
28 t->SetBranchAddress("rawevent", &rootEvent);
29
30 if(!(dateFile=fopen(dateFileName, "wb"))) {
31 cerr << "Error opening DATE file" << endl;
32 return(1);
33 }
34
35 for(gdcCounter=0; gdcCounter<t->GetEntries(); gdcCounter++) {
36 rootEvent=new AliRawEvent;
37 t->GetEntry(gdcCounter);
38 gdcSize=Root2Date(rootEvent, dateEvent);
39 delete rootEvent;
40 cerr << "\r \r" << setprecision(3) << 100*(float)(gdcCounter+1)/t->GetEntries() << "% ";
41 fwrite(dateEvent, gdcSize, 1, dateFile);
42 }
43
44 // Cleanup resources
45
46 cerr << "\r \r";
47 cerr.flush();
48 delete t;
49 rootFile.Close();
50 fclose(dateFile);
51 delete [] dateEvent;
52
53 return(0);
54
55}
56
57int main(int argc, char **argv) {
58
59 if (argc != 3) {
60 cerr << "Usage: deroot <input_root_file> <output_date_file>" << endl;
61 return 1;
62 }
63
64 deroot(argv[1], argv[2]);
65
66 return(0);
67
68}
69
70#else
71int main(int /*argc*/, char** /*argv*/)
72{
bf4e7d5b 73 ::Error("main", "this program was compiled without DATE");
36470d8d 74
75 return 1;
76}
77#endif