22 typedef std::map<reco::MuonRef, unsigned int>
MuToPFMap;
30 : debug_(pSet.getUntrackedParameter<
bool>(
"ActivateDebug",
false)) {
51 produces<reco::MuonCollection>();
58 produces<reco::MuonTimeExtraMap>(
"combined");
59 produces<reco::MuonTimeExtraMap>(
"dt");
60 produces<reco::MuonTimeExtraMap>(
"csc");
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");
144 isoMap[
"photonHighThreshold"] =
map->second.getParameter<
edm::InputTag>(
"photonHighThreshold");
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();
184 auto outputMuons = std::make_unique<reco::MuonCollection>();
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;
258 pfIsoMapVals.push_back(mapVals);
259 pfIsoMaps.push_back(maps);
269 selectorMapResults[
s].resize(
nMuons);
277 std::vector<reco::MuonShower> showerInfoColl(
nMuons);
289 std::vector<reco::MuonRef> muonRefColl(
nMuons);
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();
349 dout <<
"Number of PFMuons: " << muToPFMap.size() << endl;
350 dout <<
"Number of Muons in the original collection: " <<
inputMuons->size() << endl;
364 MuToPFMap::iterator iter = muToPFMap.find(muRef);
365 if (iter != muToPFMap.end()) {
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;
388 for (std::map<std::string, edm::InputTag>::const_iterator
map =
pfIsoMapNames[
j].begin();
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");
457 for (std::map<std::string, edm::InputTag>::const_iterator
map =
pfIsoMapNames[
j].begin();
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()) {
492 filler.insert(muonHandle, muonExtra.begin(), muonExtra.end());
500 return input.label();
std::string labelOrInstance(const edm::InputTag &) const
edm::EDGetTokenT< reco::MuonTimeExtraMap > timeMapCSCToken_
edm::InputTag theTrackDepositName
T getParameter(std::string const &) const
std::remove_cv< typename std::remove_reference< argument_type >::type >::type key_type
edm::EDGetTokenT< edm::ValueMap< unsigned int > > theCosmicIdMapToken_
ProductID id() const
Accessor for product ID.
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_
edm::InputTag theEcalDepositName
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_
const LorentzVector & p4() const final
four-momentum Lorentz vector
std::map< reco::MuonRef, unsigned int > MuToPFMap
key_type key() const
Accessor for product key.
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
T getUntrackedParameter(std::string const &, T const &) const
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)
reco::Candidate::LorentzVector pfP4() const
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)
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 &)
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