60 static std::unique_ptr<ONNXRuntime> initializeGlobalCache(
const edm::ParameterSet &iConfig);
64 void printTrackstersDebug(
const std::vector<Trackster> &,
const char *
label)
const;
65 void dumpTrackster(
const Trackster &)
const;
95 regressionAndPid_(ps.getParameter<
bool>(
"regressionAndPid")),
97 detector_(ps.getParameter<
std::
string>(
"detector")),
98 propName_(ps.getParameter<
std::
string>(
"propagator")),
103 for (
auto const &
tag : ps.
getParameter<std::vector<edm::InputTag>>(
"tracksters_collections")) {
107 for (
auto const &
tag : ps.
getParameter<std::vector<edm::InputTag>>(
"original_masks")) {
117 produces<std::vector<Trackster>>();
120 produces<std::vector<std::vector<unsigned int>>>();
121 produces<std::vector<std::vector<unsigned int>>>(
"linkedTracksterIdToInputTracksterId");
123 produces<std::vector<float>>();
128 std::string detectorName_ = (
detector_ ==
"HFNose") ?
"HGCalHFNoseSensitive" :
"HGCalEESensitive";
129 hdc_token_ = esConsumes<HGCalDDDConstants, IdealGeometryRecord, edm::Transition::BeginRun>(
138 if (pluginPset.exists(
"onnxModelPath"))
141 return std::unique_ptr<ONNXRuntime>(
nullptr);
162 auto e_over_h = (
t.raw_em_pt() / ((
t.raw_pt() -
t.raw_em_pt()) != 0. ? (
t.raw_pt() -
t.raw_em_pt()) : 1.));
164 <<
"\nTrackster raw_pt: " <<
t.raw_pt() <<
" raw_em_pt: " <<
t.raw_em_pt() <<
" eoh: " << e_over_h
165 <<
" barycenter: " <<
t.barycenter() <<
" eta,phi (baricenter): " <<
t.barycenter().eta() <<
", " 166 <<
t.barycenter().phi() <<
" eta,phi (eigen): " <<
t.eigenvectors(0).eta() <<
", " <<
t.eigenvectors(0).phi()
167 <<
" pt(eigen): " <<
std::sqrt(
t.eigenvectors(0).Unit().perp2()) *
t.raw_energy() <<
" seedID: " <<
t.seedID()
168 <<
" seedIndex: " <<
t.seedIndex() <<
" size: " <<
t.vertices().size() <<
" average usage: " 169 << (std::accumulate(std::begin(
t.vertex_multiplicity()), std::end(
t.vertex_multiplicity()), 0.) /
170 (
float)
t.vertex_multiplicity().size())
171 <<
" raw_energy: " <<
t.raw_energy() <<
" regressed energy: " <<
t.regressed_energy()
172 <<
" probs(ga/e/mu/np/cp/nh/am/unk): ";
173 for (
auto const &
p :
t.id_probabilities()) {
176 LogDebug(
"TracksterLinksProducer") <<
" sigmas: ";
177 for (
auto const &
s :
t.sigmas()) {
178 LogDebug(
"TracksterLinksProducer") <<
s <<
" ";
180 LogDebug(
"TracksterLinksProducer") << std::endl;
186 auto resultTracksters = std::make_unique<std::vector<Trackster>>();
188 auto linkedResultTracksters = std::make_unique<std::vector<std::vector<unsigned int>>>();
195 std::vector<float> original_global_mask(
layerClusters.size(), 1.f);
198 for (
unsigned int j = 0;
j < tmp_mask.size(); ++
j) {
199 original_global_mask[
j] *= tmp_mask[
j];
203 auto resultMask = std::make_unique<std::vector<float>>(original_global_mask);
205 std::vector<edm::Handle<std::vector<Trackster>>> tracksters_h(
tracksters_tokens_.size());
210 trackstersManager.addVector(*tracksters_h[
i]);
215 auto linkedTracksterIdToInputTracksterId = std::make_unique<std::vector<std::vector<unsigned int>>>();
222 linkingAlgo_->linkTracksters(
input, *resultTracksters, *linkedResultTracksters, *linkedTracksterIdToInputTracksterId);
227 for (
auto const &resultTrackster : *resultTracksters) {
228 for (
auto const &clusterIndex : resultTrackster.vertices()) {
229 (*resultMask)[clusterIndex] = 0.f;
250 evt.
put(
std::move(linkedTracksterIdToInputTracksterId),
"linkedTracksterIdToInputTracksterId");
255 LogDebug(
"TracksterLinksProducer").log([&](
auto &
log) {
257 log <<
counter++ <<
" TracksterLinksProducer (" <<
label <<
") obj barycenter: " <<
t.barycenter()
258 <<
" eta,phi (baricenter): " <<
t.barycenter().eta() <<
", " <<
t.barycenter().phi()
259 <<
" eta,phi (eigen): " <<
t.eigenvectors(0).eta() <<
", " <<
t.eigenvectors(0).phi()
260 <<
" pt(eigen): " <<
std::sqrt(
t.eigenvectors(0).Unit().perp2()) *
t.raw_energy() <<
" seedID: " <<
t.seedID()
261 <<
" seedIndex: " <<
t.seedIndex() <<
" size: " <<
t.vertices().size() <<
" average usage: " 262 << (std::accumulate(std::begin(
t.vertex_multiplicity()), std::end(
t.vertex_multiplicity()), 0.) /
263 (
float)
t.vertex_multiplicity().size())
264 <<
" raw_energy: " <<
t.raw_energy() <<
" regressed energy: " <<
t.regressed_energy()
265 <<
" probs(ga/e/mu/np/cp/nh/am/unk): ";
266 for (
auto const &
p :
t.id_probabilities()) {
270 for (
auto const &
s :
t.sigmas()) {
293 desc.add<std::vector<edm::InputTag>>(
"tracksters_collections", {
edm::InputTag(
"ticlTrackstersCLUE3DHigh")});
294 desc.add<std::vector<edm::InputTag>>(
"original_masks",
295 {
edm::InputTag(
"hgcalMergeLayerClusters",
"InitialLayerClustersMask")});
298 desc.add<
bool>(
"regressionAndPid",
false);
302 descriptions.
add(
"tracksterLinksProducer",
desc);
const HGCalDDDConstants * hgcons_
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
T getParameter(std::string const &) const
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
std::unique_ptr< TracksterInferenceAlgoBase > inferenceAlgo_
const bool regressionAndPid_
void produce(edm::Event &, const edm::EventSetup &) override
bool get(ProductID const &oid, Handle< PROD > &result) const
const edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > bfield_token_
std::vector< edm::EDGetTokenT< std::vector< float > > > original_masks_tokens_
static void globalEndJob(const ONNXRuntime *)
TracksterLinksProducer(const edm::ParameterSet &ps, const ONNXRuntime *)
hgcal::RecHitTools rhtools_
ParameterDescriptionNode * addNode(ParameterDescriptionNode const &node)
void assignPCAtoTracksters(std::vector< Trackster > &tracksters, const std::vector< reco::CaloCluster > &layerClusters, const edm::ValueMap< std::pair< float, float >> &layerClustersTime, double z_limit_em, hgcal::RecHitTools const &rhTools, bool computeLocalTime=false, bool energyWeight=true, bool clean=false, int minLayer=10, int maxLayer=10)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
std::unique_ptr< TracksterLinkingAlgoBase > linkingAlgo_
const edm::EDGetTokenT< std::vector< reco::CaloCluster > > clusters_token_
static std::string const input
T const * product() const
const edm::ESGetToken< CaloGeometry, CaloGeometryRecord > geometry_token_
#define DEFINE_FWK_MODULE(type)
static std::unique_ptr< ONNXRuntime > initializeGlobalCache(const edm::ParameterSet &iConfig)
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
void printTrackstersDebug(const std::vector< Trackster > &, const char *label) const
const std::string propName_
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
std::vector< edm::EDGetTokenT< std::vector< Trackster > > > tracksters_tokens_
~TracksterLinksProducer() override
void add(std::string const &label, ParameterSetDescription const &psetDescription)
void dumpTrackster(const Trackster &) const
edm::ESGetToken< HGCalDDDConstants, IdealGeometryRecord > hdc_token_
const std::string & fullPath() const
const edm::ESGetToken< Propagator, TrackingComponentsRecord > propagator_token_
void beginRun(edm::Run const &iEvent, edm::EventSetup const &es) override
const edm::EDGetTokenT< edm::ValueMap< std::pair< float, float > > > clustersTime_token_
const std::string detector_