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 TProof* connectProof(const char* proofServer)
8 TProof* 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, Int_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");
50 ProofEnableAliRoot(useAliRoot);
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->UploadPackage(Form("%s.par", str->String().Data())))
67 printf("Uploading of package %s failed\n", str->String().Data());
71 if (gProof->EnablePackage(str->String()))
73 printf("Loading of package %s failed\n", str->String().Data());
82 Int_t executeQuery(TChain* chain, TList* inputList, TString selectorName, const char* option = "", Long64_t entries = TChain::kBigNumber)
85 chain->GetUserInfo()->AddAll(inputList);
88 for (Int_t i=0; i<inputList->GetEntries(); ++i)
89 gProof->AddInput(inputList->At(i));
100 result = chain->Process(selectorName, option, entries);
103 result = chain->Process(selectorName, option, entries);
106 printf("ERROR: Executing process failed with %d.\n", result);
114 void ProofEnableAliRoot(Int_t aliroot)
116 // enables a locally deployed AliRoot in a PROOF cluster
118 /* executes the following commands on each node:
119 gSystem->Setenv("ALICE_ROOT", "/home/alicecaf/ALICE/aliroot-head")
120 gSystem->AddIncludePath("/home/alicecaf/ALICE/aliroot-head/include");
121 gSystem->SetDynamicPath(Form("%s:%s", gSystem->GetDynamicPath(), "/home/alicecaf/ALICE/aliroot-head/lib/tgt_linux"))
122 gSystem->Load("libMinuit");
123 gROOT->Macro("$ALICE_ROOT/macros/loadlibs.C");
126 const char* location = 0;
127 const char* target = "tgt_linux";
131 case 1: location = "/afs/cern.ch/alice/caf/sw/ALICE/v4-04-Release/slc4_ia32_gcc34/aliroot"; break;
135 gProof->Exec(Form("gSystem->Setenv(\"ALICE_ROOT\", \"%s\")", location), kTRUE);
136 gProof->AddIncludePath(Form("%s/include", location));
137 gProof->AddDynamicPath(Form("%s/lib/%s", location, target));
139 // load all libraries
140 gProof->Exec("gSystem->Load(\"libMinuit\")");
141 gProof->Exec("gROOT->Macro(\"$ALICE_ROOT/macros/loadlibs.C\")");
144 Bool_t EnablePackageLocal(const char* package)
146 printf("Enabling package %s locally...\n", package);
148 TString currentDir(gSystem->pwd());
149 if (!gSystem->cd(package))
152 gROOT->ProcessLine(".x PROOF-INF/SETUP.C");
153 gSystem->cd(currentDir);
158 Int_t CheckLoadLibrary(const char* library)
160 // checks if a library is already loaded, if not loads the library
162 if (strlen(gSystem->GetLibraries(Form("%s.so", library), "", kFALSE)) > 0)
165 return gSystem->Load(library);
168 void redeployPackages(const char* proofServer, Bool_t localAliRoot = kTRUE)
170 // deploys PWG0base and PWG0dep (the latter only when localAliRoot is true) that are expected in $ALICE_ROOT
171 // when localAliRoot is false ESD.par is also deployed
173 TProof::Reset(proofServer);
174 TVirtualProof* proof = TProof::Open(proofServer);
175 proof->ClearPackages();
178 ProofEnableAliRoot();
181 proof->UploadPackage("$ALICE_ROOT/ESD.par");
182 proof->EnablePackage("ESD");
185 proof->UploadPackage("$ALICE_ROOT/PWG0base.par");
186 proof->EnablePackage("PWG0base");
188 proof->UploadPackage("$ALICE_ROOT/PWG0dep.par");
189 proof->EnablePackage("PWG0dep");