Commit in trf++/test/gtrbase on MAIN
DetectorID_t.cpp+98added 1.1
GTrackPropagator_t.cpp+168added 1.1
GTrackState_t.cpp+184added 1.1
GTrack_t.cpp+198added 1.1
GtrTrfPropagator_t.cpp+244added 1.1
McParent_t.cpp+80added 1.1
McTrackState_t.cpp+127added 1.1
McTrack_t.cpp+153added 1.1
+1252
8 added files
component tests

trf++/test/gtrbase
DetectorID_t.cpp added at 1.1
diff -N DetectorID_t.cpp
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ DetectorID_t.cpp	10 Aug 2011 18:09:53 -0000	1.1
@@ -0,0 +1,98 @@
+// DetectorID_t.cpp
+
+
+#include "gtrbase/DetectorID.hpp"
+#include <cassert>
+#include <string>
+#include <iostream>
+#include <cassert>
+
+#ifndef DEFECT_NO_STDLIB_NAMESPACES
+using std::cout;
+using std::cerr;
+using std::endl;
+using std::string;
+#endif
+
+//**********************************************************************
+
+int main( ) {
+
+  string component = "DetectorID";
+  string ok_prefix = component + " (I): ";
+  string error_prefix = component + " test (E): ";
+
+  cout << ok_prefix
+       << "---------- Testing component " + component
+          + ". ----------" << endl;
+
+  // Make sure assert is enabled.
+  bool assert_flag = false;
+  assert ( ( assert_flag = true, assert_flag ) );
+  if ( ! assert_flag ) {
+    cerr << "Assert is disabled" << endl;
+    return 1;
+  }
+
+  //********************************************************************
+
+  int subid = 1923;
+  
+  DetectorID smt(DetectorID::SMT,subid );
+  DetectorID cft(DetectorID::CFT,subid );
+  DetectorID cft_t(cft.get_detector_id() );
+
+  assert ( ! (smt == cft) ) ;
+  assert ( smt == smt ) ;
+  assert ( cft == cft_t ) ;
+  assert ( ! ( smt < smt) ) ;
+  assert (  cft < smt ) ;
+
+  assert ( smt.get_subdetector_type() == DetectorID::SMT );
+  assert ( cft.get_subdetector_type() == DetectorID::CFT );
+
+  assert ( smt.get_subdetector_id() == subid );
+  assert ( cft.get_subdetector_id() == subid );
+
+  subid = 0 ;
+  DetectorID smt1(DetectorID::SMT,subid);
+  assert ( smt1.get_subdetector_id() == subid );
+
+  subid = 16777215 ;
+  DetectorID smt2(DetectorID::SMT,subid);
+  assert ( smt2.get_subdetector_id() == subid );
+
+  subid = 16777215 ;
+  DetectorID smt3(255,subid);
+  assert ( smt3.get_subdetector_id() == subid );
+  assert ( smt3.get_subdetector_type() == 255 );
+  assert ( (int)(smt3.get_detector_id()) == -1 );
+  cout << "ID is "<< smt3 << endl;
+
+  DetectorID smt4;
+  assert ( ! (smt4 == smt) );
+  smt4 = smt ;
+  assert ( smt4 == smt );
+
+  // test backward compatibility 
+
+  int id = 101;
+  DetectorID comp(101);
+  assert ( comp.get_subdetector_type() == DetectorID::SMT );
+
+  id = 0;
+  DetectorID comp1(0);
+  cout<< comp1<<endl;
+  assert ( comp1.get_subdetector_type() == DetectorID::RESERVED );
+
+  
+
+  //********************************************************************
+
+  cout << ok_prefix
+       << "------------- All tests passed. -------------" << endl;
+  return 0;
+
+  //********************************************************************
+
+}

