+ timer.Print();
+
+ cal->Terminate();
+ TGeoGlobalMagField::Instance()->SetField(NULL);
+ delete cdbManager;
+
+ // verbosity
+ printf("\n\tCLEANING UP TRAIN:\n");
+ mgr->GetTasks()->Delete();
+
+ if(mcH) delete mcH;
+ delete esdH;
+ delete mgr;
+ delete chain;
+ if(MEM) delete mem;
+ if(MEM) TMemStatViewerGUI::ShowGUI();
+}
+
+//____________________________________________
+TChain* MakeChainLST(const char* filename)
+{
+ // Create the chain
+ TChain* chain = new TChain("esdTree");
+
+ if(!filename){
+ chain->Add(Form("%s/AliESDs.root", gSystem->pwd()));
+ return chain;
+ }
+
+
+ // read ESD files from the input list.
+ ifstream in;
+ in.open(filename);
+ TString esdfile;
+ while(in.good()) {
+ in >> esdfile;
+ if (!esdfile.Contains("root")) continue; // protection
+ chain->Add(esdfile.Data());
+ }
+
+ in.close();
+
+ return chain;
+}
+
+//____________________________________________
+TChain* MakeChainXML(const char* xmlfile)
+{
+ if (!TFile::Open(xmlfile)) {
+ Error("MakeChainXML", Form("No file %s was found", xmlfile));
+ return 0x0;
+ }
+
+ if(gSystem->Load("libNetx.so")<0) return 0x0;
+ if(gSystem->Load("libRAliEn.so")<0) return 0x0;
+ TGrid::Connect("alien://") ;
+
+ TGridCollection *collection = (TGridCollection*) TAlienCollection::Open(xmlfile);
+ if (!collection) {
+ Error("MakeChainXML", Form("No collection found in %s", xmlfile)) ;
+ return 0x0;
+ }
+ //collection->CheckIfOnline();
+
+ TGridResult* result = collection->GetGridResult("",0 ,0);
+ if(!result->GetEntries()){
+ Error("MakeChainXML", Form("No entries found in %s", xmlfile)) ;
+ return 0x0;
+ }
+ // Makes the ESD chain
+ TChain* chain = new TChain("esdTree");
+ for (Int_t idx = 0; idx < result->GetEntries(); idx++) {
+ chain->Add(result->GetKey(idx, "turl"));
+ }
+ return chain;