diff --git a/Tests/UnitTests/Core/Seeding/SeedfinderTest.cpp b/Tests/UnitTests/Core/Seeding/SeedfinderTest.cpp index 22964c143f89c93a3f3f5860a271b377862f35eb..1db1a29f026fa993ab86e438a3a891d335719ceb 100644 --- a/Tests/UnitTests/Core/Seeding/SeedfinderTest.cpp +++ b/Tests/UnitTests/Core/Seeding/SeedfinderTest.cpp @@ -66,9 +66,51 @@ std::vector<const SpacePoint*> readFile(std::string filename) { return readSP; } -int main() { - std::vector<const SpacePoint*> spVec = readFile("sp.txt"); - std::cout << "size of read SP: " << spVec.size() << std::endl; +int main(int argc, char** argv) { + std::string file{"sp.txt"}; + bool help(false); + bool quiet(false); + + int opt; + while ((opt = getopt(argc, argv, "hf:q")) != -1) { + switch (opt) { + case 'f': + file = optarg; + break; + case 'q': + quiet = true; + break; + case 'h': + help = true; + [[fallthrough]]; + default: /* '?' */ + std::cerr << "Usage: " << argv[0] << " [-hq] [-f FILENAME]\n"; + if (help) { + std::cout << " -h : this help" << std::endl; + std::cout + << " -f FILE : read spacepoints from FILE. Default is \"" + << file << "\"" << std::endl; + std::cout << " -q : don't print out all found seeds" + << std::endl; + } + + exit(EXIT_FAILURE); + } + } + + std::ifstream f(file); + if (!f.good()) { + std::cerr << "input file \"" << file << "\" does not exist\n"; + exit(EXIT_FAILURE); + } + + auto start_read = std::chrono::system_clock::now(); + std::vector<const SpacePoint*> spVec = readFile(file); + auto end_read = std::chrono::system_clock::now(); + std::chrono::duration<double> elapsed_read = end_read - start_read; + + std::cout << "read " << spVec.size() << " SP from file " << file << " in " + << elapsed_read.count() << "s" << std::endl; Acts::SeedfinderConfig<SpacePoint> config; // silicon detector max @@ -138,19 +180,21 @@ int main() { numSeeds += outVec.size(); } std::cout << "Number of seeds generated: " << numSeeds << std::endl; - for (auto& regionVec : seedVector) { - for (size_t i = 0; i < regionVec.size(); i++) { - const Acts::Seed<SpacePoint>* seed = ®ionVec[i]; - const SpacePoint* sp = seed->sp()[0]; - std::cout << " (" << sp->x() << ", " << sp->y() << ", " << sp->z() - << ") "; - sp = seed->sp()[1]; - std::cout << sp->surface << " (" << sp->x() << ", " << sp->y() << ", " - << sp->z() << ") "; - sp = seed->sp()[2]; - std::cout << sp->surface << " (" << sp->x() << ", " << sp->y() << ", " - << sp->z() << ") "; - std::cout << std::endl; + if (!quiet) { + for (auto& regionVec : seedVector) { + for (size_t i = 0; i < regionVec.size(); i++) { + const Acts::Seed<SpacePoint>* seed = ®ionVec[i]; + const SpacePoint* sp = seed->sp()[0]; + std::cout << " (" << sp->x() << ", " << sp->y() << ", " << sp->z() + << ") "; + sp = seed->sp()[1]; + std::cout << sp->surface << " (" << sp->x() << ", " << sp->y() << ", " + << sp->z() << ") "; + sp = seed->sp()[2]; + std::cout << sp->surface << " (" << sp->x() << ", " << sp->y() << ", " + << sp->z() << ") "; + std::cout << std::endl; + } } } return 0;