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 "SaveCanvas.C"
0010 #include "SetOKStyle.C"
0011 #include <iostream>
0012 #include <fstream>
0013 #include "TROOT.h"
0014 #include "TH1.h"
0015 #include "TTree.h"
0016 using namespace std;
0017
0018
0019
0020 using std::cout;
0021 using std::endl;
0022 #endif
0023
0024
0025
0026
0027 void ReadHis()
0028 {
0029
0030 gSystem->Load("libg4eval.so");
0031 gSystem->Load("libqa_modules.so");
0032 gSystem->Load("libPrototype3.so");
0033 gStyle->SetOptFit(0);
0034 gStyle->SetOptStat(0);
0035
0036 double step = 1;
0037
0038 int Ini = 3543;
0039 int Final = 3579;
0040
0041
0042 double Xmin = 170;
0043 double Xmax = 310.0;
0044
0045 double Ymin = 60;
0046 double Ymax = 245.0;
0047
0048
0049
0050
0051
0052
0053
0054
0055
0056
0057
0058
0059 double Energy;
0060 double Energy_err;
0061 double Width;
0062 double Width_err;
0063 double Center;
0064 double Center_err;
0065
0066 double x;
0067 double y;
0068 double xhigh;
0069 double yhigh;
0070 int binxhigh;
0071 int binyhigh;
0072
0073 int binx;
0074 int biny;
0075 int XBins = (Xmax - Xmin)/step+1;
0076 int YBins = (Ymax - Ymin)/step+1;
0077 int index = 0;
0078
0079 int indexmax = XBins * YBins;
0080 char Filename[512];
0081 char inputfile[512];
0082
0083 sprintf(inputfile,"Hisfiles130/HisAll.root");
0084
0085
0086
0087
0088 TFile *fin = new TFile(inputfile);
0089 TH2D *EnPo= new TH2D("EnPo","",XBins,Xmin,Xmax,YBins,Ymin,Ymax);
0090
0091
0092 cout << "XBins = " << XBins << endl;
0093 cout << "YBins = " << YBins << endl;
0094
0095 char hisname[512];
0096
0097 for(int i = 0; i < XBins; i++)
0098 {
0099
0100 x = Xmin + step*i;
0101
0102 xhigh = Xmin + step*(i+1);
0103
0104
0105 for(int j = 0; j < YBins; j++)
0106 {
0107
0108
0109 y = Ymin + step*j;
0110 yhigh = Ymin + step*(j+1);
0111
0112
0113 binxhigh = Energyhis->GetZaxis()->FindBin(xhigh);
0114 binyhigh = Energyhis->GetYaxis()->FindBin(yhigh);
0115
0116
0117
0118 binx = Energyhis->GetZaxis()->FindBin(x);
0119 biny = Energyhis->GetYaxis()->FindBin(y);
0120
0121
0122
0123
0124
0125 TH1D *h5= new TH1D("h5","",50,6,10);
0126
0127 Energyhis->ProjectionX("h5",biny,binyhigh,binx,binxhigh);
0128
0129
0130
0131
0132
0133
0134
0135
0136
0137
0138
0139
0140
0141
0142
0143
0144
0145
0146
0147
0148
0149
0150
0151 Center = h5->GetMean();
0152
0153 cout << "Mean = " << Center << endl;
0154
0155 EnPo->SetBinContent(binx,biny,Center);
0156
0157
0158 index = index + 1;
0159
0160 }
0161
0162 }
0163
0164 TCanvas *c22 = new TCanvas("c22", "c22",0,0,800,600);
0165
0166 c22->cd();
0167
0168 EnPo->Draw();
0169
0170 c22->Update();
0171
0172 c22->SaveAs("EnPo.png");
0173
0174
0175 sprintf(Filename,"EnergyPosition.root");
0176
0177
0178 TFile *fout = new TFile(Filename,"RECREATE");
0179 EnPo->Write();
0180
0181
0182 }