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")),
71 unsigned nThreads =
cfg.getUntrackedParameter<
unsigned>(
"nThreads");
78 produces<vector<reco::Vertex> >(
"nearRegionsOfInterest");
79 produces<vector<reco::Vertex> >(
"farRegionsOfInterest");
96 list<DisplacedVertexCluster> pseudoROIs;
97 list<Distance> distances;
102 if (
minRadius_ < 0.0 || minTrackClusterRadius < 0.0 || (
x -
bs).rho() > minTrackClusterRadius)
105 if (pseudoROIs.size() > 1) {
111 for (;
j != pseudoROIs.end();
j++) {
112 distances.emplace_back(
i,
j);
117 distances.pop_back();
123 while (!distances.empty()) {
125 distances.sort(
comp);
130 dBest->entities().first->merge(*dBest->entities().second);
131 dBest->entities().second->setInvalid();
133 const auto distancePred = [](
const Distance &
a) {
134 return (!
a.entities().first->valid() || !
a.entities().second->valid());
137 distances.remove_if(distancePred);
138 pseudoROIs.remove_if(pseudoROIPred);
145 const auto &
x(roi.centerOfMass());
153 pseudoROIs.remove_if(roiPred);
155 auto nearRegionsOfInterest = make_unique<vector<reco::Vertex> >();
156 auto farRegionsOfInterest = make_unique<vector<reco::Vertex> >();
158 constexpr std::array<double, 6> errorA{{1.0, 0.0, 1.0, 0.0, 0.0, 1.0}};
161 for (
const auto &roi : pseudoROIs) {
162 const auto &
x(roi.centerOfMass());
169 event.put(
std::move(nearRegionsOfInterest),
"nearRegionsOfInterest");
170 event.put(
std::move(farRegionsOfInterest),
"farRegionsOfInterest");
176 desc.add<
double>(
"rParam", 1.0);
177 desc.add<
double>(
"minRadius", -1.0);
178 desc.add<
double>(
"nearThreshold", 9999.0);
179 desc.add<
double>(
"farThreshold", -1.0);
180 desc.add<
double>(
"discriminatorCut", -1.0);
181 desc.add<vector<string> >(
"input_names", {
"phi_0",
"phi_1"});
182 desc.add<vector<string> >(
"output_names", {
"model_5/activation_10/Softmax"});
183 desc.addUntracked<
unsigned>(
"nThreads", 1);
187 "RecoTracker/DisplacedRegionalTracking/data/FullData_Phi-64-128-256_16-32-64_F-128-64-32_Model.pb"));
191 descriptions.
add(
"displacedRegionProducer",
desc);
208 tensorflow::Tensor vertexTensor(tensorflow::DT_FLOAT, tensorflow::TensorShape({1,
maxNVertices, nVertexFeatures}));
209 auto vertex_map = vertexTensor.tensor<
float, nDimVertices>();
210 tensorflow::Tensor annulusTensor(tensorflow::DT_FLOAT,
211 tensorflow::TensorShape({1, maxNAnnulusTracks, nAnnulusTrackFeatures}));
212 auto annulus_map = annulusTensor.tensor<
float, nDimAnnulusTracks>();
216 for (
unsigned j = 0;
j < nVertexFeatures;
j++)
217 vertex_map(0, map_i,
j) = 0.0;
221 const auto &track1 = *trackCluster.daughter(1)->bestTrack();
223 vertex_map(0, map_i, 0) = trackCluster.
vx() -
bs.x0();
224 vertex_map(0, map_i, 1) = trackCluster.vy() -
bs.y0();
225 vertex_map(0, map_i, 2) = trackCluster.vz() -
bs.z0();
227 vertex_map(0, map_i, 3) = trackCluster.vertexCovariance()(0, 0);
228 vertex_map(0, map_i, 4) = trackCluster.vertexCovariance()(0, 1);
229 vertex_map(0, map_i, 5) = trackCluster.vertexCovariance()(0, 2);
230 vertex_map(0, map_i, 6) = trackCluster.vertexCovariance()(1, 1);
231 vertex_map(0, map_i, 7) = trackCluster.vertexCovariance()(1, 2);
232 vertex_map(0, map_i, 8) = trackCluster.vertexCovariance()(2, 2);
234 vertex_map(0, map_i, 9) = track0.charge() * track0.pt();
235 vertex_map(0, map_i, 10) = track0.eta();
236 vertex_map(0, map_i, 11) = track0.phi();
237 vertex_map(0, map_i, 12) = track0.dxy(
bs);
238 vertex_map(0, map_i, 13) = track0.dz(
bs.position());
239 vertex_map(0, map_i, 14) = track0.normalizedChi2();
242 vertex_map(0, map_i, 16) = track1.charge() * track1.pt();
243 vertex_map(0, map_i, 17) = track1.eta();
244 vertex_map(0, map_i, 18) = track1.phi();
245 vertex_map(0, map_i, 19) = track1.dxy(
bs);
246 vertex_map(0, map_i, 20) = track1.dz(
bs.position());
247 vertex_map(0, map_i, 21) = track1.normalizedChi2();
252 for (
int i = 0;
i < maxNAnnulusTracks;
i++)
253 for (
unsigned j = 0;
j < nAnnulusTrackFeatures;
j++)
254 annulus_map(0,
i,
j) = 0.0;
257 input_tensors.resize(2);
260 vector<tensorflow::Tensor>
outputs;
263 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::list< Distance >::iterator DistanceItr
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
~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_
std::list< DisplacedVertexCluster >::iterator DisplacedVertexClusterItr
const vector< string > output_names_
DisplacedRegionSeedingVertexProducer(const edm::ParameterSet &)
virtual const Track * bestTrack() const