BOSS 7.0.8
BESIII Offline Software System
Loading...
Searching...
No Matches
CheckRung/check/gainVsDoca.cxx File Reference
#include <vector>
#include <string>
#include "TStyle.h"
#include "TString.h"

Go to the source code of this file.

Functions

void pushNo ()
 
void gainVsDoca ()
 

Variables

vector< string > file
 
const int PadNo1 = 0
 
const int PadNo2 = 40
 
const int TotalNo = 1600
 
const int NumSlices = 40
 
const int gainmin = 0
 
const int gainmax = 3
 
TString LegendName = "gain vs doca"
 
const int Ipadx = 1
 
const int Ipady = 1
 
const int CanvasX = 800
 
const int CanvasY = 600
 
bool NormFlag = false
 
const double histmin = 0.7
 
const double histmax = 1.3
 
const double delta = 0.15
 

Function Documentation

◆ gainVsDoca()

void gainVsDoca ( )

Definition at line 35 of file CheckRung/check/gainVsDoca.cxx.

36{
37 pushNo();
38 const int FileNo = file.size();
39 TH2F*** h = new TH2F**[PadNo2];
40 TCanvas*** c = new TCanvas**[PadNo2];
41 TLegend*** lgd = new TLegend**[PadNo2];
42 gStyle->SetOptStat(0);
43 gStyle->SetCanvasColor(10);
44 for(int i=0;i<PadNo2;i++)
45 {
46 h[i] = new TH2F*[FileNo/2];
47 c[i] = new TCanvas*[FileNo/2];
48 lgd[i] = new TLegend*[FileNo/2];
49 }
50
51
52 TFile* f1;
53 TFile* f2;
54 TTree* tree1;
55 TTree* tree2;
56 double gain1[TotalNo],gain2[TotalNo],Ip_eangle1[TotalNo],Ip_eangle2[TotalNo],Norm1,Norm2;
57
58 stringstream histname; //histogram name
59 stringstream ss_file1; //file name
60 stringstream ss_file2;
61 stringstream ss1; //picture's drawing content
62 stringstream ss2;
63 stringstream cut;
64 stringstream legendheader;
65
66 for(int k=0;k<FileNo;k+=2)
67 {
68 ss_file1.str("");
69 ss_file1<<file[k];
70 f1=new TFile(ss_file1.str().c_str());
71 tree1=(TTree*)f1->Get("ddgcalib");
72 tree1->SetBranchAddress("Out_gain", gain1);
73 tree1->SetBranchAddress("Ip_eangle", Ip_eangle1);
74 tree1->GetEntry(0);
75 tree1->SetMarkerStyle(22);
76 tree1->SetMarkerColor(4);
77 tree1->SetLineColor(4);
78
79 ss_file2.str("");
80 ss_file2<<file[k+1];
81 f2=new TFile(ss_file2.str().c_str());
82 tree2=(TTree*)f2->Get("ddgcalib");
83 tree2->SetBranchAddress("Out_gain", gain2);
84 tree2->SetBranchAddress("Ip_eangle", Ip_eangle2);
85 tree2->GetEntry(0);
86 tree2->SetMarkerStyle(20);
87 tree2->SetMarkerColor(2);
88 tree2->SetLineColor(2);
89
90 for(int i=PadNo1;i<PadNo2;i++)
91 {
92 Norm1=0;
93 Norm2=0;
94 int k1=0;
95 int k2=0;
96
97 for(int j=0;j<TotalNo;j++)
98 {
99 if(Ip_eangle1[j]!=i) continue;
100 if(gain1[j]>gainmin && gain1[j]<gainmax) {Norm1 += gain1[j];k1++;}
101 if(gain2[j]>gainmin && gain2[j]<gainmax) {Norm2 += gain2[j];k2++;}
102 }
103 if(k1==0 || k2==0) {Norm1=1; Norm2=1;}
104 else {Norm1/= k1; Norm2/= k2;}
105 cout<<"Norm1= "<<Norm1<<" Norm2= "<<Norm2<<endl;
106
107 legendheader.str("");
108 legendheader<<"eangle"<<i<<": "<<LegendName;
109 //cout<<"legendheader: "<<legendheader.str().c_str()<<endl;
110 lgd[i][k/2] = new TLegend(.3, .75, .89, .89);
111 lgd[i][k/2] ->SetFillColor(10);
112 lgd[i][k/2] ->SetBorderSize(1);
113 lgd[i][k/2] ->SetHeader(legendheader.str().c_str());
114 lgd[i][k/2] ->AddEntry(tree1, ss_file1.str().c_str() , "p");
115 lgd[i][k/2] ->AddEntry(tree2, ss_file2.str().c_str() , "p");
116
117 histname.str("");
118 histname<<"eangle"<<i<<"_"<<file[k]<<"-"<<file[k+1];
119 //cout<<"histname: "<<histname.str().c_str()<<endl;
120 if(NormFlag) h[i][k/2] = new TH2F(histname.str().c_str(),"",100,0,NumSlices,100,histmin,histmax);
121 else h[i][k/2] = new TH2F(histname.str().c_str(),"",100,0,NumSlices,100,(Norm1+Norm2)/2-delta,(Norm1+Norm2)/2+delta);
122 h[i][k/2] -> GetYaxis()->SetTitle("gain");
123 h[i][k/2] -> GetYaxis()->SetTitleOffset(1.);
124 h[i][k/2] -> GetXaxis()->SetTitle("doca");
125 c[i][k/2] = new TCanvas(histname.str().c_str(),histname.str().c_str(),800,600);
126 h[i][k/2] -> Draw();
127
128 cut.str("");
129 cut<<"Ip_eangle=="<<i;
130 cout<<"cut: "<<cut.str().c_str()<<endl;
131
132 ss1.str("");
133 if(NormFlag) ss1<<"Out_gain/"<<Norm1<<":Id_doca";
134 else ss1<<"Out_gain"<<":Id_doca";
135 tree1->Draw(ss1.str().c_str(),cut.str().c_str(),"sameLP");
136 ss2.str("");
137 if(NormFlag) ss2<<"Out_gain/"<<Norm2<<":Id_doca";
138 else ss2<<"Out_gain"<<":Id_doca";
139 tree2->Draw(ss2.str().c_str(),cut.str().c_str(),"sameLP");
140 lgd[i][k/2] ->Draw();
141 }
142 }
143
144 TFile* g = new TFile("gainVsDoca.root","RECREATE");
145 for(int i=PadNo1;i<PadNo2;i++)
146 {
147 for(int k=0;k<FileNo;k+=2)
148 {
149 c[i][k/2] -> Write();
150 }
151 }
152 g->Close();
153
154 TCanvas* cc = new TCanvas("cc", "canvas", CanvasX, CanvasY);
155 cc->Divide(Ipadx,Ipady);
156 cc->Print("gainVsDoca.ps[");
157 for(int i=PadNo1;i<PadNo2;i++)
158 {
159 for(int k=0;k<FileNo;k+=2)
160 {
161 cc->cd(k/2+1);
162 gPad->Clear();
163 c[i][k/2]->DrawClonePad();
164 c[i][k/2] -> Close();
165 lgd[i][k/2] ->Delete();
166 }
167 cc->Update();
168 cc->Print("gainVsDoca.ps");
169 }
170 cc->Print("gainVsDoca.ps]");
171 cc->Close();
172
173 delete cc;
174 for(int i=PadNo1;i<PadNo2;i++)
175 {
176 for(int k=0;k<FileNo;k+=2)
177 {
178 delete h[i][k/2];
179 delete c[i][k/2];
180 }
181 }
182}
const int NumSlices
vector< string > file
const int PadNo2
const int CanvasX
const int Ipadx
const double delta
const int Ipady
const double histmax
const double histmin
const int gainmin
const int PadNo1
const int CanvasY
const int gainmax
const int TotalNo
TString LegendName
f1 Close()
curve Write()
legend Draw()
mg GetYaxis() -> SetRangeUser(0.8, 1.02)
mg GetXaxis() -> SetRangeUser(0.5, 1.9)
TFile * f1

