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;
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");
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();