trf++/test/gtrbase
GTrackPropagator_t.cpp added at 1.1
diff -N GTrackPropagator_t.cpp
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ GTrackPropagator_t.cpp	10 Aug 2011 18:09:53 -0000	1.1
@@ -0,0 +1,168 @@
+// GTrackPropagator_t.cpp
+
+// Test GTrack.
+
+#include "gtrbase/GTrackPropagator.hpp"
+#include "gtrbase/GTrackTest.hpp"
+#include "gtrbase/GtrTrfPropagator.hpp"
+// cng #include "framework/Testing.hpp"
+// cng #include "run_config_fwk/RunConfigPkg.hpp"
+
+using std::cout;
+using std::cerr;
+using std::endl;
+using std::vector;
+using std::string;
+
+/* cng
+namespace edm {
+  class Event;
+}
+
+using edm::ChunkID;
+using edm::Event;
+*/
+using namespace trf;
+
+//**********************************************************************
+
+int main( ) {
+
+  string component = "GTrackPropagator";
+  string ok_prefix = component + " (I): ";
+  string error_prefix = component + " test (E): ";
+
+  cout << ok_prefix
+       << "---------- Testing component " + component
+          + ". ----------" << endl;
+
+  // Make sure assert is enabled.
+  bool assert_flag = false;
+  assert ( ( assert_flag = true, assert_flag ) );
+  if ( ! assert_flag ) {
+    cerr << "Assert is disabled" << endl;
+    return 1;
+  }
+
+  //********************************************************************
+/* cng
+  RunConfigPkg* p1 = 0;
+  makePackage(p1, "run_config_fwk", "RunConfigPkg");
+  assert(p1 != 0);
+*/
+  GTrackTest test(ok_prefix);
+  int nclus = test.nclus;
+  int nmiss = test.nmiss;
+  int nstate = nclus + nmiss;
+  const vector<SurfacePtr>& surfs = test.all_surfs;
+  const vector<GTrackState>& states = test.states;
+  assert( states.size() == surfs.size() );
+  const GTrack& gtr = test.gtr;
+
+  //********************************************************************
+
+  cout << ok_prefix << "Build default propagator." << endl;
+  GTrackPropagator gpropd;
+  assert( gpropd.get_propagator() != 0 );
+
+  //********************************************************************
+
+  cout << ok_prefix << "Build without propagator." << endl;
+  GTrackPropagator gpropn( PropagatorPtr(0) );
+  assert( gpropn.get_propagator() == 0 );
+
+  //********************************************************************
+
+  cout << ok_prefix << "Build propagator from TRF++ propagator."
+       << endl;
+  GtrTrfPropagator propmake;
+  GTrackPropagator gprop(propmake.get_propagator());
+  assert( gprop.get_propagator() != 0 );
+
+  //********************************************************************
+
+  cout << ok_prefix << "Null propagate to an existing surface."
+       << endl;
+  for ( int i=0; i<nstate; ++i ) {
+    GTrackState gstate = gpropn.propagate( gtr, surfs[i] );
+    cout << endl;
+    cout << "*********************************************" << endl;
+    cout << gstate << endl;
+    cout << "---------------------------------------------" << endl;
+    cout << states[i] << endl;
+    cout << "---------------------------------------------" << endl;
+    assert( states[i] == gstate );
+  }
+
+  //********************************************************************
+
+  cout << ok_prefix << "Default propagate to an existing surface."
+       << endl;
+  for ( int i=0; i<nstate; ++i ) {
+    GTrackState gstate = gpropd.propagate( gtr, surfs[i] );
+    cout << gstate << endl;
+    assert( states[i] == gstate );
+  }
+
+  //********************************************************************
+
+  cout << ok_prefix << "Full propagate to an existing surface."
+       << endl;
+  for ( int i=0; i<nstate; ++i ) {
+    GTrackState gstate = gprop.propagate( gtr, surfs[i] );
+    cout << gstate << endl;
+    assert( states[i] == gstate );
+  }
+
+  //********************************************************************
+
+  cout << ok_prefix << "Null propagate to a new surfaces." << endl;
+  vector<double> r;
+  r.push_back(5.0);
+  r.push_back(13.0);
+  r.push_back(23.0);
+  r.push_back(33.0);
+  r.push_back(43.0);
+  r.push_back(55.0);
+  r.push_back(100.0);
+  for ( int i=0; i<r.size(); ++i ) {
+    SurfacePtr psrf(new SurfCylinder(r[i]));
+    cout << endl << *psrf << endl;
+    GTrackState gstate = gpropn.propagate( gtr, psrf );
+    cout << gstate << endl;
+    assert( ! gstate.is_valid() );
+  }
+
+  //********************************************************************
+
+  cout << ok_prefix << "Default Propagate to a new surfaces." << endl;
+  for ( int i=0; i<r.size(); ++i ) {
+    SurfacePtr psrf(new SurfCylinder(r[i]));
+    cout << endl << *psrf << endl;
+    GTrackState gstate = gpropd.propagate( gtr, psrf );
+    cout << gstate << endl;
+    assert( gstate.is_valid() );
+    assert( *gstate.track().get_surface() == *psrf );
+  }
+
+  //********************************************************************
+
+  cout << ok_prefix << "Full Propagate to a new surfaces." << endl;
+  for ( int i=0; i<r.size(); ++i ) {
+    SurfacePtr psrf(new SurfCylinder(r[i]));
+    cout << endl << *psrf << endl;
+    GTrackState gstate = gprop.propagate( gtr, psrf );
+    cout << gstate << endl;
+    assert( gstate.is_valid() );
+    assert( *gstate.track().get_surface() == *psrf );
+  }
+
+  //********************************************************************
+
+  cout << ok_prefix
+       << "------------- All tests passed. -------------" << endl;
+  return 0;
+
+  //********************************************************************
+
+}

