AliRoot Core  d69033e (d69033e)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PlotSys.C
Go to the documentation of this file.
1 
28 #include "TMath.h"
29 #include "TH1F.h"
30 #include "TH2F.h"
31 #include "TTree.h"
32 #include "TFile.h"
33 #include "TCut.h"
34 #include "TStyle.h"
35 #include "AliSysInfo.h"
36 
37 TObject * htemp;
38 TTree *tree=0;
39 TFile *fout=0;
40 TCut cutVM("cutVM","deltaVM>10");
41 TCut cutDT("cutDT","deltaT>2");
42 Int_t ctop=10;
43 
44 
45 Float_t TopUsage(TTree* tree, const char *exp, const char*cut, Int_t order);
46 void TopVM();
47 void TopCPU();
48 void TopVMDetector();
49 void TopCPUDetector();
50 
51 void PInit(const char *log="syswatch.log", const char *out="syswatch.root"){
53 
55  fout = new TFile(out,"recreate");
56 }
57 
58 
59 
60 void MakePlots(const char *log="syswatch.log", const char *out="syswatch.root", Int_t top=10){
62 
63  ctop=top;
64  PInit(log,out);
65  gStyle->SetOptStat(0);
66  //
67  // Top users
68  //
69  TopVM();
70  TopCPU();
71  //
72  // Reports per detector
73  //
74  fout->mkdir("cpuDetector");
75  fout->mkdir("VMDetector");
76  //
77  fout->cd("VMDetector");
78  TopVMDetector();
79  //
80  fout->cd();
81  fout->cd("cpuDetector");
83 
84  //
85  fout->Close();
86  ctop=top;
87  delete fout;
88 }
89 
90 void TopVM(){
93 
94  TH1 * his=0;
95  TH2 * his2=0;
96  Float_t thVM = TopUsage(tree,"deltaVM","",ctop);
97  cutVM = TCut("cutDT",Form("deltaVM>%f",thVM));
98  //
99  //
100  printf("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n\n\n");
101  printf("TOP Virtual memory user\n");
102  tree->Scan("deltaVM:sname",cutVM,"colsize=20");
103  printf("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n\n\n");
104  //
105  tree->Draw("deltaVM:sname>>hhh","1"+cutVM,"*");
106  his2 = (TH2F*)(tree->GetHistogram())->Clone("dvmsname");
107  delete tree->GetHistogram();
108  his2->SetYTitle("Delta Virtual Memory (MBy)");
109  his2->SetMarkerStyle(22);
110  his2->SetMarkerSize(1);
111  his2->Draw("l*");
112  his2->Write("DVMvsName");
113  delete his2;
114  //
115  tree->Draw("VM:sname>>hhh","id2<3"+cutVM,"*");
116  his2 = (TH2F*)(tree->GetHistogram())->Clone("vmsname");
117  delete tree->GetHistogram();
118  his2->SetYTitle("Delta Virtual Memory (MBy)");
119  his2->SetMarkerStyle(22);
120  his2->SetMarkerSize(1);
121  his2->Draw("l*");
122  his2->Write("VMvsName");
123  delete his2;
124  //
125  //
126  tree->Draw("VM:T>>hhh","deltaVM>1","line*");
127  his = (TH1*)tree->GetHistogram()->Clone("vmt");
128  delete tree->GetHistogram();
129  his->SetXTitle("Time (sec)");
130  his->SetYTitle("Virtual Memory (MBy)");
131  his->GetYaxis()->SetTitleOffset(1.2);
132  his->SetMarkerStyle(22);
133  his->SetMarkerSize(1);
134  his->Draw();
135  his->Write("VMvsTime");
136  delete his;
137 }
138 
139 void TopCPU(){
142 
143  TH2 * his2=0;
144  Float_t thDT = TopUsage(tree,"deltaT","id2<3",ctop);
145  cutDT = TCut("cutDT",Form("deltaT>%f",thDT));
146  //
147  printf("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n");
148  printf("/n/n/nTOP CPU user\n");
149  tree->Scan("deltaT:sname",cutDT,"colsize=20");
150  printf("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n");
151  //
152  tree->Draw("deltaT:sname>>hhh","id2<3"+cutDT,"*");
153  his2 = (TH2F*)(tree->GetHistogram())->Clone("tsname");
154  delete tree->GetHistogram();
155  his2->SetName("VMsanme");
156  his2->SetYTitle("Delta CPU time(sec)");
157  his2->SetMarkerStyle(22);
158  his2->SetMarkerSize(1);
159  his2->GetXaxis()->SetLabelSize(0.03);
160  his2->Draw("l*");
161  his2->Write("CPUvsName");
162  delete his2;
163 }
164 
165 
168 
169  TH2 * his2=0;
170  //
171  //
172  //detector part
173  //
174  for (Int_t idet=0; idet<12; idet++){
175  char cdet[100];
176  char cdvm[100];
177  sprintf(cdet,"id0==%d",idet);
178  char expr[100];
179  sprintf(expr,"deltaVM:sname>>hhh");
180  //
181  Float_t thDVM = TopUsage(tree,"deltaVM",cdet,ctop);
182  sprintf(cdvm,"%s&&deltaT>%f",cdet, thDVM);
183 
184 
185  //
186  tree->Draw(expr,cdvm,"*");
187  his2 = (TH2F*)(tree->GetHistogram())->Clone("xxx");
188  delete tree->GetHistogram();
189  his2->SetYTitle("Delta Virtual Memory (MBy)");
190  his2->SetMarkerStyle(22);
191  his2->SetMarkerSize(1);
192  his2->Draw("l*");
193  his2->Write(Form("DVMvsName_%d",idet));
194  delete his2;
195  //
196  //
197  sprintf(expr,"VM:sname>>hhh");
198  tree->Draw(expr,cdvm,"*");
199  his2 = (TH2F*)(tree->GetHistogram())->Clone("yyy");
200  delete tree->GetHistogram();
201  his2->SetYTitle("Delta Virtual Memory (MBy)");
202  his2->SetMarkerStyle(22);
203  his2->SetMarkerSize(1);
204  his2->Draw("l*");
205  his2->Write(Form("VMvsName_%d",idet));
206  delete his2;
207  }
208 }
209 
210 
211 
214 
215  TH2 * his2=0;
216  //
217  //
218  // CPU
219  //
220  for (Int_t idet=0; idet<12; idet++){
221  char cdet[100];
222  char cdtime[100];
223  sprintf(cdet,"id0==%d",idet);
224  char expr[100];
225  sprintf(expr,"deltaT:sname>>hhh");
226  //
227  Float_t thDT = TopUsage(tree,"deltaT",cdet,ctop);
228  sprintf(cdtime,"%s&&deltaT>%f",cdet, thDT);
229  //
230  tree->Draw(expr,cdtime,"*");
231  his2 = (TH2F*)(tree->GetHistogram())->Clone("dtsname");
232  delete tree->GetHistogram();
233  his2->SetYTitle("Delta CPU time(sec)");
234  his2->SetMarkerStyle(22);
235  his2->SetMarkerSize(1);
236  his2->GetXaxis()->SetLabelSize(0.03);
237  his2->Draw("l*");
238  his2->Write(Form("CPUvsName_%d",idet));
239  delete his2;
240  }
241 }
242 
243 
244 
245 
246 
247 
248 Float_t TopUsage(TTree* tree, const char *exp, const char*cut, Int_t order){
251 
252  Int_t entries = tree->Draw(Form("%s>>hhh1",exp),cut,"goff");
253  if (entries<=1) {
254  if (tree->GetHistogram()) delete tree->GetHistogram();
255  printf("%s\t No entries\n",cut);
256  return -10000;
257  }
258  if (!tree->GetV1()) {
259  printf("%s\t No entries\n",cut);
260  return -10000;
261  }
262  Int_t *index = new Int_t[entries];
263  TMath::Sort(entries, tree->GetV1(), index);
264  Int_t oindex = TMath::Min(order, entries);
265  Float_t val = tree->GetV1()[index[oindex-1]];
266  if (tree->GetHistogram()) delete tree->GetHistogram();
267  delete [] index;
268  return val;
269 }
printf("Chi2/npoints = %f\n", TMath::Sqrt(chi2/npoints))
TStyle * gStyle
void PInit(const char *log="syswatch.log", const char *out="syswatch.root")
Definition: PlotSys.C:51
void TopVMDetector()
Definition: PlotSys.C:166
void MakePlots(const char *log="syswatch.log", const char *out="syswatch.root", Int_t top=10)
Definition: PlotSys.C:60
TTree * tree
Definition: PlotSys.C:38
void TopCPUDetector()
Definition: PlotSys.C:212
TCut cutDT("cutDT","deltaT>2")
void TopVM()
Definition: PlotSys.C:90
void TopCPU()
Definition: PlotSys.C:139
TFile * fout
Definition: PlotSys.C:39
Float_t TopUsage(TTree *tree, const char *exp, const char *cut, Int_t order)
Definition: PlotSys.C:248
TObject * htemp
Definition: PlotSys.C:37
Int_t ctop
Definition: PlotSys.C:42
TCut cut
Definition: MakeGlobalFit.C:75
void MakeTree()
Definition: CalibQA.C:45
TCut cutVM("cutVM","deltaVM>10")