00001 #include <iostream>
00002 #include "TFile.h"
00003 #include "TTree.h"
00004 #include <TROOT.h>
00005
00006 using namespace std;
00007
00008 void DedxCalibConst()
00009 {
00010 Int_t runno;
00011 Double_t runmean, rungain, runresol;
00012
00013 TFile fdedx("DedxConst_before.root","recreate");
00014
00015 TTree* runbyrun = new TTree("runcalib", "runcalib");
00016 runbyrun -> Branch("runno", &runno, "runno/I");
00017 runbyrun -> Branch("runmean", &runmean, "runmean/D");
00018 runbyrun -> Branch("rungain", &rungain, "rungain/D");
00019 runbyrun -> Branch("runresol", &runresol, "runresol/D");
00020
00021 TFile fconst0("rungain.root");
00022 TTree *tree_rung = (TTree*)fconst0.Get("runcalib");
00023 tree_rung -> SetBranchAddress("rungain", &rungain);
00024 tree_rung -> SetBranchAddress("runmean", &runmean);
00025 tree_rung -> SetBranchAddress("runno", &runno);
00026 tree_rung -> SetBranchAddress("runresol", &runresol);
00027
00028 long NRUN = tree_rung -> GetEntries();
00029 cout<<"Run Number == "<<NRUN<<endl;
00030 for(long runid =0; runid<NRUN; runid++)
00031 {
00032 tree_rung->GetEntry(runid);
00033 if(runno<12739) runbyrun ->Fill();
00034 }
00035
00036 TTree *tree_resg = (TTree*)fconst0.Get("resolcalib");
00037 Double_t resolpar[1];
00038 tree_resg -> SetBranchAddress("resol", resolpar);
00039 tree_resg -> GetEntry(0);
00040
00041 TTree *tree_gaing = (TTree*)fconst0.Get("gaincalib");
00042 Double_t gainpar[1];
00043 tree_gaing -> SetBranchAddress("gain", gainpar);
00044 tree_gaing -> GetEntry(0);
00045
00046 fconst0.Close();
00047 cout<<"runbyrun const OK!!!"<<endl;
00048
00049
00050 TFile fconst1("/ihepbatch/besd26/anff/662/Calib/const_file/WireGain/wiregain_before_new.root");
00051
00052
00053
00054 Double_t gwire[6796];
00055 TTree *tree_wireg = (TTree*)fconst1.Get("wiregcalib");
00056 tree_wireg -> SetBranchAddress("wireg", gwire);
00057 tree_wireg -> GetEntry(0);
00058 fconst1.Close();
00059 cout<<"wiregcalib const OK!!!"<<endl;
00060
00061
00062 TFile fconst2("../Eangle1D/DedxConst_test.root");
00063 Double_t ggs0[43], ggs1[43], ggs2[43], ggs3[43];
00064 TTree *tree_ggs = (TTree*)fconst2.Get("ggscalib");
00065 tree_ggs -> SetBranchAddress("ggs0", ggs0);
00066 tree_ggs -> SetBranchAddress("ggs1", ggs1);
00067 tree_ggs -> SetBranchAddress("ggs2", ggs2);
00068 tree_ggs -> SetBranchAddress("ggs3", ggs3);
00069 tree_ggs->GetEntry(0);
00070 fconst2.Close();
00071 cout<<"ggscalib const OK!!!"<<endl;
00072
00073
00074 TFile fconst3("../Eangle1D/DedxConst_test.root");
00075 Double_t ddg0[43], ddg1[43], ddg2[43], ddg3[43];
00076 TTree *tree_ddg = (TTree*)fconst3.Get("ddgcalib");
00077 tree_ddg -> SetBranchAddress("ddg0", ddg0);
00078 tree_ddg -> SetBranchAddress("ddg1", ddg1);
00079 tree_ddg -> SetBranchAddress("ddg2", ddg2);
00080 tree_ddg -> SetBranchAddress("ddg3", ddg3);
00081 tree_ddg -> GetEntry(0);
00082 fconst3.Close();
00083 cout<<"ddgcalib const OK!!!"<<endl;
00084
00085
00086 TFile fconst4("../Eangle1D/DedxConst_test.root");
00087 Double_t entra0[43], entra1[43], entra2[43], entra3[43];
00088 TTree *tree_entra = (TTree*)fconst4.Get("entracalib");
00089 tree_entra -> SetBranchAddress("entra0", entra0);
00090 tree_entra -> SetBranchAddress("entra1", entra1);
00091 tree_entra -> SetBranchAddress("entra2", entra2);
00092 tree_entra -> SetBranchAddress("entra3", entra3);
00093
00094
00095
00096
00097 tree_entra->GetEntry(0);
00098 fconst4.Close();
00099
00100 TFile fconst4_1("/ihepbatch/besd26/anff/662/Calib/draw/calib/eangle/EAngle.root");
00101
00102 int entry[1]; double denangle[100];
00103 TTree *tree_entra1 = (TTree*)fconst4_1.Get("entracalib");
00104 tree_entra1 -> SetBranchAddress("1denangle_entry", entry);
00105 tree_entra1 -> SetBranchAddress("1denangle", denangle);
00106 tree_entra1 ->GetEntry(0);
00107 fconst4_1.Close();
00108 cout<<"entrance angle const OK!!!"<<endl;
00109
00110
00111 TFile fconst5("../Eangle1D/DedxConst_test.root");
00112 Double_t zdep0[43], zdep1[43], zdep2[43], zdep3[43];
00113 TTree *tree_zdep = (TTree*)fconst5.Get("zdepcalib");
00114 tree_zdep -> SetBranchAddress("zdep0", zdep0);
00115 tree_zdep -> SetBranchAddress("zdep1", zdep1);
00116 tree_zdep -> SetBranchAddress("zdep2", zdep2);
00117 tree_zdep -> SetBranchAddress("zdep3", zdep3);
00118 tree_zdep->GetEntry(0);
00119 fconst5.Close();
00120 cout<<"zdepcalib const OK!!!"<<endl;
00121
00122
00123 TFile fconst6("../Eangle1D/DedxConst_test.root");
00124 Double_t glayer[43];
00125 TTree *tree_layerg = (TTree*)fconst6.Get("layergcalib");
00126 tree_layerg -> SetBranchAddress("layerg", glayer);
00127 tree_layerg->GetEntry(0);
00128 fconst6.Close();
00129 cout<<"layergcalib const OK!!!"<<endl;
00130
00131
00132
00133
00134 TFile fconst7("/ihepbatch/besd26/anff/662/Calib/const_file/Costheta/costheta_new.root");
00135 TTree *tree_costheta = (TTree*)fconst7.Get("costhetacalib");
00136 double gcostheta[80];
00137 tree_costheta ->SetBranchAddress("costheta",gcostheta);
00138 tree_costheta->GetEntry(0);
00139 fconst7.Close();
00140 cout<<"costhetacalib const OK!!!"<<endl;
00141
00142
00143 TFile fconst8("/afs/ihep.ac.cn/bes3/offline/CalibConst/dedx/6.5.3/Jpsi/t0calib.root");
00144
00145 TTree *tree_t0=(TTree*)fconst8.Get("t0calib");
00146 double t0, dedx;
00147 double gt0[35];
00148 double gdedx[35];
00149 tree_t0->SetBranchAddress("t0",&t0);
00150 tree_t0->SetBranchAddress("dedx",&dedx);
00151 for(int i=0; i<tree_t0->GetEntries(); i++)
00152 {
00153 tree_t0->GetEntry(i);
00154 gt0[i] = t0;
00155 gdedx[i] = dedx;
00156 }
00157 fconst8.Close();
00158 cout<<"t0calib const OK!!!"<<endl;
00159
00160
00161
00162 TFile fconst9("/ihepbatch/besd26/anff/662/Calib/const_file/DocaEAngle/docaeangle_new.root");
00163 const int n = 1600;
00164 double Iner_gain[n], Iner_chi[n], Iner_hits[n];
00165 double Out_gain[n], Out_chi[n], Out_hits[n];
00166 double Id_doca[n], Ip_eangle[n];
00167
00168 TTree *tree_docasin = (TTree*)fconst9.Get("ddgcalib");
00169 tree_docasin -> SetBranchAddress("Iner_gain", Iner_gain);
00170 tree_docasin -> SetBranchAddress("Iner_chi", Iner_chi);
00171 tree_docasin -> SetBranchAddress("Iner_hits", Iner_hits);
00172 tree_docasin -> SetBranchAddress("Out_gain", Out_gain);
00173 tree_docasin -> SetBranchAddress("Out_chi", Out_chi);
00174 tree_docasin -> SetBranchAddress("Out_hits", Out_hits);
00175 tree_docasin -> SetBranchAddress("Id_doca", Id_doca);
00176 tree_docasin -> SetBranchAddress("Ip_eangle", Ip_eangle);
00177 tree_docasin -> GetEntry(0);
00178 fconst9.Close();
00179
00180 cout<<"ddgcalib const OK!!!"<<endl;
00181
00182 TFile fconst10("/panfs/panfs.ihep.ac.cn/home/data/anff/dEdxCal/662_cal/Hadron/constfile/Hadron_11414-14604.root");
00183
00184
00185 int hadronNo;
00186 double ghadron[5];
00187 TTree *tree_hadron = (TTree*)fconst10.Get("ggscalib");
00188 tree_hadron -> SetBranchAddress("hadron", ghadron);
00189 tree_hadron -> SetBranchAddress("hadronNo",&hadronNo);
00190 tree_hadron->GetEntry(0);
00191 fconst10.Close();
00192 cout<<"hadron const OK!!!"<<endl;
00193
00194
00195 fdedx.cd();
00196 TTree* gain = new TTree("gaincalib", "gaincalib");
00197 gain -> Branch("gain", gainpar, "gain[1]/D");
00198 gain -> Branch("t0", gt0, "t0[35]/D");
00199 gain -> Branch("dedx", gdedx, "dedx[35]/D");
00200
00201 TTree* resol = new TTree("resolcalib", "resolcalib");
00202 resol -> Branch("resol", resolpar, "resol[1]/D");
00203
00204 TTree* wireg = new TTree("wiregcalib", "wiregcalib");
00205 wireg -> Branch("wireg", gwire, "wireg[6796]/D");
00206 wireg-> SetBasketSize("wireg",2000000);
00207
00208 TTree* ggs = new TTree("ggscalib", "ggscalib");
00209 ggs -> Branch("ggs0", ggs0, "ggs[43]/D");
00210 ggs -> Branch("ggs1", ggs1, "ggs[43]/D");
00211 ggs -> Branch("ggs2", ggs2, "ggs[43]/D");
00212 ggs -> Branch("ggs3", ggs3, "ggs[43]/D");
00213 ggs -> Branch("costheta", gcostheta, "costheta[80]/D");
00214 ggs -> Branch("hadron",ghadron,"hadron[5]/D");
00215 ggs -> Branch("hadronNo",&hadronNo,"hadronNo/I");
00216
00217 TTree* ddg = new TTree("ddgcalib", "ddgcalib");
00218 ddg -> Branch("ddg0", ddg0, "ddg[43]/D");
00219 ddg -> Branch("ddg1", ddg1, "ddg[43]/D");
00220 ddg -> Branch("ddg2", ddg2, "ddg[43]/D");
00221 ddg -> Branch("ddg3", ddg3, "ddg[43]/D");
00222 ddg -> Branch("Iner_gain", Iner_gain, "Iner_gain[1600]/D");
00223 ddg -> Branch("Out_gain", Out_gain, "Out_gain[1600]/D");
00224 ddg -> Branch("Iner_chi", Iner_chi, "Iner_chi[1600]/D");
00225 ddg -> Branch("Out_chi", Out_chi, "Out_chi[1600]/D");
00226 ddg -> Branch("Iner_hits", Iner_hits, "Iner_hits[1600]/D");
00227 ddg -> Branch("Out_hits", Out_hits, "Out_hits[1600]/D");
00228 ddg -> Branch("Id_doca", Id_doca, "Id_doca[1600]/D");
00229 ddg -> Branch("Ip_eangle", Ip_eangle, "Ip_eangle[1600]/D");
00230
00231 TTree* entra = new TTree("entracalib", "entracalib");
00232 entra -> Branch("entra0", entra0, "entra[43]/D");
00233 entra -> Branch("entra1", entra1, "entra[43]/D");
00234 entra -> Branch("entra2", entra2, "entra[43]/D");
00235 entra -> Branch("entra3", entra3, "entra[43]/D");
00236 entra -> Branch("1denangle_entry", entry, "1denangle_entry[1]/I");
00237 entra -> Branch("1denangle", denangle, "1denangle[100]/D");
00238
00239 TTree* zdep = new TTree("zdepcalib", "zdepcalib");
00240 zdep -> Branch("zdep0", zdep0, "zdep[43]/D");
00241 zdep -> Branch("zdep1", zdep1, "zdep[43]/D");
00242 zdep -> Branch("zdep2", zdep2, "zdep[43]/D");
00243 zdep -> Branch("zdep3", zdep3, "zdep[43]/D");
00244
00245 TTree* layerg = new TTree("layergcalib", "layergcalib");
00246 layerg -> Branch("layerg", glayer, "layerg[43]/D");
00247
00248
00249 gain->Fill();
00250 resol->Fill();
00251 wireg -> Fill();
00252 ggs -> Fill();
00253 ddg -> Fill();
00254 entra -> Fill();
00255 zdep -> Fill();
00256 layerg -> Fill();
00258
00259
00260
00261
00262
00263
00264
00265
00266
00267 fdedx.Write();
00268 fdedx.Close();
00269 cout<<"All const OK!!!"<<endl;
00270 }