CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Attributes
SimTrackstersProducer Class Reference
Inheritance diagram for SimTrackstersProducer:
edm::stream::EDProducer<>

Public Member Functions

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
 
 SimTrackstersProducer (const edm::ParameterSet &)
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
 EDProducer (const EDProducer &)=delete
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
const EDProduceroperator= (const EDProducer &)=delete
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 

Private Attributes

const edm::EDGetTokenT< hgcal::SimToRecoCollectionassociatorMapCaloParticleToReco_token_
 
const edm::EDGetTokenT< hgcal::SimToRecoCollectionWithSimClustersassociatorMapSimClusterToReco_token_
 
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_
 
std::string detector_
 
const bool doNose_ = false
 
const edm::EDGetTokenT< std::vector< float > > filtered_layerclusters_mask_token_
 
const double fractionCut_
 
const edm::ESGetToken< CaloGeometry, CaloGeometryRecordgeom_token_
 
hgcal::RecHitTools rhtools_
 
const edm::EDGetTokenT< std::vector< SimCluster > > simclusters_token_
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
using CacheTypes = CacheContexts< T... >
 
using GlobalCache = typename CacheTypes::GlobalCache
 
using HasAbility = AbilityChecker< T... >
 
using InputProcessBlockCache = typename CacheTypes::InputProcessBlockCache
 
using LuminosityBlockCache = typename CacheTypes::LuminosityBlockCache
 
using LuminosityBlockContext = LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCache >
 
using LuminosityBlockSummaryCache = typename CacheTypes::LuminosityBlockSummaryCache
 
using RunCache = typename CacheTypes::RunCache
 
using RunContext = RunContextT< RunCache, GlobalCache >
 
using RunSummaryCache = typename CacheTypes::RunSummaryCache
 

Detailed Description

Definition at line 38 of file SimTrackstersProducer.cc.

Constructor & Destructor Documentation

◆ SimTrackstersProducer()

SimTrackstersProducer::SimTrackstersProducer ( const edm::ParameterSet ps)
explicit

Definition at line 74 of file SimTrackstersProducer.cc.

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"))),
83  consumes(ps.getParameter<edm::InputTag>("layerClusterSimClusterAssociator"))),
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>>>();
93 }
ESGetTokenH3DDVariant esConsumes(std::string const &Record, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
const edm::EDGetTokenT< hgcal::SimToRecoCollectionWithSimClusters > associatorMapSimClusterToReco_token_
const edm::EDGetTokenT< std::vector< float > > filtered_layerclusters_mask_token_
const edm::ESGetToken< CaloGeometry, CaloGeometryRecord > geom_token_
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_
const edm::EDGetTokenT< std::vector< SimCluster > > simclusters_token_

Member Function Documentation

◆ addTrackster()

void SimTrackstersProducer::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 
)

Definition at line 113 of file SimTrackstersProducer.cc.

References ALCARECOTkAlJpsiMuMu_cff::charge, HCALHighEnergyHPDFilter_cfi::energy, f, HLT_2022v15_cff::fraction, fractionCut_, EgammaValidation_cff::pdgId, mps_fire::result, fileCollector::seed, ticl::Trackster::setIdProbability(), ticl::Trackster::setIteration(), ticl::Trackster::setRegressedEnergy(), ticl::Trackster::setSeed(), ticl::tracksterParticleTypeFromPdgId(), ticl::Trackster::vertex_multiplicity(), ticl::Trackster::vertices(), and ticl::Trackster::zeroProbabilities().

Referenced by produce().

