Esempio n. 1
0
int main()
{
  decltype(auto) i = f();
  same_type<decltype(i),int&>();
  decltype(auto) i2 = i;
  same_type<decltype(i2),int&>();
  decltype(auto) i3 = ::i;
  same_type<decltype(i3),int>();
  decltype(auto) i4 = (::i);
  same_type<decltype(i4),int&>();
  decltype(auto) i5 = a.i;
  same_type<decltype(i5),int>();
  decltype(auto) i6 = (a.i);
  same_type<decltype(i6),int&>();
  decltype(auto) i7 = true ? ::i : ::i;
  same_type<decltype(i7),int&>();

  same_type<decltype(g()),int&>();
  same_type<decltype(h1()),int>();
  same_type<decltype(h2()),int&>();
  same_type<decltype(h2a()),int&>();
  same_type<decltype(h3()),int>();
  same_type<decltype(h4()),int&>();
  same_type<decltype(h5(a)),int>();
  same_type<decltype(h6(a)),int&>();
}
Esempio n. 2
0
int
run_main (int, ACE_TCHAR *[])
{
  ACE_START_TEST (ACE_TEXT ("Sig_Handlers_Test"));

  ACE_Sig_Handlers multi_handlers;
  ACE_Select_Reactor reactor_impl (&multi_handlers);
  ACE_Reactor reactor (&reactor_impl);
  ACE_Reactor::instance (&reactor);

  // Create a bevy of handlers.

  Test_SIGINT_Handler h1 (ACE_Reactor::instance (), "h1");
  Test_SIGINT_Handler h2 (ACE_Reactor::instance (), "h2");
  Test_SIGINT_Handler h3 (ACE_Reactor::instance (), "h3");
  Test_SIGINT_Handler h4 (ACE_Reactor::instance (), "h4");
  Test_SIGINT_Handler h5 (ACE_Reactor::instance (), "h5");
  Test_SIGINT_Handler h6 (ACE_Reactor::instance (), "h6");
  Test_SIGINT_Handler h7 (ACE_Reactor::instance (), "h7");
  Test_SIGINT_Handler h8 (ACE_Reactor::instance (), "h8");

  Test_SIGINT_Shutdown_Handler h0 (ACE_Reactor::instance ());

  // Wait for user to type SIGINT.
  while (!ACE_Reactor::instance ()->reactor_event_loop_done ())
    {
      ACE_DEBUG ((LM_DEBUG,"\nwaiting for SIGINT\n"));
      if (ACE_Reactor::instance ()->handle_events () == -1)
        ACE_ERROR ((LM_ERROR,"%p\n","handle_events"));
    }

  ACE_END_TEST;
  return 0;
}
void draw_grid(int i,int j,int k)                       //This draws the grid and changes the color the grid according to the player
{   beginFrame();
    Line h1(0,0,600,0),h2(0,100,600,100),               // "h" is the horizontal lines and "v" is the vertical lines
    h3(0,200,600,200),h4(0,300,600,300),
    h5(0,400,600,400),h6(0,500,600,500),
    h7(0,600,600,600),h8(0,700,600,700),
    h9(0,800,600,800);
    Line v1(0,0,0,800),v2(100,0,100,800),
    v3(200,0,200,800),v4(300,0,300,800),
    v5(400,0,400,800),v6(500,0,500,800),
    v7(600,0,600,800);
    h1.setColor(COLOR(255*i,255*j,255*k)),h2.setColor(COLOR(255*i,255*j,255*k)),
    h3.setColor(COLOR(255*i,255*j,255*k)),h4.setColor(COLOR(255*i,255*j,255*k)),
    h5.setColor(COLOR(255*i,255*j,255*k)),h6.setColor(COLOR(255*i,255*j,255*k)),
    h7.setColor(COLOR(255*i,255*j,255*k)),h8.setColor(COLOR(255*i,255*j,255*k)),
    h9.setColor(COLOR(255*i,255*j,255*k));
    v1.setColor(COLOR(255*i,255*j,255*k)),v2.setColor(COLOR(255*i,255*j,255*k)),
    v3.setColor(COLOR(255*i,255*j,255*k)),v4.setColor(COLOR(255*i,255*j,255*k)),
    v5.setColor(COLOR(255*i,255*j,255*k)),v6.setColor(COLOR(255*i,255*j,255*k)),
    v7.setColor(COLOR(255*i,255*j,255*k));
    h1.imprint(),h2.imprint(),
    h3.imprint(),h4.imprint(),
    h5.imprint(),h6.imprint(),
    h7.imprint(),h8.imprint(),h9.imprint();
    v1.imprint(),v2.imprint(),
    v3.imprint(),v4.imprint(),
    v5.imprint(),v6.imprint(),v7.imprint();
    endFrame();
}
Esempio n. 4
0
 ST Hermite(ST m0, ST y0, ST y1, ST m1, FT t)
 {
     return
         m0 * h3(t) +
         y0 * h1(t) +
         y1 * h2(t) +
         m1 * h4(t);
 }
Esempio n. 5
0
void convertHFShowerLibrary() {
  TFile *nF=new TFile("david.root","RECREATE","hiThere",1);
  TTree *nT=new TTree("HFSimHits","HF simple tree");
  std::vector<float> *parts=new std::vector<float>();
  std::vector<float> *partsHad=new std::vector<float>();
  nT->Branch("emParticles", &parts);
  nT->GetBranch("emParticles")->SetBasketSize(1);
  nT->Branch("hadParticles", &partsHad);
  nT->GetBranch("hadParticles")->SetBasketSize(1);

  TDirectory *target=gDirectory;
  TFile *oF=TFile::Open("HFShowerLibrary_npmt_noatt_eta4_16en_v3_orig.root");
  TTree *t=(TTree*)oF->Get("HFSimHits");
  TTreeReader fReader(t);
  TTreeReaderArray<Float_t> b1(fReader, "emParticles.position_.fCoordinates.fX");
  TTreeReaderArray<Float_t> b2(fReader, "emParticles.position_.fCoordinates.fY");
  TTreeReaderArray<Float_t> b3(fReader, "emParticles.position_.fCoordinates.fZ");
  TTreeReaderArray<Float_t> b4(fReader, "emParticles.lambda_");
  TTreeReaderArray<Float_t> b5(fReader, "emParticles.time_");

  TTreeReaderArray<Float_t> h1(fReader, "hadParticles.position_.fCoordinates.fX");
  TTreeReaderArray<Float_t> h2(fReader, "hadParticles.position_.fCoordinates.fY");
  TTreeReaderArray<Float_t> h3(fReader, "hadParticles.position_.fCoordinates.fZ");
  TTreeReaderArray<Float_t> h4(fReader, "hadParticles.lambda_");
  TTreeReaderArray<Float_t> h5(fReader, "hadParticles.time_");


  target->cd();
  while ( fReader.Next() ) {
    parts->clear();
    unsigned int s=b1.GetSize();
    parts->resize(5*s);
    for ( unsigned int i=0; i<b1.GetSize(); i++) {
      (*parts)[i]=(b1[i]);
      (*parts)[i+1*s]=(b2[i]);
      (*parts)[i+2*s]=(b3[i]);
      (*parts)[i+3*s]=(b4[i]);
      (*parts)[i+4*s]=(b5[i]);
    }  

    partsHad->clear();
    s=h1.GetSize();
    partsHad->resize(5*s);
    for ( unsigned int i=0; i<h1.GetSize(); i++) {
      (*partsHad)[i]=(h1[i]);
      (*partsHad)[i+1*s]=(h2[i]);
      (*partsHad)[i+2*s]=(h3[i]);
      (*partsHad)[i+3*s]=(h4[i]);
      (*partsHad)[i+4*s]=(h5[i]);
    }  

    nT->Fill();
  }

  nT->Write();
  nF->Close();
}
// check wait in new thread
void test_case_1()
{
	boost::uint32_t n = 3;
	tsk::spin::manual_reset_event ev;

	tsk::handle< boost::uint32_t > h1(
			tsk::async(
				tsk::make_task(
					wait_fn,
					n, boost::ref( ev) ),
				tsk::new_thread() ) );
	tsk::handle< boost::uint32_t > h2(
			tsk::async(
				tsk::make_task(
					wait_fn,
					n, boost::ref( ev) ),
				tsk::new_thread() ) );

	boost::this_thread::sleep( pt::millisec( 250) );
	BOOST_CHECK( ! h1.is_ready() );
	BOOST_CHECK( ! h2.is_ready() );

	ev.set();

	boost::this_thread::sleep( pt::millisec( 250) );
	BOOST_CHECK( h1.is_ready() );
	BOOST_CHECK( h2.is_ready() );
	BOOST_CHECK_EQUAL( h1.get(), n);
	BOOST_CHECK_EQUAL( h2.get(), n);

	ev.reset();

	tsk::handle< boost::uint32_t > h3(
			tsk::async(
				tsk::make_task(
					wait_fn,
					n, boost::ref( ev) ),
				tsk::new_thread() ) );
	tsk::handle< boost::uint32_t > h4(
			tsk::async(
				tsk::make_task(
					wait_fn,
					n, boost::ref( ev) ),
				tsk::new_thread() ) );

	boost::this_thread::sleep( pt::millisec( 250) );
	BOOST_CHECK( ! h3.is_ready() );
	BOOST_CHECK( ! h4.is_ready() );

	ev.set();

	boost::this_thread::sleep( pt::millisec( 250) );
	BOOST_CHECK( h3.is_ready() );
	BOOST_CHECK( h4.is_ready() );
	BOOST_CHECK_EQUAL( h3.get(), n);
	BOOST_CHECK_EQUAL( h4.get(), n);
}
Esempio n. 7
0
/*@ assigns \nothing; */
double f4()
{
    double tab[2],r;
    tab[0]=1.0;
    tab[1]=2.0;
    r = g4( &tab ) ;

    return r + h4(tab);
}
Esempio n. 8
0
TEST_F(HalfTest, Vec) {
    float4 f4(1,2,3,4);
    half4 h4(f4);
    half3 h3(f4.xyz);
    half2 h2(f4.xy);

    EXPECT_EQ(f4, h4);
    EXPECT_EQ(f4.xyz, h3);
    EXPECT_EQ(f4.xy, h2);
}
void TestStelSphericalGeometry::benchmarkSphericalCap()
{
	Vec3d p0(1,0,0);
	Vec3d p2(1,1,1);
	p2.normalize();
	SphericalCap h0(p0, 0);
	SphericalCap h4(p2, 0.8);
	QBENCHMARK {
		h0.intersects(h4);
	}
}
Esempio n. 10
0
int
ACE_TMAIN (int argc, ACE_TCHAR *[])
{
  // If argc > 1 then allow multiple handlers per-signal, else just
  // allow 1 handler per-signal.
  ACE_Sig_Handlers multi_handlers;

#if defined (ACE_WIN32)
  ACE_WFMO_Reactor reactor_impl (argc > 1
                                 ? &multi_handlers
                                 : (ACE_Sig_Handler *) 0);
#else
  ACE_Select_Reactor reactor_impl (argc > 1
                                   ? &multi_handlers
                                   : (ACE_Sig_Handler *) 0);
#endif /* ACE_WIN32 */
  ACE_Reactor reactor (&reactor_impl);

  if (argc > 1)
    {
      // Register an "external" signal handler so that the
      // ACE_Sig_Handlers code will have something to incorporate!

      ACE_SignalHandler eh = (ACE_SignalHandler) external_handler;
      ACE_Sig_Action sa (eh);

      sa.register_action (SIGINT);
    }

  // Create a bevy of handlers.
  Sig_Handler_1 h1 (reactor, "howdy");
  Sig_Handler_1 h2 (reactor, "doody");
  Sig_Handler_2 h3 (reactor, "tutty");
  Sig_Handler_2 h4 (reactor, "fruity");

  // Wait for user to type SIGINT and SIGQUIT.

  for (;;)
    {
      ACE_DEBUG ((LM_DEBUG,
                  "\nwaiting for SIGINT or SIGQUIT\n"));

      if (reactor.handle_events () == -1)
        ACE_ERROR ((LM_ERROR,
                    "%p\n",
                    "handle_events"));
    }

  ACE_NOTREACHED (return 0);
}
Esempio n. 11
0
/**
 * Decrypt a single block of data.
 */