trf++/test/gtrbase
GTrackState_t.cpp added at 1.1
diff -N GTrackState_t.cpp
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ GTrackState_t.cpp	10 Aug 2011 18:09:53 -0000	1.1
@@ -0,0 +1,184 @@
+// GTrackState_t.cpp
+
+// Test GTrackState.
+
+#include "gtrbase/GTrackState.hpp"
+#include <cassert>
+#include <string>
+#include <iostream>
+#include <cassert>
+#include "trfbase/SurfTest.h"
+// cng  #include "d0cluster/ChunkClusterIndex.hpp"
+#include "trfbase/MissTest.h"
+#include "gtrbase/FitStatus.hpp"
+
+#ifndef DEFECT_NO_STDLIB_NAMESPACES
+using std::cout;
+using std::cerr;
+using std::endl;
+using std::string;
+#endif
+// cng  using edm::CollisionID;
+// cng  using edm::ChunkID;
+// cng  using edm::Event;
+
+using namespace trf;
+
+//**********************************************************************
+
+int main( ) {
+
+  string component = "GTrackState";
+  string ok_prefix = component + " (I): ";
+  string error_prefix = component + " test (E): ";
+
+  cout << ok_prefix
+       << "---------- Testing component " + component
+          + ". ----------" << endl;
+
+  // Make sure assert is enabled.
+  bool assert_flag = false;
+  assert ( ( assert_flag = true, assert_flag ) );
+  if ( ! assert_flag ) {
+    cerr << "Assert is disabled" << endl;
+    return 1;
+  }
+
+  //********************************************************************
+
+  cout << ok_prefix << "Construct default state." << endl;
+  {
+    GTrackState state;
+    cout << state << endl;
+    assert( ! state.is_valid() );
+    assert( ! state.has_valid_fit() );
+  }
+
+  //********************************************************************
+
+  cout << ok_prefix << "Construct a valid state." << endl;
+  double s = 2.34;
+  SurfacePtr psrf(new SurfTest(1.0));
+  TrackVector vec;
+  vec(0) = 1.0;
+  vec(1) = 1.1;
+  vec(2) = 1.2;
+  vec(3) = 1.3;
+  vec(4) = 1.4;
+  TrackError err;
+  err(0,0) = 0.01;
+  err(1,2) = 0.11;
+  err(2,2) = 0.21;
+  err(3,3) = 0.31;
+  err(4,4) = 0.41;
+  ETrack tre(psrf,vec,err);
+  GTrackState::FitStatus stat = GTrackState::OPTIMAL;
+  double chsq = 12.345;
+  GTrackState state1(s,tre,stat,chsq);
+  cout << state1 << endl;
+  assert( state1.s() == s );
+  assert( state1.track() == tre );
+  assert( state1.fit_status() == stat );
+  assert( state1.chi_square() == chsq );
+// cng    assert( ! state1.cluster().is_valid() );
+  assert( ! state1.miss() );
+  assert( ! state1.smoother() );
+  assert( state1.is_valid() );
+  assert( state1.has_valid_fit() );
+
+  //********************************************************************
+
+  cout << ok_prefix << "Check constructor from s." << endl;
+  {
+    GTrackState state2(s);
+    cout << state2 << endl;
+    assert( state2 != state1 );
+    assert( state2.s() == s );
+    assert( ! state2.track().is_valid() );
+    assert( state2.fit_status() == INVALID );
+// cng      assert( ! state2.cluster().is_valid() );
+    assert( ! state2.miss() );
+    assert( ! state2.smoother() );
+    assert( state2.is_valid() );
+    assert( ! state2.has_valid_fit() );
+  }
+
+  //********************************************************************
+/* cng
+  cout << ok_prefix << "Check constructor with cluster." << endl;
+  {
+    EventPtr pevt( new Event(CollisionID(123,45)) );
+    ChunkID chkid(78);
+    D0ClusterIndex iclu(246);
+    ChunkClusterIndex pclu(pevt,chkid,iclu);
+    GTrackState state2(s,tre,stat,chsq,pclu);
+    cout << state2 << endl;
+    assert( state2 != state1 );
+    assert( state2.s() == s );
+    assert( state2.track() == tre );
+    assert( state1.fit_status() == stat );
+    assert( state2.chi_square() == chsq );
+    assert( state2.cluster() == pclu );
+    assert( ! state2.miss() );
+    assert( ! state2.smoother() );
+    assert( state2.is_valid() );
+    assert( state2.has_valid_fit() );
+  }
+*/
+  //********************************************************************
+
+  cout << ok_prefix << "Check constructor with miss." << endl;
+  {
+    MissPtr pmiss(new MissTest(1.0,0.5));
+    GTrackState state2(s,tre,stat,chsq,pmiss);
+    cout << state2 << endl;
+    assert( state2 != state1 );
+    assert( state2.s() == s );
+    assert( state2.track() == tre );
+    assert( state1.fit_status() == stat );
+    assert( state2.chi_square() == chsq );
+// cng      assert( ! state2.cluster().is_valid() );
+    assert( state2.miss() != 0 );
+    assert( state2.miss() == pmiss );
+    assert( ! state2.smoother() );
+    assert( state2.is_valid() );
+    assert( state2.has_valid_fit() );
+  }
+
+  //********************************************************************
+
+  cout << ok_prefix << "Check equality." << endl;
+  {
+    GTrackState state2(s,tre,stat,chsq);
+    cout << state2 << endl;
+    assert( state2 == state1 );
+  }
+  {
+    GTrackState state2(s+1.0,tre,stat,chsq);
+    cout << state2 << endl;
+    assert( ! (state2 == state1) );
+  }
+
+  //********************************************************************
+
+  cout << ok_prefix << "Check fit drop." << endl;
+  {
+    GTrackState state2(s,tre,stat,chsq);
+    cout << state2 << endl;
+    assert( state2.has_valid_fit() );
+    assert( state2.save_track_fit() );
+    state2.drop_fit();
+    assert( state2.has_valid_fit() );
+    assert( ! state2.save_track_fit() );
+    assert( state2 == state1 );
+  }
+
+  //********************************************************************
+
+  cout << ok_prefix
+       << "------------- All tests passed. -------------" << endl;
+  return 0;
+
+  //********************************************************************
+
+}

