2 Origin: marian.ivanov@cern.ch
3 Make sys watch default plots (see $ALICE_ROOT/STEER/AliSysInfo.cxx):
4 Input - syswatch.log - text log file created by process to be monitored
5 Output - syswatch.root - root files with default histograms
6 Number of top violators - only top consumer displayed
8 TOP violators - CPU and Virtual memory usage
9 Detector reports - CPU and Virtual memory usage per detector
14 gROOT->LoadMacro("$ALICE_ROOT/macros/PlotSys.C+");
15 PInit("syswatch.log","syswatch.root","syswatch.sum");
16 // 2. Make ascii report.
18 // 3. Make histos of top violators
20 // 4. Browse the results
21 TFile f("syswatch.root");
26 #include "AliReconstruction.h"
34 #include "AliSysInfo.h"
36 const Int_t kNDetectors=AliReconstruction::kNDetectors;
37 const char* fgkDetectorName[kNDetectors] = {"ITS", "TPC", "TRD", "TOF", "PHOS", "HMPID", "EMCAL", "MUON", "FMD", "ZDC", "PMD", "T0", "VZERO", "ACORDE", "HLT"};
45 TCut cutVM("cutVM","deltaVM>10");
46 TCut cutDT("cutDT","deltaT>2");
50 Float_t TopUsage(TTree* tree, const char *exp, const char*cut, Int_t order);
51 Double_t SumUsage(TTree* tree, const char *exp, const char*cut);
55 void TopCPUDetector();
58 void PInit(const char *log="syswatch.log", const char *out="syswatch.root", const char * sumName="syswatch.sum"){
62 tree = AliSysInfo::MakeTree(log);
63 fout = new TFile(out,"recreate");
69 void MakePlots(Int_t top=20){
74 gStyle->SetOptStat(0);
81 // Reports per detector
84 for (Int_t idet=0; idet<kNDetectors;idet++){
86 fout->mkdir(fgkDetectorName[idet]);
98 // select top user of virtual Memory
99 // MakeReport - ASCII and histogram
103 Float_t thVM = TopUsage(tree,"deltaVM","",ctop);
104 cutVM = TCut("cutDT",Form("deltaVM>%f",thVM));
107 printf("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n\n\n");
108 printf("TOP Virtual memory user\n");
109 //tree->Scan("deltaVM:sname",cutVM,"colsize=20");
110 printf("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n\n\n");
112 tree->Draw("deltaVM:sname>>hhh","1"+cutVM,"*");
113 his2 = (TH2F*)(tree->GetHistogram())->Clone("dvmsname");
114 delete tree->GetHistogram();
115 his2->SetYTitle("Delta Virtual Memory (MBy)");
116 his2->SetMarkerStyle(22);
117 his2->SetMarkerSize(1);
119 his2->Write("DVMvsName");
122 tree->Draw("VM:sname>>hhh","id2<3"+cutVM,"*");
123 his2 = (TH2F*)(tree->GetHistogram())->Clone("vmsname");
124 delete tree->GetHistogram();
125 his2->SetYTitle("Delta Virtual Memory (MBy)");
126 his2->SetMarkerStyle(22);
127 his2->SetMarkerSize(1);
129 his2->Write("VMvsName");
133 tree->Draw("VM:T>>hhh","deltaVM>1","line*");
134 his = (TH1*)tree->GetHistogram()->Clone("vmt");
135 delete tree->GetHistogram();
136 his->SetXTitle("Time (sec)");
137 his->SetYTitle("Virtual Memory (MBy)");
138 his->GetYaxis()->SetTitleOffset(1.2);
139 his->SetMarkerStyle(22);
140 his->SetMarkerSize(1);
142 his->Write("VMvsTime");
148 // select top user of CPU
149 // MakeReport - ASCII and histogram
152 Float_t thDT = TopUsage(tree,"deltaT","id2<3",ctop);
153 cutDT = TCut("cutDT",Form("deltaT>%f",thDT));
155 printf("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n");
156 printf("/n/n/nTOP CPU user\n");
157 //tree->Scan("deltaT:sname",cutDT,"colsize=20");
158 printf("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n");
160 tree->Draw("deltaT:sname>>hhh","id2<3"+cutDT,"*");
161 his2 = (TH2F*)(tree->GetHistogram())->Clone("tsname");
162 delete tree->GetHistogram();
163 his2->SetName("VMsanme");
164 his2->SetYTitle("Delta CPU time(sec)");
165 his2->SetMarkerStyle(22);
166 his2->SetMarkerSize(1);
167 his2->GetXaxis()->SetLabelSize(0.03);
169 his2->Write("CPUvsName");
174 void TopVMDetector(){
183 for (Int_t idet=0; idet<kNDetectors; idet++){
185 fout->cd(fgkDetectorName[idet]);
188 sprintf(cdet,"id0==%d",idet);
190 sprintf(expr,"deltaVM:sname>>hhh");
192 Float_t thDVM = TopUsage(tree,"deltaVM",cdet,ctop);
193 sprintf(cdvm,"%s&&deltaVM>%f",cdet, thDVM);
195 tree->Draw(expr,cdvm,"GOFF");
196 his2 = (TH2F*)(tree->GetHistogram())->Clone("xxx");
197 delete tree->GetHistogram();
198 his2->SetYTitle("Delta Virtual Memory (MBy)");
199 his2->SetMarkerStyle(22);
200 his2->SetMarkerSize(1);
202 his2->Write(Form("DVMvsName_%d",idet));
206 sprintf(expr,"VM:sname>>hhh");
207 tree->Draw(expr,cdvm,"goff");
208 his2 = (TH2F*)(tree->GetHistogram())->Clone("yyy");
209 delete tree->GetHistogram();
210 his2->SetYTitle("Delta Virtual Memory (MBy)");
211 his2->SetMarkerStyle(22);
212 his2->SetMarkerSize(1);
214 his2->Write(Form("VMvsName_%d",idet));
222 void TopCPUDetector(){
231 for (Int_t idet=0; idet<kNDetectors; idet++){
233 fout->cd(fgkDetectorName[idet]);
236 sprintf(cdet,"id0==%d",idet);
238 sprintf(expr,"deltaT:sname>>hhh");
240 Float_t thDT = TopUsage(tree,"deltaT",cdet,ctop);
241 sprintf(cdtime,"%s&&deltaT>%f",cdet, thDT);
243 tree->Draw(expr,cdtime,"goff");
244 his2 = (TH2F*)(tree->GetHistogram())->Clone("dtsname");
245 delete tree->GetHistogram();
246 his2->SetYTitle("Delta CPU time(sec)");
247 his2->SetMarkerStyle(22);
248 his2->SetMarkerSize(1);
249 his2->GetXaxis()->SetLabelSize(0.03);
251 his2->Write(Form("CPUvsName_%d",idet));
259 // Sum - detector information
262 pFile = fopen (sumFile,"w");
265 sprintf(cdet,"id0>=0&&id2>=0");
266 Double_t sumdTAll = SumUsage(tree,"deltaT",cdet);
267 Double_t sumdVMAll = SumUsage(tree,"deltaVM",cdet);
268 printf("%s%s%s%s%s\n","Det/C:","sumDt/F:","sumDvm/F:","fracDt/F:","fracDvm/F");
269 printf("%s\t%f\t%f\t%f\t%f\t\n","all", sumdTAll,sumdVMAll,100.,100.);
270 fprintf(pFile,"%s%s%s%s%s\n","Det/C:","sumDt/F:","sumDvm/F:","fracDt/F:","fracDvm/F");
271 fprintf(pFile,"%s\t%f\t%f\t%f\t%f\t\n","all", sumdTAll,sumdVMAll,100.,100.);
272 for (Int_t idet=0; idet<kNDetectors; idet++){
273 sprintf(cdet,"id0==%d&&id2>=0",idet);
274 sprintf(expr,"deltaT:sname>>hhh");
275 Double_t sumdT = SumUsage(tree,"deltaT",cdet);
276 Double_t sumdVM = SumUsage(tree,"deltaVM",cdet);
277 printf("%s\t%f\t%f\t%f\t%f\t\n",fgkDetectorName[idet], sumdT,sumdVM,100.*sumdT/sumdTAll, 100.*sumdVM/sumdVMAll);
278 fprintf(pFile,"%s\t%f\t%f\t%f\t%f\t\n",fgkDetectorName[idet], sumdT,sumdVM,100.*sumdT/sumdTAll, 100.*sumdVM/sumdVMAll);
288 Float_t TopUsage(TTree* tree, const char *exp, const char*cut, Int_t order){
291 // Find value for given order
292 // Used to select top violator
294 Int_t entries = tree->Draw(Form("%s>>hhh1",exp),cut,"goff");
296 if (tree->GetHistogram()) delete tree->GetHistogram();
297 printf("%s\t No entries\n",cut);
300 if (!tree->GetV1()) {
301 printf("%s\t No entries\n",cut);
304 Int_t *index = new Int_t[entries];
305 TMath::Sort(entries, tree->GetV1(), index);
306 Int_t oindex = TMath::Min(order, entries);
307 Float_t val = tree->GetV1()[index[oindex-1]];
308 if (tree->GetHistogram()) delete tree->GetHistogram();
314 Double_t SumUsage(TTree* tree, const char *exp, const char*cut){
316 // return sum of usage
318 Int_t entries = tree->Draw(Form("%s",exp),cut,"goff");
319 if (entries==0) return 0;
320 Double_t mean = TMath::Mean(entries, tree->GetV1());