2 // Macro to create the "raw" data file with selected events
\r
4 // eventListFileName - input ascii file with list of chunks and event numbers - two collumns
\r
5 // osplit - split the file after given threhshold value
\r
7 void rawmerge(const char *eventListFileName,
\r
8 const char *outputDirectoryURI,
\r
12 FILE *files=fopen(eventListFileName,"r");
\r
14 fprintf(stderr,"error: could not read event list file \"%s\". Exiting.\n",eventListFileName);
\r
25 Int_t ofilenumber=0;
\r
27 while (!feof(files)) {
\r
28 delete ifile;ifile=0;
\r
30 if (fscanf(files,"%s %d\n",iURI,&ievent)!=2) {
\r
31 fprintf(stderr,"warning: corrupted event line (%d) in input file, skipping it...\n",line);
\r
34 printf("> processing \"%s\" event %d...\n",iURI,ievent);
\r
35 TFile *ifile=TFile::Open(iURI);
\r
37 fprintf(stderr,"warning: could not open file for event \"%s\", skipping it...\n",iURI);
\r
40 TTree *itree=dynamic_cast<TTree*>(ifile->Get("RAW"));
\r
42 fprintf(stderr,"warning: could not find RAW tree for event \"%s\", skipping it...\n",iURI);
\r
46 // create (new) output file and tree
\r
47 if (!ofile || (osplit>0 && oevent%osplit==0)) {
\r
50 sprintf(oURI,"%s/merged_%d.root",outputDirectoryURI,ofilenumber);
\r
51 printf("< creating output file \"%s\"\n",oURI);
\r
52 ofile=TFile::Open(oURI,"RECREATE");
\r
54 fprintf(stderr,"error: could not create output file: \"%s\" Exiting.\n",oURI);
\r
57 otree=itree->CloneTree(0);
\r
60 // copy event and write to file
\r
61 otree->CopyAddresses(itree);
\r
62 itree->GetEntry(ievent);
\r
64 // otree->CopyEntries(itree,Form("Entry$==%d",ievent),1);
\r
69 itree->ResetBranchAddresses();
\r
72 printf("Merged %d events.\n",oevent);
\r