void Foam::relativeVelocityModel::update() { tmp<volVectorField> URel(Ur()); tmp<volScalarField> betaC(alphaC_*rhoC_); tmp<volScalarField> betaD(alphaD_*rhoD_); tmp<volScalarField> rhoM(betaC() + betaD()); tmp<volVectorField> Udm = URel()*betaC()/rhoM; tmp<volVectorField> Ucm = Udm() - URel; Udm_ = Udm(); tau_ = betaD*sqr(Udm) + betaC*sqr(Ucm); }
RVector DC1dModellingC::response(const RVector & model) { if (model.size() < (nlayers_ * 3 - 1)){ throwError(1, WHERE_AM_I + " model vector to small: nlayers_ * 2 + 1 = " + toStr(nlayers_ * 3 - 1) + " > " + toStr(model.size())); } if (model.size() > (nlayers_ * 3 - 1)){ throwError(1, WHERE_AM_I + " model vector to large: nlayers_ * 2 + 1 = " + toStr(nlayers_ * 3 - 1) + " < " + toStr(model.size())); } RVector thk(model(0, nlayers_ -1)); RVector rhoM(model(nlayers_ - 1, 2 * nlayers_ -1)); RVector rhoP(- model(2 * nlayers_ -1, 3 * nlayers_ -1)); // for (size_t i = 0 ; i < nlayers_ -1 ; i++) thk[i] = model[i]; // for (size_t i = 0 ; i < nlayers_ ; i++) rhoM[i] = model[nlayers_ + i -1]; // for (size_t i = 0 ; i < nlayers_ ; i++) rhoP[i] = - model[2 * nlayers_ + i -1]; CVector rhoC = toComplex(RVector(rhoM * cos(rhoP)), RVector(rhoM * sin(rhoP))); CVector rhoaC = rhoaT< CVector >(rhoC, thk); RVector angPlus = abs(angle(rhoaC)); return cat(abs(rhoaC), angPlus); }
void gatherAEff(const char *inpFile=NULL) { std::string line; std::vector<std::string> lines; if (!inpFile) { std::cout << "\ninpFile=NULL\n"; std::cout << "Creating sample input file\n"; const char *sampleFName="aeff_sample.inp"; std::ofstream fout(sampleFName); fout << "../root_files/constants/DY_j22_19789pb/acceptance_constants1D.root\n"; fout << "../root_files/constants/DY_j22_19789pb/event_efficiency_constants1D.root\n"; fout << "../root_files/constants/DY_j22_19789pb/scale_factors_1D_Full2012_hltEffOld_PU.root\n"; fout.close(); std::cout << "check the file <" << sampleFName << ">\n"; std::cout << "1D/2D in the name does not matter\n"; return; } else { // load input std::ifstream finput(inpFile); if (!finput) { std::cout << "failed to open file <" << inpFile << ">\n"; return; } getline(finput,line); lines.push_back(line); std::cout << "line1=<" << line << ">\n"; getline(finput,line); lines.push_back(line); std::cout << "line2=<" << line << ">\n"; getline(finput,line); lines.push_back(line); std::cout << "line3=<" << line << ">\n"; finput.close(); } std::cout << dashline; std::string fnameAcc,fnameEff,fnameRho; int count=0; for (unsigned int i=0; i<lines.size(); ++i) { line=lines[i]; AdjustDim(line); if (PosOk(line,"acceptance")) { fnameAcc=line; count++; } else if (PosOk(line,"efficiency")) { fnameEff=line; count++; } else if (PosOk(line,"scale_factors")) { fnameRho=line; count++; } else { std::cout << "could not identify the file <" << line << ">\n"; return; } } if (count!=3) { std::cout << "not all files were identified\n"; return; } std::cout << "files were identified ok\n"; std::cout << dashline; TMatrixD effM(DYTools::nMassBins,DYTools::nYBinsMax); TMatrixD effErrM(effM); TMatrixD accM(effM), accErrM(effM); TMatrixD rhoM(effM), rhoErrM(effM); if (!LoadMatrix(fnameAcc,accM,accErrM,"acceptanceMatrix","acceptanceErrMatrix") || !LoadMatrix(fnameEff,effM,effErrM,"efficiencyArray","efficiencyErrArray") || !LoadMatrix(fnameRho,rhoM,rhoErrM,"scaleFactor","scaleFactorErr") ) { std::cout << "failed to load field\n"; return; } TString outFName; if (DYTools::study2D) { outFName="dyee_aeff_2D.root"; TFile fout(outFName,"recreate"); accM.Write("acceptance"); accErrM.Write("acceptanceErr"); effM.Write("efficiency"); effErrM.Write("efficiencyErr"); rhoM.Write("scaleFactor"); rhoErrM.Write("scaleFactorErr"); unfolding::writeBinningArrays(fout); for (int i=0; i<DYTools::nMassBins; ++i) { TString massRange=Form("_%1.0lf_%2.0lf",DYTools::massBinLimits[i],DYTools::massBinLimits[i+1]); TString hAccName=TString("hAcc") + massRange; Histo_t *hAcc=extractRapidityDependence(hAccName,"",accM,accErrM,i,0); TString hEffName=TString("hEff") + massRange; Histo_t *hEff=extractRapidityDependence(hEffName,"",effM,effErrM,i,0); TString hRhoName=TString("hRho") + massRange; Histo_t *hRho=extractRapidityDependence(hRhoName,"",rhoM,rhoErrM,i,0); if (!hAcc || !hEff || !hRho) { std::cout << "got unexpected null histo\n"; break; } hAcc->Write(); hEff->Write(); hRho->Write(); } fout.Close(); } else { // 1D case outFName="dyee_aeff_1D.root"; std::cout << "accM: rows " << accM.GetNrows() << ", cols " << accM.GetNcols() << "\n"; TVectorD eff(DYTools::nMassBins), effErr(eff); TVectorD acc(eff), accErr(eff); TVectorD rho(eff), rhoErr(eff); GetMassProfile1D(accM,accErrM, acc,accErr); GetMassProfile1D(effM,effErrM, eff,effErr); GetMassProfile1D(rhoM,rhoErrM, rho,rhoErr); Histo_t *hAcc=extractMassDependence("hAcc","",accM,accErrM,0,0,0); Histo_t *hEff=extractMassDependence("hEff","",effM,effErrM,0,0,0); Histo_t *hRho=extractMassDependence("hRho","",rhoM,rhoErrM,0,0,0); if (!hAcc || !hEff || !hRho) { std::cout << "got unexpected null histo\n"; } else { TFile fout(outFName,"recreate"); acc.Write("acceptance"); accErr.Write("acceptanceErr"); eff.Write("efficiency"); effErr.Write("efficiencyErr"); rho.Write("scaleFactor"); rhoErr.Write("scaleFactorErr"); unfolding::writeBinningArrays(fout); hAcc->Write(); hEff->Write(); hRho->Write(); fout.Close(); } } std::cout << "file <" << outFName << "> created\n"; return; }
int main(){ LHDlib::RhoTable rhoTable; // rhoTable.read("C:\\Users\\KeisukeFujii\\Dropbox\\visual_studio\\LHDdata\\flx\\lhd-r375q100b000a8020.flx"); rhoTable.read("C:\\Users\\KeisukeFujii\\Dropbox\\visual_studio\\LHDdata\\flx\\lhd-r390q100g120b000a8020.flx"); size_t size = 100; std::vector<double> R_10(size), Z_10(size); std::vector<double> R_11(size), Z_11(size); std::vector<double> R_12(size), Z_12(size); for (size_t i = 0; i < size; ++i){ double theta = 2.0*myconst::pi / size*i; rhoTable.getRZfromRhoThetaPhi(1.0, theta, myconst::pi/10.0, R_10[i], Z_10[i]); rhoTable.getRZfromRhoThetaPhi(1.1, theta, myconst::pi/10.0, R_11[i], Z_11[i]); rhoTable.getRZfromRhoThetaPhi(1.2, theta, myconst::pi/10.0, R_12[i], Z_12[i]); } IGORdata::write_itx(R_10, Z_10, "RZ_10.itx", "RR_10", "ZZ_10"); IGORdata::write_itx(R_11, Z_11, "RZ_11.itx", "RR_11", "ZZ_11"); IGORdata::write_itx(R_12, Z_12, "RZ_12.itx", "RR_12", "ZZ_12"); size = 48; std::vector<double> rho(size), Vp(size), dVpdrho(size), dVdrho(size); for (size_t i = 0; i < size; ++i){ rho[i] = 1.2 / size*i; Vp[i] = rhoTable.get_Vp(0.0, rho[i]); dVpdrho[i] = rhoTable.get_dVpdrho(rho[i]); dVdrho[i] = rhoTable.get_dVdrho(rho[i]); } IGORdata::write_itx(rho, Vp, "rho_Vp.itx", "rho", "Vp"); IGORdata::write_itx(dVpdrho, dVdrho, "dVdrho.itx", "dVpdrho", "dVdrho"); size_t xsize = 100, ysize(101); std::vector<double> xaxis(xsize), yaxis(ysize); std::vector<std::vector<double>> rhoM(xsize), theta(xsize), drhodx(xsize), drhody(xsize), drhodz(xsize); for (size_t i = 0; i < xsize; ++i) xaxis[i] = 2.5 + 2.5 / xsize * i; for (size_t i = 0; i < ysize; ++i) yaxis[i] = -1.0 + 2.0 / ysize * i; for (size_t i = 0; i < xsize; ++i){ for (size_t j = 0; j < ysize; ++j){ double rho_, theta_; double drhodx_[3]; rhoTable.get_rho_drho(xaxis[i], yaxis[j], myconst::pi*0.1, &rho_, &theta_, drhodx_); rhoM[i].push_back(rho_); theta[i].push_back(theta_); drhodx[i].push_back(drhodx_[0]); drhody[i].push_back(drhodx_[1]); drhodz[i].push_back(drhodx_[2]); } } IGORdata::write_edgeVector(xaxis, "xaxis.itx", "xaxis"); IGORdata::write_edgeVector(yaxis, "yaxis.itx", "yaxis"); IGORdata::write_itx(rhoM, "rhoMatrix.itx", "rhoMatrix"); IGORdata::write_itx(theta, "theta.itx", "theta"); IGORdata::write_itx(drhodx, "drhodx.itx", "drhodx"); IGORdata::write_itx(drhody, "drhody.itx", "drhody"); IGORdata::write_itx(drhodz, "drhodz.itx", "drhodz"); return 0; }