1 // Author: Filimon Roukoutakis 02/08/2006
3 /******************************************************************************
4 MOOD - Monitor Of On-line Data and Detector Debugger for ALICE Experiment
5 ******************************************************************************/
10 #include <TSysEvtHandler.h>
14 int deroot(const char *rootFileName, const char *dateFileName, const char *ddlFilesFolder);
16 int deroot(const char *rootFileName, const char *dateFileName, const char *ddlFilesFolder) {
18 TString str = rootFileName;
19 if (str.BeginsWith("alien://"))
20 TGrid::Connect("alien://");
22 TFile *rootFile = TFile::Open(rootFileName,"READ");
24 cerr << "Raw data file can not be opened" << endl;
28 TTree *t=(TTree *)rootFile->Get("RAW");
30 cerr << "Error getting RAW tree" << endl;
33 AliRawVEvent *rootEvent=NULL;
35 t->SetBranchAddress("rawevent", &rootEvent);
38 #if defined(R__SEEK64)
39 if(!(dateFile=fopen64(dateFileName, "wb"))) {
41 if(!(dateFile=fopen(dateFileName, "wb"))) {
43 cerr << "Error opening DATE file" << endl;
47 UInt_t eventSize = 10000000; // 10MB by default
48 unsigned char *dateEvent = new unsigned char[eventSize];
49 for(Long_t gdcCounter=0; gdcCounter<t->GetEntries(); gdcCounter++) {
51 t->GetEntry(gdcCounter);
52 if (rootEvent->GetHeader()->GetEventSize() > eventSize) {
54 eventSize = (UInt_t)(1.05*rootEvent->GetHeader()->GetEventSize());
55 dateEvent = new unsigned char[eventSize];
61 sprintf(command, "rm -rf %s/raw%ld", ddlFilesFolder, gdcCounter);
62 gSystem->Exec(command);
63 sprintf(command, "%s/raw%ld", ddlFilesFolder, gdcCounter);
64 if (gSystem->MakeDirectory(command) < 0) {
65 cerr << "Can not create directory " << command << endl;
68 gdcSize=Root2Date(rootEvent, dateEvent, command);
71 gdcSize=Root2Date(rootEvent, dateEvent, NULL);
74 cerr << "\r \r" << setprecision(3) << 100*(float)(gdcCounter+1)/t->GetEntries() << "% ";
75 fwrite(dateEvent, gdcSize, 1, dateFile);
91 int main(int argc, char **argv) {
93 if (argc != 3 && argc != 4) {
94 cerr << "Usage: deroot <input_root_file> <output_date_file> [<optional_folder_for_ddl_files>]" << endl;
99 deroot(argv[1], argv[2], NULL);
101 deroot(argv[1], argv[2], argv[3]);