25int main(
int argc,
char* argv[]){
35 char* runNo_temp=argv[3];
36 runNo=atoi(runNo_temp);
40 std::cout<<
"-----------------------------------"<<
runNo<<
"-------------------------"<<std::endl;
61 f.GetObject(
"/zhsLUM/lum",lum);
62 LumValue=lum->GetBinContent(3);
67 sprintf(sql_input,
"select IntLumEndcapEE from OnlineLum where run_number='%d'",
runNo);
69 std::string intLumEndcapEE;
73 else intLumEndcapEE=
"-0";
81 sprintf(sql_input,
"insert into OfflineLum(SerNo,RunNo,IntLumEndcapEE,OfflineTwoGam,SftVer,ParVer,Creator,CreateTime,Notes) values(0,'%d','%s','%f','%s','%s','%s',now(),'%s')",
runNo,intLumEndcapEE.c_str(),LumValue,
SftVer,
ParVer,
Creator,Notes);
88 TH1D* x_of_vertex_in_kal;
89 TH1D* y_of_vertex_in_kal;
90 TH1D* z_of_vertex_in_kal;
91 f.GetObject(
"/zhsVER/x_of_vertex_in_kal",x_of_vertex_in_kal);
92 f.GetObject(
"/zhsVER/y_of_vertex_in_kal",y_of_vertex_in_kal);
93 f.GetObject(
"/zhsVER/z_of_vertex_in_kal",z_of_vertex_in_kal);
97 if(runNo<=10878 || runNo>20433){
98 func =
new TF1(
"func",
"gaus", -0.6, 0.6);
99 funcY =
new TF1(
"funcY",
"gaus", -0.6, 0.2);
100 funcZ =
new TF1(
"funcZ",
"gaus", -6, 6);
103 func =
new TF1(
"func",
"gaus", 0., 1.8);
104 funcY =
new TF1(
"funcY",
"gaus", -1., 1.);
105 funcZ =
new TF1(
"funcZ",
"gaus", -6, 6);
107 x_of_vertex_in_kal->Fit(
"func",
"RQ");
108 Double_t MeanXKal = func->GetParameter(1);
109 Double_t SigmaXKal = func->GetParameter(2);
111 y_of_vertex_in_kal->Fit(
"funcY",
"RQ");
112 Double_t MeanYKal = funcY->GetParameter(1);
113 Double_t SigmaYKal = funcY->GetParameter(2);
115 z_of_vertex_in_kal->Fit(
"funcZ",
"RQ");
116 Double_t MeanZKal = funcZ->GetParameter(1);
117 Double_t SigmaZKal = funcZ->GetParameter(2);
118 if(runNo<=10878 || runNo>20433){
119 if(MeanXKal<-0.05 || MeanXKal>0.25 || SigmaXKal>0.12 || SigmaXKal<0.){
120 std::cout<<
"--------------x_of_vertex_in_kal-------out of range--runID is:"<<
runNo<<std::endl;
123 if(MeanYKal<-0.4 || MeanYKal>0 || SigmaYKal>0.12 || SigmaYKal<0)
125 std::cout<<
"--------------y_of_vertex_in_kal-------out of range--runID is:"<<
runNo<<std::endl;
128 if(MeanZKal<-1 || MeanZKal>1.0 || SigmaZKal>1.5 || SigmaZKal<0)
130 std::cout<<
"--------------z_of_vertex_in_kal-------out of range--runID is:"<<
runNo<<std::endl;
135 if(MeanXKal<0.6 || MeanXKal>1.2 || SigmaXKal>0.18 || SigmaXKal<0.){
136 std::cout<<
"--------------x_of_vertex_in_kal-------out of range--runID is:"<<
runNo<<std::endl;
139 if(MeanYKal<-0.4 || MeanYKal>0 || SigmaYKal>0.12 || SigmaYKal<0.)
141 std::cout<<
"--------------y_of_vertex_in_kal-------out of range--runID is:"<<
runNo<<std::endl;
144 if(MeanZKal<-0.8 || MeanZKal>0.8 || SigmaZKal>1.5 || SigmaZKal<0.)
146 std::cout<<
"--------------z_of_vertex_in_kal-------out of range--runID is:"<<
runNo<<std::endl;
151 char VerFitFunc[] =
"Kalman";
152 char DistFitFunc[] =
"single Gaussian";
154 double AcSigmaVx, AcSigmaVy;
158 char query[1024*100];
162 sprintf(query,
"INSERT INTO BeamPar(BeamParSerNo,RunNo,Vx,Vy,Vz,SigmaVx,SigmaVy,SigmaVz,VerFitFunc,DistFitFunc,SftVer,Creator,AcSigmaVx,AcSigmaVy,ParVer) values(0,'%d','%f','%f','%f','%f','%f','%f','%s','%s','%s','%s','%f','%f','%s')",
runNo,MeanXKal,MeanYKal,MeanZKal,SigmaXKal,SigmaYKal,SigmaZKal,VerFitFunc,DistFitFunc,
SftVer,
Creator,AcSigmaVx,AcSigmaVy,
ParVer);
169 char query[1024*100];
179 sprintf(query,
"select Vx,Vy,Vz,SigmaVx,SigmaVy,SigmaVz,RunNo,SftVer,ParVer from BeamPar where RunNo='%d' && SftVer='%s' && ParVer='%s'",
runNo-irun,
SftVer,
ParVer);
194 sprintf(query,
"update BeamPar set Vx='%s',SigmaVx='%s' where RunNo='%d' && SftVer='%s' && ParVer='%s'",Vx.c_str(),SigmaVx.c_str(),
runNo,
SftVer,
ParVer);
197 std::cout<<
"------------------update Vx,SigmaVx successful!--------"<<std::endl;
200 sprintf(query,
"update BeamPar set Vy='%s',SigmaVy='%s' where RunNo='%d' && SftVer='%s' && ParVer='%s'",Vy.c_str(),SigmaVy.c_str(),
runNo,
SftVer,
ParVer);
203 std::cout<<
"------------------update Vy,SigmaVy successful!---------"<<std::endl;
206 sprintf(query,
"update BeamPar set Vz='%s',SigmaVz='%s' where RunNo='%d' && SftVer='%s' && ParVer='%s'",Vz.c_str(),SigmaVz.c_str(),
runNo,
SftVer,
ParVer);
209 std::cout<<
"------------------update Vz,SigmaVz successful!---------"<<std::endl;
216 std::cout<<
"--------------check RUN LUM and Vertex info -----------------------------------"<<std::endl;
218 sprintf(sql_input,
"select SerNo,RunNo,IntLumEndcapEE,OfflineTwoGam,SftVer,ParVer,Creator,CreateTime,Notes from OfflineLum where RunNo=%d && SftVer='%s' && ParVer='%s'",
runNo,
SftVer,
ParVer);
220 std::cout<<
"LUM is:"<<
"SerNo,RunNo,IntLumEndcapEE,OfflineTwoGam,SftVer,ParVer,Creator,CreateTime,Notes"<<std::endl;
225 std::cout<<
"---------------------------------------------------------------LUM is OK!"<<std::endl;
227 else std::cout<<
"-----------------------------------------ERROR to read LUM from OfflineLum db"<<std::endl;
229 sprintf(sql_input,
"select BeamParSerNo,RunNo,Vx,Vy,Vz,SigmaVx,SigmaVy,SigmaVz,VerFitFunc,DistFitFunc,SftVer,Creator,AcSigmaVx,AcSigmaVy,ParVer FROM BeamPar where RunNo ='%d' && SftVer='%s' && ParVer='%s'",
runNo,
SftVer,
ParVer);
231 std::cout<<
"BeamPar is:"<<
"BeamParSerNo,RunNo,Vx,Vy,Vz,SigmaVx,SigmaVy,SigmaVz,VerFitFunc,DistFitFunc,SftVer,Creator,AcSigmaVx,AcSigmaVy,ParVer"<<std::endl;
237 std::cout<<
"-------------------------------------------------------BeamPar is OK!"<<std::endl;
239 else std::cout<<
"-----------------------------------------ERROR to read Vertex from BeamPar db"<<std::endl;
248 cout<<
"************************************"<<endl;
250 cout<<
"************************************"<<endl;
253 if(!file_open)
return -1;
257 double Lum_start = -1;
259 double Tau_Value = -1;
262 rwite>>m_runNo>>runTime>>Lum_start>>Lum_end>>Tau_Value;
266 sprintf(sql_input,
"update OfflineLum set runTime=%f, Lum_start=%f, Lum_end=%f, Tau_Value=%f where runNo=%d && SftVer='%s' && ParVer='%s' ",runTime,Lum_start,Lum_end,Tau_Value,m_runNo,
SftVer,
ParVer);
269 cout<<
"************************************"<<endl;
270 cout<<
"LumTau FOR RUN "<<m_runNo<<
" is OK!"<<endl;
271 cout<<
"************************************"<<endl;
bool GetRow(my_ulonglong row=NEXT_ROW)
void Init(string host, string user, string passwd, string db="")
bool Execute(string query="")
string GetField(unsigned int n)
sprintf(cut,"kal_costheta0_em>-0.93&&kal_costheta0_em<0.93&&kal_pxy0_em>=0.05+%d*0.1&&kal_pxy0_em<0.15+%d*0.1&&NGch>=2", j, j)
TFile f("ana_bhabha660a_dqa_mcPat_zy_old.root")