CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Types | Private Member Functions | Private Attributes
TPStubValueMapProducer Class Reference

#include <L1Trigger/VertexFinder/plugins/TPStubValueMapProducer.cc>

Inheritance diagram for TPStubValueMapProducer:
edm::global::EDProducer<> edm::global::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 TPStubValueMapProducer (const edm::ParameterSet &)
 
 ~TPStubValueMapProducer () override
 
- 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 Types

typedef edmNew::DetSet< TTStub< Ref_Phase2TrackerDigi_ > > DetSet
 
typedef edmNew::DetSetVector< TTStub< Ref_Phase2TrackerDigi_ > > DetSetVec
 
typedef edm::Ptr< TrackingParticleTrackingParticlePtr
 
typedef TTClusterAssociationMap< Ref_Phase2TrackerDigi_TTClusterAssMap
 
typedef TTStubAssociationMap< Ref_Phase2TrackerDigi_TTStubAssMap
 
typedef edm::Ref< DetSetVec, TTStub< Ref_Phase2TrackerDigi_ > > TTStubRef
 
typedef TTTrackAssociationMap< Ref_Phase2TrackerDigi_TTTrackAssMap
 

Private Member Functions

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

Private Attributes

const edm::EDGetTokenT< TTClusterAssMapclusterTruthToken_
 
edm::EDGetTokenT< TTTrackAssociationMap< Ref_Phase2TrackerDigi_ > > l1TracksMapToken_
 
const std::vector< std::string > outputCollectionNames_
 
l1tVertexFinder::AnalysisSettings settings_
 
const edm::EDGetTokenT< DetSetVecstubToken_
 
const edm::EDGetTokenT< TTStubAssMapstubTruthToken_
 
edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecordtGeomToken_
 
const edm::EDGetTokenT< TrackingParticleCollectiontpToken_
 
edm::ESGetToken< TrackerTopology, TrackerTopologyRcdtTopoToken_
 

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

Description: Produces an two value maps

Implementation: [Notes on implementation]

Definition at line 53 of file TPStubValueMapProducer.cc.

Member Typedef Documentation

◆ DetSet

Definition at line 65 of file TPStubValueMapProducer.cc.

◆ DetSetVec

Definition at line 66 of file TPStubValueMapProducer.cc.

◆ TrackingParticlePtr

Definition at line 64 of file TPStubValueMapProducer.cc.

◆ TTClusterAssMap

Definition at line 69 of file TPStubValueMapProducer.cc.

◆ TTStubAssMap

Definition at line 68 of file TPStubValueMapProducer.cc.

◆ TTStubRef

Definition at line 67 of file TPStubValueMapProducer.cc.

◆ TTTrackAssMap

Definition at line 70 of file TPStubValueMapProducer.cc.

Constructor & Destructor Documentation

◆ TPStubValueMapProducer()

TPStubValueMapProducer::TPStubValueMapProducer ( const edm::ParameterSet iConfig)
explicit

Definition at line 87 of file TPStubValueMapProducer.cc.

References outputCollectionNames_.