void skipjack_decrypt(byte tab[10][256], byte in[8], byte out[8]) {
	word32 w1, w2, w3, w4;

	w1 = (in[0] << 8) + in[1];
	w2 = (in[2] << 8) + in[3];
	w3 = (in[4] << 8) + in[5];
	w4 = (in[6] << 8) + in[7];

	/* stepping rule A: */
	h1(tab, w2); w3 ^= w2 ^ 32;
	h0(tab, w3); w4 ^= w3 ^ 31;
	h4(tab, w4); w1 ^= w4 ^ 30;
	h3(tab, w1); w2 ^= w1 ^ 29;
	h2(tab, w2); w3 ^= w2 ^ 28;
	h1(tab, w3); w4 ^= w3 ^ 27;
	h0(tab, w4); w1 ^= w4 ^ 26;
	h4(tab, w1); w2 ^= w1 ^ 25;

	/* stepping rule B: */
	w1 ^= w2 ^ 24; h3(tab, w2);
	w2 ^= w3 ^ 23; h2(tab, w3);
	w3 ^= w4 ^ 22; h1(tab, w4);
	w4 ^= w1 ^ 21; h0(tab, w1);
	w1 ^= w2 ^ 20; h4(tab, w2);
	w2 ^= w3 ^ 19; h3(tab, w3);
	w3 ^= w4 ^ 18; h2(tab, w4);
	w4 ^= w1 ^ 17; h1(tab, w1);

	/* stepping rule A: */
	h0(tab, w2); w3 ^= w2 ^ 16;
	h4(tab, w3); w4 ^= w3 ^ 15;
	h3(tab, w4); w1 ^= w4 ^ 14;
	h2(tab, w1); w2 ^= w1 ^ 13;
	h1(tab, w2); w3 ^= w2 ^ 12;
	h0(tab, w3); w4 ^= w3 ^ 11;
	h4(tab, w4); w1 ^= w4 ^ 10;
	h3(tab, w1); w2 ^= w1 ^  9;

	/* stepping rule B: */
	w1 ^= w2 ^ 8; h2(tab, w2);
	w2 ^= w3 ^ 7; h1(tab, w3);
	w3 ^= w4 ^ 6; h0(tab, w4);
	w4 ^= w1 ^ 5; h4(tab, w1);
	w1 ^= w2 ^ 4; h3(tab, w2);
	w2 ^= w3 ^ 3; h2(tab, w3);
	w3 ^= w4 ^ 2; h1(tab, w4);
	w4 ^= w1 ^ 1; h0(tab, w1);

	out[0] = (byte)(w1 >> 8); out[1] = (byte)w1;
	out[2] = (byte)(w2 >> 8); out[3] = (byte)w2;
	out[4] = (byte)(w3 >> 8); out[5] = (byte)w3;
	out[6] = (byte)(w4 >> 8); out[7] = (byte)w4;

}
Esempio n. 12
0
int main() {

    Sac<int> s;
    Sac<Horloge> b1(4);

    s+= 4;
    s+= 6;
    s+= 9;
    s+= 8;

    IterateurSac<int> it(s);
    int somme;

    cout << "Itérateur de sac avec un sac de int" << endl;

    for(somme=0; !it; ++it){
        somme += *it;
        cout << "Élément: " << *it << endl;
    }

    cout << "la somme de tous les éléments est: " << somme << endl << endl;

    Horloge h1(16,2,4,0);
    Horloge h2(5,22,56,0);
    Horloge h3(7,15,8,0);
    Horloge h4(19,7,14,0);
    Horloge h5(55,9,5,0);
    Horloge h6(1,21,22,0);

    b1+= h1;
    b1+= h2;
    b1+= h3;
    b1+= h4;
    b1+= h5;
    b1+= h6;

    cout << "Itérateur de sac avec un sac d'horloge" << endl;

    IterateurSac<Horloge> it2(b1);
    for(; !it2; ++it2){
        cout << "Horloge: " << *it2 << endl;
    }

    system("PAUSE");
    return 0;
}
 /**
  * package http response header
  * @param responseData
  * @return
  */
 std::string packHTTPHeader(std::string responseData,
                            int responseNum,
                            std::string response) {
     std::string h1("HTTP/1.1 ");
     std::string h4("\nDate: ");
     //fake apache server:
     std::string h2("Server: Apache/1.0.0\nContent-Length: ");
     std::string h3 = this->persistent?"Keep-Alive":"close";
     time_t rawtime;
     time(&rawtime);
     return h1+std::to_string(responseNum)
            +" "+response+h4
            +std::string(ctime(&rawtime))+h2
            +std::to_string(responseData.length())
            +std::string("\nConnection: ")+h3
            //+std::string("\nContent-Type: text/html")
            +"\n\n"
            +std::string(responseData);
 }
