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_(false, l1);
47  }
48 
49  private:
53 
55 
59 
64 
67 
70 
72  template <typename Hand, typename T>
74  const Hand &handle,
75  const std::vector<T> &values,
76  const std::string &label) const;
77 
78  // for ambiguity resolution
79  std::vector<const pat::TriggerObjectStandAlone *> lockedItems_;
80  };
81 
82 } // namespace pat
83 
85  : matcher_(iConfig),
86  recoToken_(consumes<edm::View<reco::Candidate> >(iConfig.getParameter<edm::InputTag>("src"))),
87  l1Token_(consumes<PATPrimitiveCollection>(iConfig.getParameter<edm::InputTag>("matched"))),
88  selector_(iConfig),
89  resolveAmbiguities_(iConfig.getParameter<bool>("resolveAmbiguities")),
90  labelProp_(iConfig.getParameter<std::string>("setPropLabel")),
91  writeExtraInfo_(iConfig.existsAs<bool>("writeExtraInfo") ? iConfig.getParameter<bool>("writeExtraInfo") : false) {
92  produces<PATPrimitiveCollection>("propagatedReco"); // reco to muon station 2
93  produces<PATTriggerAssociation>("propagatedReco"); // asso reco to propagated reco
94  produces<PATTriggerAssociation>(); // asso reco to l1
95  if (writeExtraInfo_) {
96  produces<edm::ValueMap<float> >("deltaR");
97  produces<edm::ValueMap<float> >("deltaPhi");
98  }
99 }
100 
102  using namespace edm;
103  using namespace std;
104 
107 
108  iEvent.getByToken(recoToken_, reco);
109  iEvent.getByToken(l1Token_, l1s);
110 
111  unique_ptr<PATPrimitiveCollection> propOut(new PATPrimitiveCollection());
112  vector<int> propMatches(reco->size(), -1);
113  vector<int> fullMatches(reco->size(), -1);
114  vector<float> deltaRs(reco->size(), 999), deltaPhis(reco->size(), 999);
115  lockedItems_.clear();
116  for (int i = 0, n = reco->size(); i < n; ++i) {
117  TrajectoryStateOnSurface propagated;
118  const reco::Candidate &mu = (*reco)[i];
119  int match = matcher_.matchGeneric(mu, *l1s, *this, deltaRs[i], deltaPhis[i], propagated);
120  if (propagated.isValid()) {
121  GlobalPoint pos = propagated.globalPosition();
122  propMatches[i] = propOut->size();
123  propOut->push_back(PATPrimitive(math::PtEtaPhiMLorentzVector(mu.pt(), pos.eta(), pos.phi(), mu.mass())));
124  propOut->back().addFilterLabel(labelProp_);
125  propOut->back().setCharge(mu.charge());
126  }
127  fullMatches[i] = match;
128  if (match != -1) {
129  lockedItems_.push_back(&(*l1s)[match]);
130  }
131  }
132  lockedItems_.clear();
133 
134  OrphanHandle<PATPrimitiveCollection> propDone = iEvent.put(std::move(propOut), "propagatedReco");
135 
136  unique_ptr<PATTriggerAssociation> propAss(new PATTriggerAssociation(propDone));
137  PATTriggerAssociation::Filler propFiller(*propAss);
138  propFiller.insert(reco, propMatches.begin(), propMatches.end());
139  propFiller.fill();
140  iEvent.put(std::move(propAss), "propagatedReco");
141 
142  unique_ptr<PATTriggerAssociation> fullAss(new PATTriggerAssociation(l1s));
143  PATTriggerAssociation::Filler fullFiller(*fullAss);
144  fullFiller.insert(reco, fullMatches.begin(), fullMatches.end());
145  fullFiller.fill();
146  iEvent.put(std::move(fullAss));
147 
148  if (writeExtraInfo_) {
149  storeExtraInfo(iEvent, reco, deltaRs, "deltaR");
150  storeExtraInfo(iEvent, reco, deltaPhis, "deltaPhi");
151  }
152 }
153 
154 template <typename Hand, typename T>
156  const Hand &handle,
157  const std::vector<T> &values,
158  const std::string &label) const {
159  using namespace edm;
160  using namespace std;
161  unique_ptr<ValueMap<T> > valMap(new ValueMap<T>());
162  typename edm::ValueMap<T>::Filler filler(*valMap);
163  filler.insert(handle, values.begin(), values.end());
164  filler.fill();
165  iEvent.put(std::move(valMap), label);
166 }
167 
168 void pat::HLTL1MuonMatcher::beginRun(const edm::Run &iRun, const edm::EventSetup &iSetup) { matcher_.init(iSetup); }
169 
171 using namespace pat;
pat::HLTL1MuonMatcher::PATTriggerAssociation
pat::TriggerObjectStandAloneMatch PATTriggerAssociation
Definition: HLTL1MuonMatcher.cc:52
pat::PATTriggerMatchSelector
Definition: PATTriggerMatchSelector.h:32
electrons_cff.bool
bool
Definition: electrons_cff.py:393
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
funct::false
false
Definition: Factorize.h:29
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:101
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89287
edm::helper::Filler::fill
void fill()
Definition: ValueMap.h:65
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:45
Association.h
pat::HLTL1MuonMatcher::selector_
pat::PATTriggerMatchSelector< bool, PATPrimitive > selector_
Definition: HLTL1MuonMatcher.cc:62
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
PATTriggerMatchSelector.h
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:79
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:155
pat::HLTL1MuonMatcher::PATPrimitive
pat::TriggerObjectStandAlone PATPrimitive
Definition: HLTL1MuonMatcher.cc:50
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
pat::HLTL1MuonMatcher::resolveAmbiguities_
bool resolveAmbiguities_
Definition: HLTL1MuonMatcher.cc:63
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::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:69
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:57
pat
Definition: HeavyIon.h:7
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
pat::HLTL1MuonMatcher::beginRun
void beginRun(const edm::Run &iRun, const edm::EventSetup &iSetup) override
Definition: HLTL1MuonMatcher.cc:168
pat::HLTL1MuonMatcher::HLTL1MuonMatcher
HLTL1MuonMatcher(const edm::ParameterSet &iConfig)
Definition: HLTL1MuonMatcher.cc:84
l1s
Definition: L1Scalers.h:16
edm::ValueMap
Definition: ValueMap.h:107
dt_dqm_sourceclient_common_cff.reco
reco
Definition: dt_dqm_sourceclient_common_cff.py:110
pat::HLTL1MuonMatcher::labelProp_
std::string labelProp_
Labels to set as filter names in the output.
Definition: HLTL1MuonMatcher.cc:66
edm::EDProducer
Definition: EDProducer.h:35
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