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 const char* GetAliRootLocation(Int_t aliroot)
118 case 1: return "/afs/cern.ch/alice/caf/sw/ALICE/v4-04-Release/slc4_ia32_gcc34/aliroot"; break;
123 void ProofEnableAliRoot(Int_t aliroot)
125 // enables a locally deployed AliRoot in a PROOF cluster
127 /* executes the following commands on each node:
128 gSystem->Setenv("ALICE_ROOT", "/home/alicecaf/ALICE/aliroot-head")
129 gSystem->AddIncludePath("/home/alicecaf/ALICE/aliroot-head/include");
130 gSystem->SetDynamicPath(Form("%s:%s", gSystem->GetDynamicPath(), "/home/alicecaf/ALICE/aliroot-head/lib/tgt_linux"))
131 gSystem->Load("libMinuit");
132 gROOT->Macro("$ALICE_ROOT/macros/loadlibs.C");
135 const char* location = GetAliRootLocation(aliroot);
136 const char* target = "tgt_linux";
138 gProof->Exec(Form("gSystem->Setenv(\"ALICE_ROOT\", \"%s\")", location), kTRUE);
139 gProof->AddIncludePath(Form("%s/include", location));
140 gProof->AddDynamicPath(Form("%s/lib/%s", location, target));
142 // load all libraries
143 gProof->Exec("gSystem->Load(\"libMinuit\")");
144 gProof->Exec("gROOT->Macro(\"$ALICE_ROOT/macros/loadlibs.C\")");
147 void ProofAddAliRootIncludePath(Int_t aliroot, const char* dir)
149 // adds an include path inside the aliroot structure
151 const char* location = GetAliRootLocation(aliroot);
152 gProof->AddIncludePath(Form("%s/%s", location, dir));
155 Bool_t EnablePackageLocal(const char* package)
157 printf("Enabling package %s locally...\n", package);
159 TString currentDir(gSystem->pwd());
160 if (!gSystem->cd(package))
163 gROOT->ProcessLine(".x PROOF-INF/SETUP.C");
164 gSystem->cd(currentDir);
169 Int_t CheckLoadLibrary(const char* library)
171 // checks if a library is already loaded, if not loads the library
173 if (strlen(gSystem->GetLibraries(Form("%s.so", library), "", kFALSE)) > 0)
176 return gSystem->Load(library);
179 void redeployPackages(const char* proofServer, Bool_t localAliRoot = kTRUE)
181 // deploys PWG0base and PWG0dep (the latter only when localAliRoot is true) that are expected in $ALICE_ROOT
182 // when localAliRoot is false ESD.par is also deployed
184 TProof::Reset(proofServer);
185 TVirtualProof* proof = TProof::Open(proofServer);
186 proof->ClearPackages();
189 ProofEnableAliRoot();
192 proof->UploadPackage("$ALICE_ROOT/ESD.par");
193 proof->EnablePackage("ESD");
196 proof->UploadPackage("$ALICE_ROOT/PWG0base.par");
197 proof->EnablePackage("PWG0base");
199 proof->UploadPackage("$ALICE_ROOT/PWG0dep.par");
200 proof->EnablePackage("PWG0dep");