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