18 : tfDnnLabel_(
cfg.getParameter<
std::
string>(
"tfDnnLabel")),
21 bsize_(
cfg.getParameter<
int>(
"batchSize"))
25 static const char*
name() {
return "trackTfClassifierDefault"; }
29 desc.add<
int>(
"batchSize", 16);
34 if (session_ ==
nullptr) {
35 session_ = es.
getData(tfDnnToken_).getSession();
43 int nbatches = size_in / bsize_;
48 tensorflow::Tensor
input1(tensorflow::DT_FLOAT, {bsize_, 29});
49 tensorflow::Tensor
input2(tensorflow::DT_FLOAT, {bsize_, 1});
51 for (
auto nb = 0; nb < nbatches + 1; nb++) {
52 for (
auto nt = 0;
nt < bsize_;
nt++) {
53 int itrack =
nt + bsize_ * nb;
54 if (itrack >= size_in)
56 const auto& trk =
tracks[itrack];
60 input1.matrix<
float>()(
nt, 0) = trk.pt();
61 input1.matrix<
float>()(
nt, 1) = trk.innerMomentum().x();
62 input1.matrix<
float>()(
nt, 2) = trk.innerMomentum().y();
63 input1.matrix<
float>()(
nt, 3) = trk.innerMomentum().z();
64 input1.matrix<
float>()(
nt, 4) = trk.innerMomentum().rho();
65 input1.matrix<
float>()(
nt, 5) = trk.outerMomentum().x();
66 input1.matrix<
float>()(
nt, 6) = trk.outerMomentum().y();
67 input1.matrix<
float>()(
nt, 7) = trk.outerMomentum().z();
68 input1.matrix<
float>()(
nt, 8) = trk.outerMomentum().rho();
69 input1.matrix<
float>()(
nt, 9) = trk.ptError();
70 input1.matrix<
float>()(
nt, 10) = trk.dxy(bestVertex);
71 input1.matrix<
float>()(
nt, 11) = trk.dz(bestVertex);
74 input1.matrix<
float>()(
nt, 14) = trk.dxyError();
75 input1.matrix<
float>()(
nt, 15) = trk.dzError();
76 input1.matrix<
float>()(
nt, 16) = trk.normalizedChi2();
77 input1.matrix<
float>()(
nt, 17) = trk.eta();
78 input1.matrix<
float>()(
nt, 18) = trk.phi();
79 input1.matrix<
float>()(
nt, 19) = trk.etaError();
80 input1.matrix<
float>()(
nt, 20) = trk.phiError();
81 input1.matrix<
float>()(
nt, 21) = trk.hitPattern().numberOfValidPixelHits();
82 input1.matrix<
float>()(
nt, 22) = trk.hitPattern().numberOfValidStripHits();
83 input1.matrix<
float>()(
nt, 23) = trk.ndof();
97 input2.matrix<
float>()(
nt, 0) = trk.originalAlgo();
106 std::vector<tensorflow::Tensor>
outputs;
111 for (
auto nt = 0;
nt < bsize_;
nt++) {
112 int itrack =
nt + bsize_ * nb;
113 if (itrack >= size_in)
115 float out0 = 2.0 *
outputs[0].matrix<
float>()(
nt, 0) - 1.0;
124 const tensorflow::Session* session_;
138 for (
auto score : scores) {
std::vector< NamedTensor > NamedTensorList
std::vector< std::pair< float, bool > > MVAPairCollection
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
std::vector< Track > TrackCollection
collection of Tracks
std::vector< Vertex > VertexCollection
collection of Vertex objects
void operator()(MVA const &mva, reco::TrackCollection const &tracks, reco::BeamSpot const &beamSpot, reco::VertexCollection const &vertices, TrackMVAClassifierBase::MVAPairCollection &mvas)
std::pair< std::string, Tensor > NamedTensor
void run(Session *session, const NamedTensorList &inputs, const std::vector< std::string > &outputNames, std::vector< Tensor > *outputs, const thread::ThreadPoolOptions &threadPoolOptions)
#define DEFINE_FWK_MODULE(type)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Point getBestVertex(reco::Track const &trk, reco::VertexCollection const &vertices, const size_t minNtracks=2)