Esempio n. 14
0
int main( int argc, char *argv[])
{
	try
	{
		tsk::static_pool< tsk::unbounded_prio_queue< int > > pool( tsk::poolsize( 3) ); 

		tsk::task< int > t1( fibonacci_fn, 10);
		tsk::task< int > t2( fibonacci_fn, 10);
		tsk::task< int > t3( fibonacci_fn, 10);
		tsk::task< int > t4( fibonacci_fn, 10);

		tsk::handle< int > h1(
			tsk::async( boost::move( t1) ) );
		tsk::handle< int > h2(
			tsk::async(
				boost::move( t2),
				tsk::new_thread() ) );
		tsk::handle< int > h3(
			tsk::async(
				boost::move( t3),
				2,
				pool) );
		tsk::handle< int > h4(
			tsk::async(
				boost::move( t4),
				2,
				pool) );

		std::cout << h1.get() << std::endl;
		std::cout << h2.get() << std::endl;
		std::cout << h3.get() << std::endl;
		std::cout << h4.get() << std::endl;

		return EXIT_SUCCESS;
	}
	catch ( std::exception const& e)
	{ std::cerr << "exception: " << e.what() << std::endl; }
	catch ( ... )
	{ std::cerr << "unhandled" << std::endl; }

	return EXIT_FAILURE;
}
Esempio n. 15
0
File: look.C Progetto: elaird/nuqe
void compare1() {
  Init();

  //mine
  TFile f1("../../events_1.root");
  TFile f4("../../events_4.root");
  gROOT->cd();
  TTree *tree1=(TTree*)f1.Get("tree");
  TGraph *gr1=(TGraph*)f1.Get("ccqe_rate");

  TTree *tree4=(TTree*)f4.Get("tree");
  TGraph *gr4=(TGraph*)f4.Get("ccqe_rate");

  
  Int_t N_bins=10;
  Double_t lower=0.0;
  Double_t upper=1.2;

  TString var="q[1]**2+q[2]**2+q[3]**2-q[0]**2";
  TString title=";Q^{2} (GeV^{2});d#sigma/dQ^{2} (cm^{2}/GeV^{2})";

  TH1D h1("h1",title,N_bins,lower,upper);
  h1.Sumw2();
  TH1D h4("h4",title,N_bins,lower,upper);
  h4.Sumw2();
  TH1D hr("hr",title,N_bins,lower,upper);
  hr.Sumw2();
  hr.GetYaxis()->SetTitle("ratio");
  
  Double_t dummy,xs1,xs4;

  gr1->GetPoint(1,dummy,xs1);
  gr4->GetPoint(4,dummy,xs4);

  tree1->Draw(var+">>h1","","goff");
  h1.Scale(xs1/h1.Integral("width"));
  tree4->Draw(var+">>h4","","goff");
  h4.Scale(xs4/h4.Integral("width"));

  hr.Divide(&h1,&h4);
  hr.DrawClone("");
}
Esempio n. 16
0
void main(j) {
  if (j & 1) {
    f1();
  }
  if (j & 2) {
    f2();
  }
  if (j & 3) {
    f3();
  }
  if (j & 4) {
    f4();
  }
  if (j & 5) {
    g1();
  }
  if (j & 6) {
    g2();
  }
  if (j & 7) {
    g3();
  }
  if (j & 8) {
    h1();
  }
  if (j & 9) {
    h2();
  }
  if (j & 10) {
    h3();
  }
  if (j & 11) {
    h4();
  }
  if (j & 12) {
    int v;
    k(&v);
  }

}
Esempio n. 17
0
/**
 * Decrypt a single block of data.
 */
