{ /* This script calculate the TDC offsets of BigBite's E and dE planes. The offsets defined in db_BB.tp.dat are L-1/2*(L+R) for left side PMTs and R-1/2*(L+R) for right side PMTs. The event type should be updated under the "evtype" parameter. In addition the resolution of TDC must be defined in parameter "res". The corrected variable in for the analyzer is BB.tp.e.LT (or RT) when: BB.tp.e.LT=(BB.tp.e.lthit_tdc-BB.tp.e.ref_tdc)*res-t_offset */ gROOT->Reset(); TH1 *hEl=new TH1D("hEl","hEl",100,-100,100); TH1 *hEr=new TH1D("hEr","hEr",100,-100,100); TH1 *hdEl=new TH1D("hdEl","hdEl",100,-100,100); TH1 *hdEr=new TH1D("hdEr","hdEr",100,-100,100); TF1 *g=new TF1("g","gaus"); int evtype=3; int res=0.0602; double E_off_L[24]={0}, E_off_R[24]={0}, dE_off_L[24]={0}, dE_off_R[24]={0}; char *cut_E, *cut_dE, *left_E, *left_dE, *right_E, *right_dE, *d; cut_E=(char*)malloc(1000); cut_dE=(char*)malloc(1000); left_E=(char*)malloc(1000); right_E=(char*)malloc(1000); left_dE=(char*)malloc(1000); right_dE=(char*)malloc(1000); d=(char*)malloc(1000); TCanvas c1; c1.Divide(2,1); TCanvas c2; c2.Divide(2,1); for(int j=0;j<24;j++) { sprintf(cut_E,"BB.tp.e.lthit_bar==%d && BB.tp.e.rthit_bar==%d && fEvtHdr.fEvtType==%d",j,j,evtype); sprintf(cut_dE,"BB.tp.de.lthit_bar==%d && BB.tp.de.rthit_bar==%d && fEvtHdr.fEvtType==%d",j,j,evtype); sprintf(left_E,"BB.tp.e.lthit_tdc-0.5*(BB.tp.e.lthit_tdc+BB.tp.e.rthit_tdc)>>hEl"); sprintf(right_E,"BB.tp.e.rthit_tdc-0.5*(BB.tp.e.lthit_tdc+BB.tp.e.rthit_tdc)>>hEr"); sprintf(left_dE,"BB.tp.de.lthit_tdc-0.5*(BB.tp.de.lthit_tdc+BB.tp.de.rthit_tdc)>>hdEl"); sprintf(right_dE,"BB.tp.de.rthit_tdc-0.5*(BB.tp.de.lthit_tdc+BB.tp.de.rthit_tdc)>>hdEr"); //============================== E plane ================================================ c1.cd(1); T->Draw(left_E,cut_E); hEl->Fit("g"); // E_off_L[j]=g->GetParameter(1); E_off_L[j]=hEl->GetMean(); c1.cd(2); T->Draw(right_E,cut_E); hEr->Fit("g"); // E_off_R[j]=g->GetParameter(1); E_off_R[j]=hEr->GetMean(); //=============================== dE plane =============================================== c2.cd(1); T->Draw(left_dE,cut_dE); hdEl->Fit("g"); // dE_off_L[j]=g->GetParameter(1); dE_off_L[j]=hdEl->GetMean(); c2.cd(2); T->Draw(right_dE,cut_dE); hdEr->Fit("g"); // dE_off_R[j]=g->GetParameter(1); dE_off_R[j]=hdEr->GetMean(); c1.Paint(); c1.Update(); c2.Paint(); c2.Update(); gets(d); } //for //====================== Output Files ======================================================= ofstream E_left,dE_left,E_right,dE_right; E_left.open("left_E_tdc_off.dat"); dE_left.open("left_dE_tdc_off.dat"); E_right.open("right_E_tdc_off.dat"); dE_right.open("right_dE_tdc_off.dat"); for(int k=0;k<24;k++) { E_left<