trf++/test/gtrbase
GTrack_t.cpp added at 1.1
diff -N GTrack_t.cpp
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ GTrack_t.cpp	10 Aug 2011 18:09:53 -0000	1.1
@@ -0,0 +1,198 @@
+// GTrack_t.cpp
+
+#include "gtrbase/GTrack.hpp"
+
+// Test GTrack.
+
+#include "gtrbase/GTrackTest.hpp"
+
+using std::cout;
+using std::cerr;
+using std::endl;
+using std::vector;
+using std::string;
+
+/* cng
+#ifdef GTrack_holds_chunk_id
+using edm::ChunkID;
+using edm::LinkIndex;
+#endif
+*/
+
+using namespace trf;
+
+//**********************************************************************
+
+int main( ) {
+
+  string component = "GTrack";
+  string ok_prefix = component + " (I): ";
+  string error_prefix = component + " test (E): ";
+
+  cout << ok_prefix
+       << "---------- Testing component " + component
+          + ". ----------" << endl;
+
+  // Make sure assert is enabled.
+  bool assert_flag = false;
+  assert ( ( assert_flag = true, assert_flag ) );
+  if ( ! assert_flag ) {
+    cerr << "Assert is disabled" << endl;
+    return 1;
+  }
+
+  //********************************************************************
+
+  GTrackTest test(ok_prefix);
+  int nclus = test.nclus;
+  int nmiss = test.nmiss;
+  int nstate = nclus + nmiss;
+  const vector<double>& clus_ss = test.ss;
+  const vector<double>& miss_ss = test.miss_ss;
+  const vector<SurfacePtr>& clus_surfs = test.surfs;
+  const vector<SurfacePtr>& miss_surfs = test.miss_surfs;
+  const GTrack::StateList& states = test.stateset;
+  const GTrack& gtr0 = test.gtr;
+/* cng
+#ifdef GTrack_holds_chunk_id
+  GTrack& mgtr0 = const_cast<GTrack&>(gtr0);
+  ChunkID cid(4);
+  unsigned int oid(123);
+  ChunkID coid(cid.id(), oid);
+  mgtr0.set_ids(cid,oid);
+  {
+    LinkIndex<GTrack> igtr = gtr0.index();
+    assert( igtr.getPointer() == &gtr0 );
+    cout << coid << endl;
+    cout << igtr.id() << endl;
+    assert( igtr.id() == coid );
+  }
+#else
+  assert(false);
+#endif
+*/
+  //********************************************************************
+
+  cout << ok_prefix << "Build empty track." << endl;
+  GTrack gtr2;
+  assert( ! gtr2.is_valid() );
+  assert( gtr0 != gtr2 );
+  assert( ! (gtr0 == gtr2) );
+
+  //********************************************************************
+
+  cout << ok_prefix << "Check copy." << endl;
+  GTrack gtr1 = gtr0;
+  GTrack gtr3 = gtr2;
+  assert( gtr1.is_valid() );
+  assert( ! gtr3.is_valid() );
+  assert( gtr1 == gtr0 );
+#ifdef GTrack_holds_chunk_id
+  {
+    LinkIndex<GTrack> igtr = gtr1.index();
+    assert( igtr.getPointer() == &gtr1 );
+    assert( igtr.id() == coid );
+  }
+#endif
+
+  //********************************************************************
+
+  cout << ok_prefix << "Check assignment." << endl;
+  gtr2 = gtr1;
+  assert( gtr2.is_valid() );
+  assert( gtr2 == gtr1 );
+  gtr2 = gtr3;
+  assert( ! gtr2.is_valid() );
+
+  //********************************************************************
+
+  cout << ok_prefix << "Fetch states by s." << endl;
+  // Every other state is a miss.
+  {
+    GTrack::StateList::const_iterator ista = states.begin();
+    bool cluster = true;
+    int iclus = 0;
+    int imiss = 0;
+    for ( int i=0; i<nstate; ++i ) {
+      double s;
+      if ( cluster ) {
+        s= clus_ss[iclus++];
+        cluster = false;
+      } else {
+        s = miss_ss[imiss++];
+        cluster = true;
+      }
+      const GTrackState& state = gtr0.get_state(s);
+      cout << "State " << i << endl;
+      cout << state << endl;
+      assert( state == *ista );
+      ++ista;
+    }
+  }
+
+  //********************************************************************
+
+  cout << ok_prefix << "Fetch states by surface." << endl;
+  {
+    GTrack::StateList::const_iterator ista = states.begin();
+    bool cluster = true;
+    int iclus = 0;
+    int imiss = 0;
+    for ( int i=0; i<nstate; ++i ) {
+      SurfacePtr psrf(0);
+      if ( cluster ) {
+        psrf = clus_surfs[iclus++];
+        cluster = false;
+      } else {
+        psrf = miss_surfs[imiss++];
+        cluster = true;
+      }
+      const GTrackState& state = gtr0.get_state(psrf);
+      cout << "State " << i << endl;
+      cout << state << endl;
+      assert( state == *ista );
+      ++ista;
+    }
+  }
+
+  //********************************************************************
+
+  cout << ok_prefix << "Build track with different track parameters." 
+       << endl;
+  {
+    GTrackTest test4(ok_prefix, /* cng EventPtr(0),ChunkID(0), */4.56);
+    GTrack& gtr4 = test4.gtr;
+    cout << gtr4 << endl;
+    assert( gtr4 != gtr0 );
+  }
+
+
+  //********************************************************************
+
+  cout << ok_prefix << "Drop a fit" << endl;
+  {
+    GTrack gtr = gtr0;
+    assert( gtr.get_states().size() > 1 );
+    GTrack::StateList::const_iterator ista = gtr.get_states().begin();
+    ++ista;
+    double s = ista->s();
+    cout << "s = " << s << endl;
+    cout << gtr << endl;
+    assert( gtr.get_state(s).has_valid_fit() );
+    assert( gtr.get_state(s).save_track_fit() );
+    gtr.drop_fit(s);
+    cout << gtr << endl;
+    assert( gtr.get_state(s).has_valid_fit() );
+    assert( ! gtr.get_state(s).save_track_fit() );
+  }
+
+
+  //********************************************************************
+
+  cout << ok_prefix
+       << "------------- All tests passed. -------------" << endl;
+  return 0;
+
+  //********************************************************************
+
+}