◆ pushNo()

void pushNo ( )

Definition at line 9 of file CheckRung/check/gainVsDoca.cxx.

10{
11 file.push_back("../../DocaEangle/docaeangle.root");
12 file.push_back("docaeangle.root");
13}

Referenced by gainVsDoca().

Variable Documentation

◆ CanvasX

const int CanvasX = 800

Definition at line 27 of file CheckRung/check/gainVsDoca.cxx.

Referenced by gainVsDoca().

◆ CanvasY

const int CanvasY = 600

Definition at line 28 of file CheckRung/check/gainVsDoca.cxx.

Referenced by gainVsDoca().

◆ delta

◆ file

vector<string> file

Definition at line 8 of file CheckRung/check/gainVsDoca.cxx.

Referenced by gainVsDoca(), and pushNo().

◆ gainmax

const int gainmax = 3

Definition at line 23 of file CheckRung/check/gainVsDoca.cxx.

Referenced by gainVsDoca().

◆ gainmin

const int gainmin = 0

Definition at line 22 of file CheckRung/check/gainVsDoca.cxx.

Referenced by gainVsDoca().

◆ histmax

const double histmax = 1.3

Definition at line 31 of file CheckRung/check/gainVsDoca.cxx.

Referenced by gainVsDoca().

◆ histmin

const double histmin = 0.7

Definition at line 30 of file CheckRung/check/gainVsDoca.cxx.

Referenced by gainVsDoca().

◆ Ipadx

const int Ipadx = 1

Definition at line 25 of file CheckRung/check/gainVsDoca.cxx.

Referenced by gainVsDoca().

◆ Ipady

const int Ipady = 1

Definition at line 26 of file CheckRung/check/gainVsDoca.cxx.

Referenced by gainVsDoca().

◆ LegendName

TString LegendName = "gain vs doca"

Definition at line 24 of file CheckRung/check/gainVsDoca.cxx.

Referenced by gainVsDoca().

◆ NormFlag

bool NormFlag = false

Definition at line 29 of file CheckRung/check/gainVsDoca.cxx.

Referenced by gainVsDoca().

◆ NumSlices

const int NumSlices = 40

Definition at line 21 of file CheckRung/check/gainVsDoca.cxx.

Referenced by gainVsDoca().

◆ PadNo1

const int PadNo1 = 0

Definition at line 18 of file CheckRung/check/gainVsDoca.cxx.

Referenced by gainVsDoca().

◆ PadNo2

const int PadNo2 = 40

Definition at line 19 of file CheckRung/check/gainVsDoca.cxx.

Referenced by gainVsDoca().

◆ TotalNo

const int TotalNo = 1600

Definition at line 20 of file CheckRung/check/gainVsDoca.cxx.

Referenced by gainVsDoca().