00001
00002
00003
00004
00005
00006
00007 {
00008 TF1 *gauss1 = new TF1("gauss","gaus");
00009
00010 TFile newf("tof_sigma.root","RECREATE");
00011 TH1F* S_W_delT;
00012 TH1F* S_E_delT;
00013 TH1F* S_counter;
00014 TH1F* S_cluster;
00015 TH1F* S_EC_delT;
00016 TH1F* S_BE;
00017 TH1F* S_delT_z1;
00018 TH1F* S_delT_z2;
00019 TH1F* S_delT_z3;
00020 TH1F* S_delT_z4;
00021 TGraphErrors* delT4;
00022 TH1F* SE_offset_z;
00023 TH1F* SW_offset_z;
00024 TH1F* S_W_delT_Q;
00025 TH1F* S_E_delT_Q;
00026 TH1F* SW_offset_Q;
00027 TH1F* SE_offset_Q;
00028 delT4=new TGraphErrors();
00029 delT4->SetTitle("delT4");
00030 delT4->SetName("delT4");
00031 delT4->SetMarkerColor(4);
00032 delT4->SetMarkerStyle(21);
00033 S_W_delT=new TH1F("S_W_delT","barrel west PMT sigma",176,0.5,176.5);
00034 S_W_delT->GetYaxis()->SetRangeUser(0,0.5);
00035 S_E_delT=new TH1F("S_E_delT","barrel east PMT sigma",176,0.5,176.5);
00036 S_E_delT->GetYaxis()->SetRangeUser(0,0.5);
00037 S_counter=new TH1F("S_counter","barrel counter sigma",176,0.5,176.5);
00038 S_counter->GetYaxis()->SetRangeUser(0,0.5);
00039 S_cluster=new TH1F("S_cluster","barrel cluster sigma",88,0.5,88.5);
00040 S_cluster->GetYaxis()->SetRangeUser(0,0.5);
00041 S_EC_delT=new TH1F("S_EC_delT","endcap sigma",96,0.5,96.5);
00042 S_EC_delT->GetYaxis()->SetRangeUser(0,0.7);
00043 S_BE=new TH1F("S_BE","barrel and endcap sigma",2,0.5,2.5);
00044 S_delT_z1=new TH1F("S_delT_z1","barrel east sigma vs z",240,-120,120);
00045 S_delT_z1->GetYaxis()->SetRangeUser(0,0.5);
00046 S_delT_z2=new TH1F("S_delT_z2","barrel west sigma vs z",240,-120,120);
00047 S_delT_z2->GetYaxis()->SetRangeUser(0,0.5);
00048 S_delT_z3=new TH1F("S_delT_z3","barrel counter sigma vs z",240,-120,120);
00049 S_delT_z3->GetYaxis()->SetRangeUser(0,0.5);
00050 S_delT_z4=new TH1F("S_delT_z4","barrel cluster sigma vs z",240,-120,120);
00051 S_delT_z4->GetYaxis()->SetRangeUser(0,0.5);
00052
00053 SE_offset_z=new TH1F("SE_offset_z","east offset vs z",240,-120,120);
00054 SE_offset_z->GetYaxis()->SetRangeUser(-0.15,0.15);
00055 SW_offset_z=new TH1F("SW_offset_z","west offset vs z",240,-120,120);
00056 SW_offset_z->GetYaxis()->SetRangeUser(-0.15,0.15);
00057
00058 S_W_delT_Q=new TH1F("S_W_delT_Q","wset sigma vs Q",9000,0,9000);
00059 S_W_delT_Q->GetYaxis()->SetRangeUser(0.,0.5);
00060 S_E_delT_Q=new TH1F("S_E_delT_Q","east sigma vs Q",9000,0,9000);
00061 S_E_delT_Q->GetYaxis()->SetRangeUser(0.,0.5);
00062 SW_offset_Q=new TH1F("SW_offset_Q","wset offset vs Q",9000,0,9000);
00063 SW_offset_Q->GetYaxis()->SetRangeUser(-0.15,0.15);
00064 SE_offset_Q=new TH1F("SE_offset_Q","east offset vs Q",9000,0,9000);
00065 SE_offset_Q->GetYaxis()->SetRangeUser(-0.15,0.15);
00066
00067 TFile f("/bes/besd22/jixb/DQA/6.5.0/dqa_hist_9992.root");
00068 TOF->cd();
00069 for( int tofid=0; tofid<176; tofid++ ) {
00070 int binx = W_delT->GetXaxis()->FindBin( tofid );
00071 TH1D* hTmp = W_delT->ProjectionY("",binx,binx);
00072 hTmp->Fit(gauss1,"Q","",-1.5,1.5);
00073 S_W_delT->Fill(tofid+1,gauss1->GetParameter(2));
00074 S_W_delT->SetBinError(tofid+1,gauss1->GetParError(2));
00075 delete hTmp;
00076 }
00077 for( int tofid=0; tofid<176; tofid++ ) {
00078 int binx = E_delT->GetXaxis()->FindBin( tofid );
00079 TH1D* hTmp = E_delT->ProjectionY("",binx,binx);
00080 hTmp->Fit(gauss1,"Q","",-1.5,1.5);
00081 S_E_delT->Fill(tofid+1,gauss1->GetParameter(2));
00082 S_E_delT->SetBinError(tofid+1,gauss1->GetParError(2));
00083 delete hTmp;
00084 }
00085 for( int tofid=0; tofid<176; tofid++ ) {
00086 int binx = counter->GetXaxis()->FindBin( tofid );
00087 TH1D* hTmp = counter->ProjectionY("",binx,binx);
00088 hTmp->Fit(gauss1,"Q","",-1.5,1.5);
00089 S_counter->Fill(tofid+1,gauss1->GetParameter(2));
00090 S_counter->SetBinError(tofid+1,gauss1->GetParError(2));
00091 delete hTmp;
00092 }
00093 for( int tofid=0; tofid<88; tofid++ ) {
00094 int binx = cluster->GetXaxis()->FindBin( tofid );
00095 TH1D* hTmp = cluster->ProjectionY("",binx,binx);
00096 hTmp->Fit(gauss1,"Q","",-1.5,1.5);
00097 S_cluster->Fill(tofid+1,gauss1->GetParameter(2));
00098 S_cluster->SetBinError(tofid+1,gauss1->GetParError(2));
00099 delete hTmp;
00100 }
00101 for( int tofid=0; tofid<96; tofid++ ) {
00102 int binx = EC_delT->GetXaxis()->FindBin( tofid );
00103 TH1D* hTmp = EC_delT->ProjectionY("",binx,binx);
00104 hTmp->Fit(gauss1,"Q","",-1.5,1.5);
00105 S_EC_delT->Fill(tofid+1,gauss1->GetParameter(2));
00106 S_EC_delT->SetBinError(tofid+1,gauss1->GetParError(2));
00107 delete hTmp;
00108 }
00109
00110
00111 Bt_delT->Fit(gauss1,"Q","",-1.5,1.5);
00112 S_BE->Fill(1,gauss1->GetParameter(2));
00113 S_BE->SetBinError(1,gauss1->GetParError(2));
00114 Et_delT->Fit(gauss1,"Q","",-1.5,1.5);
00115 S_BE->Fill(2,gauss1->GetParameter(2));
00116 S_BE->SetBinError(2,gauss1->GetParError(2));
00117
00118
00119 if(h_Bzrhit->GetEntries()!=0){
00120 int xfirst=h_Bzrhit->GetXaxis()->GetFirst();
00121 int xlast=h_Bzrhit->GetXaxis()->GetLast();
00122 int Nentries=h_Bzrhit->GetEntries();
00123 int ibin=Nentries/15;
00124 std::vector<int> Vbin;
00125 Vbin.push_back(xfirst);
00126
00127 int num=1;
00128 int entries=0;
00129 for(int i=xfirst;i<xlast;i++){
00130
00131 entries += h_Bzrhit->GetBinContent(i);
00132
00133 if(entries>=num*ibin){
00134 std::cout<<"zhaohs is:"<<entries<<","<<i<<std::endl;
00135 num++;
00136 Vbin.push_back(i);
00137 }
00138 }
00139 Vbin.push_back(xlast);
00140 int Gr_index=0;
00141 std::cout<<Vbin.size()<<","<<xfirst<<","<<xlast<<std::endl;
00142 for(int i=0;i<Vbin.size()-2;i++){
00143
00144
00145 TH1D* htmp1=delT_z1->ProjectionY("",Vbin[i],Vbin[i+1]);
00146 std::cout<<Vbin[i]<<"---"<<Vbin[i+1]<<std::endl;
00147 htmp1->Fit(gauss1,"Q","",-1.5,1.5);
00148 int QQ=(Vbin[i]+Vbin[i+1])/2;
00149 (double)QQ;
00150
00151 std::cout<<"zzzzz:"<<QQ<<","<<gauss1->GetParameter(2)<<","<<gauss1->GetParError(2)<<std::endl;
00152 S_delT_z1->SetBinContent(QQ,gauss1->GetParameter(2));
00153 S_delT_z1->SetBinError(QQ,gauss1->GetParError(2));
00154 Gr_index++;
00155 delT4->SetPoint(Gr_index,QQ-120,gauss1->GetParameter(2));
00156 delT4->SetPointError(Gr_index,0.0,gauss1->GetParError(2));
00157 SE_offset_z->SetBinContent(QQ,gauss1->GetParameter(1));
00158 SE_offset_z->SetBinError(QQ,gauss1->GetParError(1));
00159
00160
00161 TH1D* htmp2=delT_z2->ProjectionY("",Vbin[i],Vbin[i+1]);
00162 htmp2->Fit(gauss1,"Q","",-1.5,1.5);
00163 S_delT_z2->SetBinContent(QQ,gauss1->GetParameter(2));
00164 S_delT_z2->SetBinError(QQ,gauss1->GetParError(2));
00165 Gr_index++;
00166 delT4->SetPoint(Gr_index ,QQ-120,gauss1->GetParameter(2));
00167 delT4->SetPointError(Gr_index,0.0,gauss1->GetParError(2));
00168 SW_offset_z->SetBinContent(QQ,gauss1->GetParameter(1));
00169 SW_offset_z->SetBinError(QQ,gauss1->GetParError(1));
00170
00171
00172 TH1D* htmp3=delT_z3->ProjectionY("",Vbin[i],Vbin[i+1]);
00173 htmp3->Fit(gauss1,"Q","",-1.5,1.5);
00174 S_delT_z3->SetBinContent(QQ,gauss1->GetParameter(2));
00175 S_delT_z3->SetBinError(QQ,gauss1->GetParError(2));
00176 Gr_index++;
00177 delT4->SetPoint(Gr_index ,QQ-120,gauss1->GetParameter(2));
00178 delT4->SetPointError(Gr_index,0.0,gauss1->GetParError(2));
00179 std::cout<<"QQ1:"<<QQ<<std::endl;
00180
00181 TH1D* htmp4=delT_z4->ProjectionY("",Vbin[i],Vbin[i+1]);
00182 htmp4->Fit(gauss1,"Q","",-1.5,1.5);
00183 S_delT_z4->SetBinContent(QQ,gauss1->GetParameter(2));
00184 S_delT_z4->SetBinError(QQ,gauss1->GetParError(2));
00185 Gr_index++;
00186 delT4->SetPoint(Gr_index ,QQ-120,gauss1->GetParameter(2));
00187 delT4->SetPointError(Gr_index,0.0,gauss1->GetParError(2));
00188
00189 }
00190 }
00191
00192
00193 int Nbin=h_ph->GetEntries();
00194 if(Nbin!=0){
00195 int ibin=Nbin/8;
00196
00197 int entries=0;
00198 int num=1;
00199 std::vector<int> Vbin;
00200 Vbin.push_back(h_ph->GetXaxis()->GetFirst());
00201 for(int xfirst=h_ph->GetXaxis()->GetFirst();xfirst<h_ph->GetXaxis()->GetLast();xfirst++){
00202 entries += h_ph->GetBinContent(xfirst);
00203 if(entries>=ibin*num){
00204 Vbin.push_back(xfirst);
00205
00206 num++;
00207 }
00208
00209 }
00210 Vbin.push_back(h_ph->GetXaxis()->GetLast());
00211 for(int i=0;i<Vbin.size()-1;i++){
00212
00213
00214 TH1D* htmp1=W_delT_Q->ProjectionY("",Vbin[i],Vbin[i+1]);
00215
00216 int nbin=(Vbin[i]+Vbin[i+1])*10/2;
00217 std::cout<<"SW_offset_Q->nbin:"<<nbin<<std::endl;
00218
00219 htmp1->Fit(gauss1,"Q","",-1.5,1.5);
00220 S_W_delT_Q->SetBinContent(nbin,gauss1->GetParameter(2));
00221 S_W_delT_Q->SetBinError(nbin,gauss1->GetParError(2));
00222 SW_offset_Q->SetBinContent(nbin,gauss1->GetParameter(1));
00223 SW_offset_Q->SetBinError(nbin,gauss1->GetParError(1));
00224
00225
00226 TH1D* htmp2=E_delT_Q->ProjectionY("",Vbin[i],Vbin[i+1]);
00227 htmp2->Fit(gauss1,"Q","",-1.5,1.5);
00228 S_E_delT_Q->SetBinContent(nbin,gauss1->GetParameter(2));
00229 S_E_delT_Q->SetBinError(nbin,gauss1->GetParError(2));
00230 SE_offset_Q->SetBinContent(nbin,gauss1->GetParameter(1));
00231 SE_offset_Q->SetBinError(nbin,gauss1->GetParError(1));
00232
00233 }
00234 }
00235 TFile newgr("tof_graph.root","RECREATE");
00236 delT4->Write();
00237 newgr->Write();
00238 newf->Write();
00239 delT4->Draw("A*");
00240 std::cout<<"The Script is ok!"<<std::endl;
00241 }