trf++/test/gtrbase
GtrTrfPropagator_t.cpp added at 1.1
diff -N GtrTrfPropagator_t.cpp
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ GtrTrfPropagator_t.cpp	10 Aug 2011 18:09:53 -0000	1.1
@@ -0,0 +1,244 @@
+// GtrTrfPropagator_t.cpp
+
+// Test GtrTrfPropagator.
+
+#include "gtrbase/GtrTrfPropagator.hpp"
+#include <cassert>
+#include <string>
+#include <iostream>
+#include <vector>
+#include <cassert>
+#include "trfbase/SurfacePtr.h"
+#include "trfcyl/SurfCylinder.h"
+#include "trfzp/SurfZPlane.h"
+#include "trfxyp/SurfXYPlane.h"
+#include "trfdca/SurfDCA.h"
+#include "trfbase/ETrack.h"
+#include "trfbase/PropStat.h"
+
+#include "spacegeom/SpacePath.h"
+// cng #include "framework/Testing.hpp"
+// cng #include "run_config_fwk/RunConfigPkg.hpp"
+
+using std::cout;
+using std::cerr;
+using std::endl;
+using std::string;
+using std::abs;
+using std::vector;
+using std::sqrt;
+
+using namespace trf;
+
+//**********************************************************************
+
+// Return true if two ETrack's are close to one another.
+// Note tests phrased so that NAN will fail.
+
+bool about_equal(const ETrack& tre1, const ETrack& tre2) {
+  bool equal = true;
+  double maxdif = 1.e-8;
+  // Check vector.
+  TrackVector vdiff = 
+    tre1.get_surface()->vec_diff( tre1.get_vector(), tre2.get_vector() );
+  for (int i=0; i<5; ++i) {
+    double adif = abs( vdiff(i) );
+    if ( ! (adif < maxdif) ) {
+      cout << "vecdif(" << i << ") = " << adif << endl;
+      equal = false;
+    }
+  }
+  // Check errors.
+  TrackError ediff = tre1.get_error() - tre2.get_error();
+  TrackError eavg = tre1.get_error() + tre2.get_error();
+  for (int i=0; i<5; ++i) {
+    for (int j=0; j<=i; ++j) {
+      double adif = abs( ediff(i,j) );
+      double afrac = ediff(i,j)/sqrt(eavg(i,i)*eavg(j,j));
+      if ( !(adif < maxdif) ) {
+        cout << "errdif(" << i << "," << j << ") = " << adif
+             << "   frac = " << afrac << endl;
+        equal = false;
+      }
+    }
+  }
+  return equal;
+}
+
+//**********************************************************************
+
+// Return whether an (intial, final) pair of surfaces should be
+// required.
+
+// 06jul98 - require all tests.
+
+bool must_pass(string initial, string final) {
+  if ( initial == "cylinder" ) {
+    if ( final == "cylinder" ) return true;
+    else if ( final == "z-plane" ) return true;
+    else if ( final == "xy-plane" ) return true;
+    else if ( final == "DCA" ) return true;
+    else assert(false);
+  }
+  else if ( initial == "z-plane" ) {
+    if ( final == "cylinder" ) return true;
+    else if ( final == "z-plane" ) return true;
+    else if ( final == "xy-plane" ) return true;
+    else if ( final == "DCA" ) return true;
+    else assert(false);
+  }
+  else if ( initial == "xy-plane" ) {
+    if ( final == "cylinder" ) return true;
+    else if ( final == "z-plane" ) return true;
+    else if ( final == "xy-plane" ) return true;
+    else if ( final == "DCA" ) return true;
+    else assert(false);
+  }
+  else if ( initial == "DCA" ) {
+    if ( final == "cylinder" ) return true;
+    else if ( final == "z-plane" ) return true;
+    else if ( final == "xy-plane" ) return true;
+    else if ( final == "DCA" ) return true;
+    else assert(false);
+  }
+  else assert(false);
+  return false;
+}
+
+//**********************************************************************
+
+int main( ) {
+
+  string component = "GtrTrfPropagator";
+  string ok_prefix = component + " (I): ";
+  string error_prefix = component + " test (E): ";
+
+  cout << ok_prefix
+       << "---------- Testing component " + component
+          + ". ----------" << endl;
+
+  // Make sure assert is enabled.
+  bool assert_flag = false;
+  assert ( ( assert_flag = true, assert_flag ) );
+  if ( ! assert_flag ) {
+    cerr << "Assert is disabled" << endl;
+    return 1;
+  }
+
+  //********************************************************************
+/* cng
+  RunConfigPkg* p1 = 0;
+  makePackage(p1, "run_config_fwk", "RunConfigPkg");
+  assert(p1 != 0);
+*/
+  cout << ok_prefix << "Fetch propagator." << endl;
+  GtrTrfPropagator gprop;
+  PropagatorPtr pprop( gprop.get_propagator() );
+  cout << *pprop << endl;
+  PropStat pstat;
+
+  //********************************************************************
+
+  cout << ok_prefix << "Construct surfaces." << endl;
+  double r0 = 10.0;
+  SurfacePtr pscyl( new SurfCylinder(r0) );
+  cout << *pscyl << endl;
+  double z0 =  5.0;
+  SurfacePtr pszpl( new SurfZPlane(z0) );
+  cout << *pszpl << endl;
+  double phi0 = 1.57;
+  double xy0 = 15.0;
+  SurfacePtr psxyp( new SurfXYPlane(xy0,phi0) );
+  cout << *psxyp << endl;
+  SurfacePtr psdca( new SurfDCA );
+  cout << *psdca << endl;
+
+  //********************************************************************
+
+  cout << ok_prefix << "Construct track." << endl;
+  TrackVector vec;
+  vec(SurfCylinder::IPHI) = 0.10;
+  vec(SurfCylinder::IZ)   = 12.00;
+  vec(SurfCylinder::IALF) = 0.03;
+  vec(SurfCylinder::ITLM) = 1.04;
+  vec(SurfCylinder::IQPT) = 0.05;
+  TrackError err;
+  err(SurfCylinder::IPHI,SurfCylinder::IPHI) = 0.0001;
+  err(SurfCylinder::IZ,  SurfCylinder::IZ  ) = 0.0200;
+  err(SurfCylinder::IALF,SurfCylinder::IALF) = 0.0003;
+  err(SurfCylinder::ITLM,SurfCylinder::ITLM) = 0.0400;
+  err(SurfCylinder::IQPT,SurfCylinder::IQPT) = 0.000005;
+  ETrack tre0(pscyl,vec,err);
+  cout << tre0 << endl;
+
+  //********************************************************************
+
+  cout << ok_prefix << "Test propagation to and back." << endl;
+  int nsrf = 4;
+  vector<SurfacePtr> surfs;
+  surfs.push_back(pscyl);
+  surfs.push_back(pszpl);
+  surfs.push_back(psxyp);
+  surfs.push_back(psdca);
+  vector<string> names;
+  names.push_back("cylinder");
+  names.push_back("z-plane");
+  names.push_back("xy-plane");
+  names.push_back("DCA");
+  int ntest = 0;
+  int nfail = 0;
+  int nfail_required = 0;
+  // Loop over starting surfaces.
+  for ( int isrf=0; isrf<nsrf; ++isrf ) {
+    SurfacePtr psrf1 = surfs[isrf];
+    // Propagate to starting surface.
+    ETrack tre1(tre0);
+    pstat = pprop->err_prop(tre1,*psrf1);
+    assert( pstat.success() );
+    // Loop over final surfaces.
+    for ( int jsrf=0; jsrf<nsrf; ++jsrf ) {
+      ++ntest;
+      SurfacePtr psrf2 = surfs[jsrf];
+      ETrack tre2(tre1);
+      cout << endl;
+      cout << "Propagate from " << names[isrf] << " to " << names[jsrf]
+           << " and back." << endl;
+      cout << tre2 << endl;
+      // Propagate to 2nd surface.
+      pstat = pprop->err_prop(tre2,*psrf2);
+      assert( pstat.success() );
+      cout << tre2 << endl;
+      // Evaluate direction for return propagation.
+      Propagator::PropDir dir = Propagator::NEAREST;
+      if ( pstat.forward() ) dir = Propagator::BACKWARD;
+      else if ( pstat.backward() ) dir = Propagator::FORWARD;
+      // Propagate back to first surface.
+      pstat = pprop->err_dir_prop(tre2,*psrf1,dir);
+      assert( pstat.success() );
+      cout << tre2 << endl;
+      // Check track is same as original.
+      bool check = about_equal(tre1,tre2);
+      if ( check ) {
+        cout << "OK" << endl;
+      }
+      else {
+         ++nfail;
+         if ( must_pass(names[isrf],names[jsrf]) ) ++nfail_required;
+         cout << "Final track differs from original!!!" << endl;
+      }
+    }
+  }
+  cout << endl;
+  cout << nfail << " of " << ntest << " tests failed." << endl;
+  assert( ntest == 16 );
+  assert( nfail_required == 0 );
+
+  //********************************************************************
+
+  cout << ok_prefix
+       << "------------- All tests passed. -------------" << endl;
+  return 0;
+
+  //********************************************************************
+
+}

