16 #define dout if(debug_) std::cout 21 typedef std::map<reco::MuonRef, unsigned int>
MuToPFMap;
53 produces<reco::MuonCollection>();
61 produces<reco::MuonTimeExtraMap>(
"combined");
62 produces<reco::MuonTimeExtraMap>(
"dt");
63 produces<reco::MuonTimeExtraMap>(
"csc");
66 if (fillDetectorBasedIsolation_){
77 produces<reco::IsoDepositMap>(theEcalDepositName.instance());
81 produces<reco::IsoDepositMap>(theHcalDepositName.instance());
86 produces<reco::IsoDepositMap>(theHoDepositName.instance());
99 if(fillShoweringInfo_){
105 if(fillCosmicsIdMap_){
120 if(fillPFIsolation_){
125 std::map<std::string,edm::ParameterSet> psetMap;
128 std::vector<std::string> isolationLabels;
129 isolationLabels.push_back(
"pfIsolationR03");
130 isolationLabels.push_back(
"pfIsoMeanDRProfileR03");
131 isolationLabels.push_back(
"pfIsoSumDRProfileR03");
132 isolationLabels.push_back(
"pfIsolationR04");
133 isolationLabels.push_back(
"pfIsoMeanDRProfileR04");
134 isolationLabels.push_back(
"pfIsoSumDRProfileR04");
137 for( std::vector<std::string>::const_iterator
label = isolationLabels.begin();
label != isolationLabels.end();++
label)
144 for(std::map<std::string,edm::ParameterSet>::const_iterator
map = psetMap.begin();
map!= psetMap.end();++
map) {
145 std::map<std::string,edm::InputTag> isoMap;
146 isoMap[
"chargedParticle"] =
map->second.getParameter<
edm::InputTag>(
"chargedParticle");
147 isoMap[
"chargedHadron"] =
map->second.getParameter<
edm::InputTag>(
"chargedHadron");
148 isoMap[
"neutralHadron"] =
map->second.getParameter<
edm::InputTag>(
"neutralHadron");
149 isoMap[
"neutralHadronHighThreshold"] =
map->second.getParameter<
edm::InputTag>(
"neutralHadronHighThreshold");
151 isoMap[
"photonHighThreshold"] =
map->second.getParameter<
edm::InputTag>(
"photonHighThreshold");
154 std::map<std::string,edm::EDGetTokenT<edm::ValueMap<double> > > isoMapToken;
155 isoMapToken[
"chargedParticle"] = consumes<edm::ValueMap<double> >(isoMap[
"chargedParticle"]);
156 isoMapToken[
"chargedHadron"] = consumes<edm::ValueMap<double> >(isoMap[
"chargedHadron"]);
157 isoMapToken[
"neutralHadron"] = consumes<edm::ValueMap<double> >(isoMap[
"neutralHadron"]);
158 isoMapToken[
"neutralHadronHighThreshold"] = consumes<edm::ValueMap<double> >(isoMap[
"neutralHadronHighThreshold"]);
159 isoMapToken[
"photon"] = consumes<edm::ValueMap<double> >(isoMap[
"photon"]);
160 isoMapToken[
"photonHighThreshold"] = consumes<edm::ValueMap<double> >(isoMap[
"photonHighThreshold"]);
161 isoMapToken[
"pu"] = consumes<edm::ValueMap<double> >(isoMap[
"pu"]);
177 if (computeStandardSelectors_){
195 auto outputMuons = std::make_unique<reco::MuonCollection>();
208 event.getByToken(
vertexes_, primaryVertices);
209 if (!primaryVertices->empty())
210 vertex = &(primaryVertices->front());
222 int nMuons=inputMuons->size();
224 std::vector<reco::MuonTimeExtra> dtTimeColl(nMuons);
225 std::vector<reco::MuonTimeExtra> cscTimeColl(nMuons);
226 std::vector<reco::MuonTimeExtra> combinedTimeColl(nMuons);
234 std::vector<reco::IsoDeposit> trackDepColl(nMuons);
235 std::vector<reco::IsoDeposit> ecalDepColl(nMuons);
236 std::vector<reco::IsoDeposit> hcalDepColl(nMuons);
237 std::vector<reco::IsoDeposit> hoDepColl(nMuons);
238 std::vector<reco::IsoDeposit> jetDepColl(nMuons);
258 std::vector<std::map<std::string,edm::Handle<edm::ValueMap<double> > > > pfIsoMaps;
259 std::vector<std::map<std::string,std::vector<double> > > pfIsoMapVals;
263 std::map<std::string,std::vector<double> > mapVals;
264 std::map<std::string,edm::Handle<edm::ValueMap<double> > > maps;
268 maps[
map->first]=handleTmp;
269 mapVals[
map->first].resize(nMuons);
271 pfIsoMapVals.push_back(mapVals);
272 pfIsoMaps.push_back(maps);
285 selectorMapResults[
s].resize(nMuons);
292 std::vector<reco::MuonShower> showerInfoColl(nMuons);
300 std::vector<reco::MuonCosmicCompatibility> cosmicCompColl(
fillCosmicsIdMap_ ? nMuons : 0);
303 std::vector<reco::MuonRef> muonRefColl(nMuons);
307 if(inputMuons->empty()) {
311 fillMuonMap<reco::MuonTimeExtra>(
event, muonHandle, combinedTimeColl,
"combined");
312 fillMuonMap<reco::MuonTimeExtra>(
event, muonHandle, dtTimeColl,
"dt");
313 fillMuonMap<reco::MuonTimeExtra>(
event, muonHandle, cscTimeColl,
"csc");
356 dout <<
"Number of PFCandidates: " << pfCandidates->size() << endl;
357 for(
unsigned int i=0;
i< pfCandidates->size();++
i)
358 if(
abs(pfCandidates->at(
i).pdgId()) == 13){
359 muToPFMap[pfCandidates->at(
i).muonRef()] =
i;
360 dout <<
"MuonRef: " << pfCandidates->at(
i).muonRef().
id() <<
" " << pfCandidates->at(
i).muonRef().key() <<
" PF p4: " << pfCandidates->at(
i).p4() << endl;
362 dout <<
"Number of PFMuons: " << muToPFMap.size() << endl;
363 dout <<
"Number of Muons in the original collection: " << inputMuons->size() << endl;
368 for(
auto const& inMuon : *inputMuons){
378 MuToPFMap::iterator iter = muToPFMap.find(muRef);
379 if(iter != muToPFMap.end()){
380 const auto& pfMu = pfCandidates->at(iter->second);
382 outMuon.
setP4(pfMu.p4());
384 outMuon.
setPdgId(-13*pfMu.charge());
386 muToPFMap.erase(iter);
387 dout <<
"MuonRef: " << muRef.
id() <<
" " << muRef.
key()
388 <<
" Is it PF? " << outMuon.
isPFMuon()
389 <<
" PF p4: " << outMuon.
pfP4() << endl;
393 dout <<
"MuonRef: " << muRef.
id() <<
" " << muRef.
key()
394 <<
" Is it PF? " << outMuon.
isPFMuon() << endl;
399 <<
" p4 " << outMuon.
p4() << endl;
408 (pfIsoMapVals[j])[
map->first][i] = (*pfIsoMaps[j][
map->first])[muRef];
415 combinedTimeColl[
i] = (*timeMapCmb)[muRef];
416 dtTimeColl[
i] = (*timeMapDT)[muRef];
417 cscTimeColl[
i] = (*timeMapCSC)[muRef];
421 trackDepColl[
i] = (*trackIsoDepMap)[muRef];
422 ecalDepColl[
i] = (*ecalIsoDepMap)[muRef];
423 hcalDepColl[
i] = (*hcalIsoDepMap)[muRef];
424 hoDepColl[
i] = (*hoIsoDepMap)[muRef];
425 jetDepColl[
i] = (*jetIsoDepMap)[muRef];;
432 selectorMapResults[s][i] = (*selectorMaps[s])[muRef];
439 cosmicIdColl[
i] = (*cosmicIdMap)[muRef];
440 cosmicCompColl[
i] = (*cosmicCompMap)[muRef];
446 bool isRun2016BCDEF = (272728 <=
event.run() &&
event.run() <= 278808);
450 outputMuons->push_back(outMuon);
454 dout <<
"Number of Muons in the new muon collection: " << outputMuons->size() << endl;
458 fillMuonMap<reco::MuonTimeExtra>(
event, muonHandle, combinedTimeColl,
"combined");
459 fillMuonMap<reco::MuonTimeExtra>(
event, muonHandle, dtTimeColl,
"dt");
460 fillMuonMap<reco::MuonTimeExtra>(
event, muonHandle, cscTimeColl,
"csc");
500 template<
typename TYPE>
503 const std::vector<TYPE>& muonExtra,
508 auto muonMap = std::make_unique<edm::ValueMap<TYPE>>();
509 if(!muonExtra.empty()){
511 filler.insert(muonHandle, muonExtra.begin(), muonExtra.end());
T getParameter(std::string const &) const
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_
bool isStandAloneMuon() const override
edm::EDGetTokenT< reco::MuonTimeExtraMap > timeMapDTToken_
const std::string metname
edm::EDGetTokenT< edm::ValueMap< reco::MuonShower > > theShowerMapToken_
key_type key() const
Accessor for product key.
edm::InputTag theEcalDepositName
reco::Candidate::LorentzVector pfP4() const
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.
std::vector< Muon > MuonCollection
collection of Muon objects
edm::ValueMap< reco::MuonShower > MuonShowerMap
static std::string const input
edm::EDGetTokenT< reco::IsoDepositMap > theHoDepositToken_
bool isTrackerMuon() const override
edm::InputTag thePFCandLabel
void setCharge(Charge q) final
set electric charge
edm::EDGetTokenT< reco::PFCandidateCollection > thePFCandToken_
std::vector< std::map< std::string, edm::InputTag > > pfIsoMapNames
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)
bool isGlobalMuon() const override
edm::EDGetTokenT< reco::IsoDepositMap > theTrackDepositToken_
bool fillDetectorBasedIsolation_
std::vector< std::map< std::string, edm::EDGetTokenT< edm::ValueMap< double > > > > pfIsoMapTokens_
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
const LorentzVector & p4() const final
four-momentum Lorentz vector
edm::InputTag theShowerMapName
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
edm::EDGetTokenT< reco::MuonTimeExtraMap > timeMapCmbToken_
edm::InputTag theHoDepositName
edm::EDGetTokenT< reco::VertexCollection > vertexes_
bool computeStandardSelectors_
std::vector< edm::InputTag > InputTags
InputTags theSelectorMapNames
reco::Muon::Selector makeSelectorBitset(reco::Muon const &muon, reco::Vertex const *vertex=0, bool run2016_hip_mitigation=false)
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)
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
void setP4(const LorentzVector &p4) final
set 4-momentum