예제 #1
0
int main()
{
   // check that it'll find nodes exactly MAX away
   {
      tree_type exact_dist(std::ptr_fun(tac));
        triplet c0(5, 4, 0);
        exact_dist.insert(c0);
        triplet target(7,4,0);

      std::pair<tree_type::const_iterator,double> found = exact_dist.find_nearest(target,2);
      assert(found.first != exact_dist.end());
      assert(found.second == 2);
      std::cout << "Test find_nearest(), found at exact distance away from " << target << ", found " << *found.first << std::endl;
   }

   // do the same test, except use alternate_triplet as the search key
   {
      // NOTE: stores triplet, but we search with alternate_triplet
      typedef KDTree::KDTree<3, triplet, alternate_tac> alt_tree;

      triplet actual_target(7,0,0);

      alt_tree tree;
      tree.insert( triplet(0, 0, 7) );
      tree.insert( triplet(0, 0, 7) );
      tree.insert( triplet(0, 0, 7) );
      tree.insert( triplet(3, 0, 0) );
      tree.insert( actual_target );
      tree.optimise();

      alternate_triplet target( actual_target );

      std::pair<alt_tree::const_iterator,double> found = tree.find_nearest(target);
      assert(found.first != tree.end());
      std::cout << "Test with alternate search type, found: " << *found.first << ", wanted " << actual_target << std::endl;
      assert(found.second == 0);
      assert(*found.first == actual_target);
   }


   {
      tree_type exact_dist(std::ptr_fun(tac));
        triplet c0(5, 2, 0);
        exact_dist.insert(c0);
        triplet target(7,4,0);

        // call find_nearest without a range value - it found a compile error earlier.
      std::pair<tree_type::const_iterator,double> found = exact_dist.find_nearest(target);
      assert(found.first != exact_dist.end());
      std::cout << "Test find_nearest(), found at exact distance away from " << target << ", found " << *found.first << " @ " << found.second << " should be " << std::sqrt(8) << std::endl;
      assert(found.second == std::sqrt(8));
   }

   {
      tree_type exact_dist(std::ptr_fun(tac));
        triplet c0(5, 2, 0);
        exact_dist.insert(c0);
        triplet target(7,4,0);

      std::pair<tree_type::const_iterator,double> found = exact_dist.find_nearest(target,std::sqrt(8));
      assert(found.first != exact_dist.end());
      std::cout << "Test find_nearest(), found at exact distance away from " << target << ", found " << *found.first << " @ " << found.second << " should be " << std::sqrt(8) << std::endl;
      assert(found.second == std::sqrt(8));
   }

  tree_type src(std::ptr_fun(tac));

  triplet c0(5, 4, 0); src.insert(c0);
  triplet c1(4, 2, 1); src.insert(c1);
  triplet c2(7, 6, 9); src.insert(c2);
  triplet c3(2, 2, 1); src.insert(c3);
  triplet c4(8, 0, 5); src.insert(c4);
  triplet c5(5, 7, 0); src.insert(c5);
  triplet c6(3, 3, 8); src.insert(c6);
  triplet c7(9, 7, 3); src.insert(c7);
  triplet c8(2, 2, 6); src.insert(c8);
  triplet c9(2, 0, 6); src.insert(c9);

  std::cout << src << std::endl;

  src.erase(c0);
  src.erase(c1);
  src.erase(c3);
  src.erase(c5);

  src.optimise();


  // test the efficient_replace_and_optimise()
  tree_type eff_repl = src;
  {
     std::vector<triplet> vec;
     // erased above as part of test vec.push_back(triplet(5, 4, 0));
     // erased above as part of test vec.push_back(triplet(4, 2, 1));
     vec.push_back(triplet(7, 6, 9));
     // erased above as part of test vec.push_back(triplet(2, 2, 1));
     vec.push_back(triplet(8, 0, 5));
     // erased above as part of test vec.push_back(triplet(5, 7, 0));
     vec.push_back(triplet(3, 3, 8));
     vec.push_back(triplet(9, 7, 3));
     vec.push_back(triplet(2, 2, 6));
     vec.push_back(triplet(2, 0, 6));

     eff_repl.clear();
     eff_repl.efficient_replace_and_optimise(vec);
  }


  std::cout << std::endl << src << std::endl;

  tree_type copied(src);
  std::cout << copied << std::endl;
  tree_type assigned;
  assigned = src;
  std::cout << assigned << std::endl;

  for (int loop = 0; loop != 4; ++loop)
    {
      tree_type * target;
      switch (loop)
	{
	case 0: std::cout << "Testing plain construction" << std::endl;
	  target = &src;
	  break;

	case 1: std::cout << "Testing copy-construction" << std::endl;
	  target = &copied;
	  break;

	case 2: std::cout << "Testing assign-construction" << std::endl;
	  target = &assigned;
	  break;

   default:
	case 4: std::cout << "Testing efficient-replace-and-optimise" << std::endl;
	  target = &eff_repl;
	  break;
	}
      tree_type & t = *target;

      int i=0;
      for (tree_type::const_iterator iter=t.begin(); iter!=t.end(); ++iter, ++i);
      std::cout << "iterator walked through " << i << " nodes in total" << std::endl;
      if (i!=6)
	{
	  std::cerr << "Error: does not tally with the expected number of nodes (6)" << std::endl;
	  return 1;
	}
      i=0;
      for (tree_type::const_reverse_iterator iter=t.rbegin(); iter!=t.rend(); ++iter, ++i);
      std::cout << "reverse_iterator walked through " << i << " nodes in total" << std::endl;
      if (i!=6)
	{
	  std::cerr << "Error: does not tally with the expected number of nodes (6)" << std::endl;
	  return 1;
	}

      triplet s(5, 4, 3);
      std::vector<triplet> v;
      unsigned int const RANGE = 3;

      size_t count = t.count_within_range(s, RANGE);
      std::cout << "counted " << count
		<< " nodes within range " << RANGE << " of " << s << ".\n";
      t.find_within_range(s, RANGE, std::back_inserter(v));

      std::cout << "found   " << v.size() << " nodes within range " << RANGE
		<< " of " << s << ":\n";
      std::vector<triplet>::const_iterator ci = v.begin();
      for (; ci != v.end(); ++ci)
	std::cout << *ci << " ";
      std::cout << "\n" << std::endl;

      std::cout << std::endl << t << std::endl;

      // search for all the nodes at exactly 0 dist away
      for (tree_type::const_iterator target = t.begin(); target != t.end(); ++target)
      {
         std::pair<tree_type::const_iterator,double> found = t.find_nearest(*target,0);
         assert(found.first != t.end());
         assert(*found.first == *target);
         std::cout << "Test find_nearest(), found at exact distance away from " << *target << ", found " << *found.first << std::endl;
      }

      {
         const double small_dist = 0.0001;
         std::pair<tree_type::const_iterator,double> notfound = t.find_nearest(s,small_dist);
         std::cout << "Test find_nearest(), nearest to " << s << " within " << small_dist << " should not be found" << std::endl;

         if (notfound.first != t.end())
         {
            std::cout << "ERROR found a node at dist " << notfound.second << " : " << *notfound.first << std::endl;
            std::cout << "Actual distance = " << s.distance_to(*notfound.first) << std::endl;
         }

         assert(notfound.first == t.end());
      }

      {
         std::pair<tree_type::const_iterator,double> nif = t.find_nearest_if(s,std::numeric_limits<double>::max(),Predicate());
         std::cout << "Test find_nearest_if(), nearest to " << s << " @ " << nif.second << ": " << *nif.first << std::endl;

         std::pair<tree_type::const_iterator,double> cantfind = t.find_nearest_if(s,std::numeric_limits<double>::max(),FalsePredicate());
         std::cout << "Test find_nearest_if(), nearest to " << s << " should never be found (predicate too strong)" << std::endl;
         assert(cantfind.first == t.end());
      }




      {
      std::pair<tree_type::const_iterator,double> found = t.find_nearest(s,std::numeric_limits<double>::max());
      std::cout << "Nearest to " << s << " @ " << found.second << " " << *found.first << std::endl;
      std::cout << "Should be " << found.first->distance_to(s) << std::endl;
      // NOTE: the assert does not check for an exact match, as it is not exact when -O2 or -O3 is
      // switched on.  Some sort of optimisation makes the math inexact.
      assert( fabs(found.second - found.first->distance_to(s)) < std::numeric_limits<double>::epsilon() );
      }

      {
      triplet s2(10, 10, 2);
      std::pair<tree_type::const_iterator,double> found = t.find_nearest(s2,std::numeric_limits<double>::max());
      std::cout << "Nearest to " << s2 << " @ " << found.second << " " << *found.first << std::endl;
      std::cout << "Should be " << found.first->distance_to(s2) << std::endl;
      // NOTE: the assert does not check for an exact match, as it is not exact when -O2 or -O3 is
      // switched on.  Some sort of optimisation makes the math inexact.
      assert( fabs(found.second - found.first->distance_to(s2)) < std::numeric_limits<double>::epsilon() );
      }

      std::cout << std::endl;

      std::cout << t << std::endl;

      // Testing iterators
      {
	std::cout << "Testing iterators" << std::endl;

	t.erase(c2);
	t.erase(c4);
	t.erase(c6);
	t.erase(c7);
	t.erase(c8);
	//    t.erase(c9);

	std::cout << std::endl << t << std::endl;

	std::cout << "Forward iterator test..." << std::endl;
	std::vector<triplet> forwards;
	for (tree_type::iterator i = t.begin(); i != t.end(); ++i)
	  { std::cout << *i << " " << std::flush; forwards.push_back(*i); }
	std::cout << std::endl;
	std::cout << "Reverse iterator test..." << std::endl;
	std::vector<triplet> backwards;
	for (tree_type::reverse_iterator i = t.rbegin(); i != t.rend(); ++i)
	  { std::cout << *i << " " << std::flush; backwards.push_back(*i); }
	std::cout << std::endl;
	std::reverse(backwards.begin(),backwards.end());
	assert(backwards == forwards);
      }
    }


  // Walter reported that the find_within_range() wasn't giving results that were within
  // the specified range... this is the test.
  {
     tree_type tree(std::ptr_fun(tac));
     tree.insert( triplet(28.771200,16.921600,-2.665970) );
     tree.insert( triplet(28.553101,18.649700,-2.155560) );
     tree.insert( triplet(28.107500,20.341400,-1.188940) );
     tree.optimise();

     std::deque< triplet > vectors;
     triplet sv(18.892500,20.341400,-1.188940);
     tree.find_within_range(sv, 10.0f, std::back_inserter(vectors));

     std::cout << std::endl << "Test find_with_range( " << sv << ", 10.0f) found " << vectors.size() << " candidates." << std::endl;

     // double-check the ranges
     for (std::deque<triplet>::iterator v = vectors.begin(); v != vectors.end(); ++v)
     {
        double dist = sv.distance_to(*v);
        std::cout << "  " << *v << " dist=" << dist << std::endl;
        if (dist > 10.0f)
           std::cout << "    This point is too far! But that is by design, its within a 'box' with a 'radius' of 10, not a sphere with a radius of 10" << std::endl;
        // Not a valid test, it can be greater than 10 if the point is in the corners of the box.
        // assert(dist <= 10.0f);
     }
  }


  return 0;
}
예제 #2
0
void Sputnik::Launch()
{
    cout << "starting RhoToolsTest" << endl;
    
    // the tests are organized as blocks to let variables
    // go out of scope.  In the output, each block is 
    // separated by a lines of ----
    
    
    // start testing OpAdd4
    
    ostream& theStream = cerr; 
    theStream  <<  "Before Testing OpAdd4 " << endl;
    theStream << endl;
    
    
    TOpAdd4 b4;
    {
	cout << "create a pair of objects:" << endl;
	TCandidate c1(TLorentzVector(1,0,0,0),0);
	TCandidate c2(TLorentzVector(0,2,0,0),0);
	TCandidate c3(TLorentzVector(0,0,3,0),0);
	PC("c1",c1);
	PC("c2",c2);
	PC("c3",c3);
	
	cout << "after OpAdd4.Fill(c3, c1, c2); "<<endl;
	b4.Fill(c3,c1,c2);
	PC("c1",c1);
	PC("c2",c2);
	PC("c3",c3);
	
	TCandidate c4(TLorentzVector(0,0,3,0),0);
	cout <<endl<< "c4(); c4 = OpAdd4().combine( c1, c2); "<<endl;
	c4 = TOpAdd4().Combine(c1,c2);
	PC("c1",c1);
	PC("c2",c2);
	PC("c3",c3);
	PC("c4",c4);
	
	cout << "---------------------------------------------------"<<endl;
    }
    
    {
	cout << "create objects:" << endl;
	TCandidate c1(TLorentzVector(1,0,0,0),0);
	TCandidate c2(TLorentzVector(0,2,0,0),0);
	TCandidate c3(TLorentzVector(0,0,3,0),0);
	TCandidate c4(TLorentzVector(0,0,0,4),0);
	PC("c1",c1);
	PC("c2",c2);
	PC("c3",c3);
	PC("c4",c4);
	
	cout <<endl<< "OpAdd4.Fill(c4,c1,c2,c3); "<<endl;
	b4.Fill(c4,c3,c2,c1);
	PC("c1",c1);
	PC("c2",c2);
	PC("c3",c3);
	PC("c4",c4);
	
	cout << "---------------------------------------------------"<<endl;
    }
    
    {
	cout << "create objects:" << endl;
	TCandidate c1(TLorentzVector(1,0,0,0),1);
	TCandidate c2(TLorentzVector(0,2,0,0),-1);
	TCandidate c3(TLorentzVector(0,0,3,0),0);
	TCandidate c4(TLorentzVector(0,0,0,4),0);
	TCandidate c5(TLorentzVector(0,0,0,0),5);
	TCandidate c6(TLorentzVector(0,0,0,0),6);
	TCandidate c7(TLorentzVector(0,0,0,0),7);
	PC("c1",c1);
	PC("c2",c2);
	PC("c3",c3);
	PC("c4",c4);
	PC("c5",c5);
	PC("c6",c6);
	PC("c7",c7);
	
	cout <<endl<< "after Add4::Fill(c5,c1,c2); Add4::Fill(c6,c3,c4); "<<endl;
	b4.Fill(c5,c1,c2);
	b4.Fill(c6,c3,c4);
	PC("c1",c1);
	PC("c2",c2);
	PC("c3",c3);
	PC("c4",c4);
	PC("c5",c5);
	PC("c6",c6);
	PC("c7",c7);
	
	cout <<endl<< "after Add4::Fill(c7,c5,c6); "<<endl;
	b4.Fill(c7,c5,c6);
	PC("c1",c1);
	PC("c2",c2);
	PC("c3",c3);
	PC("c4",c4);
	PC("c5",c5);
	PC("c6",c6);
	PC("c7",c7);
	
	// do some additional checks of copying, etc
	cout <<endl<< "after c8(c7);"<<endl;
	TCandidate c8(c7);
	PC("c1",c1);
	PC("c2",c2);
	PC("c3",c3);
	PC("c4",c4);
	PC("c5",c5);
	PC("c6",c6);
	PC("c7",c7);
	PC("c8",c8);
	
	cout <<endl<< "create c9(c1); then c9 = c7;"<<endl;
	TCandidate c9(c1); c9 = c7;
	PC("c1",c1);
	PC("c2",c2);
	PC("c3",c3);
	PC("c4",c4);
	PC("c5",c5);
	PC("c6",c6);
	PC("c7",c7);
	PC("c8",c8);
	PC("c9",c9);
	
	cout <<endl<< "c9 = c5;"<<endl;
	c9 = c5;
	PC("c1",c1);
	PC("c2",c2);
	PC("c3",c3);
	PC("c4",c4);
	PC("c5",c5);
	PC("c6",c6);
	PC("c7",c7);
	PC("c8",c8);
	PC("c9",c9);
	
	cout << endl;
	cout << "testing Overlaps:"<<endl;
	cout << "c1 and c2: "<<(c1.Overlaps(c2)?"t":"f")<<endl;
	cout << "c9 and c5: "<<(c9.Overlaps(c5)?"t":"f")<<endl;
	cout << "c8 and c5: "<<(c8.Overlaps(c5)?"t":"f")<<endl;
	cout << "c7 and c5: "<<(c7.Overlaps(c5)?"t":"f")<<endl;
	cout << "c6 and c5: "<<(c6.Overlaps(c5)?"t":"f")<<endl;
	cout << "c5 and c5: "<<(c5.Overlaps(c5)?"t":"f")<<endl;
	cout << "c5 and c9: "<<(c5.Overlaps(c9)?"t":"f")<<endl;
	cout << "c5 and c8: "<<(c5.Overlaps(c8)?"t":"f")<<endl;
	cout << "c5 and c7: "<<(c5.Overlaps(c7)?"t":"f")<<endl;
	cout << "c5 and c6: "<<(c5.Overlaps(c6)?"t":"f")<<endl;
	cout << "c5 and c5: "<<(c5.Overlaps(c5)?"t":"f")<<endl;
	cout << "---------------------------------------------------"<<endl;
    }
    
    //
    // start testing OpMakeTree
    
    theStream  <<  "Before Making Tree " << endl;
    theStream << endl;
    
    {
	
	cout << "Initialization of Pdt " << endl;
	//Pdt::readMCppTable("PARENT/PDT/pdt.table");
	TDatabasePDG *Pdt = TRho::Instance()->GetPDG();
	cout << "done." << endl;
	
	// now let's consider the Y(4S)
	double beamAngle  = 0.0204;
	double beamDeltaP = 9.-3.1; 
	
	TVector3 pY4S( -beamDeltaP*sin(beamAngle),0, 
	    beamDeltaP*cos(beamAngle) );
	TCandidate Y4S( pY4S, Pdt->GetParticle("Upsilon(4S)") );
	TTreeNavigator::PrintTree( Y4S );
	cout << "theta " << Y4S.P3().Theta() << endl;
	cout << "phi "   << Y4S.P3().Phi() << endl;
	
	// instanciate a Booster
	TBooster cmsBooster( &Y4S , kTRUE);
	
	// Let's imagine a photon with a certain angle in the CMS frame
	
	// a photon 
	double ePhot = 1.;
	double photAngle = 30*3.1416/180.;
	double photPhi   = 45*3.1416/180.;
	TCandidate 
	    photon( TVector3( ePhot*sin(photAngle)*cos(photPhi), ePhot*sin(photAngle)*sin(photPhi), ePhot*cos(photAngle) ), 
	    Pdt->GetParticle("gamma") );
	
	cout << endl << "The original photon in the CMS frame " << endl;
	TTreeNavigator::PrintTree( photon );
	cout << "theta " << photon.P3().Theta() << endl;
	cout << "phi "   << photon.P3().Phi() << endl;
	
	// the same photon in the LAB frame :
	TCandidate boostedPhoton = cmsBooster.BoostFrom( photon );
	TLorentzVector theLabP4 = cmsBooster.BoostedP4( photon, TBooster::From );
	cout << "the lab Four-Vector (" << 
	    theLabP4.X() << "," << theLabP4.Y() << "," << theLabP4.Z() << ";" << theLabP4.E() << ")" << endl;
	cout << endl << "The lab boosted photon " << endl;
	TTreeNavigator::PrintTree( boostedPhoton );
	cout << "theta " << boostedPhoton.P3().Theta() << endl;
	cout << "phi "   << boostedPhoton.P3().Phi() << endl;
	
	// now boost back in the CMS frame
	TLorentzVector theP4 = cmsBooster.BoostedP4( boostedPhoton, TBooster::To );
	cout << "the Four-Vector in CMS frame (" << 
	    theP4.X() << "," << theP4.Y() << "," << theP4.Z() << ";" << theP4.E() << ")" << endl;
	cout << " from cand :    (" << 
	    photon.P4().X() << "," << photon.P4().Y() << "," << photon.P4().Z() << ";" <<photon.P4().E() << ")" << endl;
	
	
	double mPsi = Pdt->GetParticle("J/psi")->Mass();
	double mMu  = Pdt->GetParticle("mu+")->Mass();
	double mPi  = Pdt->GetParticle("pi+")->Mass();
	double mK   = Pdt->GetParticle("K+")->Mass();
	double mB   = Pdt->GetParticle("B+")->Mass();
	double mDst = Pdt->GetParticle("D*+")->Mass();
	double mD0  = Pdt->GetParticle("D0")->Mass();
	double mRho = Pdt->GetParticle("rho+")->Mass();
	
	//
	// Let's start with a simple example   :  B+ -> J/Psi K+
	//
	
	// muons in the J/Psi frame
	double E(0.), P(0.), th(0.), ph(0.);
	TVector3 p3;
	
	th = 0.3;
	ph = 1.3;
	P  = 0.5*sqrt( pow(mPsi,2) - 4*pow(mMu,2) );
	E  = sqrt( pow(mMu,2) + pow(P,2) );
	p3 = TVector3( sin(th)*cos(ph)*P, sin(th)*sin(ph)*P, cos(th)*P );
	
	TLorentzVector mu1P4(  p3, E );
	TLorentzVector mu2P4( -p3, E );
	
	// J/psi in the B frame
	th = 1.1;
	ph = 0.5;
	P = 0.5*sqrt((pow(mB,2)-pow(mPsi-mK,2))*(pow(mB,2)-pow(mPsi+mK,2)))/mB;
	p3 = TVector3( sin(th)*cos(ph)*P, sin(th)*sin(ph)*P, cos(th)*P );
	E = sqrt( pow(mPsi,2) + pow(P,2) ); 
	TVector3 boostVector( p3.X()/E, p3.Y()/E,p3.Z()/E );
	mu1P4.Boost( boostVector );
	mu2P4.Boost( boostVector );
	E = sqrt( pow(mK,2) + pow(P,2) ); 
	TLorentzVector KP4( -p3, E );
	
	// create the TCandidates
	TCandidate* mu1 = new TCandidate( mu1P4.Vect(), Pdt->GetParticle("mu+") );
	TCandidate* mu2 = new TCandidate( mu2P4.Vect(), Pdt->GetParticle("mu-") );
	TCandidate* K   = new TCandidate( KP4.Vect(), Pdt->GetParticle("K+") );
	
	// now create the Make Tree operator
	TOpMakeTree op;
	
	// now create the J/Psi
	TCandidate psi = op.Combine( *mu1, *mu2 );
	psi.SetType( "J/psi" );
	psi.SetMassConstraint();
	
	cout << endl << "The original psi " << endl;
	TTreeNavigator::PrintTree( psi );
	
	// now create the B+
	TCandidate B = op.Combine( psi, *K );
	B.SetType( "B+" );
	B.SetMassConstraint();
	
	cout << endl << "The B " << endl;
	TTreeNavigator::PrintTree( B );
	
	// create a TTreeNavigator
	TTreeNavigator treeNavigator( B );
	TTreeNavigator::PrintTree( psi );
	
	theStream << "After tree making" << endl;
	theStream << endl;
	
	//instanciate the fitter with the B Candidate
	VAbsFitter* fitter = new TDummyFitter( psi );
	
	theStream << "After fitter construction " << endl;
	theStream << endl;
	
	// get the "fitted" TCandidates
	TCandidate fittedPsi = fitter->GetFitted( psi );
	TTreeNavigator::PrintTree( fittedPsi );
	
	TCandListIterator iterDau =  psi.DaughterIterator();
	TCandidate* dau=0;
	while( dau=iterDau.Next() )
	{
	    TCandidate fittedDau = fitter->GetFitted( *dau );
	    TTreeNavigator::PrintTree( fittedDau );
	}
	
	delete fitter;
	
	fitter = new TDummyFitter( B );
	
	// get the "fitted" TCandidates
	TCandidate fittedB = fitter->GetFitted( B );
	TTreeNavigator::PrintTree( fittedB );
	
	iterDau.Rewind();
	dau=0;
	while( dau=iterDau.Next() )
	{
	    TCandidate fittedDau = fitter->GetFitted( *dau );
	    TTreeNavigator::PrintTree( fittedDau );
	}
	
	TCandidate hello = fitter->GetFitted( psi );
	TTreeNavigator::PrintTree( hello );
	
	delete fitter;
	
	theStream << "After fitter deletion " << endl;
	theStream << endl;
	
	// first let's boost the kaon
	TCandidate boostedKaon = cmsBooster.BoostTo( *K );
	cout << endl << "The boosted Kaon " << endl;
	TTreeNavigator::PrintTree( *K );
	
	// let's boost the psi
	TCandidate boostedPsi = cmsBooster.BoostTo( psi );
	cout << endl << "The boosted Psi " << endl;
	TTreeNavigator::PrintTree( boostedPsi );
	
	
	theStream << "before tree boosting " << endl;
	theStream << endl;
	
	// now let's boost the B in the Y4S frame
	TCandidate boostedB = cmsBooster.BoostTo( B );
	
	// let's see the tree
	cout << endl << "The boosted B " << endl;
	TTreeNavigator::PrintTree( boostedB );
	
	theStream << "after tree boosting " << endl;
	theStream << endl;
	
	// now let's boost a list
	TCandList theList;
	theList.Add( psi );
	theList.Add( *K );
	theList.Add( B );
	TCandList theBoostedList;
	cmsBooster.BoostTo( theList, theBoostedList );
	TCandListIterator iter(theBoostedList);
	TCandidate* c(0);
	while( c=iter.Next() )
	{
	    cout << "boosted cand " << c->PdtEntry()->GetName() << endl;
	    TTreeNavigator::PrintTree( *c );
	}
	
	
	theBoostedList.Cleanup();
	
	PrintAncestors( *mu1 );
	
	delete mu1;
	delete mu2;
	delete K;
	
	cout << "---------------------------------------------------"<<endl;
     }
     
     theStream  <<  "At the end of the test program " << endl;
     theStream << endl;
}
예제 #3
0
int main()
{
   // check that it'll find nodes exactly MAX away
   {
      tree_type exact_dist(std::ptr_fun(tac));
        triplet c0(5, 4, 0);
        exact_dist.insert(c0);
        triplet target(7,4,0);

      std::pair<tree_type::const_iterator,double> found = exact_dist.find_nearest(target,2);
      assert(found.first != exact_dist.end());
      assert(found.second == 2);
      std::cout << "Test find_nearest(), found at exact distance away from " << target << ", found " << *found.first << std::endl;
   }

   {
      tree_type exact_dist(std::ptr_fun(tac));
        triplet c0(5, 2, 0);
        exact_dist.insert(c0);
        triplet target(7,4,0);

        // call find_nearest without a range value - it found a compile error earlier.
      std::pair<tree_type::const_iterator,double> found = exact_dist.find_nearest(target);
      assert(found.first != exact_dist.end());
      std::cout << "Test find_nearest(), found at exact distance away from " << target << ", found " << *found.first << " @ " << found.second << " should be " << sqrt(8) << std::endl;
      assert(found.second == sqrt(8));
   }

   {
      tree_type exact_dist(std::ptr_fun(tac));
        triplet c0(5, 2, 0);
        exact_dist.insert(c0);
        triplet target(7,4,0);

      std::pair<tree_type::const_iterator,double> found = exact_dist.find_nearest(target,sqrt(8));
      assert(found.first != exact_dist.end());
      std::cout << "Test find_nearest(), found at exact distance away from " << target << ", found " << *found.first << " @ " << found.second << " should be " << sqrt(8) << std::endl;
      assert(found.second == sqrt(8));
   }

  tree_type src(std::ptr_fun(tac));

  triplet c0(5, 4, 0); src.insert(c0);
  triplet c1(4, 2, 1); src.insert(c1);
  triplet c2(7, 6, 9); src.insert(c2);
  triplet c3(2, 2, 1); src.insert(c3);
  triplet c4(8, 0, 5); src.insert(c4);
  triplet c5(5, 7, 0); src.insert(c5);
  triplet c6(3, 3, 8); src.insert(c6);
  triplet c7(9, 7, 3); src.insert(c7);
  triplet c8(2, 2, 6); src.insert(c8);
  triplet c9(2, 0, 6); src.insert(c9);

  std::cout << src << std::endl;

  src.erase(c0);
  src.erase(c1);
  src.erase(c3);
  src.erase(c5);

  src.optimise();


  // test the efficient_replace_and_optimise()
  tree_type eff_repl = src;
  {
     std::vector<triplet> vec;
     // erased above as part of test vec.push_back(triplet(5, 4, 0));
     // erased above as part of test vec.push_back(triplet(4, 2, 1));
     vec.push_back(triplet(7, 6, 9));
     // erased above as part of test vec.push_back(triplet(2, 2, 1));
     vec.push_back(triplet(8, 0, 5));
     // erased above as part of test vec.push_back(triplet(5, 7, 0));
     vec.push_back(triplet(3, 3, 8));
     vec.push_back(triplet(9, 7, 3));
     vec.push_back(triplet(2, 2, 6));
     vec.push_back(triplet(2, 0, 6));

     eff_repl.clear();
     eff_repl.efficient_replace_and_optimise(vec);
  }


  std::cout << std::endl << src << std::endl;

  tree_type copied(src);
  std::cout << copied << std::endl;
  tree_type assigned;
  assigned = src;
  std::cout << assigned << std::endl;

  for (int loop = 0; loop != 4; ++loop)
    {
      tree_type * target;
      switch (loop)
	{
	case 0: std::cout << "Testing plain construction" << std::endl;
	  target = &src;
	  break;

	case 1: std::cout << "Testing copy-construction" << std::endl;
	  target = &copied;
	  break;

	case 2: std::cout << "Testing assign-construction" << std::endl;
	  target = &assigned;
	  break;

   default:
	case 4: std::cout << "Testing efficient-replace-and-optimise" << std::endl;
	  target = &eff_repl;
	  break;
	}
      tree_type & t = *target;

      int i=0;
      for (tree_type::const_iterator iter=t.begin(); iter!=t.end(); ++iter, ++i);
      std::cout << "iterator walked through " << i << " nodes in total" << std::endl;
      if (i!=6)
	{
	  std::cerr << "Error: does not tally with the expected number of nodes (6)" << std::endl;
	  return 1;
	}
      i=0;
      for (tree_type::const_reverse_iterator iter=t.rbegin(); iter!=t.rend(); ++iter, ++i);
      std::cout << "reverse_iterator walked through " << i << " nodes in total" << std::endl;
      if (i!=6)
	{
	  std::cerr << "Error: does not tally with the expected number of nodes (6)" << std::endl;
	  return 1;
	}

      triplet s(5, 4, 3);
      std::vector<triplet> v;
      unsigned int const RANGE = 3;

      size_t count = t.count_within_range(s, RANGE);
      std::cout << "counted " << count
		<< " nodes within range " << RANGE << " of " << s << ".\n";
      t.find_within_range(s, RANGE, std::back_inserter(v));

      std::cout << "found   " << v.size() << " nodes within range " << RANGE
		<< " of " << s << ":\n";
      std::vector<triplet>::const_iterator ci = v.begin();
      for (; ci != v.end(); ++ci)
	std::cout << *ci << " ";
      std::cout << "\n" << std::endl;

      std::cout << std::endl << t << std::endl;

      // search for all the nodes at exactly 0 dist away
      for (tree_type::const_iterator target = t.begin(); target != t.end(); ++target)
      {
         std::pair<tree_type::const_iterator,double> found = t.find_nearest(*target,0);
         assert(found.first != t.end());
         assert(*found.first == *target);
         std::cout << "Test find_nearest(), found at exact distance away from " << *target << ", found " << *found.first << std::endl;
      }

      {
         const double small_dist = 0.0001;
         std::pair<tree_type::const_iterator,double> notfound = t.find_nearest(s,small_dist);
         std::cout << "Test find_nearest(), nearest to " << s << " within " << small_dist << " should not be found" << std::endl;

         if (notfound.first != t.end())
         {
            std::cout << "ERROR found a node at dist " << notfound.second << " : " << *notfound.first << std::endl;
            std::cout << "Actual distance = " << s.distance_to(*notfound.first) << std::endl;
         }

         assert(notfound.first == t.end());
      }

      {
         std::pair<tree_type::const_iterator,double> nif = t.find_nearest_if(s,std::numeric_limits<double>::max(),Predicate());
         std::cout << "Test find_nearest_if(), nearest to " << s << " @ " << nif.second << ": " << *nif.first << std::endl;

         std::pair<tree_type::const_iterator,double> cantfind = t.find_nearest_if(s,std::numeric_limits<double>::max(),FalsePredicate());
         std::cout << "Test find_nearest_if(), nearest to " << s << " should never be found (predicate too strong)" << std::endl;
         assert(cantfind.first == t.end());
      }




      {
      std::pair<tree_type::const_iterator,double> found = t.find_nearest(s,std::numeric_limits<double>::max());
      std::cout << "Nearest to " << s << " @ " << found.second << " " << *found.first << std::endl;
      std::cout << "Should be " << found.first->distance_to(s) << std::endl;
      // NOTE: the assert does not check for an exact match, as it is not exact when -O2 or -O3 is
      // switched on.  Some sort of optimisation makes the math inexact.
      assert( fabs(found.second - found.first->distance_to(s)) < std::numeric_limits<double>::epsilon() );
      }

      {
      triplet s2(10, 10, 2);
      std::pair<tree_type::const_iterator,double> found = t.find_nearest(s2,std::numeric_limits<double>::max());
      std::cout << "Nearest to " << s2 << " @ " << found.second << " " << *found.first << std::endl;
      std::cout << "Should be " << found.first->distance_to(s2) << std::endl;
      // NOTE: the assert does not check for an exact match, as it is not exact when -O2 or -O3 is
      // switched on.  Some sort of optimisation makes the math inexact.
      assert( fabs(found.second - found.first->distance_to(s2)) < std::numeric_limits<double>::epsilon() );
      }

      std::cout << std::endl;

      std::cout << t << std::endl;

      // Testing iterators
      {
	std::cout << "Testing iterators" << std::endl;

	t.erase(c2);
	t.erase(c4);
	t.erase(c6);
	t.erase(c7);
	t.erase(c8);
	//    t.erase(c9);

	std::cout << std::endl << t << std::endl;

	std::cout << "Forward iterator test..." << std::endl;
	std::vector<triplet> forwards;
	for (tree_type::iterator i = t.begin(); i != t.end(); ++i)
	  { std::cout << *i << " " << std::flush; forwards.push_back(*i); }
	std::cout << std::endl;
	std::cout << "Reverse iterator test..." << std::endl;
	std::vector<triplet> backwards;
	for (tree_type::reverse_iterator i = t.rbegin(); i != t.rend(); ++i)
	  { std::cout << *i << " " << std::flush; backwards.push_back(*i); }
	std::cout << std::endl;
	std::reverse(backwards.begin(),backwards.end());
	assert(backwards == forwards);
      }
    }

  return 0;
}
void test(const Cont &)
{
  // Testing if all types are provided.

  typename Cont::value_type              t0;
  typename Cont::reference               t1 = t0;      CGAL_USE(t1);
  typename Cont::const_reference         t2 = t0;      CGAL_USE(t2);
  typename Cont::pointer                 t3 = &t0;
  typename Cont::const_pointer           t4 = &t0;     CGAL_USE(t4);
  typename Cont::size_type               t5 = 0;       CGAL_USE(t5);
  typename Cont::difference_type         t6 = t3-t3;   CGAL_USE(t6);
  typename Cont::iterator                t7;           CGAL_USE(t7);
  typename Cont::const_iterator          t8;           CGAL_USE(t8);
  typename Cont::reverse_iterator        t9;           CGAL_USE(t9);
  typename Cont::const_reverse_iterator  t10;          CGAL_USE(t10);
  typename Cont::allocator_type          t15;

  std::cout << "Testing empty containers." << std::endl;

  Cont c0, c1;
  Cont c2(t15);
  Cont c3(c2);
  Cont c4;
  c4 = c2;

  typedef std::vector<typename Cont::value_type> Vect;
  Vect v0;
  const Cont c5(v0.begin(), v0.end());
  Cont c6(c5.begin(), c5.end());
  typename Cont::allocator_type Al;
  Cont c7(c0.begin(), c0.end(), Al);
  Cont c8;
  c8.insert(c0.rbegin(), c0.rend());

  // test conversion iterator-> const_iterator.
  typename Cont::const_iterator t16 = c5.begin();  CGAL_USE(t16);
  assert(t16 == c5.begin());

  assert(c0 == c1);
  assert(! (c0 < c1));

  assert(check_empty(c0));
  assert(check_empty(c1));
  assert(check_empty(c2));
  assert(check_empty(c3));
  assert(check_empty(c4));
  assert(check_empty(c5));
  assert(check_empty(c6));
  assert(check_empty(c7));
  assert(check_empty(c8));

  c1.swap(c0);

  assert(check_empty(c0));
  assert(check_empty(c1));

  c1.merge(c0);

  assert(check_empty(c0));
  assert(check_empty(c1));

  typename Cont::allocator_type  t20 = c0.get_allocator();

  std::cout << "Now filling some containers" << std::endl;

  Vect v1(10000);
  Cont c9(v1.begin(), v1.end());

  assert(c9.size() == v1.size());
  assert(c9.max_size() >= v1.size());
  assert(c9.capacity() >= c9.size());

  Cont c10 = c9;

  assert(c10 == c9);
  assert(c10.size() == v1.size());
  assert(c10.max_size() >= v1.size());
  assert(c10.capacity() >= c10.size());

  c9.clear();

  assert(check_empty(c9));
  assert(c9.capacity() >= c9.size());
  assert(c0 == c9);

  c9.merge(c10);
  c10.swap(c9);

  assert(check_empty(c9));
  assert(c9.capacity() >= c9.size());

  assert(c10.size() == v1.size());
  assert(c10.max_size() >= v1.size());
  assert(c10.capacity() >= c10.size());

  std::cout << "Testing insertion methods" << std::endl;

  c9.assign(c10.begin(), c10.end());

  assert(c9 == c10);

  c10.assign(c9.begin(), c9.end());

  assert(c9 == c10);

  c9.insert(c10.begin(), c10.end());

  assert(c9.size() == 2*v1.size());

  c9.clear();

  assert(c9 != c10);

  c9.insert(c10.begin(), c10.end());

  assert(c9.size() == v1.size());
  assert(c9 == c10);


  typename Cont::iterator it = c9.iterator_to(*c9.begin());
  assert(it == c9.begin());
  typename Cont::const_iterator cit = c9.iterator_to(const_cast<typename Cont::const_reference>(*c9.begin()));
  assert(cit == c9.begin());

  typename Cont::iterator s_it = Cont::s_iterator_to(*c9.begin());
  assert(s_it == c9.begin());
  typename Cont::const_iterator s_cit = Cont::s_iterator_to(const_cast<typename Cont::const_reference>(*c9.begin()));
  assert(s_cit == c9.begin());


  c10 = Cont();

  assert(check_empty(c10));

  for(typename Vect::const_iterator it = v1.begin(); it != v1.end(); ++it)
    c10.insert(*it);

  assert(c10.size() == v1.size());
  assert(c9 == c10);

  c9.erase(c9.begin());
  c9.erase(c9.begin());

  assert(c9.size() == v1.size() - 2);

  // test reserve
  /*Cont c11;
  c11.reserve(v1.size());
  for(typename Vect::const_iterator it = v1.begin(); it != v1.end(); ++it)
    c11.insert(*it);
  
  assert(c11.size() == v1.size());
  assert(c10 == c11);*/

  // owns() and owns_dereferencable().
  for(typename Cont::const_iterator it = c9.begin(), end = c9.end(); it != end; ++it) {
    assert(c9.owns(it));
    assert(c9.owns_dereferencable(it));
    assert(! c10.owns(it));
    assert(! c10.owns_dereferencable(it));
  }
  assert(c9.owns(c9.end()));
  assert(! c9.owns_dereferencable(c9.end()));


  c9.erase(c9.begin(), c9.end());

  assert(check_empty(c9));
  
  std::cout << "Testing parallel insertion" << std::endl;
  {
  Cont c11;
  Vect v11(1000000);
  std::vector<typename Cont::iterator> iterators(v11.size());
  tbb::parallel_for(
    tbb::blocked_range<size_t>( 0, v11.size() ),
    Insert_in_CCC_functor<Vect, Cont>(v11, c11, iterators)
  );
  assert(c11.size() == v11.size());
  
  std::cout << "Testing parallel erasure" << std::endl;
  tbb::parallel_for(
    tbb::blocked_range<size_t>( 0, v11.size() ),
    Erase_in_CCC_functor<Cont>(c11, iterators)
  );
  assert(c11.empty());
  }

  std::cout << "Testing parallel insertion AND erasure" << std::endl;
  {
  Cont c12;
  Vect v12(1000000);
  std::vector<tbb::atomic<bool> > free_elements(v12.size());
  for(typename std::vector<tbb::atomic<bool> >::iterator 
    it = free_elements.begin(), end = free_elements.end(); it != end; ++it) 
  {
    *it = true;
  }
    
  tbb::atomic<unsigned int> num_erasures; 
  num_erasures = 0;
  std::vector<typename Cont::iterator> iterators(v12.size());
  tbb::parallel_for(
    tbb::blocked_range<size_t>( 0, v12.size() ),
    Insert_and_erase_in_CCC_functor<Vect, Cont>(
      v12, c12, iterators, free_elements, num_erasures)
  );
  assert(c12.size() == v12.size() - num_erasures);
  }
}
예제 #5
0
int main(int argc, char* argv[])
{
  Polycurve_conic_traits_2 traits;
    //polycurve constructors
  Polycurve_conic_traits_2::Construct_x_monotone_curve_2
    construct_x_mono_polycurve = traits.construct_x_monotone_curve_2_object();
  Polycurve_conic_traits_2::Construct_curve_2  construct_polycurve =
    traits.construct_curve_2_object();

   //create a curve

  Conic_curve_2 c3(1,0,0,0,-1,0,CGAL::COUNTERCLOCKWISE,
                   Conic_point_2(Algebraic(0), Algebraic(0)),
                   Conic_point_2(Algebraic(3), Algebraic(9)));
  Conic_curve_2 c4(1,0,0,0,-1,0,CGAL::COUNTERCLOCKWISE,
                   Conic_point_2(Algebraic(3), Algebraic(9)),
                   Conic_point_2(Algebraic(5), Algebraic(25)));
  Conic_curve_2 c5(0,1,0,1,0,0, CGAL::COUNTERCLOCKWISE,
                   Conic_point_2(Algebraic(-25), Algebraic(-5)),
                   Conic_point_2(Algebraic(0), Algebraic(0)));

  Conic_curve_2 c6(1,1,0,6,-26,162,CGAL::COUNTERCLOCKWISE,
                   Conic_point_2(Algebraic(-7), Algebraic(13)),
                   Conic_point_2(Algebraic(-3), Algebraic(9)));
  Conic_curve_2 c7(1,0,0,0,-1,0,CGAL::COUNTERCLOCKWISE,
                   Conic_point_2(Algebraic(-3), Algebraic(9)),
                   Conic_point_2(Algebraic(0), Algebraic(0)));
  Conic_curve_2 c8(0,1,0,-1,0,0, CGAL::COUNTERCLOCKWISE,
                   Conic_point_2(Algebraic(0), Algebraic(0)),
                   Conic_point_2(Algebraic(4), Algebraic(-2)));

  Conic_curve_2 c9(1,0,0,0,-1,0,CGAL::COUNTERCLOCKWISE,
                   Conic_point_2(Algebraic(-5), Algebraic(25)),
                   Conic_point_2(Algebraic(5), Algebraic(25)));
  Conic_curve_2 c10(58, 72, -48, 0, 0, -360);

  //This vector is used to store curves that will be used to create polycurve
  std::vector<Conic_curve_2> conic_curves;
  conic_curves.push_back(c9);

  //construct poly-curve
  Polycurve_conic_traits_2::Curve_2 conic_polycurve =
    construct_polycurve(conic_curves.begin(), conic_curves.end());

  Conic_curve_2 c11(0,1,0,-1,0,0,CGAL::COUNTERCLOCKWISE,
                     Conic_point_2(Algebraic(25), Algebraic(-5)),
                     Conic_point_2(Algebraic(0), Algebraic(0)));
  Conic_curve_2 c12(1,0,0,0,-1,0,CGAL::COUNTERCLOCKWISE,
                     Conic_point_2(Algebraic(0), Algebraic(0)),
                     Conic_point_2(Algebraic(5), Algebraic(25)));
  conic_curves.clear();
  conic_curves.push_back(c11);
  conic_curves.push_back(c12);

  //construct poly-curve
  Polycurve_conic_traits_2::Curve_2 conic_polycurve_2 =
    construct_polycurve(conic_curves.begin(), conic_curves.end());

  /* VERY IMPORTANT
   * For efficiency reasons, we recommend users not to construct
   * x-monotone conic arc directly, but rather use the Make_x_monotone_2
   * functor supplied by the conic-arc traits class to convert conic curves
   * to x-monotone curves.
   */
  Conic_x_monotone_curve_2 xc3(c3);
  Conic_x_monotone_curve_2 xc4(c4);
  Conic_x_monotone_curve_2 xc5(c5);
  Conic_x_monotone_curve_2 xc6(c6);
  Conic_x_monotone_curve_2 xc7(c7);
  Conic_x_monotone_curve_2 xc8(c8);


  //This vector is used to store curves that will be used to create
  //X-monotone-polycurve
  std::vector<Conic_x_monotone_curve_2> xmono_conic_curves_2;
  xmono_conic_curves_2.push_back(xc5);
  xmono_conic_curves_2.push_back(xc3);
  xmono_conic_curves_2.push_back(xc4);


  //construct x-monotone poly-curve
  Pc_x_monotone_curve_2 conic_x_mono_polycurve_1 =
    construct_x_mono_polycurve(xmono_conic_curves_2.begin(),
                               xmono_conic_curves_2.end());

  xmono_conic_curves_2.clear();
  xmono_conic_curves_2.push_back(xc6);
  xmono_conic_curves_2.push_back(xc7);
  xmono_conic_curves_2.push_back(xc8);
  //construct x-monotone poly-curve
  Pc_x_monotone_curve_2 conic_x_mono_polycurve_2 =
    construct_x_mono_polycurve(xmono_conic_curves_2.begin(),
                               xmono_conic_curves_2.end());

  xmono_conic_curves_2.clear();
  xmono_conic_curves_2.push_back(xc5);

  Pc_x_monotone_curve_2 x_polycurve_push =
    construct_x_mono_polycurve(xmono_conic_curves_2.begin(),
                               xmono_conic_curves_2.end());
  Polycurve_conic_traits_2::X_monotone_subcurve_2 xcurve_push =
    Polycurve_conic_traits_2::X_monotone_subcurve_2(c5);
  //traits.construct_x_monotone_curve_2_object()(c5);

  xmono_conic_curves_2.clear();
  xmono_conic_curves_2.push_back(xc3);
  xmono_conic_curves_2.push_back(xc4);
  Pc_x_monotone_curve_2 base_curve =
    construct_x_mono_polycurve(xmono_conic_curves_2.begin(),
                               xmono_conic_curves_2.end());

  //curves for push_back
  Conic_curve_2 c13(1,1,0,-50,12,660,CGAL::COUNTERCLOCKWISE,
                    Conic_point_2(Algebraic(25), Algebraic(-7)),
                    Conic_point_2(Algebraic(25), Algebraic(-5)));
  Conic_curve_2 c14(0,1,0,-1,0,0,CGAL::COUNTERCLOCKWISE,
                    Conic_point_2(Algebraic(25), Algebraic(-5)),
                    Conic_point_2(Algebraic(0), Algebraic(0)));
  Conic_curve_2 c15(-1,0,0,0,1,0,CGAL::COUNTERCLOCKWISE,
                    Conic_point_2(Algebraic(0), Algebraic(0)),
                    Conic_point_2(Algebraic(5), Algebraic(25)));
  conic_curves.clear();
  conic_curves.push_back(c13);
  conic_curves.push_back(c14);
  Polycurve_conic_traits_2::Curve_2 base_curve_push_back =
    construct_polycurve(conic_curves.begin(), conic_curves.end());

  conic_curves.push_back(c15);
  Polycurve_conic_traits_2::Curve_2 Expected_push_back_result =
    construct_polycurve(conic_curves.begin(), conic_curves.end());

  // //checking the orientattion consistency
  // Conic_curve_2 c21(0,1,0,1,0,0,CGAL::CLOCKWISE,
  //                  Conic_point_2(Algebraic(9), Algebraic(-3)),
  //                  Conic_point_2(Algebraic(0), Algebraic(0)));
  // Conic_curve_2 c20(1,0,0,0,-1,0,CGAL::COUNTERCLOCKWISE,
  //                   Conic_point_2(Algebraic(0), Algebraic(0)),
  //                   Conic_point_2(Algebraic(3), Algebraic(9)));
  //  Conic_x_monotone_curve_2 xc20(c20);
  //  Conic_x_monotone_curve_2 xc21(c21);
  //  xmono_conic_curves_2.clear();
  //  xmono_conic_curves_2.push_back(xc20);
  // xmono_conic_curves_2.push_back(xc21);
  // Pc_x_monotone_curve_2 eric_polycurve =
  //   construct_x_mono_polycurve(xmono_conic_curves_2.begin(),
  //                              xmono_conic_curves_2.end());
  // std::cout << "the polycurve is: " << eric_polycurve << std::endl;

  // std::cout<< std::endl;

  //check_compare_x_2(xc3, xc5);

  // check_equal();
  // std::cout<< std::endl;

   //check_intersect(conic_x_mono_polycurve_1, conic_x_mono_polycurve_2);
   //std::cout<< std::endl;

  // check_compare_end_points_xy_2();
  // std::cout<< std::endl;

  //check_split(conic_x_mono_polycurve_1, conic_x_mono_polycurve_2);
  // std::cout<< std::endl;

  //check_make_x_monotne_curve(conic_polycurve_2);
   //std::cout<< std::endl;

  // check_is_vertical();
  // std::cout<< std::endl;

  //check_compare_y_at_x_2();
  //std::cout<< std::endl;

  //adds the segment to the right.
  //check_push_back(base_curve_push_back, c15);
  //std::cout<< std::endl;

  //adds the segment to the left.
  //check_push_front(base_curve, xcurve_push);
  //std::cout<< std::endl;

  // check_are_mergable();
  // std::cout<< std::endl;

  // check_merge_2();
  // std::cout<< std::endl;

  // check_construct_opposite();
  // std::cout<< std::endl;

  // check_compare_y_at_x_right();
  // std::cout<< std::endl;

  // check_compare_y_at_x_left();
  // std::cout<< std::endl;
  //check_compare_points(conic_x_mono_polycurve_1);

  //number of segments
  //std::cout << "Number of segments: "
  //          << traits.number_of_points_2_object()(base_curve_push_back)
  //          << std::endl;

  check_trim(conic_x_mono_polycurve_1, atoi(argv[1]), atoi(argv[2]),
             atoi(argv[3]), atoi(argv[4]));
  std::cout << std::endl;

  //std::cout << (atoi(argv[1]) + atoi(argv[2])) << std::endl;
  // Conic_traits_2 con_traits;
  // Conic_curve_2 cc3(1,0,0,0,-1,0,CGAL::COUNTERCLOCKWISE,
  //                   Conic_point_2(Algebraic(0), Algebraic(0)),
  //                   Conic_point_2(Algebraic(3), Algebraic(9)));
  // Conic_x_monotone_curve_2 xcc3(cc3);
  // Conic_point_2       ps2(0, 0);
  // Conic_point_2       pt2(3, 9);
  // std::cout << "conic curve is : " << xcc3 << std::endl;
  // Conic_x_monotone_curve_2 trimmed_curve =
  //   con_traits.trim_2_object()(xc3, ps2, pt2);
  // std::cout << "trimmed conic curve is : " << trimmed_curve << std::endl;

  return 0;
}