CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
AllTracksterToSimTracksterAssociatorsByLCsProducer Class Reference
Inheritance diagram for AllTracksterToSimTracksterAssociatorsByLCsProducer:
edm::global::EDProducer<> edm::global::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 AllTracksterToSimTracksterAssociatorsByLCsProducer (const edm::ParameterSet &)
 
 ~AllTracksterToSimTracksterAssociatorsByLCsProducer () override=default
 
- Public Member Functions inherited from edm::global::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
 
EDProduceroperator= (const EDProducer &)=delete
 
bool wantsGlobalLuminosityBlocks () const noexcept final
 
bool wantsGlobalRuns () const noexcept final
 
bool wantsInputProcessBlocks () const noexcept final
 
bool wantsProcessBlocks () const noexcept final
 
bool wantsStreamLuminosityBlocks () const noexcept final
 
bool wantsStreamRuns () const noexcept final
 
- Public Member Functions inherited from edm::global::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
 ~EDProducerBase () override
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
std::vector< edm::ProductResolverIndex > const & indiciesForPutProducts (BranchType iBranchType) const
 
 ProducerBase ()
 
std::vector< edm::ProductResolverIndex > const & putTokenIndexToProductResolverIndex () const
 
std::vector< bool > const & recordProvenanceList () const
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription const &)> registrationCallback () const
 used by the fwk to register list of products More...
 
void resolvePutIndicies (BranchType iBranchType, ModuleToResolverIndicies const &iIndicies, std::string const &moduleLabel)
 
TypeLabelList const & typeLabelList () const
 used by the fwk to register the list of products of this module More...
 
 ~ProducerBase () noexcept(false) override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ESResolverIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESResolverIndex > const & esGetTokenIndicesVector (edm::Transition iTrans) const
 
std::vector< ESRecordIndex > const & esGetTokenRecordIndicesVector (edm::Transition iTrans) const
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::array< std::vector< ModuleDescription const *> *, NumBranchTypes > &modulesAll, std::vector< ModuleProcessName > &modulesInPreviousProcesses, ProductRegistry const &preg, std::map< std::string, ModuleDescription const *> const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
void selectInputProcessBlocks (ProductRegistry const &productRegistry, ProcessBlockHelperBase const &processBlockHelperBase)
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProductResolverIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 
- Static Public Member Functions inherited from edm::global::EDProducerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 

Private Member Functions

void produce (edm::StreamID, edm::Event &, const edm::EventSetup &) const override
 

Private Attributes

edm::EDGetTokenT< std::vector< reco::CaloCluster > > layerClustersToken_
 
std::vector< std::pair< std::string, edm::EDGetTokenT< ticl::AssociationMap< ticl::mapWithFraction, std::vector< reco::CaloCluster >, std::vector< ticl::Trackster > > > > > layerClusterToSimTracksterMapTokens_
 
std::vector< std::pair< std::string, edm::EDGetTokenT< ticl::AssociationMap< ticl::mapWithFraction, std::vector< reco::CaloCluster >, std::vector< ticl::Trackster > > > > > layerClusterToTracksterMapTokens_
 
std::vector< std::pair< std::string, edm::EDGetTokenT< std::vector< ticl::Trackster > > > > simTracksterCollectionTokens_
 
std::vector< std::pair< std::string, edm::EDGetTokenT< std::vector< ticl::Trackster > > > > tracksterCollectionTokens_
 

Additional Inherited Members

- Public Types inherited from edm::global::EDProducerBase
typedef EDProducerBase ModuleType
 
- Public Types inherited from edm::ProducerBase
template<typename T >
using BranchAliasSetterT = ProductRegistryHelper::BranchAliasSetterT< T >
 
using ModuleToResolverIndicies = std::unordered_multimap< std::string, std::tuple< edm::TypeID const *, const char *, edm::ProductResolverIndex > >
 
typedef ProductRegistryHelper::TypeLabelList TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Protected Member Functions inherited from edm::ProducerBase
template<Transition Tr = Transition::Event>
auto produces (std::string instanceName) noexcept
 declare what type of product will make and with which optional label More...
 
template<Transition B>
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<BranchType B>
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<class ProductType >
BranchAliasSetterT< ProductType > produces ()
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces ()
 
