void Hist::SetResidualValue(Double_t x[], Int_t Layer) { if(Layer == 1) { Resdx_0 = x[0]; Resdx_1 = x[1]; Resdx_2 = x[2]; Resdx_3 = x[3]; Resdx_4 = x[4]; Resdx_5 = x[5]; Resdx_6 = x[6]; Resdx_7 = x[7]; Resdx_8 = x[8]; Resdx_9 = x[9]; Resdx_10 = x[10]; Resdx_11 = x[11]; } else { Resdy_0 = x[0]; Resdy_1 = x[1]; Resdy_2 = x[2]; Resdy_3 = x[3]; Resdy_4 = x[4]; Resdy_5 = x[5]; Resdy_6 = x[6]; Resdy_7 = x[7]; Resdy_8 = x[8]; Resdy_9 = x[9]; Resdy_10 = x[10]; Resdy_11 = x[11]; }} Double_t Hist::ComputeResidue(TGraphErrors* g, Double_t LayerNo, Double_t StripNo) { fpoint = g->GetN(); residual = -9994.0; layerno = 0; stripno = 0; X_max = TMath::MaxElement(g->GetN(),g->GetX()); X_min = TMath::MinElement(g->GetN(),g->GetX()); f1 = new TF1("f1",Linear_regression,X_min,X_max,2); f1->SetParameters(2,1); f1->SetParNames("cut-off","slope"); if(g->Fit("f1","NQO")==0) { if(f1->GetChisquare()/f1->GetNDF() > 10) { for (int i=0; i < g->GetN();i++) { g->GetPoint(i,layerno,stripno); if(fabs(stripno - (f1->GetParameter(0)+f1->GetParameter(1)*layerno))>(MAXSHIFT-1)) { g->RemovePoint(i); i--; fpoint--; }} g->Set(fpoint); if(fpoint < 4) { residual = -9999.; } else { if(g->Fit("f1","NQO")==0) // Second Fitting is successful { residual = StripNo-(LayerNo*f1->GetParameter(1) + f1->GetParameter(0)); }}} else { residual = StripNo-(LayerNo*f1->GetParameter(1) + f1->GetParameter(0)); }} else { residual = -9999.; } return residual; } void Hist::FitData(TGraphErrors *g,FITPARAM1& f, int mult[12], Int_t Layer) { for (mm =0; mm < 12; mm++) { gfit[mm]->Set(0); Resd[mm] = -9999.; fpt[mm] = 0; } layer=0; for(mm=0;mm0 && mult[mm]<=MAXMULT) { pt= TMath::BinarySearch(g->GetN(),g->GetX(),(double)mm); for(kk=0;kkGetPoint(pt+kk,layer,strip[kk]); if(layer!=mm) { break; } } if(layer==mm) { for(kk=0;kkMAXSHIFT) { goodlayer[mm]=false; break; } else goodlayer[mm]=true; } if(goodlayer[mm]) { Y[mm] = TMath::Mean(mult[mm],strip); if(mm!=0) { gfit[0]->SetPoint(fpt[0],layer,TMath::Mean(mult[mm],strip)); gfit[0]->SetPointError(fpt[0],SIGMALAYER,SIGMASTRIP); fpt[0]++; } if(mm!=1) { gfit[1]->SetPoint(fpt[1],layer,TMath::Mean(mult[mm],strip)); gfit[1]->SetPointError(fpt[1],SIGMALAYER,SIGMASTRIP); fpt[1]++; } if(mm!=2) { gfit[2]->SetPoint(fpt[2],layer,TMath::Mean(mult[mm],strip)); gfit[2]->SetPointError(fpt[2],SIGMALAYER,SIGMASTRIP); fpt[2]++; } if(mm!=3) { gfit[3]->SetPoint(fpt[3],layer,TMath::Mean(mult[mm],strip)); gfit[3]->SetPointError(fpt[3],SIGMALAYER,SIGMASTRIP); fpt[3]++; } if(mm!=4) { gfit[4]->SetPoint(fpt[4],layer,TMath::Mean(mult[mm],strip)); gfit[4]->SetPointError(fpt[4],SIGMALAYER,SIGMASTRIP); fpt[4]++; } if(mm!=5) { gfit[5]->SetPoint(fpt[5],layer,TMath::Mean(mult[mm],strip)); gfit[5]->SetPointError(fpt[5],SIGMALAYER,SIGMASTRIP); fpt[5]++; } if(mm!=6) { gfit[6]->SetPoint(fpt[6],layer,TMath::Mean(mult[mm],strip)); gfit[6]->SetPointError(fpt[6],SIGMALAYER,SIGMASTRIP); fpt[6]++; } if(mm!=7) { gfit[7]->SetPoint(fpt[7],layer,TMath::Mean(mult[mm],strip)); gfit[7]->SetPointError(fpt[7],SIGMALAYER,SIGMASTRIP); fpt[7]++; } if(mm!=8) { gfit[8]->SetPoint(fpt[8],layer,TMath::Mean(mult[mm],strip)); gfit[8]->SetPointError(fpt[8],SIGMALAYER,SIGMASTRIP); fpt[8]++; } if(mm!=9) { gfit[9]->SetPoint(fpt[9],layer,TMath::Mean(mult[mm],strip)); gfit[9]->SetPointError(fpt[9],SIGMALAYER,SIGMASTRIP); fpt[9]++; } if(mm!=10) { gfit[10]->SetPoint(fpt[10],layer,TMath::Mean(mult[mm],strip)); gfit[10]->SetPointError(fpt[10],SIGMALAYER,SIGMASTRIP); fpt[10]++; } if(mm!=11) { gfit[11]->SetPoint(fpt[11],layer,TMath::Mean(mult[mm],strip)); gfit[11]->SetPointError(fpt[11],SIGMALAYER,SIGMASTRIP); fpt[11]++; }}}}} for (mm = 0; mm < 12; mm++) { gfit[mm]->Set(fpt[mm]); if(fpt[mm] < 4){ Resd[mm] = -9999.; } else { Resd[mm] = ComputeResidue(gfit[mm], X[mm], Y[mm]); } } SetResidualValue(Resd, Layer); }