62 std::unique_ptr<AbstractSuperclusteringDNNInput>
dnnInput_;
63 std::vector<std::vector<float>>
87 deltaEtaWindow_(ps.getParameter<double>(
"deltaEtaWindow")),
88 deltaPhiWindow_(ps.getParameter<double>(
"deltaPhiWindow")),
89 seedPtThreshold_(ps.getParameter<double>(
"seedPtThreshold")),
90 candidateEnergyThreshold_(ps.getParameter<double>(
"candidateEnergyThreshold")),
91 explVarRatioCut_energyBoundary_(ps.getParameter<double>(
"candidateEnergyThreshold")),
92 explVarRatioMinimum_lowEnergy_(ps.getParameter<double>(
"explVarRatioMinimum_lowEnergy")),
93 explVarRatioMinimum_highEnergy_(ps.getParameter<double>(
"explVarRatioMinimum_highEnergy")),
96 features_(dnnInput_->featureCount()) {
97 usesResource(
"TFileService");
102 output_tree_ =
fs->make<TTree>(
"superclusteringTraining",
"Superclustering training samples");
108 output_tree_->Branch(
"seedTracksterBestAssociation_caloParticleEnergy",
115 for (
unsigned int i = 0;
i <
dnnInput_->featureCount();
i++) {
125 float explVar_denominator =
127 if (explVar_denominator != 0.) {
128 float explVarRatio = ts.
eigenvalues()[0] / explVar_denominator;
150 std::vector<unsigned int> trackstersIndicesPt(inputTracksters->size());
151 std::iota(trackstersIndicesPt.begin(), trackstersIndicesPt.end(), 0);
153 trackstersIndicesPt.begin(), trackstersIndicesPt.end(), [&inputTracksters](
unsigned int i1,
unsigned int i2) {
154 return (*inputTracksters)[
i1].raw_pt() > (*inputTracksters)[
i2].raw_pt();
160 for (
unsigned int ts_seed_idx_pt = 0; ts_seed_idx_pt < inputTracksters->size(); ts_seed_idx_pt++) {
161 const unsigned int ts_seed_idx_input =
162 trackstersIndicesPt[ts_seed_idx_pt];
163 Trackster const& ts_seed = (*inputTracksters)[ts_seed_idx_input];
172 auto seed_assocs = assoc_CP_recoToSim->
find({inputTracksters, ts_seed_idx_input});
173 if (seed_assocs == assoc_CP_recoToSim->
end())
176 *std::min_element(seed_assocs->val.begin(),
177 seed_assocs->val.end(),
182 return assoc_1.second.second < assoc_2.second.second;
187 for (
unsigned int ts_cand_idx_pt = ts_seed_idx_pt + 1; ts_cand_idx_pt < inputTracksters->size(); ts_cand_idx_pt++) {
188 Trackster const& ts_cand = (*inputTracksters)[trackstersIndicesPt[ts_cand_idx_pt]];
198 for (
unsigned int feature_idx = 0; feature_idx <
features_.size(); feature_idx++) {
204 float candidateTracksterBestAssociationScore = 1.;
205 long candidateTracksterBestAssociation_simTsIdx = -1;
206 float candidateTracksterAssociationWithSeed_score =
210 auto cand_assocCP = assoc_CP_recoToSim->
find(
212 if (cand_assocCP != assoc_CP_recoToSim->
end()) {
215 *std::min_element(cand_assocCP->val.begin(),
216 cand_assocCP->val.end(),
220 return assoc_1.second.second < assoc_2.second.second;
222 candidateTracksterBestAssociationScore = cand_assocWithBestScore.second.second;
223 candidateTracksterBestAssociation_simTsIdx = cand_assocWithBestScore.first.key();
226 auto cand_assocWithSeedCP =
227 std::find_if(cand_assocCP->val.begin(),
228 cand_assocCP->val.end(),
231 return assoc.first == seed_assocWithBestScore.first;
233 if (cand_assocWithSeedCP != cand_assocCP->val.end()) {
234 candidateTracksterAssociationWithSeed_score = cand_assocWithSeedCP->second.second;
265 ->setComment(
"Input trackster collection, same as what is used for superclustering inference.");
267 edm::InputTag(
"tracksterSimTracksterAssociationLinkingbyCLUE3D",
"recoToSim"));
269 edm::allowedValues<std::string>(
"v1",
"v2"))
271 "DNN inputs version tag. Defines which set of features is fed to the DNN. Must match with the actual DNN.");
273 desc.add<
double>(
"deltaEtaWindow", 0.2)
275 "Size of delta eta window to consider for superclustering. Seed-candidate pairs outside this window " 276 "are not considered for DNN inference.");
277 desc.add<
double>(
"deltaPhiWindow", 0.7)
279 "Size of delta phi window to consider for superclustering. Seed-candidate pairs outside this window " 280 "are not considered for DNN inference.");
281 desc.add<
double>(
"seedPtThreshold", 3.)
282 ->setComment(
"Minimum transverse momentum of trackster to be considered as seed of a supercluster");
283 desc.add<
double>(
"candidateEnergyThreshold", 1.5)
284 ->setComment(
"Minimum energy of trackster to be considered as candidate for superclustering");
285 desc.add<
double>(
"explVarRatioCut_energyBoundary", 50.)
286 ->setComment(
"Boundary energy between low and high energy explVarRatio cut threshold");
287 desc.add<
double>(
"explVarRatioMinimum_lowEnergy", 0.85)
289 "Cut on explained variance ratio of tracksters to be considered as candidate, " 290 "for trackster raw_energy < explVarRatioCut_energyBoundary");
291 desc.add<
double>(
"explVarRatioMinimum_highEnergy", 0.9)
293 "Cut on explained variance ratio of tracksters to be considered as candidate, " 294 "for trackster raw_energy > explVarRatioCut_energyBoundary");
295 descriptions.
add(
"superclusteringSampleDumper",
desc);
std::vector< unsigned int > candidateTracksterIdx_
const float raw_pt() const
void analyze(const edm::Event &, const edm::EventSetup &) override
const Vector & barycenter() const
std::vector< float > seedTracksterBestAssociationScore_
Tag::data_type data_type
insert data type
const edm::EDGetTokenT< std::vector< Trackster > > tracksters_clue3d_token_
std::vector< unsigned int > seedTracksterIdx_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
std::vector< float > candidateTracksterAssociationWithSeed_score_
example_stream void analyze(const edm::Event &, const edm::EventSetup &) override
const_iterator find(const key_type &k) const
find element with specified reference key
std::vector< float > seedTracksterBestAssociation_caloParticleEnergy_
const_iterator end() const
last iterator over the map (read only)
std::vector< std::vector< float > > features_
std::vector< long > seedTracksterBestAssociation_simTsIdx_
float explVarRatioCut_energyBoundary_
std::vector< float > features(const reco::PreId &ecal, const reco::PreId &hcal, double rho, const reco::BeamSpot &spot, noZS::EcalClusterLazyTools &ecalTools)
const float raw_energy() const
Abs< T >::type abs(const T &t)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
SuperclusteringSampleDumper(const edm::ParameterSet &)
const edm::EDGetTokenT< ticl::RecoToSimCollectionSimTracksters > tsRecoToSimCP_token_
#define DEFINE_FWK_MODULE(type)
bool checkExplainedVarianceRatioCut(ticl::Trackster const &ts) const
float explVarRatioMinimum_lowEnergy_
float explVarRatioMinimum_highEnergy_
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
std::vector< float > candidateTracksterBestAssociationScore_
float candidateEnergyThreshold_
void add(std::string const &label, ParameterSetDescription const &psetDescription)
std::unique_ptr< AbstractSuperclusteringDNNInput > makeSuperclusteringDNNInputFromString(std::string dnnVersion)
std::vector< long > candidateTracksterBestAssociation_simTsIdx_
std::unique_ptr< AbstractSuperclusteringDNNInput > dnnInput_
const std::array< float, 3 > & eigenvalues() const