void HarmonySearchUnitTests::TestIteration() {
    HarmonyCompare const& hc = *m_pCompare;
    for (unsigned int iter = 0; iter < 10; ++iter) {
        m_pSearch->Iterate();
        for (unsigned i = 0; i < m_memory-1; ++i) {
            Harmony const* r1 = m_pSearch->GetRanked(i);
            Harmony const* r2 = m_pSearch->GetRanked(i+1);
            bool success = (hc(r1, r2) || (!hc(r1, r2) && !hc(r1, r2)));
            CPPUNIT_ASSERT(success);
            delete r1;
            delete r2;
        }
    }
}
Пример #2
0
/* Test setting coefficients on hypercube_lowd */
int hc_setting() {
	int L = 2;
	double additive[L];

	for(int i=0; i<L;i++) {
		additive[i] = 3;
	}

	hypercube_lowd hc(3, L);
	hc.reset();
	hc.additive(additive);
	hc.fft_coeff_to_func();
	
	if(LOWD_VERBOSE){
		cerr<<"Func values: ";
		for(int gt=0; gt < (1<<L); gt++)
			cerr<<hc.get_func(gt)<<" ";
		cerr<<endl;

		cerr<<"Coeff values: ";
		for(int gt=0; gt < (1<<L); gt++)
			cerr<<hc.get_coeff(gt)<<" ";
		cerr<<endl;
	}
	return 0;
}
Пример #3
0
int doMatrix(default_unli_t* default_unli)
{
    HttpClient hc(Config::getMatrixKey(), Config::getMatrixCert(), Config::getMatrixCacert(), Config::getMatrixIgnoreCert());
    std::string req = "{"
                      "  \"productName\" : \"ROAMSURF599\","
                      "  \"msisdn\" : \"" + std::string(default_unli->msisdn) + "\","
                      "  \"startDate\" : \"" + std::string(default_unli->start_date) + "\","
                      "  \"endDate\" : \"" + std::string(default_unli->end_date) + "\","
                      "  \"country\" : \"" + std::string(default_unli->mcc) + "\","
                      "  \"roamingPartner\" : \"" + std::string(default_unli->mnc) + "\""
                      "}";
    std::vector<string> headers;
                        headers.push_back(std::string("Authorization: Bearer ") + Config::getMatrixAuthToken());
                        headers.push_back(std::string("TransactionCode: ") + Config::getMatrixTranCode());
                        headers.push_back("Content-Type: application/json");

    int res_code = hc.httpPost(Config::getMatrixUrl(), req.c_str(), headers, Config::getMatrixTimeoutSec());

    std::ostringstream osheaders;
    std::copy(headers.begin(), headers.end(), std::ostream_iterator<std::string>(osheaders, ";"));

    LOG_INFO("%s: url: %s, headers: %s, req: %s, res_code: %d, res_body: %s, res_error: %s", __func__,
            Config::getMatrixUrl(), osheaders.str().c_str(), req.c_str(), res_code, hc.getResponseBody(), hc.getError());

    return 0;
}
Пример #4
0
void HeapInspection::heap_inspection() {
  ResourceMark rm;
  HeapWord* permgen_bottom = NULL;

  if (Universe::heap()->kind() == CollectedHeap::GenCollectedHeap) {
    GenCollectedHeap* gch = GenCollectedHeap::heap();
    gch->gc_prologue(false /* !full */); // get any necessary locks
    permgen_bottom = gch->perm_gen()->used_region().start();
  } else {
    return;
  }

  // Collect klass instance info

  // Iterate over objects in the heap
  KlassInfoTable cit(KlassInfoTable::cit_size, permgen_bottom);
  RecordInstanceClosure ric(&cit);
  Universe::heap()->object_iterate(&ric);

  // Sort and print klass instance info
  KlassInfoHisto histo("\n"
                   "num   #instances    #bytes  class name\n"
                   "--------------------------------------",
                   KlassInfoHisto::histo_initial_size);
  HistoClosure hc(&histo);
  cit.iterate(&hc);
  histo.sort();
  histo.print_on(gclog_or_tty);
  gclog_or_tty->flush();

  if (Universe::heap()->kind() == CollectedHeap::GenCollectedHeap) {
    GenCollectedHeap* gch = GenCollectedHeap::heap();
    gch->gc_epilogue(false /* !full */); // release all acquired locks
  }
}
Пример #5
0
void print_dilep_count()
{
    rt::TH1Container hc("plots/dilep_counts.root");

    const float wz_mm = rt::Integral(hc["h_count_mm_wz2l2q" ]) + rt::Integral(hc["h_count_mm_wz3l"]);
    const float wz_ee = rt::Integral(hc["h_count_ee_wz2l2q" ]) + rt::Integral(hc["h_count_ee_wz3l"]);
    const float zz_mm = rt::Integral(hc["h_count_mm_zz2l2q" ]) + rt::Integral(hc["h_count_mm_zz2l2nu"]) + rt::Integral(hc["h_count_mm_zz4l"]);
    const float zz_ee = rt::Integral(hc["h_count_ee_zz2l2q" ]) + rt::Integral(hc["h_count_ee_zz2l2nu"]) + rt::Integral(hc["h_count_ee_zz4l"]);
    
    CTable t1;
    t1.useTitle();
    t1.setTitle("Generator level number of \\ell\\ell events (no selections)");
    t1.setTable() (                                                 "mm ",                                   "ee")
                  ( "DY --> mm"   , rt::Integral(hc["h_count_mm_dyll"   ]), rt::Integral(hc["h_count_ee_dyll"   ]))
                  ( "W --> mnu"   , rt::Integral(hc["h_count_mm_wjets"  ]), rt::Integral(hc["h_count_ee_wjets"  ]))
                  ( "tt"          , rt::Integral(hc["h_count_mm_ttdil"  ]), rt::Integral(hc["h_count_ee_ttdil"  ]))
                  ( "QCD"         , rt::Integral(hc["h_count_mm_qcd"    ]), rt::Integral(hc["h_count_ee_qcd"    ]))
                  ( "WW"          , rt::Integral(hc["h_count_mm_ww"     ]), rt::Integral(hc["h_count_ee_ww"     ]))
                  ( "WZ"          , wz_mm                                 , wz_ee                                 )
                  ( "WZ --> 2l2q" , rt::Integral(hc["h_count_mm_wz2l2q" ]), rt::Integral(hc["h_count_ee_wz2l2q" ]))
                  ( "WZ --> 3lnu" , rt::Integral(hc["h_count_mm_wz3l"   ]), rt::Integral(hc["h_count_ee_wz3l"   ]))
                  ( "ZZ"          , zz_mm                                 , zz_ee                                 ) 
                  ( "ZZ --> 2l2q" , rt::Integral(hc["h_count_mm_zz2l2q" ]), rt::Integral(hc["h_count_ee_zz2l2q" ]))
                  ( "ZZ --> 2lnu" , rt::Integral(hc["h_count_mm_zz2l2nu"]), rt::Integral(hc["h_count_ee_zz2l2nu"]))
                  ( "ZZ --> 4l"   , rt::Integral(hc["h_count_mm_zz4l"   ]), rt::Integral(hc["h_count_ee_zz4l"   ]))
                  ;
    std::cout << t1 << std::endl;
}
void HarmonySearchUnitTests::TestInitialization() {
    HarmonyCompare const& hc = *m_pCompare;
    // Tests that Harmonies are ordered correctly
    for (unsigned i = 0; i < m_memory-1; ++i) {
        Harmony const* r1 = m_pSearch->GetRanked(i);
        Harmony const* r2 = m_pSearch->GetRanked(i+1);
        bool success = hc(r1, r2);
        CPPUNIT_ASSERT(success);
        delete r1;
        delete r2;
    }
    // Tests that Harmonies are intact as expected
    for (unsigned i = 0; i < m_memory; ++i) {
        Harmony const* h1 = m_pFactory->GenerateRandomHarmony();
        Harmony const* h2 = m_pSearch->GetRanked(m_memory-i-1);
        for (unsigned j = 0; j < m_vCount; ++j) {
            float v1 = h1->at(j);
            float v2 = h2->at(j);
            CPPUNIT_ASSERT(FloatEqual(v1, v2));
        }
        delete h1;
        delete h2;
    }
    m_pFactory->Reset();
}
Пример #7
0
void destroy(Hierarchy d) {
  ParticlesTemp all;
  //core::Hierarchy h=d;

  core::gather(d, True(), std::back_inserter(all));
  for (unsigned int i=0; i< all.size(); ++i) {
    if (Bonded::particle_is_instance(all[i])) {
     Bonded b(all[i]);
      while (b.get_number_of_bonds() > 0) {
        destroy_bond(b.get_bond(b.get_number_of_bonds()-1));
      }
    }
    Hierarchy hc(all[i]);
    while (hc.get_number_of_children() > 0) {
      hc.remove_child(hc.get_child(hc.get_number_of_children()-1));
    }
  }

  // If this Hierarchy has a parent, remove the relationship
  Hierarchy parent = d.get_parent();
  if (parent) {
    parent.remove_child(d);
  }

  for (unsigned int i=0; i< all.size(); ++i) {
    all[i]->get_model()->remove_particle(all[i]);
  }
}
Пример #8
0
/*!
 * Adds an acceleration key to the given option so it can be activated by that key.
 * If id is not an option id, then nothing is done.
 * \param unicode The hot key
 * \param optId The option id
 */
