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