trf++/test/gtrbase
McParent_t.cpp added at 1.1
diff -N McParent_t.cpp
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ McParent_t.cpp	10 Aug 2011 18:09:53 -0000	1.1
@@ -0,0 +1,80 @@
+// McParent_t.cpp
+
+// Test McParent.
+
+#include "gtrbase/McParent.hpp"
+#include <cassert>
+#include <string>
+#include <iostream>
+#include <cassert>
+
+#ifndef DEFECT_NO_STDLIB_NAMESPACES
+using std::cout;
+using std::cerr;
+using std::endl;
+using std::string;
+#endif
+
+//**********************************************************************
+
+int main( ) {
+
+  string component = "MCParent";
+  string ok_prefix = component + " (I): ";
+  string error_prefix = component + " test (E): ";
+
+  cout << ok_prefix
+       << "---------- Testing component " + component
+          + ". ----------" << endl;
+
+  // Make sure assert is enabled.
+  bool assert_flag = false;
+  assert ( ( assert_flag = true, assert_flag ) );
+  if ( ! assert_flag ) {
+    cerr << "Assert is disabled" << endl;
+    return 1;
+  }
+
+  //********************************************************************
+
+  McParent parent;
+  assert(!parent.from_uds());
+
+  parent.set_parent(1);
+  assert(parent.from_uds());
+
+  parent.set_parent(23);
+  assert(parent.from_z());
+
+  int parentword = parent.get_parentword();
+  assert(parent.get_parentword()==129);
+
+  const McParent::ParentList plist = parent.parents();
+  assert( plist.size()==2);
+  assert( plist.find(23)!= plist.end() );
+  assert( plist.find(1) != plist.end() );
+  assert( plist.find(37) == plist.end() );
+  for (McParent::ParentList::const_iterator it = plist.begin(); it!=plist.end(); ++it){
+    cout << " Parent= " << *it << endl;
+  }
+
+  McParent parent2(parentword);
+  assert(parent2.from_uds());
+  assert(parent2.from_z());
+
+  const McParent::ParentList plist2 =  parent2.parents();
+  assert( plist2.size()==2);
+  assert( plist2.find(23)!= plist2.end() );
+  assert( plist2.find(1) != plist2.end() );
+  assert( plist2.find(37) == plist2.end() );
+
+
+  //********************************************************************
+
+  cout << ok_prefix
+       << "------------- All tests passed. -------------" << endl;
+  return 0;
+
+  //********************************************************************
+
+}

