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 proof->SetParallel(20);
18 // enable the new packetizer
19 //proof->AddInput(new TNamed("PROOF_Packetizer", "TPacketizerProgressive"));
26 Bool_t prepareQuery(TString libraries, TString packages, Bool_t useAliRoot)
28 // if not proof load libraries
31 TObjArray* librariesList = libraries.Tokenize(";");
32 for (Int_t i=0; i<librariesList->GetEntries(); ++i)
34 TObjString* str = dynamic_cast<TObjString*> (librariesList->At(i));
38 printf("Loading %s...", str->String().Data());
39 Int_t result = CheckLoadLibrary(str->String());
46 printf("succeeded\n");
54 TObjArray* packagesList = packages.Tokenize(";");
55 for (Int_t i=0; i<packagesList->GetEntries(); ++i)
57 TObjString* str = dynamic_cast<TObjString*> (packagesList->At(i));
61 if (!EnablePackageLocal(str->String()))
63 printf("Loading of package %s locally failed\n", str->String().Data());
67 if (gProof->EnablePackage(str->String()))
69 printf("Loading of package %s failed\n", str->String().Data());
78 Int_t executeQuery(TChain* chain, TList* inputList, TString selectorName, const char* option = "")
81 chain->GetUserInfo()->AddAll(inputList);
84 for (Int_t i=0; i<inputList->GetEntries(); ++i)
85 gProof->AddInput(inputList->At(i));
94 result = chain->MakeTDSet()->Process(selectorName, option);
96 result = chain->Process(selectorName, option);
99 printf("ERROR: Executing process failed with %d.\n", result);
107 void ProofEnableAliRoot()
109 // enables a locally deployed AliRoot in a PROOF cluster
111 /* executes the following commands on each node:
112 gSystem->Setenv("ALICE_ROOT", "/home/alicecaf/ALICE/aliroot-head")
113 gSystem->AddIncludePath("/home/alicecaf/ALICE/aliroot-head/include");
114 gSystem->SetDynamicPath(Form("%s:%s", gSystem->GetDynamicPath(), "/home/alicecaf/ALICE/aliroot-head/lib/tgt_linux"))
115 gSystem->Load("libMinuit");
116 gROOT->Macro("$ALICE_ROOT/macros/loadlibs.C");
119 const char* location = "/home/alicecaf/ALICE/aliroot-head";
121 gProof->Exec(Form("gSystem->Setenv(\"ALICE_ROOT\", \"%s\")", location), kTRUE);
122 gProof->AddIncludePath(Form("%s/include", location));
123 gProof->AddDynamicPath(Form("%s/lib/tgt_linux", location));
125 // load all libraries
126 gProof->Exec("gSystem->Load(\"libMinuit\")");
127 gProof->Exec("gROOT->Macro(\"$ALICE_ROOT/macros/loadlibs.C\")");
130 Bool_t EnablePackageLocal(const char* package)
132 printf("Enabling package %s locally...\n", package);
134 if (!gSystem->cd(package))
137 gROOT->ProcessLine(".x PROOF-INF/SETUP.C");
143 Int_t CheckLoadLibrary(const char* library)
145 // checks if a library is already loaded, if not loads the library
147 if (strlen(gSystem->GetLibraries(Form("%s.so", library), "", kFALSE)) > 0)
150 return gSystem->Load(library);
153 void redeployPackages(const char* proofServer, Bool_t localAliRoot = kTRUE)
155 // deploys PWG0base and PWG0dep (the latter only when localAliRoot is true) that are expected in $ALICE_ROOT
156 // when localAliRoot is false ESD.par is also deployed
158 TProof::Reset(proofServer);
159 TVirtualProof* proof = TProof::Open(proofServer);
160 proof->ClearPackages();
163 ProofEnableAliRoot();
166 proof->UploadPackage("$ALICE_ROOT/ESD.par");
167 proof->EnablePackage("ESD");
170 proof->UploadPackage("$ALICE_ROOT/PWG0base.par");
171 proof->EnablePackage("PWG0base");
173 proof->UploadPackage("$ALICE_ROOT/PWG0dep.par");
174 proof->EnablePackage("PWG0dep");