diff --git a/macros/CCEScan/pulseFit.C b/macros/CCEScan/pulseFit.C index 6cb421e..f10bf61 100755 --- a/macros/CCEScan/pulseFit.C +++ b/macros/CCEScan/pulseFit.C @@ -288,9 +288,10 @@ //Evaluation of the systematic error on the integral of the pulse shape using a polinomial //Define the interval were most likely the zeros should be + //TO DO: Set min and max from the time vector double low_limit = -50; double high_limit = 50; - + //HERE //POLY3 cout << "================ poly3 ====================" << endl<Fit("poly3","M"); Info("pulseFit","#chi^{2}/ndf: %6.2f/%d",poly3->GetChisquare(),poly3->GetNDF()); - double x1_poly3 = poly3->GetX(0,low_limit,0); //GetX will return x* such that f(x*)=0 only if this exists, will (probably) return the argmin(f(x)) in the interval otherwis - double x2_poly3 = poly3->GetX(0,0, high_limit); - double z1_poly3 = -99; - double z2_poly3 = -99; - bool b_poly3 = false; - double integral_poly3_val = -999; - double integral_poly3_err = 0; + std::vector v_max_p3; + std::vector v_time_srtd; + bool b_max_p3 = true; - if( TMath::Abs(poly3->Eval(x1_poly3)) > 1e-08){cout <<"No zeros on the left, the lower point is y1: "<Eval(x1_poly3)<Eval(x1_poly3)<Eval(x2_poly3)) > 1e-08){cout <<"No zero found, the lower point is y2: "<Eval(x2_poly3)<Eval(x2_poly3)<GetMaximum(v_time_srtd[i], v_time_srtd[i+1]); + + //Checks on the maximum -> do not accept maxima at the boundary + if( (max_tmp <= poly3->Eval(v_time_srtd[i])) || (max_tmp <= poly3->Eval(v_time_srtd[i+1])) ){ + continue; + }else{ + v_max_p3.push_back(max_tmp); } - } - - - //This has to be done before any other fit is performed - if(b_poly3 == true){ - - cout << "Poly3 behaves properly in the range ["<Integral(z1_poly3,z2_poly3)/20.; - integral_poly3_err = poly3->IntegralError(z1_poly3,z2_poly3)/20.; - cout << "The integral between the two zeros is "<< integral_poly3_val <<"+/-"<Fit("poly4","M0Q","0"); Info("pulseFit","#chi^{2}/ndf: %6.2f/%d",poly4->GetChisquare(),poly4->GetNDF()); - - double x1_poly4 = poly4->GetX(0,low_limit,0); - double x2_poly4 = poly4->GetX(0,0, high_limit); - double z1_poly4 = -99; - double z2_poly4 = -99; - bool b_poly4 = false; - double integral_poly4_val = -999; - double integral_poly4_err = 0; - - - if( TMath::Abs(poly4->Eval(x1_poly4)) > 1e-08){cout <<"No zeros on the left, the lower point is y1: "<Eval(x1_poly4)<Eval(x1_poly4)<Eval(x2_poly4)) > 1e-08){cout <<"No zero found, the lower point is y2: "<Eval(x2_poly4)<Eval(x2_poly4)<Integral(z1_poly4,z2_poly4)/20.; - integral_poly4_err = poly4->IntegralError(z1_poly4,z2_poly4)/20.; - cout << "The integral between the two zeros is "<< integral_poly4_val <<"+/-"<GetMaximum(low_limit, high_limit); //POLY5 @@ -388,39 +360,8 @@ ge_pulse->Fit("poly5","M"); Info("pulseFit","#chi^{2}/ndf: %6.2f/%d",poly5->GetChisquare(),poly5->GetNDF()); - - - double x1_poly5 = poly5->GetX(0,low_limit,0); - double x2_poly5 = poly5->GetX(0,0, high_limit); - double z1_poly5 = -99; - double z2_poly5 = -99; - bool b_poly5 = false; - double integral_poly5_val = -999; - double integral_poly5_err = 0; - - if( TMath::Abs(poly5->Eval(x1_poly5)) > 1e-08){cout <<"No zeros on the left, the lower point is y1: "<Eval(x1_poly5)<Eval(x1_poly5)<Eval(x2_poly5)) > 1e-08){cout <<"No zero found, the lower point is y2: "<Eval(x2_poly5)<Eval(x2_poly5)<Integral(z1_poly5,z2_poly5)/20.; - integral_poly5_err = poly5->IntegralError(z1_poly5,z2_poly5)/20.; - cout << "The integral between the two zeros is "<< integral_poly5_val <<"+/-"<GetMaximum(low_limit, high_limit); + */ //MIchele - End /* TF1* fu_pulse2 = STTool::halfGauss2; @@ -457,34 +398,11 @@ //Estimate the systematics: # if a polynomial with zeros is found take as sys the semidifference // between its integral and the integral obtained from the fitted theoretical model // # if no polynomial behaved properly set the systematic error to -999 - double int_sys = -999.0; - double b_int_sys = true; - - if(b_poly3 == true){ - - int_sys = TMath::Abs(integral_poly3_val - int_val)/2.; - - }else{ - - if(b_poly4 == true){ - - int_sys = TMath::Abs(integral_poly4_val - int_val)/2.; - - }else{ - - if(b_poly5 == true){ - - int_sys = TMath::Abs(integral_poly5_val - int_val)/2.; - }else{ - b_int_sys = false; - } - - } - - } - //Michele - end - + double max_sys = -999; + if (b_max_p3 == true){ + max_sys = TMath::Abs(max_val - v_max_p3[0])/2.; + } @@ -496,11 +414,12 @@ Info("pulseFit"," tau: %8.4f+/-%8.4f ns",tau_val,tau_err); //Michele - if(b_int_sys == true){ - Info("pulseFit"," charge eq: %8.4f +/- %8.4f(stat) +/- %8.4f (sys)",int_val,int_err, int_sys); + //TO DO: control + if(b_max_p3 == true){ + Info("pulseFit"," charge eq: %8.4f +/- %8.4f(stat) +/- %8.4f (sys)",max_val,max_err, max_sys); }else{ - Info("pulseFit"," charge eq: %8.4f +/- %8.4f(stat) +/- No sys eval.",int_val,int_err); + Info("pulseFit"," charge eq: %8.4f +/- %8.4f(stat) +/- No sys eval.", max_val,max_err); } // // Plot pulse @@ -510,8 +429,8 @@ fu_pulse->Draw("Same"); //fu_pulse2->Draw("Same"); poly3->Draw("Same"); - poly4->Draw("Same"); - poly5->Draw("Same"); + //poly4->Draw("Same"); + //poly5->Draw("Same"); mg_pulse->Draw(""); mg_pulse->GetXaxis()->SetLimits(-30.0,30.0); mg_pulse->GetXaxis()->SetTitle("#delta#it{t} [ns]"); @@ -537,7 +456,7 @@ v_res(8) = cov_volt[1]; v_res(9) = cov_volt[2]; v_res(10)= cov_volt[5]; - v_res(11) = int_sys; + v_res(11) = max_sys; // Write the data and the plots