void  Menu::registerHotKey(uint16 unicode, int optId) {
    Option *pOption = getOption(optId);
    if (pOption) {
        HotKey hc(KFC_UNKNOWN, unicode, pOption);
        hotKeys_.push_back(hc);
    }
}
Пример #9
0
//may be more faster
//first, spectral cluster
//second, the nearest neighbor cluster or hierarchical cluster
double* twoStepCluster(const Mat& convexPoints)
{
    printf("start to cluster the convex points using two tep method ...\n");

    time_t startTime = time(0);

    int nl = convexPoints.rows;
    int k = 200;
    Kmeans km(convexPoints, k);
    //printf("centers: %d\n", km.centers.rows);
    //std::cout << "centers: \n" << km.centers << endl;
    //cout << "nums: \n";
    //cout << km.nums;
    //cout << endl;
    //spectralClustering(convexPoints, k, indices, centers);
    printf("tag 1...\n");

    //further process
    Hierarchical hc(km.centers, km.nums);
    printf("tag 2...\n");

    double* score = hc.collectScore(km.indices);
    //double* score = km.collectScore();
    printf("end of cluster the convex points using method 2...\n");
    return score;
}
Пример #10
0
/*!
 * Adds an acceleration key to the given option so it can be activated by that key.
 * If id is not an existing option id, then nothing is done.
 * \param code The hot key
 * \param optId The option id
 */
