20 #include "TApplication.h"
21 #include "TGraphErrors.h"
22 #include "/sphenix/user/gregtom3/SBU/research/macros/macros/sPHENIXStyle/sPhenixStyle.C"
25 #define XSTR(X) STR(X)
26 #define NELEMS(a) (sizeof(a)/sizeof(a[0]))
29 TTree *
load_tree(
const char *
const file_name,
const char *
const tree_name);
31 {
"/sphenix/user/gregtom3/data/Summer2018/SVTX_studies/hits-per-eta/hitcount.root"};
33 const char *
const hit_containers[] {
"G4HIT_EGEM_0",
"G4HIT_EGEM_1",
"G4HIT_EGEM_3",
34 "G4HIT_FGEM_0",
"G4HIT_FGEM_1",
"G4HIT_FGEM_2",
"G4HIT_FGEM_3",
"G4HIT_FGEM_4",
"G4HIT_MAPS",
36 const static Color_t
plot_colors[] = { kBlue, kSpring, kBlack, kYellow, kCyan, kGray, kMagenta, kOrange,
37 kRed, kGreen + 3, kPink};
43 gROOT->SetBatch(
true);
45 TCanvas *
const c {
new TCanvas {
"hits",
"Hits", gStyle->GetCanvasDefW(), gStyle->GetCanvasDefH()}};
46 TLegend *
const l {
new TLegend {0.7, 0.9, 0.95, 0.61,
"Detector"}};
49 std::vector<TH1F*> hists {};
55 Double_t
eta, hit_count;
56 hits->SetBranchAddress(
"eta", &eta);
57 hits->SetBranchAddress(
"hit_count", &hit_count);
59 Long64_t nentries {hits->GetEntries()};
62 h->SetYTitle(
"Normalized Hit Count");
64 for (Long64_t
j {0};
j < nentries; ++
j) {
65 if (hits->LoadTree(
j) < 0)
71 h->Fill(eta, hit_count);
74 const Long64_t
nbins {
h->GetSize() - 2};
75 for (Long64_t
j {0};
j <
nbins; ++
j) {
76 const Double_t hit_count {
h->GetBinContent(
j + 1)};
77 max = (hit_count > max) ? hit_count : max;
83 l->AddEntry(
h,
"G4HIT_SVTX / 10",
"l");
89 for (
const auto&
h: hists) {
90 h->GetYaxis()->SetRangeUser(0.000001, max * 1.1);
99 TImage *
const img {TImage::Create()};
101 img->WriteImage(
"Hits_vs_Eta.png");
103 gApplication->Terminate(0);
106 TTree *
load_tree(
const char *
const file_name,
const char *
const tree_name)
108 return (TTree *) (
new TFile(file_name,
"READ"))->
Get(tree_name);
111 int main(
int argc,
char *argv[]) {
112 TApplication
app(
"Hit Plots", &argc, argv);