22 typedef std::map<reco::MuonRef, unsigned int>
MuToPFMap;
30 :
debug_(pSet.getUntrackedParameter<bool>(
"ActivateDebug",
false)) {
51 produces<reco::MuonCollection>();
53 if (fillTimingInfo_) {
58 produces<reco::MuonTimeExtraMap>(
"combined");
59 produces<reco::MuonTimeExtraMap>(
"dt");
60 produces<reco::MuonTimeExtraMap>(
"csc");
63 if (fillDetectorBasedIsolation_) {
74 produces<reco::IsoDepositMap>(theEcalDepositName.instance());
78 produces<reco::IsoDepositMap>(theHcalDepositName.instance());
83 produces<reco::IsoDepositMap>(theHoDepositName.instance());
95 if (fillShoweringInfo_) {
101 if (fillCosmicsIdMap_) {
113 if (fillPFIsolation_) {
117 std::map<std::string, edm::ParameterSet> psetMap;
120 std::vector<std::string> isolationLabels;
121 isolationLabels.push_back(
"pfIsolationR03");
122 isolationLabels.push_back(
"pfIsoMeanDRProfileR03");
123 isolationLabels.push_back(
"pfIsoSumDRProfileR03");
124 isolationLabels.push_back(
"pfIsolationR04");
125 isolationLabels.push_back(
"pfIsoMeanDRProfileR04");
126 isolationLabels.push_back(
"pfIsoSumDRProfileR04");
129 for (std::vector<std::string>::const_iterator
label = isolationLabels.begin();
label != isolationLabels.end();
137 for (std::map<std::string, edm::ParameterSet>::const_iterator map = psetMap.begin(); map != psetMap.end(); ++map) {
138 std::map<std::string, edm::InputTag> isoMap;
139 isoMap[
"chargedParticle"] = map->second.getParameter<
edm::InputTag>(
"chargedParticle");
140 isoMap[
"chargedHadron"] = map->second.getParameter<
edm::InputTag>(
"chargedHadron");
141 isoMap[
"neutralHadron"] = map->second.getParameter<
edm::InputTag>(
"neutralHadron");
142 isoMap[
"neutralHadronHighThreshold"] = map->second.getParameter<
edm::InputTag>(
"neutralHadronHighThreshold");
143 isoMap[
"photon"] = map->second.getParameter<
edm::InputTag>(
"photon");
144 isoMap[
"photonHighThreshold"] = map->second.getParameter<
edm::InputTag>(
"photonHighThreshold");
145 isoMap[
"pu"] = map->second.getParameter<
edm::InputTag>(
"pu");
147 std::map<std::string, edm::EDGetTokenT<edm::ValueMap<double>>> isoMapToken;
148 isoMapToken[
"chargedParticle"] = consumes<edm::ValueMap<double>>(isoMap[
"chargedParticle"]);
149 isoMapToken[
"chargedHadron"] = consumes<edm::ValueMap<double>>(isoMap[
"chargedHadron"]);
150 isoMapToken[
"neutralHadron"] = consumes<edm::ValueMap<double>>(isoMap[
"neutralHadron"]);
151 isoMapToken[
"neutralHadronHighThreshold"] = consumes<edm::ValueMap<double>>(isoMap[
"neutralHadronHighThreshold"]);
152 isoMapToken[
"photon"] = consumes<edm::ValueMap<double>>(isoMap[
"photon"]);
153 isoMapToken[
"photonHighThreshold"] = consumes<edm::ValueMap<double>>(isoMap[
"photonHighThreshold"]);
154 isoMapToken[
"pu"] = consumes<edm::ValueMap<double>>(isoMap[
"pu"]);
161 for (std::map<std::string, edm::InputTag>::const_iterator map =
pfIsoMapNames.at(
j).begin();
168 if (computeStandardSelectors_) {
184 auto outputMuons = std::make_unique<reco::MuonCollection>();
197 event.getByToken(
vertexes_, primaryVertices);
198 if (!primaryVertices->empty())
199 vertex = &(primaryVertices->front());
211 int nMuons = inputMuons->size();
213 std::vector<reco::MuonTimeExtra> dtTimeColl(nMuons);
214 std::vector<reco::MuonTimeExtra> cscTimeColl(nMuons);
215 std::vector<reco::MuonTimeExtra> combinedTimeColl(nMuons);
223 std::vector<reco::IsoDeposit> trackDepColl(nMuons);
224 std::vector<reco::IsoDeposit> ecalDepColl(nMuons);
225 std::vector<reco::IsoDeposit> hcalDepColl(nMuons);
226 std::vector<reco::IsoDeposit> hoDepColl(nMuons);
227 std::vector<reco::IsoDeposit> jetDepColl(nMuons);
243 std::vector<std::map<std::string, edm::Handle<edm::ValueMap<double>>>> pfIsoMaps;
244 std::vector<std::map<std::string, std::vector<double>>> pfIsoMapVals;
248 std::map<std::string, std::vector<double>> mapVals;
249 std::map<std::string, edm::Handle<edm::ValueMap<double>>> maps;
250 for (std::map<std::string, edm::InputTag>::const_iterator map =
pfIsoMapNames.at(
j).begin();
255 maps[map->first] = handleTmp;
256 mapVals[map->first].resize(nMuons);
258 pfIsoMapVals.push_back(mapVals);
259 pfIsoMaps.push_back(maps);
269 selectorMapResults[
s].resize(nMuons);
277 std::vector<reco::MuonShower> showerInfoColl(nMuons);
287 std::vector<reco::MuonCosmicCompatibility> cosmicCompColl(
fillCosmicsIdMap_ ? nMuons : 0);
289 std::vector<reco::MuonRef> muonRefColl(nMuons);
291 if (inputMuons->empty()) {
295 fillMuonMap<reco::MuonTimeExtra>(
event, muonHandle, combinedTimeColl,
"combined");
296 fillMuonMap<reco::MuonTimeExtra>(
event, muonHandle, dtTimeColl,
"dt");
297 fillMuonMap<reco::MuonTimeExtra>(
event, muonHandle, cscTimeColl,
"csc");
320 fillMuonMap<reco::MuonCosmicCompatibility>(
328 for (std::map<std::string, edm::InputTag>::const_iterator map =
pfIsoMapNames.at(
j).begin();
331 fillMuonMap<double>(
event, muonHandle, pfIsoMapVals.at(
j)[map->first],
labelOrInstance(map->second));
342 dout <<
"Number of PFCandidates: " << pfCandidates->size() << endl;
343 for (
unsigned int i = 0;
i < pfCandidates->size(); ++
i)
344 if (
abs(pfCandidates->at(
i).pdgId()) == 13) {
345 muToPFMap[pfCandidates->at(
i).muonRef()] =
i;
346 dout <<
"MuonRef: " << pfCandidates->at(
i).muonRef().
id() <<
" " << pfCandidates->at(
i).muonRef().key()
347 <<
" PF p4: " << pfCandidates->at(
i).p4() << endl;
349 dout <<
"Number of PFMuons: " << muToPFMap.size() << endl;
350 dout <<
"Number of Muons in the original collection: " << inputMuons->size() << endl;
355 for (
auto const& inMuon : *inputMuons) {
364 MuToPFMap::iterator iter = muToPFMap.find(muRef);
365 if (iter != muToPFMap.end()) {
366 const auto& pfMu = pfCandidates->at(iter->second);
368 outMuon.
setP4(pfMu.p4());
370 outMuon.
setPdgId(-13 * pfMu.charge());
372 muToPFMap.erase(iter);
373 dout <<
"MuonRef: " << muRef.
id() <<
" " << muRef.
key() <<
" Is it PF? " << outMuon.
isPFMuon()
374 <<
" PF p4: " << outMuon.
pfP4() << endl;
377 dout <<
"MuonRef: " << muRef.
id() <<
" " << muRef.
key() <<
" Is it PF? " << outMuon.
isPFMuon() << endl;
391 (pfIsoMapVals[
j])[map->first][i] = (*pfIsoMaps[
j][map->first])[muRef];
398 combinedTimeColl[
i] = (*timeMapCmb)[muRef];
399 dtTimeColl[
i] = (*timeMapDT)[muRef];
400 cscTimeColl[
i] = (*timeMapCSC)[muRef];
404 trackDepColl[
i] = (*trackIsoDepMap)[muRef];
405 ecalDepColl[
i] = (*ecalIsoDepMap)[muRef];
406 hcalDepColl[
i] = (*hcalIsoDepMap)[muRef];
407 hoDepColl[
i] = (*hoIsoDepMap)[muRef];
408 jetDepColl[
i] = (*jetIsoDepMap)[muRef];
415 selectorMapResults[s][i] = (*selectorMaps[s])[muRef];
420 showerInfoColl[
i] = (*showerInfoMap)[muRef];
423 cosmicIdColl[
i] = (*cosmicIdMap)[muRef];
424 cosmicCompColl[
i] = (*cosmicCompMap)[muRef];
430 bool isRun2016BCDEF = (272728 <=
event.run() &&
event.run() <= 278808);
434 outputMuons->push_back(outMuon);
438 dout <<
"Number of Muons in the new muon collection: " << outputMuons->size() << endl;
442 fillMuonMap<reco::MuonTimeExtra>(
event, muonHandle, combinedTimeColl,
"combined");
443 fillMuonMap<reco::MuonTimeExtra>(
event, muonHandle, dtTimeColl,
"dt");
444 fillMuonMap<reco::MuonTimeExtra>(
event, muonHandle, cscTimeColl,
"csc");
460 fillMuonMap<double>(event, muonHandle, pfIsoMapVals[
j][map->first],
labelOrInstance(map->second));
475 fillMuonMap<reco::MuonCosmicCompatibility>(
482 template <
typename TYPE>
485 const std::vector<TYPE>& muonExtra,
489 auto muonMap = std::make_unique<edm::ValueMap<TYPE>>();
490 if (!muonExtra.empty()) {
491 FILLER filler(*muonMap);
492 filler.insert(muonHandle, muonExtra.begin(), muonExtra.end());
500 return input.
label();
edm::EDGetTokenT< reco::MuonTimeExtraMap > timeMapCSCToken_
T getUntrackedParameter(std::string const &, T const &) const
edm::InputTag theTrackDepositName
std::remove_cv< typename std::remove_reference< argument_type >::type >::type key_type
edm::EDGetTokenT< edm::ValueMap< unsigned int > > theCosmicIdMapToken_
edm::EDGetTokenT< reco::MuonTimeExtraMap > timeMapDTToken_
const std::string metname
std::vector< std::map< std::string, edm::EDGetTokenT< edm::ValueMap< double > > > > pfIsoMapTokens_
edm::EDGetTokenT< edm::ValueMap< reco::MuonShower > > theShowerMapToken_
key_type key() const
Accessor for product key.
edm::InputTag theEcalDepositName
reco::Candidate::LorentzVector pfP4() const
reco::Muon::Selector makeSelectorBitset(reco::Muon const &muon, reco::Vertex const *vertex=nullptr, bool run2016_hip_mitigation=false)
void produce(edm::Event &, const edm::EventSetup &) override
reconstruct muons
std::vector< edm::EDGetTokenT< edm::ValueMap< bool > > > theSelectorMapTokens_
edm::EDGetTokenT< reco::IsoDepositMap > theJetDepositToken_
std::map< reco::MuonRef, unsigned int > MuToPFMap
ProductID id() const
Accessor for product ID.
bool isTrackerMuon() const override
std::vector< Muon > MuonCollection
collection of Muon objects
edm::ValueMap< reco::MuonShower > MuonShowerMap
static std::string const input
edm::EDGetTokenT< reco::IsoDepositMap > theHoDepositToken_
edm::InputTag thePFCandLabel
void setCharge(Charge q) final
set electric charge
edm::EDGetTokenT< reco::PFCandidateCollection > thePFCandToken_
void fillMuonMap(edm::Event &event, const edm::OrphanHandle< reco::MuonCollection > &muonHandle, const std::vector< TYPE > &muonExtra, const std::string &label)
void setSelectors(uint64_t selectors)
edm::EDGetTokenT< reco::IsoDepositMap > theTrackDepositToken_
bool fillDetectorBasedIsolation_
void setAlias(std::string alias)
edm::InputTag theMuonsCollectionLabel
Abs< T >::type abs(const T &t)
std::string labelOrInstance(const edm::InputTag &) const
edm::Ref< MuonCollection > MuonRef
presistent reference to a Muon
edm::InputTag theShowerMapName
edm::EDGetTokenT< reco::MuonTimeExtraMap > timeMapCmbToken_
edm::InputTag theHoDepositName
edm::EDGetTokenT< reco::VertexCollection > vertexes_
bool computeStandardSelectors_
std::vector< edm::InputTag > InputTags
InputTags theSelectorMapNames
edm::EDGetTokenT< reco::MuonCollection > theMuonsCollectionToken_
std::string theMuToMuMapName
edm::EDGetTokenT< reco::IsoDepositMap > theEcalDepositToken_
int embedPFIsolation(reco::Muon &, reco::MuonRef &)
T getParameter(std::string const &) const
edm::EDGetTokenT< edm::ValueMap< reco::MuonCosmicCompatibility > > theCosmicCompMapToken_
MuPFIsoHelper * thePFIsoHelper
void beginEvent(const edm::Event &iEvent)
std::vector< std::map< std::string, edm::InputTag > > pfIsoMapNames
virtual void setBestTrack(MuonTrackType muonType)
edm::EDGetTokenT< reco::IsoDepositMap > theHcalDepositToken_
edm::InputTag theCosmicCompMapName
MuonProducer(const edm::ParameterSet &)
Constructor.
virtual void setPFP4(const reco::Candidate::LorentzVector &p4_)
edm::InputTag theHcalDepositName
~MuonProducer() override
Destructor.
void setPdgId(int pdgId) final
edm::InputTag theJetDepositName
bool isGlobalMuon() const override
void setP4(const LorentzVector &p4) final
set 4-momentum
bool isStandAloneMuon() const override