3 // Helper macros can be found in this file
4 // A set of them can be used to connect to proof and execute selectors.
6 TVirtualProof* connectProof(const char* proofServer)
8 TVirtualProof* proof = TProof::Open(proofServer);
12 printf("ERROR: PROOF connection not established.\n");
16 // enable the new packetizer
17 //proof->AddInput(new TNamed("PROOF_Packetizer", "TPacketizerProgressive"));
24 Bool_t prepareQuery(TString libraries, TString packages, Bool_t useAliRoot)
26 // if not proof load libraries
29 TObjArray* librariesList = libraries.Tokenize(";");
30 for (Int_t i=0; i<librariesList->GetEntries(); ++i)
32 TObjString* str = dynamic_cast<TObjString*> (librariesList->At(i));
36 printf("Loading %s...", str->String().Data());
37 Int_t result = CheckLoadLibrary(str->String());
44 printf("succeeded\n");
52 TObjArray* packagesList = packages.Tokenize(";");
53 for (Int_t i=0; i<packagesList->GetEntries(); ++i)
55 TObjString* str = dynamic_cast<TObjString*> (packagesList->At(i));
59 if (!EnablePackageLocal(str->String()))
61 printf("Loading of package %s locally failed\n", str->String().Data());
65 if (gProof->EnablePackage(str->String()))
67 printf("Loading of package %s failed\n", str->String().Data());
76 Int_t executeQuery(TChain* chain, TList* inputList, TString selectorName, const char* option = "")
79 chain->GetUserInfo()->AddAll(inputList);
82 for (Int_t i=0; i<inputList->GetEntries(); ++i)
83 gProof->AddInput(inputList->At(i));
92 result = chain->MakeTDSet()->Process(selectorName, option);
94 result = chain->Process(selectorName, option);
97 printf("ERROR: Executing process failed with %d.\n", result);
105 void ProofEnableAliRoot()
107 // enables a locally deployed AliRoot in a PROOF cluster
109 /* executes the following commands on each node:
110 gSystem->Setenv("ALICE_ROOT", "/home/alicecaf/ALICE/aliroot-head")
111 gSystem->AddIncludePath("/home/alicecaf/ALICE/aliroot-head/include");
112 gSystem->SetDynamicPath(Form("%s:%s", gSystem->GetDynamicPath(), "/home/alicecaf/ALICE/aliroot-head/lib/tgt_linux"))
113 gSystem->Load("libMinuit");
114 gROOT->Macro("$ALICE_ROOT/macros/loadlibs.C");
117 const char* location = "/home/alicecaf/ALICE/aliroot-head";
119 gProof->Exec(Form("gSystem->Setenv(\"ALICE_ROOT\", \"%s\")", location), kTRUE);
120 gProof->AddIncludePath(Form("%s/include", location));
121 gProof->AddDynamicPath(Form("%s/lib/tgt_linux", location));
123 // load all libraries
124 gProof->Exec("gSystem->Load(\"libMinuit\")");
125 gProof->Exec("gROOT->Macro(\"$ALICE_ROOT/macros/loadlibs.C\")");
128 Bool_t EnablePackageLocal(const char* package)
130 printf("Enabling package %s locally...\n", package);
132 TString currentDir(gSystem->pwd());
133 if (!gSystem->cd(package))
136 gROOT->ProcessLine(".x PROOF-INF/SETUP.C");
137 gSystem->cd(currentDir);
142 Int_t CheckLoadLibrary(const char* library)
144 // checks if a library is already loaded, if not loads the library
146 if (strlen(gSystem->GetLibraries(Form("%s.so", library), "", kFALSE)) > 0)
149 return gSystem->Load(library);
152 void redeployPackages(const char* proofServer, Bool_t localAliRoot = kTRUE)
154 // deploys PWG0base and PWG0dep (the latter only when localAliRoot is true) that are expected in $ALICE_ROOT
155 // when localAliRoot is false ESD.par is also deployed
157 TProof::Reset(proofServer);
158 TVirtualProof* proof = TProof::Open(proofServer);
159 proof->ClearPackages();
162 ProofEnableAliRoot();
165 proof->UploadPackage("$ALICE_ROOT/ESD.par");
166 proof->EnablePackage("ESD");
169 proof->UploadPackage("$ALICE_ROOT/PWG0base.par");
170 proof->EnablePackage("PWG0base");
172 proof->UploadPackage("$ALICE_ROOT/PWG0dep.par");
173 proof->EnablePackage("PWG0dep");