15 #include <boost/foreach.hpp> 16 #define foreach BOOST_FOREACH 19 #define dout if(debug_) std::cout 24 typedef std::map<reco::MuonRef, unsigned int>
MuToPFMap;
56 produces<reco::MuonCollection>();
64 produces<reco::MuonTimeExtraMap>(
"combined");
65 produces<reco::MuonTimeExtraMap>(
"dt");
66 produces<reco::MuonTimeExtraMap>(
"csc");
69 if (fillDetectorBasedIsolation_){
80 produces<reco::IsoDepositMap>(theEcalDepositName.instance());
84 produces<reco::IsoDepositMap>(theHcalDepositName.instance());
89 produces<reco::IsoDepositMap>(theHoDepositName.instance());
102 if(fillShoweringInfo_){
108 if(fillCosmicsIdMap_){
123 if(fillPFIsolation_){
128 std::map<std::string,edm::ParameterSet> psetMap;
131 std::vector<std::string> isolationLabels;
132 isolationLabels.push_back(
"pfIsolationR03");
133 isolationLabels.push_back(
"pfIsoMeanDRProfileR03");
134 isolationLabels.push_back(
"pfIsoSumDRProfileR03");
135 isolationLabels.push_back(
"pfIsolationR04");
136 isolationLabels.push_back(
"pfIsoMeanDRProfileR04");
137 isolationLabels.push_back(
"pfIsoSumDRProfileR04");
140 for( std::vector<std::string>::const_iterator
label = isolationLabels.begin();
label != isolationLabels.end();++
label)
147 for(std::map<std::string,edm::ParameterSet>::const_iterator
map = psetMap.begin();
map!= psetMap.end();++
map) {
148 std::map<std::string,edm::InputTag> isoMap;
149 isoMap[
"chargedParticle"] =
map->second.getParameter<
edm::InputTag>(
"chargedParticle");
150 isoMap[
"chargedHadron"] =
map->second.getParameter<
edm::InputTag>(
"chargedHadron");
151 isoMap[
"neutralHadron"] =
map->second.getParameter<
edm::InputTag>(
"neutralHadron");
152 isoMap[
"neutralHadronHighThreshold"] =
map->second.getParameter<
edm::InputTag>(
"neutralHadronHighThreshold");
154 isoMap[
"photonHighThreshold"] =
map->second.getParameter<
edm::InputTag>(
"photonHighThreshold");
157 std::map<std::string,edm::EDGetTokenT<edm::ValueMap<double> > > isoMapToken;
158 isoMapToken[
"chargedParticle"] = consumes<edm::ValueMap<double> >(isoMap[
"chargedParticle"]);
159 isoMapToken[
"chargedHadron"] = consumes<edm::ValueMap<double> >(isoMap[
"chargedHadron"]);
160 isoMapToken[
"neutralHadron"] = consumes<edm::ValueMap<double> >(isoMap[
"neutralHadron"]);
161 isoMapToken[
"neutralHadronHighThreshold"] = consumes<edm::ValueMap<double> >(isoMap[
"neutralHadronHighThreshold"]);
162 isoMapToken[
"photon"] = consumes<edm::ValueMap<double> >(isoMap[
"photon"]);
163 isoMapToken[
"photonHighThreshold"] = consumes<edm::ValueMap<double> >(isoMap[
"photonHighThreshold"]);
164 isoMapToken[
"pu"] = consumes<edm::ValueMap<double> >(isoMap[
"pu"]);
180 if (computeStandardSelectors_){
198 auto outputMuons = std::make_unique<reco::MuonCollection>();
211 event.getByToken(
vertexes_, primaryVertices);
212 if (!primaryVertices->empty())
213 vertex = &(primaryVertices->front());
225 int nMuons=inputMuons->size();
227 std::vector<reco::MuonTimeExtra> dtTimeColl(nMuons);
228 std::vector<reco::MuonTimeExtra> cscTimeColl(nMuons);
229 std::vector<reco::MuonTimeExtra> combinedTimeColl(nMuons);
237 std::vector<reco::IsoDeposit> trackDepColl(nMuons);
238 std::vector<reco::IsoDeposit> ecalDepColl(nMuons);
239 std::vector<reco::IsoDeposit> hcalDepColl(nMuons);
240 std::vector<reco::IsoDeposit> hoDepColl(nMuons);
241 std::vector<reco::IsoDeposit> jetDepColl(nMuons);
261 std::vector<std::map<std::string,edm::Handle<edm::ValueMap<double> > > > pfIsoMaps;
262 std::vector<std::map<std::string,std::vector<double> > > pfIsoMapVals;
266 std::map<std::string,std::vector<double> > mapVals;
267 std::map<std::string,edm::Handle<edm::ValueMap<double> > > maps;
271 maps[
map->first]=handleTmp;
272 mapVals[
map->first].resize(nMuons);
274 pfIsoMapVals.push_back(mapVals);
275 pfIsoMaps.push_back(maps);
288 selectorMapResults[
s].resize(nMuons);
295 std::vector<reco::MuonShower> showerInfoColl(nMuons);
303 std::vector<reco::MuonCosmicCompatibility> cosmicCompColl(
fillCosmicsIdMap_ ? nMuons : 0);
306 std::vector<reco::MuonRef> muonRefColl(nMuons);
310 if(inputMuons->empty()) {
314 fillMuonMap<reco::MuonTimeExtra>(
event, muonHandle, combinedTimeColl,
"combined");
315 fillMuonMap<reco::MuonTimeExtra>(
event, muonHandle, dtTimeColl,
"dt");
316 fillMuonMap<reco::MuonTimeExtra>(
event, muonHandle, cscTimeColl,
"csc");
359 dout <<
"Number of PFCandidates: " << pfCandidates->size() << endl;
360 for(
unsigned int i=0;
i< pfCandidates->size();++
i)
361 if(
abs(pfCandidates->at(
i).pdgId()) == 13){
362 muToPFMap[pfCandidates->at(
i).muonRef()] =
i;
363 dout <<
"MuonRef: " << pfCandidates->at(
i).muonRef().
id() <<
" " << pfCandidates->at(
i).muonRef().key() <<
" PF p4: " << pfCandidates->at(
i).p4() << endl;
365 dout <<
"Number of PFMuons: " << muToPFMap.size() << endl;
366 dout <<
"Number of Muons in the original collection: " << inputMuons->size() << endl;
371 foreach(
const reco::Muon &inMuon, *inputMuons){
381 MuToPFMap::iterator iter = muToPFMap.find(muRef);
382 if(iter != muToPFMap.end()){
383 const auto& pfMu = pfCandidates->at(iter->second);
385 outMuon.
setP4(pfMu.p4());
387 outMuon.
setPdgId(-13*pfMu.charge());
389 muToPFMap.erase(iter);
390 dout <<
"MuonRef: " << muRef.
id() <<
" " << muRef.
key()
391 <<
" Is it PF? " << outMuon.
isPFMuon()
392 <<
" PF p4: " << outMuon.
pfP4() << endl;
396 dout <<
"MuonRef: " << muRef.
id() <<
" " << muRef.
key()
397 <<
" Is it PF? " << outMuon.
isPFMuon() << endl;
402 <<
" p4 " << outMuon.
p4() << endl;
411 (pfIsoMapVals[j])[
map->first][i] = (*pfIsoMaps[j][
map->first])[muRef];
418 combinedTimeColl[
i] = (*timeMapCmb)[muRef];
419 dtTimeColl[
i] = (*timeMapDT)[muRef];
420 cscTimeColl[
i] = (*timeMapCSC)[muRef];
424 trackDepColl[
i] = (*trackIsoDepMap)[muRef];
425 ecalDepColl[
i] = (*ecalIsoDepMap)[muRef];
426 hcalDepColl[
i] = (*hcalIsoDepMap)[muRef];
427 hoDepColl[
i] = (*hoIsoDepMap)[muRef];
428 jetDepColl[
i] = (*jetIsoDepMap)[muRef];;
435 selectorMapResults[s][i] = (*selectorMaps[s])[muRef];
442 cosmicIdColl[
i] = (*cosmicIdMap)[muRef];
443 cosmicCompColl[
i] = (*cosmicCompMap)[muRef];
449 bool isRun2016BCDEF = (272728 <=
event.run() &&
event.run() <= 278808);
453 outputMuons->push_back(outMuon);
457 dout <<
"Number of Muons in the new muon collection: " << outputMuons->size() << endl;
461 fillMuonMap<reco::MuonTimeExtra>(
event, muonHandle, combinedTimeColl,
"combined");
462 fillMuonMap<reco::MuonTimeExtra>(
event, muonHandle, dtTimeColl,
"dt");
463 fillMuonMap<reco::MuonTimeExtra>(
event, muonHandle, cscTimeColl,
"csc");
503 template<
typename TYPE>
506 const std::vector<TYPE>& muonExtra,
511 auto muonMap = std::make_unique<edm::ValueMap<TYPE>>();
512 if(!muonExtra.empty()){
514 filler.insert(muonHandle, muonExtra.begin(), muonExtra.end());
BranchAliasSetterT< ProductType > produces()
declare what type of product will make and with which optional label
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_
void setCutBasedSelectorFlags(reco::Muon &muon, const reco::Vertex *vertex=0, bool run2016_hip_mitigation=false)
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_
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
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)
bool isGlobalMuon() const override
edm::EDGetTokenT< reco::IsoDepositMap > theTrackDepositToken_
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
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
edm::EDGetTokenT< reco::MuonCollection > theMuonsCollectionToken_
std::string theMuToMuMapName
edm::EDGetTokenT< reco::IsoDepositMap > theEcalDepositToken_
void setSelectors(unsigned int selectors)
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