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