CMS 3D CMS Logo

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

Public Member Functions

 MuonBeamspotConstraintValueMapProducer (const edm::ParameterSet &config)
 
 ~MuonBeamspotConstraintValueMapProducer () 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 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
 
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 streamID, edm::Event &event, const edm::EventSetup &setup) const override
 

Private Attributes

edm::EDGetTokenT< reco::BeamSpotbeamSpotToken_
 
edm::EDGetTokenT< pat::MuonCollectionmuonToken_
 
edm::EDGetTokenT< reco::VertexCollectionPrimaryVertexToken_
 
SingleTrackVertexConstraint stvc
 
edm::ESGetToken< TransientTrackBuilder, TransientTrackRecordttbToken_
 

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

Compute muon pt and ptErr after beamspot constraint.

Definition at line 18 of file MuonBeamspotConstraintValueMapProducer.cc.

Constructor & Destructor Documentation

◆ MuonBeamspotConstraintValueMapProducer()

MuonBeamspotConstraintValueMapProducer::MuonBeamspotConstraintValueMapProducer ( const edm::ParameterSet config)
inlineexplicit

Definition at line 20 of file MuonBeamspotConstraintValueMapProducer.cc.

21  : muonToken_(consumes<pat::MuonCollection>(config.getParameter<edm::InputTag>("src"))),
22  beamSpotToken_(consumes<reco::BeamSpot>(config.getParameter<edm::InputTag>("beamspot"))),
23  PrimaryVertexToken_(consumes<reco::VertexCollection>(config.getParameter<edm::InputTag>("vertices"))),
24  ttbToken_(esConsumes(edm::ESInputTag("", "TransientTrackBuilder"))) {
25  produces<edm::ValueMap<float>>("muonBSConstrainedPt");
26  produces<edm::ValueMap<float>>("muonBSConstrainedPtErr");
27  produces<edm::ValueMap<float>>("muonBSConstrainedChi2");
28  }
edm::ESGetToken< TransientTrackBuilder, TransientTrackRecord > ttbToken_
Definition: config.py:1
edm::EDGetTokenT< reco::VertexCollection > PrimaryVertexToken_

◆ ~MuonBeamspotConstraintValueMapProducer()

MuonBeamspotConstraintValueMapProducer::~MuonBeamspotConstraintValueMapProducer ( )
overridedefault

Member Function Documentation

◆ fillDescriptions()

static void MuonBeamspotConstraintValueMapProducer::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
inlinestatic

Definition at line 32 of file MuonBeamspotConstraintValueMapProducer.cc.

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

32  {
34  desc.add<edm::InputTag>("src", edm::InputTag("muons"))->setComment("Muon collection");
35  desc.add<edm::InputTag>("beamspot", edm::InputTag("offlineBeamSpot"))->setComment("Beam spot collection");
36  desc.add<edm::InputTag>("vertices", edm::InputTag("offlineSlimmedPrimaryVertices"))
37  ->setComment("Primary vertex collection");
38 
39  descriptions.addWithDefaultLabel(desc);
40  }
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)

◆ produce()

void MuonBeamspotConstraintValueMapProducer::produce ( edm::StreamID  streamID,
edm::Event event,
const edm::EventSetup setup 
) const
inlineoverrideprivatevirtual

Implements edm::global::EDProducerBase.

Definition at line 43 of file MuonBeamspotConstraintValueMapProducer.cc.

References beamSpotToken_, reco::BeamSpot::BeamWidthX(), reco::BeamSpot::BeamWidthXError(), reco::BeamSpot::BeamWidthY(), reco::BeamSpot::BeamWidthYError(), TransientTrackBuilder::build(), SingleTrackVertexConstraint::constrain(), f, trigObjTnPSource_cfi::filler, edm::HandleBase::isValid(), eostools::move(), DiMuonV_cfg::muons, muonToken_, PrimaryVertexToken_, reco::TrackBase::pt(), reco::TrackBase::ptError(), RPCpg::pts, FSQDQM_cfi::pvs, singleTopDQM_cfi::setup, stvc, HLT_2024v12_cff::track, and ttbToken_.