88  : outputCollectionNames_(iConfig.getParameter<std::vector<std::string>>("outputCollectionNames")),
89  settings_(iConfig),
90  l1TracksMapToken_(consumes<TTTrackAssMap>(iConfig.getParameter<edm::InputTag>("l1TracksTruthMapInputTags"))),
91  tpToken_(consumes<TrackingParticleCollection>(iConfig.getParameter<edm::InputTag>("tpInputTag"))),
92  stubToken_(consumes<DetSetVec>(iConfig.getParameter<edm::InputTag>("stubInputTag"))),
93  stubTruthToken_(consumes<TTStubAssMap>(iConfig.getParameter<edm::InputTag>("stubTruthInputTag"))),
94  clusterTruthToken_(consumes<TTClusterAssMap>(iConfig.getParameter<edm::InputTag>("clusterTruthInputTag"))),
95  tTopoToken_(esConsumes<TrackerTopology, TrackerTopologyRcd>(edm::ESInputTag("", ""))),
96  tGeomToken_(esConsumes<TrackerGeometry, TrackerDigiGeometryRecord>(edm::ESInputTag("", ""))) {
97  // Define EDM output to be written to file (if required)
98  produces<TrackingParticleCollection>();
99  produces<edm::ValueMap<l1tVertexFinder::TP>>(outputCollectionNames_[0]);
100  produces<edm::ValueMap<l1tVertexFinder::TP>>(outputCollectionNames_[1]);
101  produces<std::vector<l1tVertexFinder::TP>>(outputCollectionNames_[2]);
102 }
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
const edm::EDGetTokenT< TTStubAssMap > stubTruthToken_
edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > tTopoToken_
edm::EDGetTokenT< TTTrackAssociationMap< Ref_Phase2TrackerDigi_ > > l1TracksMapToken_
const edm::EDGetTokenT< TrackingParticleCollection > tpToken_
l1tVertexFinder::AnalysisSettings settings_
const edm::EDGetTokenT< DetSetVec > stubToken_
edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord > tGeomToken_
const std::vector< std::string > outputCollectionNames_
const edm::EDGetTokenT< TTClusterAssMap > clusterTruthToken_

◆ ~TPStubValueMapProducer()

TPStubValueMapProducer::~TPStubValueMapProducer ( )
override

Definition at line 104 of file TPStubValueMapProducer.cc.

104 {}

Member Function Documentation

◆ fillDescriptions()

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

Definition at line 211 of file TPStubValueMapProducer.cc.

References edm::ConfigurationDescriptions::addDefault(), and submitPVResolutionJobs::desc.

211  {
212  //The following says we do not know what parameters are allowed so do no validation
213  // Please change this to state exactly what you do use, even if it is no parameters
215  desc.setUnknown();
216  descriptions.addDefault(desc);
217 }
void addDefault(ParameterSetDescription const &psetDescription)

◆ produce()

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

Implements edm::global::EDProducerBase.

Definition at line 111 of file TPStubValueMapProducer.cc.

References cms::cuda::assert(), edmNew::DetSetVector< T >::begin(), clusterTruthToken_, edmNew::DetSetVector< T >::end(), mps_splice::entry, l1tVertexFinder::Stub::fillTruth(), edm::EventSetup::getData(), mps_fire::i, iEvent, l1TracksMapToken_, edmNew::makeRefTo(), eostools::move(), outputCollectionNames_, edm::second(), settings_, edmNew::DetSetVector< T >::size(), stubToken_, stubTruthToken_, tGeomToken_, cmsswSequenceInfo::tp, tpToken_, and tTopoToken_.

