Commit in trf++/test/gtrfit on MAIN
GTrackSmoother_t.cpp+104added 1.1
SimpleGTrackFitter_t.cpp+78added 1.1
+182
2 added files
global track fitting

trf++/test/gtrfit
GTrackSmoother_t.cpp added at 1.1
diff -N GTrackSmoother_t.cpp
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ GTrackSmoother_t.cpp	11 Aug 2011 00:05:53 -0000	1.1
@@ -0,0 +1,104 @@
+// GTrackSmoother_t.cpp
+
+#include "GTrackSmoother.hpp"
+#include "gtrbase/GTrack.hpp"
+#include "gtrbase/GTrackTest.hpp"
+#include "trfcyl/PropCyl.h"
+#include <iostream>
+#include <string>
+#include <cassert>
+
+using std::cout;
+using std::cerr;
+using std::endl;
+using std::string;
+using std::vector;
+using namespace trf;
+
+namespace {
+double correct_path_distance(const GTrack::StateList& states,double s);
+}
+
+//**********************************************************************
+
+int main( ) {
+
+  string component = "GTrackSmoother";
+  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>& ss = test.ss;
+  const vector<SurfacePtr>& surfs = test.surfs;
+  const GTrack::StateList& states = test.stateset;
+  const GTrack& gtr0 = test.gtr;
+  assert( gtr0.get_states().size() == nstate );
+  cout << "Starting GTrack: " << endl << gtr0 << endl;
+ 
+  //test constructor
+  cout << "Testing Constructor " << endl;
+  //Specify the order...
+  int order = 1;
+  //Build a propagator...
+  double bfield = 2.0;
+  PropagatorPtr pcylcyl( new PropCyl(ObjDoublePtr(new ObjDouble(bfield))));
+
+  GTrackSmoother gtf(pcylcyl);
+
+  // test the fitter
+  // We skip this because we cannot handle cluster indices without
+  // a chunk and an event.
+  //cout << "Fitting the Gtrack... " << endl;
+  //GTrack gtr1 = gtr0;
+  //gtf.fit(gtr1);
+  //cout << "Refit GTrack: " << endl << gtr1 << endl;
+  //assert( gtr0.get_states().size() == nstate );
+
+  GTrack::StateList statelist;
+  ETrack tre1;
+  for(int i=0 ; i < 4 ; ++i ) {
+    double s= correct_path_distance(statelist,0.);
+    std::cout<<"s= "<<s<<'\n';
+    GTrackState state(s,tre1,GTrackState::OPTIMAL, 0., MissPtr(0));
+    statelist.insert(state);
+    assert( statelist.size() == i+1 );
+  }
+
+  //********************************************************************
+
+  cout << ok_prefix
+       << "------------- All tests passed. -------------" << endl;
+  return 0;
+
+  //********************************************************************
+
+}
+
+namespace {
+  double correct_path_distance(const GTrack::StateList& states,double spath) {
+  double s = spath;
+  for(GTrack::StateList::const_iterator i=states.begin(); i != states.end() ; ++i) {
+    if( fabs(i->s() - s) < 1.e-7 ) {
+      s+=1e-5;
+    }
+  }
+  return s;
+}
+}

trf++/test/gtrfit
SimpleGTrackFitter_t.cpp added at 1.1
diff -N SimpleGTrackFitter_t.cpp
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ SimpleGTrackFitter_t.cpp	11 Aug 2011 00:05:53 -0000	1.1
@@ -0,0 +1,78 @@
+// SimpleGTrackFitter_t.cpp
+
+#include "SimpleGTrackFitter.hpp"
+#include "gtrbase/GTrackTest.hpp"
+#include "trfcyl/PropCyl.h"
+#include <iostream>
+#include <string>
+#include <cassert>
+
+using std::cout;
+using std::cerr;
+using std::endl;
+using std::string;
+using std::vector;
+using namespace trf;
+
+//**********************************************************************
+
+int main( ) {
+
+  string component = "SimpleGTrackFitter";
+  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>& ss = test.ss;
+  const vector<SurfacePtr>& surfs = test.surfs;
+  const GTrack::StateList& states = test.stateset;
+  const GTrack& gtr0 = test.gtr;
+  assert( gtr0.get_states().size() == nstate );
+  cout << "Starting GTrack: " << endl << gtr0 << endl;
+ 
+  //test constructor
+  cout << "Testing Constructor " << endl;
+  //Specify the order...
+  int order = 1;
+  //Build a propagator...
+  double bfield = 2.0;
+  PropagatorPtr pcylcyl( new PropCyl(ObjDoublePtr(new ObjDouble(bfield))));
+
+  SimpleGTrackFitter gtf(pcylcyl, order, 0, 200.);
+
+  // test the fitter
+  // We skip this because we cannot handle cluster indices without
+  // a chunk and an event.
+  //cout << "Fitting the Gtrack... " << endl;
+  //GTrack gtr1 = gtr0;
+  //gtf.fit(gtr1);
+  //cout << "Refit GTrack: " << endl << gtr1 << endl;
+  //assert( gtr0.get_states().size() == nstate );
+
+  //********************************************************************
+
+  cout << ok_prefix
+       << "------------- All tests passed. -------------" << endl;
+  return 0;
+
+  //********************************************************************
+
+}
+
CVSspam 0.2.8