AliPhysics  5eaf189 (5eaf189)
PlotSysInfo.C
Go to the documentation of this file.
1 
15 TVirtualPad* MakeCanvas(const char* title="")
16 {
17  static Int_t cId = 0;
18  TCanvas* c = new TCanvas(Form("c%02d", ++cId), title);
19  c->SetTopMargin(0.02);
20  c->SetRightMargin(0.02);
21  c->cd();
22  return c;
23 }
35  const char* exp,
36  const char* cut,
37  bool draw=false)
38 {
39  if (draw) MakeCanvas(Form("%s [%s]", exp, cut));
40 
41  Int_t entries = tree->Draw(exp, cut, (draw ? "" : "goff"));
42  if (entries==0) return 0;
43 
44  Double_t mean = TMath::Mean(entries, tree->GetV1());
45  return entries * mean;
46 }
58  const char* exp,
59  const char* cut,
60  Int_t order)
61 {
62  Int_t entries = tree->Draw(exp, cut, "goff");
63  if (entries <= 1 || !tree->GetV1()) return -10000;
64 
65  TArrayI index(entries);
66  TMath::Sort(entries, tree->GetV1(), index.fArray);
67 
68  Int_t oindex = TMath::Min(order, entries);
69  Double_t value = tree->GetV1()[index[oindex-1]];
70 
71  return value;
72 }
88  const char* exp,
89  const char* cut,
90  const char* name,
91  const char* xtitle="",
92  const char* ytitle="",
93  Bool_t draw=false)
94 {
95  tree->Draw(Form("%s>>tmpa", exp), cut, "GOFF");
96  if (!tree->GetHistogram()) return 0;
97 
98  TH1* ret = static_cast<TH1*>(tree->GetHistogram()->Clone(name));
99  delete tree->GetHistogram();
100  ret->SetXTitle(xtitle);
101  ret->SetYTitle(ytitle);
102  ret->SetMarkerStyle(22);
103  ret->SetMarkerSize(1);
104  if (draw) {
105  if (draw) MakeCanvas(name);
106  ret->Draw();
107  }
108  return ret;
109 }
110 
121 void Print(std::ostream& o,
122  const char* name,
123  Double_t dT,
124  Double_t dVM,
125  Double_t alldT,
126  Double_t alldVM)
127 {
128  o << name << "\t"
129  << dT << "\t"
130  << dVM << "\t"
131  << 100*(alldT > 0 ? dT / alldT : 0) << "\t"
132  << 100*(alldVM > 0 ? dVM / alldVM : 0) << std::endl;
133 }
138 const char* dets[] = {"ITS",
139  "TPC",
140  "TRD",
141  "TOF",
142  "PHOS",
143  "HMPID",
144  "EMCAL",
145  "MUON",
146  "FMD",
147  "ZDC",
148  "PMD",
149  "T0",
150  "VZERO",
151  "ACORDE",
152  "HLT",
153  0 };
154 
161 void
162 Plot1SysInfo(const char* file, UShort_t draw=0x1)
163 {
164  // --- Create output file and tree ---------------------------------
165  TString rootOut(file);
166  rootOut.ReplaceAll(".log", ".root");
167  rootOut.ReplaceAll(".foo", ".root");
168  Info("", "Writing to ROOT file %s", rootOut.Data());
169  TFile* out = TFile::Open(rootOut, "RECREATE");
170  TTree* tree = AliSysInfo::MakeTree(file);
171  tree->SetName("T");
172 
173 
174  // --- Create ASCII output ------------------------------------------
175  TString sumOut(rootOut);
176  sumOut.ReplaceAll(".root", ".sum");
177  Info("", "Writing to ASCII file %s", sumOut.Data());
178  std::ofstream ascii(sumOut.Data());
179  ascii << "Det/C:sumDt/F:sumDvm/F:fracDt/F:fracDvm/F" << std::endl;
180 
181  // --- Get global stuff ---------------------------------------------
182  const char* all = "id0>=0&&id2>=0";
183  Double_t sumdTAll = SumUsage(tree, "deltaT", all, draw & 0x1);
184  Double_t sumdVMAll = SumUsage(tree, "deltaVM", all, draw & 0x1);
185  Double_t topdT = TopUsage(tree, "deltaT", "id2<3", 20);
186  Double_t topdVM = TopUsage(tree, "deltaVM", "", 20);
187  TCut cutT("cutDT", Form("deltaT > %f", topdT));
188  TCut cutVM("cutVM", Form("deltaVM > %f", topdVM));
189 
190  ExtractHist(tree, "deltaVM:sname", "1"+cutVM,
191  "DVMvsName","","#DeltaVM [MB]", draw&0x4);
192  ExtractHist(tree, "VM:sname", "id2<3"+cutVM,
193  "VMvsName", "", "VM [MB]", draw&0x4);
194  ExtractHist(tree, "VM:T", "deltaVM>1",
195  "VMvsTime", "Time [sec]", "VM [MB]", draw&0x4);
196  ExtractHist(tree, "deltaT:sname","id2<3"+cutT,
197  "CPUvsName","","#DeltaT [sec]", draw&0x4);
198 
199 
200 
201  Print(ascii, "all", sumdTAll, sumdVMAll, sumdTAll, sumdVMAll);
202 
203 
204 
205  // --- Loop over detetors ------------------------------------------
206  const char** pdet = dets;
207  Int_t idet = 0;
208  while (*pdet) {
209  TString cut = Form("id0==%d && id2 >= 0", idet);
210  Double_t sumdT = SumUsage(tree, "deltaT", cut, draw & 0x2);
211  Double_t sumdVM = SumUsage(tree, "deltaVM", cut, draw & 0x2);
212  Print(ascii, *pdet, sumdT, sumdVM, sumdTAll, sumdVMAll);
213 
214 #if 0
215  TString cut2 = Form("id0==%d",idet);
216  ExtractHist(tree, "deltaVM:sname", cut2.Data()+cutVM,
217  Form("DVMvsName_%02d", idet), "", "#DeltaVM [MB]", draw&0x8);
218  ExtractHist(tree, "VM:sname", cut2.Data()+cutVM,
219  Form("VMvsName_%02d", idet), "", "VM [MB]", draw&0x8);
220  ExtractHist(tree, "deltaT:sname", cut2.Data()+cutT,
221  Form("CPUvsName_%02d", idet),"", "#DeltaT [sec]", draw&0x8);
222 #endif
223 
224  pdet++;
225  idet++;
226  }
227  ascii.close();
228  tree->Write();
229  out->Write();
230  out->ls();
231  new TBrowser;
232 }
233 
239 void
240 PlotSysInfo(ULong_t pid=431808952)
241 {
242  Plot1SysInfo(Form("%d_simwatch.log", pid));
243  Plot1SysInfo(Form("%d_recowatch.log", pid));
244 }
245 //
246 // EOF
247 //
248 
249 
void Print(std::ostream &o, const char *name, Double_t dT, Double_t dVM, Double_t alldT, Double_t alldVM)
Definition: PlotSysInfo.C:121
double Double_t
Definition: External.C:58
const char * title
Definition: MakeQAPdf.C:27
TCanvas * c
Definition: TestFitELoss.C:172
void PlotSysInfo(ULong_t pid=431808952)
Definition: PlotSysInfo.C:240
TVirtualPad * MakeCanvas(const char *title="")
Definition: PlotSysInfo.C:15
int Int_t
Definition: External.C:63
TH1 * ExtractHist(TTree *tree, const char *exp, const char *cut, const char *name, const char *xtitle="", const char *ytitle="", Bool_t draw=false)
Definition: PlotSysInfo.C:87
Double_t TopUsage(TTree *tree, const char *exp, const char *cut, Int_t order)
Definition: PlotSysInfo.C:57
Double_t SumUsage(TTree *tree, const char *exp, const char *cut, bool draw=false)
Definition: PlotSysInfo.C:34
unsigned long ULong_t
Definition: External.C:38
Bool_t draw[nPtBins]
void Plot1SysInfo(const char *file, UShort_t draw=0x1)
Definition: PlotSysInfo.C:162
TFile * file
TList with histograms for a given trigger.
const char * dets[]
Definition: PlotSysInfo.C:138
unsigned short UShort_t
Definition: External.C:28
bool Bool_t
Definition: External.C:53
Definition: External.C:196