void cmd_nlls() { Real *work, *y, *bounds, *covar, *p; int nQ = count_data(); int ndim = fit[0].pars.n; int i; /* Allocate storage: y, covar, bounds, p */ work = (Real *)malloc(sizeof(Real)*(nQ + ndim*ndim + 3*ndim)); assert(work != NULL); y = work; bounds = y + nQ; covar = bounds + 2*ndim; p = covar + ndim*ndim; write_pop(&set); /* In case fit crashes */ /* Record what we are doing */ if (parFD != NULL) { fprintf(parFD,"# %15d Starting Levenberg-Marquardt\n", GetGen(&set)); fflush(parFD); } /* Copy normalized data values */ copy_normalized_data(y); /* Set bounds */ for (i=0; i < ndim; i++) { bounds[i] = 0.; bounds[i+ndim] = 1.; } /* Get best into p */ pars_set(&fit[0].pars, bestpars); pars_get01(&fit[0].pars, p); /* Call nlls */ tic(); #if 1 box_nlls(step_nlls, ndim, nQ, fit, y, bounds, p, covar); #else nlls(step_nlls, ndim, nQ, fit, y, p, covar); #endif printf("Done LM\n");fflush(stdout); toc(); print_covar(ndim,covar); /* Record LM results */ log_best(); /* Inject new p into the GA */ setChromosome(&set, 0, p); /* Done */ free(work); }
const CAuth_list& CPub::GetAuthors (void) const { switch (Which()) { case CPub::e_Gen : return (GetGen().GetAuthors()); case CPub::e_Sub : return (GetSub().GetAuthors()); case CPub::e_Article : return (GetArticle().GetAuthors()); case CPub::e_Book : return (GetBook().GetAuthors()); case CPub::e_Proc : return (GetProc().GetBook().GetAuthors()); case CPub::e_Patent : return (GetPatent().GetAuthors()); case CPub::e_Man : return (GetMan().GetCit().GetAuthors()); default : NCBI_THROW(CSerialException, eNotImplemented, "CPub::GetAuthors: unsupported entry type " + SelectionName(Which())); } }
bool CPub::IsSetAuthors(void) const { switch (Which()) { case CPub::e_Gen : return (GetGen().IsSetAuthors()); case CPub::e_Sub : return (GetSub().IsSetAuthors()); case CPub::e_Article : return (GetArticle().IsSetAuthors()); case CPub::e_Book : return (GetBook().IsSetAuthors()); case CPub::e_Proc : return (GetProc().IsSetBook() && GetProc().GetBook().IsSetAuthors()); case CPub::e_Patent : return (GetPatent().IsSetAuthors()); case CPub::e_Man : return (GetMan().IsSetCit() && GetMan().GetCit().IsSetAuthors()); default : break; } return false; }
void ZShape2dMC(){ double signal_weight = 3531.89/30459500.;//3504 if (!doMG) signal_weight = 1966.7 / 42705454.; // TH1D* mc_truegen; vector<TH1D*> mc_truegen_cteq, mc_truegen_fsr_pileup; GetGen(signal_weight, mc_truegen, mc_truegen_cteq, mc_truegen_fsr_pileup); cout<<"Get MC distribution"<<endl; vector<TGraphAsymmErrors*> g_MC_phistar; TGraphAsymmErrors* g_MC_phistar_temp1=ConvertToTGraph(mc_truegen); g_MC_phistar.push_back(g_MC_phistar_temp1); vector<TGraphAsymmErrors*> g_MC_phistar_cteq; for (size_t u=0; u<mc_truegen_cteq.size(); u++){ TGraphAsymmErrors* g_MC_phistar_temp=ConvertToTGraph(mc_truegen_cteq[u]); g_MC_phistar_cteq.push_back(g_MC_phistar_temp); } vector<TGraphAsymmErrors*> g_MC_phistar_fsr_pileup; for (size_t u=0; u<mc_truegen_fsr_pileup.size(); u++){ TGraphAsymmErrors* g_MC_phistar_temp=ConvertToTGraph(mc_truegen_fsr_pileup[u]); g_MC_phistar_fsr_pileup.push_back(g_MC_phistar_temp); } vector<TGraphAsymmErrors *> g_MC_norm = CreateCopy(g_MC_phistar); vector<TGraphAsymmErrors *> g_MC_norm_cteq = CreateCopy(g_MC_phistar_cteq); vector<TGraphAsymmErrors *> g_MC_norm_fsr_pileup = CreateCopy(g_MC_phistar_fsr_pileup); NormalizeGraph(g_MC_phistar, 0); NormalizeGraph(g_MC_phistar_cteq, 0); NormalizeGraph(g_MC_phistar_fsr_pileup, 0); NormalizeGraph(g_MC_norm, 1); NormalizeGraph(g_MC_norm_cteq, 1); NormalizeGraph(g_MC_norm_fsr_pileup, 1); TGraphAsymmErrors* g_syst_mc_cteq = CalcTotalSysU_updown(g_MC_phistar_cteq,g_MC_phistar_cteq[0],1,1); TGraphAsymmErrors* g_syst_mc_fsr = CalcTotalSysU_fsr(g_MC_phistar_fsr_pileup[0],g_MC_phistar[0]); TGraphAsymmErrors* g_syst_norm_mc_cteq = CalcTotalSysU_updown(g_MC_norm_cteq,g_MC_norm_cteq[0],1,1); TGraphAsymmErrors* g_syst_norm_mc_fsr = CalcTotalSysU_fsr(g_MC_norm_fsr_pileup[0],g_MC_norm[0]); vector<TGraphAsymmErrors *> g_mc_syst; g_mc_syst.push_back(g_MC_phistar[0]); g_mc_syst.push_back(g_syst_mc_fsr); if (!doMG) g_mc_syst.push_back(g_syst_mc_cteq); vector<std::string> syst_mc_list; syst_mc_list.push_back("unfolding"); syst_mc_list.push_back("fsr"); if (!doMG) syst_mc_list.push_back("cteq"); TGraphAsymmErrors* g_mc_final=GetMCFinal(g_mc_syst, syst_mc_list, 0); vector<TGraphAsymmErrors *> g_mc_syst_norm; g_mc_syst_norm.push_back(g_MC_norm[0]); g_mc_syst_norm.push_back(g_syst_norm_mc_fsr); if (!doMG) g_mc_syst_norm.push_back(g_syst_norm_mc_cteq); vector<std::string> syst_mc_list_norm; syst_mc_list_norm.push_back("unfolding"); syst_mc_list_norm.push_back("fsr"); if (!doMG) syst_mc_list_norm.push_back("cteq"); TGraphAsymmErrors* g_mc_final_norm=GetMCFinal(g_mc_syst_norm, syst_mc_list_norm, 1); string textn="Output/TESTMC_Graph_Abs_"; if (doMG) textn+="MG_"; else textn+="PH_"; if (elec==0)textn+="Dressed.root"; if (elec==1)textn+="Born.root"; if (elec==2)textn+="Naked.root"; TFile tr2(textn.c_str(),"RECREATE"); g_mc_final->Write(); textn="Output/TESTMC_Graph_Norm_"; if (doMG) textn+="MG_"; else textn+="PH_"; if (elec==0)textn+="Dressed.root"; if (elec==1)textn+="Born.root"; if (elec==2)textn+="Naked.root"; TFile tr3(textn.c_str(),"RECREATE"); g_mc_final_norm->Write(); }
// Appends a label to "label" bool CPub::GetLabel(string* label, ELabelType type, TLabelFlags flags, ELabelVersion version) const { static const char* s_PubTypes[14] = { "Unknown", "Generic", "Submit", "Medline", "MUID", "Article", "Journal", "Book", "Proceedings", "Patent", "PatID", "Manuscript", "Equiv", "PMID" }; // Check that label exists if (!label) { return false; } // Get the index into the s_PubTypes array corresponding to pub type int idx = static_cast<int>(Which()); idx = idx >= 0 && idx < 14 ? idx : 0; if (type == eType) { // Append pub type to label and return *label += s_PubTypes[idx]; return true; } if (type == eBoth) { // Append pub type to label *label += string(s_PubTypes[idx]) + ": "; } switch (Which()) { case e_Muid: *label += "NLM" + NStr::IntToString(GetMuid()); return true; case e_Pmid: *label += "PM" + NStr::IntToString(GetPmid().Get()); return true; case e_Equiv: return GetEquiv().GetLabel(label, flags, version); case e_Medline: return GetMedline().GetLabel(label, flags, version); case e_Article: return GetArticle().GetLabel(label, flags, version); case e_Journal: return GetJournal().GetLabel(label, flags, version); case e_Book: return GetBook().GetLabel(label, flags, version); case e_Proc: return GetProc().GetLabel(label, flags, version); case e_Man: return GetMan().GetLabel(label, flags, version); case e_Sub: return GetSub().GetLabel(label, flags, version); case e_Patent: return GetPatent().GetLabel(label, flags, version); case e_Pat_id: return GetPat_id().GetLabel(label, flags, version); case e_Gen: return GetGen().GetLabel(label, flags, version); default: return false; } }
void CPub::GetTitles( TOneTitleRefVec & out_title, size_t iMaxToGet ) const { // this "if" lets us assume below this point that // we have room for at least one if( iMaxToGet <= 0 ) { return; } switch( Which() ) { case CPub::e_not_set: case CPub::e_Medline: case CPub::e_Pmid: case CPub::e_Pat_id: // these types don't have titles, so nothing to do break; case CPub::e_Gen: if( GetGen().IsSetTitle() ) { out_title.push_back( xs_GetTitleFromPlainString( GetGen().GetTitle()) ); } break; case CPub::e_Sub: if( GetSub().IsSetDescr() ) { out_title.push_back( xs_GetTitleFromPlainString( GetSub().GetDescr()) ); } break; case CPub::e_Article: if( GetArticle().IsSetTitle() && GetArticle().GetTitle().IsSet() ) { xs_AppendTitles( out_title, iMaxToGet, GetArticle().GetTitle() ); } break; case CPub::e_Journal: if( GetJournal().IsSetTitle() ) { xs_AppendTitles( out_title, iMaxToGet, GetJournal().GetTitle() ); } break; case CPub::e_Book: if( GetBook().IsSetTitle() ) { xs_AppendTitles( out_title, iMaxToGet, GetBook().GetTitle() ); } break; case CPub::e_Proc: // what to do here? It has a book and meeting // It's not entirely clear if this is the best course of action if( FIELD_CHAIN_OF_2_IS_SET(GetProc(), Book, Title) ) { xs_AppendTitles( out_title, iMaxToGet, GetProc().GetBook().GetTitle() ); } break; case CPub::e_Patent: if( GetPatent().IsSetTitle() ) { out_title.push_back( xs_GetTitleFromPlainString( GetPatent().GetTitle()) ); } break; case CPub::e_Man: if( FIELD_CHAIN_OF_2_IS_SET(GetMan(), Cit, Title) ) { xs_AppendTitles( out_title, iMaxToGet, GetMan().GetCit().GetTitle() ); } break; case CPub::e_Equiv: { size_t iMaxTitleSizeAllowed = ( out_title.size() + iMaxToGet ); if( iMaxTitleSizeAllowed < out_title.size() ) { // integer overflowed iMaxTitleSizeAllowed = std::numeric_limits<std::size_t>::max(); } FOR_EACH_PUB_ON_PUBEQUIV(pub_it, GetEquiv()) { if( out_title.size() >= iMaxTitleSizeAllowed ) { break; } // dig down recursively (*pub_it)->GetTitles(out_title, (iMaxTitleSizeAllowed - out_title.size()) ); } } break; default: NCBI_THROW(CException, eUnknown, "unhandled pub type"); } }