BOSS 7.0.9
BESIII Offline Software System
Loading...
Searching...
No Matches
WireGain/wiregVsWire_bylayer.cxx File Reference
#include "TStyle.h"
#include "TString.h"

Go to the source code of this file.

Functions

void pushNo ()
 
void wiregVsWire_bylayer ()
 

Variables

int wirebind [44] = {0,40,84,132,188,252,324,404,484,560,636,724,812,912,1012,1124,1236,1364,1492,1632,1772,1932,2092,2252,2412,2588,2764,2940,3116,3324,3532,3740,3948,4188,4428,4668,4908,5164,5420,5676,5932,6220,6508,6796}
 
const int LayNoi = 0
 
const int LayNo = 43
 
const int WireNo = 6796
 
double wiregmin = 0.
 
double wiregmax = 3
 
TString LegendName = "wiregen vs wire"
 
const int Ipadx = 1
 
const int Ipady = 1
 
const int CanvasX = 800
 
const int CanvasY = 600
 
bool NormFlag = true
 
const double histmin = 0.7
 
const double histmax = 1.3
 
const double delta = 0.15
 
vector< string > file
 

Function Documentation

◆ pushNo()

void pushNo ( )

Definition at line 26 of file WireGain/wiregVsWire_bylayer.cxx.

27{
28 file.push_back("wiregain.root");
29 file.push_back("wiregain_new.root");
30}
vector< string > file

Referenced by wiregVsWire_bylayer().

◆ wiregVsWire_bylayer()

void wiregVsWire_bylayer ( )

Definition at line 32 of file WireGain/wiregVsWire_bylayer.cxx.

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

Variable Documentation

◆ CanvasX

const int CanvasX = 800

Definition at line 16 of file WireGain/wiregVsWire_bylayer.cxx.

Referenced by wiregVsWire_bylayer().

◆ CanvasY

const int CanvasY = 600

Definition at line 17 of file WireGain/wiregVsWire_bylayer.cxx.

Referenced by wiregVsWire_bylayer().

◆ delta

const double delta = 0.15

Definition at line 21 of file WireGain/wiregVsWire_bylayer.cxx.

Referenced by wiregVsWire_bylayer().

◆ file

vector<string> file

Definition at line 25 of file WireGain/wiregVsWire_bylayer.cxx.

Referenced by pushNo(), and wiregVsWire_bylayer().

◆ histmax

const double histmax = 1.3

Definition at line 20 of file WireGain/wiregVsWire_bylayer.cxx.

Referenced by wiregVsWire_bylayer().

◆ histmin

const double histmin = 0.7

Definition at line 19 of file WireGain/wiregVsWire_bylayer.cxx.

Referenced by wiregVsWire_bylayer().

◆ Ipadx

const int Ipadx = 1

Definition at line 14 of file WireGain/wiregVsWire_bylayer.cxx.

Referenced by wiregVsWire_bylayer().

◆ Ipady

const int Ipady = 1

Definition at line 15 of file WireGain/wiregVsWire_bylayer.cxx.

Referenced by wiregVsWire_bylayer().

◆ LayNo

const int LayNo = 43

Definition at line 9 of file WireGain/wiregVsWire_bylayer.cxx.

Referenced by wiregVsWire_bylayer().

◆ LayNoi

const int LayNoi = 0

Definition at line 8 of file WireGain/wiregVsWire_bylayer.cxx.

Referenced by wiregVsWire_bylayer().

◆ LegendName

TString LegendName = "wiregen vs wire"

Definition at line 13 of file WireGain/wiregVsWire_bylayer.cxx.

Referenced by wiregVsWire_bylayer().

◆ NormFlag

bool NormFlag = true

Definition at line 18 of file WireGain/wiregVsWire_bylayer.cxx.

Referenced by wiregVsWire_bylayer().

◆ wirebind

int wirebind[44] = {0,40,84,132,188,252,324,404,484,560,636,724,812,912,1012,1124,1236,1364,1492,1632,1772,1932,2092,2252,2412,2588,2764,2940,3116,3324,3532,3740,3948,4188,4428,4668,4908,5164,5420,5676,5932,6220,6508,6796}

Definition at line 7 of file WireGain/wiregVsWire_bylayer.cxx.

Referenced by wiregVsWire_bylayer().

◆ wiregmax

double wiregmax = 3

Definition at line 12 of file WireGain/wiregVsWire_bylayer.cxx.

Referenced by wiregVsWire_bylayer().

◆ wiregmin

double wiregmin = 0.

Definition at line 11 of file WireGain/wiregVsWire_bylayer.cxx.

Referenced by wiregVsWire_bylayer().

◆ WireNo

const int WireNo = 6796

Definition at line 10 of file WireGain/wiregVsWire_bylayer.cxx.

Referenced by wiregVsWire_bylayer().