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 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 63 of file SimTrackstersProducer.cc.

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"))),
72  consumes(ps.getParameter<edm::InputTag>("layerClusterSimClusterAssociator"))),
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>>>();
82 }
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

◆ fillDescriptions()

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

Definition at line 84 of file SimTrackstersProducer.cc.

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

84  {
85  // hgcalMultiClusters
87  desc.add<std::string>("detector", "HGCAL");
88  desc.add<edm::InputTag>("layer_clusters", edm::InputTag("hgcalLayerClusters"));
89  desc.add<edm::InputTag>("time_layerclusters", edm::InputTag("hgcalLayerClusters", "timeLayerCluster"));
90  desc.add<edm::InputTag>("filtered_mask", edm::InputTag("filteredLayerClustersSimTracksters", "ticlSimTracksters"));
91  desc.add<edm::InputTag>("simclusters", edm::InputTag("mix", "MergedCaloTruth"));
92  desc.add<edm::InputTag>("caloparticles", edm::InputTag("mix", "MergedCaloTruth"));
93  desc.add<edm::InputTag>("layerClusterSimClusterAssociator",
94  edm::InputTag("layerClusterSimClusterAssociationProducer"));
95  desc.add<edm::InputTag>("layerClusterCaloParticleAssociator",
96  edm::InputTag("layerClusterCaloParticleAssociationProducer"));
97  desc.add<double>("fractionCut", 0.);
98 
99  descriptions.addWithDefaultLabel(desc);
100 }
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)

◆ produce()

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

Definition at line 102 of file SimTrackstersProducer.cc.

References ticl::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.

102  {
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>>>();
108  const auto& layerClusters = evt.get(clusters_token_);
109  const auto& layerClustersTimes = evt.get(clustersTime_token_);
110  const auto& inputClusterMask = evt.get(filtered_layerclusters_mask_token_);
111  output_mask->resize(layerClusters.size(), 1.f);
112  output_mask_fromCP->resize(layerClusters.size(), 1.f);
113 
114  const auto& simclusters = evt.get(simclusters_token_);
115  const auto& caloparticles = evt.get(caloparticles_token_);
116 
117  const auto& simClustersToRecoColl = evt.get(associatorMapSimClusterToReco_token_);
118  const auto& caloParticlesToRecoColl = evt.get(associatorMapCaloParticleToReco_token_);
119 
120  const auto& geom = es.getData(geom_token_);
122  const auto num_simclusters = simclusters.size();
123  result->reserve(num_simclusters); // Conservative size, will call shrink_to_fit later
124  const auto num_caloparticles = caloparticles.size();
125  result_fromCP->reserve(num_caloparticles);
126 
127  for (const auto& [key, lcVec] : caloParticlesToRecoColl) {
128  auto const& cp = *(key);
129  auto cpIndex = &cp - &caloparticles[0];
130 
131  auto regr_energy = cp.energy();
132  std::vector<uint> scSimTracksterIdx;
133  scSimTracksterIdx.reserve(cp.simClusters().size());
134 
135  // Create a Trackster from the object entering HGCal
136  if (cp.g4Tracks()[0].crossedBoundary()) {
137  regr_energy = cp.g4Tracks()[0].getMomentumAtBoundary().energy();
138 
139  addTrackster(cpIndex,
140  lcVec,
141  inputClusterMask,
142  fractionCut_,
143  regr_energy,
144  cp.pdgId(),
145  cp.charge(),
146  key.id(),
148  *output_mask,
149  *result);
150  } else {
151  for (const auto& scRef : cp.simClusters()) {
152  const auto& it = simClustersToRecoColl.find(scRef);
153  if (it == simClustersToRecoColl.end())
154  continue;
155  const auto& lcVec = it->val;
156  auto const& sc = *(scRef);
157  auto const scIndex = &sc - &simclusters[0];
158 
159  addTrackster(scIndex,
160  lcVec,
161  inputClusterMask,
162  fractionCut_,
163  sc.g4Tracks()[0].getMomentumAtBoundary().energy(),
164  sc.pdgId(),
165  sc.charge(),
166  scRef.id(),
168  *output_mask,
169  *result);
170 
171  if (result->empty())
172  continue;
173  const auto index = result->size() - 1;
174  if (std::find(scSimTracksterIdx.begin(), scSimTracksterIdx.end(), index) == scSimTracksterIdx.end()) {
175  scSimTracksterIdx.emplace_back(index);
176  }
177  }
178  scSimTracksterIdx.shrink_to_fit();
179  }
180 
181  // Create a Trackster from any CP
182  addTrackster(cpIndex,
183  lcVec,
184  inputClusterMask,
185  fractionCut_,
186  regr_energy,
187  cp.pdgId(),
188  cp.charge(),
189  key.id(),
191  *output_mask_fromCP,
192  *result_fromCP);
193 
194  if (result_fromCP->empty())
195  continue;
196  const auto index = result_fromCP->size() - 1;
197  if (cpToSc_SimTrackstersMap->find(index) == cpToSc_SimTrackstersMap->end()) {
198  (*cpToSc_SimTrackstersMap)[index] = scSimTracksterIdx;
199  }
200  }
201 
204  result->shrink_to_fit();
206  *result_fromCP, layerClusters, layerClustersTimes, rhtools_.getPositionLayer(rhtools_.lastLayerEE(doNose_)).z());
207  result_fromCP->shrink_to_fit();
208 
209  evt.put(std::move(result));
210  evt.put(std::move(output_mask));
211  evt.put(std::move(result_fromCP), "fromCPs");
212  evt.put(std::move(output_mask_fromCP), "fromCPs");
213  evt.put(std::move(cpToSc_SimTrackstersMap));
214 }
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:346
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)
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)
Definition: commons.h:36
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 56 of file SimTrackstersProducer.cc.

Referenced by produce().

◆ associatorMapSimClusterToReco_token_

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

Definition at line 55 of file SimTrackstersProducer.cc.

Referenced by produce().

◆ caloparticles_token_

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

Definition at line 53 of file SimTrackstersProducer.cc.

Referenced by produce().

◆ clusters_token_

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

Definition at line 48 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 49 of file SimTrackstersProducer.cc.

Referenced by produce().

◆ detector_

std::string SimTrackstersProducer::detector_
private

Definition at line 46 of file SimTrackstersProducer.cc.

◆ doNose_

const bool SimTrackstersProducer::doNose_ = false
private

Definition at line 47 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 50 of file SimTrackstersProducer.cc.

Referenced by produce().

◆ fractionCut_

const double SimTrackstersProducer::fractionCut_
private

Definition at line 59 of file SimTrackstersProducer.cc.

Referenced by produce().

◆ geom_token_

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

Definition at line 57 of file SimTrackstersProducer.cc.

Referenced by produce().

◆ rhtools_

hgcal::RecHitTools SimTrackstersProducer::rhtools_
private

Definition at line 58 of file SimTrackstersProducer.cc.

Referenced by produce().

◆ simclusters_token_

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

Definition at line 52 of file SimTrackstersProducer.cc.

Referenced by produce().