Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:54:18

0001 #include "DataFormats/TrackReco/interface/Track.h"
0002 #include "DataFormats/ParticleFlowReco/interface/PFDisplacedVertexSeed.h"
0003 
0004 #include "catch.hpp"
0005 
0006 static constexpr auto s_tag = "[PFDisplacedVertexSeed]";
0007 TEST_CASE("Check adding elements", s_tag) {
0008   reco::PFDisplacedVertexSeed seed;
0009 
0010   REQUIRE(seed.elements().empty());
0011 
0012   SECTION("updateSeedPoint") {
0013     //empty tracks are fine
0014     std::vector<reco::Track> tracks(5);
0015 
0016     seed.updateSeedPoint(GlobalPoint(0.01, 0.01, 0.01),
0017                          reco::TrackBaseRef(reco::TrackRef(&tracks, 0)),
0018                          reco::TrackBaseRef(reco::TrackRef(&tracks, 1)));
0019     REQUIRE(seed.elements().size() == 2);
0020     REQUIRE(seed.nTracks() == 2);
0021 
0022     seed.updateSeedPoint(GlobalPoint(0.01, 0.01, 0.01),
0023                          reco::TrackBaseRef(reco::TrackRef(&tracks, 0)),
0024                          reco::TrackBaseRef(reco::TrackRef(&tracks, 1)));
0025     REQUIRE(seed.elements().size() == 2);
0026     REQUIRE(seed.nTracks() == 2);
0027 
0028     seed.updateSeedPoint(GlobalPoint(0.01, 0.01, 0.01),
0029                          reco::TrackBaseRef(reco::TrackRef(&tracks, 0)),
0030                          reco::TrackBaseRef(reco::TrackRef(&tracks, 2)));
0031     REQUIRE(seed.elements().size() == 3);
0032     REQUIRE(seed.nTracks() == 3);
0033 
0034     seed.updateSeedPoint(GlobalPoint(0.01, 0.01, 0.01),
0035                          reco::TrackBaseRef(reco::TrackRef(&tracks, 3)),
0036                          reco::TrackBaseRef(reco::TrackRef(&tracks, 4)));
0037     REQUIRE(seed.elements().size() == 5);
0038     REQUIRE(seed.nTracks() == 5);
0039   }
0040 
0041   SECTION("addElement") {
0042     //empty tracks are fine
0043     std::vector<reco::Track> tracks(3);
0044 
0045     seed.updateSeedPoint(GlobalPoint(0.01, 0.01, 0.01),
0046                          reco::TrackBaseRef(reco::TrackRef(&tracks, 0)),
0047                          reco::TrackBaseRef(reco::TrackRef(&tracks, 1)));
0048     REQUIRE(seed.elements().size() == 2);
0049     REQUIRE(seed.nTracks() == 2);
0050 
0051     seed.addElement(reco::TrackBaseRef(reco::TrackRef(&tracks, 0)));
0052     REQUIRE(seed.elements().size() == 2);
0053     REQUIRE(seed.nTracks() == 2);
0054 
0055     seed.addElement(reco::TrackBaseRef(reco::TrackRef(&tracks, 2)));
0056     REQUIRE(seed.elements().size() == 3);
0057     REQUIRE(seed.nTracks() == 3);
0058   }
0059   SECTION("mergeWith") {
0060     std::vector<reco::Track> tracks(5);
0061 
0062     seed.updateSeedPoint(GlobalPoint(0.01, 0.01, 0.01),
0063                          reco::TrackBaseRef(reco::TrackRef(&tracks, 0)),
0064                          reco::TrackBaseRef(reco::TrackRef(&tracks, 1)));
0065 
0066     SECTION("completely overlapping seeds") {
0067       reco::PFDisplacedVertexSeed otherSeed;
0068       otherSeed.updateSeedPoint(GlobalPoint(0.01, 0.01, 0.01),
0069                                 reco::TrackBaseRef(reco::TrackRef(&tracks, 0)),
0070                                 reco::TrackBaseRef(reco::TrackRef(&tracks, 1)));
0071 
0072       seed.mergeWith(otherSeed);
0073       REQUIRE(seed.elements().size() == 2);
0074     }
0075 
0076     SECTION("partially overlapping seeds") {
0077       reco::PFDisplacedVertexSeed otherSeed;
0078       otherSeed.updateSeedPoint(GlobalPoint(0.01, 0.01, 0.01),
0079                                 reco::TrackBaseRef(reco::TrackRef(&tracks, 0)),
0080                                 reco::TrackBaseRef(reco::TrackRef(&tracks, 2)));
0081 
0082       seed.mergeWith(otherSeed);
0083       REQUIRE(seed.elements().size() == 3);
0084     }
0085 
0086     SECTION("non overlapping seeds") {
0087       REQUIRE(seed.elements().size() == 2);
0088       reco::PFDisplacedVertexSeed otherSeed;
0089       otherSeed.updateSeedPoint(GlobalPoint(0.01, 0.01, 0.01),
0090                                 reco::TrackBaseRef(reco::TrackRef(&tracks, 3)),
0091                                 reco::TrackBaseRef(reco::TrackRef(&tracks, 2)));
0092       REQUIRE(otherSeed.elements().size() == 2);
0093 
0094       seed.mergeWith(otherSeed);
0095       REQUIRE(seed.elements().size() == 4);
0096     }
0097   }
0098 }