Hall-D Software  alpha
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
plugins/monitoring/DAQ_online/daq_words.C
Go to the documentation of this file.
1 
2 // The following are special comments used by RootSpy to know
3 // which histograms to fetch for the macro.
4 //
5 // hnamepath: /DAQ/daq_words_by_type
6 
7 {
8  //TFile *f = new TFile("hd_root.root");
9  //f->cd("daq");
10 
11  TDirectory *DAQdir = (TDirectory*)gDirectory->FindObjectAny("DAQ");
12  if(!DAQdir){
13  cout << "Can't find 'DAQ' directory! (aborting macro)" << endl;
14  return;
15  }
16  TH1D *daq_words_by_type = (TH1D*)DAQdir->Get("daq_words_by_type");
17  if(!daq_words_by_type){
18  cout << "Can't find 'daq_words_by_type' histogram! (aborting macro)" << endl;
19  return;
20  }
21 
22  if(!gPad){
23  cout << "gPad==NULL!! aborting macro" << endl;
24  return;
25  }
26 
27 // gStyle->SetPadBottomMargin(0.3);
28 // gStyle->SetPadLeftMargin(0.05);
29 // gStyle->SetPadRightMargin(0.02);
30 
31  gPad->SetBottomMargin(0.3);
32  gPad->SetLeftMargin(0.05);
33  gPad->SetRightMargin(0.02);
34 
35  //c1 = new TCanvas("c1", "", 1500, 600);
36  gPad->GetCanvas()->SetTicks();
37  gPad->GetCanvas()->SetLogy();
38 
39  double max = daq_words_by_type->GetMaximum()*1.3;
40  double min = 1.0;
41 
42  daq_words_by_type->SetStats(0);
43  daq_words_by_type->SetYTitle("Total number of 32-bit words");
44  daq_words_by_type->GetYaxis()->SetTitleOffset(0.6);
45  daq_words_by_type->GetYaxis()->SetRangeUser(min, max);
46  daq_words_by_type->Draw();
47 
48  double ylab = pow(10.0, 0.3*(log(max)-log(min)) + log(min));
49 
50  TLatex latex;
51  latex.SetTextSize(0.030);
52  latex.SetTextAlign(12);
53  latex.SetTextAngle(90.0);
54 
55  Int_t Nbins = daq_words_by_type->GetNbinsX();
56  double Nword_tot = daq_words_by_type->GetBinContent(Nbins-1);
57  double sum = 0;
58  for(int ibin=1; ibin<=Nbins; ibin++){
59 
60  double x = daq_words_by_type->GetXaxis()->GetBinCenter(ibin);
61  double Nwords = daq_words_by_type->GetBinContent(ibin);
62  double percent = 100.0 * Nwords / Nword_tot;
63 
64  if(Nwords == 0) continue;
65 
66  if(ibin < Nbins-2) sum += Nwords;
67 
68  char str[256];
69  sprintf(str, "%3.1f%%", percent);
70  if(ibin < Nbins-2) sprintf(str, "%s _{(%3.1f%% total)}", str, 100.0*sum/Nword_tot);
71  latex.DrawLatex( x, ylab, str);
72 
73  }
74 
75 // cout << " sum: " << sum << endl;
76 // cout << " Nword_tot: " << Nword_tot << endl;
77 // cout << " missing: " << (Nword_tot-sum)/Nword_tot*100.0 << "%" << endl;
78 
79 // c1->SaveAs("daq_words.png");
80 // c1->SaveAs("daq_words.pdf");
81 }
82 
char str[256]
Double_t x[NCHANNELS]
Definition: st_tw_resols.C:39
sprintf(text,"Post KinFit Cut")