4 // Created by Laurent Aphecetche
7 #if !defined(__CINT__) || defined(__MAKECINT__)
15 #include "TObjString.h"
19 Int_t CpMacroWithFilter(TString from, const TString& to,
21 const TString& filterMacroFullPath,
22 const TString& filterRootLogonFullPath,
23 const TString& alirootPath)
26 /// Copy one file from url "from" into url "to", while filtering it at the same time.
29 std::cout << "CpMacroWithFilter from : " << from.Data() << std::endl << " to : " << to.Data() << std::endl
30 << " with filter " << filterName.Data() << std::endl;
32 if (from.IsNull() || to.IsNull()) return -1;
34 if ( gSystem->AccessPathName(filterMacroFullPath.Data()) )
36 std::cerr << "Could not find requested filter macro (looking into " << filterMacroFullPath.Data() << ")" << std::endl;
40 // check that the companion macro (to load the relevant libraries
41 // and set the additional include paths, if needed) exists
43 if ( gSystem->AccessPathName(filterRootLogonFullPath.Data()) )
45 std::cerr << "Could not find requested filter companion macro (looking into " << filterRootLogonFullPath.Data() << ")" << std::endl;
49 if (from.Contains("alien://"))
51 TGrid::Connect("alien://");
55 std::cerr << "Cannot get gGrid !" << std::endl;
60 if ( !filterName.IsNull() )
62 // most probably the filter will require AliRoot libs, so add the dynamic path here
63 // as well as the include path and the macro path.
65 gSystem->AddDynamicPath(Form("%s/lib/tgt_%s",alirootPath.Data(),gSystem->GetBuildArch()));
66 gSystem->SetIncludePath(Form("-I%s/include -I%s/PWG/muon",alirootPath.Data(),alirootPath.Data()));
67 gROOT->SetMacroPath(Form("%s:%s/PWG/muon",gROOT->GetMacroPath(),alirootPath.Data()));
69 // execute the companion macro
70 std::cout << Form("Will load companion macro %s(\"%s\",\"%s\")",filterRootLogonFullPath.Data(),from.Data(),to.Data()) << std::endl;
72 gROOT->Macro(filterRootLogonFullPath.Data());
74 std::cout << gSystem->GetIncludePath() << std::endl;
76 // finally delegate the work to the required filter
78 std::cout << Form("Will compile filter %s+(\"%s\",\"%s\")",filterMacroFullPath.Data(),from.Data(),to.Data()) << std::endl;
80 TString compile(filterMacroFullPath.Data());
84 Int_t fail = gROOT->LoadMacro(compile.Data());
88 std::cout << Form("Failed to load/compile macro %s+",filterMacroFullPath.Data()) << std::endl;
92 std::cout << Form("Will execute filter %s(\"%s\",\"%s\")",filterName.Data(),from.Data(),to.Data()) << std::endl;
94 return (Int_t)gROOT->ProcessLine(Form("%s(\"%s\",\"%s\")",filterName.Data(),from.Data(),to.Data()));