124  {
125  if (lcVec.empty())
126  return;
127 
128  Trackster tmpTrackster;
129  tmpTrackster.zeroProbabilities();
130  tmpTrackster.vertices().reserve(lcVec.size());
131  tmpTrackster.vertex_multiplicity().reserve(lcVec.size());
132  for (auto const& [lc, energyScorePair] : lcVec) {
133  if (inputClusterMask[lc.index()] > 0) {
134  double fraction = energyScorePair.first / lc->energy();
135  if (fraction < fractionCut_)
136  continue;
137  tmpTrackster.vertices().push_back(lc.index());
138  output_mask[lc.index()] -= fraction;
139  tmpTrackster.vertex_multiplicity().push_back(1. / fraction);
140  }
141  }
142 
144  tmpTrackster.setRegressedEnergy(energy);
145  tmpTrackster.setIteration(iter);
146  tmpTrackster.setSeed(seed, index);
147  result.emplace_back(tmpTrackster);
148 }
void setSeed(edm::ProductID pid, int index)
Definition: Trackster.h:60
void setRegressedEnergy(float value)
Definition: Trackster.h:68
Trackster::ParticleType tracksterParticleTypeFromPdgId(int pdgId, int charge)
Definition: commons.h:14
double f[11][100]
void zeroProbabilities()
Definition: Trackster.h:107
std::vector< unsigned int > & vertices()
Definition: Trackster.h:57
std::vector< float > & vertex_multiplicity()
Definition: Trackster.h:58
void setIteration(const Trackster::IterationIndex i)
Definition: Trackster.h:56
void setIdProbability(ParticleType type, float value)
Definition: Trackster.h:117

◆ fillDescriptions()

void SimTrackstersProducer::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 95 of file SimTrackstersProducer.cc.

References edm::ConfigurationDescriptions::addWithDefaultLabel(), submitPVResolutionJobs::desc, HLT_2022v15_cff::InputTag, and AlCaHLTBitMon_QueryRunRegistry::string.

95  {
96  // hgcalMultiClusters
98  desc.add<std::string>("detector", "HGCAL");
99  desc.add<edm::InputTag>("layer_clusters", edm::InputTag("hgcalLayerClusters"));
100  desc.add<edm::InputTag>("time_layerclusters", edm::InputTag("hgcalLayerClusters", "timeLayerCluster"));
101  desc.add<edm::InputTag>("filtered_mask", edm::InputTag("filteredLayerClustersSimTracksters", "ticlSimTracksters"));
102  desc.add<edm::InputTag>("simclusters", edm::InputTag("mix", "MergedCaloTruth"));
103  desc.add<edm::InputTag>("caloparticles", edm::InputTag("mix", "MergedCaloTruth"));
104  desc.add<edm::InputTag>("layerClusterSimClusterAssociator",
105  edm::InputTag("layerClusterSimClusterAssociationProducer"));
106  desc.add<edm::InputTag>("layerClusterCaloParticleAssociator",
107  edm::InputTag("layerClusterCaloParticleAssociationProducer"));
108  desc.add<double>("fractionCut", 0.);
109 
110  descriptions.addWithDefaultLabel(desc);
111 }
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)

◆ produce()

void SimTrackstersProducer::produce ( edm::Event evt,
const edm::EventSetup es 
)
override

Definition at line 150 of file SimTrackstersProducer.cc.

References addTrackster(), ticl::assignPCAtoTracksters(), associatorMapCaloParticleToReco_token_, associatorMapSimClusterToReco_token_, SimTracksters_cff::caloparticles, caloparticles_token_, clusters_token_, clustersTime_token_, doNose_, filtered_layerclusters_mask_token_, spr::find(), fractionCut_, relativeConstraints::geom, geom_token_, edm::Event::get(), edm::EventSetup::getData(), hgcal::RecHitTools::getPositionLayer(), crabWrapper::key, hgcal::RecHitTools::lastLayerEE(), hltEgammaHGCALIDVarsL1Seeded_cfi::layerClusters, eostools::move(), edm::Event::put(), mps_fire::result, rhtools_, hgcal::RecHitTools::setGeometry(), ticl::Trackster::SIM, ticl::Trackster::SIM_CP, SimTracksters_cff::simclusters, simclusters_token_, and z.

