From 8ddad12124e37cad619320993820cf69fbb2364d Mon Sep 17 00:00:00 2001 From: agheata Date: Mon, 17 Jan 2011 12:46:12 +0000 Subject: [PATCH] pipe support for the error bar (C.Holm), minor fix for proof mode in the plugin (D.Stocco) --- ANALYSIS/AliAnalysisAlien.cxx | 15 +++++++++------ ANALYSIS/AliAnalysisManager.cxx | 22 +++++++++++++++++++--- ANALYSIS/AliAnalysisManager.h | 4 ++++ 3 files changed, 32 insertions(+), 9 deletions(-) diff --git a/ANALYSIS/AliAnalysisAlien.cxx b/ANALYSIS/AliAnalysisAlien.cxx index 355729c848b..e6327dea5fa 100644 --- a/ANALYSIS/AliAnalysisAlien.cxx +++ b/ANALYSIS/AliAnalysisAlien.cxx @@ -1673,10 +1673,10 @@ const char *AliAnalysisAlien::GetJobStatus(Int_t jobidstart, Int_t lastid, Int_t Int_t pid; for (Int_t ijob=0; ijobAt(ijob); - pid = gROOT->ProcessLine(Form("atoi(((TAlienJobStatus*)0x%lx)->GetKey(\"queueId\"));", (ULong_t)status)); + pid = gROOT->ProcessLine(Form("atoi(((TAlienJobStatus*)%p)->GetKey(\"queueId\"));", status)); if (pidProcessLine(Form("sprintf((char*)0x%lx,((TAlienJobStatus*)0x%lx)->GetKey(\"status\"));",(ULong_t)mstatus, (ULong_t)status)); + gROOT->ProcessLine(Form("sprintf((char*)%p,((TAlienJobStatus*)%p)->GetKey(\"status\"));",mstatus, status)); } switch (status->GetStatus()) { case TGridJobStatus::kWAITING: @@ -2445,6 +2445,9 @@ Bool_t AliAnalysisAlien::StartAnalysis(Long64_t /*nentries*/, Long64_t /*firstEn 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())); @@ -2461,15 +2464,15 @@ Bool_t AliAnalysisAlien::StartAnalysis(Long64_t /*nentries*/, Long64_t /*firstEn printf("%s %s\n", obj->GetName(), obj->GetTitle()); } if (!gROOT->ProcessLine(Form("gProof->UploadPackage(\"%s\");",alirootLite.Data())) - && !gROOT->ProcessLine(Form("gProof->EnablePackage(\"%s\", (TList*)0x%lx);",alirootLite.Data(),(ULong_t)&optionsList))) { + && !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*)0x%lx);", - fAliROOTVersion.Data(), (ULong_t)&optionsList))) { + 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; } @@ -2547,7 +2550,7 @@ Bool_t AliAnalysisAlien::StartAnalysis(Long64_t /*nentries*/, Long64_t /*firstEn } TFileCollection *coll = new TFileCollection(); coll->AddFromFile(fFileForTestMode); - gROOT->ProcessLine(Form("gProof->RegisterDataSet(\"test_collection\", (TFileCollection*)0x%lx, \"OV\");", (ULong_t)coll)); + gROOT->ProcessLine(Form("gProof->RegisterDataSet(\"test_collection\", (TFileCollection*)%p, \"OV\");", coll)); gROOT->ProcessLine("gProof->ShowDataSets()"); } return kTRUE; diff --git a/ANALYSIS/AliAnalysisManager.cxx b/ANALYSIS/AliAnalysisManager.cxx index 88345082bb3..e62b54d230d 100644 --- a/ANALYSIS/AliAnalysisManager.cxx +++ b/ANALYSIS/AliAnalysisManager.cxx @@ -27,6 +27,7 @@ #include "AliAnalysisManager.h" +#include #include #include #include @@ -2021,6 +2022,19 @@ void AliAnalysisManager::ExecAnalysis(Option_t *option) cdir->cd(); } +//______________________________________________________________________________ +Bool_t AliAnalysisManager::IsPipe(std::ostream &out) +{ +// Check if the stdout is connected to a pipe (C.Holm) + Bool_t ispipe = kFALSE; + out.seekp(0, std::ios_base::cur); + if (out.fail()) { + out.clear(); + if (errno == ESPIPE) ispipe = kTRUE; + } + return ispipe; +} + //______________________________________________________________________________ void AliAnalysisManager::SetInputEventHandler(AliVEventHandler* const handler) { @@ -2184,8 +2198,10 @@ void AliAnalysisManager::ProgressBar(const char *opname, Long64_t current, Long6 static Bool_t oneoftwo = kFALSE; static Int_t nrefresh = 0; static Int_t nchecks = 0; + static char lastChar = 0; const char symbol[4] = {'-','\\','|','/'}; + if (!lastChar) lastChar = (IsPipe(std::cerr))?'\r':'\n'; if (!refresh) { nrefresh = 0; if (!size) return; @@ -2248,10 +2264,10 @@ void AliAnalysisManager::ProgressBar(const char *opname, Long64_t current, Long6 Int_t rsec = remain % 60; Int_t rmin = (remain / 60) % 60; Int_t rhour = (remain / 60 / 60); - fprintf(stderr, "[%6.2f %%] TIME %.2d:%.2d:%.2d ETA %.2d:%.2d:%.2d\r", - percent, hours, minutes, seconds, rhour, rmin, rsec); + fprintf(stderr, "[%6.2f %%] TIME %.2d:%.2d:%.2d ETA %.2d:%.2d:%.2d%c", + percent, hours, minutes, seconds, rhour, rmin, rsec, lastChar); } - else fprintf(stderr, "[%6.2f %%]\r", percent); + else fprintf(stderr, "[%6.2f %%]%c", percent, lastChar); if (refresh && oneoftwo) oname = nname; if (owatch) owatch->Continue(); if (last) { diff --git a/ANALYSIS/AliAnalysisManager.h b/ANALYSIS/AliAnalysisManager.h index d61d0f2a5ba..990f65bf00f 100644 --- a/ANALYSIS/AliAnalysisManager.h +++ b/ANALYSIS/AliAnalysisManager.h @@ -19,6 +19,9 @@ #ifndef ROOT_THashTable #include #endif +#ifndef ROOT_Riostream +#include +#endif class TClass; class TTree; @@ -115,6 +118,7 @@ enum EAliAnalysisFlags { TObjArray *GetTopTasks() const {return fTopTasks;} TTree *GetTree() const {return fTree;} TObjArray *GetZombieTasks() const {return fZombies;} + static Bool_t IsPipe(std::ostream &out); Bool_t IsProofMode() const {return (fMode==kProofAnalysis)?kTRUE:kFALSE;} Bool_t IsRemote() const {return fIsRemote;} Bool_t IsUsingDataSet() const {return TObject::TestBit(kUseDataSet);} -- 2.39.3