47 const bool doNose_ =
false;
64 : detector_(ps.getParameter<
std::
string>(
"detector")),
65 doNose_(detector_ ==
"HFNose"),
66 clusters_token_(consumes(ps.getParameter<
edm::
InputTag>(
"layer_clusters"))),
67 clustersTime_token_(consumes(ps.getParameter<
edm::
InputTag>(
"time_layerclusters"))),
68 filtered_layerclusters_mask_token_(consumes(ps.getParameter<
edm::
InputTag>(
"filtered_mask"))),
69 simclusters_token_(consumes(ps.getParameter<
edm::
InputTag>(
"simclusters"))),
70 caloparticles_token_(consumes(ps.getParameter<
edm::
InputTag>(
"caloparticles"))),
71 associatorMapSimClusterToReco_token_(
72 consumes(ps.getParameter<
edm::
InputTag>(
"layerClusterSimClusterAssociator"))),
73 associatorMapCaloParticleToReco_token_(
74 consumes(ps.getParameter<
edm::
InputTag>(
"layerClusterCaloParticleAssociator"))),
76 fractionCut_(ps.getParameter<double>(
"fractionCut")) {
77 produces<TracksterCollection>();
78 produces<std::vector<float>>();
79 produces<TracksterCollection>(
"fromCPs");
80 produces<std::vector<float>>(
"fromCPs");
81 produces<std::map<uint, std::vector<uint>>>();
96 edm::InputTag(
"layerClusterCaloParticleAssociationProducer"));
97 desc.add<
double>(
"fractionCut", 0.);
103 auto result = std::make_unique<TracksterCollection>();
104 auto output_mask = std::make_unique<std::vector<float>>();
105 auto result_fromCP = std::make_unique<TracksterCollection>();
106 auto output_mask_fromCP = std::make_unique<std::vector<float>>();
107 auto cpToSc_SimTrackstersMap = std::make_unique<std::map<uint, std::vector<uint>>>();
123 result->reserve(num_simclusters);
125 result_fromCP->reserve(num_caloparticles);
127 for (
const auto& [
key, lcVec] : caloParticlesToRecoColl) {
128 auto const&
cp = *(
key);
131 auto regr_energy =
cp.energy();
132 std::vector<uint> scSimTracksterIdx;
133 scSimTracksterIdx.reserve(
cp.simClusters().size());
136 if (
cp.g4Tracks()[0].crossedBoundary()) {
137 regr_energy =
cp.g4Tracks()[0].getMomentumAtBoundary().energy();
151 for (
const auto& scRef :
cp.simClusters()) {
152 const auto& it = simClustersToRecoColl.find(scRef);
153 if (it == simClustersToRecoColl.end())
155 const auto& lcVec = it->val;
156 auto const& sc = *(scRef);
163 sc.g4Tracks()[0].getMomentumAtBoundary().energy(),
174 if (
std::find(scSimTracksterIdx.begin(), scSimTracksterIdx.end(),
index) == scSimTracksterIdx.end()) {
175 scSimTracksterIdx.emplace_back(
index);
178 scSimTracksterIdx.shrink_to_fit();
194 if (result_fromCP->empty())
196 const auto index = result_fromCP->size() - 1;
197 if (cpToSc_SimTrackstersMap->find(
index) == cpToSc_SimTrackstersMap->end()) {
198 (*cpToSc_SimTrackstersMap)[
index] = scSimTracksterIdx;
207 result_fromCP->shrink_to_fit();
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
bool get(ProductID const &oid, Handle< PROD > &result) const
#define DEFINE_FWK_MODULE(type)
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)
static 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)
void produce(edm::Event &, const edm::EventSetup &) override
const edm::EDGetTokenT< std::vector< CaloParticle > > caloparticles_token_
const edm::EDGetTokenT< std::vector< reco::CaloCluster > > clusters_token_
bool getData(T &iHolder) const
const edm::EDGetTokenT< edm::ValueMap< std::pair< float, float > > > clustersTime_token_
const edm::EDGetTokenT< hgcal::SimToRecoCollection > associatorMapCaloParticleToReco_token_
SimTrackstersProducer(const edm::ParameterSet &)
const edm::EDGetTokenT< std::vector< SimCluster > > simclusters_token_
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
hgcal::RecHitTools rhtools_