#include #include #include #include #include #include #include #include "tutGenerateEvents.hxx" namespace tut { struct baseTHit { baseTHit() { // Run before each test. SimG4::GenerateEvents(); } ~baseTHit() { // Run after each test. } }; // Declare the test typedef test_group::object testTHit; test_group groupTHit("COMET::IHit"); // Check that the SimG4 events with SimDetectorResponse run exist. template<> template<> void testTHit::test<1> () { ensure("COMET MC Events exist.", SimG4::Events.size()>0); } // Check that all of the hits have reasonable times and charges template<> template<> void testTHit::test<2>() { for (SimG4::EventVector::iterator e = SimG4::Events.begin(); e != SimG4::Events.end(); ++e) { COMET::IHandle hits = (*e)->Get("hits"); // Changed const_iterator to iterator for now to let this compile // for (COMET::IDataVector::const_iterator s = hits->begin(); for (COMET::IDataVector::iterator s = hits->begin(); s != hits->end(); ++s) { COMET::IHandle select = (*s)->Get("."); std::string name = select->GetName(); for (COMET::IHitSelection::iterator h = select->begin(); h != select->end(); ++h) { double charge = (*h)->GetCharge(); double time = (*h)->GetTime(); std::string comment = "Non-zero charge for " + name; ensure_greaterthan(comment.c_str(),std::abs(charge),1E-6); comment = "Valid time for " + name; ensure_lessthan(comment.c_str(),time,1*unit::second); ensure_greaterthan(comment.c_str(),time,-1*unit::second); } } } } };