63 std::array<float, 6> x_dphi;
64 std::array<float, 6> x_dtheta;
65 std::array<float, 4> x_bend_emtf;
66 std::array<float, 1> x_fr_emtf;
67 std::array<float, 1> x_trk_theta;
68 std::array<float, 1> x_me11ring;
69 std::array<float, 4> x_rpcbit;
83 const int invalid_dtheta = 127;
84 const int invalid_dphi = 8191;
87 int dPhi_12, dPhi_13, dPhi_14, dPhi_23, dPhi_24, dPhi_34;
88 int dTh_12, dTh_13, dTh_14, dTh_23, dTh_24, dTh_34;
90 int bend_1, bend_2, bend_3, bend_4;
91 int rpc_1, rpc_2, rpc_3, rpc_4;
92 int St1_ring2 =
data.st1_ring2;
94 int pat1 = -99, pat2 = -99, pat3 = -99, pat4 = -99;
97 int st1 = (
track.Mode() >= 8);
98 int st2 = ((
track.Mode() % 8) >= 4);
99 int st3 = ((
track.Mode() % 4) >= 2);
100 int st4 = ((
track.Mode() % 2) == 1);
104 pat1 =
data.cpattern[0];
106 pat2 =
data.cpattern[1];
108 pat3 =
data.cpattern[2];
110 pat4 =
data.cpattern[3];
116 rpc_1 = (st1 ? (pat1 == 0) : 0);
117 rpc_2 = (st2 ? (pat2 == 0) : 0);
118 rpc_3 = (st3 ? (pat3 == 0) : 0);
119 rpc_4 = (st4 ? (pat4 == 0) : 0);
138 if (
std::abs(bend_1) == 5 && rpc_1 == 1)
140 if (
std::abs(bend_2) == 5 && rpc_2 == 1)
142 if (
std::abs(bend_3) == 5 && rpc_3 == 1)
144 if (
std::abs(bend_4) == 5 && rpc_4 == 1)
148 dPhi_12 = (
data.delta_ph[0] != invalid_dphi) ?
data.delta_ph[0] * (
data.sign_ph[0] ? 1 : -1) : 0;
149 dPhi_13 = (
data.delta_ph[1] != invalid_dphi) ?
data.delta_ph[1] * (
data.sign_ph[1] ? 1 : -1) : 0;
150 dPhi_14 = (
data.delta_ph[2] != invalid_dphi) ?
data.delta_ph[2] * (
data.sign_ph[2] ? 1 : -1) : 0;
151 dPhi_23 = (
data.delta_ph[3] != invalid_dphi) ?
data.delta_ph[3] * (
data.sign_ph[3] ? 1 : -1) : 0;
152 dPhi_24 = (
data.delta_ph[4] != invalid_dphi) ?
data.delta_ph[4] * (
data.sign_ph[4] ? 1 : -1) : 0;
153 dPhi_34 = (
data.delta_ph[5] != invalid_dphi) ?
data.delta_ph[5] * (
data.sign_ph[5] ? 1 : -1) : 0;
156 dTh_12 = (
data.delta_th[0] != invalid_dtheta) ?
data.delta_th[0] * (
data.sign_th[0] ? 1 : -1) : 0;
157 dTh_13 = (
data.delta_th[1] != invalid_dtheta) ?
data.delta_th[1] * (
data.sign_th[1] ? 1 : -1) : 0;
158 dTh_14 = (
data.delta_th[2] != invalid_dtheta) ?
data.delta_th[2] * (
data.sign_th[2] ? 1 : -1) : 0;
159 dTh_23 = (
data.delta_th[3] != invalid_dtheta) ?
data.delta_th[3] * (
data.sign_th[3] ? 1 : -1) : 0;
160 dTh_24 = (
data.delta_th[4] != invalid_dtheta) ?
data.delta_th[4] * (
data.sign_th[4] ? 1 : -1) : 0;
161 dTh_34 = (
data.delta_th[5] != invalid_dtheta) ?
data.delta_th[5] * (
data.sign_th[5] ? 1 : -1) : 0;
212 x_dtheta[0] = dTh_12;
213 x_dtheta[1] = dTh_13;
214 x_dtheta[2] = dTh_14;
215 x_dtheta[3] = dTh_23;
216 x_dtheta[4] = dTh_24;
217 x_dtheta[5] = dTh_34;
220 x_bend_emtf[0] = bend_1;
221 x_bend_emtf[1] = bend_2;
222 x_bend_emtf[2] = bend_3;
223 x_bend_emtf[3] = bend_4;
226 x_trk_theta[0] =
track.Theta_fp();
227 x_me11ring[0] = St1_ring2;
234 feature = {{x_dphi[0], x_dphi[1], x_dphi[2], x_dphi[3], x_dphi[4], x_dphi[5],
235 x_dtheta[0], x_dtheta[1], x_dtheta[2], x_dtheta[3], x_dtheta[4], x_dtheta[5],
236 x_bend_emtf[0], x_bend_emtf[1], x_bend_emtf[2], x_bend_emtf[3], x_fr_emtf[0], x_trk_theta[0],
237 x_me11ring[0], x_rpcbit[0], x_rpcbit[1], x_rpcbit[2], x_rpcbit[3]}};
243 std::vector<tensorflow::Tensor>
outputs;
252 const float reg_pt_scale = 100.0;
253 const float reg_dxy_scale = 1.0;
255 prediction.at(0) =
outputs[0].matrix<
float>()(0, 0);
256 prediction.at(1) =
outputs[0].matrix<
float>()(0, 1);
259 prediction.at(0) /= reg_pt_scale;
260 prediction.at(1) /= reg_dxy_scale;
Session * createSession(SessionOptions &sessionOptions)
virtual ~PtAssignmentEngineDxy()
static PFTauRenderPlugin instance
GraphDef * loadGraphDef(const std::string &pbFile)
std::vector< std::string > outputNamesDxy_
const PtAssignmentEngineAux2017 & aux() const
virtual void calculate_pt_dxy(const EMTFTrack &track, emtf::Feature &feature, emtf::Prediction &prediction) const
constexpr int NUM_PREDICTIONS
tensorflow::Session * sessionDxy_
void configure(int verbose, const std::string pbFileNameDxy)
static std::string const input
virtual void call_tensorflow_dxy(const emtf::Feature &feature, emtf::Prediction &prediction) const
tensorflow::GraphDef * graphDefDxy_
std::array< float, NUM_PREDICTIONS > Prediction
int calcBendFromPattern(const int pattern, const int endcap) const
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)
Abs< T >::type abs(const T &t)
std::string inputNameDxy_
constexpr int NUM_FEATURES
std::string pbFileNameDxy_
char data[epos_bytes_allocation]
virtual void preprocessing_dxy(const EMTFTrack &track, emtf::Feature &feature) const
std::array< float, NUM_FEATURES > Feature
std::string pbFilePathDxy_