150  {
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>>>();
156  const auto& layerClusters = evt.get(clusters_token_);
157  const auto& layerClustersTimes = evt.get(clustersTime_token_);
158  const auto& inputClusterMask = evt.get(filtered_layerclusters_mask_token_);
159  output_mask->resize(layerClusters.size(), 1.f);
160  output_mask_fromCP->resize(layerClusters.size(), 1.f);
161 
162  const auto& simclusters = evt.get(simclusters_token_);
163  const auto& caloparticles = evt.get(caloparticles_token_);
164 
165  const auto& simClustersToRecoColl = evt.get(associatorMapSimClusterToReco_token_);
166  const auto& caloParticlesToRecoColl = evt.get(associatorMapCaloParticleToReco_token_);
167 
168  const auto& geom = es.getData(geom_token_);
170  const auto num_simclusters = simclusters.size();
171  result->reserve(num_simclusters); // Conservative size, will call shrink_to_fit later
172  const auto num_caloparticles = caloparticles.size();
173  result_fromCP->reserve(num_caloparticles);
174 
175  for (const auto& [key, lcVec] : caloParticlesToRecoColl) {
176  auto const& cp = *(key);
177  auto cpIndex = &cp - &caloparticles[0];
178 
179  auto regr_energy = cp.energy();
180  std::vector<uint> scSimTracksterIdx;
181  scSimTracksterIdx.reserve(cp.simClusters().size());
182 
183  // Create a Trackster from the object entering HGCal
184  if (cp.g4Tracks()[0].crossedBoundary()) {
185  regr_energy = cp.g4Tracks()[0].getMomentumAtBoundary().energy();
186 
187  addTrackster(cpIndex,
188  lcVec,
189  inputClusterMask,
190  fractionCut_,
191  regr_energy,
192  cp.pdgId(),
193  cp.charge(),
194  key.id(),
196  *output_mask,
197  *result);
198  } else {
199  for (const auto& scRef : cp.simClusters()) {
200  const auto& it = simClustersToRecoColl.find(scRef);
201  if (it == simClustersToRecoColl.end())
202  continue;
203  const auto& lcVec = it->val;
204  auto const& sc = *(scRef);
205  auto const scIndex = &sc - &simclusters[0];
206 
207  addTrackster(scIndex,
208  lcVec,
209  inputClusterMask,
210  fractionCut_,
211  sc.g4Tracks()[0].getMomentumAtBoundary().energy(),
212  sc.pdgId(),
213  sc.charge(),
214  scRef.id(),
216  *output_mask,
217  *result);
218 
219  if (result->empty())
220  continue;
221  const auto index = result->size() - 1;
222  if (std::find(scSimTracksterIdx.begin(), scSimTracksterIdx.end(), index) == scSimTracksterIdx.end()) {
223  scSimTracksterIdx.emplace_back(index);
224  }
225  }
226  scSimTracksterIdx.shrink_to_fit();
227  }
228 
229  // Create a Trackster from any CP
230  addTrackster(cpIndex,
231  lcVec,
232  inputClusterMask,
233  fractionCut_,
234  regr_energy,
235  cp.pdgId(),
236  cp.charge(),
237  key.id(),
239  *output_mask_fromCP,
240  *result_fromCP);
241 
242  if (result_fromCP->empty())
243  continue;
244  const auto index = result_fromCP->size() - 1;
245  if (cpToSc_SimTrackstersMap->find(index) == cpToSc_SimTrackstersMap->end()) {
246  (*cpToSc_SimTrackstersMap)[index] = scSimTracksterIdx;
247  }
248  }
249 
252  result->shrink_to_fit();
254  *result_fromCP, layerClusters, layerClustersTimes, rhtools_.getPositionLayer(rhtools_.lastLayerEE(doNose_)).z());
255  result_fromCP->shrink_to_fit();
256 
257  evt.put(std::move(result));
258  evt.put(std::move(output_mask));
259  evt.put(std::move(result_fromCP), "fromCPs");
260  evt.put(std::move(output_mask_fromCP), "fromCPs");
261  evt.put(std::move(cpToSc_SimTrackstersMap));
262 }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
bool get(ProductID const &oid, Handle< PROD > &result) const
Definition: Event.h:347
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)
Definition: FindCaloHit.cc:19
void assignPCAtoTracksters(std::vector< Trackster > &, const std::vector< reco::CaloCluster > &, const edm::ValueMap< std::pair< float, float >> &, double, bool energyWeight=true)
const edm::EDGetTokenT< std::vector< CaloParticle > > caloparticles_token_
const edm::EDGetTokenT< std::vector< reco::CaloCluster > > clusters_token_
bool getData(T &iHolder) const
Definition: EventSetup.h:122
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_
GlobalPoint getPositionLayer(int layer, bool nose=false) const
Definition: RecHitTools.cc:141
void setGeometry(CaloGeometry const &)
Definition: RecHitTools.cc:68
def move(src, dest)
Definition: eostools.py:511
unsigned int lastLayerEE(bool nose=false) const
Definition: RecHitTools.h:75

