]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MONITOR/deroot.cxx
add un-use functionality to clusters
[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>
8e8e0e3e 8#include <TSystem.h>
36470d8d 9#include <TSysEvtHandler.h>
a0d9ff9d 10#include <TGrid.h>
36470d8d 11#include "deroot.h"
12
8e8e0e3e 13int deroot(const char *rootFileName, const char *dateFileName, const char *ddlFilesFolder);
36470d8d 14
8e8e0e3e 15int deroot(const char *rootFileName, const char *dateFileName, const char *ddlFilesFolder) {
36470d8d 16
a0d9ff9d 17 TString str = rootFileName;
18 if (str.BeginsWith("alien://"))
19 TGrid::Connect("alien://");
20
21 TFile *rootFile = TFile::Open(rootFileName,"READ");
22 if (!rootFile) {
23 cerr << "Raw data file can not be opened" << endl;
24 return(1);
25 }
26
27 TTree *t=(TTree *)rootFile->Get("RAW");
36470d8d 28 if(!t) {
29 cerr << "Error getting RAW tree" << endl;
30 return(1);
31 }
32 AliRawEvent *rootEvent=NULL;
33
34 t->SetBranchAddress("rawevent", &rootEvent);
35
8e8e0e3e 36 FILE *dateFile;
36470d8d 37 if(!(dateFile=fopen(dateFileName, "wb"))) {
38 cerr << "Error opening DATE file" << endl;
39 return(1);
40 }
41
8e8e0e3e 42 UInt_t eventSize = 10000000; // 10MB by default
43 unsigned char *dateEvent = new unsigned char[eventSize];
f8e4a10a 44 for(Long_t gdcCounter=0; gdcCounter<t->GetEntries(); gdcCounter++) {
36470d8d 45 rootEvent=new AliRawEvent;
46 t->GetEntry(gdcCounter);
8e8e0e3e 47 if (rootEvent->GetHeader()->GetEventSize() > eventSize) {
48 delete [] dateEvent;
49 eventSize = (UInt_t)(1.05*rootEvent->GetHeader()->GetEventSize());
50 dateEvent = new unsigned char[eventSize];
51 }
52
53 size_t gdcSize;
54 if (ddlFilesFolder) {
55 char command[256];
db001056 56 sprintf(command, "rm -rf %s/raw%ld", ddlFilesFolder, gdcCounter);
8e8e0e3e 57 gSystem->Exec(command);
e41f1e44 58 sprintf(command, "%s/raw%ld", ddlFilesFolder, gdcCounter);
8e8e0e3e 59 if (gSystem->MakeDirectory(command) < 0) {
60 cerr << "Can not create directory " << command << endl;
61 return(1);
62 }
63 gdcSize=Root2Date(rootEvent, dateEvent, command);
64 }
65 else
66 gdcSize=Root2Date(rootEvent, dateEvent, NULL);
67
36470d8d 68 delete rootEvent;
69 cerr << "\r \r" << setprecision(3) << 100*(float)(gdcCounter+1)/t->GetEntries() << "% ";
70 fwrite(dateEvent, gdcSize, 1, dateFile);
71 }
72
73 // Cleanup resources
74
75 cerr << "\r \r";
76 cerr.flush();
77 delete t;
a0d9ff9d 78 rootFile->Close();
36470d8d 79 fclose(dateFile);
80 delete [] dateEvent;
81
82 return(0);
83
84}
85
86int main(int argc, char **argv) {
87
8e8e0e3e 88 if (argc != 3 && argc != 4) {
89 cerr << "Usage: deroot <input_root_file> <output_date_file> [<optional_folder_for_ddl_files>]" << endl;
36470d8d 90 return 1;
91 }
92
8e8e0e3e 93 if (argc ==3)
94 deroot(argv[1], argv[2], NULL);
95 else
96 deroot(argv[1], argv[2], argv[3]);
36470d8d 97
98 return(0);
99
100}
101