Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-06 08:15:41

0001 #include <cmath>
0002 #include <TFile.h>
0003 #include <TString.h>
0004 #include <TLine.h>
0005 #include <TTree.h>
0006 #include <TLatex.h>
0007 #include <TGraphErrors.h>
0008 #include <cassert>
0009 #include <iostream>
0010 #include <fstream>
0011 using namespace std;
0012 
0013 
0014 
0015 using std::cout;
0016 using std::endl;
0017 #endif
0018 
0019 
0020 void EnergyGlance()
0021 {
0022  gStyle->SetOptFit(0);
0023    gStyle->SetOptStat(0);
0024 
0025 const int N = 8;
0026 
0027 double x[N] ={-288, -288, -277, -260, -230, -205, -258, -300};
0028 double y[N] = {-105, -177, -117, -165, -165, -138, -138, -188};
0029 
0030 int XBinlow;
0031 int XBinhigh;
0032 
0033 int YBinlow;
0034 int YBinhigh;
0035 
0036 char hisname[512];
0037 
0038 char Title[512];
0039 
0040 double step = 5;
0041 
0042 TFile *fin = new TFile("His3.root");
0043 
0044  TCanvas *c12 = new TCanvas("c12", "c12",0,0,800,600);
0045  c12->cd();
0046 
0047 
0048 TH1D *h1 = new TH1D("h1","",50,4,12);
0049 
0050 for(int i = 0; i < N ; i++)
0051 {
0052 cout << i << endl;
0053 
0054 
0055 
0056 XBinlow = Energyhis->GetXaxis()->FindBin(x[i]-step);
0057 XBinhigh = Energyhis->GetXaxis()->FindBin(x[i]+step);
0058 
0059 YBinlow = Energyhis->GetXaxis()->FindBin(y[i]-step);
0060 YBinhigh = Energyhis->GetXaxis()->FindBin(y[i]+step);
0061 
0062 cout << "XBin = " << XBinlow << endl;
0063 
0064 Energyhis->ProjectionZ("h1",XBinlow,XBinhigh,YBinlow,YBinhigh);
0065 
0066 
0067 
0068 
0069 sprintf(Title,"Energy Spetrum at Location X = %d Y = %d",x[i],y[i]);
0070 
0071 h1->SetTitle(Title);
0072 h1->GetXaxis()->SetTitle("Energy (GeV)");
0073 h1->GetYaxis()->SetTitle("Counts");
0074 
0075 //return;
0076 
0077 h1->Draw();
0078 
0079 
0080 
0081 c12->Update();
0082 
0083 sprintf(hisname,"Result/Spetrum%d.png",i);
0084 
0085 c12->SaveAs(hisname);
0086 
0087 
0088 }
0089 
0090 }