111  {
112  auto vTrackingParticles = std::make_unique<TrackingParticleCollection>();
113 
114  edm::Handle<TTTrackAssMap> mcTruthTTTrackHandle;
116  edm::Handle<DetSetVec> ttStubHandle;
117  edm::Handle<TTStubAssMap> mcTruthTTStubHandle;
118  edm::Handle<TTClusterAssMap> mcTruthTTClusterHandle;
119  iEvent.getByToken(l1TracksMapToken_, mcTruthTTTrackHandle);
120  iEvent.getByToken(tpToken_, tpHandle);
121  iEvent.getByToken(stubToken_, ttStubHandle);
122  iEvent.getByToken(stubTruthToken_, mcTruthTTStubHandle);
123  iEvent.getByToken(clusterTruthToken_, mcTruthTTClusterHandle);
124 
125  // Produce the vector of TP for the edm::Ref<TrackingParticle>->TP value map
126  unsigned int nTP = tpHandle->size();
127  auto vTPs = std::make_unique<std::vector<l1tVertexFinder::TP>>();
128  auto vTPsUse = std::make_unique<std::vector<l1tVertexFinder::TP>>();
129  vTPs->reserve(nTP);
130  vTPsUse->reserve(nTP);
131  std::set<edm::Ptr<TrackingParticle>> sTPs;
132  for (unsigned int i = 0; i < nTP; i++) {
133  TrackingParticlePtr tpPtr(tpHandle, i);
134  // Store the TrackingParticle info, using class TP to provide easy access to the most useful info.
136  // Only bother storing tp if it could be useful for tracking efficiency or fake rate measurements.
137  // Also create map relating edm::Ptr<TrackingParticle> to TP.
138  if (tp.use()) {
139  vTrackingParticles->push_back(tpHandle->at(i));
140  vTPsUse->push_back(tp);
141  sTPs.insert(tpPtr);
142  }
143  vTPs->push_back(tp);
144  }
145 
146  auto vAllMatchedTPs = std::make_unique<std::vector<l1tVertexFinder::TP>>(*vTPsUse);
147  for (auto& entry : mcTruthTTTrackHandle->getTTTrackToTrackingParticleMap()) {
148  if (sTPs.count(entry.second) == 0) {
149  vAllMatchedTPs->push_back(l1tVertexFinder::TP(entry.second, settings_));
150  }
151  }
152 
153  // Get the tracker geometry info needed to unpack the stub info.
154  const TrackerTopology& tTopo = iSetup.getData(tTopoToken_);
155  const TrackerGeometry& tGeom = iSetup.getData(tGeomToken_);
156 
157  const TrackerTopology* tTopology = &tTopo;
158  const TrackerGeometry* tGeometry = &tGeom;
159 
160  //Create the vector of Stub for the TTStubRef->Stub value map
161  unsigned int nStubs = ttStubHandle->size();
162  auto vAllStubs = std::make_unique<std::vector<l1tVertexFinder::Stub>>();
163  vAllStubs->reserve(nStubs);
164  for (DetSetVec::const_iterator p_module = ttStubHandle->begin(); p_module != ttStubHandle->end(); p_module++) {
165  for (DetSet::const_iterator p_ttstub = p_module->begin(); p_ttstub != p_module->end(); p_ttstub++) {
166  TTStubRef ttStubRef = edmNew::makeRefTo(ttStubHandle, p_ttstub);
167  // Store the Stub info, using class Stub to provide easy access to the most useful info.
168  l1tVertexFinder::Stub stub(ttStubRef, settings_, tGeometry, tTopology);
169  // Also fill truth associating stubs to tracking particles.
170  stub.fillTruth(mcTruthTTStubHandle, mcTruthTTClusterHandle);
171  vAllStubs->push_back(stub);
172  }
173  }
174 
175  //Set the Stubs associate to each TP
176  std::map<const TrackingParticlePtr, std::vector<l1tVertexFinder::Stub>> tpStubMap;
177  for (const l1tVertexFinder::TP& tp : *vTPs)
178  tpStubMap[tp.getTrackingParticle()] = std::vector<l1tVertexFinder::Stub>();
179  for (const l1tVertexFinder::Stub& stub : *vAllStubs) {
180  for (const TrackingParticlePtr& tp : stub.assocTPs()) {
181  tpStubMap[tp].push_back(stub);
182  }
183  }
184  for (l1tVertexFinder::TP& tp : *vTPs) {
185  assert(tpStubMap.count(tp.getTrackingParticle()) == 1);
186  tp.setMatchingStubs(tpStubMap.find(tp.getTrackingParticle())->second);
187  }
188 
189  //Put the products into the event
190  // Modeled after: https://github.com/cms-sw/cmssw/blob/master/PhysicsTools/SelectorUtils/interface/VersionedIdProducer.h
191 
192  // Collections of products
193  auto vTrackingParticlesHandle = iEvent.put(std::move(vTrackingParticles));
194  auto vAllMatchedTPsHandle = iEvent.put(std::move(vAllMatchedTPs), outputCollectionNames_[2]);
195 
196  // Value maps to TP/Stub
197  auto TPV = std::make_unique<edm::ValueMap<l1tVertexFinder::TP>>();
199  fillerTP.insert(tpHandle, vTPs->begin(), vTPs->end());
200  fillerTP.fill();
202 
203  auto TPuseV = std::make_unique<edm::ValueMap<l1tVertexFinder::TP>>();
204  edm::ValueMap<l1tVertexFinder::TP>::Filler fillerTPuse(*TPuseV);
205  fillerTPuse.insert(vTrackingParticlesHandle, vTPsUse->begin(), vTPsUse->end());
206  fillerTPuse.fill();
207  iEvent.put(std::move(TPuseV), outputCollectionNames_[1]);
208 }
edm::Ref< typename HandleT::element_type, typename HandleT::element_type::value_type::value_type > makeRefTo(const HandleT &iHandle, typename HandleT::element_type::value_type::const_iterator itIter)
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
Definition: EventSetup.h:119
const edm::EDGetTokenT< TTStubAssMap > stubTruthToken_
edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > tTopoToken_
data_type const * const_iterator
Definition: DetSetNew.h:31
assert(be >=bs)
edm::EDGetTokenT< TTTrackAssociationMap< Ref_Phase2TrackerDigi_ > > l1TracksMapToken_
const edm::EDGetTokenT< TrackingParticleCollection > tpToken_
const_iterator end(bool update=false) const
l1tVertexFinder::AnalysisSettings settings_
U second(std::pair< T, U > const &p)
int iEvent
Definition: GenABIO.cc:224
const edm::EDGetTokenT< DetSetVec > stubToken_
boost::transform_iterator< IterHelp, const_IdIter > const_iterator
const_iterator begin(bool update=false) const
size_type size() const
edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord > tGeomToken_
const std::vector< std::string > outputCollectionNames_
def move(src, dest)
Definition: eostools.py:511
const edm::EDGetTokenT< TTClusterAssMap > clusterTruthToken_

