12 #ifdef Use_GraphicsHarvester
13 #include "RecoVertex/VertexSimpleVis/interface/PrimitivesHarvester.h"
14 #include "Utilities/UI/interface/SimpleConfigurable.h"
43 inline unsigned int sum(
unsigned int nr) {
52 return (nr * (nr + 1)) / 2;
55 #ifdef Use_GraphicsHarvester
57 void graphicsDebug(
const std::vector<PointAndDistance>&
input) {
58 bool sve = SimpleConfigurable<bool>(
false,
"CrossingPointStudy:Harvest").
value();
59 std::string fname = SimpleConfigurable<string>(
"crossingpoints.txt",
"CrossingPointStudy:FileName").
value();
61 for (std::vector<PointAndDistance>::const_iterator
i = input.begin();
i != input.end(); ++
i) {
62 std::map<std::string, MultiType> attrs;
63 attrs[
"name"] =
"GlobalPoint";
64 attrs[
"color"] =
"yellow";
66 attrs[
"comment"] =
"Input for CrossingPtBasedLinearizationPointFinder";
67 PrimitivesHarvester(fname).save(
i->first, attrs);
69 std::map<std::string, MultiType> attrs;
70 attrs[
"name"] =
"The Mode(*theAlgo)";
71 attrs[
"color"] =
"green";
72 attrs[
"comment"] =
"Output from CrossingPtBasedLinearizationPointFinder";
73 PrimitivesHarvester(fname).save(
ret, attrs);
75 attrs[
"name"] =
"The Mode(SubsetHSM)";
76 attrs[
"color"] =
"red";
77 PrimitivesHarvester(fname).save(subsethsm, attrs);
79 attrs[
"name"] =
"The Mode(HSM)";
80 attrs[
"color"] =
"blue";
81 PrimitivesHarvester(fname).save(hsm, attrs);
83 attrs[
"name"] =
"The Mode(LMS)";
84 attrs[
"color"] =
"gold";
85 PrimitivesHarvester(fname).save(lms, attrs);
92 const signed int n_pairs)
93 : useMatrix(
false), theNPairs(n_pairs), theMatrix(nullptr), theAlgo(algo.
clone()) {}
97 const signed int n_pairs)
98 : useMatrix(m->hasCrossingPoints()), theNPairs(n_pairs), theMatrix(m), theAlgo(algo.
clone()) {}
102 : useMatrix(o.useMatrix),
103 theNPairs(o.theNPairs),
104 theMatrix(o.theMatrix ),
105 theAlgo(o.theAlgo->
clone()) {}
110 const std::vector<reco::TransientTrack>&
tracks)
const {
111 unsigned int n_tracks = (2 * (
unsigned int)(
theNPairs)) < tracks.size() ? 2 *
theNPairs : tracks.size();
113 std::vector<reco::TransientTrack> newtracks =
tracks;
114 partial_sort(newtracks.begin(), newtracks.begin() + n_tracks, newtracks.end(),
CompareTwoTracks());
115 newtracks.erase(newtracks.begin() + n_tracks, newtracks.end());
132 const std::vector<reco::TransientTrack>&
tracks)
const {
133 std::vector<PointAndDistance> vgp;
137 std::vector<reco::TransientTrack>::const_iterator
end = tracks.end();
138 std::vector<reco::TransientTrack>::const_iterator endm1 = (end - 1);
139 for (std::vector<reco::TransientTrack>::const_iterator
x = tracks.begin();
x != endm1; ++
x) {
140 for (std::vector<reco::TransientTrack>::const_iterator
y =
x + 1;
y !=
end; ++
y) {
141 status = ttmd.
calculate((*x).impactPointState(), (*y).impactPointState());
143 std::pair<GlobalPoint, GlobalPoint>
pts = ttmd.
points();
144 std::pair<GlobalPoint, float>
v((pts.second + pts.first) / 2., (pts.second - pts.first).mag());
156 const std::vector<reco::TransientTrack>&
tracks)
const {
157 std::vector<PointAndDistance> vgp;
158 vgp.reserve((
int)(tracks.size() * (tracks.size() - 1) / 2. - 1));
159 std::vector<reco::TransientTrack>::const_iterator
end = tracks.end();
160 std::vector<reco::TransientTrack>::const_iterator endm1 = (end - 1);
161 for (std::vector<reco::TransientTrack>::const_iterator
x = tracks.begin();
x != endm1; ++
x) {
162 for (std::vector<reco::TransientTrack>::const_iterator
y =
x + 1;
y !=
end; ++
y) {
174 const std::vector<FreeTrajectoryState>&
tracks)
const {
183 #ifdef Use_GraphicsHarvester
185 graphicsDebug(input);
192 const std::vector<reco::TransientTrack>&
tracks)
const {
193 if (tracks.size() < 2)
194 throw LinPtException(
"CrossingPtBasedLinPtFinder: too few tracks given.");
195 std::vector<PointAndDistance> vgp;
204 if (sum(tracks.size() - 1) < ((
unsigned int)(
theNPairs))) {
214 std::vector<reco::TransientTrack> goodtracks =
getBestTracks(tracks);
217 if (goodtracks.size() < 2)
218 throw LinPtException(
"CrossingPtBasedLinPtFinder: less than two tracks given");
220 unsigned int t_first = 0;
221 unsigned int t_interval = goodtracks.size() / 2;
222 unsigned int lim = goodtracks.size() - 1;
235 while (vgp.size() < ((
unsigned int)(
theNPairs))) {
246 std::pair<GlobalPoint, GlobalPoint>
pts = ttmd.
points();
247 PointAndDistance
v((pts.second + pts.first) / 2., (pts.second - pts.first).mag());
251 if ((t_first + t_interval) < lim) {
256 if (t_interval == 0) {
264 if (t_interval == goodtracks.size()) {
269 t_interval = goodtracks.size() / 2 - 1;
GlobalPoint useAllTracks(const std::vector< reco::TransientTrack > &) const
tuple ret
prodAgent to be discontinued
const RecTracksDistanceMatrix * theMatrix
GlobalPoint find(const std::vector< std::pair< GlobalPoint, float > > &) const
std::pair< GlobalPoint, float > PointAndDistance
virtual double distance(const reco::TransientTrack, const reco::TransientTrack) const =0
MatrixMeschach operator+(const MatrixMeschach &mat1, const MatrixMeschach &mat2)
MatrixMeschach operator-(const MatrixMeschach &mat1, const MatrixMeschach &mat2)
Global3DPoint GlobalPoint
std::vector< reco::TransientTrack > getBestTracks(const std::vector< reco::TransientTrack > &) const
auto const & tracks
cannot be loose
static std::string const input
bool calculate(const TrajectoryStateOnSurface &sta, const TrajectoryStateOnSurface &stb) override
static const double pts[33]
CrossingPtBasedLinearizationPointFinder(const ModeFinder3d &algo, const signed int n_pairs=5)
~CrossingPtBasedLinearizationPointFinder() override
std::pair< GlobalPoint, GlobalPoint > points() const override
T1 operator/(const Phi< T1, Range > &a, const Phi< T1, Range > &b)
Division.
virtual GlobalPoint crossingPoint(const reco::TransientTrack, const reco::TransientTrack) const =0
TEveGeoShape * clone(const TEveElement *element, TEveElement *parent)
virtual GlobalPoint getLinearizationPoint(const std::vector< reco::TransientTrack > &) const =0
GlobalPoint getLinearizationPoint(const std::vector< reco::TransientTrack > &) const override
GlobalPoint getLinearizationPoint(const std::vector< reco::TransientTrack > &) const override
TrajectoryStateOnSurface impactPointState() const
MatrixMeschach operator*(const MatrixMeschach &mat1, const MatrixMeschach &mat2)
GlobalPoint useFullMatrix(const std::vector< reco::TransientTrack > &) const