13#include "GaudiKernel/SystemOfUnits.h"
24using Gaudi::Units::mm;
25using Gaudi::Units::MeV;
26using Gaudi::Units::GeV;
49 v.setCovariancePosition (cov);
56 std::cout <<
a.x() <<
" " <<
a.y() <<
" " <<
a.z();
60void assertVec3D (
const char* which,
62 const std::vector<double>& v,
65 if (
v.size() - offs < 3) std::abort();
70 std::cerr <<
"VertexSeedFinderTestAlg::assertVec3D mismatch " <<
which
77 <<
v[offs+2] <<
"]\n";
83void dumpVector (
const std::vector<float>& v)
87 std::cerr <<
f <<
", ";
91void failVector (
const char* which,
92 const std::vector<float>&
a,
93 const std::vector<float>& b)
95 std::cerr <<
"VertexSeedFinderTestAlg::assertVector mismatch " <<
which
101void assertVector (
const char* which,
102 const std::vector<float>&
a,
103 const std::vector<float>& b)
105 if (
a.size() !=
b.size()) {
106 failVector (which,
a, b);
108 for (
size_t i=0;
i <
a.size();
i++) {
110 failVector (which,
a, b);
129 return StatusCode::SUCCESS;
139 const EventContext& ctx = Gaudi::Hive::currentContext();
158 auto p1a = std::make_unique<Trk::Perigee>(pos1a, mom1a, 1, pos0, cov5());
159 auto p1b = std::make_unique<Trk::Perigee>(pos1b, mom1b, -1, pos0, cov5());
160 auto p1c = std::make_unique<Trk::Perigee>(pos1c, mom1c, -1, pos0, cov5());
162 std::vector<const Trk::TrackParameters*> v1a { p1a.get(), p1b.get(), p1c.get() };
163 std::vector<const Trk::TrackParameters*> v1b { p1c.get(), p1a.get(), p1b.get() };
170 std::unique_ptr<Trk::IMode3dInfo> info;
171 p =
m_finder->findSeed (vx, vy, info, v1b);
175 std::vector<float>
phi;
176 std::vector<float>
r;
177 std::vector<float>
z;
178 std::vector<float> w;
179 size_t sz = info->Modes1d (
phi,
r,
z, w);
180 assert (
sz ==
phi.size());
181 assert (
sz ==
r.size());
182 assert (
sz ==
z.size());
183 assert (
sz == w.size());
191 std::vector<const Trk::TrackParameters*> p;
192 size_t sz = info->perigeesAtSeed (p, v1a);
193 assert (
sz == p.size());
194 std::vector<int> ndx;
196 auto it = std::find (v1a.begin(), v1a.end(), pp);
197 assert (it != v1a.end());
198 ndx.push_back (it - v1a.begin());
206 info->getCorrelationDistance (cXY, cZ);
220 p =
m_finder->findSeed (vx, vy, v1b, &vert1);
224 std::vector<std::unique_ptr<Trk::Perigee> > perigees;
225 std::vector<const Trk::TrackParameters*>
pvec;
234 for (
unsigned int i=0; i <
m_npart3; i++) {
235 double x = xdist(rng);
236 double y = ydist(rng);
246 double pt = ptdist(rng);
247 double phi = phidist(rng);
248 double eta = etadist(rng);
250 double charge = etadist(rng) > 0 ? 1 : -1;
251 perigees.emplace_back (std::make_unique<Trk::Perigee> (pos, mom,
charge, pos0,
253 pvec.push_back (perigees.back().get());
267 std::vector<Amg::Vector3D> seeds =
m_finder->findMultiSeeds (
pvec);
269 std::cerr <<
"VertexSeedFinderTestAlg size mismatch 3b "
270 << seeds.size() <<
" / " <<
m_expected3.size()/3 <<
"\n";
274 for (
const auto& seed : seeds) {
281 return StatusCode::SUCCESS;
291 auto *evt1 =
new HepMC::GenEvent();
292 auto *evt2 =
new HepMC::GenEvent();
293 auto *evt3 =
new HepMC::GenEvent();
305 for (
unsigned int i = 0; i < 1000; i++) {
306 double pt = ptdist(rng);
307 double phi = phidist(rng);
308 double eta = etadist(rng);
309 double e = pt*sinh(
eta);
310 double charge = etadist(rng) > 0 ? 1 : -1;
311 HepMC::FourVector mom {pt*cos(
phi), pt*sin(
phi), e, e };
314 double vrand = etadist(rng);
318 else if (vrand < 3) {
326 auto evtcoll = std::make_unique<McEventCollection>();
330 evtcoll->push_back (evt1);
331 evtcoll->push_back (evt2);
332 evtcoll->push_back (evt3);
336 return StatusCode::SUCCESS;
Scalar eta() const
pseudorapidity method
#define ATH_CHECK
Evaluate an expression and check for errors.
double charge(const T &p)
#define AmgSymMatrix(dim)
Handle class for recording to StoreGate.
Algorithm for doing unit tests of the seed finder tools. Basic test only, not terribly comprehensive.
Header file for AthHistogramAlgorithm.
Gaudi::Property< std::vector< float > > m_expected1RModes
Gaudi::Property< std::vector< double > > m_expected1CorrDist
ToolHandle< Trk::IVertexSeedFinder > m_finder
Gaudi::Property< std::vector< double > > m_priVert
virtual StatusCode initialize() override
Standard Gaudi initialize method.
Gaudi::Property< std::vector< float > > m_expected1PhiModes
Gaudi::Property< unsigned int > m_npart3
Gaudi::Property< std::vector< double > > m_expected2
Gaudi::Property< std::vector< float > > m_expected1Weights
StatusCode makeMcEventCollection(const EventContext &ctx) const
Make a test McEventCollection.
Gaudi::Property< std::vector< int > > m_expected1Indices
Gaudi::Property< std::vector< float > > m_expected1ZModes
SG::WriteHandleKey< McEventCollection > m_mcEventCollectionKey
Gaudi::Property< std::vector< double > > m_expected1
virtual StatusCode execute() override
Execute the algorithm.
Gaudi::Property< std::vector< double > > m_expected3
Eigen::Matrix< double, 3, 1 > Vector3D
bool isEqual(double x1, double x2, double thresh=1e-6)
void set_signal_process_vertex(GenEvent *e, T v)
GenVertexPtr newGenVertexPtr(const HepMC::FourVector &pos=HepMC::FourVector(0.0, 0.0, 0.0, 0.0), const int i=0)
GenParticlePtr newGenParticlePtr(const HepMC::FourVector &mom=HepMC::FourVector(0.0, 0.0, 0.0, 0.0), int pid=0, int status=0)
void fillBarcodesAttribute(GenEvent *)
GenVertex * signal_process_vertex(const GenEvent *e)
Ensure that the ATLAS eigen extensions are properly loaded.
@ z
global position (cartesian)
ParametersBase< TrackParametersDim, Charged > TrackParameters
ICaloAffectedTool is abstract interface for tools checking if 4 mom is in calo affected region.
Vertex_v1 Vertex
Define the latest version of the vertex class.
Very simple random numbers for regression testing.
Generator compatible with the C++11 STL UniformRandomNumberGenerator.