CMS 3D CMS Logo

MuonProducer.cc
Go to the documentation of this file.
1 
8 
13 
14 
15 #include <boost/foreach.hpp>
16 #define foreach BOOST_FOREACH
17 
18 #ifndef dout
19 #define dout if(debug_) std::cout
20 #endif
21 
22 using std::endl;
23 
24 typedef std::map<reco::MuonRef, unsigned int> MuToPFMap;
25 
26 
27 namespace reco {
29 }
30 
31 
33 MuonProducer::MuonProducer(const edm::ParameterSet& pSet):debug_(pSet.getUntrackedParameter<bool>("ActivateDebug",false)){
34 
35  setAlias(pSet.getParameter<std::string>("@module_label"));
36 
37  fastLabelling_ = pSet.getUntrackedParameter<bool>("FastLabelling",true);
38 
39 
41  theMuonsCollectionToken_ = consumes<reco::MuonCollection>(theMuonsCollectionLabel);
42 
43  thePFCandLabel = pSet.getParameter<edm::InputTag>("PFCandidates");
44  thePFCandToken_ = consumes<reco::PFCandidateCollection>(thePFCandLabel);
45 
46  // Variables to switch on-off the differnt parts
47  fillSelectors_ = pSet.getParameter<bool>("FillSelectorMaps");
48  fillCosmicsIdMap_ = pSet.getParameter<bool>("FillCosmicsIdMap");
49  fillPFMomentum_ = pSet.getParameter<bool>("FillPFMomentumAndAssociation");
50  fillPFIsolation_ = pSet.getParameter<bool>("FillPFIsolation");
51  fillDetectorBasedIsolation_ = pSet.getParameter<bool>("FillDetectorBasedIsolation");
52  fillShoweringInfo_ = pSet.getParameter<bool>("FillShoweringInfo");
53  fillTimingInfo_ = pSet.getParameter<bool>("FillTimingInfo");
54  computeStandardSelectors_ = pSet.getParameter<bool>("ComputeStandardSelectors");
55 
56  produces<reco::MuonCollection>();
57 
58  if(fillTimingInfo_){
59 
60  timeMapCmbToken_= consumes<reco::MuonTimeExtraMap>(edm::InputTag(theMuonsCollectionLabel.label(),"combined")) ;
61  timeMapDTToken_ = consumes<reco::MuonTimeExtraMap>(edm::InputTag(theMuonsCollectionLabel.label(),"dt")) ;
62  timeMapCSCToken_= consumes<reco::MuonTimeExtraMap>(edm::InputTag(theMuonsCollectionLabel.label(),"csc")) ;
63 
64  produces<reco::MuonTimeExtraMap>("combined");
65  produces<reco::MuonTimeExtraMap>("dt");
66  produces<reco::MuonTimeExtraMap>("csc");
67  }
68 
69  if (fillDetectorBasedIsolation_){
70  theTrackDepositName = pSet.getParameter<edm::InputTag>("TrackIsoDeposits");
71  theTrackDepositToken_ = consumes<reco::IsoDepositMap>(theTrackDepositName);
72  produces<reco::IsoDepositMap>(labelOrInstance(theTrackDepositName));
73 
74  theJetDepositName = pSet.getParameter<edm::InputTag>("JetIsoDeposits");
75  theJetDepositToken_ = consumes<reco::IsoDepositMap>(theJetDepositName);
76  produces<reco::IsoDepositMap>(labelOrInstance(theJetDepositName));
77 
78  theEcalDepositName = pSet.getParameter<edm::InputTag>("EcalIsoDeposits");
79  theEcalDepositToken_ = consumes<reco::IsoDepositMap>(theEcalDepositName);
80  produces<reco::IsoDepositMap>(theEcalDepositName.instance());
81 
82  theHcalDepositName = pSet.getParameter<edm::InputTag>("HcalIsoDeposits");
83  theHcalDepositToken_ = consumes<reco::IsoDepositMap>(theHcalDepositName);
84  produces<reco::IsoDepositMap>(theHcalDepositName.instance());
85 
86  theHoDepositName = pSet.getParameter<edm::InputTag>("HoIsoDeposits");
87  theHoDepositToken_ = consumes<reco::IsoDepositMap>(theHoDepositName);
88 
89  produces<reco::IsoDepositMap>(theHoDepositName.instance());
90  }
91 
92  if(fillSelectors_){
93  theSelectorMapNames = pSet.getParameter<InputTags>("SelectorMaps");
94 
95  for(InputTags::const_iterator tag = theSelectorMapNames.begin(); tag != theSelectorMapNames.end(); ++tag) {
97  produces<edm::ValueMap<bool> >(labelOrInstance(*tag));
98  }
99 
100  }
101 
102  if(fillShoweringInfo_){
103  theShowerMapName = pSet.getParameter<edm::InputTag>("ShowerInfoMap");
104  theShowerMapToken_ = consumes<reco::MuonShowerMap>(theShowerMapName);
105  produces<edm::ValueMap<reco::MuonShower> >(labelOrInstance(theShowerMapName));
106  }
107 
108  if(fillCosmicsIdMap_){
109  theCosmicCompMapName = pSet.getParameter<edm::InputTag>("CosmicIdMap");
110  theCosmicIdMapToken_ = consumes<edm::ValueMap<unsigned int> >(theCosmicCompMapName);
111  theCosmicCompMapToken_ = consumes<edm::ValueMap<reco::MuonCosmicCompatibility> >(theCosmicCompMapName);
112 
113  produces<edm::ValueMap<reco::MuonCosmicCompatibility> >(labelOrInstance(theCosmicCompMapName));
114  produces<edm::ValueMap<unsigned int> >(labelOrInstance(theCosmicCompMapName));
115  }
116 
117  theMuToMuMapName = theMuonsCollectionLabel.label()+"2"+theAlias+"sMap";
118  produces<edm::ValueMap<reco::MuonRef> >(theMuToMuMapName);
119 
120 
121 
122 
123  if(fillPFIsolation_){
124 
125  edm::ParameterSet pfIsoPSet = pSet.getParameter<edm::ParameterSet >("PFIsolation");
126 
127  //Define a map between the isolation and the PSet for the PFHelper
128  std::map<std::string,edm::ParameterSet> psetMap;
129 
130  //First declare what isolation you are going to read
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");
138 
139  //Fill the label,pet map and initialize MuPFIsoHelper
140  for( std::vector<std::string>::const_iterator label = isolationLabels.begin();label != isolationLabels.end();++label)
141  psetMap[*label] =pfIsoPSet.getParameter<edm::ParameterSet >(*label);
142 
144 
145  //Now loop on the mass read for each PSet the parameters and save them to the mapNames for later
146 
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");
153  isoMap["photon"] = map->second.getParameter<edm::InputTag>("photon");
154  isoMap["photonHighThreshold"] = map->second.getParameter<edm::InputTag>("photonHighThreshold");
155  isoMap["pu"] = map->second.getParameter<edm::InputTag>("pu");
156 
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"]);
165 
166 
167  pfIsoMapNames.push_back(isoMap);
168  pfIsoMapTokens_.push_back(isoMapToken);
169  }
170 
171 
172  for(unsigned int j=0;j<pfIsoMapNames.size();++j) {
173  for(std::map<std::string,edm::InputTag>::const_iterator map = pfIsoMapNames.at(j).begin(); map != pfIsoMapNames.at(j).end(); ++map)
175 
176  }
177 
178  }
179 
180  if (computeStandardSelectors_){
181  vertexes_ = consumes<reco::VertexCollection>(pSet.getParameter<edm::InputTag>("vertices"));
182  }
183 
184 }
185 
189 }
190 
191 
194 
195  const std::string metname = "Muon|RecoMuon|MuonIdentification|MuonProducer";
196 
197  // the muon collection, it will be loaded in the event
198  auto outputMuons = std::make_unique<reco::MuonCollection>();
199  reco::MuonRefProd outputMuonsRefProd = event.getRefBeforePut<reco::MuonCollection>();
200 
202  event.getByToken(theMuonsCollectionToken_, inputMuons);
203  edm::OrphanHandle<reco::MuonCollection> inputMuonsOH(inputMuons.product(), inputMuons.id());
204 
206  event.getByToken(thePFCandToken_, pfCandidates);
207 
209  const reco::Vertex* vertex(nullptr);
211  event.getByToken(vertexes_, primaryVertices);
212  if (!primaryVertices->empty())
213  vertex = &(primaryVertices->front());
214  }
215 
216  // fetch collections for PFIso
218 
219 
220  // Fill timing information
224 
225  int nMuons=inputMuons->size();
226 
227  std::vector<reco::MuonTimeExtra> dtTimeColl(nMuons);
228  std::vector<reco::MuonTimeExtra> cscTimeColl(nMuons);
229  std::vector<reco::MuonTimeExtra> combinedTimeColl(nMuons);
230 
231  if(fillTimingInfo_){
232  event.getByToken(timeMapCmbToken_,timeMapCmb);
233  event.getByToken(timeMapDTToken_,timeMapDT);
234  event.getByToken(timeMapCSCToken_,timeMapCSC);
235  }
236 
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);
242 
243 
244  edm::Handle<reco::IsoDepositMap> trackIsoDepMap;
245  edm::Handle<reco::IsoDepositMap> ecalIsoDepMap;
246  edm::Handle<reco::IsoDepositMap> hcalIsoDepMap;
249 
250 
252  event.getByToken(theTrackDepositToken_,trackIsoDepMap);
253  event.getByToken(theEcalDepositToken_,ecalIsoDepMap);
254  event.getByToken(theHcalDepositToken_,hcalIsoDepMap);
255  event.getByToken(theHoDepositToken_,hoIsoDepMap);
256  event.getByToken(theJetDepositToken_,jetIsoDepMap);
257  }
258 
259 
260 
261  std::vector<std::map<std::string,edm::Handle<edm::ValueMap<double> > > > pfIsoMaps;
262  std::vector<std::map<std::string,std::vector<double> > > pfIsoMapVals;
263 
264  if(fillPFIsolation_){
265  for(unsigned int j=0;j<pfIsoMapNames.size();++j) {
266  std::map<std::string,std::vector<double> > mapVals;
267  std::map<std::string,edm::Handle<edm::ValueMap<double> > > maps;
268  for(std::map<std::string,edm::InputTag>::const_iterator map = pfIsoMapNames.at(j).begin(); map != pfIsoMapNames.at(j).end(); ++map) {
270  event.getByToken(pfIsoMapTokens_.at(j)[map->first],handleTmp);
271  maps[map->first]=handleTmp;
272  mapVals[map->first].resize(nMuons);
273  }
274  pfIsoMapVals.push_back(mapVals);
275  pfIsoMaps.push_back(maps);
276 
277  }
278  }
279 
280 
281 
282  std::vector<edm::Handle<edm::ValueMap<bool> > > selectorMaps(fillSelectors_ ? theSelectorMapNames.size() : 0);
283  std::vector<std::vector<bool> > selectorMapResults(fillSelectors_ ? theSelectorMapNames.size() : 0);
284  if(fillSelectors_){
285  unsigned int s=0;
286  for(InputTags::const_iterator tag = theSelectorMapNames.begin(); tag != theSelectorMapNames.end(); ++tag, ++s){
287  event.getByToken(theSelectorMapTokens_.at(s),selectorMaps[s]);
288  selectorMapResults[s].resize(nMuons);
289  }
290  }
291 
292  edm::Handle<reco::MuonShowerMap> showerInfoMap;
293  if(fillShoweringInfo_) event.getByToken(theShowerMapToken_,showerInfoMap);
294 
295  std::vector<reco::MuonShower> showerInfoColl(nMuons);
296 
298  if(fillCosmicsIdMap_) event.getByToken(theCosmicIdMapToken_,cosmicIdMap);
299  std::vector<unsigned int> cosmicIdColl(fillCosmicsIdMap_ ? nMuons : 0);
300 
302  if(fillCosmicsIdMap_) event.getByToken(theCosmicCompMapToken_,cosmicCompMap);
303  std::vector<reco::MuonCosmicCompatibility> cosmicCompColl(fillCosmicsIdMap_ ? nMuons : 0);
304 
305 
306  std::vector<reco::MuonRef> muonRefColl(nMuons);
307 
308 
309 
310  if(inputMuons->empty()) {
311  edm::OrphanHandle<reco::MuonCollection> muonHandle = event.put(std::move(outputMuons));
312 
313  if(fillTimingInfo_){
314  fillMuonMap<reco::MuonTimeExtra>(event, muonHandle, combinedTimeColl,"combined");
315  fillMuonMap<reco::MuonTimeExtra>(event, muonHandle, dtTimeColl,"dt");
316  fillMuonMap<reco::MuonTimeExtra>(event, muonHandle, cscTimeColl,"csc");
317  }
318 
320  fillMuonMap<reco::IsoDeposit>(event, muonHandle, trackDepColl, labelOrInstance(theTrackDepositName));
321  fillMuonMap<reco::IsoDeposit>(event, muonHandle, jetDepColl, labelOrInstance(theJetDepositName));
322  fillMuonMap<reco::IsoDeposit>(event, muonHandle, ecalDepColl, theEcalDepositName.instance());
323  fillMuonMap<reco::IsoDeposit>(event, muonHandle, hcalDepColl, theHcalDepositName.instance());
324  fillMuonMap<reco::IsoDeposit>(event, muonHandle, hoDepColl, theHoDepositName.instance());
325  }
326 
327  if(fillSelectors_){
328  unsigned int s = 0;
329  for(InputTags::const_iterator tag = theSelectorMapNames.begin();
330  tag != theSelectorMapNames.end(); ++tag, ++s){
331  fillMuonMap<bool>(event, muonHandle, selectorMapResults[s], labelOrInstance(*tag));
332  }
333  }
334 
335  if(fillShoweringInfo_) fillMuonMap<reco::MuonShower>(event, muonHandle, showerInfoColl, labelOrInstance(theShowerMapName));
336 
337  if(fillCosmicsIdMap_){
338  fillMuonMap<unsigned int>(event, muonHandle, cosmicIdColl, labelOrInstance(theCosmicCompMapName));
339  fillMuonMap<reco::MuonCosmicCompatibility>(event, muonHandle, cosmicCompColl, labelOrInstance(theCosmicCompMapName));
340  }
341 
342  fillMuonMap<reco::MuonRef>(event,inputMuonsOH, muonRefColl, theMuToMuMapName);
343 
344  if(fillPFIsolation_){
345  for(unsigned int j=0;j<pfIsoMapNames.size();++j)
346  for(std::map<std::string,edm::InputTag>::const_iterator map = pfIsoMapNames.at(j).begin(); map != pfIsoMapNames.at(j).end(); ++map) {
347  fillMuonMap<double>(event, muonHandle, pfIsoMapVals.at(j)[map->first], labelOrInstance(map->second));
348  }
349  }
350  return;
351  }
352 
353  // FIXME: add the option to swith off the Muon-PF "info association".
354 
355 
356  MuToPFMap muToPFMap;
357 
358  if(fillPFMomentum_){
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;
364  }
365  dout << "Number of PFMuons: " << muToPFMap.size() << endl;
366  dout << "Number of Muons in the original collection: " << inputMuons->size() << endl;
367  }
368 
369  reco::MuonRef::key_type muIndex = 0;
370  unsigned int i = 0;
371  foreach(const reco::Muon &inMuon, *inputMuons){
372 
373  reco::MuonRef muRef(inputMuons, muIndex);
374  muonRefColl[i] = reco::MuonRef(outputMuonsRefProd, muIndex++);
375 
376  // Copy the muon
377  reco::Muon outMuon = inMuon;
378 
379  if(fillPFMomentum_){
380  // search for the corresponding pf candidate
381  MuToPFMap::iterator iter = muToPFMap.find(muRef);
382  if(iter != muToPFMap.end()){
383  const auto& pfMu = pfCandidates->at(iter->second);
384  outMuon.setPFP4(pfMu.p4());
385  outMuon.setP4(pfMu.p4());//PF is the default
386  outMuon.setCharge(pfMu.charge());//PF is the default
387  outMuon.setPdgId(-13*pfMu.charge());
388  outMuon.setBestTrack(pfMu.bestMuonTrackType());
389  muToPFMap.erase(iter);
390  dout << "MuonRef: " << muRef.id() << " " << muRef.key()
391  << " Is it PF? " << outMuon.isPFMuon()
392  << " PF p4: " << outMuon.pfP4() << endl;
393  }
394 
395 
396  dout << "MuonRef: " << muRef.id() << " " << muRef.key()
397  << " Is it PF? " << outMuon.isPFMuon() << endl;
398 
399  dout << "GLB " << outMuon.isGlobalMuon()
400  << " TM " << outMuon.isTrackerMuon()
401  << " STA " << outMuon.isStandAloneMuon()
402  << " p4 " << outMuon.p4() << endl;
403  }
404 
405  // Add PF isolation info
406  if(fillPFIsolation_){
407  thePFIsoHelper->embedPFIsolation(outMuon,muRef);
408 
409  for(unsigned int j=0;j<pfIsoMapNames.size();++j) {
410  for(std::map<std::string,edm::InputTag>::const_iterator map = pfIsoMapNames[j].begin(); map != pfIsoMapNames[j].end(); ++map){
411  (pfIsoMapVals[j])[map->first][i] = (*pfIsoMaps[j][map->first])[muRef];
412  }
413  }
414  }
415 
416  // Fill timing information
417  if(fillTimingInfo_){
418  combinedTimeColl[i] = (*timeMapCmb)[muRef];
419  dtTimeColl[i] = (*timeMapDT)[muRef];
420  cscTimeColl[i] = (*timeMapCSC)[muRef];
421  }
422 
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];;
429  }
430 
431  if(fillSelectors_){
432  unsigned int s = 0;
433  for(InputTags::const_iterator tag = theSelectorMapNames.begin();
434  tag != theSelectorMapNames.end(); ++tag, ++s)
435  selectorMapResults[s][i] = (*selectorMaps[s])[muRef];
436  }
437 
438  // Fill the Showering Info
439  if(fillShoweringInfo_) showerInfoColl[i] = (*showerInfoMap)[muRef];
440 
441  if(fillCosmicsIdMap_){
442  cosmicIdColl[i] = (*cosmicIdMap)[muRef];
443  cosmicCompColl[i] = (*cosmicCompMap)[muRef];
444  }
445 
446  // Standard Selectors - keep it at the end so that all inputs are available
448  outMuon.setSelectors(0); // reset flags
449  bool isRun2016BCDEF = (272728 <= event.run() && event.run() <= 278808);
450  muon::setCutBasedSelectorFlags(outMuon, vertex, isRun2016BCDEF);
451  }
452 
453  outputMuons->push_back(outMuon);
454  ++i;
455  }
456 
457  dout << "Number of Muons in the new muon collection: " << outputMuons->size() << endl;
458  edm::OrphanHandle<reco::MuonCollection> muonHandle = event.put(std::move(outputMuons));
459 
460  if(fillTimingInfo_){
461  fillMuonMap<reco::MuonTimeExtra>(event, muonHandle, combinedTimeColl,"combined");
462  fillMuonMap<reco::MuonTimeExtra>(event, muonHandle, dtTimeColl,"dt");
463  fillMuonMap<reco::MuonTimeExtra>(event, muonHandle, cscTimeColl,"csc");
464  }
465 
467  fillMuonMap<reco::IsoDeposit>(event, muonHandle, trackDepColl, labelOrInstance(theTrackDepositName));
468  fillMuonMap<reco::IsoDeposit>(event, muonHandle, jetDepColl, labelOrInstance(theJetDepositName));
469  fillMuonMap<reco::IsoDeposit>(event, muonHandle, ecalDepColl, theEcalDepositName.instance());
470  fillMuonMap<reco::IsoDeposit>(event, muonHandle, hcalDepColl, theHcalDepositName.instance());
471  fillMuonMap<reco::IsoDeposit>(event, muonHandle, hoDepColl, theHoDepositName.instance());
472  }
473 
474  if(fillPFIsolation_){
475 
476  for(unsigned int j=0;j<pfIsoMapNames.size();++j) {
477  for(std::map<std::string,edm::InputTag>::const_iterator map = pfIsoMapNames[j].begin(); map != pfIsoMapNames[j].end(); ++map)
478  fillMuonMap<double>(event, muonHandle, pfIsoMapVals[j][map->first], labelOrInstance(map->second));
479  }
480  }
481 
482  if(fillSelectors_){
483  unsigned int s = 0;
484  for(InputTags::const_iterator tag = theSelectorMapNames.begin();
485  tag != theSelectorMapNames.end(); ++tag, ++s)
486  fillMuonMap<bool>(event, muonHandle, selectorMapResults[s], labelOrInstance(*tag));
487  }
488 
489  if(fillShoweringInfo_) fillMuonMap<reco::MuonShower>(event, muonHandle, showerInfoColl, labelOrInstance(theShowerMapName));
490 
491  if(fillCosmicsIdMap_){
492  fillMuonMap<unsigned int>(event, muonHandle, cosmicIdColl, labelOrInstance(theCosmicCompMapName));
493  fillMuonMap<reco::MuonCosmicCompatibility>(event, muonHandle, cosmicCompColl, labelOrInstance(theCosmicCompMapName));
494  }
495 
496  fillMuonMap<reco::MuonRef>(event,inputMuonsOH, muonRefColl, theMuToMuMapName);
497 
498 
499 }
500 
501 
502 
503 template<typename TYPE>
505  const edm::OrphanHandle<reco::MuonCollection>& muonHandle,
506  const std::vector<TYPE>& muonExtra,
507  const std::string& label){
508 
509  typedef typename edm::ValueMap<TYPE>::Filler FILLER;
510 
511  auto muonMap = std::make_unique<edm::ValueMap<TYPE>>();
512  if(!muonExtra.empty()){
513  FILLER filler(*muonMap);
514  filler.insert(muonHandle, muonExtra.begin(), muonExtra.end());
515  filler.fill();
516  }
517  event.put(std::move(muonMap),label);
518 }
519 
520 
522  if(fastLabelling_) return input.label();
523 
524  return input.label() != theMuonsCollectionLabel.label() ? input.label() : input.instance();
525 }
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_
Definition: MuonProducer.h:133
T getUntrackedParameter(std::string const &, T const &) const
edm::InputTag theTrackDepositName
Definition: MuonProducer.h:104
std::remove_cv< typename std::remove_reference< argument_type >::type >::type key_type
Definition: Ref.h:169
edm::EDGetTokenT< edm::ValueMap< unsigned int > > theCosmicIdMapToken_
Definition: MuonProducer.h:125
bool isStandAloneMuon() const override
Definition: Muon.h:267
edm::EDGetTokenT< reco::MuonTimeExtraMap > timeMapDTToken_
Definition: MuonProducer.h:132
const std::string metname
bool fillSelectors_
Definition: MuonProducer.h:95
#define dout
Definition: MuonProducer.cc:19
std::string theAlias
Definition: MuonProducer.h:72
edm::EDGetTokenT< edm::ValueMap< reco::MuonShower > > theShowerMapToken_
Definition: MuonProducer.h:122
void setCutBasedSelectorFlags(reco::Muon &muon, const reco::Vertex *vertex=0, bool run2016_hip_mitigation=false)
key_type key() const
Accessor for product key.
Definition: Ref.h:265
edm::InputTag theEcalDepositName
Definition: MuonProducer.h:105
reco::Candidate::LorentzVector pfP4() const
Definition: Muon.h:102
void produce(edm::Event &, const edm::EventSetup &) override
reconstruct muons
std::vector< edm::EDGetTokenT< edm::ValueMap< bool > > > theSelectorMapTokens_
Definition: MuonProducer.h:118
edm::EDGetTokenT< reco::IsoDepositMap > theJetDepositToken_
Definition: MuonProducer.h:114
std::map< reco::MuonRef, unsigned int > MuToPFMap
Definition: MuonProducer.cc:24
ProductID id() const
Accessor for product ID.
Definition: Ref.h:259
std::vector< Muon > MuonCollection
collection of Muon objects
Definition: MuonFwd.h:9
bool fillCosmicsIdMap_
Definition: MuonProducer.h:96
edm::ValueMap< reco::MuonShower > MuonShowerMap
Definition: MuonProducer.cc:28
static std::string const input
Definition: EdmProvDump.cc:44
edm::EDGetTokenT< reco::IsoDepositMap > theHoDepositToken_
Definition: MuonProducer.h:113
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
bool isTrackerMuon() const override
Definition: Muon.h:266
ProductID id() const
edm::InputTag thePFCandLabel
Definition: MuonProducer.h:88
void setCharge(Charge q) final
set electric charge
Definition: LeafCandidate.h:93
edm::EDGetTokenT< reco::PFCandidateCollection > thePFCandToken_
Definition: MuonProducer.h:89
std::vector< std::map< std::string, edm::InputTag > > pfIsoMapNames
Definition: MuonProducer.h:138
void fillMuonMap(edm::Event &event, const edm::OrphanHandle< reco::MuonCollection > &muonHandle, const std::vector< TYPE > &muonExtra, const std::string &label)
bool isGlobalMuon() const override
Definition: Muon.h:265
edm::EDGetTokenT< reco::IsoDepositMap > theTrackDepositToken_
Definition: MuonProducer.h:110
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
bool fillDetectorBasedIsolation_
Definition: MuonProducer.h:99
std::vector< std::map< std::string, edm::EDGetTokenT< edm::ValueMap< double > > > > pfIsoMapTokens_
Definition: MuonProducer.h:139
void setAlias(std::string alias)
Definition: MuonProducer.h:74
edm::InputTag theMuonsCollectionLabel
Definition: MuonProducer.h:85
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
std::string labelOrInstance(const edm::InputTag &) const
edm::Ref< MuonCollection > MuonRef
presistent reference to a Muon
Definition: MuonFwd.h:13
const LorentzVector & p4() const final
four-momentum Lorentz vector
Definition: LeafCandidate.h:99
edm::InputTag theShowerMapName
Definition: MuonProducer.h:121
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_
Definition: MuonProducer.h:131
edm::InputTag theHoDepositName
Definition: MuonProducer.h:107
bool fillTimingInfo_
Definition: MuonProducer.h:101
edm::EDGetTokenT< reco::VertexCollection > vertexes_
Definition: MuonProducer.h:141
bool computeStandardSelectors_
Definition: MuonProducer.h:102
std::vector< edm::InputTag > InputTags
Definition: MuonProducer.h:61
bool fillPFIsolation_
Definition: MuonProducer.h:98
InputTags theSelectorMapNames
Definition: MuonProducer.h:117
edm::EDGetTokenT< reco::MuonCollection > theMuonsCollectionToken_
Definition: MuonProducer.h:86
std::string theMuToMuMapName
Definition: MuonProducer.h:127
bool fillShoweringInfo_
Definition: MuonProducer.h:100
edm::EDGetTokenT< reco::IsoDepositMap > theEcalDepositToken_
Definition: MuonProducer.h:111
primaryVertices
Definition: jets_cff.py:73
void setSelectors(unsigned int selectors)
Definition: Muon.h:217
int embedPFIsolation(reco::Muon &, reco::MuonRef &)
edm::EDGetTokenT< edm::ValueMap< reco::MuonCosmicCompatibility > > theCosmicCompMapToken_
Definition: MuonProducer.h:126
std::string const & label() const
Definition: InputTag.h:36
MuPFIsoHelper * thePFIsoHelper
Definition: MuonProducer.h:129
void beginEvent(const edm::Event &iEvent)
fixed size matrix
virtual void setBestTrack(MuonTrackType muonType)
Definition: Muon.h:91
#define begin
Definition: vmac.h:30
edm::EDGetTokenT< reco::IsoDepositMap > theHcalDepositToken_
Definition: MuonProducer.h:112
edm::InputTag theCosmicCompMapName
Definition: MuonProducer.h:124
MuonProducer(const edm::ParameterSet &)
Constructor.
Definition: MuonProducer.cc:33
bool fastLabelling_
Definition: MuonProducer.h:83
bool isPFMuon() const
Definition: Muon.h:269
virtual void setPFP4(const reco::Candidate::LorentzVector &p4_)
edm::InputTag theHcalDepositName
Definition: MuonProducer.h:106
bool fillPFMomentum_
Definition: MuonProducer.h:97
~MuonProducer() override
Destructor.
void setPdgId(int pdgId) final
std::string const & instance() const
Definition: InputTag.h:37
edm::InputTag theJetDepositName
Definition: MuonProducer.h:108
void setP4(const LorentzVector &p4) final
set 4-momentum
def move(src, dest)
Definition: eostools.py:510
Definition: event.py:1