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();
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
bool get(ProductID const &oid, Handle< PROD > &result) const
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)
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_
const edm::EDGetTokenT< std::vector< SimCluster > > simclusters_token_
hgcal::RecHitTools rhtools_