44 void addTrackster(
const int&
index,
46 const std::vector<float>& inputClusterMask,
47 const float& fractionCut_,
53 std::vector<float>& output_mask,
54 std::vector<Trackster>&
result);
58 const bool doNose_ =
false;
75 : detector_(ps.getParameter<
std::
string>(
"detector")),
76 doNose_(detector_ ==
"HFNose"),
77 clusters_token_(consumes(ps.getParameter<
edm::
InputTag>(
"layer_clusters"))),
78 clustersTime_token_(consumes(ps.getParameter<
edm::
InputTag>(
"time_layerclusters"))),
79 filtered_layerclusters_mask_token_(consumes(ps.getParameter<
edm::
InputTag>(
"filtered_mask"))),
80 simclusters_token_(consumes(ps.getParameter<
edm::
InputTag>(
"simclusters"))),
81 caloparticles_token_(consumes(ps.getParameter<
edm::
InputTag>(
"caloparticles"))),
82 associatorMapSimClusterToReco_token_(
83 consumes(ps.getParameter<
edm::
InputTag>(
"layerClusterSimClusterAssociator"))),
84 associatorMapCaloParticleToReco_token_(
85 consumes(ps.getParameter<
edm::
InputTag>(
"layerClusterCaloParticleAssociator"))),
87 fractionCut_(ps.getParameter<double>(
"fractionCut")) {
88 produces<TracksterCollection>();
89 produces<std::vector<float>>();
90 produces<TracksterCollection>(
"fromCPs");
91 produces<std::vector<float>>(
"fromCPs");
92 produces<std::map<uint, std::vector<uint>>>();
107 edm::InputTag(
"layerClusterCaloParticleAssociationProducer"));
108 desc.add<
double>(
"fractionCut", 0.);
116 const std::vector<float>& inputClusterMask,
117 const float& fractionCut_,
123 std::vector<float>& output_mask,
124 std::vector<Trackster>&
result) {
130 tmpTrackster.
vertices().reserve(lcVec.size());
132 for (
auto const& [lc, energyScorePair] : lcVec) {
133 if (inputClusterMask[lc.index()] > 0) {
134 double fraction = energyScorePair.first / lc->energy();
137 tmpTrackster.
vertices().push_back(lc.index());
138 output_mask[lc.index()] -=
fraction;
147 result.emplace_back(tmpTrackster);
151 auto result = std::make_unique<TracksterCollection>();
152 auto output_mask = std::make_unique<std::vector<float>>();
153 auto result_fromCP = std::make_unique<TracksterCollection>();
154 auto output_mask_fromCP = std::make_unique<std::vector<float>>();
155 auto cpToSc_SimTrackstersMap = std::make_unique<std::map<uint, std::vector<uint>>>();
171 result->reserve(num_simclusters);
173 result_fromCP->reserve(num_caloparticles);
175 for (
const auto& [
key, lcVec] : caloParticlesToRecoColl) {
176 auto const&
cp = *(
key);
179 auto regr_energy =
cp.energy();
180 std::vector<uint> scSimTracksterIdx;
181 scSimTracksterIdx.reserve(
cp.simClusters().size());
184 if (
cp.g4Tracks()[0].crossedBoundary()) {
185 regr_energy =
cp.g4Tracks()[0].getMomentumAtBoundary().energy();
199 for (
const auto& scRef :
cp.simClusters()) {
200 const auto& it = simClustersToRecoColl.find(scRef);
201 if (it == simClustersToRecoColl.end())
203 const auto& lcVec = it->val;
204 auto const& sc = *(scRef);
211 sc.g4Tracks()[0].getMomentumAtBoundary().energy(),
222 if (
std::find(scSimTracksterIdx.begin(), scSimTracksterIdx.end(),
index) == scSimTracksterIdx.end()) {
223 scSimTracksterIdx.emplace_back(
index);
226 scSimTracksterIdx.shrink_to_fit();
242 if (result_fromCP->empty())
244 const auto index = result_fromCP->size() - 1;
245 if (cpToSc_SimTrackstersMap->find(
index) == cpToSc_SimTrackstersMap->end()) {
246 (*cpToSc_SimTrackstersMap)[
index] = scSimTracksterIdx;
255 result_fromCP->shrink_to_fit();
void setSeed(edm::ProductID pid, int index)
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
void setRegressedEnergy(float value)
bool get(ProductID const &oid, Handle< PROD > &result) const
void addTrackster(const int &index, const std::vector< std::pair< edm::Ref< reco::CaloClusterCollection >, std::pair< float, float >>> &lcVec, const std::vector< float > &inputClusterMask, const float &fractionCut_, const float &energy, const int &pdgId, const int &charge, const edm::ProductID &seed, const Trackster::IterationIndex iter, std::vector< float > &output_mask, std::vector< Trackster > &result)
const edm::EDGetTokenT< hgcal::SimToRecoCollectionWithSimClusters > associatorMapSimClusterToReco_token_
const edm::EDGetTokenT< std::vector< float > > filtered_layerclusters_mask_token_
const edm::ESGetToken< CaloGeometry, CaloGeometryRecord > geom_token_
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
const double fractionCut_
void assignPCAtoTracksters(std::vector< Trackster > &, const std::vector< reco::CaloCluster > &, const edm::ValueMap< std::pair< float, float >> &, double, bool energyWeight=true)
Trackster::ParticleType tracksterParticleTypeFromPdgId(int pdgId, int charge)
void produce(edm::Event &, const edm::EventSetup &) override
#define DEFINE_FWK_MODULE(type)
const edm::EDGetTokenT< std::vector< CaloParticle > > caloparticles_token_
const edm::EDGetTokenT< std::vector< reco::CaloCluster > > clusters_token_
const edm::EDGetTokenT< edm::ValueMap< std::pair< float, float > > > clustersTime_token_
const edm::EDGetTokenT< hgcal::SimToRecoCollection > associatorMapCaloParticleToReco_token_
SimTrackstersProducer(const edm::ParameterSet &)
std::vector< unsigned int > & vertices()
const edm::EDGetTokenT< std::vector< SimCluster > > simclusters_token_
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
hgcal::RecHitTools rhtools_
std::vector< float > & vertex_multiplicity()
void setIteration(const Trackster::IterationIndex i)
void setIdProbability(ParticleType type, float value)