Exemplo n.º 1
0
//________________________________________________________________________________
TChain* CreateChain(const char *xmlfile, const char *type)
{
// Create a chain using url's from xml file
   TString treename = type;
   treename.ToLower();
   treename += "Tree";
   printf("***************************************\n");
   printf("    Getting chain of trees %s\n", treename.Data());
   printf("***************************************\n");
   TGridCollection *coll = gGrid->OpenCollection(xmlfile);
   if (!coll) {
      ::Error("CreateChain", "Cannot create an AliEn collection from %s", xmlfile);
      return NULL;
   }
   TChain *chain = new TChain(treename);
   coll->Reset();
   while (coll->Next()) {
      chain->Add(coll->GetTURL(""));
   }
   if (!chain->GetNtrees()) {
      ::Error("CreateChain", "No tree found from collection %s", xmlfile);
      return NULL;
   }
   return chain;
}
Exemplo n.º 2
0
void MergeCollectionFromGrid(const char * incollection = "test.xml", const char * outputfile= "dndeta_merged.root")
{
  // for running with root only
  gSystem->Load("libTree");
  gSystem->Load("libGeom");
  gSystem->Load("libVMC");
  gSystem->Load("libSTEERBase");
  gSystem->Load("libESD");
  gSystem->Load("libAOD");

  // load analysis framework
  gSystem->Load("libANALYSIS");
  gSystem->Load("libANALYSISalice");

  // load dndeta task
  gROOT->LoadMacro("AliAnalysisTaskdNdetaMC.cxx+");


  TFileMerger * fileMerger  = new TFileMerger(0); // dont merge local files

  TGrid::Connect("alien://");
  TGridCollection * coll = TAlienCollection::Open (incollection);
  Int_t  ifile=0;
  while(coll->Next()){
    fileMerger->AddFile(TString("alien://")+coll->GetLFN());
    ifile++;
    //    if(ifile>2) break;
  }
  fileMerger->OutputFile("tmp.root");
  fileMerger->Merge();

  // Reopen the merged file, normalize histos and save them back.
  // SOME DUPLICATED CODE... SOME CLEAN UP WOULD BE GOOD
  AliAnalysisTaskdNdetaMC * localTask  = new AliAnalysisTaskdNdetaMC("merger", "tmp.root");
  localTask->Finalize();
  
  TFile * fout = new TFile (outputfile, "recreate");
  localTask->GetList()->Write();
  fout->Close();
}