- }
- TIter nextmap(res);
- TMap *map = 0;
- while ((map=(TMap*)nextmap())) {
- TString turl = map->GetValue("turl")->GetName();
- if (!turl.Length()) {
- // Nothing found
- delete res;
- return kFALSE;
- }
- turl.ReplaceAll("alien://", "");
- turl.ReplaceAll(saliendir, "");
- sfilename = gSystem->BaseName(turl);
- turl = turl.Strip(TString::kLeading, '/');
- // Now check to what the file corresponds to:
- // original output - aliendir/%03d/filename
- // merged file (which stage) - aliendir/filename-Stage%02d_%04d
- // final merged file - aliendir/filename
- if (sfilename == turl) {
- if (sfilename == filename) {
- doneFinal = kTRUE;
- } else {
- // check stage
- Int_t index = sfilename.Index("Stage");
- if (index<0) continue;
- stmp = sfilename(index+5,2);
- Int_t istage = atoi(stmp);
- stmp = sfilename(index+8,4);
- Int_t ijob = atoi(stmp);
- if (istage<stage) continue; // Ignore lower stages
- if (istage>stage) {
- countStage = 0;
- chunksDone.ResetAllBits();
- stage = istage;
- }
- countStage++;
- chunksDone.SetBitNumber(ijob);
- }
- } else {
- countOrig++;
- }
- if (doneFinal) {
- delete res;
- printf("=> Removing files from previous stages...\n");
- gGrid->Rm(Form("%s/*Stage*.root", aliendir));
- for (i=1; i<stage; i++)
- gGrid->Rm(Form("%s/*Stage%d*.zip", aliendir, i));
- return kTRUE;
- }