template<class ProductType >
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces ()
 
template<Transition Tr = Transition::Event>
auto produces () noexcept
 
ProducesCollector producesCollector ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< Bconsumes (edm::InputTag tag) noexcept
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
constexpr auto esConsumes ()
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag)
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
void resetItemsToGetFrom (BranchType iType)
 

Detailed Description

Definition at line 15 of file AllTracksterToSimTracksterAssociatorsByLCsProducer.cc.

Constructor & Destructor Documentation

◆ AllTracksterToSimTracksterAssociatorsByLCsProducer()

AllTracksterToSimTracksterAssociatorsByLCsProducer::AllTracksterToSimTracksterAssociatorsByLCsProducer ( const edm::ParameterSet pset)
explicit

Definition at line 40 of file AllTracksterToSimTracksterAssociatorsByLCsProducer.cc.

References edm::EDConsumerBase::consumes(), label, layerClusterToSimTracksterMapTokens_, layerClusterToTracksterMapTokens_, edm::ProductRegistryHelper::produces(), muonDTDigis_cfi::pset, TSToSimTSAssociation_cfi::simTracksterCollections, simTracksterCollectionTokens_, AlCaHLTBitMon_QueryRunRegistry::string, makeGlobalPositionRcd_cfg::tag, ticlDumper_cff::tracksterCollections, and tracksterCollectionTokens_.

42  : layerClustersToken_(consumes<std::vector<reco::CaloCluster>>(pset.getParameter<edm::InputTag>("layerClusters"))) {
43  const auto& tracksterCollections = pset.getParameter<std::vector<edm::InputTag>>("tracksterCollections");
44  for (const auto& tag : tracksterCollections) {
45  std::string label = tag.label();
46  if (tag.instance() != "") {
47  label += tag.instance();
48  }
49  tracksterCollectionTokens_.emplace_back(label, consumes<std::vector<ticl::Trackster>>(tag));
51  label,
52  consumes<
53  ticl::AssociationMap<ticl::mapWithFraction, std::vector<reco::CaloCluster>, std::vector<ticl::Trackster>>>(
54  edm::InputTag("allLayerClusterToTracksterAssociations", label)));
55  }
56 
57  const auto& simTracksterCollections = pset.getParameter<std::vector<edm::InputTag>>("simTracksterCollections");
58  for (const auto& tag : simTracksterCollections) {
59  std::string label = tag.label();
60  if (tag.instance() != "") {
61  label += tag.instance();
62  }
63  simTracksterCollectionTokens_.emplace_back(label, consumes<std::vector<ticl::Trackster>>(tag));
65  label,
66  consumes<
67  ticl::AssociationMap<ticl::mapWithFraction, std::vector<reco::CaloCluster>, std::vector<ticl::Trackster>>>(
68  edm::InputTag("allLayerClusterToTracksterAssociations", label)));
69  }
70 
71  // Produce separate association maps for each trackster-simTrackster combination
72  for (const auto& tracksterToken : tracksterCollectionTokens_) {
73  for (const auto& simTracksterToken : simTracksterCollectionTokens_) {
74  std::string instanceLabel = tracksterToken.first + "To" + simTracksterToken.first;
76  std::vector<ticl::Trackster>,
77  std::vector<ticl::Trackster>>>(instanceLabel);
78  std::string reverseInstanceLabel = simTracksterToken.first + "To" + tracksterToken.first;
80  std::vector<ticl::Trackster>,
81  std::vector<ticl::Trackster>>>(reverseInstanceLabel);
82  }
83  }
84 }
std::vector< std::pair< std::string, edm::EDGetTokenT< std::vector< ticl::Trackster > > > > simTracksterCollectionTokens_
std::vector< std::pair< std::string, edm::EDGetTokenT< ticl::AssociationMap< ticl::mapWithFraction, std::vector< reco::CaloCluster >, std::vector< ticl::Trackster > > > > > layerClusterToTracksterMapTokens_
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
char const * label
std::vector< std::vector< std::pair< unsigned int, float > >> mapWithFraction
std::vector< std::pair< std::string, edm::EDGetTokenT< ticl::AssociationMap< ticl::mapWithFraction, std::vector< reco::CaloCluster >, std::vector< ticl::Trackster > > > > > layerClusterToSimTracksterMapTokens_
std::vector< std::vector< std::pair< unsigned int, std::pair< float, float > >> > mapWithFractionAndScore
std::vector< std::pair< std::string, edm::EDGetTokenT< std::vector< ticl::Trackster > > > > tracksterCollectionTokens_

