CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 final
 
bool wantsGlobalRuns () const final
 
bool wantsInputProcessBlocks () const final
 
bool wantsProcessBlocks () const final
 
bool wantsStreamLuminosityBlocks () const final
 
bool wantsStreamRuns () const 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
 
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)
 
 ~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
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESProxyIndex > 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
 
bool registeredToConsumeMany (TypeID const &, 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::ESRecordsToProxyIndices 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
< TrackingParticle
TrackingParticlePtr
 
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
< TTClusterAssMap
clusterTruthToken_
 
edm::EDGetTokenT
< TTTrackAssociationMap
< Ref_Phase2TrackerDigi_ > > 
l1TracksMapToken_
 
const std::vector< std::string > outputCollectionNames_
 
l1tVertexFinder::AnalysisSettings settings_
 
const edm::EDGetTokenT< DetSetVecstubToken_
 
const edm::EDGetTokenT
< TTStubAssMap
stubTruthToken_
 
edm::ESGetToken
< TrackerGeometry,
TrackerDigiGeometryRecord
tGeomToken_
 
const edm::EDGetTokenT
< TrackingParticleCollection
tpToken_
 
edm::ESGetToken
< TrackerTopology,
TrackerTopologyRcd
tTopoToken_
 

Additional Inherited Members

- Public Types inherited from edm::global::EDProducerBase
typedef EDProducerBase ModuleType
 
- Public Types inherited from edm::ProducerBase
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
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 ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
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

Definition at line 65 of file TPStubValueMapProducer.cc.

Definition at line 66 of file TPStubValueMapProducer.cc.

Definition at line 64 of file TPStubValueMapProducer.cc.

Definition at line 69 of file TPStubValueMapProducer.cc.

Definition at line 68 of file TPStubValueMapProducer.cc.

Definition at line 67 of file TPStubValueMapProducer.cc.

Definition at line 70 of file TPStubValueMapProducer.cc.

Constructor & Destructor Documentation

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

Definition at line 88 of file TPStubValueMapProducer.cc.

References outputCollectionNames_.

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

Definition at line 105 of file TPStubValueMapProducer.cc.

105 {}

Member Function Documentation

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

Definition at line 212 of file TPStubValueMapProducer.cc.

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

212  {
213  //The following says we do not know what parameters are allowed so do no validation
214  // Please change this to state exactly what you do use, even if it is no parameters
216  desc.setUnknown();
217  descriptions.addDefault(desc);
218 }
void addDefault(ParameterSetDescription const &psetDescription)
void TPStubValueMapProducer::produce ( edm::StreamID  ,
edm::Event iEvent,
const edm::EventSetup iSetup 
) const
overrideprivatevirtual

Implements edm::global::EDProducerBase.

Definition at line 112 of file TPStubValueMapProducer.cc.

References cms::cuda::assert(), clusterTruthToken_, mps_splice::entry, l1tVertexFinder::Stub::fillTruth(), edm::Event::getByToken(), edm::EventSetup::getData(), mps_fire::i, l1TracksMapToken_, edmNew::makeRefTo(), eostools::move(), outputCollectionNames_, edm::Event::put(), edm::second(), settings_, stubToken_, stubTruthToken_, tGeomToken_, cmsswSequenceInfo::tp, tpToken_, tTopoToken_, and l1tVertexFinder::TP::use().

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

Member Data Documentation

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

Definition at line 79 of file TPStubValueMapProducer.cc.

Referenced by produce().

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

Definition at line 75 of file TPStubValueMapProducer.cc.

Referenced by produce().

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

Definition at line 73 of file TPStubValueMapProducer.cc.

Referenced by produce(), and TPStubValueMapProducer().

l1tVertexFinder::AnalysisSettings TPStubValueMapProducer::settings_
private

Definition at line 74 of file TPStubValueMapProducer.cc.

Referenced by produce().

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

Definition at line 77 of file TPStubValueMapProducer.cc.

Referenced by produce().

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

Definition at line 78 of file TPStubValueMapProducer.cc.

Referenced by produce().

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

Definition at line 82 of file TPStubValueMapProducer.cc.

Referenced by produce().

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

Definition at line 76 of file TPStubValueMapProducer.cc.

Referenced by produce().

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

Definition at line 81 of file TPStubValueMapProducer.cc.

Referenced by produce().