File indexing completed on 2025-08-05 08:14:42
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 ReadHis3()
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 = 340.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;
0076 int YBins = (Ymax - Ymin)/step;
0077
0078
0079
0080
0081
0082 int index = 0;
0083
0084 int indexmax = XBins * YBins;
0085 char Filename[512];
0086 char inputfile[512];
0087
0088
0089
0090 sprintf(inputfile,"His3.root");
0091
0092 TFile *fin = new TFile(inputfile);
0093 TH2D *EnPo= new TH2D("EnPo","",XBins,Xmin,Xmax,YBins,Ymin,Ymax);
0094
0095
0096 cout << "XBins = " << XBins << endl;
0097 cout << "YBins = " << YBins << endl;
0098
0099 char hisname[512];
0100
0101 for(int i = 0; i < XBins; i++)
0102 {
0103
0104 x = Xmin + step*i;
0105
0106 xhigh = Xmin + step*(i+1);
0107
0108
0109 for(int j = 0; j < YBins; j++)
0110 {
0111
0112
0113 y = Ymin + step*j;
0114 yhigh = Ymin + step*(j+1);
0115
0116
0117
0118
0119 binx = Energyhis->GetXaxis()->FindBin(x+0.0001);
0120 biny = Energyhis->GetYaxis()->FindBin(y+0.0001);
0121
0122
0123
0124
0125
0126
0127 binxhigh = Energyhis->GetXaxis()->FindBin(xhigh-0.0001);
0128 binyhigh = Energyhis->GetYaxis()->FindBin(yhigh-0.0001);
0129
0130
0131 TH1D *h5= new TH1D("h5","",50,6,10);
0132
0133
0134
0135
0136 Energyhis->ProjectionZ("h5",binx,binxhigh,biny,binyhigh);
0137
0138
0139
0140
0141
0142
0143
0144
0145
0146
0147
0148
0149
0150
0151
0152
0153
0154
0155
0156
0157
0158
0159
0160 Center = h5->GetMean();
0161
0162
0163
0164
0165 cout << "Mean = " << Center << endl;
0166
0167 EnPo->SetBinContent(binx,biny,Center);
0168
0169
0170 index = index + 1;
0171
0172 }
0173
0174 }
0175
0176 TCanvas *c22 = new TCanvas("c22", "c22",0,0,800,600);
0177
0178 c22->cd();
0179
0180 EnPo->Draw();
0181
0182 c22->Update();
0183
0184 c22->SaveAs("EnPo.png");
0185
0186
0187
0188
0189 sprintf(Filename,"EnergyPosition3.root");
0190 TFile *fout = new TFile(Filename,"RECREATE");
0191 EnPo->Write();
0192
0193
0194 }