◆ ~AllTracksterToSimTracksterAssociatorsByLCsProducer()

AllTracksterToSimTracksterAssociatorsByLCsProducer::~AllTracksterToSimTracksterAssociatorsByLCsProducer ( )
overridedefault

Member Function Documentation

◆ fillDescriptions()

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

Definition at line 270 of file AllTracksterToSimTracksterAssociatorsByLCsProducer.cc.

References edm::ConfigurationDescriptions::add(), submitPVResolutionJobs::desc, and ProducerED_cfi::InputTag.

270  {
272  desc.add<std::vector<edm::InputTag>>(
273  "tracksterCollections", {edm::InputTag("ticlTrackstersCLUE3DHigh"), edm::InputTag("ticlTrackstersLinks")});
274  desc.add<std::vector<edm::InputTag>>(
275  "simTracksterCollections", {edm::InputTag("ticlSimTracksters"), edm::InputTag("ticlSimTracksters", "fromCPs")});
276  desc.add<edm::InputTag>("layerClusters", edm::InputTag("hgcalMergeLayerClusters"));
277  descriptions.add("AllTracksterToSimTracksterAssociatorsByLCsProducer", desc);
278 }
void add(std::string const &label, ParameterSetDescription const &psetDescription)

◆ produce()

void AllTracksterToSimTracksterAssociatorsByLCsProducer::produce ( edm::StreamID  ,
edm::Event iEvent,
const edm::EventSetup  
) const
overrideprivatevirtual

Implements edm::global::EDProducerBase.

Definition at line 86 of file AllTracksterToSimTracksterAssociatorsByLCsProducer.cc.

References mps_fire::i, iEvent, hltEgammaHGCALIDVarsL1Seeded_cfi::layerClusters, layerClustersToken_, layerClusterToSimTracksterMapTokens_, layerClusterToTracksterMapTokens_, SiStripPI::min, eostools::move(), offlineSlimmedPrimaryVertices_cfi::score, egamma::sharedEnergy(), simTracksterCollectionTokens_, jetUpdater_cfi::sort, tracksterCollectionTokens_, and tier0::unique().

