12 #include "TLorentzVector.h" 34 const float catch_infs(
const float in,
const float replace_value) {
37 if (in < -1e32 || in > 1e32)
44 const float replace_value,
45 const float lowerbound,
46 const float upperbound,
48 const bool use_offsets) {
50 if (withoutinfs +
offset < lowerbound)
52 if (withoutinfs +
offset > upperbound)
81 return p.Unit().Dot(
d.Unit());
85 float mindrsvpfcand(
const std::vector<reco::VertexCompositePtrCandidate> &svs,
88 for (
unsigned int i0 = 0; i0 < svs.size(); ++i0) {
99 float mindist_ = 999.999;
100 float out_dist = 0.0;
101 for (
unsigned int i = 0;
i < svs.size(); ++
i) {
102 if (!
track.isValid()) {
106 svs[
i].fillVertexCovariance(csv);
120 if (!tsos.isValid()) {
124 GlobalError refPointErr = tsos.cartesianError().position();
128 std::pair<bool, Measurement1D>
result(
136 double prod = IPVec.dot(direction);
137 double sign = (
prod >= 0) ? 1. : -1.;
139 if (
result.second.value() < mindist_) {
141 mindist_ =
result.second.value();
148 template bool sv_vertex_comparator<reco::VertexCompositePtrCandidate, reco::Vertex>(
153 if (
pv.isNonnull() &&
pfcand.trackRef().isNonnull() &&
pv->trackWeight(
pfcand.trackRef()) > 0.5 &&
154 pv_ass_quality == 7) {
187 const auto *patJet =
dynamic_cast<const pat::Jet *
>(&
jet);
191 if (patJet->nSubjetCollections() > 0) {
192 auto subjets = patJet->subjets();
216 std::vector<float> &datavec,
225 assert(min_length <= max_length);
227 unsigned target_length = std::clamp((
unsigned)
input.size(), min_length, max_length);
228 for (
unsigned i = 0;
i < target_length; ++
i) {
232 datavec[
i + startval] = pad_value;
235 return target_length;
241 unsigned target_length,
242 std::vector<float> &datavec,
252 for (
unsigned i = 0; i < std::min(static_cast<unsigned int>(
input.size()), target_length); ++
i) {
255 if (
input.size() < target_length)
256 datavec.insert(datavec.end(), target_length -
input.size(), pad_value);
258 return target_length;
263 std::vector<std::string> &input_names_,
264 std::unordered_map<std::string, PreprocessParams> &prep_info_map_,
266 std::vector<unsigned> &input_sizes_,
270 if (!json_path.empty()) {
274 js.at(
"input_names").get_to(input_names_);
275 for (
const auto &group_name : input_names_) {
276 const auto &group_pset = js.at(group_name);
277 auto &prep_params = prep_info_map_[group_name];
278 group_pset.at(
"var_names").get_to(prep_params.var_names);
279 if (group_pset.contains(
"var_length")) {
280 prep_params.min_length = group_pset.at(
"var_length");
281 prep_params.max_length = prep_params.min_length;
282 input_shapes_.push_back({1, (int64_t)prep_params.var_names.size(), prep_params.max_length});
284 prep_params.min_length = group_pset.at(
"min_length");
285 prep_params.max_length = group_pset.at(
"max_length");
286 input_shapes_.push_back({1, (int64_t)prep_params.var_names.size(), -1});
288 const auto &var_info_pset = group_pset.at(
"var_infos");
289 for (
const auto &
var_name : prep_params.var_names) {
290 const auto &var_pset = var_info_pset.at(
var_name);
291 double median = var_pset.at(
"median");
296 double pad = var_pset.contains(
"pad") ? double(var_pset.at(
"pad")) : 0;
297 prep_params.var_info_map[
var_name] =
301 if (
doExtra && data_ !=
nullptr) {
303 const auto &len = input_sizes_.emplace_back(prep_params.max_length * prep_params.var_names.size());
304 data_->emplace_back(len, 0);
310 input_names_ = prep_pset.
getParameter<std::vector<std::string>>(
"input_names");
311 for (
const auto &group_name : input_names_) {
313 auto &prep_params = prep_info_map_[group_name];
314 prep_params.var_names = group_pset.
getParameter<std::vector<std::string>>(
"var_names");
315 prep_params.min_length = group_pset.
getParameter<
unsigned>(
"var_length");
316 prep_params.max_length = prep_params.min_length;
318 for (
const auto &
var_name : prep_params.var_names) {
325 prep_params.var_info_map[
var_name] =
329 if (
doExtra && data_ !=
nullptr) {
331 const auto &len = input_sizes_.emplace_back(prep_params.max_length * prep_params.var_names.size());
332 data_->emplace_back(len, 0);
int center_norm_pad_halfRagged(const std::vector< float > &input, float center, float scale, unsigned target_length, std::vector< float > &datavec, int startval, float pad_value=0, float replace_inf_value=0, float min=0, float max=-1)
reco::Vertex::Point convertPos(const GlobalPoint &p)
float quality_from_pfcand(const reco::PFCandidate &pfcand)
vector< string > parse(string line, const string &delimiter)
T getParameter(std::string const &) const
float vertexDdotP(const reco::VertexCompositePtrCandidate &sv, const reco::Vertex &pv)
Measurement1D vertexD3d(const reco::VertexCompositePtrCandidate &svcand, const reco::Vertex &pv)
math::XYZVector Vector
point in the space
const float catch_infs(const float in, const float replace_value=0.)
Measurement1D distance(const GlobalPoint &vtx1Position, const GlobalError &vtx1PositionError, const GlobalPoint &vtx2Position, const GlobalError &vtx2PositionError) const override
constexpr bool isNotFinite(T x)
void fillVertexCovariance(CovarianceMatrix &v) const override
fill SMatrix
Base class for all types of Jets.
reco::Vertex::Error convertError(const GlobalError &ge)
ParameterSet const & getParameterSet(std::string const &) const
const Point & vertex() const override
vertex position (overwritten by PF...)
std::pair< float, float > getDRSubjetFeatures(const reco::Jet &jet, const reco::Candidate *cand)
std::vector< std::vector< float > > FloatArrays
math::Error< dimension >::type CovarianceMatrix
covariance error matrix (3x3)
static std::string const input
const float catch_infs_and_bound(const float in, const float replace_value, const float lowerbound, const float upperbound, const float offset=0., const bool use_offsets=true)
qualityFlagsShiftsAndMasks
void ParticleNetConstructor(const edm::ParameterSet &Config_, bool doExtra, std::vector< std::string > &input_names_, std::unordered_map< std::string, PreprocessParams > &prep_info_map_, std::vector< std::vector< int64_t >> &input_shapes_, std::vector< unsigned > &input_sizes_, cms::Ort::FloatArrays *data_)
float mindrsvpfcand(const std::vector< reco::VertexCompositePtrCandidate > &svs, const reco::Candidate *cand, float mindr=0.4)
std::vector< float > features(const reco::PreId &ecal, const reco::PreId &hcal, double rho, const reco::BeamSpot &spot, noZS::EcalClusterLazyTools &ecalTools)
Measurement1D vertexDxy(const reco::VertexCompositePtrCandidate &svcand, const reco::Vertex &pv)
float vtx_ass_from_pfcand(const reco::PFCandidate &pfcand, int pv_ass_quality, const reco::VertexRef &pv)
float mindistsvpfcand(const std::vector< reco::VertexCompositePtrCandidate > &svs, const reco::TransientTrack track)
constexpr auto deltaR(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
Measurement1D distance(const GlobalPoint &vtx1Position, const GlobalError &vtx1PositionError, const GlobalPoint &vtx2Position, const GlobalError &vtx2PositionError) const override
Analysis-level calorimeter jet class.
int center_norm_pad(const std::vector< float > &input, float center, float scale, unsigned min_length, unsigned max_length, std::vector< float > &datavec, int startval, float pad_value=0, float replace_inf_value=0, float min=0, float max=-1)
float lost_inner_hits_from_pfcand(const reco::PFCandidate &pfcand)
Particle reconstructed by the particle flow algorithm.
static constexpr int qualityMap[8]