61 : rParam_(
cfg.getParameter<double>(
"rParam")),
62 minRadius_(
cfg.getParameter<double>(
"minRadius")),
63 nearThreshold_(
cfg.getParameter<double>(
"nearThreshold")),
64 farThreshold_(
cfg.getParameter<double>(
"farThreshold")),
65 discriminatorCut_(
cfg.getParameter<double>(
"discriminatorCut")),
66 maxPseudoROIs_(
cfg.getParameter<unsigned
int>(
"maxPseudoROIs")),
72 unsigned nThreads =
cfg.getUntrackedParameter<
unsigned>(
"nThreads");
79 produces<vector<reco::Vertex> >(
"nearRegionsOfInterest");
80 produces<vector<reco::Vertex> >(
"farRegionsOfInterest");
97 vector<DisplacedVertexCluster> pseudoROIs;
99 vector<Distance> distances;
104 if (
minRadius_ < 0.0 || minTrackClusterRadius < 0.0 || (
x -
bs).rho() > minTrackClusterRadius)
109 <<
" possible track clusters.";
113 if (pseudoROIs.size() > 1) {
114 distances.reserve(pseudoROIs.size() *
std::max(1.0, pseudoROIs.size() * 0.05));
120 for (;
j != pseudoROIs.end();
j++) {
121 distances.emplace_back(
i,
j);
126 distances.pop_back();
131 auto itBegin = distances.begin();
132 auto itLast = distances.end();
135 while (itBegin != itLast) {
141 double distanceBest = dBest->distance2();
143 for (
auto i = itBegin;
i != itLast;
i++) {
144 if (distanceBest >
i->distance2()) {
146 distanceBest =
i->distance2();
153 dBest->entities().first->merge(*dBest->entities().second);
154 dBest->entities().second->setInvalid();
156 const auto distancePred = [](
const Distance &
a) {
157 return (!
a.entities().first->valid() || !
a.entities().second->valid());
159 itLast = std::remove_if(itBegin, itLast, distancePred);
163 auto remove_invalid = std::remove_if(pseudoROIs.begin(), pseudoROIs.end(), pseudoROIPred);
169 const auto &
x(roi.centerOfMass());
177 auto remove_pred = std::remove_if(pseudoROIs.begin(), remove_invalid, roiPred);
179 auto nearRegionsOfInterest = make_unique<vector<reco::Vertex> >();
180 auto farRegionsOfInterest = make_unique<vector<reco::Vertex> >();
182 constexpr std::array<double, 6> errorA{{1.0, 0.0, 1.0, 0.0, 0.0, 1.0}};
185 for (
auto it = pseudoROIs.begin();
it != remove_pred; ++
it) {
186 auto const &roi = *
it;
187 const auto &
x(roi.centerOfMass());
194 event.put(
std::move(nearRegionsOfInterest),
"nearRegionsOfInterest");
195 event.put(
std::move(farRegionsOfInterest),
"farRegionsOfInterest");
201 desc.add<
double>(
"rParam", 1.0);
202 desc.add<
double>(
"minRadius", -1.0);
203 desc.add<
double>(
"nearThreshold", 9999.0);
204 desc.add<
double>(
"farThreshold", -1.0);
205 desc.add<
double>(
"discriminatorCut", -1.0);
206 desc.add<vector<string> >(
"input_names", {
"phi_0",
"phi_1"});
207 desc.add<vector<string> >(
"output_names", {
"model_5/activation_10/Softmax"});
208 desc.add<
unsigned int>(
"maxPseudoROIs", 10000);
209 desc.addUntracked<
unsigned>(
"nThreads", 1);
213 "RecoTracker/DisplacedRegionalTracking/data/FullData_Phi-64-128-256_16-32-64_F-128-64-32_Model.pb"));
217 descriptions.
add(
"displacedRegionProducer",
desc);
234 tensorflow::Tensor vertexTensor(tensorflow::DT_FLOAT, tensorflow::TensorShape({1,
maxNVertices, nVertexFeatures}));
235 auto vertex_map = vertexTensor.tensor<
float, nDimVertices>();
236 tensorflow::Tensor annulusTensor(tensorflow::DT_FLOAT,
237 tensorflow::TensorShape({1, maxNAnnulusTracks, nAnnulusTrackFeatures}));
238 auto annulus_map = annulusTensor.tensor<
float, nDimAnnulusTracks>();
242 for (
unsigned j = 0;
j < nVertexFeatures;
j++)
243 vertex_map(0, map_i,
j) = 0.0;
247 const auto &track1 = *trackCluster.daughter(1)->bestTrack();
249 vertex_map(0, map_i, 0) = trackCluster.
vx() -
bs.x0();
250 vertex_map(0, map_i, 1) = trackCluster.vy() -
bs.y0();
251 vertex_map(0, map_i, 2) = trackCluster.vz() -
bs.z0();
253 vertex_map(0, map_i, 3) = trackCluster.vertexCovariance()(0, 0);
254 vertex_map(0, map_i, 4) = trackCluster.vertexCovariance()(0, 1);
255 vertex_map(0, map_i, 5) = trackCluster.vertexCovariance()(0, 2);
256 vertex_map(0, map_i, 6) = trackCluster.vertexCovariance()(1, 1);
257 vertex_map(0, map_i, 7) = trackCluster.vertexCovariance()(1, 2);
258 vertex_map(0, map_i, 8) = trackCluster.vertexCovariance()(2, 2);
260 vertex_map(0, map_i, 9) = track0.charge() * track0.pt();
261 vertex_map(0, map_i, 10) = track0.eta();
262 vertex_map(0, map_i, 11) = track0.phi();
263 vertex_map(0, map_i, 12) = track0.dxy(
bs);
264 vertex_map(0, map_i, 13) = track0.dz(
bs.position());
265 vertex_map(0, map_i, 14) = track0.normalizedChi2();
268 vertex_map(0, map_i, 16) = track1.charge() * track1.pt();
269 vertex_map(0, map_i, 17) = track1.eta();
270 vertex_map(0, map_i, 18) = track1.phi();
271 vertex_map(0, map_i, 19) = track1.dxy(
bs);
272 vertex_map(0, map_i, 20) = track1.dz(
bs.position());
273 vertex_map(0, map_i, 21) = track1.normalizedChi2();
278 for (
int i = 0;
i < maxNAnnulusTracks;
i++)
279 for (
unsigned j = 0;
j < nAnnulusTrackFeatures;
j++)
280 annulus_map(0,
i,
j) = 0.0;
283 input_tensors.resize(2);
286 vector<tensorflow::Tensor>
outputs;
289 return (
outputs.at(0).flat<
float>()(1));
const Candidate * daughter(size_type) const override
return daughter at a given position, i = 0, ... numberOfDaughters() - 1 (read only mode) ...
std::vector< NamedTensor > NamedTensorList
void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override
const vector< string > input_names_
double vx() const
x coordinate of the reference point on track
GraphDef * loadGraphDef(const std::string &pbFile)
std::vector< DisplacedVertexCluster >::iterator DisplacedVertexClusterItr
math::Error< dimension >::type Error
covariance error matrix (3x3)
const double nearThreshold_
const Point & vertex() const override
vertex position (overwritten by PF...)
const double discriminatorCut_
std::pair< std::string, Tensor > NamedTensor
const reco::VertexCompositeCandidate * constituent(const unsigned i) const
tensorflow::Session * session_
DisplacedVertexCluster::DistanceItr DistanceItr
std::vector< Distance >::iterator DistanceItr
~DisplacedRegionSeedingVertexProducer() override
const double farThreshold_
DisplacedVertexCluster::Distance Distance
void run(Session *session, const NamedTensorList &inputs, const std::vector< std::string > &outputNames, std::vector< Tensor > *outputs, const thread::ThreadPoolOptions &threadPoolOptions)
bool closeSession(Session *&session)
math::XYZPoint Point
point in the space
#define DEFINE_FWK_MODULE(type)
Session * createSession()
static void fillDescriptions(edm::ConfigurationDescriptions &)
const edm::EDGetTokenT< edm::View< reco::VertexCompositeCandidate > > trackClustersToken_
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
double getDiscriminatorValue(const DisplacedVertexCluster &, const reco::BeamSpot &) const
XYZVectorD XYZVector
spatial vector with cartesian internal representation
void add(std::string const &label, ParameterSetDescription const &psetDescription)
unsigned nConstituents() const
const edm::EDGetTokenT< reco::BeamSpot > beamSpotToken_
const vector< string > output_names_
DisplacedRegionSeedingVertexProducer(const edm::ParameterSet &)
virtual const Track * bestTrack() const
const unsigned int maxPseudoROIs_
Log< level::Warning, false > LogWarning