43  {
45  event.getByToken(muonToken_, muons);
46 
47  edm::Handle<reco::BeamSpot> beamSpotHandle;
48  event.getByToken(beamSpotToken_, beamSpotHandle);
49 
51 
52  std::vector<float> pts, ptErrs, chi2s;
53  pts.reserve(muons->size());
54  ptErrs.reserve(muons->size());
55  chi2s.reserve(muons->size());
56 
57  for (const auto& muon : *muons) {
58  bool tbd = true;
59  if (beamSpotHandle.isValid()) {
60  double BeamWidthX = beamSpotHandle->BeamWidthX();
61  double BeamWidthXError = beamSpotHandle->BeamWidthXError();
62  double BeamWidthY = beamSpotHandle->BeamWidthY();
63  double BeamWidthYError = beamSpotHandle->BeamWidthYError();
64  // Protect for mis-reconstructed beamspots (note that
65  // SingleTrackVertexConstraint uses the width for the constraint,
66  // not the error)
67  if ((BeamWidthXError / BeamWidthX < 0.3) && (BeamWidthYError / BeamWidthY < 0.3)) {
69  stvc.constrain(ttkb->build(muon.muonBestTrack()), *beamSpotHandle);
70  if (std::get<0>(btft)) {
71  const reco::Track& trkBS = std::get<1>(btft).track();
72  pts.push_back(trkBS.pt());
73  ptErrs.push_back(trkBS.ptError());
74  chi2s.push_back(std::get<2>(btft));
75  tbd = false;
76  }
77  }
78  }
79 
80  if (tbd) {
81  // Invalid BS; use PV instead
83  event.getByToken(PrimaryVertexToken_, pvHandle);
84 
85  if (pvHandle.isValid() && !pvHandle->empty()) {
86  auto pv = pvHandle->at(0);
88 
89  SingleTrackVertexConstraint::BTFtuple btft = stvc.constrain(ttkb->build(muon.muonBestTrack()), pvs);
90  if (std::get<0>(btft)) {
91  const reco::Track& trkBS = std::get<1>(btft).track();
92  pts.push_back(trkBS.pt());
93  ptErrs.push_back(trkBS.ptError());
94  chi2s.push_back(std::get<2>(btft));
95  tbd = false;
96  }
97  }
98  }
99 
100  if (tbd) {
101  // Fall-back case, keep the unconstrained values
102  pts.push_back(muon.pt());
103  ptErrs.push_back(muon.bestTrack()->ptError());
104  chi2s.push_back(-1.f);
105  }
106  }
107 
108  {
109  std::unique_ptr<edm::ValueMap<float>> valueMap(new edm::ValueMap<float>());
111  filler.insert(muons, pts.begin(), pts.end());
112  filler.fill();
113  event.put(std::move(valueMap), "muonBSConstrainedPt");
114  }
115 
116  {
117  std::unique_ptr<edm::ValueMap<float>> valueMap(new edm::ValueMap<float>());
119  filler.insert(muons, ptErrs.begin(), ptErrs.end());
120  filler.fill();
121  event.put(std::move(valueMap), "muonBSConstrainedPtErr");
122  }
123 
124  {
125  std::unique_ptr<edm::ValueMap<float>> valueMap(new edm::ValueMap<float>());
127  filler.insert(muons, chi2s.begin(), chi2s.end());
128  filler.fill();
129  event.put(std::move(valueMap), "muonBSConstrainedChi2");
130  }
131  }
double BeamWidthX() const
beam width X
Definition: BeamSpot.h:82
double BeamWidthYError() const
error on beam width Y, assume error in X = Y
Definition: BeamSpot.h:101
double ptError() const
error on Pt (set to 1000 TeV if charge==0 for safety)
Definition: TrackBase.h:754
std::tuple< bool, reco::TransientTrack, float > BTFtuple
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
GlobalErrorBase< double, ErrorMatrixTag > GlobalError
Definition: GlobalError.h:13
edm::ESGetToken< TransientTrackBuilder, TransientTrackRecord > ttbToken_
muons
the two sets of parameters below are mutually exclusive, depending if RECO or ALCARECO is used the us...
Definition: DiMuonV_cfg.py:214
BTFtuple constrain(const reco::TransientTrack &track, const GlobalPoint &priorPos, const GlobalError &priorError) const
reco::TransientTrack build(const reco::Track *p) const
static const double pts[33]
Definition: Constants.h:30
double pt() const
track transverse momentum
Definition: TrackBase.h:637
double BeamWidthY() const
beam width Y
Definition: BeamSpot.h:84
double f[11][100]
double BeamWidthXError() const
error on beam width X, assume error in X = Y
Definition: BeamSpot.h:99
bool isValid() const
Definition: HandleBase.h:70
edm::EDGetTokenT< reco::VertexCollection > PrimaryVertexToken_
def move(src, dest)
Definition: eostools.py:511

Member Data Documentation

◆ beamSpotToken_

edm::EDGetTokenT<reco::BeamSpot> MuonBeamspotConstraintValueMapProducer::beamSpotToken_
private

Definition at line 134 of file MuonBeamspotConstraintValueMapProducer.cc.

Referenced by produce().

◆ muonToken_

edm::EDGetTokenT<pat::MuonCollection> MuonBeamspotConstraintValueMapProducer::muonToken_
private

Definition at line 133 of file MuonBeamspotConstraintValueMapProducer.cc.

Referenced by produce().

◆ PrimaryVertexToken_

edm::EDGetTokenT<reco::VertexCollection> MuonBeamspotConstraintValueMapProducer::PrimaryVertexToken_
private

Definition at line 135 of file MuonBeamspotConstraintValueMapProducer.cc.

Referenced by produce().

◆ stvc

SingleTrackVertexConstraint MuonBeamspotConstraintValueMapProducer::stvc
private

Definition at line 137 of file MuonBeamspotConstraintValueMapProducer.cc.

Referenced by produce().

◆ ttbToken_

edm::ESGetToken<TransientTrackBuilder, TransientTrackRecord> MuonBeamspotConstraintValueMapProducer::ttbToken_
private

Definition at line 136 of file MuonBeamspotConstraintValueMapProducer.cc.

Referenced by produce().