void  Menu::registerHotKey(KeyFunc code, int optId) {
    Option *pOption = getOption(optId);
    if (pOption) {
        HotKey hc(code, 0, pOption);
        hotKeys_.push_back(hc);
    }
}
void HeapInspection::heap_inspection(outputStream* st, bool need_prologue) {
  ResourceMark rm;

  KlassInfoTable cit(start_of_perm_gen());
  if (!cit.allocation_failed()) {
    size_t missed_count = populate_table(&cit, need_prologue);
    if (missed_count != 0) {
      st->print_cr("WARNING: Ran out of C-heap; undercounted " SIZE_FORMAT
                   " total instances in data below",
                   missed_count);
    }

    KlassInfoHisto histo("\n"
                     " num     #instances         #bytes  class name\n"
                     "----------------------------------------------");
    HistoClosure hc(&histo);

    cit.iterate(&hc);

    histo.sort();
    histo.print_on(st);
  } else {
    st->print_cr("WARNING: Ran out of C-heap; histogram not generated");
  }
  st->flush();
}
Пример #12
0
BOOL CallHprose::deltask(std::string strIndex)
{
	 std::vector<hprose::any> vecAny;
	 vecAny.push_back(strIndex);

	 std::string strReturn;
	 hprose::httpclient hc(dataFileObject.m_strHproseRpc);
	 hc.invoke(strReturn, "deltask", vecAny);

	 ZTools::WriteZToolsFormatLog(" deltask 返回字符串为:%s ",strReturn.c_str());
	 if (strReturn.empty())
	 {
		 dataFileObject.m_strMsg = "invoke deltask 返回空字符串";
		 ZTools::WriteZToolsLog(dataFileObject.m_strMsg.c_str());
	 }

	 DeltaskReturn delReturn;
	 delReturn.FromJson(strReturn);

	 if (delReturn.error.compare("0") == 0)
		 return TRUE;

	else if (delReturn.error.compare("1") == 0)
	 {
		 dataFileObject.m_strMsg = delReturn.error;
		 ZTools::WriteZToolsFormatLog("invoke deltask 返回 error:%s",dataFileObject.m_strMsg.c_str());
		 return FALSE;
	 }
	 else
		 return TRUE;
}
Пример #13
0
int main()
{
    CppServer cserver;

    cserver.create(1, 100024, [](CppServer&, void* ud, const char* buffer, int len)
    {
        return HttpHelp::check_packet(buffer, len);
    });

    cserver.setMsgHandle([](CppServer& cserver, struct nrmgr_net_msg* msg){
        if (msg->type == nrmgr_net_msg_connect)
        {
            /*  发出http请求    */
            HttpRequest request;
            request.setHost("www.baidu.com");
            request.setProtocol(HRP_GET);

            string request_str = request.getResult();

            struct nrmgr_send_msg_data* sdmsg = cserver.makeSendMsg(request_str.c_str(), request_str.length());
            cserver.sendMsg(msg->session, sdmsg);
        }
        else if (msg->type == nrmgr_net_msg_data)
        {
            /*  接收到数据   */

        }
    });

    HttpConnector   hc(&cserver);
    string baidu_ip = HttpHelp::getipofhost("www.baidu.com");
    hc.connect(baidu_ip.c_str(), 80, 10000, NULL);

    while (true)
    {
        hc.poll();
        cserver.logicPoll(1);
    }
    /*
    int a = 100*(1/4);
    WebClientMgr<MyHttpClient> clientMgr;

    clientMgr.init(500, 1, 10024, 10024, WebClientMgr<MyHttpClient>::s_check);
    
    connector.setSocketMgr(clientMgr.getMgr());

    string baidu_ip = HttpHelp::getipofhost("www.baidu.com");

    connector.connect(baidu_ip.c_str(), 80, 10000, NULL);

    while(true)
    {
        clientMgr.poll(1);
        connector.poll();
    }
    */

    return 0;
}
Пример #14
0
void bs(int cascade, int start, int n) {
  hc(cascade, start, n);

  if(n > 2) {
    cascade++;
    bs(cascade, start, n/2);
    bs(cascade, start + n/2, n/2);
  }
}
Пример #15
0
/** Returns a BitSet with true for documents which should be permitted in
search results, and false for those that should not. */
BitSet* QueryFilter::bits( IndexReader* reader )
{
    BitSet* bits = _CLNEW BitSet(reader->maxDoc());

	IndexSearcher s(reader);
	QFHitCollector hc(bits);
	s._search(query, NULL, &hc);
    return bits;
}
Пример #16
0
HostClass* get_hostclass(const string& ip, int firstnode) 
{
    if(HostClass* hc = find_host(hostlist, ip)) 
	return hc;

    HostClass hc(ip, firstnode);
    hostlist.push_back(hc);

    return find_host(hostlist, ip);
}
Пример #17
0
TEST(HttpContextTest, test_print_access_log) {
    //set_log_level("INFO");
    HttpContext hc(0); // use stdin fd
    int ret = hc.get_request().parse_request(TEST_GET_REQ.c_str(), TEST_GET_REQ.size());
    ASSERT_EQ(0, ret);
    ret = hc.get_res().gen_response("HTTP/1.0", false);
    ASSERT_EQ(0, ret);
    ret = hc.print_access_log("127.0.0.1");
    ASSERT_EQ(0, ret);
}
Пример #18
0
bool YoukuParser::parse(const tstring& URL, vector<VideoList>& videolist) {
	httpclient hc(pwin->GetConsoleHandle());
	tstring html;
	if (hc.GetHtml(URL, html)) {
		parser(html, videolist);
		cookie = hc.GetHtmlSetCookie();
		pwin->SetHtmlCookie(cookie);
		return true;
	} else {
		return false;
	}
}
Пример #19
0
//该接口成功回空字符串,失败返回错误详细信息
BOOL CallHprose::init(std::string strUrl, std::vector<hprose::any> vecAny)
{
	std::string strReturn;
	//std::locale old_loc;
	try
	{
		//old_loc = std::locale::global(std::locale("C"));
		hprose::httpclient hc(strUrl);
		hc.invoke(strReturn, "init", vecAny);
		//std::locale::global(old_loc);

		DataInitReturn oInitReturn;
		oInitReturn.FromJson(strReturn);

		if (oInitReturn.flag.compare("0") == 0)
		{
			return TRUE;
		}
		else if (oInitReturn.flag.compare("1") == 0)
		{
			m_strFileId = oInitReturn.fileID;
			if (m_strFileId.empty())
			{
				m_strErrMsg = ZTools::FormatString("init error: flag is 1, but fileID is NULL");
				ZTools::WriteZToolsLog(m_strErrMsg);
				return FALSE;
			}
			else
			{
				return TRUE;
			}
		}
		else
		{
			m_strErrMsg = ZTools::FormatString("init error: flag is not 0 or 1");
			ZTools::WriteZToolsLog(m_strErrMsg);
			return FALSE;
		}
	}
	catch (hprose::exception e)
	{
		//std::locale::global(old_loc);
		m_strErrMsg = ZTools::FormatString("init error: %s", e.what());
		ZTools::WriteZToolsLog(m_strErrMsg);
		return FALSE;
	}
	catch (...)
	{

	}
	return TRUE;
}
Пример #20
0
void StateMachine::addConfig(string hostname)
{
  auto it = hostConfigMap.find(hostname);
  if (it != hostConfigMap.end()) {
    HostConfig hc = hostConfigMap[hostname]; 
    hc.reload();
  } else {
    HostConfig hc(hostname);
    LOG(INFO)<<"add this host config:";
    LOG(INFO)<<hc.toString();
    hostConfigMap[hostname] = hc;
  }
}
Пример #21
0
void HeatControl2Delta::main()
{
    HeatControl2Delta hc(100, 100, 100);

    hc.O.resize(2*hc.L);
    hc.O[0] = 0.50;
    hc.O[1] = 0.80;
    hc.O[2] = 0.70;
    hc.O[3] = 0.20;
    hc.O[4] = 0.20;
    hc.O[5] = 0.30;

    hc.initialize();

    DoubleVector x(2*hc.L + (hc.M+1)*hc.L);
    x[0] = 0.60; x[1] = 0.70; x[2] = 0.65; x[3] = 0.25; x[4] = 0.25; x[5] = 0.35;

    for (unsigned int k=0; k<=hc.M; k++)
    {
        x[2*hc.L + 0*(hc.M+1) + k] = 1.0;//hc.v1(k*hc.ht);
        x[2*hc.L + 1*(hc.M+1) + k] = 1.0;//hc.v2(k*hc.ht);
        x[2*hc.L + 2*(hc.M+1) + k] = 1.0;//hc.v3(k*hc.ht);
    }

    /* Minimization */
    ConjugateGradient g2;
    g2.setFunction(&hc);
    g2.setGradient(&hc);
    g2.setEpsilon1(0.0001);
    g2.setEpsilon2(0.0001);
    g2.setEpsilon3(0.0001);
    g2.setR1MinimizeEpsilon(1.0, 0.0001);
    g2.setPrinter(&hc);
    g2.setProjection(&hc);
    g2.setNormalize(true);
    g2.calculate(x);

    DoubleVector gr1(x.length());
    IGradient::Gradient(&hc, 0.00001, x, gr1);
    gr1.L2Normalize();

    DoubleVector gr2(x.length());
    hc.gradient(x, gr2);
    gr2.L2Normalize();

    printf("J[%d]: %.16f\n", 0, hc.fx(x));
    printf("eo: [%12.8f, %12.8f] [%12.8f, %12.8f] [%12.8f, %12.8f]\n", hc.O[0], hc.O[1], hc.O[2], hc.O[3], hc.O[4], hc.O[5]);
    printf("e1: [%12.8f, %12.8f] [%12.8f, %12.8f] [%12.8f, %12.8f]\n", x[0], x[1], x[2], x[3], x[4], x[5]);
    printf("gr1: [%12.8f, %12.8f] [%12.8f, %12.8f] [%12.8f, %12.8f]\n", gr1[0], gr1[1], gr1[2], gr1[3], gr1[4], gr1[5]);
    printf("gr2: [%12.8f, %12.8f] [%12.8f, %12.8f] [%12.8f, %12.8f]\n", gr2[0], gr2[1], gr2[2], gr2[3], gr2[4], gr2[5]);
}
Пример #22
0
void PrintValidation 
(
    const float mass_stop,
    const float mass_lsp,
    const int signal_region_num
)
{
    rt::TH1Container hc("plots/interp/t2tt/t2tt_bdt_hists.root");
/*     hc.List(); */
    const stop::SignalRegion::value_type signal_region = stop::GetSignalRegionFromName(Form("sr%d", signal_region_num)); 
    const std::string sr_label = stop::GetSignalRegionInfo(signal_region).label; 

    const float xsec            = rt::GetBinContent1D(hc["h_xsec"                ], mass_stop);
    const float ngen            = rt::GetBinContent2D(hc["h_ngen"                ], mass_stop, mass_lsp);
    const float scale1fb        = rt::GetBinContent2D(hc["h_scale1fb"            ], mass_stop, mass_lsp);
    const float den             = rt::GetBinContent2D(hc["h_den"                 ], mass_stop, mass_lsp);
    const float nevt            = rt::GetBinContent2D(hc["h_nevt_"      +sr_label], mass_stop, mass_lsp);
    const float num             = rt::GetBinContent2D(hc["h_num_"       +sr_label], mass_stop, mass_lsp);
    const float eff             = rt::GetBinContent2D(hc["h_eff_"       +sr_label], mass_stop, mass_lsp);
    const float err_jes         = rt::GetBinContent2D(hc["h_err_jes_"   +sr_label], mass_stop, mass_lsp);
    const float num_jesup       = rt::GetBinContent2D(hc["h_num_jesup_" +sr_label], mass_stop, mass_lsp);
    const float num_jesdn       = rt::GetBinContent2D(hc["h_num_jesdn_" +sr_label], mass_stop, mass_lsp);
    const float err_btag        = rt::GetBinContent2D(hc["h_err_btag_"  +sr_label], mass_stop, mass_lsp);
    const float num_btagup      = rt::GetBinContent2D(hc["h_num_btagup_"+sr_label], mass_stop, mass_lsp);
    const float num_btagdn      = rt::GetBinContent2D(hc["h_num_btagdn_"+sr_label], mass_stop, mass_lsp);
    const float err_noisr       = rt::GetBinContent2D(hc["h_err_noisr_" +sr_label], mass_stop, mass_lsp);
    const float num_noisr       = rt::GetBinContent2D(hc["h_num_noisr_" +sr_label], mass_stop, mass_lsp);
    const float err_total       = rt::GetBinContent2D(hc["h_err_total_" +sr_label], mass_stop, mass_lsp);
    const float err_stats       = rt::GetBinContent2D(hc["h_err_stats_" +sr_label], mass_stop, mass_lsp);

    cout << "\nQuick Validation for Search Region " << signal_region_num <<     endl ;
    cout << Form("mass point            = m_stop = %1.0f, m_lsp = %1.0f", mass_stop, mass_lsp) << endl;
    cout << Form("xsec                  = %1.4e" , xsec)                                        << endl;
    cout << Form("scale1fb              = %1.4f" , scale1fb)                                    << endl;
    cout << Form("efficiency (%%)        = %1.4f", eff*100.0)                                   << endl;
    cout << Form("num generated (raw)   = %1.0f" , ngen)                                        << endl;
    cout << Form("num passing (raw)     = %1.0f" , nevt)                                        << endl;
    cout << Form("den                   = %1.1f" , den)                                         << endl;
    cout << Form("num                   = %1.1f" , num)                                         << endl;
    cout << Form("num JES+              = %1.1f" , num_jesup)                                   << endl;
    cout << Form("num JES-              = %1.1f" , num_jesdn)                                   << endl;
    cout << Form("num Btag+             = %1.1f" , num_btagup)                                  << endl;
    cout << Form("num Btag-             = %1.1f" , num_btagdn)                                  << endl;
    cout << Form("num ISR               = %1.1f" , num_noisr)                                   << endl;
    cout << Form("Uncertainty JES+/-    = %1.5f" , err_jes)                                     << endl;
    cout << Form("Uncertainty Btag+/-   = %1.5f" , err_btag)                                    << endl;
    cout << Form("Uncertainty ISR       = %1.5f" , err_noisr)                                   << endl;
    cout << Form("Uncertainty stats     = %1.5f" , err_stats)                                   << endl;
    cout << Form("Uncertainty Total     = %1.5f" , err_total)                                   << endl;
}
Пример #23
0
int check_h()
{
    int i,flg=0;
    for(i=0; i<E; i++)
    {
        h(i)=H3(en(i,0)-1,0)-H3(en(i,1)-1,0);
        qc(i)=c(i)*(h(i)+Hd(i));
        if(ch(i)==1)
        {
            Re=ro*qc(i)*D(i)/(A(i)*mu);
            f(i)=.094*pow(K(i),0.225)+0.53*K(i)+88*pow(K(i),0.44)*pow(fabs(Re),(-1.62*pow(K(i),0.134)));
            hc(i)=f(i)*L(i)*pow(qc(i),2)/(2*g*D(i)*pow(A(i),2))+k(i)*pow(qc(i),2)/(2*g*pow(A(i),2));
        }
        else if (ch(i)==2 && qc(i)>0)
        {
            hc(i)=pow((qc(i)/A(i)),2)/(2*g)-Hd(i);
        }
        else if(ch(i)==2 && qc(i)<0)
        {
            hc(i)=-pow((qc(i)/A(i)),2)/(2*g)-Hd(i);
        }
        else if(ch(i)==3)
        {
            hc(i)=k(i)*pow((qc(i)/A(i)),2)/(2*g)*pow((100.0/o(i)),(2*n(i)));
        }
        cc(i)=fabs(qc(i)/(hc(i)+Hd(i)));
        err(i)=fabs(fabs(hc(i))-fabs(h(i)))/fabs(h(i))*100;
        qDebug()<<"hc "<<hc(i)<<"h "<<h(i)<<"D "<<D(i)<<"f "<<f(i)<<"L "<<L(i)<<"A "<<A(i);
        if(err(i)<rangep)
        {
            flg++;
        }
        if(hc(i)!=hc(i))
        {
            qDebug()<<"Inside break for NaN";
            stop=1;
        }
    }
    qDebug()<<"flg "<< flg;
return flg;
}
Пример #24
0
void print_dilep_plots(const std::string& suffix = "png")
{
    rt::TH1Container hc("plots/dilep_counts.root");

    // formatting
    rt::TH1Overlay::legend_height_per_entry_default = 0.050;
    rt::TH1Overlay::legend_text_size_default        = 0.025;
    const float ymin = 1e0;
    const float ymax = 3e4;
    const std::string option = "sb::off dt::stack lg::top_left";

    rt::TH1Overlay p1("Generator Level Dimuon distributions - #intL = 82 pb^{-1};m_{#mu^{+}#mu^{-}} (GeV/c^{2});Events/1.0 GeV/c^{2}", option);
    p1.Add(hc["h_mmm_dyll"   ],  "DY #rightarrow #mu#mu"        , kOrange-2);
    p1.Add(hc["h_mmm_wz2l2q" ],  "WZ #rightarrow 2l2q"          , kRed+2   );
    p1.Add(hc["h_mmm_wz3l"   ],  "WZ #rightarrow 3l#nu"         , kRed-7   );
    p1.Add(hc["h_mmm_zz2l2q" ],  "ZZ #rightarrow 2l2q"          , kBlue    );
    p1.Add(hc["h_mmm_zz2l2nu"],  "ZZ #rightarrow 2l#nu"         , kBlue+2  );
    p1.Add(hc["h_mmm_zz4l"   ],  "ZZ #rightarrow 4l"            , kBlue-5  );
    p1.Add(hc["h_mmm_ttdil"  ],  "t#bar{t} #rightarrow 2l2#nu2b", kOrange+7);
    p1.Add(hc["h_mmm_ww"     ],  "WW #rightarrow 2l2#nu"        , kGreen+2 );
    p1.Add(hc["h_mmm_wjets"  ],  "W #rightarrow l#nu"           , kGray+1  );
    p1.Add(hc["h_mmm_qcd"    ],  "QCD"                          , kMagenta );
    p1.SetYAxisRange(ymin, ymax);

    rt::TH1Overlay p2("Generator Level Dielectron distributions - #intL = 82 pb^{-1};m_{e^{+}e^{-}} (GeV/c^{2});Events/1.0 GeV/c^{2}", option);
    p2.Add(hc["h_mee_dyll"   ],  "DY #rightarrow ee"            , kOrange-2);
    p2.Add(hc["h_mee_wz2l2q" ],  "WZ #rightarrow 2l2q"          , kRed+2   );
    p2.Add(hc["h_mee_wz3l"   ],  "WZ #rightarrow 3l#nu"         , kRed-7   );
    p2.Add(hc["h_mee_zz2l2q" ],  "ZZ #rightarrow 2l2q"          , kBlue    );
    p2.Add(hc["h_mee_zz2l2nu"],  "ZZ #rightarrow 2l#nu"         , kBlue+2  );
    p2.Add(hc["h_mee_zz4l"   ],  "ZZ #rightarrow 4l"            , kBlue-5  );
    p2.Add(hc["h_mee_ttdil"  ],  "t#bar{t} #rightarrow 2l2#nu2b", kOrange+7);
    p2.Add(hc["h_mee_ww"     ],  "WW #rightarrow 2l2#nu"        , kGreen+2 );
    p2.Add(hc["h_mee_wjets"  ],  "W #rightarrow l#nu"           , kGray+1  );
    p2.Add(hc["h_mee_qcd"    ],  "QCD"                          , kMagenta );
    p2.SetYAxisRange(ymin, ymax);

    // output
    rt::Print(p1, "plots/p_gen_mmm", suffix);
    rt::Print(p2, "plots/p_gen_mee", suffix);

    // log output
    p1.SetLogy(true);
    rt::Print(p1, "plots/p_gen_mmm_log", suffix);
    p2.SetLogy(true);
    rt::Print(p2, "plots/p_gen_mee_log", suffix);
}
Пример #25
0
XBOOL XHScrollBar::OnPaint(XGraphics &g)
{
	XRect rect;
	GetClientRect(rect);
	XColor c(XWindow::m_nColors[XCW_BUTTON]);
	XColor cc(c);
	cc.Bright(24);
	g.SetBackColor(cc);
	g.FillRectangle(rect);
	
	XRect r=rect;
	int pp;
	CalcRect(r,pp);
	if(m_nStatus==XS_UPPAGE&&r.left>rect.bottom)
	{
	   XColor cm(c);
	   cm.Bright(12);
	   g.SetBackColor(cm);
	   g.FillRectangle(XRect(0,0,r.left,rect.bottom));
	}
	if(m_nStatus==XS_DOWNPAGE&&r.right<rect.right-rect.bottom)
	{
	   XColor cm(c);
	   cm.Bright(12);
	   g.SetBackColor(cm);
	   g.FillRectangle(XRect(r.right,0,rect.right-rect.bottom,rect.bottom));
	}


	XColor hc(c);
	hc.Bright(10);
	XRect rl(0,0,rect.bottom,rect.bottom);
	XRect rr(rect.right-rect.bottom,0,rect.right,rect.bottom);
	g.DrawButton(rl,m_nStatus==XS_UPLINE?hc:c,XBS_BFRAME|XBS_WFRAME);
	g.DrawButton(rr,m_nStatus==XS_DOWNLINE?hc:c,XBS_BFRAME|XBS_WFRAME);

	cc=c;cc.Dark(60);
	g.DrawDirect(rl,XK_LEFT,cc);
	g.DrawDirect(rr,XK_RIGHT,cc);


	g.DrawButton(r,m_nStatus==XS_HAND?hc:c,XBS_BFRAME|XBS_WFRAME|XBS_VHAND);

	return XTRUE;
	//*/
}
Пример #26
0
void HeapInspection::heap_inspection(outputStream* st) {
  ResourceMark rm;

  if (_print_help) {
    for (int c=0; c<KlassSizeStats::_num_columns; c++) {
      st->print("%s:\n\t", name_table[c]);
      const int max_col = 60;
      int col = 0;
      for (const char *p = help_table[c]; *p; p++,col++) {
        if (col >= max_col && *p == ' ') {
          st->print("\n\t");
          col = 0;
        } else {
          st->print("%c", *p);
        }
      }
      st->print_cr(".\n");
    }
    return;
  }

  KlassInfoTable cit(_print_class_stats);
  if (!cit.allocation_failed()) {
    size_t missed_count = populate_table(&cit);
    if (missed_count != 0) {
      st->print_cr("WARNING: Ran out of C-heap; undercounted " SIZE_FORMAT
                   " total instances in data below",
                   missed_count);
    }

    // Sort and print klass instance info
    const char *title = "\n"
              " num     #instances         #bytes  class name\n"
              "----------------------------------------------";
    KlassInfoHisto histo(&cit, title);
    HistoClosure hc(&histo);

    cit.iterate(&hc);

    histo.sort();
    histo.print_histo_on(st, _print_class_stats, _csv_format, _columns);
  } else {
    st->print_cr("WARNING: Ran out of C-heap; histogram not generated");
  }
  st->flush();
}
Пример #27
0
//该接口成功回空字符串,失败返回错误详细信息
BOOL CallHprose::cwrite(std::string strUrl, std::vector<hprose::any> vecAny)
{
	std::string strReturn;
	//std::locale old_loc;	
	try
	{
		//old_loc = std::locale::global(std::locale("C"));
		hprose::httpclient hc(strUrl);
		hc.invoke(strReturn, "cwrite", vecAny);
		if (strReturn.empty())
		{
			ZTools::WriteZToolsFormatLog("cwrite 返回字符串为空");
		}
		//ZTools::WriteZToolsFormatLog("cwrite 返回字符串为【%s】",strReturn.c_str());
		//std::locale::global(old_loc);

		DataCwriteReturn oCwriteReturn;
		oCwriteReturn.FromJson(strReturn);
		if (oCwriteReturn.error.compare("0") != 0)
		{
			dataFileObject.m_strMsg  = ZTools::FormatString("cwrite error: %s", oCwriteReturn.msg.c_str());
			ZTools::WriteZToolsLog(dataFileObject.m_strMsg);
			return FALSE;
		}

		if (!oCwriteReturn.fileID.empty())
		{
			dataFileObject.m_strFileId = oCwriteReturn.fileID;
			m_strFileSize = oCwriteReturn.end;
		}
	}
	catch (hprose::exception e)
	{
		//std::locale::global(old_loc);
		strReturn = ZTools::FormatString("cwrite error: %s", e.what());
		dataFileObject.m_strMsg = strReturn;
		ZTools::WriteZToolsLog(strReturn);
		return FALSE;
	}
	catch (...)
	{

	}
	return TRUE;
}
Пример #28
0
int main(int argc, char* argv[])
{
#ifdef _DEBUG
    //initLeakCheck(false);
#endif

    parseCommandLine(argc, argv);
    
    char* sourcefile = gArgv[1];
    char* outdir = (gArgc>=3)?(char*)gArgv[2]:(char*)"";
    
    HIDLcompiler hc(sourcefile, outdir);
    hc.Process();

    delete[] gArgv;
    if (esp_def_export_tag)
        free(esp_def_export_tag);

    return 0;
}
Пример #29
0
void hc(int n, int graph[][n], int offset_i, int offset_j, int edge_count) {

    // ma smysl hledat reseni jenom pokud muzeme najit lepsi reseni, nez uz mame ... tzn pokud uz jsme do grafu pridali vic hran nez ma zatim nalezene nejlepsi reseni, nema smysl ve vetvi pokracovat
    if (edge_count < solution.edges) {
        // test jestli uz graf je hamiltonovsky, pokud ano a pouzilo se mene hran nez ma dosavadni nejlepsi reseni tak prepsat reseni.
        if(hamilton_test(n, graph)) {
            if (edge_count < solution.edges) {
                solution.edges = edge_count;
                for (int n1 = 0; n1 < n; n1++) {
                    for (int n2 = 0; n2 < n; n2++) {
                        solution.graph[n1][n2] = graph[n1][n2];
                    }
                }
                            //printf("mam NEJLEPSI reseni, pocet hran:%d \n", edge_count+1);
            }
            else {
                            //printf("mam reseni, ale neni nejlepsi, pocet hran:%d \n", edge_count+1);    
            }
        }

        // az narazim na nespojenou dvojici uzlu, tak pridam hranu a rekurze ... + pokracovani bez pridani hrany    
        for (int i = offset_i; i < n; i++) {
            for (int j = offset_j; j < n; j++) {
            //printf("i:%d j:%d\n", i, j);
                if (graph[i][j] == 0) {
                    graph[i][j] = 1;
                    graph[j][i] = 1;
                    
                    // rekurze
                    hc(n, graph, i, j+1, edge_count+1);

                    graph[i][j] = 0;
                    graph[j][i] = 0;
                }
            }
            offset_j = i+2;
        }
    }
}
Пример #30
0
    void transform(const char * source, const char * outdir="", StringBuffer * out=NULL, bool outputIncludes=true, bool includedESDL=false)
    {
        if (!added.getValue(source))
        {
            if (optVerbose)
            {
                fprintf(stdout, "Processing ESDL definition: %s\n", source);
                if (out==NULL && (!outdir || !*outdir))
                    fprintf(stdout, "Output directory not specified\n");
            }

            //prevent recursive adding of this same content
            added.setValue(source, true);

            ESDLcompiler hc(source, out==NULL, outdir, outputIncludes, includedESDL, includePath);
            hc.Process();

            if (optRecursive && hc.includes)
            {
                StringBuffer subfile;
                StringBuffer srcDir = hc.getSrcDir();

                IncludeInfo * ii;
                for (ii=hc.includes;ii;ii=ii->next)
                {
                    subfile.setf("%s%s%s", srcDir.str(), ii->pathstr.str(), ESDL_FILE_EXTENSION);
                    transform(subfile, outdir, out, outputIncludes, true);
                }
            }

            if (out != NULL) //includes must come before body to handle ESDLDefVersions correctly
                out->append(hc.getEsxdlContent());

            if (optVerbose)
                fprintf(stdout, "Finished processing ESDL definition: %s\n", source);
        }
        else if (optVerbose)
            fprintf(stdout, "ESDL definition: %s has already been loaded!\n", source);
    }