예제 #1
0
파일: alien.C 프로젝트: MycrofD/root
void alien()
{
   TString testdir = "root-test3";
   int nfiles      = 10;

   // connect to AliEn
   TGrid *alien = TGrid::Connect("alien", gSystem->Getenv("USER"), "",
                                 "-domain=cern.ch");
   if (alien->IsZombie()) {
      delete alien;
      return;
   }

   // get info on AliEn version
   printf("Using AliEn version %s\n", alien->GetInfo());

   // print current working directory
   printf("Current directory is %s\n", alien->Pwd());

   // check if directory exists
   Long_t size, flags, modtime;
   if (alien->GetPathInfo(testdir, &size, &flags, &modtime) == 0) {
      // delete existing directory
      alien->Rmdir(testdir);
   }

   // create a directory
   alien->Mkdir(testdir);

   // change directory
   alien->Cd(testdir);

   printf("Current directory is %s\n", alien->Pwd());

   // insert nfiles into the catalog
   Int_t i;
   char lfn[32], pfn[256];
   for (i = 0; i < nfiles; i++) {
      sprintf(lfn, "test-%d.root", i);
      sprintf(pfn, "rfio:/castor/cern.ch/user/r/rdm/mytest-%d.root", i);
      alien->AddFile(lfn, pfn, 1000000000);
   }

   // list the contents of a directory
   alien->ls("", "l");

   // get physical file name from lfn
   for (i = 0; i < nfiles; i++) {
      sprintf(lfn, "test-%d.root", i);
      char *pf = alien->GetPhysicalFileName(lfn);
      if (i == nfiles-1)
         printf("last pfn retrieved is: %s\n", pf);
      delete [] pf;
   }

   delete alien;
}
예제 #2
0
void MergeFlowd() 
{
	TGrid *alien = TGrid::Connect("alien");
	if (alien->IsZombie())
	{
		delete alien;
		cout << "Fatal: Alien is a zombie!" << endl;
		return;
	}

  Int_t runlist[] = {                                                               // Counter
    /*170309, 170308, 170306, 170270, 170269, 170268, 170230, 170228,*/ 170204, 170203, // 10
    170193, 170163, 170159, 170155, 170081, 170027, 169859, 169858, 169855, 169846, // 20
    169838, 169837, 169835, 169417, 169415, 169411, 169238, 169167, 169160, 169156, // 30
    169148, 169145, 169144, 169138, 169094, 169091, 169035, 168992, 168988, 168826, // 40
    168777, 168514, 168512, 168511, 168467, 168464, 168460, 168458, 168362, 168361, // 50
    168342, 168341, 168325, 168322, 168311, 168310, 167988, 167987                  // 58
  };	

  TFileMerger merger;
  TString dataBaseDir = "/alice/cern.ch/user/m/mpuccio/Flowd_PbPb2011/output/000";
  merger.OutputFile("FileMerger.root");
  for (int iRun = 0; iRun < 1; ++iRun)
  {
  	TString runDir = Form("%s%i",dataBaseDir.Data(),runlist[iRun]);
  	TGridResult *res = alien->Command(Form("find %s */mpuccio_Flowd.root",runDir.Data()));
  	TIter iter(res);
  	TMap *map;
  	while ((map = (TMap*)iter())) 
  	{
  		TObjString *obj = dynamic_cast<TObjString*>(map->GetValue("turl"));
  		if (!obj || !obj->String().Length())
  		{
  			delete res;
  			break;
  		}

  		TFile *f = TFile::Open(obj->String().Data());
  		if (!f->IsOpen())
  		{
  			cout << "File " << obj->String().Data() << " has some problems..." << endl;
  			continue;
  		}
  		merger.AddFile(f);
  		merger.PartialMerge();
  		f->Close();
  	}
  }
  merger.Merge();
  merger.Write();
}