12 #include "TLorentzVector.h" 20 constexpr
static int qualityMap[8] = {1, 0, 1, 1, 4, 4, 5, 6};
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 (
pfcand.trackRef().isNonnull() &&
pv->trackWeight(
pfcand.trackRef()) > 0.5 && pv_ass_quality == 7) {
164 uint16_t qualityFlags = 0;
180 uint16_t qualityFlags = 0;
186 const auto *patJet =
dynamic_cast<const pat::Jet *
>(&
jet);
190 if (patJet->nSubjetCollections() > 0) {
191 auto subjets = patJet->subjets();
215 std::vector<float> &datavec,
224 assert(min_length <= max_length);
226 unsigned target_length = std::clamp((
unsigned)
input.size(), min_length, max_length);
227 for (
unsigned i = 0;
i < target_length; ++
i) {
231 datavec[
i + startval] = pad_value;
234 return target_length;
240 unsigned target_length,
241 std::vector<float> &datavec,
251 for (
unsigned i = 0; i < std::min(static_cast<unsigned int>(
input.size()), target_length); ++
i) {
254 if (
input.size() < target_length)
255 datavec.insert(datavec.end(), target_length -
input.size(), pad_value);
257 return target_length;
262 std::vector<std::string> &input_names_,
263 std::unordered_map<std::string, PreprocessParams> &prep_info_map_,
265 std::vector<unsigned> &input_sizes_,
269 if (!json_path.empty()) {
273 js.at(
"input_names").get_to(input_names_);
274 for (
const auto &group_name : input_names_) {
275 const auto &group_pset = js.at(group_name);
276 auto &prep_params = prep_info_map_[group_name];
277 group_pset.at(
"var_names").get_to(prep_params.var_names);
278 if (group_pset.contains(
"var_length")) {
279 prep_params.min_length = group_pset.at(
"var_length");
280 prep_params.max_length = prep_params.min_length;
282 prep_params.min_length = group_pset.at(
"min_length");
283 prep_params.max_length = group_pset.at(
"max_length");
284 input_shapes_.push_back({1, (int64_t)prep_params.var_names.size(), -1});
286 const auto &var_info_pset = group_pset.at(
"var_infos");
287 for (
const auto &var_name : prep_params.var_names) {
288 const auto &var_pset = var_info_pset.at(var_name);
289 double median = var_pset.at(
"median");
294 double pad = var_pset.contains(
"pad") ? double(var_pset.at(
"pad")) : 0;
295 prep_params.var_info_map[var_name] =
299 if (
doExtra && data_ !=
nullptr) {
301 const auto &len = input_sizes_.emplace_back(prep_params.max_length * prep_params.var_names.size());
302 data_->emplace_back(len, 0);
308 input_names_ = prep_pset.
getParameter<std::vector<std::string>>(
"input_names");
309 for (
const auto &group_name : input_names_) {
311 auto &prep_params = prep_info_map_[group_name];
312 prep_params.var_names = group_pset.
getParameter<std::vector<std::string>>(
"var_names");
313 prep_params.min_length = group_pset.
getParameter<
unsigned>(
"var_length");
314 prep_params.max_length = prep_params.min_length;
316 for (
const auto &var_name : prep_params.var_names) {
323 prep_params.var_info_map[var_name] =
327 if (
doExtra && data_ !=
nullptr) {
329 const auto &len = input_sizes_.emplace_back(prep_params.max_length * prep_params.var_names.size());
330 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]