+ }
+ // Set the needed environment
+ gEnv->SetValue("XSec.GSI.DelegProxy","2");
+ // Do we need to reset PROOF ? The success of the Reset operation cannot be checked
+ if (fProofReset && !testMode) {
+ if (fProofReset==1) {
+ Info("StartAnalysis", "Sending soft reset signal to proof cluster %s", fProofCluster.Data());
+ gROOT->ProcessLine(Form("TProof::Reset(\"%s\", kFALSE);", fProofCluster.Data()));
+ } else {
+ Info("StartAnalysis", "Sending hard reset signal to proof cluster %s", fProofCluster.Data());
+ gROOT->ProcessLine(Form("TProof::Reset(\"%s\", kTRUE);", fProofCluster.Data()));
+ }
+ Info("StartAnalysis", "Stopping the analysis. Please use SetProofReset(0) to resume.");
+ return kFALSE;
+ }
+ // Do we need to change the ROOT version ? The success of this cannot be checked.
+ if (!fRootVersionForProof.IsNull() && !testMode) {
+ gROOT->ProcessLine(Form("TProof::Mgr(\"%s\")->SetROOTVersion(\"%s\");",
+ fProofCluster.Data(), fRootVersionForProof.Data()));
+ }
+ // Connect to PROOF and check the status
+ Long_t proof = 0;
+ TString sworkers;
+ if (fNproofWorkersPerSlave) sworkers = Form("workers=%dx", fNproofWorkersPerSlave);
+ else if (fNproofWorkers) sworkers = Form("workers=%d", fNproofWorkers);
+ if (!testMode) {
+ if (!sworkers.IsNull())
+ proof = gROOT->ProcessLine(Form("TProof::Open(\"%s\", \"%s\");", fProofCluster.Data(), sworkers.Data()));
+ else
+ proof = gROOT->ProcessLine(Form("TProof::Open(\"%s\");", fProofCluster.Data()));
+ } else {
+ proof = gROOT->ProcessLine("TProof::Open(\"\");");
+ if (!proof) {
+ Error("StartAnalysis", "Could not start PROOF in test mode");
+ return kFALSE;
+ }
+ }
+ if (!proof) {
+ Error("StartAnalysis", "Could not connect to PROOF cluster <%s>", fProofCluster.Data());
+ return kFALSE;
+ }
+ if (fNproofWorkersPerSlave*fNproofWorkers > 0)
+ gROOT->ProcessLine(Form("gProof->SetParallel(%d);", fNproofWorkers));
+ // Is dataset existing ?
+ if (!testMode) {
+ TString dataset = fProofDataSet;
+ Int_t index = dataset.Index("#");
+ if (index>=0) dataset.Remove(index);
+// if (!gROOT->ProcessLine(Form("gProof->ExistsDataSet(\"%s\");",fProofDataSet.Data()))) {
+// Error("StartAnalysis", "Dataset %s not existing", fProofDataSet.Data());
+// return kFALSE;
+// }
+// Info("StartAnalysis", "Dataset %s found", dataset.Data());
+ }
+ // Is ClearPackages() needed ?
+ if (TestSpecialBit(kClearPackages)) {
+ Info("StartAnalysis", "ClearPackages signal sent to PROOF. Use SetClearPackages(kFALSE) to reset this.");
+ gROOT->ProcessLine("gProof->ClearPackages();");
+ }
+ // Is a given aliroot mode requested ?
+ TList optionsList;
+ TString parLibs;
+ if (!fAliRootMode.IsNull()) {
+ TString alirootMode = fAliRootMode;
+ if (alirootMode == "default") alirootMode = "";
+ Info("StartAnalysis", "You are requesting AliRoot mode: %s", fAliRootMode.Data());
+ optionsList.SetOwner();
+ optionsList.Add(new TNamed("ALIROOT_MODE", alirootMode.Data()));
+ // Check the additional libs to be loaded
+ TString extraLibs;
+ Bool_t parMode = kFALSE;
+ if (!alirootMode.IsNull()) extraLibs = "ANALYSIS:ANALYSISalice";
+ // Parse the extra libs for .so
+ if (fAdditionalLibs.Length()) {
+ TObjArray *list = fAdditionalLibs.Tokenize(" ");
+ TIter next(list);
+ TObjString *str;
+ while((str=(TObjString*)next())) {
+ if (str->GetString().Contains(".so")) {
+ if (parMode) {
+ Warning("StartAnalysis", "Plugin does not support loading libs after par files in PROOF mode. Library %s and following will not load on workers", str->GetName());
+ break;
+ }
+ TString stmp = str->GetName();
+ if (stmp.BeginsWith("lib")) stmp.Remove(0,3);
+ stmp.ReplaceAll(".so","");
+ if (!extraLibs.IsNull()) extraLibs += ":";
+ extraLibs += stmp;
+ continue;
+ }
+ if (str->GetString().Contains(".par")) {
+ // The first par file found in the list will not allow any further .so
+ parMode = kTRUE;
+ if (!parLibs.IsNull()) parLibs += ":";
+ parLibs += str->GetName();
+ continue;
+ }
+ }
+ if (list) delete list;
+ }
+ if (!extraLibs.IsNull()) optionsList.Add(new TNamed("ALIROOT_EXTRA_LIBS",extraLibs.Data()));
+ // Check extra includes
+ if (!fIncludePath.IsNull()) {
+ TString includePath = fIncludePath;
+ includePath.ReplaceAll(" ",":");
+ includePath.ReplaceAll("$ALICE_ROOT","");
+ includePath.ReplaceAll("${ALICE_ROOT}","");
+ includePath.ReplaceAll("-I","");
+ includePath.Strip(TString::kTrailing, ':');
+ Info("StartAnalysis", "Adding extra includes: %s",includePath.Data());
+ optionsList.Add(new TNamed("ALIROOT_EXTRA_INCLUDES",includePath.Data()));
+ }
+ // Check if connection to grid is requested
+ if (TestSpecialBit(kProofConnectGrid))
+ optionsList.Add(new TNamed("ALIROOT_ENABLE_ALIEN", "1"));
+ // Enable AliRoot par
+ if (testMode) {
+ // Enable proof lite package
+ TString alirootLite = gSystem->ExpandPathName("$ALICE_ROOT/ANALYSIS/macros/AliRootProofLite.par");
+ for (Int_t i=0; i<optionsList.GetSize(); i++) {
+ TNamed *obj = (TNamed*)optionsList.At(i);
+ printf("%s %s\n", obj->GetName(), obj->GetTitle());
+ }
+ if (!gROOT->ProcessLine(Form("gProof->UploadPackage(\"%s\");",alirootLite.Data()))
+ && !gROOT->ProcessLine(Form("gProof->EnablePackage(\"%s\", (TList*)%p);",alirootLite.Data(),&optionsList))) {
+ Info("StartAnalysis", "AliRootProofLite enabled");
+ } else {
+ Error("StartAnalysis", "There was an error trying to enable package AliRootProofLite.par");
+ return kFALSE;
+ }
+ } else {
+ if (gROOT->ProcessLine(Form("gProof->EnablePackage(\"VO_ALICE@AliRoot::%s\", (TList*)%p, kTRUE);",
+ fAliROOTVersion.Data(), &optionsList))) {
+ Error("StartAnalysis", "There was an error trying to enable package VO_ALICE@AliRoot::%s", fAliROOTVersion.Data());
+ return kFALSE;
+ }
+ }
+ // Enable first par files from fAdditionalLibs
+ if (!parLibs.IsNull()) {
+ TObjArray *list = parLibs.Tokenize(":");
+ TIter next(list);
+ TObjString *package;
+ while((package=(TObjString*)next())) {
+ TString spkg = package->GetName();
+ spkg.ReplaceAll(".par", "");
+ gSystem->Exec(TString::Format("rm -rf %s", spkg.Data()));
+ if (!gROOT->ProcessLine(Form("gProof->UploadPackage(\"%s\");", package->GetName()))) {
+ TString enablePackage = (testMode)?Form("gProof->EnablePackage(\"%s\",kFALSE);", package->GetName()):Form("gProof->EnablePackage(\"%s\",kTRUE);", package->GetName());
+ if (gROOT->ProcessLine(enablePackage)) {
+ Error("StartAnalysis", "There was an error trying to enable package %s", package->GetName());
+ return kFALSE;
+ }
+ } else {
+ Error("StartAnalysis", "There was an error trying to upload package %s", package->GetName());
+ return kFALSE;
+ }
+ }
+ if (list) delete list;
+ }
+ } else {
+ if (fAdditionalLibs.Contains(".so") && !testMode) {
+ Error("StartAnalysis", "You request additional libs to be loaded but did not enabled any AliRoot mode. Please refer to: \
+ \n http://aaf.cern.ch/node/83 and use a parameter for SetAliRootMode()");
+ return kFALSE;
+ }
+ }
+ // Enable par files if requested
+ if (fPackages && fPackages->GetEntries()) {
+ TIter next(fPackages);
+ TObject *package;
+ while ((package=next())) {
+ // Skip packages already enabled
+ if (parLibs.Contains(package->GetName())) continue;
+ TString spkg = package->GetName();
+ spkg.ReplaceAll(".par", "");
+ gSystem->Exec(TString::Format("rm -rf %s", spkg.Data()));
+ if (gROOT->ProcessLine(Form("gProof->UploadPackage(\"%s\");", package->GetName()))) {
+ if (gROOT->ProcessLine(Form("gProof->EnablePackage(\"%s\",kTRUE);", package->GetName()))) {
+ Error("StartAnalysis", "There was an error trying to enable package %s", package->GetName());
+ return kFALSE;
+ }
+ } else {
+ Error("StartAnalysis", "There was an error trying to upload package %s", package->GetName());
+ return kFALSE;
+ }
+ }
+ }
+ // Do we need to load analysis source files ?
+ // NOTE: don't load on client since this is anyway done by the user to attach his task.
+ if (fAnalysisSource.Length()) {
+ TObjArray *list = fAnalysisSource.Tokenize(" ");
+ TIter next(list);
+ TObjString *str;
+ while((str=(TObjString*)next())) {
+ gROOT->ProcessLine(Form("gProof->Load(\"%s+g\", kTRUE);", str->GetName()));
+ }
+ if (list) delete list;