8 {
9 Int_t runno;
10 Double_t runmean, rungain, runresol;
11
12 TFile fdedx( "DedxConst_before.root", "recreate" );
13
14 TTree* runbyrun = new TTree( "runcalib", "runcalib" );
15 runbyrun->Branch( "runno", &runno, "runno/I" );
16 runbyrun->Branch( "runmean", &runmean, "runmean/D" );
17 runbyrun->Branch( "rungain", &rungain, "rungain/D" );
18 runbyrun->Branch( "runresol", &runresol, "runresol/D" );
19
20 TFile fconst0( "rungain.root" );
21 TTree* tree_rung = (TTree*)fconst0.Get( "runcalib" );
22 tree_rung->SetBranchAddress( "rungain", &rungain );
23 tree_rung->SetBranchAddress( "runmean", &runmean );
24 tree_rung->SetBranchAddress( "runno", &runno );
25 tree_rung->SetBranchAddress( "runresol", &runresol );
26
27 long NRUN = tree_rung->GetEntries();
28 cout << "Run Number == " << NRUN << endl;
29 for ( long runid = 0; runid < NRUN; runid++ )
30 {
31 tree_rung->GetEntry( runid );
32 if ( runno < 12739 ) runbyrun->Fill();
33 }
34
35 TTree* tree_resg = (TTree*)fconst0.Get( "resolcalib" );
36 Double_t resolpar[1];
37 tree_resg->SetBranchAddress( "resol", resolpar );
38 tree_resg->GetEntry( 0 );
39
40 TTree* tree_gaing = (TTree*)fconst0.Get( "gaincalib" );
41 Double_t gainpar[1];
42 tree_gaing->SetBranchAddress( "gain", gainpar );
43 tree_gaing->GetEntry( 0 );
44
45 fconst0.Close();
46 cout << "runbyrun const OK!!!" << endl;
47
48
49 TFile fconst1( "/ihepbatch/besd26/anff/662/Calib/const_file/WireGain/"
50 "wiregain_before_new.root" );
51
52
53
54
55
56
57
58
59
60 Double_t gwire[6796];
61 TTree* tree_wireg = (TTree*)fconst1.Get( "wiregcalib" );
62 tree_wireg->SetBranchAddress( "wireg", gwire );
63 tree_wireg->GetEntry( 0 );
64 fconst1.Close();
65 cout << "wiregcalib const OK!!!" << endl;
66
67
68 TFile fconst2( "../Eangle1D/DedxConst_test.root" );
69 Double_t ggs0[43], ggs1[43], ggs2[43], ggs3[43];
70 TTree* tree_ggs = (TTree*)fconst2.Get( "ggscalib" );
71 tree_ggs->SetBranchAddress( "ggs0", ggs0 );
72 tree_ggs->SetBranchAddress( "ggs1", ggs1 );
73 tree_ggs->SetBranchAddress( "ggs2", ggs2 );
74 tree_ggs->SetBranchAddress( "ggs3", ggs3 );
75 tree_ggs->GetEntry( 0 );
76 fconst2.Close();
77 cout << "ggscalib const OK!!!" << endl;
78
79
80 TFile fconst3( "../Eangle1D/DedxConst_test.root" );
81 Double_t ddg0[43], ddg1[43], ddg2[43], ddg3[43];
82 TTree* tree_ddg = (TTree*)fconst3.Get( "ddgcalib" );
83 tree_ddg->SetBranchAddress( "ddg0", ddg0 );
84 tree_ddg->SetBranchAddress( "ddg1", ddg1 );
85 tree_ddg->SetBranchAddress( "ddg2", ddg2 );
86 tree_ddg->SetBranchAddress( "ddg3", ddg3 );
87 tree_ddg->GetEntry( 0 );
88 fconst3.Close();
89 cout << "ddgcalib const OK!!!" << endl;
90
91
92 TFile fconst4( "../Eangle1D/DedxConst_test.root" );
93 Double_t entra0[43], entra1[43], entra2[43], entra3[43];
94 TTree* tree_entra = (TTree*)fconst4.Get( "entracalib" );
95 tree_entra->SetBranchAddress( "entra0", entra0 );
96 tree_entra->SetBranchAddress( "entra1", entra1 );
97 tree_entra->SetBranchAddress( "entra2", entra2 );
98 tree_entra->SetBranchAddress( "entra3", entra3 );
99
100
101
102
103 tree_entra->GetEntry( 0 );
104 fconst4.Close();
105
106 TFile fconst4_1( "/ihepbatch/besd26/anff/662/Calib/draw/calib/eangle/EAngle.root" );
107
108 int entry[1];
109 double denangle[100];
110 TTree* tree_entra1 = (TTree*)fconst4_1.Get( "entracalib" );
111 tree_entra1->SetBranchAddress( "1denangle_entry", entry );
112 tree_entra1->SetBranchAddress( "1denangle", denangle );
113 tree_entra1->GetEntry( 0 );
114 fconst4_1.Close();
115 cout << "entrance angle const OK!!!" << endl;
116
117
118 TFile fconst5( "../Eangle1D/DedxConst_test.root" );
119 Double_t zdep0[43], zdep1[43], zdep2[43], zdep3[43];
120 TTree* tree_zdep = (TTree*)fconst5.Get( "zdepcalib" );
121 tree_zdep->SetBranchAddress( "zdep0", zdep0 );
122 tree_zdep->SetBranchAddress( "zdep1", zdep1 );
123 tree_zdep->SetBranchAddress( "zdep2", zdep2 );
124 tree_zdep->SetBranchAddress( "zdep3", zdep3 );
125 tree_zdep->GetEntry( 0 );
126 fconst5.Close();
127 cout << "zdepcalib const OK!!!" << endl;
128
129
130 TFile fconst6( "../Eangle1D/DedxConst_test.root" );
131 Double_t glayer[43];
132 TTree* tree_layerg = (TTree*)fconst6.Get( "layergcalib" );
133 tree_layerg->SetBranchAddress( "layerg", glayer );
134 tree_layerg->GetEntry( 0 );
135 fconst6.Close();
136 cout << "layergcalib const OK!!!" << endl;
137
138
139
140
141
142 TFile fconst7( "/ihepbatch/besd26/anff/662/Calib/const_file/Costheta/costheta_new.root" );
143 TTree* tree_costheta = (TTree*)fconst7.Get( "costhetacalib" );
144 double gcostheta[80];
145 tree_costheta->SetBranchAddress( "costheta", gcostheta );
146 tree_costheta->GetEntry( 0 );
147 fconst7.Close();
148 cout << "costhetacalib const OK!!!" << endl;
149
150
151 TFile fconst8( "/afs/ihep.ac.cn/bes3/offline/CalibConst/dedx/6.5.3/Jpsi/t0calib.root" );
152
153 TTree* tree_t0 = (TTree*)fconst8.Get( "t0calib" );
154 double t0, dedx;
155 double gt0[35];
156 double gdedx[35];
157 tree_t0->SetBranchAddress( "t0", &t0 );
158 tree_t0->SetBranchAddress( "dedx", &dedx );
159 for ( int i = 0; i < tree_t0->GetEntries(); i++ )
160 {
161 tree_t0->GetEntry( i );
162 gt0[i] = t0;
163 gdedx[i] = dedx;
164 }
165 fconst8.Close();
166 cout << "t0calib const OK!!!" << endl;
167
168
169
170
171 TFile fconst9(
172 "/ihepbatch/besd26/anff/662/Calib/const_file/DocaEAngle/docaeangle_new.root" );
174 double Iner_gain[
n], Iner_chi[
n], Iner_hits[
n];
175 double Out_gain[
n], Out_chi[
n], Out_hits[
n];
176 double Id_doca[
n], Ip_eangle[
n];
177
178 TTree* tree_docasin = (TTree*)fconst9.Get( "ddgcalib" );
179 tree_docasin->SetBranchAddress( "Iner_gain", Iner_gain );
180 tree_docasin->SetBranchAddress( "Iner_chi", Iner_chi );
181 tree_docasin->SetBranchAddress( "Iner_hits", Iner_hits );
182 tree_docasin->SetBranchAddress( "Out_gain", Out_gain );
183 tree_docasin->SetBranchAddress( "Out_chi", Out_chi );
184 tree_docasin->SetBranchAddress( "Out_hits", Out_hits );
185 tree_docasin->SetBranchAddress( "Id_doca", Id_doca );
186 tree_docasin->SetBranchAddress( "Ip_eangle", Ip_eangle );
187 tree_docasin->GetEntry( 0 );
188 fconst9.Close();
189
190 cout << "ddgcalib const OK!!!" << endl;
191
192 TFile fconst10( "/panfs/panfs.ihep.ac.cn/home/data/anff/dEdxCal/662_cal/Hadron/constfile/"
193 "Hadron_11414-14604.root" );
194
195
196
197
198 int hadronNo;
199 double ghadron[5];
200 TTree* tree_hadron = (TTree*)fconst10.Get( "ggscalib" );
201 tree_hadron->SetBranchAddress( "hadron", ghadron );
202 tree_hadron->SetBranchAddress( "hadronNo", &hadronNo );
203 tree_hadron->GetEntry( 0 );
204 fconst10.Close();
205 cout << "hadron const OK!!!" << endl;
206
207
208 fdedx.cd();
209 TTree* gain = new TTree( "gaincalib", "gaincalib" );
210 gain->Branch( "gain", gainpar, "gain[1]/D" );
211 gain->Branch( "t0", gt0, "t0[35]/D" );
212 gain->Branch( "dedx", gdedx, "dedx[35]/D" );
213
214 TTree* resol = new TTree( "resolcalib", "resolcalib" );
215 resol->Branch( "resol", resolpar, "resol[1]/D" );
216
217 TTree* wireg = new TTree( "wiregcalib", "wiregcalib" );
218 wireg->Branch( "wireg", gwire, "wireg[6796]/D" );
219 wireg->SetBasketSize( "wireg", 2000000 );
220
221 TTree* ggs = new TTree( "ggscalib", "ggscalib" );
222 ggs->Branch( "ggs0", ggs0, "ggs[43]/D" );
223 ggs->Branch( "ggs1", ggs1, "ggs[43]/D" );
224 ggs->Branch( "ggs2", ggs2, "ggs[43]/D" );
225 ggs->Branch( "ggs3", ggs3, "ggs[43]/D" );
226 ggs->Branch( "costheta", gcostheta, "costheta[80]/D" );
227 ggs->Branch( "hadron", ghadron, "hadron[5]/D" );
228 ggs->Branch( "hadronNo", &hadronNo, "hadronNo/I" );
229
230 TTree* ddg = new TTree( "ddgcalib", "ddgcalib" );
231 ddg->Branch( "ddg0", ddg0, "ddg[43]/D" );
232 ddg->Branch( "ddg1", ddg1, "ddg[43]/D" );
233 ddg->Branch( "ddg2", ddg2, "ddg[43]/D" );
234 ddg->Branch( "ddg3", ddg3, "ddg[43]/D" );
235 ddg->Branch( "Iner_gain", Iner_gain, "Iner_gain[1600]/D" );
236 ddg->Branch( "Out_gain", Out_gain, "Out_gain[1600]/D" );
237 ddg->Branch( "Iner_chi", Iner_chi, "Iner_chi[1600]/D" );
238 ddg->Branch( "Out_chi", Out_chi, "Out_chi[1600]/D" );
239 ddg->Branch( "Iner_hits", Iner_hits, "Iner_hits[1600]/D" );
240 ddg->Branch( "Out_hits", Out_hits, "Out_hits[1600]/D" );
241 ddg->Branch( "Id_doca", Id_doca, "Id_doca[1600]/D" );
242 ddg->Branch( "Ip_eangle", Ip_eangle, "Ip_eangle[1600]/D" );
243
244 TTree* entra = new TTree( "entracalib", "entracalib" );
245 entra->Branch( "entra0", entra0, "entra[43]/D" );
246 entra->Branch( "entra1", entra1, "entra[43]/D" );
247 entra->Branch( "entra2", entra2, "entra[43]/D" );
248 entra->Branch( "entra3", entra3, "entra[43]/D" );
249 entra->Branch( "1denangle_entry", entry, "1denangle_entry[1]/I" );
250 entra->Branch( "1denangle", denangle, "1denangle[100]/D" );
251
252 TTree* zdep = new TTree( "zdepcalib", "zdepcalib" );
253 zdep->Branch( "zdep0", zdep0, "zdep[43]/D" );
254 zdep->Branch( "zdep1", zdep1, "zdep[43]/D" );
255 zdep->Branch( "zdep2", zdep2, "zdep[43]/D" );
256 zdep->Branch( "zdep3", zdep3, "zdep[43]/D" );
257
258 TTree* layerg = new TTree( "layergcalib", "layergcalib" );
259 layerg->Branch( "layerg", glayer, "layerg[43]/D" );
260
261
262 gain->Fill();
263 resol->Fill();
264 wireg->Fill();
265 ggs->Fill();
266 ddg->Fill();
267 entra->Fill();
268 zdep->Fill();
269 layerg->Fill();
270
271
272
273
274
275
276
277
278
279
280 fdedx.Write();
281 fdedx.Close();
282 cout << "All const OK!!!" << endl;
283}