void SKIPJACK::Dec::ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const
{
	word w1, w2, w3, w4;
	Block::Get(inBlock)(w4)(w3)(w2)(w1);

	/* stepping rule A: */
	h1(tab, w2); w3 ^= w2 ^ 32;
	h0(tab, w3); w4 ^= w3 ^ 31;
	h4(tab, w4); w1 ^= w4 ^ 30;
	h3(tab, w1); w2 ^= w1 ^ 29;
	h2(tab, w2); w3 ^= w2 ^ 28;
	h1(tab, w3); w4 ^= w3 ^ 27;
	h0(tab, w4); w1 ^= w4 ^ 26;
	h4(tab, w1); w2 ^= w1 ^ 25;

	/* stepping rule B: */
	w1 ^= w2 ^ 24; h3(tab, w2);
	w2 ^= w3 ^ 23; h2(tab, w3);
	w3 ^= w4 ^ 22; h1(tab, w4);
	w4 ^= w1 ^ 21; h0(tab, w1);
	w1 ^= w2 ^ 20; h4(tab, w2);
	w2 ^= w3 ^ 19; h3(tab, w3);
	w3 ^= w4 ^ 18; h2(tab, w4);
	w4 ^= w1 ^ 17; h1(tab, w1);

	/* stepping rule A: */
	h0(tab, w2); w3 ^= w2 ^ 16;
	h4(tab, w3); w4 ^= w3 ^ 15;
	h3(tab, w4); w1 ^= w4 ^ 14;
	h2(tab, w1); w2 ^= w1 ^ 13;
	h1(tab, w2); w3 ^= w2 ^ 12;
	h0(tab, w3); w4 ^= w3 ^ 11;
	h4(tab, w4); w1 ^= w4 ^ 10;
	h3(tab, w1); w2 ^= w1 ^  9;

	/* stepping rule B: */
	w1 ^= w2 ^ 8; h2(tab, w2);
	w2 ^= w3 ^ 7; h1(tab, w3);
	w3 ^= w4 ^ 6; h0(tab, w4);
	w4 ^= w1 ^ 5; h4(tab, w1);
	w1 ^= w2 ^ 4; h3(tab, w2);
	w2 ^= w3 ^ 3; h2(tab, w3);
	w3 ^= w4 ^ 2; h1(tab, w4);
	w4 ^= w1 ^ 1; h0(tab, w1);

	Block::Put(xorBlock, outBlock)(w4)(w3)(w2)(w1);
}
Esempio n. 18
0
void calcH(tNodeQueue *p, tNodeQueue *m, int heuristica) {
    m->elem->p = p->elem;
    switch (heuristica) {
        case 1:
            m->elem->h = h1(m->elem->matrix);
            break;
        case 2:
            m->elem->h = h2(m->elem->matrix);
            break;
        case 3:
            m->elem->h = h3(m->elem->matrix);
            break;
        case 4:
            m->elem->h = h4(m->elem->matrix, p1, p2, p3);
            break;
        case 5:
            m->elem->h = h5(m->elem->matrix);
            break;

    }
    m->elem->f = m->elem->h + m->elem->g;
}
Esempio n. 19
0
void test01()
{
    {
        String on1;
        on1 = "//atp:77/root/cimv25:"
              "TennisPlayer.last=\"Rafter\",first=\"Patrick\"";

        String on2;
        on2 = "//atp:77/root/cimv25:"
              "TennisPlayer.first=\"Patrick\",last=\"Rafter\"";

        CIMObjectPath r = on1;
        PEGASUS_TEST_ASSERT(r.toString() != on1);
        PEGASUS_TEST_ASSERT(r.toString() == on2);

        CIMObjectPath r2 = r;
        CIMObjectPath r3 = CIMObjectPath
            ("//atp:77/root/cimv25:"
            "TennisPlayer.first=\"Chris\",last=\"Evert\"");

        if (verbose)
        {
            XmlWriter::printValueReferenceElement(r, false);
            cout << r.toString() << endl;
        }

        Buffer mofOut;
        MofWriter::appendValueReferenceElement(mofOut, r);
        r.clear();
    }

    {
        CIMObjectPath r1 = CIMObjectPath
            ("MyClass.z=true,y=1234,x=\"Hello World\"");
        CIMObjectPath r2 = CIMObjectPath
            ("myclass.X=\"Hello World\",Z=true,Y=1234");
        CIMObjectPath r3 = CIMObjectPath ("myclass.X=\"Hello\",Z=true,Y=1234");
        // cout << r1.toString() << endl;
        // cout << r2.toString() << endl;
        PEGASUS_TEST_ASSERT(r1 == r2);
        PEGASUS_TEST_ASSERT(r1 != r3);
    }

    // Test case independence and order independence of parameters.
    {
        CIMObjectPath r1 = CIMObjectPath ("X.a=123,b=true");
        CIMObjectPath r2 = CIMObjectPath ("x.B=TRUE,A=123");
        PEGASUS_TEST_ASSERT(r1 == r2);
        PEGASUS_TEST_ASSERT(r1.makeHashCode() == r2.makeHashCode());

        CIMObjectPath r3 = CIMObjectPath ("x.B=TRUE,A=123,c=FALSE");
        PEGASUS_TEST_ASSERT(r1 != r3);
        String keyValue;

        Array<CIMKeyBinding> kbArray;
        {
            Boolean found = false;
            kbArray = r3.getKeyBindings();
            for (Uint32 i = 0; i < kbArray.size(); i++)
            {
                if (verbose)
                {
                    cout << "keyName= " <<  kbArray[i].getName().getString()
                         << " Value= " << kbArray[i].getValue() << endl;
                }
                if ( kbArray[i].getName() == CIMName ("B") )
                {
                    keyValue = kbArray[i].getValue();
                    if(keyValue == "TRUE")
                    found = true;
                }
            }
            if(!found)
            {
                cerr << "Key Binding Test error " << endl;
                exit(1);
            }
            //ATTN: KS 12 May 2002 P3 DEFER - keybinding manipulation. too
            // simplistic.
            // This code demonstrates that it is not easy to manipulate and
            // test keybindings.  Needs better tool both in CIMObjectPath and
            // separate.
        }
    }


    // Test building from component parts of CIM Reference.
    {
        CIMObjectPath r1 ("atp:77", CIMNamespaceName ("root/cimv25"),
            CIMName ("TennisPlayer"));
        CIMObjectPath r2 ("//atp:77/root/cimv25:TennisPlayer.");
        //cout << "r1 " << r1.toString() << endl;
        //cout << "r2 " << r2.toString() << endl;

        PEGASUS_TEST_ASSERT(r1 == r2);
        PEGASUS_TEST_ASSERT(r1.toString() == r2.toString());

    }


    {
        String hostName = "atp:77";
        String nameSpace = "root/cimv2";
        String className = "tennisplayer";

        CIMObjectPath r1;
        r1.setHost(hostName);
        r1.setNameSpace(nameSpace);
        r1.setClassName(className);
        PEGASUS_TEST_ASSERT(r1.getClassName().equal(CIMName ("TENNISPLAYER")));
        PEGASUS_TEST_ASSERT(!r1.getClassName().equal(CIMName ("blob")));


        String newHostName = r1.getHost();
        //cout << "HostName = " << newHostName << endl;

        CIMObjectPath r2 (hostName, nameSpace, className);
        PEGASUS_TEST_ASSERT(r1 == r2);
    }

    // Test cases for the Hostname.  CIMObjectPaths allows the
    // host to include the domain. Eg. xyz.company.com

    // First, try a good hostname
    CIMObjectPath h0("//usoPen-9.ustA-1-a.org:77/root/cimv25:"
        "TennisPlayer.first=\"Chris\",last=\"Evert\"");
    CIMObjectPath h1("//usoPen-9:77/root/cimv25:"
        "TennisPlayer.first=\"Chris\",last=\"Evert\"");
    CIMObjectPath h2("//usoPen-9/root/cimv25:"
        "TennisPlayer.first=\"Chris\",last=\"Evert\"");
    CIMObjectPath h3("//usoPen-9.ustA-1-a.org:0/root/cimv25:"
        "TennisPlayer.first=\"Chris\",last=\"Evert\"");
    CIMObjectPath h4("//usoPen-9.ustA-1-a.org:9876/root/cimv25:"
        "TennisPlayer.first=\"Chris\",last=\"Evert\"");
    CIMObjectPath h5("//usoPen-9.ustA-1-a.org:65535/root/cimv25:"
        "TennisPlayer.first=\"Chris\",last=\"Evert\"");
    CIMObjectPath h6("//usopen-9.usta-1-a.1org:77/root/cimv25:"
        "TennisPlayer.first=\"Chris\",last=\"Evert\"");
    CIMObjectPath h7("//192.168.1.com:77/root/cimv25:"
        "TennisPlayer.first=\"Chris\",last=\"Evert\"");
    CIMObjectPath h8("//192.168.0.org/root/cimv25:"
        "TennisPlayer.first=\"Chris\",last=\"Evert\"");
    CIMObjectPath h9("//192.168.1.80.com:77/root/cimv25:"
        "TennisPlayer.first=\"Chris\",last=\"Evert\"");
    CIMObjectPath h10("//192.168.0.80.org/root/cimv25:"
        "TennisPlayer.first=\"Chris\",last=\"Evert\"");
    CIMObjectPath h11("//192.168.1.80.255.com:77/root/cimv25:"
        "TennisPlayer.first=\"Chris\",last=\"Evert\"");
    CIMObjectPath h12("//192.168.0.80.254.org/root/cimv25:"
        "TennisPlayer.first=\"Chris\",last=\"Evert\"");
    CIMObjectPath h13("//192.168.257.80.com:77/root/cimv25:"
        "TennisPlayer.first=\"Chris\",last=\"Evert\"");
    CIMObjectPath h14("//192.256.0.80.org/root/cimv25:"
        "TennisPlayer.first=\"Chris\",last=\"Evert\"");

    CIMObjectPath h15("//localhost/root/cimv25:"
        "TennisPlayer.first=\"Chris\",last=\"Evert\"");
    CIMObjectPath h16("//ou812/root/cimv25:"
        "TennisPlayer.first=\"Chris\",last=\"Evert\"");
    CIMObjectPath h17("//u812/root/cimv25:"
        "TennisPlayer.first=\"Chris\",last=\"Evert\"");

    // Hostname with '_' character support checks, see bug#2556.
    CIMObjectPath h18("//_atp:9999/_root/_cimv25:_TennisPlayer");
    CIMObjectPath h19("//a_tp/_root/_cimv25:_TennisPlayer");
    CIMObjectPath h20("//atp_:9999/_root/_cimv25:_TennisPlayer");
    CIMObjectPath h21("//atp_-9:9999/_root/_cimv25:_TennisPlayer");
    CIMObjectPath h22(
        "//_a_t_p_-9.ustA-1-a.org:9999/_root/_cimv25:_TennisPlayer");
    CIMObjectPath h23("//_/root/cimv25:_TennisPlayer");
    CIMObjectPath h24("//_______/root/cimv25:_TennisPlayer");

    // try IPAddress as hostname which should be good
    CIMObjectPath h_ip0("//192.168.1.80:77/root/cimv25:"
        "TennisPlayer.first=\"Chris\",last=\"Evert\"");
    CIMObjectPath h_ip1("//192.168.0.255/root/cimv25:"
        "TennisPlayer.first=\"Chris\",last=\"Evert\"");

    // Try IPv6 Addresses.
    CIMObjectPath ip6_1("//[::1]:77/root/cimv25:"
        "TennisPlayer.first=\"Chris\",last=\"Evert\"");

    CIMObjectPath ip6_2("//[::ffff:192.1.2.3]:77/root/cimv25:"
        "TennisPlayer.first=\"Chris\",last=\"Evert\"");

    CIMObjectPath ip6_3("//[fffe:233:321:234d:e45:fad4:78:12]:77/root/cimv25:"
        "TennisPlayer.first=\"Chris\",last=\"Evert\"");

    CIMObjectPath ip6_4("//[fffe::]:77/root/cimv25:"
        "TennisPlayer.first=\"Chris\",last=\"Evert\"");


    Boolean errorDetected = false;

    // Invalid IPV6 Addresses
    try
    { // IPv6 addresses must be enclosed in brackets
        CIMObjectPath ip6_mb("//fffe::12ef:127/root/cimv25:"
            "TennisPlayer.first=\"Chris\",last=\"Evert\"");
    }
    catch (const Exception&)
    {
       errorDetected = true;
    }
    PEGASUS_TEST_ASSERT(errorDetected);

    errorDetected = false;
    try
    { // IPv6 address invalid
        CIMObjectPath ip6_invalid("//[fffe::sd:77]/root/cimv25:"
            "TennisPlayer.first=\"Chris\",last=\"Evert\"");
    }
    catch (const Exception&)
    {
       errorDetected = true;
    }
    PEGASUS_TEST_ASSERT(errorDetected);

    errorDetected = false;
    try
    {
       //Port number out of range.
       CIMObjectPath h_Port("//usoPen-9.ustA-1-a.org:9876543210/root/cimv25:"
           "TennisPlayer.first=\"Chris\",last=\"Evert\"");
    }
    catch (const Exception&)
    {
       errorDetected = true;
    }
    PEGASUS_TEST_ASSERT(errorDetected);

    errorDetected = false;
    try
    {
       //Port number out of range.
       CIMObjectPath h_Port("//usoPen-9.ustA-1-a.org:65536/root/cimv25:"
           "TennisPlayer.first=\"Chris\",last=\"Evert\"");
    }
    catch (const Exception&)
    {
       errorDetected = true;
    }
    PEGASUS_TEST_ASSERT(errorDetected);

    errorDetected = false;
    try
    {
       //Port number out of range.
       CIMObjectPath h_Port("//usoPen-9.ustA-1-a.org:100000/root/cimv25:"
           "TennisPlayer.first=\"Chris\",last=\"Evert\"");
    }
    catch (const Exception&)
    {
       errorDetected = true;
    }
    PEGASUS_TEST_ASSERT(errorDetected);

    errorDetected = false;
    try
    {
        //more than three digits in an octect
        CIMObjectPath h_ErrIp0("//192.1600008.1.80:77/root/cimv25:"
            "TennisPlayer.first=\"Chris\",last=\"Evert\"");
    }
    catch (const Exception&)
    {
        errorDetected = true;
    }
    PEGASUS_TEST_ASSERT(errorDetected);

    errorDetected = false;
    try
    {
        // Octet out of range
        CIMObjectPath op("//192.168.256.80:77/root/cimv25:"
            "TennisPlayer.first=\"Chris\",last=\"Evert\"");
    }
    catch (const Exception&)
    {
        errorDetected = true;
    }
    PEGASUS_TEST_ASSERT(errorDetected);

    errorDetected = false;
    try
    {
        // Missing port is okay, needs be ignored
        CIMObjectPath op("//192.168.1.80:/root/cimv25:"
            "TennisPlayer.first=\"Chris\",last=\"Evert\"");
    }
    catch (const Exception&)
    {
        errorDetected = true;
    }
    PEGASUS_TEST_ASSERT(!errorDetected);

    errorDetected = false;
    try
    {
        // Too many octets
        CIMObjectPath op("//192.168.1.80.12/root/cimv25:"
            "TennisPlayer.first=\"Chris\",last=\"Evert\"");
    }
    catch (const Exception&)
    {
        errorDetected = true;
    }
    PEGASUS_TEST_ASSERT(errorDetected);

    errorDetected = false;
    try
    {
        // Too few octets
        CIMObjectPath op("//192.168.80:77/root/cimv25:"
            "TennisPlayer.first=\"Chris\",last=\"Evert\"");
    }
    catch (const Exception&)
    {
        errorDetected = true;
    }
    PEGASUS_TEST_ASSERT(errorDetected);

    errorDetected = false;
    try
    {
        // Missing port is okay, needs be ignored
        CIMObjectPath op("//usopen-9.usta-1-a.org:/root/cimv25:"
            "TennisPlayer.first=\"Chris\",last=\"Evert\"");
    }
    catch (Exception&)
    {
        errorDetected = true;
    }
    PEGASUS_TEST_ASSERT(!errorDetected);

    errorDetected = false;
    try
    {
        // Hostname (IP) without trailing '/' (with port)
        CIMObjectPath op("//192.168.256.80:77");
    }
    catch (const Exception&)
    {
        errorDetected = true;
    }
    PEGASUS_TEST_ASSERT(errorDetected);

    errorDetected = false;
    try
    {
        // Hostname (IP) without trailing '/' (without port)
        CIMObjectPath op("//192.168.256.80");
    }
    catch (const Exception&)
    {
        errorDetected = true;
    }
    PEGASUS_TEST_ASSERT(errorDetected);

    errorDetected = false;
    try
    {
        // Hostname without trailing '/' (with port)
        CIMObjectPath op("//usopen-9.usta-1-a.org:77");
    }
    catch (const Exception&)
    {
        errorDetected = true;
    }
    PEGASUS_TEST_ASSERT(errorDetected);

    errorDetected = false;
    try
    {
        // Hostname without trailing '/' (without port)
        CIMObjectPath op("//usopen-9.usta-1-a.org");
    }
    catch (const Exception&)
    {
        errorDetected = true;
    }
    PEGASUS_TEST_ASSERT(errorDetected);

    errorDetected = false;
    try
    {
        // Invalid first character
        CIMObjectPath op("//+usopen-9.usta-1-a.1org:77/root/cimv25:"
            "TennisPlayer.first=\"Chris\",last=\"Evert\"");
    }
    catch (Exception&)
    {
        errorDetected = true;
    }
    PEGASUS_TEST_ASSERT(errorDetected);

    errorDetected = false;
    try
    {
        // Non-alphanum char (?)
        CIMObjectPath op("//usopen-9.usta?-1-a.org:77/root/cimv25:"
            "TennisPlayer.first=\"Chris\",last=\"Evert\"");
    }
    catch (Exception&)
    {
        errorDetected = true;
    }
    PEGASUS_TEST_ASSERT(errorDetected);

    errorDetected = false;
    try
    {
        // Leading dot
        CIMObjectPath op("//.usopen-9.usta-1-a.org:77/root/cimv25:"
            "TennisPlayer.first=\"Chris\",last=\"Evert\"");
    }
    catch (Exception&)
    {
        errorDetected = true;
    }
    PEGASUS_TEST_ASSERT(errorDetected);

    errorDetected = false;
    try
    {
        // Dot in the wrong spot (before a -)
        CIMObjectPath op("//usopen.-9.usta-1-a.org:77/root/cimv25:"
            "TennisPlayer.first=\"Chris\",last=\"Evert\"");
    }
    catch (Exception&)
    {
        errorDetected = true;
    }
    PEGASUS_TEST_ASSERT(errorDetected);

    errorDetected = false;
    try
    {
        // Two dots in a row
        CIMObjectPath op("//usopen-9.usta-1-a..org:77/root/cimv25:"
            "TennisPlayer.first=\"Chris\",last=\"Evert\"");
    }
    catch (Exception&)
    {
        errorDetected = true;
    }
    PEGASUS_TEST_ASSERT(errorDetected);

    errorDetected = false;
    try
    {
        // Trailing dot
        CIMObjectPath op("//usopen-9.usta-1-a.org.:77/root/cimv25:"
            "TennisPlayer.first=\"Chris\",last=\"Evert\"");
    }
    catch (Exception&)
    {
        errorDetected = true;
    }
    PEGASUS_TEST_ASSERT(errorDetected);
}
Esempio n. 20
0
//---------------------------------------------------------------------------//
TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( HistoryBuffer, buffering, Ordinal )
{
    typedef MCLS::AdjointHistory<Ordinal> HT;
    HT::setByteSize();

    int num_history = 4;
    MCLS::HistoryBuffer<HT> buffer( HT::getPackedBytes(), num_history );
    TEST_EQUALITY( MCLS::HistoryBuffer<HT>::maxNum(), 4 );
    TEST_EQUALITY( MCLS::HistoryBuffer<HT>::sizePackedHistory(),
		   sizeof(double)+sizeof(Ordinal)+3*sizeof(int) );

    TEST_EQUALITY( buffer.allocatedSize(),
		   num_history*MCLS::HistoryBuffer<HT>::sizePackedHistory() 
		   + sizeof(int) );
    TEST_ASSERT( buffer.isEmpty() );
    TEST_EQUALITY( buffer.numHistories(), 0 );

    std::stack<HT> bank;
    TEST_ASSERT( bank.empty() );

    HT h1( 1, 1, 1 );
    HT h2( 2, 2, 2 );
    HT h3( 3, 4, 3 );
    HT h4( 4, 4, 4 );

    buffer.bufferHistory( h1 );
    TEST_ASSERT( !buffer.isFull() );
    TEST_ASSERT( !buffer.isEmpty() );
    TEST_EQUALITY( buffer.numHistories(), 1 );

    buffer.bufferHistory( h2 );
    TEST_ASSERT( !buffer.isFull() );
    TEST_ASSERT( !buffer.isEmpty() );
    TEST_EQUALITY( buffer.numHistories(), 2 );

    buffer.bufferHistory( h3 );
    TEST_ASSERT( !buffer.isFull() );
    TEST_ASSERT( !buffer.isEmpty() );
    TEST_EQUALITY( buffer.numHistories(), 3 );

    buffer.bufferHistory( h4 );
    TEST_ASSERT( buffer.isFull() );
    TEST_ASSERT( !buffer.isEmpty() );
    TEST_EQUALITY( buffer.numHistories(), 4 );

    buffer.addToBank( bank );

    HT ph1, ph2, ph3, ph4;

    TEST_EQUALITY( bank.size(), 4 );
    ph4 = bank.top();
    bank.pop();
    TEST_EQUALITY( ph4.globalState(), 4 );
    TEST_EQUALITY( ph4.weight(), 4 );

    TEST_EQUALITY( bank.size(), 3 );
    ph3 = bank.top();
    bank.pop();
    TEST_EQUALITY( ph3.globalState(), 3 );
    TEST_EQUALITY( ph3.weight(), 3 );

    TEST_EQUALITY( bank.size(), 2 );
    ph2 = bank.top();
    bank.pop();
    TEST_EQUALITY( ph2.globalState(), 2 );
    TEST_EQUALITY( ph2.weight(), 2 );

    TEST_EQUALITY( bank.size(), 1 );
    ph1 = bank.top();
    bank.pop();
    TEST_EQUALITY( ph1.globalState(), 1 );
    TEST_EQUALITY( ph1.weight(), 1 );

    TEST_ASSERT( bank.empty() );
}
Esempio n. 21
0
/* --std=c90 -Wv */
void f1(void) { int i; struct tag { int x; } x; int *p; i(); x(); p(); }
void f2(void) { void h2(int, double); void g2(); h2(0, 1); g2(0, 1); }    /* prototype vs. non-prototype */
void f3(void) { struct tag { int x; } h3(void), x; int g3(void), y; x = h3(); y = g3(); }    /* struct vs. non-struct */
void f4(void) { struct tag h4(void); h4(); }    /* error - incomplete return */
Esempio n. 22
0
void pull( int n_toys = 10000,
      int n_tot_entries = 100,
      int nbins = 40,
      bool do_chi2=true ){

    TString method_prefix("Log-Likelihood ");
    if (do_chi2)
        method_prefix="#chi^{2} ";

    // Create histo
    TH1F h4(method_prefix+"h4",
            method_prefix+" Random Gauss",
            nbins,-4,4);
    h4.SetMarkerStyle(21);
    h4.SetMarkerSize(0.8);
    h4.SetMarkerColor(kRed);

    // Histogram for sigma and pull
    TH1F sigma(method_prefix+"sigma",
               method_prefix+"sigma from gaus fit",
               50,0.5,1.5);
    TH1F pull(method_prefix+"pull",
              method_prefix+"pull from gaus fit",
              50,-4.,4.);

    // Make nice canvases
    auto c0 = new TCanvas(method_prefix+"Gauss",
                          method_prefix+"Gauss",0,0,320,240);
    c0->SetGrid();

    // Make nice canvases
    auto c1 = new TCanvas(method_prefix+"Result",
                          method_prefix+"Sigma-Distribution",
                          0,300,600,400);
    c0->cd();

    float sig, mean;
    for (int i=0; i<n_toys; i++){
     // Reset histo contents
        h4.Reset();
     // Fill histo
        for ( int j = 0; j<n_tot_entries; j++ )
        h4.Fill(gRandom->Gaus());
     // perform fit
        if (do_chi2) h4.Fit("gaus","q"); // Chi2 fit
        else h4.Fit("gaus","lq"); // Likelihood fit
     // some control output on the way
        if (!(i%100)){
            h4.Draw("ep");
            c0->Update();}

     // Get sigma from fit
        TF1 *fit = h4.GetFunction("gaus");
        sig = fit->GetParameter(2);
        mean= fit->GetParameter(1);
        sigma.Fill(sig);
        pull.Fill(mean/sig * sqrt(n_tot_entries));
       } // end of toy MC loop
     // print result
        c1->cd();
        pull.DrawClone();
}
Esempio n. 23
0
void jecplots(){

  gROOT->SetStyle("Plain");
   
  gStyle->SetPalette(1);
  gStyle->SetOptStat(1111111);  // Show overflow, underflow + SumOfWeights 
  gStyle->SetOptFit(111110); 
  gStyle->SetOptFile(1); 
  
  gStyle->SetMarkerStyle(20);
  gStyle->SetMarkerSize(.3);
  gStyle->SetMarkerColor(1);

  TCanvas* c0 = new TCanvas("c0"," ",200,10,500,500);
  c0->Clear();

  TFile g("/tmp/delre/vbf.root");
  TFile g1("/tmp/delre/vbf1.root");
  TFile g2("/tmp/delre/vbf2.root");
  TFile g3("/tmp/delre/vbf3.root");
  TFile g4("/tmp/delre/vbf4.root");
  TFile h("/tmp/delre/vh.root");
  TFile h1("/tmp/delre/vh1.root");
  TFile h2("/tmp/delre/vh2.root");
  TFile h3("/tmp/delre/vh3.root");
  TFile h4("/tmp/delre/vh4.root");

  g.cd();
  JECresovbf->SetTitle("");
  JECresovbf->SetStats(0);
  JECresovbf->SetXTitle("(p_{T}^{meas}-p_{T}^{gen}))/p_{T}^{gen}");
  JECresovbf->Draw();
  g1.cd();
  JECresovbf->SetLineColor(kRed);
  JECresovbf->Draw("same");
  g2.cd();
  JECresovbf->SetLineColor(kBlue);
  JECresovbf->Draw("same");
  
  c0->SaveAs("JECsyst_vbf.png");
  
  h.cd();
  JECresovh->SetTitle("");
  JECresovh->SetStats(0);
  JECresovh->SetXTitle("(p_{T}^{meas}-p_{T}^{gen}))/p_{T}^{gen}");
  JECresovh->Draw();
  h1.cd();
  JECresovh->SetLineColor(kRed);
  JECresovh->Draw("same");
  h2.cd();
  JECresovh->SetLineColor(kBlue);
  JECresovh->Draw("same");
  
  c0->SaveAs("JECsyst_vh.png");
   
  g4.cd();
  JECresovbf->SetLineColor(kRed);
  JECresovbf->SetTitle("");
  JECresovbf->SetStats(0);
  JECresovbf->SetXTitle("(p_{T}^{meas}-p_{T}^{gen}))/p_{T}^{gen}");
  JECresovbf->Draw();
  g.cd();
  JECresovbf->Draw("same");
  g3.cd();
  JECresovbf->SetLineColor(kBlue);
  JECresovbf->Draw("same");
  
  c0->SaveAs("JERsyst_vbf.png");
  
  h4.cd();
  JECresovh->SetTitle("");
  JECresovh->SetLineColor(kRed);
  JECresovh->SetStats(0);
  JECresovh->SetXTitle("(p_{T}^{meas}-p_{T}^{gen}))/p_{T}^{gen}");
  JECresovh->Draw();
  h.cd();
  JECresovh->Draw("same");
  h3.cd();
  JECresovh->SetLineColor(kBlue);
  JECresovh->Draw("same");
  
  c0->SaveAs("JERsyst_vh.png");
   

}
void TestStelSphericalGeometry::testSphericalCap()
{
	Vec3d p0(1.,0.,0.);
	Vec3d p1(-1.,0.,0.);
	Vec3d p2(1.,1.,1.);
	p2.normalize();
	Vec3d p3(0.,1.,0.);

	SphericalCap h0(p0, 0.);
	SphericalCap h1(p0, 0.8);
	SphericalCap h2(p0, -0.5);
	SphericalCap h3(p1, 0.5);
	SphericalCap h4(p2, 0.8);
	SphericalCap h5(p2, 1.);
	SphericalCap h6(p1, 0.);

	QVERIFY2(h0.contains(p0), "SphericalCap contains point failure");
	QVERIFY2(h1.contains(p0), "SphericalCap contains point failure");
	QVERIFY2(h0.contains(p3), "SphericalCap contains point on the edge failure");
	QVERIFY2(h6.contains(p3), "SphericalCap contains point on the edge failure");

	QVERIFY(h0.intersects(h1));
	QVERIFY(h0.intersects(h2));
	QVERIFY(h1.intersects(h2));
	QVERIFY(h4.intersects(h1));
	QVERIFY(!h0.intersects(h3));
	QVERIFY(!h1.intersects(h3));
	QVERIFY(h2.intersects(h3));
	QVERIFY(h0.intersects(h5));

	QVERIFY(h0.intersects(h0));
	QVERIFY(h1.intersects(h1));
	QVERIFY(h2.intersects(h2));
	QVERIFY(h3.intersects(h3));
	QVERIFY(h4.intersects(h4));
	QVERIFY(h5.intersects(h5));
	QVERIFY(h6.intersects(h0));
	QVERIFY(h0.intersects(h6));

	QVERIFY(h0.contains(h1));
	QVERIFY(!h1.contains(h0));
	QVERIFY(h2.contains(h0));
	QVERIFY(!h0.contains(h2));
	QVERIFY(!h6.contains(h0));
	QVERIFY(!h0.contains(h6));
	QVERIFY(h2.contains(h1));
	QVERIFY(!h1.contains(h2));
	QVERIFY(!h0.contains(h3));
	QVERIFY(!h1.contains(h3));
	QVERIFY(h0.contains(h5));
	QVERIFY(h2.contains(h5));
	QVERIFY(!h5.contains(h0));
	QVERIFY(!h5.contains(h1));
	QVERIFY(!h5.contains(h2));
	QVERIFY(!h5.contains(h3));
	QVERIFY(!h5.contains(h4));
	QVERIFY(h0.contains(h0));
	QVERIFY(h1.contains(h1));
	QVERIFY(h2.contains(h2));
	QVERIFY(h3.contains(h3));
	QVERIFY(h4.contains(h4));
	QVERIFY(h5.contains(h5));
}
Esempio n. 25
0
MarkdownEdit::MarkdownEdit(LiteApi::IApplication *app, LiteApi::IEditor *editor, QObject *parent) :
    QObject(parent), m_liteApp(app)
{
    m_editor = LiteApi::getTextEditor(editor);
    if (!m_editor) {
        return;
    }
    m_ed = LiteApi::getPlainTextEdit(editor);
    if (!m_ed) {
        return;
    }
    m_ed->setLineWrapMode(QPlainTextEdit::WidgetWidth);

    LiteApi::IActionContext *actionContext = m_liteApp->actionManager()->getActionContext(this,"Markdown");

    QAction *h1 = new QAction(QIcon("icon:markdown/images/h1.png"),tr("Header (h1)"),this);
    actionContext->regAction(h1,"Header1","Ctrl+1");

    QAction *h2 = new QAction(QIcon("icon:markdown/images/h2.png"),tr("Header (h2)"),this);
    actionContext->regAction(h2,"Header2","Ctrl+2");

    QAction *h3 = new QAction(QIcon("icon:markdown/images/h3.png"),tr("Header (h3)"),this);
    actionContext->regAction(h3,"Header3","Ctrl+3");

    QAction *h4 = new QAction(QIcon("icon:markdown/images/h4.png"),tr("Header (h4)"),this);
    actionContext->regAction(h4,"Header4","Ctrl+4");

    QAction *h5 = new QAction(QIcon("icon:markdown/images/h5.png"),tr("Header (h5)"),this);
    actionContext->regAction(h5,"Header5","Ctrl+5");

    QAction *h6 = new QAction(QIcon("icon:markdown/images/h6.png"),tr("Header (h6)"),this);
    actionContext->regAction(h6,"Header6","Ctrl+6");

    QAction *bold = new QAction(QIcon("icon:markdown/images/bold.png"),tr("Bold"),this);
    actionContext->regAction(bold,"Bold",QKeySequence::Bold);

    QAction *italic = new QAction(QIcon("icon:markdown/images/italic.png"),tr("Italic"),this);
    actionContext->regAction(italic,"Italic",QKeySequence::Italic);

    QAction *code = new QAction(QIcon("icon:markdown/images/code.png"),tr("Inline Code"),this);
    actionContext->regAction(code,"InlineCode","Ctrl+K");

    QAction *link = new QAction(QIcon("icon:markdown/images/link.png"),tr("Link"),this);
    actionContext->regAction(link,"Link","Ctrl+Shift+L");

    QAction *image = new QAction(QIcon("icon:markdown/images/image.png"),tr("Image"),this);
    actionContext->regAction(image,"Image","Ctrl+Shift+I");

    QAction *ul = new QAction(QIcon("icon:markdown/images/ul.png"),tr("Unordered List"),this);
    actionContext->regAction(ul,"UnorderedList","Ctrl+Shift+U");

    QAction *ol = new QAction(QIcon("icon:markdown/images/ol.png"),tr("Ordered List"),this);
    actionContext->regAction(ol,"OrderedList","Ctrl+Shift+O");

    QAction *bq = new QAction(QIcon("icon:markdown/images/quote.png"),tr("Blockquote"),this);
    actionContext->regAction(bq,"Blockquote","Ctrl+Shift+Q");

    QAction *hr = new QAction(QIcon("icon:markdown/images/hr.png"),tr("Horizontal Rule"),this);
    actionContext->regAction(hr,"HorizontalRule","Ctrl+Shift+H");

    QToolBar *toolBar = LiteApi::findExtensionObject<QToolBar*>(editor,"LiteApi.QToolBar");

    QMenu *menu = LiteApi::getEditMenu(editor);
    if (menu) {
        menu->addSeparator();
        QMenu *h = menu->addMenu(tr("Heading"));
        h->addAction(h1);
        h->addAction(h2);
        h->addAction(h3);
        h->addAction(h4);
        h->addAction(h5);
        h->addAction(h6);
        menu->addSeparator();
        menu->addAction(link);
        menu->addAction(image);
        menu->addSeparator();
        menu->addAction(bold);
        menu->addAction(italic);
        menu->addAction(code);
        menu->addSeparator();
        menu->addAction(ul);
        menu->addAction(ol);
        menu->addSeparator();
        menu->addAction(bq);
        menu->addAction(hr);
    }
    menu = LiteApi::getContextMenu(editor);
    if (menu) {
        menu->addSeparator();
        menu->addAction(link);
        menu->addAction(image);
        menu->addSeparator();
        menu->addAction(bold);
        menu->addAction(italic);
        menu->addAction(code);
        menu->addSeparator();
        menu->addAction(ul);
        menu->addAction(ol);
        menu->addSeparator();
        menu->addAction(bq);
        menu->addAction(hr);
    }

    if (toolBar) {
        toolBar->addSeparator();
        toolBar->addAction(h1);
        toolBar->addAction(h2);
        toolBar->addAction(h3);
        toolBar->addSeparator();
        toolBar->addAction(link);
        toolBar->addAction(image);
        toolBar->addSeparator();
        toolBar->addAction(bold);
        toolBar->addAction(italic);
        toolBar->addAction(code);
        toolBar->addSeparator();
        toolBar->addAction(ul);
        toolBar->addAction(ol);
        toolBar->addSeparator();
        toolBar->addAction(bq);
        toolBar->addAction(hr);
        //updateToolTip(toolBar);
    }

    connect(editor,SIGNAL(destroyed()),this,SLOT(deleteLater()));
    connect(h1,SIGNAL(triggered()),this,SLOT(h1()));
    connect(h2,SIGNAL(triggered()),this,SLOT(h2()));
    connect(h3,SIGNAL(triggered()),this,SLOT(h3()));
    connect(h4,SIGNAL(triggered()),this,SLOT(h4()));
    connect(h5,SIGNAL(triggered()),this,SLOT(h5()));
    connect(h6,SIGNAL(triggered()),this,SLOT(h6()));
    connect(bold,SIGNAL(triggered()),this,SLOT(bold()));
    connect(italic,SIGNAL(triggered()),this,SLOT(italic()));
    connect(code,SIGNAL(triggered()),this,SLOT(code()));
    connect(link,SIGNAL(triggered()),this,SLOT(link()));
    connect(image,SIGNAL(triggered()),this,SLOT(image()));
    connect(ul,SIGNAL(triggered()),this,SLOT(ul()));
    connect(ol,SIGNAL(triggered()),this,SLOT(ol()));
    connect(bq,SIGNAL(triggered()),this,SLOT(bq()));
    connect(hr,SIGNAL(triggered()),this,SLOT(hr()));

    //m_ed->installEventFilter(this);
}
Esempio n. 26
0
void p_dist_look(Int_t mode=0) {
  gROOT->SetStyle("Plain");

  TFile f("p_dists.root");
  gROOT->cd();
  TGraph *sm=(TGraph*)f.Get("sm")->Clone();
  TGraph *mf=(TGraph*)f.Get("mf")->Clone();
  TGraph *corr=(TGraph*)f.Get("corr")->Clone();
  TGraph *tot=(TGraph*)f.Get("tot")->Clone();
  f.Close();

  TFile g("../ref/polish/O16/graph.root");
  gROOT->cd();
  TGraph *as_mf=(TGraph*)g.Get("polish_n_mf")->Clone();
  TGraph *as_corr=(TGraph*)g.Get("polish_n_corr")->Clone();
  f.Close();

  if (mode==1) {
    tot->DrawClone("ap");
    sm->DrawClone("psame");
    mf->DrawClone("psame");
    corr->DrawClone("psame");
    gPad->SetLogy();
  }

  if (mode==2) {
    mf->DrawClone("ap");
    corr->DrawClone("psame");
    as_mf->SetMarkerColor(kRed);
    as_mf->DrawClone("psame");
    as_corr->SetMarkerColor(kBlue);
    as_corr->DrawClone("psame");
    gPad->SetLogy();
    
  }

  if (mode==3) {
    Int_t n_points=tot->GetN();
    Int_t n_bins=n_points;

    Double_t p_max,y;
    tot->GetPoint(n_points-1,p_max,y);

    TH1D h1("h1","",n_bins,0.0,p_max);
    TH1D h2("h2","",n_bins,0.0,p_max);
    TH1D h3("h3","",n_bins,0.0,p_max);
    TH1D h4("h4","",n_bins,0.0,p_max);

    for (Int_t iBin=1;iBin<=n_bins;iBin++) {
      Double_t value1=sm->Eval(h1.GetBinCenter(iBin));
      value1*=4.0*TMath::Pi()*pow(h1.GetBinCenter(iBin),2);
      h1.SetBinContent(iBin,value1);

      Double_t value2=mf->Eval(h2.GetBinCenter(iBin));
      value2*=4.0*TMath::Pi()*pow(h2.GetBinCenter(iBin),2);
      h2.SetBinContent(iBin,value2);

      Double_t value3=tot->Eval(h3.GetBinCenter(iBin));
      value3*=4.0*TMath::Pi()*pow(h3.GetBinCenter(iBin),2);
      h3.SetBinContent(iBin,value3);

      Double_t value4=corr->Eval(h4.GetBinCenter(iBin));
      value4*=4.0*TMath::Pi()*pow(h4.GetBinCenter(iBin),2);
      h4.SetBinContent(iBin,value4);
    }

    h1.SetStats(kFALSE);
    h1.SetTitle(";p (GeV);N_{target nucleons}/GeV");
    h2.SetLineColor(kRed);
    h3.SetLineColor(kBlue);
    h4.SetLineColor(kGreen);

    h1.DrawCopy();
    h2.DrawCopy("same");
    h4.DrawCopy("same");
    h3.DrawCopy("same");

    TLegend legend(0.45,0.6,0.9,0.9,"^{16}O");
    legend.SetBorderSize(0);
    legend.SetFillStyle(0);
    legend.AddEntry(&h1,"Smith-Moniz","l");
    legend.AddEntry(&h2,"Ciofi degli Atti-Simula mean field (MF)","l");
    legend.AddEntry(&h4,"Ciofi degli Atti-Simula correlated (corr)","l");
    legend.AddEntry(&h3,"Ciofi degli Atti-Simula total","l");
    legend.DrawClone("same");

    gPad->SetLogy(0);
    cout << "h1.int: " << h1.Integral("width") << endl;
    cout << "h2.int: " << h2.Integral("width") << endl;
    cout << "h3.int: " << h3.Integral("width") << endl;
    cout << "h4.int: " << h4.Integral("width") << endl;
  }
  
  delete sm;
  delete mf;
  delete corr;
  delete tot;
}
Esempio n. 27
0
int wx::orgdata (wxdata_t *wx, char *oneline)
//*************************************************************************
//
// calculates raw data values from onelineformat
//
//   3 YYYY = wind speed (0.1km/h)
//   7 zzZZ = wind direction (ZZ 0..255) zz indicates calibration (00/ff)
//  11 OOOO = outdoor temperature (0.1 fahrenheit)
//  15 XXXX = rain, long term total (0.01 inches)
//  19 PPPP = barometer  (0.1 hPa=0.1 mBar)
//  23 IIII = indoor temperature (0.1 fahrenheit)
//  27 WWWW = outdoor humidity  (0.1 per cent)
//  31 RRRR = indoor humidity (0.1 per cent), inactive
//  35 DDDD = day of year (1.jan = 0000)
//  39 MMMM = minute of day (00:00 = 0000)
//  43 YYYY = today's rain total (0.01 inches)
//  47 UUUU = 1 minute wind adverage (0.1km/h)
//     <CR><LF>
//
//              YYYYZZZZOOOOXXXXPPPPIIIIWWWWRRRRDDDDMMMMYYYYUUUU
//            !!0000000F00DC05D7254202CA03AB----0164045D00000000
//            12345678901234567890123456789012345678901234567890
//                     1   2       3       4       5
//*************************************************************************
{
 char name[20];
 strcpy(name, "wx:orgdata");
 double khdif;
 int bad = 0; //line must be incorrect

 // simple check if string is correct
 if (strlen(oneline) != 50 || oneline[0] != '!')
   return 0;

 // measured data
 // using 1 min average here
 wx->windspeed = h4(oneline, 47) / 10.0 / 3.6; // m/s, orginally in 0.1km/h
 wx->wind_direction = h4(oneline, 7); // 0..255
 wx->wind_direction = wx->wind_direction * 360.0/255.0; // 0..360 degrees
 wx->outdoort = h4(oneline, 11) / 10.0; // 0.1fahrenheit
 wx->outdoort = (wx->outdoort - 32.0) / 1.8; // celsius
 wx->rainltt = h4(oneline, 15); // 0.01 inches, long term total
 wx->rainltt = wx->rainltt/2.54; // 1mm
 wx->air_pres_qfe = h4(oneline, 19) / 10.0; // 0.1hPa or 0.1mBar
 wx->indoort = h4(oneline, 23) / 10.0; // 0.1fahrenheit
 wx->indoort = (wx->indoort -32.0) / 1.8; // 1celsius
 wx->humidity = h4(oneline, 27) / 10.0;
 wx->hum_indoor = h4(oneline, 31);
 wx->dayoyear = h4(oneline, 35)+1;
 wx->minuteofday = h4(oneline, 39);
 wx->winddir_str = get_wdir_str(wx->wind_direction);
 wx->t = ad_time();
 // check data
 if (wx->windspeed < 0 || wx->windspeed > 300)
 {
   wx->windspeed = 0;
   bad++;
 }
 if (wx->humidity > 99.0)
 {
   wx->humidity = 99.0; // must be less than 100%
   bad++;
 }
 if (wx->humidity < 0)
 {
   wx->humidity = 0;
   bad++;
 }
 if (wx->outdoort < -50 ||wx->outdoort > 70)
 {
   wx->outdoort = 0;
   bad++;
 }
 if (wx->indoort < -50 || wx->indoort > 70)
 {
   wx->indoort = 0;
   bad++;
 }
 if (wx->air_pres_qfe < 0)
 {
   wx->air_pres_qfe = 0;
   bad++;
 }
 if (bad)
 {
   trace(report, name, "bad: %s", oneline);
   return 0;
 }
 // calculated data

 // wind-chill
 // formulas by DL1ZAJ

 // luftdruck qnh
 wx->air_pres_qnh = wx->air_pres_qfe + (m.wxqthaltitude /
                     (8.7 - (m.wxqthaltitude * 0.0005)));

 // Fühlbare Temperatur (Windchill) in C
 //    FT = (-0.0432 * (SQR(100 * WMS) + 10.45 - WMS) * (33 - T)) + 31.46
 //  adopted: windspeed+1.0 => better results with low speeds,
 //   result must be lower than real temperatur (DerStandard,
 //   28.12.96)
 wx->wind_chill = (-0.0432 * ((double)sqrt(100.0*(wx->windspeed+1.0))+10.45 -
                   (wx->windspeed+1.0))*(33.0-wx->outdoort))+31.46;
 if (wx->wind_chill > wx->outdoort)
   wx->wind_chill = wx->outdoort;

 // Saettigungsdampfdruck
 //   Saettigungsdampfdruck in hPa
 //   IF T > 0 THEN
 //   SDAD = 6.09 * 10 ^ ((7.5 * T) / (237.3 + T))
 //   ELSE
 //   SDAD = 6.09 * 10 ^ ((9.5 * T) / (265.5 + T))
 //   END IF
 if (wx->outdoort > 0)
   wx->sat_sp = 6.09 * (double) exp(((7.5*wx->outdoort)/(273.3 +
                                     wx->outdoort))*log(10.0));
 else
   wx->sat_sp = 6.09 * exp(((9.5*wx->outdoort)/(265.5 +
                             wx->outdoort))*log(10));

 // steam_pressure
 wx->steam_pressure = (wx->humidity * wx->sat_sp) / 100.0;

 // Absolute Feuchte
 //   Absolute Feuchte in Gramm H2O / m3
 //   LDI = QFE / (2.8704 * TKE) Luftdichte in Kilogramm / m3
 //   SPFEU = (623 * DAD) / (QFE - 0.377 * DAD) Spezifische Feuchte
 //                                             in Gramm H2O / Kilogramm
 //   AFEU = SPFEU * LDI
 if (wx->air_pres_qfe > 0)
   wx->abs_humidity = ((623*wx->steam_pressure)/(wx->air_pres_qfe - 0.377 *
                          wx->steam_pressure)) *
                       (wx->air_pres_qfe/(2.8704*(wx->outdoort+273.15)));
 else
   wx->abs_humidity = 0;

 // Taupunkt
 //     Taupunkt in °C
 //     TP = (234.67 * (LOG(DAD) / LOG(10)) - 184.2) /
 //          (8.233 - (LOG(DAD) / LOG(10)))
 if (wx->steam_pressure > 0)
   wx->dew_point = (234.67 * (log(wx->steam_pressure)/log(10))-184.2)/
                         (8.233 - (log(wx->steam_pressure)/log(10)));
 else
   wx->dew_point = 0;

 // Kondensationsnivau
 //     Kondensationsniveau (Wolkenuntergrenze für Cumuluswolken) in Meter über NN
 //     KON = (T + ((SSH - 2) / 100) - TP) * 120
 wx->kond_niveau = (wx->outdoort + ((m.wxsensoraltitude-2.0)/100.0)-
                                     wx->dew_point)*120.0;

 // Schneefallgrenze in m
 //     Schneefallgrenze/Null-Grad-Niveau in KILOMETER über NN
 //     SFG = (T / 10) + (HOEHE / 1000)
 //     KHDIF = (KON - HOEHE) / 100
 //     IF (T * 100) > KON THEN SFG = SFG + (KHDIF / 6) - (KHDIF / 10)
 //     IF SFG < 0 THEN SFG = 0
 //     Anzeige der SFG (in km) in METERN (in Schritten von 10 Metern) :
 //     SFG = CINT(SFG * 100) * 10
 wx->snowfall_limit = (wx->outdoort/10)+(m.wxqthaltitude/1000);
 khdif = (wx->kond_niveau - m.wxqthaltitude) / 100;
 if ((wx->outdoort * 100) > wx->kond_niveau)
   wx->snowfall_limit = wx->snowfall_limit + (khdif/6) - (khdif/10);
 if (wx->snowfall_limit < 0)
   wx->snowfall_limit = 0;
 else // not in 1km units but in 1m units
   wx->snowfall_limit = 1000 * wx->snowfall_limit;

 // Windstaerke in Beaufort
 //     BEAU = CINT(10 ^ ((LOG(((WMS - 0.07) / 0.834) ^ 2) / LOG(10)) / 3))
 //     Different data from "Zentralanstalt für Metereologie und Geodynamik
 //     Wien" used here
 //     newer data from Willy, oe3wyc
                    //0    1    2    3    4    5     6
 double beau_tab[] = {0, 0.3, 1.5, 3.3, 5.4, 7.9, 10.7,
                     //  7     8     9    10    11    12
                      13.8, 17.1, 20.7, 24.4, 28.4, 32.6};
 wx->wind_beaufort = 12; // Maximum
 while (wx->wind_beaufort && beau_tab[wx->wind_beaufort] > wx->windspeed)
   wx->wind_beaufort--;

 wx->data_valid = 1;
 return 1;
}