Member Data Documentation

◆ clusterTruthToken_

const edm::EDGetTokenT<TTClusterAssMap> TPStubValueMapProducer::clusterTruthToken_
private

Definition at line 79 of file TPStubValueMapProducer.cc.

Referenced by produce().

◆ l1TracksMapToken_

edm::EDGetTokenT<TTTrackAssociationMap<Ref_Phase2TrackerDigi_> > TPStubValueMapProducer::l1TracksMapToken_
private

Definition at line 75 of file TPStubValueMapProducer.cc.

Referenced by produce().

◆ outputCollectionNames_

const std::vector<std::string> TPStubValueMapProducer::outputCollectionNames_
private

Definition at line 73 of file TPStubValueMapProducer.cc.

Referenced by produce(), and TPStubValueMapProducer().

◆ settings_

l1tVertexFinder::AnalysisSettings TPStubValueMapProducer::settings_
private

Definition at line 74 of file TPStubValueMapProducer.cc.

Referenced by produce().

◆ stubToken_

const edm::EDGetTokenT<DetSetVec> TPStubValueMapProducer::stubToken_
private

Definition at line 77 of file TPStubValueMapProducer.cc.

Referenced by produce().

◆ stubTruthToken_

const edm::EDGetTokenT<TTStubAssMap> TPStubValueMapProducer::stubTruthToken_
private

Definition at line 78 of file TPStubValueMapProducer.cc.

Referenced by produce().

◆ tGeomToken_

edm::ESGetToken<TrackerGeometry, TrackerDigiGeometryRecord> TPStubValueMapProducer::tGeomToken_
private

Definition at line 81 of file TPStubValueMapProducer.cc.

Referenced by produce().

◆ tpToken_

const edm::EDGetTokenT<TrackingParticleCollection> TPStubValueMapProducer::tpToken_
private

Definition at line 76 of file TPStubValueMapProducer.cc.

Referenced by produce().

◆ tTopoToken_

edm::ESGetToken<TrackerTopology, TrackerTopologyRcd> TPStubValueMapProducer::tTopoToken_
private

Definition at line 80 of file TPStubValueMapProducer.cc.

Referenced by produce().