88  {
89  using namespace edm;
90 
91  Handle<std::vector<reco::CaloCluster>> layerClustersHandle;
92  iEvent.getByToken(layerClustersToken_, layerClustersHandle);
93  const auto& layerClusters = *layerClustersHandle;
94 
95  for (const auto& tracksterToken : tracksterCollectionTokens_) {
96  Handle<std::vector<ticl::Trackster>> recoTrackstersHandle;
97  iEvent.getByToken(tracksterToken.second, recoTrackstersHandle);
98  const auto& recoTracksters = *recoTrackstersHandle;
99 
100  // Retrieve the correct LayerClusterToTracksterMap for the current trackster collection
102  layerClusterToTracksterMapHandle;
103  auto tracksterMapTokenIter =
104  std::find_if(layerClusterToTracksterMapTokens_.begin(),
106  [&tracksterToken](const auto& pair) { return pair.first == tracksterToken.first; });
107  if (tracksterMapTokenIter != layerClusterToTracksterMapTokens_.end()) {
108  iEvent.getByToken(tracksterMapTokenIter->second, layerClusterToTracksterMapHandle);
109  }
110  const auto& layerClusterToTracksterMap = *layerClusterToTracksterMapHandle;
111 
112  for (const auto& simTracksterToken : simTracksterCollectionTokens_) {
113  Handle<std::vector<ticl::Trackster>> simTrackstersHandle;
114  iEvent.getByToken(simTracksterToken.second, simTrackstersHandle);
115  const auto& simTracksters = *simTrackstersHandle;
116 
117  // Retrieve the correct LayerClusterToSimTracksterMap for the current simTrackster collection
119  layerClusterToSimTracksterMapHandle;
120  auto simTracksterMapTokenIter =
121  std::find_if(layerClusterToSimTracksterMapTokens_.begin(),
123  [&simTracksterToken](const auto& pair) { return pair.first == simTracksterToken.first; });
124  if (simTracksterMapTokenIter != layerClusterToSimTracksterMapTokens_.end()) {
125  iEvent.getByToken(simTracksterMapTokenIter->second, layerClusterToSimTracksterMapHandle);
126  }
127  const auto& layerClusterToSimTracksterMap = *layerClusterToSimTracksterMapHandle;
128 
129  // Create the association maps
130  auto tracksterToSimTracksterMap = std::make_unique<
132  recoTrackstersHandle, simTrackstersHandle, iEvent);
133  auto simTracksterToTracksterMap = std::make_unique<
135  simTrackstersHandle, recoTrackstersHandle, iEvent);
136 
137  for (unsigned int tracksterIndex = 0; tracksterIndex < recoTracksters.size(); ++tracksterIndex) {
138  const auto& recoTrackster = recoTracksters[tracksterIndex];
139  edm::Ref<std::vector<ticl::Trackster>> recoTracksterRef(recoTrackstersHandle, tracksterIndex);
140  const auto& layerClustersIds = recoTrackster.vertices();
141  float recoToSimScoresDenominator = 0.f;
142  ticl::mapWithFraction layerClusterToAssociatedSimTracksterMap(layerClustersIds.size());
143  std::vector<unsigned int> associatedSimTracksterIndices;
144  for (unsigned int i = 0; i < layerClustersIds.size(); ++i) {
145  unsigned int layerClusterId = layerClustersIds[i];
146  const auto& layerCluster = layerClusters[layerClusterId];
147  float recoFraction = 1.f / recoTrackster.vertex_multiplicity(i);
148  float squaredRecoFraction = recoFraction * recoFraction;
149  float squaredLayerClusterEnergy = layerCluster.energy() * layerCluster.energy();
150  recoToSimScoresDenominator += squaredLayerClusterEnergy * squaredRecoFraction;
151  const auto& simTracksterVec = layerClusterToSimTracksterMap[layerClusterId];
152  for (const auto& [simTracksterIndex, simSharedEnergy] : simTracksterVec) {
153  layerClusterToAssociatedSimTracksterMap[i].push_back({simTracksterIndex, simSharedEnergy});
154  associatedSimTracksterIndices.push_back(simTracksterIndex);
155  }
156  }
157 
158  // Keep only unique associatedSimTracksterIndices
159  std::sort(associatedSimTracksterIndices.begin(), associatedSimTracksterIndices.end());
160  associatedSimTracksterIndices.erase(
161  std::unique(associatedSimTracksterIndices.begin(), associatedSimTracksterIndices.end()),
162  associatedSimTracksterIndices.end());
163 
164  // Add missing sim tracksters with 0 shared energy to layerClusterToAssociatedSimTracksterMap
165  for (unsigned int i = 0; i < layerClustersIds.size(); ++i) {
166  unsigned int layerClusterId = layerClustersIds[i];
167  const auto& simTracksterVec = layerClusterToSimTracksterMap[layerClusterId];
168  for (unsigned int simTracksterIndex : associatedSimTracksterIndices) {
169  if (std::find_if(simTracksterVec.begin(), simTracksterVec.end(), [simTracksterIndex](const auto& pair) {
170  return pair.first == simTracksterIndex;
171  }) == simTracksterVec.end()) {
172  layerClusterToAssociatedSimTracksterMap[i].push_back({simTracksterIndex, 0.f});
173  }
174  }
175  }
176 
177  const float invDenominator = 1.f / recoToSimScoresDenominator;
178 
179  for (unsigned int i = 0; i < layerClustersIds.size(); ++i) {
180  unsigned int layerClusterId = layerClustersIds[i];
181  const auto& layerCluster = layerClusters[layerClusterId];
182  float recoFraction = 1.f / recoTrackster.vertex_multiplicity(i);
183  float squaredRecoFraction = recoFraction * recoFraction;
184  float squaredLayerClusterEnergy = layerCluster.energy() * layerCluster.energy();
185  float recoSharedEnergy = layerCluster.energy() * recoFraction;
186  float invLayerClusterEnergy = 1.f / layerCluster.energy();
187  const auto& simTracksterVec = layerClusterToAssociatedSimTracksterMap[i];
188  for (const auto& [simTracksterIndex, simSharedEnergy] : simTracksterVec) {
189  edm::Ref<std::vector<ticl::Trackster>> simTracksterRef(simTrackstersHandle, simTracksterIndex);
190  float sharedEnergy = std::min(simSharedEnergy, recoSharedEnergy);
191  float simFraction = simSharedEnergy * invLayerClusterEnergy;
192  float score = invDenominator *
193  std::min(squaredRecoFraction, (recoFraction - simFraction) * (recoFraction - simFraction)) *
194  squaredLayerClusterEnergy;
195  tracksterToSimTracksterMap->insert(recoTracksterRef, simTracksterRef, sharedEnergy, score);
196  }
197  }
198  }
199 
200  for (unsigned int tracksterIndex = 0; tracksterIndex < simTracksters.size(); ++tracksterIndex) {
201  const auto& simTrackster = simTracksters[tracksterIndex];
202  edm::Ref<std::vector<ticl::Trackster>> simTracksterRef(simTrackstersHandle, tracksterIndex);
203  const auto& layerClustersIds = simTrackster.vertices();
204  float simToRecoScoresDenominator = 0.f;
205  ticl::mapWithFraction layerClusterToAssociatedTracksterMap(layerClustersIds.size());
206  std::vector<unsigned int> associatedRecoTracksterIndices;
207  for (unsigned int i = 0; i < layerClustersIds.size(); ++i) {
208  unsigned int layerClusterId = layerClustersIds[i];
209  const auto& layerCluster = layerClusters[layerClusterId];
210  float simFraction = 1.f / simTrackster.vertex_multiplicity(i);
211  float squaredSimFraction = simFraction * simFraction;
212  float squaredLayerClusterEnergy = layerCluster.energy() * layerCluster.energy();
213  simToRecoScoresDenominator += squaredLayerClusterEnergy * squaredSimFraction;
214  const auto& recoTracksterVec = layerClusterToTracksterMap[layerClusterId];
215  for (const auto& [recoTracksterIndex, recoSharedEnergy] : recoTracksterVec) {
216  layerClusterToAssociatedTracksterMap[i].push_back({recoTracksterIndex, recoSharedEnergy});
217  associatedRecoTracksterIndices.push_back(recoTracksterIndex);
218  }
219  }
220  // keep only unique associatedRecoTracksterIndices
221  std::sort(associatedRecoTracksterIndices.begin(), associatedRecoTracksterIndices.end());
222  associatedRecoTracksterIndices.erase(
223  std::unique(associatedRecoTracksterIndices.begin(), associatedRecoTracksterIndices.end()),
224  associatedRecoTracksterIndices.end());
225  // for each layer cluster, loop over associatedRecoTracksterIndices and add the missing reco tracksters with 0 shared energy to layerClusterToAssociatedTracksterMap
226  for (unsigned int i = 0; i < layerClustersIds.size(); ++i) {
227  unsigned int layerClusterId = layerClustersIds[i];
228  const auto& recoTracksterVec = layerClusterToTracksterMap[layerClusterId];
229  for (unsigned int recoTracksterIndex : associatedRecoTracksterIndices) {
230  if (std::find_if(recoTracksterVec.begin(), recoTracksterVec.end(), [recoTracksterIndex](const auto& pair) {
231  return pair.first == recoTracksterIndex;
232  }) == recoTracksterVec.end()) {
233  layerClusterToAssociatedTracksterMap[i].push_back({recoTracksterIndex, 0.f});
234  }
235  }
236  }
237 
238  const float invDenominator = 1.f / simToRecoScoresDenominator;
239 
240  for (unsigned int i = 0; i < layerClustersIds.size(); ++i) {
241  unsigned int layerClusterId = layerClustersIds[i];
242  const auto& layerCluster = layerClusters[layerClusterId];
243  float simFraction = 1.f / simTrackster.vertex_multiplicity(i);
244  float squaredSimFraction = simFraction * simFraction;
245  float squaredLayerClusterEnergy = layerCluster.energy() * layerCluster.energy();
246  float simSharedEnergy = layerCluster.energy() * simFraction;
247  float invLayerClusterEnergy = 1.f / layerCluster.energy();
248  const auto& recoTracksterVec = layerClusterToAssociatedTracksterMap[i];
249  for (const auto& [recoTracksterIndex, recoSharedEnergy] : recoTracksterVec) {
250  edm::Ref<std::vector<ticl::Trackster>> recoTracksterRef(recoTrackstersHandle, recoTracksterIndex);
251  float sharedEnergy = std::min(recoSharedEnergy, simSharedEnergy);
252  float recoFraction = recoSharedEnergy * invLayerClusterEnergy;
253  float score = invDenominator *
254  std::min(squaredSimFraction, (simFraction - recoFraction) * (simFraction - recoFraction)) *
255  squaredLayerClusterEnergy;
256  simTracksterToTracksterMap->insert(tracksterIndex, recoTracksterIndex, sharedEnergy, score);
257  }
258  }
259  }
260  tracksterToSimTracksterMap->sort(true);
261  simTracksterToTracksterMap->sort(true);
262 
263  // After populating the maps, store them in the event
264  iEvent.put(std::move(tracksterToSimTracksterMap), tracksterToken.first + "To" + simTracksterToken.first);
265  iEvent.put(std::move(simTracksterToTracksterMap), simTracksterToken.first + "To" + tracksterToken.first);
266  }
267  }
268 }
std::vector< std::pair< std::string, edm::EDGetTokenT< std::vector< ticl::Trackster > > > > simTracksterCollectionTokens_
std::vector< std::pair< std::string, edm::EDGetTokenT< ticl::AssociationMap< ticl::mapWithFraction, std::vector< reco::CaloCluster >, std::vector< ticl::Trackster > > > > > layerClusterToTracksterMapTokens_
std::vector< std::vector< std::pair< unsigned int, float > >> mapWithFraction
int iEvent
Definition: GenABIO.cc:224
def unique(seq, keepstr=True)
Definition: tier0.py:24
std::vector< std::pair< std::string, edm::EDGetTokenT< ticl::AssociationMap< ticl::mapWithFraction, std::vector< reco::CaloCluster >, std::vector< ticl::Trackster > > > > > layerClusterToSimTracksterMapTokens_
float sharedEnergy(reco::CaloCluster const &clu1, reco::CaloCluster const &clu2, EcalRecHitCollection const &barrelRecHits, EcalRecHitCollection const &endcapRecHits)
HLT enums.
std::vector< std::pair< std::string, edm::EDGetTokenT< std::vector< ticl::Trackster > > > > tracksterCollectionTokens_
def move(src, dest)
Definition: eostools.py:511

