CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
L1TrackVertexAssociationProducer::NNTrackWordSelector Struct Reference

Public Member Functions

 NNTrackWordSelector (tensorflow::Session *AssociationSesh, const double AssociationThreshold, const std::vector< double > &AssociationNetworkZ0binning, const std::vector< double > &AssociationNetworkEtaBounds, const std::vector< double > &AssociationNetworkZ0ResBins)
 
bool operator() (const TTTrackType &t, const l1t::VertexWord &v) const
 

Private Attributes

tensorflow::Session * AssociationSesh_
 
double AssociationThreshold_
 
std::vector< double > eta_bins_
 
std::vector< double > res_bins_
 
std::vector< double > z0_binning_
 

Detailed Description

Definition at line 155 of file L1TrackVertexAssociationProducer.cc.

Constructor & Destructor Documentation

◆ NNTrackWordSelector()

L1TrackVertexAssociationProducer::NNTrackWordSelector::NNTrackWordSelector ( tensorflow::Session *  AssociationSesh,
const double  AssociationThreshold,
const std::vector< double > &  AssociationNetworkZ0binning,
const std::vector< double > &  AssociationNetworkEtaBounds,
const std::vector< double > &  AssociationNetworkZ0ResBins 
)
inline

Member Function Documentation

◆ operator()()

bool L1TrackVertexAssociationProducer::NNTrackWordSelector::operator() ( const TTTrackType t,
const l1t::VertexWord v 
) const
inline

Definition at line 167 of file L1TrackVertexAssociationProducer.cc.

References funct::abs(), AssociationSesh_, AssociationThreshold_, HLT_2024v14_cff::distance, l1ctLayer1_cff::dZ, eta_bins_, JetChargeProducer_cfi::exp, nano_mu_digi_cff::float, pfDeepBoostedJetPreprocessParams_cfi::lower_bound, res_bins_, tensorflow::run(), submitPVValidationJobs::t, findQualityFiles::v, and z0_binning_.

167  {
168  tensorflow::Tensor inputAssoc(tensorflow::DT_FLOAT, {1, 4});
169  std::vector<tensorflow::Tensor> outputAssoc;
170 
171  TTTrack_TrackWord::tanl_t etaEmulationBits = t.getTanlWord();
172  ap_fixed<16, 3> etaEmulation;
173  etaEmulation.V = (etaEmulationBits.range());
174 
175  auto lower = std::lower_bound(eta_bins_.begin(), eta_bins_.end(), etaEmulation.to_double());
176 
177  int resbin = std::distance(eta_bins_.begin(), lower);
178  float binWidth = z0_binning_[2];
179  // Calculate integer dZ from track z0 and vertex z0 (use floating point version and convert internally allowing use of both emulator and simulator vertex and track)
180  float dZ =
181  abs(floor(((t.getZ0() + z0_binning_[1]) / (binWidth))) - floor(((v.z0() + z0_binning_[1]) / (binWidth))));
182 
183  // The following constants <14, 9>, <22, 9> are defined by the quantisation of the Neural Network
184  ap_uint<14> ptEmulationBits = t.getTrackWord()(TTTrack_TrackWord::TrackBitLocations::kRinvMSB - 1,
185  TTTrack_TrackWord::TrackBitLocations::kRinvLSB);
186  ap_ufixed<14, 9> ptEmulation;
187  ptEmulation.V = (ptEmulationBits.range());
188 
189  ap_ufixed<22, 9> ptEmulation_rescale;
190  ptEmulation_rescale = ptEmulation.to_double();
191 
192  ap_ufixed<22, 9> resBinEmulation_rescale;
193  resBinEmulation_rescale = res_bins_[resbin];
194 
195  ap_ufixed<22, 9> MVAEmulation_rescale;
196  MVAEmulation_rescale = t.getMVAQualityBits();
197 
198  ap_ufixed<22, 9> dZEmulation_rescale;
199  dZEmulation_rescale = dZ;
200 
201  inputAssoc.tensor<float, 2>()(0, 0) = ptEmulation_rescale.to_double();
202  inputAssoc.tensor<float, 2>()(0, 1) = MVAEmulation_rescale.to_double();
203  inputAssoc.tensor<float, 2>()(0, 2) = resBinEmulation_rescale.to_double() / 16.0;
204  inputAssoc.tensor<float, 2>()(0, 3) = dZEmulation_rescale.to_double();
205 
206  // Run Association Network:
207  tensorflow::run(AssociationSesh_, {{"assoc:0", inputAssoc}}, {"Identity:0"}, &outputAssoc);
208 
209  double NNOutput = (double)outputAssoc[0].tensor<float, 2>()(0, 0);
210 
211  double NNOutput_exp = 1.0 / (1.0 + exp(-1.0 * (NNOutput)));
212 
213  return NNOutput_exp >= AssociationThreshold_;
214  }
void run(Session *session, const NamedTensorList &inputs, const std::vector< std::string > &outputNames, std::vector< Tensor > *outputs, const thread::ThreadPoolOptions &threadPoolOptions)
Definition: TensorFlow.cc:271
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
ap_uint< TrackBitWidths::kTanlSize > tanl_t

Member Data Documentation

◆ AssociationSesh_

tensorflow::Session* L1TrackVertexAssociationProducer::NNTrackWordSelector::AssociationSesh_
private

Definition at line 217 of file L1TrackVertexAssociationProducer.cc.

Referenced by operator()().

◆ AssociationThreshold_

double L1TrackVertexAssociationProducer::NNTrackWordSelector::AssociationThreshold_
private

Definition at line 218 of file L1TrackVertexAssociationProducer.cc.

Referenced by operator()().

◆ eta_bins_

std::vector<double> L1TrackVertexAssociationProducer::NNTrackWordSelector::eta_bins_
private

Definition at line 220 of file L1TrackVertexAssociationProducer.cc.

Referenced by operator()().

◆ res_bins_

std::vector<double> L1TrackVertexAssociationProducer::NNTrackWordSelector::res_bins_
private

Definition at line 221 of file L1TrackVertexAssociationProducer.cc.

Referenced by operator()().

◆ z0_binning_

std::vector<double> L1TrackVertexAssociationProducer::NNTrackWordSelector::z0_binning_
private

Definition at line 219 of file L1TrackVertexAssociationProducer.cc.

Referenced by operator()().