CMS 3D CMS Logo

HLTL1MuonMatcher.cc
Go to the documentation of this file.
1 //
2 //
3 
15 
18 
23 
26 
28 
30 
31 namespace pat {
32 
34  public:
35  explicit HLTL1MuonMatcher(const edm::ParameterSet &iConfig);
36  ~HLTL1MuonMatcher() override {}
37 
38  void produce(edm::Event &iEvent, const edm::EventSetup &iSetup) override;
39 
40  void beginRun(const edm::Run &iRun, const edm::EventSetup &iSetup) override;
41 
43  bool operator()(const pat::TriggerObjectStandAlone &l1) const {
44  if (resolveAmbiguities_ && (std::find(lockedItems_.begin(), lockedItems_.end(), &l1) != lockedItems_.end()))
45  return false;
46  return selector_(l1);
47  }
48 
49  private:
53 
55 
59 
63 
66 
69 
71  template <typename Hand, typename T>
73  const Hand &handle,
74  const std::vector<T> &values,
75  const std::string &label) const;
76 
77  // for ambiguity resolution
78  std::vector<const pat::TriggerObjectStandAlone *> lockedItems_;
79  };
80 
81 } // namespace pat
82 
84  : matcher_(iConfig),
85  recoToken_(consumes<edm::View<reco::Candidate> >(iConfig.getParameter<edm::InputTag>("src"))),
86  l1Token_(consumes<PATPrimitiveCollection>(iConfig.getParameter<edm::InputTag>("matched"))),
87  selector_{iConfig.getParameter<std::string>("matchedCuts")},
88  resolveAmbiguities_(iConfig.getParameter<bool>("resolveAmbiguities")),
89  labelProp_(iConfig.getParameter<std::string>("setPropLabel")),
90  writeExtraInfo_(iConfig.existsAs<bool>("writeExtraInfo") ? iConfig.getParameter<bool>("writeExtraInfo") : false) {
91  produces<PATPrimitiveCollection>("propagatedReco"); // reco to muon station 2
92  produces<PATTriggerAssociation>("propagatedReco"); // asso reco to propagated reco
93  produces<PATTriggerAssociation>(); // asso reco to l1
94  if (writeExtraInfo_) {
95  produces<edm::ValueMap<float> >("deltaR");
96  produces<edm::ValueMap<float> >("deltaPhi");
97  }
98 }
99 
101  using namespace edm;
102  using namespace std;
103 
106 
107  iEvent.getByToken(recoToken_, reco);
108  iEvent.getByToken(l1Token_, l1s);
109 
110  unique_ptr<PATPrimitiveCollection> propOut(new PATPrimitiveCollection());
111  vector<int> propMatches(reco->size(), -1);
112  vector<int> fullMatches(reco->size(), -1);
113  vector<float> deltaRs(reco->size(), 999), deltaPhis(reco->size(), 999);
114  lockedItems_.clear();
115  for (int i = 0, n = reco->size(); i < n; ++i) {
116  TrajectoryStateOnSurface propagated;
117  const reco::Candidate &mu = (*reco)[i];
118  int match = matcher_.matchGeneric(mu, *l1s, *this, deltaRs[i], deltaPhis[i], propagated);
119  if (propagated.isValid()) {
120  GlobalPoint pos = propagated.globalPosition();
121  propMatches[i] = propOut->size();
122  propOut->push_back(PATPrimitive(math::PtEtaPhiMLorentzVector(mu.pt(), pos.eta(), pos.phi(), mu.mass())));
123  propOut->back().addFilterLabel(labelProp_);
124  propOut->back().setCharge(mu.charge());
125  }
126  fullMatches[i] = match;
127  if (match != -1) {
128  lockedItems_.push_back(&(*l1s)[match]);
129  }
130  }
131  lockedItems_.clear();
132 
133  OrphanHandle<PATPrimitiveCollection> propDone = iEvent.put(std::move(propOut), "propagatedReco");
134 
135  unique_ptr<PATTriggerAssociation> propAss(new PATTriggerAssociation(propDone));
136  PATTriggerAssociation::Filler propFiller(*propAss);
137  propFiller.insert(reco, propMatches.begin(), propMatches.end());
138  propFiller.fill();
139  iEvent.put(std::move(propAss), "propagatedReco");
140 
141  unique_ptr<PATTriggerAssociation> fullAss(new PATTriggerAssociation(l1s));
142  PATTriggerAssociation::Filler fullFiller(*fullAss);
143  fullFiller.insert(reco, fullMatches.begin(), fullMatches.end());
144  fullFiller.fill();
145  iEvent.put(std::move(fullAss));
146 
147  if (writeExtraInfo_) {
148  storeExtraInfo(iEvent, reco, deltaRs, "deltaR");
149  storeExtraInfo(iEvent, reco, deltaPhis, "deltaPhi");
150  }
151 }
152 
153 template <typename Hand, typename T>
155  const Hand &handle,
156  const std::vector<T> &values,
157  const std::string &label) const {
158  using namespace edm;
159  using namespace std;
160  unique_ptr<ValueMap<T> > valMap(new ValueMap<T>());
161  typename edm::ValueMap<T>::Filler filler(*valMap);
162  filler.insert(handle, values.begin(), values.end());
163  filler.fill();
164  iEvent.put(std::move(valMap), label);
165 }
166 
167 void pat::HLTL1MuonMatcher::beginRun(const edm::Run &iRun, const edm::EventSetup &iSetup) { matcher_.init(iSetup); }
168 
170 using namespace pat;
pat::HLTL1MuonMatcher::PATTriggerAssociation
pat::TriggerObjectStandAloneMatch PATTriggerAssociation
Definition: HLTL1MuonMatcher.cc:52
edm::helper::Filler::insert
void insert(const H &h, I begin, I end)
Definition: ValueMap.h:53
mps_fire.i
i
Definition: mps_fire.py:428
MessageLogger.h
edm::Association::Filler
Definition: Association.h:78
dqmiodumpmetadata.n
n
Definition: dqmiodumpmetadata.py:28
configurableAnalysis::Candidate
char Candidate[]
Definition: modules.cc:20
EDProducer.h
sistrip::View
View
Definition: ConstantsForView.h:26
amptDefaultParameters_cff.mu
mu
Definition: amptDefaultParameters_cff.py:16
patZpeak.handle
handle
Definition: patZpeak.py:23
edm::Run
Definition: Run.h:45
deltaPhi.h
pat::TriggerObjectStandAlone
Analysis-level trigger object class (stand-alone)
Definition: TriggerObjectStandAlone.h:32
edm::EDGetTokenT
Definition: EDGetToken.h:33
edm
HLT enums.
Definition: AlignableModifier.h:19
TrajectoryStateOnSurface::globalPosition
GlobalPoint globalPosition() const
Definition: TrajectoryStateOnSurface.h:65
pos
Definition: PixelAliasList.h:18
pat::HLTL1MuonMatcher::produce
void produce(edm::Event &iEvent, const edm::EventSetup &iSetup) override
Definition: HLTL1MuonMatcher.cc:100
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89301
edm::helper::Filler::fill
void fill()
Definition: ValueMap.h:65
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:46
Association.h
spr::find
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
edm::Handle
Definition: AssociativeIterator.h:50
pat::HLTL1MuonMatcher::~HLTL1MuonMatcher
~HLTL1MuonMatcher() override
Definition: HLTL1MuonMatcher.cc:36
pat::HLTL1MuonMatcher::matcher_
L1MuonMatcherAlgo matcher_
Definition: HLTL1MuonMatcher.cc:54
TrajectoryStateOnSurface
Definition: TrajectoryStateOnSurface.h:16
MakerMacros.h
L1Scalers_cfi.l1s
l1s
Definition: L1Scalers_cfi.py:5
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
pat::HLTL1MuonMatcher::lockedItems_
std::vector< const pat::TriggerObjectStandAlone * > lockedItems_
Definition: HLTL1MuonMatcher.cc:78
pat::HLTL1MuonMatcher
Definition: HLTL1MuonMatcher.cc:33
pat::HLTL1MuonMatcher::recoToken_
edm::EDGetTokenT< edm::View< reco::Candidate > > recoToken_
Tokens for input collections.
Definition: HLTL1MuonMatcher.cc:57
contentValuesCheck.values
values
Definition: contentValuesCheck.py:38
pat::HLTL1MuonMatcher::PATPrimitiveCollection
pat::TriggerObjectStandAloneCollection PATPrimitiveCollection
Definition: HLTL1MuonMatcher.cc:51
L1MuonMatcherAlgo.h
Point3DBase< float, GlobalTag >
pat::HLTL1MuonMatcher::storeExtraInfo
void storeExtraInfo(edm::Event &iEvent, const Hand &handle, const std::vector< T > &values, const std::string &label) const
Store extra information in a ValueMap.
Definition: HLTL1MuonMatcher.cc:154
pat::HLTL1MuonMatcher::PATPrimitive
pat::TriggerObjectStandAlone PATPrimitive
Definition: HLTL1MuonMatcher.cc:50
pat::HLTL1MuonMatcher::resolveAmbiguities_
bool resolveAmbiguities_
Definition: HLTL1MuonMatcher.cc:62
edm::ParameterSet
Definition: ParameterSet.h:47
Event.h
deltaR.h
trigObjTnPSource_cfi.filler
filler
Definition: trigObjTnPSource_cfi.py:21
match
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
Definition: Utils.h:10
pat::HLTL1MuonMatcher::selector_
StringCutObjectSelector< PATPrimitive > selector_
Select HLT objects.
Definition: HLTL1MuonMatcher.cc:61
pat::HLTL1MuonMatcher::operator()
bool operator()(const pat::TriggerObjectStandAlone &l1) const
select L1s with patName_ and filterLabel_ (public, so it can be used by L1MuonMatcherAlgo)
Definition: HLTL1MuonMatcher.cc:43
pat::HLTL1MuonMatcher::writeExtraInfo_
bool writeExtraInfo_
Write out additional info as ValueMaps.
Definition: HLTL1MuonMatcher.cc:68
Ptr.h
iEvent
int iEvent
Definition: GenABIO.cc:224
pat::TriggerObjectStandAloneCollection
std::vector< TriggerObjectStandAlone > TriggerObjectStandAloneCollection
Collection of TriggerObjectStandAlone.
Definition: TriggerObjectStandAlone.h:219
edm::Association
Definition: Association.h:18
edm::EventSetup
Definition: EventSetup.h:58
pat
Definition: HeavyIon.h:7
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
InputTag.h
reco::Candidate
Definition: Candidate.h:27
ValueMap.h
eostools.move
def move(src, dest)
Definition: eostools.py:511
std
Definition: JetResolutionObject.h:76
edm::OrphanHandle
Definition: EDProductfwd.h:39
StringCutObjectSelector.h
pat::HLTL1MuonMatcher::beginRun
void beginRun(const edm::Run &iRun, const edm::EventSetup &iSetup) override
Definition: HLTL1MuonMatcher.cc:167
pat::HLTL1MuonMatcher::HLTL1MuonMatcher
HLTL1MuonMatcher(const edm::ParameterSet &iConfig)
Definition: HLTL1MuonMatcher.cc:83
l1s
Definition: L1Scalers.h:16
edm::ValueMap
Definition: ValueMap.h:107
StringCutObjectSelector
Definition: StringCutObjectSelector.h:16
dt_dqm_sourceclient_common_cff.reco
reco
Definition: dt_dqm_sourceclient_common_cff.py:111
pat::HLTL1MuonMatcher::labelProp_
std::string labelProp_
Labels to set as filter names in the output.
Definition: HLTL1MuonMatcher.cc:65
edm::EDProducer
Definition: EDProducer.h:35
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
math::PtEtaPhiMLorentzVector
PtEtaPhiMLorentzVectorD PtEtaPhiMLorentzVector
Lorentz vector with cartesian internal representation.
Definition: LorentzVector.h:25
edm::helper::Filler
Definition: ValueMap.h:22
View.h
pat::HLTL1MuonMatcher::l1Token_
edm::EDGetTokenT< PATPrimitiveCollection > l1Token_
Definition: HLTL1MuonMatcher.cc:58
edm::Event
Definition: Event.h:73
TriggerObjectStandAlone.h
label
const char * label
Definition: PFTauDecayModeTools.cc:11
TrajectoryStateOnSurface::isValid
bool isValid() const
Definition: TrajectoryStateOnSurface.h:54
L1MuonMatcherAlgo
Matcher of reconstructed objects to L1 Muons.
Definition: L1MuonMatcherAlgo.h:26