Hall-D Software  alpha
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
programs/Utilities/hdevio_scan/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 void daq_words(void)
8 {
9 
10  TH1D *daq_words_by_type = (TH1D*)gROOT->FindObject("daq_words_by_type");
11  if(!daq_words_by_type){
12  cout << "Can't find 'daq_words_by_type' histogram! (aborting macro)" << endl;
13  return;
14  }
15 
16  TCanvas *c1 = new TCanvas("c1", "", 1600, 800);
17  c1->Draw();
18 
19  if(!gPad){
20  cout << "gPad==NULL!! aborting macro" << endl;
21  return;
22  }
23 
24  gPad->SetBottomMargin(0.3);
25  gPad->SetLeftMargin(0.05);
26  gPad->SetRightMargin(0.02);
27 
28  //c1 = new TCanvas("c1", "", 1500, 600);
29  gPad->GetCanvas()->SetTicks();
30  gPad->GetCanvas()->SetLogy();
31 
32  // Set max so maximum bin (not including total words bin
33  // which should be highest) is at 55%
34 
35 
36  double mid = daq_words_by_type->GetMaximum(daq_words_by_type->GetMaximum());
37  double min = 1.0;
38  double max = pow(10.0, (1.0/0.65)*(log10(mid)-log10(min) + log10(min)));
39 
40  daq_words_by_type->SetStats(0);
41  daq_words_by_type->SetYTitle("Total number of 32-bit words");
42  daq_words_by_type->GetYaxis()->SetTitleOffset(0.6);
43  daq_words_by_type->GetYaxis()->SetRangeUser(min, max);
44  daq_words_by_type->SetFillColor(kBlue);
45  daq_words_by_type->SetBarWidth(0.92);
46  daq_words_by_type->Draw("bar");
47 
48  double ylab = max;
49 
50  TLatex latex;
51  latex.SetTextSize(0.030);
52  latex.SetTextAlign(32);
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 Nevents = daq_words_by_type->GetBinContent(Nbins);
58  double Nunknown = daq_words_by_type->GetBinContent(2);
59  double sum = 0;
60  for(int ibin=1; ibin<=Nbins; ibin++){
61 
62  double x = daq_words_by_type->GetXaxis()->GetBinCenter(ibin);
63  double Nwords = daq_words_by_type->GetBinContent(ibin);
64  double percent = 100.0 * Nwords / Nword_tot;
65 
66  if(Nwords == 0) continue;
67 
68  if(ibin < Nbins-2) sum += Nwords;
69 
70  char str[256];
71  sprintf(str, "%4.1f%%", percent);
72  if(ibin < Nbins-2) sprintf(str, "%s _{(%3.1f%% total)}", str, 100.0*sum/Nword_tot);
73  latex.DrawLatex( x, ylab, str);
74 
75  }
76 
77  double y_one_percent = 0.01*Nword_tot;
78  TLine lin(0.0, y_one_percent, (double)Nbins, y_one_percent);
79  lin.SetLineColor(kMagenta);
80  lin.Draw();
81 
82  cout << " sum: " << sum << endl;
83  cout << " Nword_tot: " << Nword_tot << endl;
84  cout << " missing: " << (Nword_tot-sum)/Nword_tot*100.0 << "%" << endl;
85  cout << " Event Size: " << (double)Nword_tot/(double)Nevents*4.0/1024.0 << " kB/event" << endl;
86  cout << " Nunknown/event: " << (double)Nunknown/(double)Nevents << " bytes" << endl;
87 
88  c1->SaveAs("daq_words.png");
89  c1->SaveAs("daq_words.pdf");
90 }
91 
char str[256]
Double_t x[NCHANNELS]
Definition: st_tw_resols.C:39
sprintf(text,"Post KinFit Cut")
Double_t c1[2][NMODULES]
Definition: tw_corr.C:68
double Nevents