/* //========================================================================== This script calculate the position offset for BigBite dE and E planes scintillators. The output is writen to file: BB_pos_shifts.dat Pay attention that the position offset in the data base file is defined from the starting edge of the fit and not from the center this is due to the hand libraries for the analyzer //========================================================================== */ Double_t fitfun(Double_t *x, Double_t *par) { if ((x[0]>par[0]) && (x[0]SetOptFit(1); TCanvas c1; Float_t Shifts[32], Scales[32],m; int channels; char *dummy,*dummy1,*str,*var; dummy=(char *)malloc(1000); dummy1=(char *)malloc(1000); str=(char *)malloc(1000); var=(char*)malloc(1000); TH1F H("H","H",100,-200,200); TH1F h("h","h",100,-200,200); TF1 *func = new TF1("fit",fitfun,-100,100,3); func->SetParNames("Start","Width","Height"); int pl,evtype; cout<<" Choose plane E = 1, dE = 2 "<>pl; cout<<" ENTER EVENTTYPE (singels) "<>evtype; if(pl==1) { channels=24; sprintf(var,"BB.tp.e."); } if(pl==2) { channels=24; sprintf(var,"BB.tp.de."); } for (Int_t i=0;i>h",var,var); sprintf(dummy1,"%slthit_bar==%d && %srthit_bar==%d && fEvtHdr.fEvtType==%d",var,i,var,i,evtype); T->Draw(dummy,dummy1); func->SetParameters(h->GetMean()-1.5*h->GetRMS(),h->GetRMS()*3,h->GetMaximum()/2.); h->Fit("fit"); Scales[i]=func->GetParameter(1); Shifts[i]=-(func->GetParameter(0)+Scales[i]/2.); c1.Paint(); c1.Update(); printf("%i\n",i); gets(dummy); } ofstream file; file.open("BB_pos_shifts.dat"); for (i=0;i