/* Gain calibration for elastic proton from H(e,e'p) reaction. known energy deposit in E and/or dE bars. */ { gROOT->Reset(); // = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = // char *file_name; file_name=(char*)malloc(1000); int file_num=2229; //file number sprintf(file_name,"~/E01015/Rootfiles/e01015els_l_%d.root",file_num); TFile *f=new TFile(file_name); TCanvas c; c.Divide(2,1); TCanvas c1; char *center,*c_center,*left,*right,*cut,*d,*var; var=(char*)malloc(1000); // variable name d=(char*)malloc(1000); cut=(char*)malloc(1000); // Cut for ADC left=(char*)malloc(1000); // left side ADC right=(char*)malloc(1000); // right side ADC c_center=(char*)malloc(1000); // cut for position center=(char*)malloc(1000); // position LT-RT int pl; int evtype; cout<<" Enter plane (1 for E plane, 2 for dE plane) "<< endl; cin>>pl; cout<<" Enter event type "<>evtype; Double_t off; if(pl==1) sprintf(var,"BB.src.tp.e"); // variable name if(pl==2) sprintf(var,"BB.src.tp.de"); // variable name int evetype=3; //event type, choose elastic double ped_E_L[24]={0}, ped_E_R[24]={0}; // pedestals values for E plane double ped_dE_L[24]={0}, ped_dE_R[24]={0}; // pedestals values for dE plane double posL[24],posR[24]; TH1 *h=new TH1D("h","h",100,-500,500); TH1 *hl=new TH1D("hl","hl",100,0,2000); TH1 *hr=new TH1D("hr","hr",100,0,2000); TF1 *g=new TF1("g","gaus",10,2000); for(int i=0;i<24;i++) { //===================== Position cut ===============================================// c1.cd(); sprintf(center,"%s.lt[%d]-%s.rt[%d]>>h",var,i,var,i); sprintf(c_center,"%s.lt[%d]>0 && %s.rt[%d]>0 && fEvtHdr.fEvtType==%d",var,i,var,i,evtype); T->Draw(center,c_center); cout<>hl",var,i,ped_E_L[i]); sprintf(right,"%s.ra[%d]-%f>>hr",var,i,ped_E_R[i]); } if(pl==2) { sprintf(left,"%s.la[%d]-%f>>hl",var,i,ped_dE_L[i]); sprintf(right,"%s.ra[%d]-%f>>hr",var,i,ped_dE_R[i]); } sprintf(cut,"%s && TMath::Abs(%s.lt[%d]-%s.rt[%d]-%f)<30",c_center,var,i,var,i,off); // cut for ADCs // gets(d); c.cd(1); T->Draw(left,cut); hl->Fit("g","Q"); posL[i]=g->GetParameter(1); c.cd(2); T->Draw(right,cut); hr->Fit("g","Q"); posR[i]=g->GetParameter(1); posR[i]=g->GetParameter(1); c.Paint(); c.Update(); //gets(d); } }