Member Data Documentation

◆ layerClustersToken_

edm::EDGetTokenT<std::vector<reco::CaloCluster> > AllTracksterToSimTracksterAssociatorsByLCsProducer::layerClustersToken_
private

Definition at line 27 of file AllTracksterToSimTracksterAssociatorsByLCsProducer.cc.

Referenced by produce().

◆ layerClusterToSimTracksterMapTokens_

std::vector<std::pair< std::string, edm::EDGetTokenT< ticl::AssociationMap<ticl::mapWithFraction, std::vector<reco::CaloCluster>, std::vector<ticl::Trackster> > > > > AllTracksterToSimTracksterAssociatorsByLCsProducer::layerClusterToSimTracksterMapTokens_
private

◆ layerClusterToTracksterMapTokens_

std::vector<std::pair< std::string, edm::EDGetTokenT< ticl::AssociationMap<ticl::mapWithFraction, std::vector<reco::CaloCluster>, std::vector<ticl::Trackster> > > > > AllTracksterToSimTracksterAssociatorsByLCsProducer::layerClusterToTracksterMapTokens_
private

◆ simTracksterCollectionTokens_

std::vector<std::pair<std::string, edm::EDGetTokenT<std::vector<ticl::Trackster> > > > AllTracksterToSimTracksterAssociatorsByLCsProducer::simTracksterCollectionTokens_
private

◆ tracksterCollectionTokens_

std::vector<std::pair<std::string, edm::EDGetTokenT<std::vector<ticl::Trackster> > > > AllTracksterToSimTracksterAssociatorsByLCsProducer::tracksterCollectionTokens_
private