X-Git-Url: http://git.uio.no/git/?p=u%2Fmrichter%2FAliRoot.git;a=blobdiff_plain;f=macros%2FPlotSys.C;h=a680b32d1246c70933a1441e2c47a402b16cf3c0;hp=c595f7f5c5105699c36d51ab61f24ce1e12cb3fc;hb=ab557934fe585eff24a4645eb201426baaa5cca5;hpb=faad97e35a4e80b89443df060e43522b7e51935a diff --git a/macros/PlotSys.C b/macros/PlotSys.C index c595f7f5c51..a680b32d124 100644 --- a/macros/PlotSys.C +++ b/macros/PlotSys.C @@ -4,24 +4,26 @@ Input - syswatch.log - text log file created by process to be monitored Output - syswatch.root - root files with default histograms Number of top violators - only top consumer displayed - Default histogram: - - TOP violateors - CPU and Virtual memory usage + TOP violators - CPU and Virtual memory usage Detector reports - CPU and Virtual memory usage per detector - - - - - - Usage example: - .x ~/rootlogon.C + // + + Example usage: + // 1. Initialize gROOT->LoadMacro("$ALICE_ROOT/macros/PlotSys.C+"); - MakePlots("syswatch.log","syswatch.root",10); + PInit("syswatch.log","syswatch.root","syswatch.sum"); + // 2. Make ascii report. + SumDetector() + // 3. Make histos of top violators + MakePlots(20); + // 4. Browse the results TFile f("syswatch.root"); TBrowser b; -*/ + */ +#include +#include "AliReconstruction.h" #include "TMath.h" #include "TH1F.h" #include "TH2F.h" @@ -31,36 +33,44 @@ #include "TStyle.h" #include "AliSysInfo.h" +const Int_t kNDetectors=AliReconstruction::kNDetectors; +const char* fgkDetectorName[kNDetectors] = {"ITS", "TPC", "TRD", "TOF", "PHOS", "HMPID", "EMCAL", "MUON", "FMD", "ZDC", "PMD", "T0", "VZERO", "ACORDE", "HLT"}; + + + TObject * htemp; TTree *tree=0; TFile *fout=0; +TString sumFile; TCut cutVM("cutVM","deltaVM>10"); TCut cutDT("cutDT","deltaT>2"); -Int_t ctop=10; +Int_t ctop=20; Float_t TopUsage(TTree* tree, const char *exp, const char*cut, Int_t order); +Double_t SumUsage(TTree* tree, const char *exp, const char*cut); void TopVM(); void TopCPU(); void TopVMDetector(); void TopCPUDetector(); +void SumDetector(); -void PInit(const char *log="syswatch.log", const char *out="syswatch.root"){ +void PInit(const char *log="syswatch.log", const char *out="syswatch.root", const char * sumName="syswatch.sum"){ // // Set Input output // tree = AliSysInfo::MakeTree(log); fout = new TFile(out,"recreate"); + sumFile=sumName; } -void MakePlots(const char *log="syswatch.log", const char *out="syswatch.root", Int_t top=10){ +void MakePlots(Int_t top=20){ // // // ctop=top; - PInit(log,out); gStyle->SetOptStat(0); // // Top users @@ -70,16 +80,13 @@ void MakePlots(const char *log="syswatch.log", const char *out="syswatch.root", // // Reports per detector // - fout->mkdir("cpuDetector"); - fout->mkdir("VMDetector"); - // - fout->cd("VMDetector"); - TopVMDetector(); - // fout->cd(); - fout->cd("cpuDetector"); + for (Int_t idet=0; idetcd(); + fout->mkdir(fgkDetectorName[idet]); + } + TopVMDetector(); TopCPUDetector(); - // fout->Close(); ctop=top; @@ -99,7 +106,7 @@ void TopVM(){ // printf("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n\n\n"); printf("TOP Virtual memory user\n"); - tree->Scan("deltaVM:sname",cutVM,"colsize=20"); + //tree->Scan("deltaVM:sname",cutVM,"colsize=20"); printf("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n\n\n"); // tree->Draw("deltaVM:sname>>hhh","1"+cutVM,"*"); @@ -147,7 +154,7 @@ void TopCPU(){ // printf("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n"); printf("/n/n/nTOP CPU user\n"); - tree->Scan("deltaT:sname",cutDT,"colsize=20"); + //tree->Scan("deltaT:sname",cutDT,"colsize=20"); printf("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n"); // tree->Draw("deltaT:sname>>hhh","id2<3"+cutDT,"*"); @@ -173,7 +180,9 @@ void TopVMDetector(){ // //detector part // - for (Int_t idet=0; idet<12; idet++){ + for (Int_t idet=0; idetcd(); + fout->cd(fgkDetectorName[idet]); char cdet[100]; char cdvm[100]; sprintf(cdet,"id0==%d",idet); @@ -181,32 +190,31 @@ void TopVMDetector(){ sprintf(expr,"deltaVM:sname>>hhh"); // Float_t thDVM = TopUsage(tree,"deltaVM",cdet,ctop); - sprintf(cdvm,"%s&&deltaT>%f",cdet, thDVM); - - + sprintf(cdvm,"%s&&deltaVM>%f",cdet, thDVM); // - tree->Draw(expr,cdvm,"*"); + tree->Draw(expr,cdvm,"GOFF"); his2 = (TH2F*)(tree->GetHistogram())->Clone("xxx"); delete tree->GetHistogram(); his2->SetYTitle("Delta Virtual Memory (MBy)"); his2->SetMarkerStyle(22); his2->SetMarkerSize(1); - his2->Draw("l*"); + //his2->Draw("l*"); his2->Write(Form("DVMvsName_%d",idet)); delete his2; // // sprintf(expr,"VM:sname>>hhh"); - tree->Draw(expr,cdvm,"*"); + tree->Draw(expr,cdvm,"goff"); his2 = (TH2F*)(tree->GetHistogram())->Clone("yyy"); delete tree->GetHistogram(); his2->SetYTitle("Delta Virtual Memory (MBy)"); his2->SetMarkerStyle(22); his2->SetMarkerSize(1); - his2->Draw("l*"); + //his2->Draw("l*"); his2->Write(Form("VMvsName_%d",idet)); delete his2; } + fout->cd(); } @@ -220,7 +228,9 @@ void TopCPUDetector(){ // // CPU // - for (Int_t idet=0; idet<12; idet++){ + for (Int_t idet=0; idetcd(); + fout->cd(fgkDetectorName[idet]); char cdet[100]; char cdtime[100]; sprintf(cdet,"id0==%d",idet); @@ -230,20 +240,47 @@ void TopCPUDetector(){ Float_t thDT = TopUsage(tree,"deltaT",cdet,ctop); sprintf(cdtime,"%s&&deltaT>%f",cdet, thDT); // - tree->Draw(expr,cdtime,"*"); + tree->Draw(expr,cdtime,"goff"); his2 = (TH2F*)(tree->GetHistogram())->Clone("dtsname"); delete tree->GetHistogram(); his2->SetYTitle("Delta CPU time(sec)"); his2->SetMarkerStyle(22); his2->SetMarkerSize(1); his2->GetXaxis()->SetLabelSize(0.03); - his2->Draw("l*"); + //his2->Draw("l*"); his2->Write(Form("CPUvsName_%d",idet)); delete his2; } + fout->cd(); +} + +void SumDetector(){ + // + // Sum - detector information + // + FILE * pFile; + pFile = fopen (sumFile,"w"); + char cdet[100]; + char expr[100]; + sprintf(cdet,"id0>=0&&id2>=0"); + Double_t sumdTAll = SumUsage(tree,"deltaT",cdet); + Double_t sumdVMAll = SumUsage(tree,"deltaVM",cdet); + printf("%s%s%s%s%s\n","Det/C:","sumDt/F:","sumDvm/F:","fracDt/F:","fracDvm/F"); + printf("%s\t%f\t%f\t%f\t%f\t\n","all", sumdTAll,sumdVMAll,100.,100.); + fprintf(pFile,"%s%s%s%s%s\n","Det/C:","sumDt/F:","sumDvm/F:","fracDt/F:","fracDvm/F"); + fprintf(pFile,"%s\t%f\t%f\t%f\t%f\t\n","all", sumdTAll,sumdVMAll,100.,100.); + for (Int_t idet=0; idet=0",idet); + sprintf(expr,"deltaT:sname>>hhh"); + Double_t sumdT = SumUsage(tree,"deltaT",cdet); + Double_t sumdVM = SumUsage(tree,"deltaVM",cdet); + printf("%s\t%f\t%f\t%f\t%f\t\n",fgkDetectorName[idet], sumdT,sumdVM,100.*sumdT/sumdTAll, 100.*sumdVM/sumdVMAll); + fprintf(pFile,"%s\t%f\t%f\t%f\t%f\t\n",fgkDetectorName[idet], sumdT,sumdVM,100.*sumdT/sumdTAll, 100.*sumdVM/sumdVMAll); + } + fclose (pFile); } - + @@ -272,3 +309,14 @@ Float_t TopUsage(TTree* tree, const char *exp, const char*cut, Int_t order){ delete [] index; return val; } + + +Double_t SumUsage(TTree* tree, const char *exp, const char*cut){ + // + // return sum of usage + // + Int_t entries = tree->Draw(Form("%s",exp),cut,"goff"); + if (entries==0) return 0; + Double_t mean = TMath::Mean(entries, tree->GetV1()); + return entries*mean; +}