1 // Author: Filimon Roukoutakis 02/08/2006
3 /******************************************************************************
4 MOOD - Monitor Of On-line Data and Detector Debugger for ALICE Experiment
5 ******************************************************************************/
9 #include <TSysEvtHandler.h>
13 int deroot(const char *rootFileName, const char *dateFileName, const char *ddlFilesFolder);
15 int deroot(const char *rootFileName, const char *dateFileName, const char *ddlFilesFolder) {
17 TString str = rootFileName;
18 if (str.BeginsWith("alien://"))
19 TGrid::Connect("alien://");
21 TFile *rootFile = TFile::Open(rootFileName,"READ");
23 cerr << "Raw data file can not be opened" << endl;
27 TTree *t=(TTree *)rootFile->Get("RAW");
29 cerr << "Error getting RAW tree" << endl;
32 AliRawVEvent *rootEvent=NULL;
34 t->SetBranchAddress("rawevent", &rootEvent);
37 if(!(dateFile=fopen(dateFileName, "wb"))) {
38 cerr << "Error opening DATE file" << endl;
42 UInt_t eventSize = 10000000; // 10MB by default
43 unsigned char *dateEvent = new unsigned char[eventSize];
44 for(Long_t gdcCounter=0; gdcCounter<t->GetEntries(); gdcCounter++) {
46 t->GetEntry(gdcCounter);
47 if (rootEvent->GetHeader()->GetEventSize() > eventSize) {
49 eventSize = (UInt_t)(1.05*rootEvent->GetHeader()->GetEventSize());
50 dateEvent = new unsigned char[eventSize];
56 sprintf(command, "rm -rf %s/raw%ld", ddlFilesFolder, gdcCounter);
57 gSystem->Exec(command);
58 sprintf(command, "%s/raw%ld", ddlFilesFolder, gdcCounter);
59 if (gSystem->MakeDirectory(command) < 0) {
60 cerr << "Can not create directory " << command << endl;
63 gdcSize=Root2Date(rootEvent, dateEvent, command);
66 gdcSize=Root2Date(rootEvent, dateEvent, NULL);
69 cerr << "\r \r" << setprecision(3) << 100*(float)(gdcCounter+1)/t->GetEntries() << "% ";
70 fwrite(dateEvent, gdcSize, 1, dateFile);
86 int main(int argc, char **argv) {
88 if (argc != 3 && argc != 4) {
89 cerr << "Usage: deroot <input_root_file> <output_date_file> [<optional_folder_for_ddl_files>]" << endl;
94 deroot(argv[1], argv[2], NULL);
96 deroot(argv[1], argv[2], argv[3]);