double callPriceBS(const double S, const double K, const double T, const double r, const double sigma) { double t = T/ (double)252.0 ; return norm_cdf(d_1(S,K,T,r,sigma)) * S - norm_cdf(d_2(S,K,T,r,sigma)) * K * exp((-1 *r )* (t)); }
Bool_t FakedSeeding::Process(Long64_t entry) { fChain->GetTree()->GetEntry(entry); //Map float zref = (float)m_zReference; PrSeedTrack *Track = new PrSeedTrack(zref); Track->setZref(zref); Track->setdRatio((float)m_dRatio); PrSeedTrack *Track_All = new PrSeedTrack(zref); Track_All->setZref(zref); Track_All->setdRatio((float)m_dRatio); double Z1 = 7855.6; double Z2 = 8040.4; double Z3 = 8537.6; const float dxDy = (5./360.00000)*2.*TMath::Pi(); double Z4 = 8722.4; double Z5 = 9222.6; double Z6 = 9407.4; double ZU1 = 7917.2; double ZV1 = 7978.8; double ZU2 = 8599.2; double ZV2 = 8660.8; double ZU3 = 9284.8; double ZV3 = 9345.8; double X1 = X1st; double X2 = X2nd; double X3 = X3rd; double X4 = X4th; double X5 = X5th; double X6 = X6th; double XU1 = Ux1st; double XU2 = Ux2nd; double XU3 = Ux3rd; double XV1 = Vx1st; double XV2 = Vx2nd; double XV3 = Vx3rd; Hit hit1 =Hit(X1,Y1st,Z1); Hit hit2 =Hit(XU1,Uy1st,ZU1); hit2.SetDxDy(dxDy); Hit hit3 =Hit(XV1,Vy1st,ZV1); hit3.SetDxDy(-dxDy); Hit hit4 =Hit(X2,Y2nd,Z2); Hit hit5 =Hit(X3,Y3rd,Z3); Hit hit6 =Hit(XU2,Uy2nd,ZU2); hit6.SetDxDy(dxDy); Hit hit7 =Hit(XV2,Vy2nd,ZV2); hit7.SetDxDy(-dxDy); Hit hit8 =Hit(X4,Y4th,Z4); Hit hit9 =Hit(X5,Y5th,Z5); Hit hit10 =Hit(XU3,Uy3rd,ZU3); hit10.SetDxDy(-dxDy); Hit hit11 =Hit(XV3,Vy3rd,ZV3); hit11.SetDxDy(dxDy); Hit hit12 =Hit(X6,Y6th,Z6); std::vector<Hit> AllHits; std::random_device rd_1; std::mt19937 gen_1(rd_1()); std::discrete_distribution<> d_1({4, 24, 33, 39}); hit1.SetSize((double)d_1(gen_1)); hit2.SetSize((double)d_1(gen_1)); hit3.SetSize((double)d_1(gen_1)); hit4.SetSize((double)d_1(gen_1)); hit5.SetSize((double)d_1(gen_1)); hit6.SetSize((double)d_1(gen_1)); hit7.SetSize((double)d_1(gen_1)); hit8.SetSize((double)d_1(gen_1)); hit9.SetSize((double)d_1(gen_1)); hit10.SetSize((double)d_1(gen_1)); hit11.SetSize((double)d_1(gen_1)); hit12.SetSize((double)d_1(gen_1)); AllHits.push_back(hit1); AllHits.push_back(hit2); AllHits.push_back(hit3); AllHits.push_back(hit4); AllHits.push_back(hit5); AllHits.push_back(hit6); AllHits.push_back(hit7); AllHits.push_back(hit8); AllHits.push_back(hit9); AllHits.push_back(hit10); AllHits.push_back(hit11); AllHits.push_back(hit12); Track_All->addHits(AllHits); //Track_All->printHits(); //in a for loop Size = (double)d_1(gen_1); //FITTA(Track_All); std::vector<Hit> Hitss = Track_All->hits(); double solutions[4]; double solutions_y[3]; std::vector<double> dsolution; std::vector<double> dsolution_y; std::fill(solutions,solutions+4,0.); std::fill(solutions_y,solutions_y+3,0.); double res = 0.; double resy = 0.; double dz = 0; // if(P<5000) return kTRUE; // if(OVTX_Z>4000) return kTRUE; // if( std::abs(PID)==11 || (std::abs(PID)!=211 && std::abs(PID)!=2212 && std::abs(PID)!=321 && std::abs(PID)!=13)) // return kTRUE; // if ((Y1st>=0 && Y6th<=0)||(Y1st>=0 && Y6th<=0)) // return kTRUE; // if(P<500) // return kTRUE; int regionT1= -1; int regionT3 = -1; if(std::fabs(Y1st)>500){ if(std::fabs(X1st)>500) regionT1 = 3; if(std::fabs(X1st)<=500) regionT1 = 2; } if(std::fabs(Y1st)<500){ if(std::fabs(X1st>500)) regionT1 = 1; if(std::fabs(X1st<500)) regionT1 = 0; } if(std::fabs(Y6th)>500){ if(std::fabs(X6thx)>500) regionT3 = 3; if(std::fabs(X6th)<=500) regionT3 = 2; } if(std::fabs(Y6th)<500){ if(std::fabs(X6th>500)) regionT3 = 1; if(std::fabs(X1st<500)) regionT3 = 0; } XYType=-1; XZType=-1; //Region motion With Y info, without Y info //2 / 3 0-->0 XYType = 0 0/2 --> 0/2 XZType = 0 2*regionT1%2 + regionT3%2 //0 / 1 0-->1 XYType = 1 0/2 --> 1/3 XZType = 1 // 0-->2 XYType = 2 1/3 --> 0/2 XZType = 2 // 0-->3 XYType = 3 1/3 --> 1/3 XYType = 3 // 1-->0 XYType = 4 // 1-->1 XYType = 5 // 1-->2 XYType = 6 // 1-->3 XYType = 7 // 2-->0 XYtype = 8 // 2-->1 XYType = 9 // 2-->2 XYType = 10 // 2-->3 XYType = 11 // 3-->0 XYType = 12 // 3-->1 XYType = 13 // 3-->2 XYType = 14 // 3-->3 XYType = 15 XYType = regionT1*4+regionT3; XZType = 2*regionT2%2+regionT3%2; if(doFit){ for(int j=0;j<3;j++){//loop //std::fill(dsolutions,dsolutions+4,0.); LinParFit<double> fit(4); LinParFit<double> fit_y(3); for (int i = 0;i<Hitss.size();i++){ dz =(double)(Hitss[i].GetZ()-m_zReference); res=(double)(Hitss[i].GetX() - (solutions[0]+solutions[1]*dz+solutions[2]*dz*dz+solutions[3]*dz*dz*dz));//*dz*dz*dz+solutions[4]*dz*dz*dz*dz)); resy = (double)(Hitss[i].GetY()-(solutions_y[0]+solutions_y[1]*dz + solutions_y[2]*dz*dz)); //std::cout<<"Loop\t"<<j<<"\t Residual \t"<<res<<std::endl; fit_y.accumulate(resy,0.100,dz); fit.accumulate(res,0.100,dz); } //std::vector<double> solution; dsolution_y= fit_y.solution(); dsolution=fit.solution(); for (int k=0;k<4;k++){ if(k<3){ solutions_y[k]+=dsolution_y[k]; } solutions[k]+=dsolution[k]; } } //Fit for y(z) = [0]+[1]*(z-zRef) //So y(zRef) = [0] double ay = solutions_y[0];// - m_zReference*solutions_y[1]; double by = solutions_y[1]; double cy = solutions_y[2]; //std::cout<<"Par \t Value "<<std::endl; double a = solutions[0]; double b = solutions[1]; double c = solutions[2]; double e = solutions[3]/solutions[2]; double Constant_C; ay_0=ay; by_0=by; cy_0=cy; ax_0=a; bx_0=b; cx_0=c; dx_0=e; xFirst=X1st; xLast=X6th; yFirst=Y1st; yLast=Y6th; t1->Fill(); // double f = solutions[4]/(solutions[3]*solutions[2]); // std::cout<<" a \t"<<a // <<"\n b \t"<<b // <<"\n c \t"<<c // <<"\n e \t"<<e<<std::endl; for (int i = 0;i<Hitss.size();i++){ dz = (double)(Hitss[i].GetZ()-m_zReference); res = (double)(Hitss[i].GetX() - (a+b*dz+c*dz*dz*(1.+e*dz)));//+solutions[3]));//*dz*dz*dz+solutions[4]*dz*dz*dz*dz)); // std::d::cout<<"Hit Index\t Residual"<<"\n "<<i<<"\t"<<res<<std::endl; } // <<"\n f \t"<<f // <<std::endl; double dRatioy = solutions_y[2]/solutions_y[1]; //std::cout<<"Fitted dRatio y " <<solutions_y[2]/solutions_y[1]<<std::endl; Fitted_dRatioy->Fill(dRatioy*10e6); Fitted_dRatioyVsC->Fill(dRatioy*10e6,c); Fitted_dRatioyVsP->Fill(dRatioy*10e6,P); Fitted_dRatioyVsXFirst->Fill(dRatioy*10e6,a); Constant_C =( b * m_zReference - a)/c; C_Constant->Fill(Constant_C); Fitted_dRatio->Fill((double)e); Fitted_dRatio_Vs_p->Fill((double)P,(double)e); Fitted_dRatio_VsXAtZ->Fill((double)a,(double)e); //Vs aY Fitted_dRatio_VsYatZ->Fill((double)(ay),(double)e); Fitted_dRatio_VsbyatZ->Fill((double)by,(double)e); Fitted_dRatio_VsbyOveray->Fill((double)(ay/by),(double)e); // std::cout<<"ay = "<<ay // <<"by = "<<by // <<"by/ay ="<<ay/by<<std::endl; C_Constant_Vs_P->Fill((double)P,(double)Constant_C); if(P>1000 && OVTX_Z<9000 && std::abs(PID)!=11) { //Vs y Fitted_dRatio_VsYatZSel->Fill((double)(ay),(double)e); Fitted_dRatio_VsbyatZSel->Fill((double)(by),(double)e); Fitted_dRatio_VsbyOveraySel->Fill((double)(ay/by),(double)e); Fitted_dRatio_Sel->Fill((double)e); Fitted_dRatio_Vs_p_Sel->Fill((double)P,(double)e); C_Constant_Vs_P_Sel->Fill((double)P,(double)Constant_C); C_Constant_Sel->Fill(Constant_C); C_Constant_Vs_a->Fill(Constant_C,std::abs(a)); C_Constant_Vs_b->Fill(Constant_C,b); C_Constant_Vs_c->Fill(Constant_C,c); } } //---------------- // Only X Layers //---------------- std::vector<double> Z; Z.push_back((float)Z1); Z.push_back((float)Z2); Z.push_back((float)Z3); Z.push_back((float)Z4); Z.push_back((float)Z5); Z.push_back((float)Z6); //-------------- //Remove Electrons , Keep Muon(13), Pions(211), Protons(2212),Kaons(321) if(P<500) return kTRUE; if(OVTX_Z>9000) return kTRUE; if( std::abs(PID)==11 || (std::abs(PID)!=211 && std::abs(PID)!=2212 && std::abs(PID)!=321 && std::abs(PID)!=13)) return kTRUE; if ((Y1st>=0 && Y6th<=0)||(Y1st>=0 && Y6th<=0)) return kTRUE; //Fit result plotted for this selection m_Total++; std::vector<double> X_true; std::vector<double> X_smear; X_true.push_back(X1st); X_true.push_back(X2nd); X_true.push_back(X3rd); X_true.push_back(X4th); X_true.push_back(X5th); X_true.push_back(X6th); Int_t Case=0; double X_T3_2 = X6th +gRandom->Gaus(0,m_sigmaSmearing); // X in last Layer double X_T1_1 = X1st +gRandom->Gaus(0,m_sigmaSmearing); // X in first Layer double Z_T3_2 = Z6; // Z of last Layer double Z_T1_1 = Z1; // Z of first Layer double X_T1_2 = X2nd +gRandom->Gaus(0,m_sigmaSmearing); double Z_T1_2 = Z2; double X_T2_1 = X3rd +gRandom->Gaus(0,m_sigmaSmearing); // X of 1st Layer in T2 double Z_T2_1 = Z3; // Z of 1st Layer in T2 double X_T2_2 = X4th+gRandom->Gaus(0,m_sigmaSmearing); // X of 2nd Layer in T2 double Z_T2_2 = Z4; // Z of 2nd Layer in T2 double X_T3_1 = X5th+gRandom->Gaus(0,m_sigmaSmearing); double Z_T3_1 = Z5th; if(Case==0){ Xlast= X_T3_2; Zlast= Z_T3_2; Xfirst= X_T1_2; Zfirst= Z_T1_2; } if(Case==1){ Xfirst=X_T1_1; Zfirst=Z_T1_1; Xlast=X_T3_1; Zlast=Z_T3_1; } if(Case==2){ Xfirst =X_T1_2; Xlast =X_T3_2; Zfirst =Z_T1_1; Xlast =Z_T3_2; } if(Case==0){ X_smear.push_back((float)Xfirst); X_smear.push_back((float)X_T1_2); X_smear.push_back((float)X_T2_1); X_smear.push_back((float)X_T2_2); X_smear.push_back((float)X_T3_1); X_smear.push_back((float)Xlast); } if(Case==1){ X_smear.push_back((float)Xfirst); X_smear.push_back((float)X_T1_2); X_smear.push_back((float)X_T2_1); X_smear.push_back((float)X_T2_2); X_smear.push_back((float)Xlast); X_smear.push_back((float)X_T3_2); } if(Case==1){ X_smear.push_back((float)XT1_1); X_smear.push_back((float)Xfirst); X_smear.push_back((float)X_T2_1); X_smear.push_back((float)X_T2_2); X_smear.push_back((float)X_T3_1); X_smear.push_back((float)Xlast); } for (int i =0;i<6;i++) { Hit_res->Fill(X_smear[i]-X_true[i]); } std::vector<Hit> Hits; double t_inf = Xfirst/Zfirst; double X_last_Projected = Xfirst/Zfirst*Zlast; double Distance_LastToInfProjected = Xlast-X_last_Projected; //LastInf //LastInfDistance = Xlast-X_last_Projected double Correction = m_alphaCorrection*(t_inf); double Distance_LastToInfProjected_Corrected = Distance_LastToInfProjected - Correction; // Xlast -(m_alphaCoorection*t_inf+Xfirst/Zfirst*Zlast) L0_Corrected_1d->Fill(Distance_LastToInfProjected_Corrected); L0_1d->Fill(Distance_LastToInfProjected); //---------- //L0 Plots (selection for last layer dependengly on first layer picked position) //L0_1d->Write(); //--------- L0_0->Fill(X_last_Projected,Distance_LastToInfProjected); L0_1->Fill(t_inf,Distance_LastToInfProjected); L0_Corrected->Fill(t_inf,Distance_LastToInfProjected_Corrected); //To D0 : check for cases different from this and if one can gain from selecting only hits in central region applying another rotation (diagonal one) //-----------------L1 step Do the selection if( std::abs(Distance_LastToInfProjected_Corrected) > L0_Up) return kTRUE; m_L0Selected++; double tx_picked = (Xlast-Xfirst)/(Zlast-Zfirst) ; double X_projected_3rd = Xfirst + tx_picked *(Z3-Zfirst); double Deltatx = tx_picked - t_inf; double Delta = X_T2_1 - X_projected_3rd; double x0 = -1*(tx_picked)*Zfirst + Xfirst; double CorrX0 = m_x0Corr*x0; double DeltaCorr = Delta - CorrX0 ; x0vsTxInf->Fill(x0,t_inf); L1_0->Fill(x0,Delta); L1_0_corr->Fill(x0,DeltaCorr); L1_0_1D ->Fill(Delta); L1_0_1D_Corr->Fill(DeltaCorr); if(x0>0) { L1_0_x0pos->Fill(tx_picked,Delta); L1_1_x0pos->Fill(Deltatx,Delta); L1_2_x0pos->Fill(x0,Delta); L1_0_x0posCorr->Fill(tx_picked,DeltaCorr); L1_1_x0posCorr->Fill(Deltatx,DeltaCorr); L1_2_x0posCorr->Fill(x0,DeltaCorr); } if(x0<0) { L1_0_x0neg->Fill(tx_picked,Delta); L1_1_x0neg->Fill(Deltatx,Delta); L1_2_x0neg->Fill(x0,Delta); L1_0_x0negCorr->Fill(tx_picked,DeltaCorr); L1_1_x0negCorr->Fill(Deltatx,DeltaCorr); L1_2_x0negCorr->Fill(x0,DeltaCorr); } //Do L1 Selection: //x0<0 : res_Corr < m_m1(x+m_x0Offset) +m_yOff1 //Upper // res_Corr > m_m2(x+m_x0Offset) +m_yOff2 //Lower //x0>0 : res_Corr > m_m2(x-m_x0Offset) -m_yOff2 // res_Corr < m_m1(x+m_x0Offset) -m_yOff1 if(x0<0.) { double upperBound = m_m1*(x0+m_x0Offset)+m_yOff1; double lowerBound = m_m2*(x0+m_x0Offset)+m_yOff2; if(DeltaCorr> upperBound || DeltaCorr<lowerBound) return kTRUE; } if(x0>0.) { double lowerBound = m_m1*(x0-m_x0Offset)-m_yOff1; double upperBound = m_m2*(x0-m_x0Offset)-m_yOff2; if(DeltaCorr> upperBound || DeltaCorr<lowerBound) return kTRUE; } m_L1Selected++; //Be carefull in real Life these parameters has to be optimised and look to occupancy (1Hit /8mm expected) //================================ //Selection L2 In this step we will have a 3 Hit Combination (case0_1) 1st,3rd,6th station //=============================== //We Fit the parabola with 3 hits (or we compute the parabola) //2 Methods : //Compute Parabola in 2 ways //Parabola simple //Parabola with 3rd order correction //Create Method SolveParabola(Hit1,Hit2,Hit3,a,b,c); //Create Method SolveParabola2(Hit1,Hit2,Hit3,a,b,c); //Try to plot the q/p vs c with SolveParabola1 and SolveParabola2 //Look to Delta ParabolaExtrapolated Hit_X2, Hit_X4,Hit_X5 Hit *Hit1 = new Hit(Xfirst,0,Zfirst); Hit *Hit2 = new Hit(X_T2_1,0,Z3); Hit *Hit3 = new Hit(Xlast,0,Zlast); double a_par1=0; double b_par1=0; double c_par1=0; double a_par2=0; double b_par2=0; double c_par2=0; SolveParabola(Hit1,Hit2,Hit3,a_par1,b_par1,c_par1); //std::cout<<"a \t "<<a_par1<<"\t b \t "<<b_par1<<"\t c \t "<<c_par1<<std::endl; SolveParabola2(Hit1,Hit2,Hit3,a_par2,b_par2,c_par2); //std::cout<<"a \t "<<a<<"\t b \t "<<b<<"\t c \t "<<c<<std::endl; //std::cout<<"Next Track"<<std::endl; Hit *HitT1 = new Hit(X_T1_2,0.,Z_T1_2 ); Hit *HitT2 = new Hit(X_T2_2,0.,Z_T2_2 ); Hit *HitT3 = new Hit(X_T3_1,0.,Z_T3_1 ); //Compute distance from Parabola 1: //Extrapolate Hit double ExtrapolX_T1_par1 = Extrapol(HitT1->GetZ(),a_par1,b_par1,c_par1); double ExtrapolX_T2_par1 = Extrapol(HitT2->GetZ(),a_par1,b_par1,c_par1); double ExtrapolX_T3_par1 = Extrapol(HitT3->GetZ(),a_par1,b_par1,c_par1); double DeltaX_T1_par1 = HitT1->GetX()-ExtrapolX_T1_par1; double DeltaX_T2_par1 = HitT2->GetX()-ExtrapolX_T2_par1; double DeltaX_T3_par1 = HitT3->GetX()-ExtrapolX_T3_par1; // //Compute distance from Parabola 2: double ExtrapolX_T1_par2 = Extrapol2(HitT1->GetZ(),a_par2,b_par2,c_par2); double ExtrapolX_T2_par2 = Extrapol2(HitT2->GetZ(),a_par2,b_par2,c_par2); double ExtrapolX_T3_par2 = Extrapol2(HitT3->GetZ(),a_par2,b_par2,c_par2); double DeltaX_T1_par2 = HitT1->GetX()-ExtrapolX_T1_par2; double DeltaX_T2_par2 = HitT2->GetX()-ExtrapolX_T2_par2; double DeltaX_T3_par2 = HitT3->GetX()-ExtrapolX_T3_par2; L2_0_T1_par1->Fill(DeltaX_T1_par1); L2_0_T2_par1->Fill(DeltaX_T2_par1); L2_0_T3_par1->Fill(DeltaX_T3_par1); L2_0_T1_par2->Fill(DeltaX_T1_par2); L2_0_T2_par2->Fill(DeltaX_T2_par2); L2_0_T3_par2->Fill(DeltaX_T3_par2); // std::cout<<DeltaX_T1_par1<<"\t"<<DeltaX_T2_par1<<"\t"<<DeltaX_T3_par1<<std::endl; // std::cout<<DeltaX_T1_par2<<"\t"<<DeltaX_T2_par2<<"\t"<<DeltaX_T3_par2<<std::endl; if( std::abs(DeltaX_T1_par1) < maxDelta_par1 && std::abs(DeltaX_T2_par1) < maxDelta_par1 && std::abs(DeltaX_T3_par1) < maxDelta_par1) m_L2_Par1_Selected ++; if( std::abs(DeltaX_T1_par2) < maxDelta_par2 && std::abs(DeltaX_T2_par2) < maxDelta_par2 && std::abs(DeltaX_T3_par2) < maxDelta_par2) m_L2_Par2_Selected ++; //--------------------- //L2//Parabola 1 Selection //--------------------- if( std::abs(DeltaX_T1_par1) > maxDelta_par1 && std::abs(DeltaX_T2_par1) < maxDelta_par1 && std::abs(DeltaX_T3_par1) > maxDelta_par1) return kTRUE; //LinParFit<double> fit_quartic(5); LinParFit<double> fit_parabola(3); std::vector<double> x,errx,z; //Create the vector of Hits // double Xlast = X6th; // X in last Layer // double Xfirst = X1st; // X in first Layer // double Zlast = Z6; // Z of last Layer // double Zfirst = Z1; // Z of first Layer // double X_T1_2 = X2nd; // double Z_T1_2 = Z2; // double X_T2_1 = X3rd; // X of 1st Layer in T2 // double Z_T2_1 = Z3; // Z of 1st Layer in T2 // double X_T2_2 = X4th; // X of 2nd Layer in T2 // double Z_T2_2 = Z4; // Z of 2nd Layer in T2 // double X_T3_1 = X5th; // double Z_T3_1 = Z5; x.push_back(Xfirst); x.push_back(X_T1_2); x.push_back(X_T2_1); x.push_back(X_T2_2); x.push_back(X_T3_1); x.push_back(Xlast); z.push_back(Zfirst-m_zReference); z.push_back(Z2-m_zReference); z.push_back(Z3-m_zReference); z.push_back(Z4-m_zReference); z.push_back(Z5-m_zReference); z.push_back(Zlast-m_zReference); std::random_device rd; std::mt19937 gen(rd()); std::discrete_distribution<> d({4, 24, 33, 39}); // for (int i=0;i<6;i++) // { // Hit Hit(X_smear[i],0.,Z[i]); // Hits.push_back(Hit); // } // Track->addHits(Hits); // Track->printTrack(); double ClSize = 0; for (int i=0;i<6;i++) { Hit Hit(X_smear[i],0.,Z[i]); ClSize = (double)d(gen); ClSize_1->Fill(ClSize+1); //GeneratedSize->Fill(ClSize+1.); errx.push_back(0.05 + 0.03*(ClSize+1.)); Hit.SetSize((int)(ClSize+1)); Hits.push_back(Hit); } Track->addHits(Hits); for (auto ity = std::begin(x), its = std::begin(errx), itx = std::begin(z); std::end(x) != ity; ++ity, ++its, ++itx) { fit_parabola.accumulate(*ity, *its, *itx); } std::vector<double> solution; solution = fit_parabola.solution(); double Chi2 = 0; for (auto ity = std::begin(x), its = std::begin(errx), itx = std::begin(z); std::end(x) != ity; ++ity, ++its, ++itx) { Chi2+=std::pow(*ity - (solution[0]+solution[1]*(*itx)+solution[2]*(*itx)*(*itx)),2)/((*its)*(*its)); } Chi2_par1->Fill(Chi2); bool Ok = fitXProjection(Track); if(Ok) { float C = (Track->b() * m_zReference - Track->a())/(Track->c()); float X0 = Track->a() - Track->b()*m_zReference +Track->c()*m_ConstC; C_par->Fill(C); XBackProj->Fill(X0); Chi2_par2->Fill(Track->chi2()); } if(Ok) { m_L2_Selection_ParCubic++; //std::cout<<"C\t"<<C<<std::endl; //Track->printTrack(); } //Track->printTrack(); // std::cout<<"Chi2 = \t "<<Chi2<<std::endl; //std::cout<<fit_parabola<<std::endl; return kTRUE; }
double putPriceBS(const double S, const double K, const double T, const double r, const double sigma) { double t = T/ (double)252.0 ; return -S* norm_cdf(-d_1( S, K, T, r, sigma))+K*exp(-r*t) * norm_cdf(-d_2(S, K, T, r, sigma)); }
double d_2(const double S, const double K, const double T, const double r, const double sigma) { double t = T/ (double)252.0 ; return(d_1(S,K,T,r,sigma) - (sigma * sqrt(t))); }
void dgtsv( long n, long nrhs, double dl[], double d[], double du[], double b[], long ldb, long *info ) { /** * -- LAPACK routine (version 1.1) -- * Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd., * Courant Institute, Argonne National Lab, and Rice University * March 31, 1993 * * .. Scalar Arguments ..*/ /** .. * .. Array Arguments ..*/ #undef du_1 #define du_1(a1) du[a1-1] #undef dl_1 #define dl_1(a1) dl[a1-1] #undef d_1 #define d_1(a1) d[a1-1] #undef b_2 #define b_2(a1,a2) b[a1-1+ldb*(a2-1)] /** .. * * Purpose * ======= * * DGTSV solves the equation * * A*X = B, * * where A is an N-by-N tridiagonal matrix, by Gaussian elimination with * partial pivoting. * * Note that the equation A'*X = B may be solved by interchanging the * order of the arguments DU and DL. * * Arguments * ========= * * N (input) INTEGER * The order of the matrix A. N >= 0. * * NRHS (input) INTEGER * The number of right hand sides, i.e., the number of columns * of the matrix B. NRHS >= 0. * * DL_1 (input/output) DOUBLE PRECISION array, dimension (N-1) * On entry, DL must contain the (n-1) subdiagonal elements of * A. * On exit, DL is overwritten by the (n-2) elements of the * second superdiagonal of the upper triangular matrix U from * the LU factorization of A, in DL_1(1), ..., DL_1(n-2). * * D_1 (input/output) DOUBLE PRECISION array, dimension (N) * On entry, D must contain the diagonal elements of A. * On exit, D is overwritten by the n diagonal elements of U. * * DU_1 (input/output) DOUBLE PRECISION array, dimension (N-1) * On entry, DU must contain the (n-1) superdiagonal elements * of A. * On exit, DU is overwritten by the (n-1) elements of the first * superdiagonal of U. * * B_2 (input/output) DOUBLE PRECISION array, dimension (LDB,NRHS) * On entry, the N-by-NRHS right hand side matrix B. * On exit, if INFO = 0, the N-by-NRHS solution matrix X. * * LDB (input) INTEGER * The leading dimension of the array B. LDB >= max(1,N). * * INFO (output) * = 0: successful exit * < 0: if INFO = -i, the i-th argument had an illegal value * > 0: if INFO = i, U(i,i) is exactly zero, and the solution * has not been computed. The factorization has not been * completed unless i = N. * * ===================================================================== * * .. Parameters ..*/ #undef zero #define zero 0.0e+0 /** .. * .. Local Scalars ..*/ long j, k; double mult, temp; /** .. * .. Intrinsic Functions ..*/ /* intrinsic abs, max;*/ /** .. * .. Executable Statements .. **/ /*-----implicit-declarations-----*/ /*-----end-of-declarations-----*/ *info = 0; if( n<0 ) { *info = -1; } else if( nrhs<0 ) { *info = -2; } else if( ldb<max( 1, n ) ) { *info = -7; } if( *info!=0 ) { xerbla( "dgtsv ", -*info ); return; } if( n==0 ) return; for (k=1 ; k<=n - 1 ; k+=1) { if( dl_1( k )==zero ) { /** * Subdiagonal is zero, no elimination is required. **/ if( d_1( k )==zero ) { /** * Diagonal is zero: set INFO = K and return; a unique * solution can not be found. **/ *info = k; return; } } else if( abs( d_1( k ) )>=abs( dl_1( k ) ) ) { /** * No row interchange required **/ mult = dl_1( k ) / d_1( k ); d_1( k+1 ) = d_1( k+1 ) - mult*du_1( k ); for (j=1 ; j<=nrhs ; j+=1) { b_2( k+1, j ) = b_2( k+1, j ) - mult*b_2( k, j ); } if( k<( n-1 ) ) dl_1( k ) = zero; } else { /** * Interchange rows K and K+1 **/ mult = d_1( k ) / dl_1( k ); d_1( k ) = dl_1( k ); temp = d_1( k+1 ); d_1( k+1 ) = du_1( k ) - mult*temp; if( k<( n-1 ) ) { dl_1( k ) = du_1( k+1 ); du_1( k+1 ) = -mult*dl_1( k ); } du_1( k ) = temp; for (j=1 ; j<=nrhs ; j+=1) { temp = b_2( k, j ); b_2( k, j ) = b_2( k+1, j ); b_2( k+1, j ) = temp - mult*b_2( k+1, j ); } } } if( d_1( n )==zero ) { *info = n; return; } /** * Back solve with the matrix U from the factorization. **/ for (j=1 ; j<=nrhs ; j+=1) { b_2( n, j ) = b_2( n, j ) / d_1( n ); if( n>1 ) b_2( n-1, j ) = ( b_2( n-1, j )-du_1( n-1 )*b_2( n, j ) ) / d_1( n-1 ); for (k=n - 2 ; k>=1 ; k+=-1) { b_2( k, j ) = ( b_2( k, j )-du_1( k )*b_2( k+1, j )-dl_1( k )* b_2( k+2, j ) ) / d_1( k ); } } return; /** * End of DGTSV **/ }