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 outMuon.
setPFP4(pfCandidates->at(iter->second).p4());
368 outMuon.
setP4(pfCandidates->at(iter->second).p4());
369 outMuon.
setCharge(pfCandidates->at(iter->second).charge());
370 outMuon.
setBestTrack(pfCandidates->at(iter->second).bestMuonTrackType());
371 muToPFMap.erase(iter);
372 dout <<
"MuonRef: " << muRef.
id() <<
" " << muRef.
key()
373 <<
" Is it PF? " << outMuon.
isPFMuon()
374 <<
" PF p4: " << outMuon.
pfP4() << endl;
378 dout <<
"MuonRef: " << muRef.
id() <<
" " << muRef.
key()
379 <<
" Is it PF? " << outMuon.
isPFMuon() << endl;
384 <<
" p4 " << outMuon.
p4() << endl;
393 (pfIsoMapVals[
j])[
map->first][i] = (*pfIsoMaps[
j][
map->first])[muRef];
400 combinedTimeColl[
i] = (*timeMapCmb)[muRef];
401 dtTimeColl[
i] = (*timeMapDT)[muRef];
402 cscTimeColl[
i] = (*timeMapCSC)[muRef];
406 trackDepColl[
i] = (*trackIsoDepMap)[muRef];
407 ecalDepColl[
i] = (*ecalIsoDepMap)[muRef];
408 hcalDepColl[
i] = (*hcalIsoDepMap)[muRef];
409 hoDepColl[
i] = (*hoIsoDepMap)[muRef];
410 jetDepColl[
i] = (*jetIsoDepMap)[muRef];;
417 selectorMapResults[s][i] = (*selectorMaps[s])[muRef];
424 cosmicIdColl[
i] = (*cosmicIdMap)[muRef];
425 cosmicCompColl[
i] = (*cosmicCompMap)[muRef];
428 outputMuons->push_back(outMuon);
432 dout <<
"Number of Muons in the new muon collection: " << outputMuons->size() << endl;
436 fillMuonMap<reco::MuonTimeExtra>(
event, muonHandle, combinedTimeColl,
"combined");
437 fillMuonMap<reco::MuonTimeExtra>(
event, muonHandle, dtTimeColl,
"dt");
438 fillMuonMap<reco::MuonTimeExtra>(
event, muonHandle, cscTimeColl,
"csc");
478 template<
typename TYPE>
481 const std::vector<TYPE>& muonExtra,
487 if(!muonExtra.empty()){
488 FILLER filler(*muonMap);
489 filler.insert(muonHandle, muonExtra.begin(), muonExtra.end());
492 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
virtual void setCharge(Charge q) GCC11_FINAL
set electric charge
edm::EDGetTokenT< edm::ValueMap< unsigned int > > theCosmicIdMapToken_
virtual const LorentzVector & p4() const GCC11_FINAL
four-momentum Lorentz vector
edm::EDGetTokenT< reco::MuonTimeExtraMap > timeMapDTToken_
const std::string metname
virtual ~MuonProducer()
Destructor.
bool isTrackerMuon() const
edm::EDGetTokenT< edm::ValueMap< reco::MuonShower > > theShowerMapToken_
bool isGlobalMuon() const
edm::InputTag theEcalDepositName
bool isStandAloneMuon() const
reco::Candidate::LorentzVector pfP4() const
std::vector< edm::EDGetTokenT< edm::ValueMap< bool > > > theSelectorMapTokens_
edm::EDGetTokenT< reco::IsoDepositMap > theJetDepositToken_
std::map< reco::MuonRef, unsigned int > MuToPFMap
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 &)
key_type key() const
Accessor for product key.
edm::EDGetTokenT< edm::ValueMap< reco::MuonCosmicCompatibility > > theCosmicCompMapToken_
virtual void produce(edm::Event &, const edm::EventSetup &)
reconstruct muons
MuPFIsoHelper * thePFIsoHelper
void beginEvent(const edm::Event &iEvent)
virtual void setBestTrack(MuonTrackType muonType)
virtual void setP4(const LorentzVector &p4) GCC11_FINAL
set 4-momentum
edm::EDGetTokenT< reco::IsoDepositMap > theHcalDepositToken_
edm::InputTag theCosmicCompMapName
MuonProducer(const edm::ParameterSet &)
Constructor.
edm::InputTag theHcalDepositName
virtual void setPFP4(const reco::Candidate::LorentzVector &p4_)
ProductID id() const
Accessor for product ID.
volatile std::atomic< bool > shutdown_flag false
boost::remove_cv< typename boost::remove_reference< argument_type >::type >::type key_type
edm::InputTag theJetDepositName