12 #include <boost/foreach.hpp>
13 #define foreach BOOST_FOREACH
16 #define dout if(debug_) std::cout
21 typedef std::map<reco::MuonRef, unsigned int>
MuToPFMap;
52 produces<reco::MuonCollection>();
60 produces<reco::MuonTimeExtraMap>(
"combined");
61 produces<reco::MuonTimeExtraMap>(
"dt");
62 produces<reco::MuonTimeExtraMap>(
"csc");
65 if (fillDetectorBasedIsolation_){
76 produces<reco::IsoDepositMap>(theEcalDepositName.instance());
80 produces<reco::IsoDepositMap>(theHcalDepositName.instance());
85 produces<reco::IsoDepositMap>(theHoDepositName.instance());
98 if(fillShoweringInfo_){
104 if(fillCosmicsIdMap_){
119 if(fillPFIsolation_){
124 std::map<std::string,edm::ParameterSet> psetMap;
127 std::vector<std::string> isolationLabels;
128 isolationLabels.push_back(
"pfIsolationR03");
129 isolationLabels.push_back(
"pfIsoMeanDRProfileR03");
130 isolationLabels.push_back(
"pfIsoSumDRProfileR03");
131 isolationLabels.push_back(
"pfIsolationR04");
132 isolationLabels.push_back(
"pfIsoMeanDRProfileR04");
133 isolationLabels.push_back(
"pfIsoSumDRProfileR04");
136 for( std::vector<std::string>::const_iterator
label = isolationLabels.begin();
label != isolationLabels.end();++
label)
143 for(std::map<std::string,edm::ParameterSet>::const_iterator
map = psetMap.begin();
map!= psetMap.end();++
map) {
144 std::map<std::string,edm::InputTag> isoMap;
145 isoMap[
"chargedParticle"] =
map->second.getParameter<
edm::InputTag>(
"chargedParticle");
146 isoMap[
"chargedHadron"] =
map->second.getParameter<
edm::InputTag>(
"chargedHadron");
147 isoMap[
"neutralHadron"] =
map->second.getParameter<
edm::InputTag>(
"neutralHadron");
148 isoMap[
"neutralHadronHighThreshold"] =
map->second.getParameter<
edm::InputTag>(
"neutralHadronHighThreshold");
150 isoMap[
"photonHighThreshold"] =
map->second.getParameter<
edm::InputTag>(
"photonHighThreshold");
153 std::map<std::string,edm::EDGetTokenT<edm::ValueMap<double> > > isoMapToken;
154 isoMapToken[
"chargedParticle"] = consumes<edm::ValueMap<double> >(isoMap[
"chargedParticle"]);
155 isoMapToken[
"chargedHadron"] = consumes<edm::ValueMap<double> >(isoMap[
"chargedHadron"]);
156 isoMapToken[
"neutralHadron"] = consumes<edm::ValueMap<double> >(isoMap[
"neutralHadron"]);
157 isoMapToken[
"neutralHadronHighThreshold"] = consumes<edm::ValueMap<double> >(isoMap[
"neutralHadronHighThreshold"]);
158 isoMapToken[
"photon"] = consumes<edm::ValueMap<double> >(isoMap[
"photon"]);
159 isoMapToken[
"photonHighThreshold"] = consumes<edm::ValueMap<double> >(isoMap[
"photonHighThreshold"]);
160 isoMapToken[
"pu"] = consumes<edm::ValueMap<double> >(isoMap[
"pu"]);
209 int nMuons=inputMuons->size();
211 std::vector<reco::MuonTimeExtra> dtTimeColl(nMuons);
212 std::vector<reco::MuonTimeExtra> cscTimeColl(nMuons);
213 std::vector<reco::MuonTimeExtra> combinedTimeColl(nMuons);
221 std::vector<reco::IsoDeposit> trackDepColl(nMuons);
222 std::vector<reco::IsoDeposit> ecalDepColl(nMuons);
223 std::vector<reco::IsoDeposit> hcalDepColl(nMuons);
224 std::vector<reco::IsoDeposit> hoDepColl(nMuons);
225 std::vector<reco::IsoDeposit> jetDepColl(nMuons);
245 std::vector<std::map<std::string,edm::Handle<edm::ValueMap<double> > > > pfIsoMaps;
246 std::vector<std::map<std::string,std::vector<double> > > pfIsoMapVals;
250 std::map<std::string,std::vector<double> > mapVals;
251 std::map<std::string,edm::Handle<edm::ValueMap<double> > > maps;
255 maps[
map->first]=handleTmp;
256 mapVals[
map->first].resize(nMuons);
258 pfIsoMapVals.push_back(mapVals);
259 pfIsoMaps.push_back(maps);
272 selectorMapResults[
s].resize(nMuons);
279 std::vector<reco::MuonShower> showerInfoColl(nMuons);
287 std::vector<reco::MuonCosmicCompatibility> cosmicCompColl(
fillCosmicsIdMap_ ? nMuons : 0);
290 std::vector<reco::MuonRef> muonRefColl(nMuons);
294 if(inputMuons->empty()) {
298 fillMuonMap<reco::MuonTimeExtra>(
event, muonHandle, combinedTimeColl,
"combined");
299 fillMuonMap<reco::MuonTimeExtra>(
event, muonHandle, dtTimeColl,
"dt");
300 fillMuonMap<reco::MuonTimeExtra>(
event, muonHandle, cscTimeColl,
"csc");
343 dout <<
"Number of PFCandidates: " << pfCandidates->size() << endl;
344 for(
unsigned int i=0;
i< pfCandidates->size();++
i)
345 if(
abs(pfCandidates->at(
i).pdgId()) == 13){
346 muToPFMap[pfCandidates->at(
i).muonRef()] =
i;
347 dout <<
"MuonRef: " << pfCandidates->at(
i).muonRef().
id() <<
" " << pfCandidates->at(
i).muonRef().key() <<
" 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 foreach(
const reco::Muon &inMuon, *inputMuons){
365 MuToPFMap::iterator iter = muToPFMap.find(muRef);
366 if(iter != muToPFMap.end()){
367 const auto& pfMu = pfCandidates->at(iter->second);
369 outMuon.
setP4(pfMu.p4());
371 outMuon.
setPdgId(-13*pfMu.charge());
373 muToPFMap.erase(iter);
374 dout <<
"MuonRef: " << muRef.
id() <<
" " << muRef.
key()
375 <<
" Is it PF? " << outMuon.
isPFMuon()
376 <<
" PF p4: " << outMuon.
pfP4() << endl;
380 dout <<
"MuonRef: " << muRef.
id() <<
" " << muRef.
key()
381 <<
" Is it PF? " << outMuon.
isPFMuon() << endl;
386 <<
" p4 " << outMuon.
p4() << endl;
395 (pfIsoMapVals[
j])[
map->first][i] = (*pfIsoMaps[
j][
map->first])[muRef];
402 combinedTimeColl[
i] = (*timeMapCmb)[muRef];
403 dtTimeColl[
i] = (*timeMapDT)[muRef];
404 cscTimeColl[
i] = (*timeMapCSC)[muRef];
408 trackDepColl[
i] = (*trackIsoDepMap)[muRef];
409 ecalDepColl[
i] = (*ecalIsoDepMap)[muRef];
410 hcalDepColl[
i] = (*hcalIsoDepMap)[muRef];
411 hoDepColl[
i] = (*hoIsoDepMap)[muRef];
412 jetDepColl[
i] = (*jetIsoDepMap)[muRef];;
419 selectorMapResults[s][i] = (*selectorMaps[s])[muRef];
426 cosmicIdColl[
i] = (*cosmicIdMap)[muRef];
427 cosmicCompColl[
i] = (*cosmicCompMap)[muRef];
430 outputMuons->push_back(outMuon);
434 dout <<
"Number of Muons in the new muon collection: " << outputMuons->size() << endl;
438 fillMuonMap<reco::MuonTimeExtra>(
event, muonHandle, combinedTimeColl,
"combined");
439 fillMuonMap<reco::MuonTimeExtra>(
event, muonHandle, dtTimeColl,
"dt");
440 fillMuonMap<reco::MuonTimeExtra>(
event, muonHandle, cscTimeColl,
"csc");
480 template<
typename TYPE>
483 const std::vector<TYPE>& muonExtra,
489 if(!muonExtra.empty()){
490 FILLER filler(*muonMap);
491 filler.insert(muonHandle, muonExtra.begin(), muonExtra.end());
494 event.put(muonMap,label);
T getParameter(std::string const &) const
edm::EDGetTokenT< reco::MuonTimeExtraMap > timeMapCSCToken_
T getUntrackedParameter(std::string const &, T const &) const
edm::InputTag theTrackDepositName
edm::EDGetTokenT< edm::ValueMap< unsigned int > > theCosmicIdMapToken_
edm::EDGetTokenT< reco::MuonTimeExtraMap > timeMapDTToken_
const std::string metname
virtual ~MuonProducer()
Destructor.
virtual void setCharge(Charge q)
set electric charge
bool isTrackerMuon() const
edm::EDGetTokenT< edm::ValueMap< reco::MuonShower > > theShowerMapToken_
bool isGlobalMuon() const
virtual void setP4(const LorentzVector &p4)
set 4-momentum
key_type key() const
Accessor for product key.
edm::InputTag theEcalDepositName
bool isStandAloneMuon() const
reco::Candidate::LorentzVector pfP4() const
virtual 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)
std::vector< PFCandidatePtr > pfCandidates(const PFJet &jet, int particleId, bool sort=true)
edm::InputTag thePFCandLabel
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)
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)
TypeLabelItem const & produces()
declare what type of product will make and with which optional label
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
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
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)
virtual void setBestTrack(MuonTrackType muonType)
edm::EDGetTokenT< reco::IsoDepositMap > theHcalDepositToken_
edm::InputTag theCosmicCompMapName
virtual void setPdgId(int pdgId)
MuonProducer(const edm::ParameterSet &)
Constructor.
virtual void setPFP4(const reco::Candidate::LorentzVector &p4_)
edm::InputTag theHcalDepositName
volatile std::atomic< bool > shutdown_flag false
virtual const LorentzVector & p4() const
four-momentum Lorentz vector
edm::InputTag theJetDepositName
boost::remove_cv< typename boost::remove_reference< argument_type >::type >::type key_type