void Foam::twoPhaseMixtureThermo::correct() { psi_ = alpha1()*thermo1_->psi() + alpha2()*thermo2_->psi(); mu_ = alpha1()*thermo1_->mu() + alpha2()*thermo2_->mu(); alpha_ = alpha1()*thermo1_->alpha() + alpha2()*thermo2_->alpha(); interfaceProperties::correct(); }
void Foam::twoPhaseMixtureThermo::correct() { thermo1_->he() = thermo1_->he(p_, T_); thermo1_->correct(); thermo2_->he() = thermo2_->he(p_, T_); thermo2_->correct(); psi_ = alpha1()*thermo1_->psi() + alpha2()*thermo2_->psi(); mu_ = alpha1()*thermo1_->mu() + alpha2()*thermo2_->mu(); alpha_ = alpha1()*thermo1_->alpha() + alpha2()*thermo2_->alpha(); }
Foam::tmp<Foam::volScalarField> Foam::dragModels::Tenneti::CdRe() const { volScalarField alpha1 ( max(pair_.dispersed(), pair_.continuous().residualAlpha()) ); volScalarField alpha2 ( max(scalar(1) - pair_.dispersed(), pair_.continuous().residualAlpha()) ); volScalarField F0 ( 5.81*alpha1/pow3(alpha2) + 0.48*pow(alpha1, 1.0/3.0)/pow4(alpha2) ); volScalarField F1 ( pow(alpha1, 3)*max(pair_.Re(), residualRe_) *(0.95 + 0.61*pow3(alpha1)/sqr(alpha2)) ); // Tenneti et al. correlation includes the mean pressure drag. // This was removed here by multiplying F by alpha2 for consistency with // the formulation used in OpenFOAM return SchillerNaumann_->CdRe()/(alpha2*max(pair_.Re(), residualRe_)) + 24.0*sqr(alpha2)*(F0 + F1); }
void OperationMultipleHierarchisationLinearClenshawCurtis::doDehierarchisation( base::DataMatrix& alpha) { base::GridStorage& storage = *grid.getStorage(); const size_t d = storage.dim(); base::OperationNaiveEvalLinearClenshawCurtis opNaiveEval(&storage); base::DataVector nodeValues(storage.size(), 0.0); base::DataVector x(d, 0.0); base::DataVector alpha1(storage.size(), 0.0); for (size_t i = 0; i < alpha.getNcols(); i++) { alpha.getColumn(i, alpha1); for (size_t j = 0; j < storage.size(); j++) { const base::GridIndex& gp = *storage[j]; for (size_t t = 0; t < d; t++) { x[t] = gp.getCoord(t); } nodeValues[j] = opNaiveEval.eval(alpha1, x); } alpha.setColumn(i, nodeValues); } }
Foam::twoPhaseMixtureThermo::twoPhaseMixtureThermo ( const volVectorField& U, const surfaceScalarField& phi ) : psiThermo(U.mesh(), word::null), twoPhaseMixture(U.mesh(), *this), interfaceProperties(alpha1(), U, *this), thermo1_(nullptr), thermo2_(nullptr) { { volScalarField T1(IOobject::groupName("T", phase1Name()), T_); T1.write(); } { volScalarField T2(IOobject::groupName("T", phase2Name()), T_); T2.write(); } thermo1_ = rhoThermo::New(U.mesh(), phase1Name()); thermo2_ = rhoThermo::New(U.mesh(), phase2Name()); // thermo1_->validate(phase1Name(), "e"); // thermo2_->validate(phase2Name(), "e"); correct(); }
bool EmbeddedMap2::check() { bool topo = Map2::check() ; if (!topo) return false ; CGoGNout << "Check: embedding begin" << CGoGNendl ; for(Dart d = begin(); d != end(); next(d)) { if (isOrbitEmbedded<VERTEX>()) { if (getEmbedding<VERTEX>(d) != getEmbedding<VERTEX>(alpha1(d))) { CGoGNout << "Check: different embeddings on vertex" << CGoGNendl ; return false ; } } if (isOrbitEmbedded<EDGE>()) { if (getEmbedding<EDGE>(d) != getEmbedding<EDGE>(phi2(d))) { CGoGNout << "Check: different embeddings on edge" << CGoGNendl ; return false ; } } // if (isOrbitEmbedded(ORIENTED_FACE)) // { // if (getEmbedding(ORIENTED_FACE, d) != getEmbedding(ORIENTED_FACE, phi1(d))) // { // CGoGNout << "Check: different embeddings on oriented face" << CGoGNendl ; // return false ; // } // } if (isOrbitEmbedded<FACE>()) { if (getEmbedding<FACE>(d) != getEmbedding<FACE>(phi1(d))) { CGoGNout << "Check: different embeddings on face" << CGoGNendl ; return false ; } } } CGoGNout << "Check: embedding ok" << CGoGNendl ; std::cout << "nb vertex orbits : " << getNbOrbits<VERTEX>() << std::endl ; std::cout << "nb vertex cells : " << m_attribs[VERTEX].size() << std::endl ; std::cout << "nb edge orbits : " << getNbOrbits<EDGE>() << std::endl ; std::cout << "nb edge cells : " << m_attribs[EDGE].size() << std::endl ; std::cout << "nb face orbits : " << getNbOrbits<FACE>() << std::endl ; std::cout << "nb face cells : " << m_attribs[FACE].size() << std::endl ; return true ; }
Foam::tmp<Foam::volScalarField> Foam::twoPhaseMixtureThermo::he ( const volScalarField& p, const volScalarField& T ) const { return alpha1()*thermo1_->he(p, T) + alpha2()*thermo2_->he(p, T); }
Foam::tmp<Foam::scalarField> Foam::twoPhaseMixtureThermo::kappa ( const label patchi ) const { return alpha1().boundaryField()[patchi]*thermo1_->kappa(patchi) + alpha2().boundaryField()[patchi]*thermo2_->kappa(patchi); }
Foam::tmp<Foam::volScalarField> Foam::twoPhaseMixtureThermo::alphaEff ( const volScalarField& alphat ) const { return alpha1()*thermo1_->alphaEff(alphat) + alpha2()*thermo2_->alphaEff(alphat); }
Foam::immiscibleIncompressibleTwoPhaseMixture:: immiscibleIncompressibleTwoPhaseMixture ( const volVectorField& U, const surfaceScalarField& phi ) : incompressibleTwoPhaseMixture(U, phi), interfaceProperties(alpha1(), U, *this) {}
Foam::tmp<Foam::scalarField> Foam::twoPhaseMixtureThermo::CpByCpv ( const scalarField& p, const scalarField& T, const label patchi ) const { return alpha1().boundaryField()[patchi]*thermo1_->CpByCpv(p, T, patchi) + alpha2().boundaryField()[patchi]*thermo2_->CpByCpv(p, T, patchi); }
Foam::tmp<Foam::scalarField> Foam::twoPhaseMixtureThermo::alphaEff ( const scalarField& alphat, const label patchi ) const { return alpha1().boundaryField()[patchi]*thermo1_->alphaEff(alphat, patchi) + alpha2().boundaryField()[patchi]*thermo2_->alphaEff(alphat, patchi) ; }
Foam::tmp<Foam::scalarField> Foam::twoPhaseMixtureThermo::he ( const scalarField& p, const scalarField& T, const labelList& cells ) const { return scalarField(alpha1(), cells)*thermo1_->he(p, T, cells) + scalarField(alpha2(), cells)*thermo2_->he(p, T, cells); }
Foam::tmp<Foam::scalarField> Foam::twoPhaseMixtureThermo::nu ( const label patchi ) const { return mu(patchi) /( alpha1().boundaryField()[patchi]*thermo1_->rho(patchi) + alpha2().boundaryField()[patchi]*thermo2_->rho(patchi) ); }
bool EmbeddedGMap2::check() const { bool topo = GMap2::check() ; if (!topo) return false ; CGoGNout << "Check: embedding begin" << CGoGNendl ; for(Dart d = begin(); d != end(); next(d)) { if (isOrbitEmbedded<VERTEX>()) { if (getEmbedding<VERTEX>(d) != getEmbedding<VERTEX>(alpha1(d))) { CGoGNout << "Check: different embeddings on vertex" << CGoGNendl ; return false ; } } if (isOrbitEmbedded<EDGE>()) { if (getEmbedding<EDGE>(d) != getEmbedding<EDGE>(phi2(d))) { CGoGNout << "Check: different embeddings on edge" << CGoGNendl ; return false ; } } if (isOrbitEmbedded<FACE>()) { if (getEmbedding<FACE>(d) != getEmbedding<FACE>(phi1(d))) { CGoGNout << "Check: different embeddings on face" << CGoGNendl ; return false ; } } } CGoGNout << "Check: embedding ok" << CGoGNendl ; std::cout << "nb vertex orbits : " << Algo::Topo::getNbOrbits<VERTEX>(*this) << std::endl ; std::cout << "nb vertex cells : " << m_attribs[VERTEX].size() << std::endl ; std::cout << "nb edge orbits : " << Algo::Topo::getNbOrbits<EDGE>(*this) << std::endl ; std::cout << "nb edge cells : " << m_attribs[EDGE].size() << std::endl ; std::cout << "nb face orbits : " << Algo::Topo::getNbOrbits<FACE>(*this) << std::endl ; std::cout << "nb face cells : " << m_attribs[FACE].size() << std::endl ; return true ; }
float calVelUpdateStepLen(const FwiParams ¶ms, const float *wlt, const float *dobs, const float *derr, float epsil, const EnquistAbc2d &fmMethod, const ShotPosition &allSrcPos, const ShotPosition &allGeoPos ) { int nt = params.nt; int nz = params.nz; int nx = params.nx; int ng = params.ng; int ns = params.ns; std::vector<float> dcal(ng, 0); /* calculated/synthetic seismic data */ std::vector<float> sp0(nz * nx); /* source wavefield p0 */ std::vector<float> sp1(nz * nx); /* source wavefield p1 */ std::vector<float> sp2(nz * nx); /* source wavefield p2 */ std::vector<float> alpha1(ng, 0); /* numerator of alpha, length=ng */ std::vector<float> alpha2(ng, 0); /* denominator of alpha, length=ng */ for (int is = 0; is < ns; is++) { std::fill(sp0.begin(), sp0.end(), 0); std::fill(sp1.begin(), sp1.end(), 0); ShotPosition currSrcPos = allSrcPos.clip(is); for (int it = 0; it < nt; it++) { fmMethod.addSource(&sp1[0], &wlt[it], currSrcPos); fmMethod.stepForward(&sp0[0], &sp1[0], &sp2[0]); cycleSwap(sp0, sp1, sp2); fmMethod.recordSeis(&dcal[0], &sp0[0], allGeoPos); sum_alpha12(&alpha1[0], &alpha2[0], &dcal[0], &dobs[is * nt * ng + it * ng], &derr[is * ng * nt + it * ng], ng); } } float alpha = cal_alpha(&alpha1[0], &alpha2[0], epsil, ng); return alpha; }
TEST_F(test_core, transition_INPSS) { sas::String<M1> alpha1("ALPHA"), omega1("OMEGA"); // define network entry. link(term, pound, atInvoke, 1); entry. link(term, lowercase, atNegative, 3); entry. link(term, letters, atPositive, 2); entry. link(exit, alpha1, atSimple, 4); entry. link(exit, omega1, atSimple, 5); exit. link(term, end, atSimple, 6); // test parsing EXPECT_EQ( "3", parse(entry, "#Alpha") ); EXPECT_EQ( "3", parse(entry, "#Omega") ); EXPECT_EQ( "3", parse(entry, "#alpha") ); EXPECT_EQ( "3", parse(entry, "#omega") ); EXPECT_EQ( "5 | 1 4 6", parse(entry, "#ALPHA") ); EXPECT_EQ( "5 | 1 5 6", parse(entry, "#OMEGA") ); }
bool EmbeddedGMap2::edgeCanCollapse(Dart d) { if(isBoundaryVertex(d) || isBoundaryVertex(phi1(d))) return false ; unsigned int val_v1 = vertexDegree(d) ; unsigned int val_v2 = vertexDegree(phi1(d)) ; if(val_v1 + val_v2 < 8 || val_v1 + val_v2 > 14) return false ; if(faceDegree(d) == 3) { if(vertexDegree(phi_1(d)) < 4) return false ; } Dart dd = phi2(d) ; if(faceDegree(dd) == 3) { if(vertexDegree(phi_1(dd)) < 4) return false ; } // Check vertex sharing condition std::vector<unsigned int> vu1 ; vu1.reserve(32) ; Dart vit1 = alpha1(alpha1(d)) ; Dart end = phi1(dd) ; do { unsigned int ve = getEmbedding<VERTEX>(phi2(vit1)) ; vu1.push_back(ve) ; vit1 = alpha1(vit1) ; } while(vit1 != end) ; end = phi1(d) ; Dart vit2 = alpha1(alpha1(dd)) ; do { unsigned int ve = getEmbedding<VERTEX>(phi2(vit2)) ; std::vector<unsigned int>::iterator it = std::find(vu1.begin(), vu1.end(), ve) ; if(it != vu1.end()) return false ; vit2 = alpha1(vit2) ; } while(vit2 != end) ; return true ; }
/**** * This routine computes <LeftVector | \hat P_\pm (\D+B(1-(1/\rho)\D))^-1 P_\pm | RightVector> * All factors are already included. */ bool AnalyzerObservablePsiBarPhiPsiCondensateBase::calcMatrixElementProjectorHatMinverseProjector(Complex& result, double* phiField, Complex* LeftVector, Complex* RightVector, double TOL, int projMode) { int L0 = fermiOps->get1DSizeL0(); int L1 = fermiOps->get1DSizeL1(); int L2 = fermiOps->get1DSizeL2(); int L3 = fermiOps->get1DSizeL3(); bool success = true; double rho, r; fermiOps->getDiracParameters(rho, r); double fac = -1.0 / (2.0*rho); if (projMode != 0) fac *= 0.25; //Missing factor 0.5 in projector \hat P_\pm and P_\pm compensated with this factor 0.25. //Berechne daggered Projector \hat P_\pm angewendet auf LeftVector ==> Faktor 0.5 fehlt if (projMode != 0) { fermiOps->executeGamma5(LeftVector, SolutionVector); fermiOps->executeDiracDaggerMatrixMultiplication(SolutionVector, HelperVector, false); Complex alpha1(-1.0/rho, 0); SSE_ComplexVectorAddition(L0, L1, L2, L3, xtraSize1, xtraSize2, xtraSize3, alpha1, HelperVector, SolutionVector); Complex alpha2(projMode, 0); SSE_ComplexVectorAddition(L0, L1, L2, L3, xtraSize1, xtraSize2, xtraSize3, alpha2, SolutionVector, LeftVector); } //Apply inverse M^dagger int neededIter = 0; bool b = fermiOps->executeFermionMatrixDaggerInverseMatrixMultiplication(LeftVector, SolutionVector, phiField, TOL, false, -1, neededIter); if (!b) success = false; //Apply P_\pm^dagger ==> Faktor 0.5 fehlt if (projMode != 0) { bool projPlus = true; if (projMode<0) projPlus = false; fermiOps->executeProjectorMultiplication(SolutionVector, SolutionVector, projPlus); //OHNE Faktor 0.5 } Complex scalar(0,0); SSE_ComplexScalarProduct(L0, L1, L2, L3, xtraSize1, xtraSize2, xtraSize3, SolutionVector, RightVector, scalar); result = fac*scalar; return success; }
Foam::tmp<Foam::volScalarField> Foam::dragModels::Tenneti::CdRe() const { volScalarField alpha1 ( max(pair_.dispersed(), pair_.continuous().residualAlpha()) ); volScalarField alpha2 ( max(pair_.continuous(), pair_.continuous().residualAlpha()) ); volScalarField Res(alpha2*pair_.Re()); volScalarField CdReIsolated ( neg(Res - 1000)*24*(1 + 0.15*pow(Res, 0.687)) + pos0(Res - 1000)*0.44*max(Res, residualRe_) ); volScalarField F0 ( 5.81*alpha1/pow3(alpha2) + 0.48*pow(alpha1, 1.0/3.0)/pow4(alpha2) ); volScalarField F1 ( pow3(alpha1)*Res*(0.95 + 0.61*pow3(alpha1)/sqr(alpha2)) ); // Tenneti et al. correlation includes the mean pressure drag. // This was removed here by multiplying F by alpha2 for consistency with // the formulation used in OpenFOAM return CdReIsolated + 24*sqr(alpha2)*(F0 + F1); }
void BDT_cuts_norm(){ gROOT->ProcessLine(".L ~/cern/project/lhcbStyle.C"); lhcbStyle(); const std::string filename("/afs/cern.ch/work/a/apmorris/private/cern/ntuples/new_tuples/normalisation_samples/Lb2JpsipK_2011_2012_signal_withbdt.root"); const std::string treename = "withbdt"; const std::string filenameMC("/afs/cern.ch/work/a/apmorris/private/cern/ntuples/new_tuples/normalisation_samples/Lb2JpsipK_MC_2011_2012_norm_withbdt.root"); TFile* file = TFile::Open( filename.c_str() ); if( !file ) std::cout << "file " << filename << " does not exist" << std::endl; TTree* tree = (TTree*)file->Get( treename.c_str() ); if( !tree ) std::cout << "tree " << treename << " does not exist" << std::endl; TFile* fileMC = TFile::Open( filenameMC.c_str() ); if( !fileMC ) std::cout << "file " << filenameMC << " does not exist" << std::endl; TTree* treeMC = (TTree*)fileMC->Get( treename.c_str() ); if( !treeMC ) std::cout << "tree " << treename << " does not exist" << std::endl; // -- signal, mass shape RooRealVar Lambda_b0_DTF_MASS_constr1("Lambda_b0_DTF_MASS_constr1","m(J/#psi pK^{-})", 5550., 5700., "MeV/c^{2}"); RooRealVar Jpsi_M("Jpsi_M","m(#mu#mu)", 3000., 3200., "MeV/c^{2}"); RooRealVar chi_c_M("chi_c_M","m(J/#psi#gamma)", 3400., 3700., "MeV/c^{2}"); RooRealVar mean("mean","mean", 5630., 5610., 5650.); RooRealVar sigma1("sigma1","sigma1", 10., 1., 100.); RooRealVar sigma2("sigma2","sigma2", 30.0, 5.0, 300.0); RooRealVar alpha1("alpha1","alpha1", 1.0, 0.5, 5.0); RooRealVar n1("n1","n1", 1.8, 0.2, 15.0); RooRealVar alpha2("alpha2","alpha2", -0.5, -5.5, 0.0); RooRealVar n2("n2","n2", 0.7, 0.2, 10.0); //RooRealVar bkgcat_chic("bkgcat_chic","bkgcat_chic", 0, 100); RooRealVar bdtg3("bdtg3", "bdtg3", -1.0, 1.0); RooRealVar frac2("frac2","frac2", 0.3, 0., 1.); RooGaussian gauss1("gauss1","gauss1", Lambda_b0_DTF_MASS_constr1, mean, sigma1); RooGaussian gauss2("gauss2","gauss2", Lambda_b0_DTF_MASS_constr1, mean, sigma2); RooCBShape cb1("cb1","cb1", Lambda_b0_DTF_MASS_constr1, mean, sigma1, alpha1, n1); RooCBShape cb2("cb2","cb2", Lambda_b0_DTF_MASS_constr1, mean, sigma2, alpha2, n2); RooAddPdf sig("sig", "sig", RooArgList(cb1, cb2), RooArgList( frac2 )); RooRealVar cbRatio("cbRatio","cb Ratio", 0.8, 0.1, 1.0); RooRealVar sigYield("sigYield","sig Yield", 4e2, 1e0, 1e6); RooRealVar bgYield("bgYield","bg Yield", 1e4, 1e0, 1e6); //put in values from fit_MC here <<--- DON'T FORGET TO CHANGE THESE IF THE FIT CHANGES!!! /* EXT PARAMETER INTERNAL INTERNAL NO. NAME VALUE ERROR STEP SIZE VALUE 1 alpha1 2.18020e+00 2.85078e-02 1.38432e-04 -2.56034e-01 2 alpha2 -2.79102e+00 6.74385e-02 1.51818e-04 -1.49177e-02 3 cbRatio 3.07172e-01 1.49204e-02 1.72642e-04 -5.69984e-01 4 mean 5.61985e+03 9.58397e-03 5.56682e-05 -9.66293e-02 5 n1 1.49358e+00 8.14447e-02 2.09300e-04 -9.70542e-01 6 n2 1.45276e+00 1.09864e-01 2.59028e-04 -8.39538e-01 7 sigma1 8.46303e+00 1.32851e-01 2.86985e-05 -1.01453e+00 8 sigma2 4.93976e+00 3.42842e-02 5.03572e-06 -1.44512e+00 */ alpha1.setVal( 2.18020e+00 ); alpha2.setVal( -2.79102e+00 ); n1.setVal( 1.49358e+00 ); n2.setVal( 1.45276e+00 ); frac2.setVal( 3.07172e-01 ); sigma1.setVal( 8.46303e+00 ); sigma2.setVal( 4.93976e+00 ); alpha1.setConstant( true ); alpha2.setConstant( true ); frac2.setConstant( true ); n1.setConstant( true ); n2.setConstant( true ); sigma1.setConstant( true ); sigma2.setConstant( true ); // -- bg, mass shape RooRealVar a1("a1","a1", -0.1, -0.5, 0.5); RooChebychev comb("comb","comb", Lambda_b0_DTF_MASS_constr1, a1); RooRealVar mean3("mean3","mean3", 5560., 5500., 5600.); RooRealVar sigma3("sigma3","sigma3", 5., 1., 10.); RooRealVar frac3("frac3","frac", 0.2, 0.0, 0.3); RooGaussian gauss3("gauss3","gauss3", Lambda_b0_DTF_MASS_constr1, mean3, sigma3); //RooAddPdf bg("bg","bg", RooArgList(comb), RooArgList(frac3)); // -- add signal & bg RooAddPdf pdf("pdf", "pdf", RooArgList(sig, comb), RooArgList( sigYield, bgYield)); double efficiencies1[40]; double efficiencies1_error[40]; double bdt_cuts[40]; double efficiencies2[40]; double efficiencies2_error[40]; double sideband_bg_val[40]; double MC_pre = treeMC->GetEntries(); double effvals[40]; //loop starting here for(int i=0; i < 40; i=i+1) { double cut_val = -1.0 + i*0.05; //double cut_val = -1.0; // testing bdt_cuts[i] = cut_val; std::stringstream c; c << "bdtg3" << " >= " << cut_val; const std::string cut = c.str(); //std::cout << cut; RooArgSet obs; obs.add(Lambda_b0_DTF_MASS_constr1); //obs.add(chi_c_Mp); //obs.add(mass_pK); obs.add(Jpsi_M); obs.add(chi_c_M); obs.add(bdtg3); RooDataSet ds("ds","ds", obs, RooFit::Import(*tree), RooFit::Cut(cut.c_str())); RooPlot* plot = Lambda_b0_DTF_MASS_constr1.frame(); RooFitResult * result = pdf.fitTo( ds, RooFit::Extended() ); double sig_val = sigYield.getVal(); double bg_val = bgYield.getVal(); double sig_error = sigYield.getError(); double bg_error = bgYield.getError(); double efficiency1 = (sig_val)/(sqrt(sig_val + bg_val)); efficiencies1[i] = efficiency1; double efficiency1_error_sq = (pow(sig_error,2)/(sig_val+bg_val) + (pow(sig_val,2)*(pow(sig_error,2)+pow(bg_error,2))/(4*pow((sig_val+bg_val),3)))); double efficiency1_error = sqrt(efficiency1_error_sq); efficiencies1_error[i] = efficiency1_error; /* double MC_post = treeMC->GetEntries(cut.c_str()); double eff_val = MC_post/MC_pre; //something here to get the sideband background count Lambda_b0_DTF_MASS_constr1.setRange("R", 5650., 5700.); RooFitResult * sideband = bg.fitTo( ds, RooFit::Range("R") ); sideband->Print(); Lambda_b0_DTF_MASS_constr1.setRange("R", 5650., 5700.); RooAbsReal* integral = pdf.createIntegral(Lambda_b0_DTF_MASS_constr1, RooFit::Range("R")); //std::cout << integral->getVal() << std::endl; //std::cout << integral->getError() << std::endl; //Double_t sideband_bg_val = integral->getVal(); //double sideband_bg_error = integral->getError(); std::stringstream r; r << "bdtg3" << " >= " << cut_val << " && Lambda_b0_DTF_MASS_constr1 >= 5650 && Lambda_b0_DTF_MASS_constr1 <= 5700"; const std::string cut2 = r.str(); double integ = tree->GetEntries(cut2.c_str()); //double integ = integral->getVal(); double efficiency2 = eff_val/(5./2. + sqrt(integ)); efficiencies2[i] = efficiency2; effvals[i]=eff_val; std::cout << "\n" << integ << std::endl; std::cout << "\n" << eff_val << std::endl; std::cout << "\n" << efficiency2 << std::endl; */ //double efficiency2_error = efficiency2*sqrt(pow(eff_error/eff_val,2)+(1/(4*sideband_bg_val))*pow(sideband_bg_error/(5/2+sideband_bg_val),2)); //std::cout << "\n\n" << "BDT cut value = " << cut_val << "\n" ; //std::cout << "S = " << sig_val << " +/- " << sig_error << "\n" ; //std::cout << "B = " << bg_val << " +/- " << bg_error << "\n" ; //std::cout << "S/sqrt(S+B) = " << efficiency << " +/- " << efficiency_error << "\n\n" ; //ds.plotOn( plot ); //pdf.plotOn( plot ); //RooPlot* plotPullMass = mass.frame(); //plotPullMass->addPlotable( plot->pullHist() ); //plotPullMass->SetMinimum(); //plotPullMass->SetMaximum(); //std::cout << cut_val; } TCanvas *c1 = new TCanvas(); //double zeros[20]; //for (i=0, i<20, i++) zeros[i]=0.0; TGraphErrors* graph = new TGraphErrors(40, bdt_cuts, efficiencies1, 0, efficiencies1_error); graph->SetTitle("S/sqrt(S+B) vs BDTG3 cut"); //graph->SetMarkerColor(4); //graph->SetMarkerStyle(20); //graph->SetMarkerSize(1.0); graph->GetXaxis()->SetTitle("BDTG3 cut (>)"); graph->GetXaxis()->SetRangeUser(-1.0,1.0); graph->GetYaxis()->SetTitle("S/sqrt(S+B)"); //graph->Fit("pol5"); graph->Draw("AP"); c1->SaveAs("~/cern/plots/bdt_cuts_norm/Lb2JpsipK_2011_2012_BDTG3_cuts_S_sqrtS+B.pdf"); //return c1; //std::cout << efficiencies1_error[5] << std::endl; //gStyle->SetOptFit(1011); /*TCanvas *c2 = new TCanvas(); TGraph* graph2 = new TGraph(40, bdt_cuts, efficiencies2); graph2->SetTitle("eff/[5/2+sqrt(B)] vs BDTG3 cut"); graph2->SetMarkerColor(4); graph2->SetMarkerStyle(20); graph2->SetMarkerSize(1.0); graph2->GetXaxis()->SetTitle("BDTG3 cut (>)"); graph2->GetXaxis()->SetRangeUser(-1.0,1.0); graph2->GetYaxis()->SetTitle("eff/[5/2+sqrt(B)]"); //graph2->Fit("pol7"); graph2->Draw("AP"); c2->SaveAs("~/cern/plots/bdt_cuts_norm/Lb2JpsipK_2011_2012_BDTG3_cuts_Punzi.png"); //return c2; */ /* TCanvas* c = new TCanvas(); TPad* pad1 = new TPad("pad1","pad1", 0, 0.3, 1, 1.0); pad1->SetBottomMargin(0.1); pad1->SetTopMargin(0.1); pad1->Draw(); c->cd(); TPad* pad2 = new TPad("pad2","pad2", 0, 0, 1, 0.3); pad2->SetBottomMargin(0.1); pad2->SetTopMargin(0.0); pad2->Draw(); //pdf.plotOn( plot, RooFit::Components( DfbPdf ), RooFit::LineColor( kRed ), RooFit::LineStyle(kDashed) ); //pdf.plotOn( plot, RooFit::Components( promptPdf ), RooFit::LineColor( kBlue ), RooFit::LineStyle(kDotted) ); //pdf.plotOn( plot, RooFit::Components( bgPdf ), RooFit::LineColor( kOrange ), RooFit::LineStyle(kDashDotted) ); pad1->cd(); plot->Draw(); pad2->cd(); plotPullMass->Draw("AP"); c->SaveAs(out_file_mass); RooStats::SPlot* sData = new RooStats::SPlot("sData","An SPlot", ds, &pdf, RooArgList(sigYield, bgYield) ); RooDataSet * dataw_z = new RooDataSet(ds.GetName(),ds.GetTitle(),&ds,*(ds.get()),0,"sigYield_sw") ; */ /* TCanvas* d = new TCanvas(); RooPlot* w_mass_chicp = mass_chicp.frame(); dataw_z->plotOn(w_mass_chicp, RooFit::DataError(RooAbsData::SumW2), RooFit::Binning(20)) ; w_mass_chicp->Draw(); d->SaveAs("m_chicp_sweighted.png"); TCanvas* e = new TCanvas(); RooPlot* w_mass_pK = mass_pK.frame(); dataw_z->plotOn(w_mass_pK, RooFit::DataError(RooAbsData::SumW2), RooFit::Binning(20)) ; w_mass_pK->Draw(); e->SaveAs("m_pK_sweighted.png"); */ /* TCanvas* f = new TCanvas(); RooPlot* w_mass_Jpsi = mass_Jpsi.frame(); dataw_z->plotOn(w_mass_Jpsi, RooFit::DataError(RooAbsData::SumW2), RooFit::Binning(20)) ; w_mass_Jpsi->Draw(); f->SaveAs("m_Jpsi_sweighted.png"); TCanvas* g = new TCanvas(); RooPlot* w_mass_Chic = mass_Chic.frame(); dataw_z->plotOn(w_mass_Chic, RooFit::DataError(RooAbsData::SumW2), RooFit::Binning(20)) ; w_mass_Chic->Draw(); g->SaveAs("m_Chic_sweighted.png"); */ }
void fit_and_weights_norm(){ gROOT->ProcessLine(".x ~/cern/scripts/lhcbStyle.C"); //lhcbStyle(); gStyle->SetLabelSize(0.05,"x"); gStyle->SetLabelSize(0.05,"y"); gStyle->SetTitleSize(0.05,"x"); gStyle->SetPaperSize(20,26); gStyle->SetPadTopMargin(0.0); gStyle->SetPadRightMargin(0.05); // increase for colz plots gStyle->SetPadBottomMargin(0.0); gStyle->SetPadLeftMargin(0.14); gStyle->SetTitleH(0.01); // const std::string filename("/afs/cern.ch/work/a/apmorris/private/cern/ntuples/new_tuples/normalisation_samples/Lb2JpsipK_2011_2012_signal_withbdt_cut_05.root"); const std::string treename = "withbdt"; const std::string out_file_mass("~/cern/plots/fitting/Lb2JpsipK_2011_2012_mass_fit_after_bdtg3_05.png"); // TFile* file = TFile::Open( filename.c_str() ); if( !file ) std::cout << "file " << filename << " does not exist" << std::endl; TTree* tree = (TTree*)file->Get( treename.c_str() ); if( !tree ) std::cout << "tree " << treename << " does not exist" << std::endl; // -- signal, mass shape RooRealVar Lambda_b0_DTF_MASS_constr1("Lambda_b0_DTF_MASS_constr1","m(#chi_{c}pK^{-})", 5550., 5700., "MeV/c^{2}"); RooRealVar Jpsi_M("Jpsi_M","m(#mu#mu)", 3000., 3200., "MeV/c^{2}"); //RooRealVar chi_c_M("chi_c_M","m(J/#psi#gamma)", 3400., 3700., "MeV/c^{2}"); RooRealVar mean("mean","mean", 5630., 5610., 5650.); RooRealVar sigma1("sigma1","sigma1", 10., 1., 100.); RooRealVar sigma2("sigma2","sigma2", 30.0, 5.0, 300.0); RooRealVar alpha1("alpha1","alpha1", 1.0, 0.5, 5.0); RooRealVar n1("n1","n1", 1.8, 0.2, 15.0); RooRealVar alpha2("alpha2","alpha2", -0.5, -5.5, 0.0); RooRealVar n2("n2","n2", 0.7, 0.2, 10.0); //RooRealVar bkgcat_chic("bkgcat_chic","bkgcat_chic", 0, 100); RooRealVar bdtg3("bdtg3", "bdtg3", -1.0, 1.0); // RooRealVar frac2("frac2","frac2", 0.3, 0., 1.); Lambda_b0_DTF_MASS_constr1.setBins(75); RooGaussian gauss1("gauss1","gauss1", Lambda_b0_DTF_MASS_constr1, mean, sigma1); RooGaussian gauss2("gauss2","gauss2", Lambda_b0_DTF_MASS_constr1, mean, sigma2); RooCBShape cb1("cb1","cb1", Lambda_b0_DTF_MASS_constr1, mean, sigma1, alpha1, n1); RooCBShape cb2("cb2","cb2", Lambda_b0_DTF_MASS_constr1, mean, sigma2, alpha2, n2); RooAddPdf sig("sig", "sig", RooArgList(cb1, cb2), RooArgList( frac2 )); RooRealVar cbRatio("cbRatio","cb Ratio", 0.8, 0.1, 1.0); RooRealVar sigYield("sigYield","sig Yield", 4e2, 1e1, 1e4); RooRealVar bgYield("bgYield","bg Yield", 1e2, 1e0, 5e5); //put in values from fit_MC here <<--- DON'T FORGET TO CHANGE THESE IF THE FIT CHANGES!!! /* EXT PARAMETER INTERNAL INTERNAL NO. NAME VALUE ERROR STEP SIZE VALUE 1 alpha1 1.74154e+00 3.36750e-02 1.24897e-04 -4.64754e-01 2 alpha2 -2.02379e+00 6.38694e-02 1.18078e-04 2.87434e+00 3 cbRatio 3.81630e-01 2.53217e-02 1.04396e-03 -3.83487e-01 4 mean 5.61983e+03 1.06900e-02 5.57074e-05 -9.73350e-02 5 n1 3.61886e+00 1.29299e-01 2.50836e-04 -5.68053e-01 6 n2 3.28978e+00 1.59452e-01 3.00100e-04 -3.78398e-01 7 sigma1 7.37006e+00 1.49989e-01 2.60360e-05 -1.05787e+00 8 sigma2 4.90330e+00 4.88847e-02 5.78092e-06 -1.44570e+00 */ alpha1.setVal( 1.74154e+00 ); alpha2.setVal( -2.02379e+00 ); n1.setVal( 3.61886e+00 ); n2.setVal( 3.28978e+00 ); frac2.setVal( 3.81630e-01 ); sigma1.setVal( 7.37006e+00 ); sigma2.setVal( 4.90330e+00 ); alpha1.setConstant( true ); alpha2.setConstant( true ); frac2.setConstant( true ); n1.setConstant( true ); n2.setConstant( true ); sigma1.setConstant( true ); sigma2.setConstant( true ); // -- bg, mass shape RooRealVar a1("a1","a1", -0.1, -0.5, 0.5); RooChebychev comb("comb","comb", Lambda_b0_DTF_MASS_constr1, a1); RooRealVar mean3("mean3","mean3", 5560., 5500., 5600.); RooRealVar sigma3("sigma3","sigma3", 5., 1., 10.); RooRealVar frac3("frac3","frac", 0.2, 0.0, 0.3); RooGaussian gauss3("gauss3","gauss3", Lambda_b0_DTF_MASS_constr1, mean3, sigma3); RooAddPdf bg("bg","bg", RooArgList(gauss3, comb), RooArgList(frac3)); // -- add signal & bg RooAddPdf pdf("pdf", "pdf", RooArgList(sig, comb), RooArgList( sigYield, bgYield)); RooArgSet obs; obs.add(Lambda_b0_DTF_MASS_constr1); obs.add(Jpsi_M); //obs.add(chi_c_M); //obs.add(proton_ProbNNp); //obs.add(proton_ProbNNk); //obs.add(kaon_ProbNNp); //obs.add(kaon_ProbNNk); RooDataSet ds("ds","ds", obs, RooFit::Import(*tree)); RooPlot* plot = Lambda_b0_DTF_MASS_constr1.frame(); RooFitResult * result = pdf.fitTo( ds, RooFit::Extended() ); ds.plotOn( plot ); pdf.plotOn( plot ); RooPlot* plotPullMass = Lambda_b0_DTF_MASS_constr1.frame(); plotPullMass->addPlotable( plot->pullHist() ); //plotPullMass->SetMinimum(); //plotPullMass->SetMaximum(); TCanvas* c = new TCanvas(); TPad* pad1 = new TPad("pad1","pad1", 0, 0.3, 1, 1.0); pad1->SetBottomMargin(0.0); pad1->SetTopMargin(0.01); pad1->Draw(); c->cd(); TPad* pad2 = new TPad("pad2","pad2", 0, 0., 1, 0.3); pad2->SetBottomMargin(0.0); pad2->SetTopMargin(0.0); pad2->Draw(); pdf.plotOn( plot, RooFit::Components( sig ), RooFit::LineColor( kTeal ), RooFit::LineStyle(kDashed) ); pdf.plotOn( plot, RooFit::Components( comb ), RooFit::LineColor( kOrange ), RooFit::LineStyle(kDashed) ); pdf.plotOn( plot, RooFit::Components( gauss3 ), RooFit::LineColor( kViolet ), RooFit::LineStyle(kDashed) ); pad1->cd(); plot->Draw(); pad2->cd(); plotPullMass->Draw("AP"); c->SaveAs(out_file_mass.c_str()); /* RooStats::SPlot* sData = new RooStats::SPlot("sData","An SPlot", ds, &pdf, RooArgList(sigYield, bgYield) ); RooDataSet * dataw_z = new RooDataSet(ds.GetName(),ds.GetTitle(),&ds,*(ds.get()),0,"sigYield_sw") ; TTree *tree_data = (TTree*)dataw_z->tree(); TFile * newfile = TFile::Open("/afs/cern.ch/work/a/apmorris/private/cern/ntuples/new_tuples/weighted_data.root","RECREATE"); tree_data->Write(); newfile->Close(); */ /* TCanvas* d = new TCanvas(); RooPlot* w_chi_c_Mp = chi_c_Mp.frame(); dataw_z->plotOn(w_chi_c_Mp, RooFit::DataError(RooAbsData::SumW2), RooFit::Binning(20)) ; w_chi_c_Mp->Draw(); d->SaveAs("m_chicp_sweighted.png"); TCanvas* e = new TCanvas(); RooPlot* w_mass_pK = mass_pK.frame(); dataw_z->plotOn(w_mass_pK, RooFit::DataError(RooAbsData::SumW2), RooFit::Binning(20)) ; w_mass_pK->Draw(); e->SaveAs("m_pK_sweighted.png"); */ /* TCanvas* f = new TCanvas(); RooPlot* w_Jpsi_M = Jpsi_M.frame(); dataw_z->plotOn(w_Jpsi_M, RooFit::DataError(RooAbsData::SumW2), RooFit::Binning(20)) ; w_Jpsi_M->Draw(); f->SaveAs("~/cern/plots/m_Jpsi_sweighted.png"); TCanvas* g = new TCanvas(); RooPlot* w_chi_c_M = chi_c_M.frame(); dataw_z->plotOn(w_chi_c_M, RooFit::DataError(RooAbsData::SumW2), RooFit::Binning(20)) ; w_chi_c_M->Draw(); g->SaveAs("~/cern/plots/m_Chic_sweighted.png"); */ }
int WolfeLineSearch(FunctorType &func, Scalar &alpha, XType &x1, Scalar &f1, XType &gradx1, const XType &p, const XType &x0, const Scalar &f0, const XType &gradx0, const Scalar &c1, const Scalar &c2, const Scalar &minAlpha, const Scalar &maxLSIts, const Scalar &maxLSRestarts) { const Scalar dfp(gradx0.dot(p)); const Scalar c1dfp(c1*dfp); const Scalar c2dfp(c2*dfp); Scalar alpha0(minAlpha); Scalar alpha1(alpha); Scalar prevF(f0); XType prevDF(gradx0); Scalar prevDFp(dfp); Scalar newDFp; int retCode = 0, nits = 0, lsRestarts = 0, ret; while (1) { if (nits >= maxLSIts) { retCode = 1; break; } x1.noalias() = x0 + alpha1 * p; ret = func(x1, f1, gradx1); if (ret != 0) { if (lsRestarts >= maxLSRestarts) { retCode = 1; break; } alpha1 = 0.5 * (alpha0 + alpha1); lsRestarts++; continue; } lsRestarts = 0; newDFp = gradx1.dot(p); if ((f1 > f0 + alpha * c1dfp) || (f1 >= prevF && nits > 0)) { retCode = WolfLSZoom(alpha, x1, f1, gradx1, func, x0, f0, dfp, c1dfp, c2dfp, p, alpha0, prevF, prevDFp, alpha1, f1, newDFp, 1e-16); break; } if (std::fabs(newDFp) <= -c2dfp) { alpha = alpha1; break; } if (newDFp >= 0) { retCode = WolfLSZoom(alpha, x1, f1, gradx1, func, x0, f0, dfp, c1dfp, c2dfp, p, alpha1, f1, newDFp, alpha0, prevF, prevDFp, 1e-16); break; } alpha0 = alpha1; prevF = f1; std::swap(prevDF, gradx1); prevDFp = newDFp; alpha1 *= 10.0; nits++; } return retCode; }
void fitGraphs( const ZGConfig& cfg, const std::vector<float> masses, const std::string& width, const std::string& outdir, TFile* outfile, const std::string& name, const std::string& sel ) { std::cout << "+++ STARTING: " << name << std::endl; TString name_tstr(name); std::string plotdir = outdir + "/plots"; system( Form("mkdir -p %s", plotdir.c_str() ) ); TGraphErrors* gr_mean = new TGraphErrors(0); TGraphErrors* gr_sigma = new TGraphErrors(0); TGraphErrors* gr_width = new TGraphErrors(0); TGraphErrors* gr_alpha1 = new TGraphErrors(0); TGraphErrors* gr_n1 = new TGraphErrors(0); TGraphErrors* gr_alpha2 = new TGraphErrors(0); TGraphErrors* gr_n2 = new TGraphErrors(0); gr_mean ->SetName(Form("mean_w%s_%s" , width.c_str(), name.c_str())); gr_sigma ->SetName(Form("sigma_w%s_%s" , width.c_str(), name.c_str())); gr_width ->SetName(Form("width_w%s_%s" , width.c_str(), name.c_str())); gr_alpha1->SetName(Form("alpha1_w%s_%s", width.c_str(), name.c_str())); gr_n1 ->SetName(Form("n1_w%s_%s" , width.c_str(), name.c_str())); gr_alpha2->SetName(Form("alpha2_w%s_%s", width.c_str(), name.c_str())); gr_n2 ->SetName(Form("n2_w%s_%s" , width.c_str(), name.c_str())); TFile* file = TFile::Open( Form("%s/trees.root", cfg.getEventYieldDir().c_str()) ); outfile->cd(); int iPoint = 0; for( unsigned i=0; i<masses.size(); ++i ) { float thisMass = masses[i]; if( thisMass==1250. && name=="mm" && width=="0p014" ) continue; std::cout << "-> Starting mass: " << thisMass << std::endl; std::string signalName; if( thisMass <= 500. ) { signalName = std::string(Form("XZg_Spin0ToZG_ZToLL_W_%s_M_%.0f", width.c_str(), thisMass )); } else { signalName = std::string(Form("GluGluSpin0ToZG_ZToLL_W%s_M%.0f", width.c_str(), thisMass )); } TTree* tree0 = (TTree*)file->Get( signalName.c_str() ); if( tree0 == 0 ) continue; TTree* tree; if( sel=="" ) { tree = tree0; } else { tree = tree0->CopyTree(sel.c_str()); } float maxMassFact = (thisMass>1000. || width=="5p6" ) ? 1.5 : 1.3; RooRealVar x("boss_mass", "boss_mass", thisMass, 0.5*thisMass, maxMassFact*thisMass ); // Crystal-Ball RooRealVar mean( "mean", "mean", thisMass, 0.9*thisMass, 1.1*thisMass ); float sigmaResolution = ( width=="5p6" ) ? 0.03 : 0.015; RooRealVar sigma( "sigma", "sigma", sigmaResolution*thisMass, 0., 0.07*thisMass ); float alpha1_init = (width=="5p6" && thisMass<1000. ) ? 0.8 : 1.2; if( width=="5p6" && thisMass==1500.) alpha1_init=1.4; RooRealVar alpha1( "alpha1", "alpha1", alpha1_init, 0., 2.5 ); RooRealVar n1( "n1", "n1", 3., 0., 5. ); RooRealVar alpha2( "alpha2", "alpha2", 1.2, 0., 2.5 ); RooRealVar n2( "n2", "n2", 3.5, 0., 10. ); RooDoubleCBShape cb( "cb", "cb", x, mean, sigma, alpha1, n1, alpha2, n2 ); RooDataSet* data = new RooDataSet( "data", "data", RooArgSet(x), RooFit::Import(*tree) ); cb.fitTo( *data, RooFit::Strategy(2) ); RooPlot* frame = x.frame(); data->plotOn(frame); cb.plotOn(frame); TCanvas* c1 = new TCanvas("c1", "", 600, 600); c1->cd(); frame->Draw(); c1->SaveAs( Form("%s/fit_%s_m%.0f_w%s.eps", plotdir.c_str(), name.c_str(), thisMass, width.c_str()) ); c1->SaveAs( Form("%s/fit_%s_m%.0f_w%s.pdf", plotdir.c_str(), name.c_str(), thisMass, width.c_str()) ); c1->SetLogy(); c1->SaveAs( Form("%s/fit_%s_m%.0f_w%s_log.eps", plotdir.c_str(), name.c_str(), thisMass, width.c_str()) ); c1->SaveAs( Form("%s/fit_%s_m%.0f_w%s_log.pdf", plotdir.c_str(), name.c_str(), thisMass, width.c_str()) ); delete c1; gr_mean ->SetPoint( iPoint, thisMass, mean.getVal() ); gr_sigma ->SetPoint( iPoint, thisMass, sigma.getVal() ); gr_width ->SetPoint( iPoint, thisMass, sigma.getVal()/mean.getVal() ); gr_alpha1->SetPoint( iPoint, thisMass, alpha1.getVal() ); gr_n1 ->SetPoint( iPoint, thisMass, n1.getVal() ); gr_alpha2->SetPoint( iPoint, thisMass, alpha2.getVal() ); gr_n2 ->SetPoint( iPoint, thisMass, n2.getVal() ); gr_mean ->SetPointError( iPoint, 0., mean.getError() ); gr_sigma ->SetPointError( iPoint, 0., sigma.getError() ); gr_width ->SetPointError( iPoint, 0., sigma.getError()/mean.getVal() ); // random gr_alpha1->SetPointError( iPoint, 0., alpha1.getError() ); gr_n1 ->SetPointError( iPoint, 0., n1.getError() ); gr_alpha2->SetPointError( iPoint, 0., alpha2.getError() ); gr_n2 ->SetPointError( iPoint, 0., n2.getError() ); //gr_width->SetPointError( iPoint, 0., sqrt( sigma.getError()*sigma.getError()/(mean.getVal()*mean.getVal()) + sigma.getVal()*sigma.getVal()*mean.getError()*mean.getError()/(mean.getError()*mean.getError()*mean.getError()*mean.getError()) ) ); iPoint++; delete tree; delete data; } // for i TF1* f1_mean = fitGraph(plotdir, gr_mean , "Gaussian Mean [GeV]"); TF1* f1_sigma = fitGraph(plotdir, gr_sigma , "Gaussian Sigma [GeV]"); TF1* f1_width = fitGraph(plotdir, gr_width , "Gaussian #sigma/#mu"); TF1* f1_alpha1 = fitGraph(plotdir, gr_alpha1, "CB left #alpha"); TF1* f1_n1 = fitGraph(plotdir, gr_n1 , "CB left N"); TF1* f1_alpha2 = fitGraph(plotdir, gr_alpha2, "CB right #alpha"); TF1* f1_n2 = fitGraph(plotdir, gr_n2 , "CB right N"); f1_mean ->Write(); f1_sigma ->Write(); f1_width ->Write(); f1_alpha1->Write(); f1_n1 ->Write(); f1_alpha2->Write(); f1_n2 ->Write(); gr_mean ->Write(); gr_sigma ->Write(); gr_width ->Write(); gr_alpha1->Write(); gr_n1 ->Write(); gr_alpha2->Write(); gr_n2 ->Write(); }
void EmbeddedGMap3::unsewVolumes(Dart d) { Dart dd = alpha1(d); unsigned int fEmb = EMBNULL ; if(isOrbitEmbedded<FACE>()) fEmb = getEmbedding<FACE>(d) ; GMap3::unsewVolumes(d); Dart dit = d; do { // embed the unsewn vertex orbit with the vertex embedding if it is deconnected if(isOrbitEmbedded<VERTEX>()) { if(!sameVertex(dit, dd)) { setOrbitEmbedding<VERTEX>(dit, getEmbedding<VERTEX>(dit)) ; setOrbitEmbeddingOnNewCell<VERTEX>(dd); copyCell<VERTEX>(dd, dit); } else { setOrbitEmbedding<VERTEX>(dit, getEmbedding<VERTEX>(dit)) ; } } dd = phi_1(dd); // embed the unsewn edge with the edge embedding if it is deconnected if(isOrbitEmbedded<EDGE>()) { if(!sameEdge(dit, dd)) { setOrbitEmbedding<EDGE>(dit, getEmbedding<EDGE>(dit)) ; setOrbitEmbeddingOnNewCell<EDGE>(dd); copyCell<EDGE>(dd, dit); } else { setOrbitEmbedding<EDGE>(dit, getEmbedding<EDGE>(dit)) ; } } if(isOrbitEmbedded<FACE>()) { setDartEmbedding<FACE>(beta3(dit), fEmb) ; setDartEmbedding<FACE>(beta0(beta3(dit)), fEmb) ; } dit = phi1(dit); } while(dit != d); // embed the unsewn face with the face embedding if (isOrbitEmbedded<FACE>()) { setOrbitEmbeddingOnNewCell<FACE>(dd); copyCell<FACE>(dd, d); } }
void GSRendererHW::RoundSpriteOffset() { //#define DEBUG_U //#define DEBUG_V #if defined(DEBUG_V) || defined(DEBUG_U) bool debug = linear; #endif size_t count = m_vertex.next; GSVertex* v = &m_vertex.buff[0]; for(size_t i = 0; i < count; i += 2) { // Performance note: if it had any impact on perf, someone would port it to SSE (AKA GSVector) // Compute the coordinate of first and last texels (in native with a linear filtering) int ox = m_context->XYOFFSET.OFX; int X0 = v[i].XYZ.X - ox; int X1 = v[i+1].XYZ.X - ox; int Lx = (v[i+1].XYZ.X - v[i].XYZ.X); float ax0 = alpha0(Lx, X0, X1); float ax1 = alpha1(Lx, X0, X1); int tx0 = Interpolate_UV(ax0, v[i].U, v[i+1].U); int tx1 = Interpolate_UV(ax1, v[i].U, v[i+1].U); #ifdef DEBUG_U if (debug) { fprintf(stderr, "u0:%d and u1:%d\n", v[i].U, v[i+1].U); fprintf(stderr, "a0:%f and a1:%f\n", ax0, ax1); fprintf(stderr, "t0:%d and t1:%d\n", tx0, tx1); } #endif int oy = m_context->XYOFFSET.OFY; int Y0 = v[i].XYZ.Y - oy; int Y1 = v[i+1].XYZ.Y - oy; int Ly = (v[i+1].XYZ.Y - v[i].XYZ.Y); float ay0 = alpha0(Ly, Y0, Y1); float ay1 = alpha1(Ly, Y0, Y1); int ty0 = Interpolate_UV(ay0, v[i].V, v[i+1].V); int ty1 = Interpolate_UV(ay1, v[i].V, v[i+1].V); #ifdef DEBUG_V if (debug) { fprintf(stderr, "v0:%d and v1:%d\n", v[i].V, v[i+1].V); fprintf(stderr, "a0:%f and a1:%f\n", ay0, ay1); fprintf(stderr, "t0:%d and t1:%d\n", ty0, ty1); } #endif #ifdef DEBUG_U if (debug) fprintf(stderr, "GREP_BEFORE %d => %d\n", v[i].U, v[i+1].U); #endif #ifdef DEBUG_V if (debug) fprintf(stderr, "GREP_BEFORE %d => %d\n", v[i].V, v[i+1].V); #endif #if 1 // Use rounded value of the newly computed texture coordinate. It ensures // that sampling will remains inside texture boundary // // Note for bilinear: by definition it will never work correctly! A sligh modification // of interpolation migth trigger a discard (with alpha testing) // Let's use something simple that correct really bad case (for a couple of 2D games). // I hope it won't create too much glitches. if (linear) { int Lu = v[i+1].U - v[i].U; // Note 32 is based on taisho-mononoke if ((Lu > 0) && (Lu <= (Lx+32))) { v[i+1].U -= 8; } } else { if (tx0 <= tx1) { v[i].U = tx0; v[i+1].U = tx1 + 16; } else { v[i].U = tx0 + 15; v[i+1].U = tx1; } } #endif #if 1 if (linear) { int Lv = v[i+1].V - v[i].V; if ((Lv > 0) && (Lv <= (Ly+32))) { v[i+1].V -= 8; } } else { if (ty0 <= ty1) { v[i].V = ty0; v[i+1].V = ty1 + 16; } else { v[i].V = ty0 + 15; v[i+1].V = ty1; } } #endif #ifdef DEBUG_U if (debug) fprintf(stderr, "GREP_AFTER %d => %d\n\n", v[i].U, v[i+1].U); #endif #ifdef DEBUG_V if (debug) fprintf(stderr, "GREP_AFTER %d => %d\n\n", v[i].V, v[i+1].V); #endif } }
Foam::tmp<Foam::volScalarField> Foam::twoPhaseMixtureThermo::kappa() const { return alpha1()*thermo1_->kappa() + alpha2()*thermo2_->kappa(); }
void fit_MC_norm(std::string input_file = "/afs/cern.ch/work/a/apmorris/private/cern/ntuples/new_tuples/normalisation_samples/reduced_Lb2JpsipK_MC_2011_2012_norm.root", std::string out_file_mass = "~/cern/plots/fitting/Lb2JpsipK_MC_2011_2012_cut_mass_fit.png"){ // gROOT->ProcessLine(".L ~/cern/scripts/lhcbStyle.C"); //lhcbStyle(); const std::string filename(input_file.c_str()); const std::string treename = "DecayTree"; TFile* file = TFile::Open( filename.c_str() ); if( !file ) std::cout << "file " << filename << " does not exist" << std::endl; TTree* tree = (TTree*)file->Get( treename.c_str() ); if( !tree ) std::cout << "tree " << treename << " does not exist" << std::endl; // -- signal, mass shape RooRealVar Lambda_b0_DTF_MASS_constr1("Lambda_b0_DTF_MASS_constr1","m(J/#psi pK^{-})", 5450., 5850., "MeV/c^{2}"); RooRealVar Jpsi_M("Jpsi_M","m(#mu#mu)", 3000., 3200., "MeV/c^{2}"); //RooRealVar chi_c_M("chi_c_M","m(J/#psi#gamma)", 3350., 3750., "MeV/c^{2}"); RooRealVar mean("mean","mean", 5620., 5595., 5650.); RooRealVar sigma1("sigma1","sigma1", 10., 1., 100.); RooRealVar sigma2("sigma2","sigma2", 100., 1., 1000.); RooRealVar alpha1("alpha1","alpha1", 1.0, 0.5, 5.0); RooRealVar n1("n1","n1", 1.8, 0.2, 15.0); RooRealVar alpha2("alpha2","alpha2", -0.5, -5.5, 0.0); RooRealVar n2("n2","n2", 0.7, 0.2, 10.0); //RooRealVar bkgcat_chic("bkgcat_chic","bkgcat_chic", 0, 100); RooGaussian gauss1("gauss1","gauss1", Lambda_b0_DTF_MASS_constr1, mean, sigma1); RooGaussian gauss2("gauss2","gauss2", Lambda_b0_DTF_MASS_constr1, mean, sigma2); RooCBShape cb1("cb1","cb1", Lambda_b0_DTF_MASS_constr1, mean, sigma1, alpha1, n1); RooCBShape cb2("cb2","cb2", Lambda_b0_DTF_MASS_constr1, mean, sigma2, alpha2, n2); /* // the chi_c2 component RooRealVar mean3("mean3","mean3", 5570., 5520., 5580.); RooRealVar sigma3("sigma3","sigma3", 10., 1., 20.); RooGaussian gauss3("gauss3","gauss3", Lambda_b0_DTF_MASS_constr1, mean3, sigma3); */ RooRealVar cbRatio("cbRatio","cbRatio", 0.8, 0.1, 1.0); RooRealVar frac2("frac2","frac2", 0.3, 0., 1.); /* alpha1.setVal( 2.1 ); alpha2.setVal( -4.9 ); n1.setVal( 3.2 ); n2.setVal( 7.9 ); cbRatio.setVal( 0.6808 ); alpha1.setConstant( true ); alpha2.setConstant( true ); cbRatio.setConstant( true ); n1.setConstant( true ); n2.setConstant( true ); */ // -- add signal & bg //RooAddPdf pdf("pdf", "pdf", RooArgList(gauss1, gauss2), RooArgList( frac2 )); RooAddPdf pdf("pdf", "pdf", RooArgList(cb1, cb2), RooArgList( cbRatio )); RooArgSet obs; obs.add(Lambda_b0_DTF_MASS_constr1); obs.add(Jpsi_M); //obs.add(chi_c_M); //obs.add(bkgcat_chic); RooDataSet ds("ds","ds", obs, RooFit::Import(*tree)); //RooFit::Cut("Lambda_b0_DTF_MASS_constr1 > 5580") RooPlot* plot = Lambda_b0_DTF_MASS_constr1.frame(); plot->SetAxisRange(5500., 5750.); pdf.fitTo( ds ); ds.plotOn( plot, RooFit::Binning(200) ); pdf.plotOn( plot ); //gauss3.plotOn( plot ); RooPlot* plotPullMass = Lambda_b0_DTF_MASS_constr1.frame(); plotPullMass->addPlotable( plot->pullHist() ); //plotPullMass->SetMinimum(); //plotPullMass->SetMaximum(); plotPullMass->SetAxisRange(5500., 5750.); TCanvas* c = new TCanvas(); c->cd(); TPad* pad1 = new TPad("pad1","pad1", 0, 0.3, 1, 1.0); pad1->SetBottomMargin(0.1); pad1->SetTopMargin(0.1); pad1->Draw(); //TPad* pad2 = new TPad("pad2","pad2", 0, 0.05, 1, 0.4); TPad* pad2 = new TPad("pad2","pad2", 0, 0, 1, 0.3); pad2->SetBottomMargin(0.1); pad2->SetTopMargin(0.0); pad2->Draw(); pdf.plotOn( plot, RooFit::Components( cb1 ), RooFit::LineColor( kRed ), RooFit::LineStyle(kDashed) ); pdf.plotOn( plot, RooFit::Components( cb2 ), RooFit::LineColor( kOrange ), RooFit::LineStyle(kDotted) ); //pdf.plotOn( plot, RooFit::Components( bgPdf ), RooFit::LineColor( kBlue ), RooFit::LineStyle(kDashDotted) ); pad1->cd(); //pad1->SetLogy(); plot->Draw(); pad2->cd(); plotPullMass->Draw("AP"); c->SaveAs(out_file_mass.c_str()); }
Foam::tmp<Foam::volScalarField> Foam::twoPhaseMixtureThermo::nu() const { return mu()/(alpha1()*thermo1_->rho() + alpha2()*thermo2_->rho()); }
void fitSingleMass( const std::string& basedir, float mass, const std::string& width, TGraphErrors* gr_mean, TGraphErrors* gr_sigma, TGraphErrors* gr_width, TGraphErrors* gr_alpha1, TGraphErrors* gr_n1, TGraphErrors* gr_alpha2, TGraphErrors* gr_n2 ) { std::string outdir = "genSignalShapes"; system( Form("mkdir -p %s", outdir.c_str()) ); std::string dataset( Form( "GluGluSpin0ToZGamma_ZToLL_W_%s_M_%.0f_TuneCUEP8M1_13TeV_pythia8", width.c_str(), mass ) ); std::cout << "-> Starting: " << dataset << std::endl; system( Form("ls %s/%s/crab_%s/*/0000/genAna_1.root >> toBeAdded.txt", basedir.c_str(), dataset.c_str(), dataset.c_str() ) ); TChain* tree = new TChain("mt2"); ifstream ifs("toBeAdded.txt"); while( ifs.good() ) { std::string fileName; ifs >> fileName; TString fileName_tstr(fileName); if( !fileName_tstr.Contains("pnfs") ) continue; tree->Add(Form("$DCAP/%s/mt2", fileName.c_str()) ); } system( "rm toBeAdded.txt" ); if( tree->GetEntries()==0 ) return; int ngenPart; tree->SetBranchAddress( "ngenPart", &ngenPart ); float genPart_pt[100]; tree->SetBranchAddress( "genPart_pt", genPart_pt ); float genPart_eta[100]; tree->SetBranchAddress( "genPart_eta", genPart_eta ); float genPart_phi[100]; tree->SetBranchAddress( "genPart_phi", genPart_phi ); float genPart_mass[100]; tree->SetBranchAddress( "genPart_mass", genPart_mass ); int genPart_pdgId[100]; tree->SetBranchAddress( "genPart_pdgId", genPart_pdgId ); int genPart_motherId[100]; tree->SetBranchAddress( "genPart_motherId", genPart_motherId ); int genPart_status[100]; tree->SetBranchAddress( "genPart_status", genPart_status ); RooRealVar* x = new RooRealVar("boss_mass", "boss_mass", mass, 0.5*mass, 1.5*mass ); RooDataSet* data = new RooDataSet( "data", "data", RooArgSet(*x) ); int nentries = tree->GetEntries(); for( int iEntry = 0; iEntry<nentries; ++iEntry ) { if( iEntry % 25000 == 0 ) std::cout << " Entry: " << iEntry << " / " << nentries << std::endl; tree->GetEntry(iEntry); TLorentzVector leptPlus; TLorentzVector leptMinus; TLorentzVector photon; bool foundLeptPlus = false; bool foundLeptMinus = false; bool foundPhoton = false; bool tauEvent = false; for( int iPart=0; iPart<ngenPart; ++iPart ) { if( genPart_status[iPart]!=1 ) continue; if( abs(genPart_pdgId[iPart])==15 ) { tauEvent = true; break; } if( (genPart_pdgId[iPart]==+11 || genPart_pdgId[iPart]==+13) && genPart_motherId[iPart]==23 ) { leptMinus.SetPtEtaPhiM( genPart_pt[iPart], genPart_eta[iPart], genPart_phi[iPart], genPart_mass[iPart] ); foundLeptMinus = true; } if( (genPart_pdgId[iPart]==-11 || genPart_pdgId[iPart]==-13) && genPart_motherId[iPart]==23 ) { leptPlus.SetPtEtaPhiM( genPart_pt[iPart], genPart_eta[iPart], genPart_phi[iPart], genPart_mass[iPart] ); foundLeptPlus = true; } if( genPart_pdgId[iPart]==22 && genPart_motherId[iPart]==25 ) { photon.SetPtEtaPhiM( genPart_pt[iPart], genPart_eta[iPart], genPart_phi[iPart], genPart_mass[iPart] ); foundPhoton = true; } } // for genparts if( tauEvent ) continue; if( !foundLeptPlus || !foundLeptMinus || !foundPhoton ) continue; if( photon.Pt() < 40. ) continue; float ptMax = TMath::Max( leptPlus.Pt(), leptMinus.Pt() ); float ptMin = TMath::Min( leptPlus.Pt(), leptMinus.Pt() ); if( ptMax<25. ) continue; if( ptMin<20. ) continue; if( fabs( photon.Eta() ) > 2.5 ) continue; if( fabs( photon.Eta())>1.44 && fabs( photon.Eta())<1.57 ) continue; if( fabs( leptPlus.Eta() ) > 2.4 ) continue; if( fabs( leptMinus.Eta() ) > 2.4 ) continue; if( photon.DeltaR( leptPlus ) < 0.4 ) continue; if( photon.DeltaR( leptMinus ) < 0.4 ) continue; TLorentzVector zBoson = leptPlus + leptMinus; if( zBoson.M() < 50. ) continue; TLorentzVector boss = zBoson + photon; if( boss.M() < 200. ) continue; if( photon.Pt()/boss.M()< 40./150. ) continue; x->setVal(boss.M()); data->add(RooArgSet(*x)); } //RooRealVar* bw_mean = new RooRealVar( "bw_mean", "Breit-Wigner Mean" , mass, 0.2*mass, 1.8*mass ); //RooRealVar* bw_gamma = new RooRealVar( "bw_gamma", "Breit-Wigner Width", 0.01*mass, 0., 0.3*mass ); //RooBreitWigner* model = new RooBreitWigner( "bw", "Breit-Wigner", *x, *bw_mean, *bw_gamma); // Crystal-Ball RooRealVar mean( "mean", "mean", mass, 0.9*mass, 1.1*mass ); RooRealVar sigma( "sigma", "sigma", 0.015*mass, 0., 0.07*mass ); RooRealVar alpha1( "alpha1", "alpha1", 1.2, 0., 2.5 ); RooRealVar n1( "n1", "n1", 3., 0., 5. ); RooRealVar alpha2( "alpha2", "alpha2", 1.2, 0., 2.5 ); RooRealVar n2( "n2", "n2", 3., 0., 10. ); RooDoubleCBShape* model = new RooDoubleCBShape( "cb", "cb", *x, mean, sigma, alpha1, n1, alpha2, n2 ); model->fitTo( *data ); int npoints = gr_mean->GetN(); gr_mean ->SetPoint( npoints, mass, mean.getVal() ); gr_sigma ->SetPoint( npoints, mass, sigma.getVal() ); gr_width ->SetPoint( npoints, mass, sigma.getVal()/mean.getVal() ); gr_alpha1->SetPoint( npoints, mass, alpha1.getVal() ); gr_alpha2->SetPoint( npoints, mass, alpha2.getVal() ); gr_n1 ->SetPoint( npoints, mass, n1.getVal() ); gr_n2 ->SetPoint( npoints, mass, n2.getVal() ); gr_mean ->SetPointError( npoints, 0., mean.getError() ); gr_sigma ->SetPointError( npoints, 0., sigma.getError() ); gr_width ->SetPointError( npoints, 0., sigma.getError()/mean.getVal() ); gr_alpha1->SetPointError( npoints, 0., alpha1.getError() ); gr_alpha2->SetPointError( npoints, 0., alpha2.getError() ); gr_n1 ->SetPointError( npoints, 0., n1.getError() ); gr_n2 ->SetPointError( npoints, 0., n2.getError() ); //gr_mean ->SetPoint ( npoints, mass, bw_mean->getVal() ); //gr_gamma->SetPoint ( npoints, mass, bw_gamma->getVal() ); //gr_width->SetPoint ( npoints, mass, bw_gamma->getVal()/bw_mean->getVal() ); //gr_mean ->SetPointError( npoints, 0., bw_mean->getError() ); //gr_gamma->SetPointError( npoints, 0., bw_gamma->getError()/bw_mean->getVal() ); //gr_width->SetPointError( npoints, 0., bw_gamma->getError()/bw_mean->getVal() ); RooPlot* plot = x->frame(); data->plotOn(plot); model->plotOn(plot); TCanvas* c1 = new TCanvas( "c1", "", 600, 600 ); c1->cd(); plot->Draw(); c1->SaveAs( Form("%s/fit_m%.0f_%s.eps", outdir.c_str(), mass, width.c_str()) ); c1->SaveAs( Form("%s/fit_m%.0f_%s.pdf", outdir.c_str(), mass, width.c_str()) ); c1->SetLogy(); c1->SaveAs( Form("%s/fit_m%.0f_%s_log.eps", outdir.c_str(), mass, width.c_str()) ); c1->SaveAs( Form("%s/fit_m%.0f_%s_log.pdf", outdir.c_str(), mass, width.c_str()) ); //delete bw_mean; //delete bw_gamma; delete c1; delete data; delete model; delete plot; delete x; }