]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - PWGPP/macros/rawmerge.C
end-of-line normalization
[u/mrichter/AliRoot.git] / PWGPP / macros / rawmerge.C
index ccf718ab2cec158bb0e4ce4c62498d352c591b8a..ba58fc443da4482a0f5f213df00dd5d9105292f3 100644 (file)
@@ -1,93 +1,93 @@
-//\r
-// Macro to create the "raw" data file with selected events\r
-// Paramaters:\r
-//  eventListFileName - input ascii file with list of chunks and event numbers - two collumns\r
-//  osplit            - split the file after given threhshold value\r
-//\r
-//  TGrid * alien = TGrid::Connect("alien://",0,0,"t");\r
-\r
-void rawmerge(const char *eventListFileName,\r
-              const char *outputDirectoryURI,\r
-              Long64_t osplit=-1)\r
-{\r
-  TGrid * alien = TGrid::Connect("alien://",0,0,"t");\r
-  \r
-  Int_t eventNumber;\r
-  FILE *files=fopen(eventListFileName,"r");\r
-  if (!files) {\r
-    fprintf(stderr,"error: could not read event list file \"%s\". Exiting.\n",eventListFileName);\r
-    return;\r
-  }\r
-  char iURI[1000];\r
-  TString  iURIold;\r
-  char oURI[1000];\r
-  TFile *ifile=0;\r
-  TFile *ofile=0;\r
-  TTree *itree=0;\r
-  TTree *otree=0;\r
-  Long64_t ievent;\r
-  Long64_t oevent;\r
-  Int_t ofilenumber=0;\r
-  Int_t line=0;\r
-  Int_t eventold=0;\r
-  while (!feof(files)) {\r
-    ++line;\r
-    if (fscanf(files,"%s %d\n",iURI,&ievent)!=2) {\r
-      fprintf(stderr,"warning: corrupted event line (%d) in input file, skipping it...\n",line);\r
-      continue;\r
-    } \r
-    printf("> processing \"%s\" event %d...\n",iURI,ievent);\r
-    if (ievent==eventold) { printf("duplicated continue\n"),continue;}\r
-    //\r
-    if (iURIold.Contains(iURI)==0){ \r
-      printf("NF: %s\n",iURI);\r
-      delete ifile;ifile=0;\r
-      ifile=TFile::Open(iURI);\r
-      if (!ifile) {\r
-       fprintf(stderr,"warning: could not open file for event \"%s\", skipping it...\n",iURI);\r
-       continue;\r
-      }\r
-      iURIold=iURI;\r
-    }else{\r
-      printf("OF: %s\n",iURI);\r
-      iURIold=iURI; \r
-    }\r
-    //\r
-    TTree *itree=dynamic_cast<TTree*>(ifile->Get("RAW"));\r
-    if (!itree) {\r
-      fprintf(stderr,"warning: could not find RAW tree for event \"%s\", skipping it...\n",iURI);\r
-      continue;\r
-    }\r
-\r
-    // create (new) output file and tree\r
-    if (!ofile || (osplit>0 && oevent%osplit==0)) {\r
-      delete ofile;\r
-      ++ofilenumber;\r
-      sprintf(oURI,"%s/merged_%d.root",outputDirectoryURI,ofilenumber);\r
-      printf("< creating output file \"%s\"\n",oURI);\r
-      ofile=TFile::Open(oURI,"RECREATE");\r
-      if (!ofile) {\r
-        fprintf(stderr,"error: could not create output file: \"%s\" Exiting.\n",oURI);\r
-        break;\r
-      }\r
-      otree=itree->CloneTree(0);\r
-    }\r
-    // copy event and write to file\r
-    otree->CopyAddresses(itree);\r
-    if (ievent==eventold) continue;\r
-    itree->GetEntry(ievent);\r
-    eventold=ievent;    \r
-    otree->Fill();\r
-//    otree->CopyEntries(itree,Form("Entry$==%d",ievent),1);\r
-    ofile->Write();\r
-    ++oevent;\r
-\r
-    // reset input\r
-    itree->ResetBranchAddresses();\r
-  }\r
-\r
-  printf("Merged %d events.\n",oevent);\r
-  delete ifile;\r
-  delete ofile;\r
-}\r
-\r
+//
+// Macro to create the "raw" data file with selected events
+// Paramaters:
+//  eventListFileName - input ascii file with list of chunks and event numbers - two collumns
+//  osplit            - split the file after given threhshold value
+//
+//  TGrid * alien = TGrid::Connect("alien://",0,0,"t");
+
+void rawmerge(const char *eventListFileName,
+              const char *outputDirectoryURI,
+              Long64_t osplit=-1)
+{
+  TGrid * alien = TGrid::Connect("alien://",0,0,"t");
+  
+  Int_t eventNumber;
+  FILE *files=fopen(eventListFileName,"r");
+  if (!files) {
+    fprintf(stderr,"error: could not read event list file \"%s\". Exiting.\n",eventListFileName);
+    return;
+  }
+  char iURI[1000];
+  TString  iURIold;
+  char oURI[1000];
+  TFile *ifile=0;
+  TFile *ofile=0;
+  TTree *itree=0;
+  TTree *otree=0;
+  Long64_t ievent;
+  Long64_t oevent;
+  Int_t ofilenumber=0;
+  Int_t line=0;
+  Int_t eventold=0;
+  while (!feof(files)) {
+    ++line;
+    if (fscanf(files,"%s %d\n",iURI,&ievent)!=2) {
+      fprintf(stderr,"warning: corrupted event line (%d) in input file, skipping it...\n",line);
+      continue;
+    } 
+    printf("> processing \"%s\" event %d...\n",iURI,ievent);
+    if (ievent==eventold) { printf("duplicated continue\n"),continue;}
+    //
+    if (iURIold.Contains(iURI)==0){ 
+      printf("NF: %s\n",iURI);
+      delete ifile;ifile=0;
+      ifile=TFile::Open(iURI);
+      if (!ifile) {
+       fprintf(stderr,"warning: could not open file for event \"%s\", skipping it...\n",iURI);
+       continue;
+      }
+      iURIold=iURI;
+    }else{
+      printf("OF: %s\n",iURI);
+      iURIold=iURI; 
+    }
+    //
+    TTree *itree=dynamic_cast<TTree*>(ifile->Get("RAW"));
+    if (!itree) {
+      fprintf(stderr,"warning: could not find RAW tree for event \"%s\", skipping it...\n",iURI);
+      continue;
+    }
+
+    // create (new) output file and tree
+    if (!ofile || (osplit>0 && oevent%osplit==0)) {
+      delete ofile;
+      ++ofilenumber;
+      sprintf(oURI,"%s/merged_%d.root",outputDirectoryURI,ofilenumber);
+      printf("< creating output file \"%s\"\n",oURI);
+      ofile=TFile::Open(oURI,"RECREATE");
+      if (!ofile) {
+        fprintf(stderr,"error: could not create output file: \"%s\" Exiting.\n",oURI);
+        break;
+      }
+      otree=itree->CloneTree(0);
+    }
+    // copy event and write to file
+    otree->CopyAddresses(itree);
+    if (ievent==eventold) continue;
+    itree->GetEntry(ievent);
+    eventold=ievent;    
+    otree->Fill();
+//    otree->CopyEntries(itree,Form("Entry$==%d",ievent),1);
+    ofile->Write();
+    ++oevent;
+
+    // reset input
+    itree->ResetBranchAddresses();
+  }
+
+  printf("Merged %d events.\n",oevent);
+  delete ifile;
+  delete ofile;
+}
+