trf++/test/gtrbase
McTrackState_t.cpp added at 1.1
diff -N McTrackState_t.cpp
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ McTrackState_t.cpp	10 Aug 2011 18:09:53 -0000	1.1
@@ -0,0 +1,127 @@
+// McTrackState_t.cpp
+
+// Test McTrackState.
+
+#include "gtrbase/McTrackState.hpp"
+#include <cassert>
+#include <string>
+#include <iostream>
+#include <cassert>
+#include "trfbase/SurfTest.h"
+
+#ifndef DEFECT_NO_STDLIB_NAMESPACES
+using std::cout;
+using std::cerr;
+using std::endl;
+using std::string;
+#endif
+
+using namespace trf;
+
+//**********************************************************************
+
+int main( ) {
+
+  string component = "McTrackState";
+  string ok_prefix = component + " (I): ";
+  string error_prefix = component + " test (E): ";
+
+  cout << ok_prefix
+       << "---------- Testing component " + component
+          + ". ----------" << endl;
+
+  // Make sure assert is enabled.
+  bool assert_flag = false;
+  assert ( ( assert_flag = true, assert_flag ) );
+  if ( ! assert_flag ) {
+    cerr << "Assert is disabled" << endl;
+    return 1;
+  }
+
+  //********************************************************************
+
+  cout << ok_prefix << "Construct default state." << endl;
+  {
+    McTrackState state;
+    cout << state << endl;
+    assert( ! state.is_valid() );
+  }
+
+  //********************************************************************
+
+  cout << ok_prefix << "Construct a valid state." << endl;
+  double s = 2.34;
+  SurfacePtr psrf(new SurfTest(1.0));
+  TrackVector vec;
+  vec(0) = 1.0;
+  vec(1) = 1.1;
+  vec(2) = 1.2;
+  vec(3) = 1.3;
+  vec(4) = 1.4;
+  VTrack trv(psrf,vec);
+  McTrackState state1(s,trv);
+  cout << state1 << endl;
+  assert( state1.s() == s );
+  assert( state1.track() == trv );
+
+  //********************************************************************
+
+  cout << ok_prefix << "Check long constructor." << endl;
+  {
+    McTrackState state2(s,psrf,vec);
+    cout << state2 << endl;
+    assert( state2 == state1 );
+  }
+
+  //********************************************************************
+
+  cout << ok_prefix << "Check equality." << endl;
+  {
+    McTrackState state2(s,trv);
+    cout << state2 << endl;
+    assert( state2 == state1 );
+  }
+  {
+    TrackVector vec2 = vec;
+    vec2(0) = 2.0;
+    VTrack trv2(psrf,vec2);
+    McTrackState state2(s,trv2);
+    cout << state2 << endl;
+    assert( ! (state2 == state1) );
+  }
+  {
+    McTrackState state2(s+1.0,trv);
+    cout << state2 << endl;
+    assert( ! (state2 == state1) );
+  }
+
+  //********************************************************************
+
+  cout << ok_prefix << "Check ordering." << endl;
+  {
+    McTrackState state2(s+1.0,trv);
+    cout << state2 << endl;
+    assert( state1 < state2 );
+  }
+
+   //********************************************************************
+
+  cout << ok_prefix << "Check DetectorID." << endl;
+  {
+    McTrackState state2(s+1.0,trv);
+    assert( state2.get_detid() == DetectorID(0) );
+    state2.set_detid(DetectorID(12));
+    assert( state2.get_detid() == DetectorID(12) );
+    McTrackState state3 = state2;
+    assert( state3.get_detid() == DetectorID(12) );
+  }
+
+  //********************************************************************
+
+  cout << ok_prefix
+       << "------------- All tests passed. -------------" << endl;
+  return 0;
+
+  //********************************************************************
+
+}

