Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
EnergyGlance.C
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file EnergyGlance.C
1 #include <cmath>
2 #include <TFile.h>
3 #include <TString.h>
4 #include <TLine.h>
5 #include <TTree.h>
6 #include <TLatex.h>
7 #include <TGraphErrors.h>
8 #include <cassert>
9 #include <iostream>
10 #include <fstream>
11 using namespace std;
12 
13 
14 
15 using std::cout;
16 using std::endl;
17 #endif
18 
19 
21 {
22  gStyle->SetOptFit(0);
23  gStyle->SetOptStat(0);
24 
25 const int N = 8;
26 
27 double x[N] ={-288, -288, -277, -260, -230, -205, -258, -300};
28 double y[N] = {-105, -177, -117, -165, -165, -138, -138, -188};
29 
30 int XBinlow;
31 int XBinhigh;
32 
33 int YBinlow;
34 int YBinhigh;
35 
36 char hisname[512];
37 
38 char Title[512];
39 
40 double step = 5;
41 
42 TFile *fin = new TFile("His3.root");
43 
44  TCanvas *c12 = new TCanvas("c12", "c12",0,0,800,600);
45  c12->cd();
46 
47 
48 TH1D *h1 = new TH1D("h1","",50,4,12);
49 
50 for(int i = 0; i < N ; i++)
51 {
52 cout << i << endl;
53 
54 
55 
56 XBinlow = Energyhis->GetXaxis()->FindBin(x[i]-step);
57 XBinhigh = Energyhis->GetXaxis()->FindBin(x[i]+step);
58 
59 YBinlow = Energyhis->GetXaxis()->FindBin(y[i]-step);
60 YBinhigh = Energyhis->GetXaxis()->FindBin(y[i]+step);
61 
62 cout << "XBin = " << XBinlow << endl;
63 
64 Energyhis->ProjectionZ("h1",XBinlow,XBinhigh,YBinlow,YBinhigh);
65 
66 
67 
68 
69 sprintf(Title,"Energy Spetrum at Location X = %d Y = %d",x[i],y[i]);
70 
71 h1->SetTitle(Title);
72 h1->GetXaxis()->SetTitle("Energy (GeV)");
73 h1->GetYaxis()->SetTitle("Counts");
74 
75 //return;
76 
77 h1->Draw();
78 
79 
80 
81 c12->Update();
82 
83 sprintf(hisname,"Result/Spetrum%d.png",i);
84 
85 c12->SaveAs(hisname);
86 
87 
88 }
89 
90 }