Member Data Documentation

◆ associatorMapCaloParticleToReco_token_

const edm::EDGetTokenT<hgcal::SimToRecoCollection> SimTrackstersProducer::associatorMapCaloParticleToReco_token_
private

Definition at line 67 of file SimTrackstersProducer.cc.

Referenced by produce().

◆ associatorMapSimClusterToReco_token_

const edm::EDGetTokenT<hgcal::SimToRecoCollectionWithSimClusters> SimTrackstersProducer::associatorMapSimClusterToReco_token_
private

Definition at line 66 of file SimTrackstersProducer.cc.

Referenced by produce().

◆ caloparticles_token_

const edm::EDGetTokenT<std::vector<CaloParticle> > SimTrackstersProducer::caloparticles_token_
private

Definition at line 64 of file SimTrackstersProducer.cc.

Referenced by produce().

◆ clusters_token_

const edm::EDGetTokenT<std::vector<reco::CaloCluster> > SimTrackstersProducer::clusters_token_
private

Definition at line 59 of file SimTrackstersProducer.cc.

Referenced by produce().

◆ clustersTime_token_

const edm::EDGetTokenT<edm::ValueMap<std::pair<float, float> > > SimTrackstersProducer::clustersTime_token_
private

Definition at line 60 of file SimTrackstersProducer.cc.

Referenced by produce().

◆ detector_

std::string SimTrackstersProducer::detector_
private

Definition at line 57 of file SimTrackstersProducer.cc.

◆ doNose_

const bool SimTrackstersProducer::doNose_ = false
private

Definition at line 58 of file SimTrackstersProducer.cc.

Referenced by produce().

◆ filtered_layerclusters_mask_token_

const edm::EDGetTokenT<std::vector<float> > SimTrackstersProducer::filtered_layerclusters_mask_token_
private

Definition at line 61 of file SimTrackstersProducer.cc.

Referenced by produce().

◆ fractionCut_

const double SimTrackstersProducer::fractionCut_
private

Definition at line 70 of file SimTrackstersProducer.cc.

Referenced by addTrackster(), and produce().

◆ geom_token_

const edm::ESGetToken<CaloGeometry, CaloGeometryRecord> SimTrackstersProducer::geom_token_
private

Definition at line 68 of file SimTrackstersProducer.cc.

Referenced by produce().

◆ rhtools_

hgcal::RecHitTools SimTrackstersProducer::rhtools_
private

Definition at line 69 of file SimTrackstersProducer.cc.

Referenced by produce().

◆ simclusters_token_

const edm::EDGetTokenT<std::vector<SimCluster> > SimTrackstersProducer::simclusters_token_
private

Definition at line 63 of file SimTrackstersProducer.cc.

Referenced by produce().