trf++/test/gtrbase
McTrack_t.cpp added at 1.1
diff -N McTrack_t.cpp
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ McTrack_t.cpp	10 Aug 2011 18:09:53 -0000	1.1
@@ -0,0 +1,153 @@
+// McTrack_t.cpp
+
+// Test McTrack.
+
+#include "gtrbase/McTrack.hpp"
+#include <cassert>
+#include <string>
+#include <iostream>
+#include <cassert>
+#include "trfbase/SurfTest.h"
+// cng #include "mcpp/MCparticle.hpp"
+// cng #include "d0_mcpp/D0MCparticle.hpp"
+
+#ifndef DEFECT_NO_STDLIB_NAMESPACES
+using std::cout;
+using std::cerr;
+using std::endl;
+using std::string;
+#endif
+
+using namespace trf;
+
+//**********************************************************************
+
+int main( ) {
+
+  string component = "GTrMCTrack";
+  string ok_prefix = component + " (I): ";
+  string error_prefix = component + " test (E): ";
+
+  cout << ok_prefix
+       << "---------- Testing component " + component
+          + ". ----------" << endl;
+
+  // Make sure assert is enabled.
+  bool assert_flag = false;
+  assert ( ( assert_flag = true, assert_flag ) );
+  if ( ! assert_flag ) {
+    cerr << "Assert is disabled" << endl;
+    return 1;
+  }
+
+  //********************************************************************
+
+  cout << ok_prefix << "Construct track." << endl;
+  McTrack::StateList states;
+  SurfacePtr psrf1( new SurfTest(1) );
+  SurfacePtr psrf2( new SurfTest(2) );
+  SurfacePtr psrf3( new SurfTest(3) );
+  TrackVector vec1;
+  vec1(0) = 1.0;
+  TrackVector vec2;
+  vec2(0) = 2.0;
+  TrackVector vec3;
+  vec3(0) = 3.0;
+  TrackVector vec4;
+  vec4(0) = 4.0;
+  states.insert( McTrackState(1.0,psrf1,vec1) );
+  states.insert( McTrackState(4.0,psrf2,vec4) );
+  states.insert( McTrackState(3.0,psrf3,vec3) );
+  states.insert( McTrackState(2.0,psrf2,vec2 ));
+
+  int mctrackid = 1;
+  int parentword = 129;
+
+/* cng
+  // Create D0MCparticle
+  MCparticle* p=new MCparticle();
+  D0MCparticle d0mc_p(p);
+  edm::LinkIndex<D0MCparticle> mclink=d0mc_p.index();
+*/
+  McTrack trmc(states,mctrackid,parentword /*,mclink*/ );
+  cout << trmc << endl;
+  assert( trmc.is_valid() );
+
+  //********************************************************************
+
+  cout << ok_prefix << "Fetch particle Id type." << endl;
+  assert( trmc.get_pdgid()== 13 );
+
+  cout << ok_prefix << "Fetch MC particle track Id." << endl;
+  assert( trmc.get_mctrackid()== mctrackid );
+
+  //********************************************************************
+
+  cout << ok_prefix << "Fetch particle parentage." << endl;
+  assert( trmc.get_parent().from_z() );
+
+
+  //********************************************************************
+
+  cout << ok_prefix << "Construct bad tracks." << endl;
+  McTrack trmcbad1;
+  cout << trmcbad1 << endl;
+  assert( ! trmcbad1.is_valid() );
+  /* The following invokes an assertion
+  states.insert( McTrack::State() );
+  McTrack trmcbad2(states);
+  cout << trmcbad2 << endl;
+  assert( ! trmcbad2.is_valid() );
+  */
+
+  //********************************************************************
+
+  cout << ok_prefix << "Access full list." << endl;
+  assert( trmc.get_states().size() == states.size() );
+  assert( trmc.get_states() == states );
+
+  //********************************************************************
+
+  cout << ok_prefix << "Access a particular state." << endl;
+  assert( trmc.get_state(*psrf2).is_valid() );
+  McTrackState state2 = trmc.get_state(*psrf2);
+  assert( state2 == McTrackState(2.0,psrf2,vec2) );
+  SurfTest srf2b(2);
+  assert( trmc.get_state(srf2b) == McTrackState(2.0,psrf2,vec2) );
+  SurfTest srf4(4);
+  assert( ! trmc.get_state(srf4).is_valid() );
+
+  //********************************************************************
+
+  cout << ok_prefix << "Equality (and order)." << endl;
+  McTrack::StateList states2;
+  McTrack::StateList states3;
+  states2.insert( McTrackState(1.0, psrf1, vec1) );
+  states2.insert( McTrackState(2.0, psrf2, vec2) );
+  states2.insert( McTrackState(4.0, psrf2, vec4) );
+  states2.insert( McTrackState(3.0, psrf3, vec3) );
+  McTrack trmc2(states2,mctrackid,parentword /*,mclink */);
+  assert( trmc2 == trmc );
+  assert( ! (trmc2 != trmc ) );
+  states3.insert( McTrackState(3.0,psrf3,vec3) );
+  int pdgid = -11;
+  McTrack trmc3(states3,mctrackid,parentword, /* mclink,*/ pdgid);
+  assert( trmc3 != trmc );
+  assert( ! (trmc3 == trmc ) );
+  assert( trmc3.get_pdgid()==pdgid );
+
+  //********************************************************************
+
+  cout << ok_prefix << "Copy." << endl;
+  McTrack trmc4(trmc);
+  assert( trmc4 == trmc );
+
+  //********************************************************************
+
+  cout << ok_prefix
+       << "------------- All tests passed. -------------" << endl;
+  return 0;
+
+  //********************************************************************
+
+}
CVSspam 0.2.8