CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Types | Public Member Functions | Private Member Functions | Private Attributes
MuonProducer Class Reference

#include <MuonProducer.h>

Inheritance diagram for MuonProducer:
edm::EDProducer edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Types

typedef std::vector
< edm::InputTag
InputTags
 
- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
typedef WorkerT< EDProducerWorkerType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 

Public Member Functions

 MuonProducer (const edm::ParameterSet &)
 Constructor. More...
 
virtual void produce (edm::Event &, const edm::EventSetup &)
 reconstruct muons More...
 
virtual ~MuonProducer ()
 Destructor. More...
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription
const &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
 EDConsumerBase ()
 
ProductHolderIndex indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndex > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndex > &) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Member Functions

template<typename TYPE >
void fillMuonMap (edm::Event &event, const edm::OrphanHandle< reco::MuonCollection > &muonHandle, const std::vector< TYPE > &muonExtra, const std::string &label)
 
std::string labelOrInstance (const edm::InputTag &) const
 
void setAlias (std::string alias)
 

Private Attributes

bool debug_
 
bool fastLabelling_
 
bool fillCosmicsIdMap_
 
bool fillDetectorBasedIsolation_
 
bool fillIsolation_
 
bool fillPFIsolation_
 
bool fillPFMomentum_
 
bool fillSelectors_
 
bool fillShoweringInfo_
 
bool fillTimingInfo_
 
std::vector< std::map
< std::string, edm::InputTag > > 
pfIsoMapNames
 
std::string theAlias
 
edm::InputTag theCosmicCompMapName
 
edm::InputTag theEcalDepositName
 
edm::InputTag theHcalDepositName
 
edm::InputTag theHoDepositName
 
edm::InputTag theJetDepositName
 
edm::InputTag theMuonsCollectionLabel
 
std::string theMuToMuMapName
 
edm::InputTag thePFCandLabel
 
MuPFIsoHelperthePFIsoHelper
 
InputTags theSelectorMapNames
 
edm::InputTag theShowerMapName
 
edm::InputTag theTrackDepositName
 
bool writeIsoDeposits_
 

Additional Inherited Members

- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDProducer
CurrentProcessingContext const * currentContext () const
 
- Protected Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Detailed Description

See header file.

Date:
2013/02/07 00:32:22
Revision:
1.18
Author
R. Bellan - UCSB ricca.nosp@m.rdo..nosp@m.bella.nosp@m.n@ce.nosp@m.rn.ch

Producer meant for the Post PF reconstruction.

This class takes the muon collection produced before the PF is run (muons1Step) and the information calculated after that the entire event has been reconstructed. The collections produced here are meant to be used for the final analysis (or as PAT input). The previous muon collection is meant to be transient.

Date:
2012/07/21 00:38:17
Revision:
1.15
Author
R. Bellan - UCSB ricca.nosp@m.rdo..nosp@m.bella.nosp@m.n@ce.nosp@m.rn.ch

Definition at line 29 of file MuonProducer.h.

Member Typedef Documentation

typedef std::vector<edm::InputTag> MuonProducer::InputTags

Definition at line 42 of file MuonProducer.h.

Constructor & Destructor Documentation

MuonProducer::MuonProducer ( const edm::ParameterSet pSet)

Constructor.

Definition at line 50 of file MuonProducer.cc.

References fastLabelling_, fillCosmicsIdMap_, fillDetectorBasedIsolation_, fillPFIsolation_, fillPFMomentum_, fillSelectors_, fillShoweringInfo_, fillTimingInfo_, edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), j, diffTwoXMLs::label, labelOrInstance(), Association::map, pfIsoMapNames, edm::ProductRegistryHelper::produces(), setAlias(), AlCaHLTBitMon_QueryRunRegistry::string, GlobalPosition_Frontier_DevDB_cff::tag, theAlias, theCosmicCompMapName, theEcalDepositName, theHcalDepositName, theHoDepositName, theJetDepositName, theMuonsCollectionLabel, theMuToMuMapName, thePFCandLabel, thePFIsoHelper, theSelectorMapNames, theShowerMapName, and theTrackDepositName.

50  :debug_(pSet.getUntrackedParameter<bool>("ActivateDebug",false)){
51 
52  setAlias(pSet.getParameter<std::string>("@module_label"));
53 
54  fastLabelling_ = pSet.getUntrackedParameter<bool>("FastLabelling",true);
55 
56 
58  thePFCandLabel = pSet.getParameter<edm::InputTag>("PFCandidates");
59 
60 
61  // Variables to switch on-off the differnt parts
62  fillSelectors_ = pSet.getParameter<bool>("FillSelectorMaps");
63  fillCosmicsIdMap_ = pSet.getParameter<bool>("FillCosmicsIdMap");
64  fillPFMomentum_ = pSet.getParameter<bool>("FillPFMomentumAndAssociation");
65  fillPFIsolation_ = pSet.getParameter<bool>("FillPFIsolation");
66  fillDetectorBasedIsolation_ = pSet.getParameter<bool>("FillDetectorBasedIsolation");
67  fillShoweringInfo_ = pSet.getParameter<bool>("FillShoweringInfo");
68  fillTimingInfo_ = pSet.getParameter<bool>("FillTimingInfo");
69 
70  produces<reco::MuonCollection>();
71 
72  if(fillTimingInfo_){
73  produces<reco::MuonTimeExtraMap>("combined");
74  produces<reco::MuonTimeExtraMap>("dt");
75  produces<reco::MuonTimeExtraMap>("csc");
76  }
77 
78  if (fillDetectorBasedIsolation_){
79  theTrackDepositName = pSet.getParameter<edm::InputTag>("TrackIsoDeposits");
80  produces<reco::IsoDepositMap>(labelOrInstance(theTrackDepositName));
81  theJetDepositName = pSet.getParameter<edm::InputTag>("JetIsoDeposits");
82  produces<reco::IsoDepositMap>(labelOrInstance(theJetDepositName));
83  theEcalDepositName = pSet.getParameter<edm::InputTag>("EcalIsoDeposits");
84  produces<reco::IsoDepositMap>(theEcalDepositName.instance());
85  theHcalDepositName = pSet.getParameter<edm::InputTag>("HcalIsoDeposits");
86  produces<reco::IsoDepositMap>(theHcalDepositName.instance());
87  theHoDepositName = pSet.getParameter<edm::InputTag>("HoIsoDeposits");
88  produces<reco::IsoDepositMap>(theHoDepositName.instance());
89  }
90 
91  if(fillSelectors_){
92  theSelectorMapNames = pSet.getParameter<InputTags>("SelectorMaps");
93 
94  for(InputTags::const_iterator tag = theSelectorMapNames.begin(); tag != theSelectorMapNames.end(); ++tag)
96  }
97 
98  if(fillShoweringInfo_){
99  theShowerMapName = pSet.getParameter<edm::InputTag>("ShowerInfoMap");
100  produces<edm::ValueMap<reco::MuonShower> >(labelOrInstance(theShowerMapName));
101  }
102 
103  if(fillCosmicsIdMap_){
104  theCosmicCompMapName = pSet.getParameter<edm::InputTag>("CosmicIdMap");
105  produces<edm::ValueMap<reco::MuonCosmicCompatibility> >(labelOrInstance(theCosmicCompMapName));
106  produces<edm::ValueMap<unsigned int> >(labelOrInstance(theCosmicCompMapName));
107  }
108 
109  theMuToMuMapName = theMuonsCollectionLabel.label()+"2"+theAlias+"sMap";
110  produces<edm::ValueMap<reco::MuonRef> >(theMuToMuMapName);
111 
112 
113 
114 
115  if(fillPFIsolation_){
116 
117  edm::ParameterSet pfIsoPSet = pSet.getParameter<edm::ParameterSet >("PFIsolation");
118 
119  //Define a map between the isolation and the PSet for the PFHelper
120  std::map<std::string,edm::ParameterSet> psetMap;
121 
122  //First declare what isolation you are going to read
123  std::vector<std::string> isolationLabels;
124  isolationLabels.push_back("pfIsolationR03");
125  isolationLabels.push_back("pfIsoMeanDRProfileR03");
126  isolationLabels.push_back("pfIsoSumDRProfileR03");
127  isolationLabels.push_back("pfIsolationR04");
128  isolationLabels.push_back("pfIsoMeanDRProfileR04");
129  isolationLabels.push_back("pfIsoSumDRProfileR04");
130 
131  //Fill the label,pet map and initialize MuPFIsoHelper
132  for( std::vector<std::string>::const_iterator label = isolationLabels.begin();label != isolationLabels.end();++label)
133  psetMap[*label] =pfIsoPSet.getParameter<edm::ParameterSet >(*label);
134  thePFIsoHelper = new MuPFIsoHelper(psetMap);
135 
136  //Now loop on the mass read for each PSet the parameters and save them to the mapNames for later
137 
138  for(std::map<std::string,edm::ParameterSet>::const_iterator map = psetMap.begin();map!= psetMap.end();++map) {
139  std::map<std::string,edm::InputTag> isoMap;
140  isoMap["chargedParticle"] = map->second.getParameter<edm::InputTag>("chargedParticle");
141  isoMap["chargedHadron"] = map->second.getParameter<edm::InputTag>("chargedHadron");
142  isoMap["neutralHadron"] = map->second.getParameter<edm::InputTag>("neutralHadron");
143  isoMap["neutralHadronHighThreshold"] = map->second.getParameter<edm::InputTag>("neutralHadronHighThreshold");
144  isoMap["photon"] = map->second.getParameter<edm::InputTag>("photon");
145  isoMap["photonHighThreshold"] = map->second.getParameter<edm::InputTag>("photonHighThreshold");
146  isoMap["pu"] = map->second.getParameter<edm::InputTag>("pu");
147  pfIsoMapNames.push_back(isoMap);
148  }
149 
150 
151  for(unsigned int j=0;j<pfIsoMapNames.size();++j) {
152  for(std::map<std::string,edm::InputTag>::const_iterator map = pfIsoMapNames.at(j).begin(); map != pfIsoMapNames.at(j).end(); ++map)
154 
155  }
156 
157  }
158 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
edm::InputTag theTrackDepositName
Definition: MuonProducer.h:79
bool fillSelectors_
Definition: MuonProducer.h:71
std::string theAlias
Definition: MuonProducer.h:53
edm::InputTag theEcalDepositName
Definition: MuonProducer.h:80
bool fillCosmicsIdMap_
Definition: MuonProducer.h:72
dictionary map
Definition: Association.py:205
edm::InputTag thePFCandLabel
Definition: MuonProducer.h:67
std::vector< std::map< std::string, edm::InputTag > > pfIsoMapNames
Definition: MuonProducer.h:94
bool fillDetectorBasedIsolation_
Definition: MuonProducer.h:75
void setAlias(std::string alias)
Definition: MuonProducer.h:55
TypeLabelItem const & produces()
declare what type of product will make and with which optional label
edm::InputTag theMuonsCollectionLabel
Definition: MuonProducer.h:66
int j
Definition: DBlmapReader.cc:9
std::string labelOrInstance(const edm::InputTag &) const
edm::InputTag theShowerMapName
Definition: MuonProducer.h:87
edm::InputTag theHoDepositName
Definition: MuonProducer.h:82
bool fillTimingInfo_
Definition: MuonProducer.h:77
std::vector< edm::InputTag > InputTags
Definition: MuonProducer.h:42
bool fillPFIsolation_
Definition: MuonProducer.h:74
InputTags theSelectorMapNames
Definition: MuonProducer.h:85
std::string theMuToMuMapName
Definition: MuonProducer.h:90
bool fillShoweringInfo_
Definition: MuonProducer.h:76
MuPFIsoHelper * thePFIsoHelper
Definition: MuonProducer.h:92
edm::InputTag theCosmicCompMapName
Definition: MuonProducer.h:88
bool fastLabelling_
Definition: MuonProducer.h:64
edm::InputTag theHcalDepositName
Definition: MuonProducer.h:81
bool fillPFMomentum_
Definition: MuonProducer.h:73
edm::InputTag theJetDepositName
Definition: MuonProducer.h:83
MuonProducer::~MuonProducer ( )
virtual

Destructor.

Definition at line 161 of file MuonProducer.cc.

References fillPFIsolation_, and thePFIsoHelper.

161  {
163 }
bool fillPFIsolation_
Definition: MuonProducer.h:74
MuPFIsoHelper * thePFIsoHelper
Definition: MuonProducer.h:92

Member Function Documentation

template<typename TYPE >
void MuonProducer::fillMuonMap ( edm::Event event,
const edm::OrphanHandle< reco::MuonCollection > &  muonHandle,
const std::vector< TYPE > &  muonExtra,
const std::string &  label 
)
private

Definition at line 461 of file MuonProducer.cc.

464  {
465 
466  typedef typename edm::ValueMap<TYPE>::Filler FILLER;
467 
468  std::auto_ptr<edm::ValueMap<TYPE> > muonMap(new edm::ValueMap<TYPE>());
469  if(!muonExtra.empty()){
470  FILLER filler(*muonMap);
471  filler.insert(muonHandle, muonExtra.begin(), muonExtra.end());
472  filler.fill();
473  }
474  event.put(muonMap,label);
475 }
std::string MuonProducer::labelOrInstance ( const edm::InputTag input) const
private

Definition at line 478 of file MuonProducer.cc.

References fastLabelling_, edm::InputTag::instance(), edm::InputTag::label(), and theMuonsCollectionLabel.

Referenced by MuonProducer(), and produce().

478  {
479  if(fastLabelling_) return input.label();
480 
481  return input.label() != theMuonsCollectionLabel.label() ? input.label() : input.instance();
482 }
edm::InputTag theMuonsCollectionLabel
Definition: MuonProducer.h:66
std::string const & label() const
Definition: InputTag.h:42
bool fastLabelling_
Definition: MuonProducer.h:64
std::string const & instance() const
Definition: InputTag.h:43
void MuonProducer::produce ( edm::Event event,
const edm::EventSetup eventSetup 
)
virtual

reconstruct muons

Implements edm::EDProducer.

Definition at line 167 of file MuonProducer.cc.

References abs, begin, MuPFIsoHelper::beginEvent(), dout, MuPFIsoHelper::embedPFIsolation(), event(), fillCosmicsIdMap_, fillDetectorBasedIsolation_, fillPFIsolation_, fillPFMomentum_, fillSelectors_, fillShoweringInfo_, fillTimingInfo_, i, edm::OrphanHandleBase::id(), edm::Ref< C, T, F >::id(), edm::InputTag::instance(), reco::Muon::isGlobalMuon(), reco::Muon::isPFMuon(), reco::Muon::isStandAloneMuon(), reco::Muon::isTrackerMuon(), j, edm::Ref< C, T, F >::key(), edm::InputTag::label(), labelOrInstance(), Association::map, metname, reco::LeafCandidate::p4(), reco::tau::pfCandidates(), pfIsoMapNames, reco::Muon::pfP4(), alignCSCRings::s, reco::Muon::setBestTrack(), reco::LeafCandidate::setP4(), reco::Muon::setPFP4(), AlCaHLTBitMon_QueryRunRegistry::string, GlobalPosition_Frontier_DevDB_cff::tag, theCosmicCompMapName, theEcalDepositName, theHcalDepositName, theHoDepositName, theJetDepositName, theMuonsCollectionLabel, theMuToMuMapName, thePFCandLabel, thePFIsoHelper, theSelectorMapNames, theShowerMapName, and theTrackDepositName.

167  {
168 
169  const std::string metname = "Muon|RecoMuon|MuonIdentification|MuonProducer";
170 
171  // the muon collection, it will be loaded in the event
172  std::auto_ptr<reco::MuonCollection> outputMuons(new reco::MuonCollection());
173  reco::MuonRefProd outputMuonsRefProd = event.getRefBeforePut<reco::MuonCollection>();
174 
176  event.getByLabel(theMuonsCollectionLabel, inputMuons);
177  edm::OrphanHandle<reco::MuonCollection> inputMuonsOH(inputMuons.product(), inputMuons.id());
178 
180  event.getByLabel(thePFCandLabel, pfCandidates);
181 
182 
183  // fetch collections for PFIso
185 
186 
187  // Fill timing information
191 
192  int nMuons=inputMuons->size();
193 
194  std::vector<reco::MuonTimeExtra> dtTimeColl(nMuons);
195  std::vector<reco::MuonTimeExtra> cscTimeColl(nMuons);
196  std::vector<reco::MuonTimeExtra> combinedTimeColl(nMuons);
197 
198  if(fillTimingInfo_){
199  event.getByLabel(theMuonsCollectionLabel.label(),"combined",timeMapCmb);
200  event.getByLabel(theMuonsCollectionLabel.label(),"dt",timeMapDT);
201  event.getByLabel(theMuonsCollectionLabel.label(),"csc",timeMapCSC);
202  }
203 
204  std::vector<reco::IsoDeposit> trackDepColl(nMuons);
205  std::vector<reco::IsoDeposit> ecalDepColl(nMuons);
206  std::vector<reco::IsoDeposit> hcalDepColl(nMuons);
207  std::vector<reco::IsoDeposit> hoDepColl(nMuons);
208  std::vector<reco::IsoDeposit> jetDepColl(nMuons);
209 
210 
211  edm::Handle<reco::IsoDepositMap> trackIsoDepMap;
212  edm::Handle<reco::IsoDepositMap> ecalIsoDepMap;
213  edm::Handle<reco::IsoDepositMap> hcalIsoDepMap;
216 
217 
219  event.getByLabel(theTrackDepositName,trackIsoDepMap);
220  event.getByLabel(theEcalDepositName,ecalIsoDepMap);
221  event.getByLabel(theHcalDepositName,hcalIsoDepMap);
222  event.getByLabel(theHoDepositName,hoIsoDepMap);
223  event.getByLabel(theJetDepositName,jetIsoDepMap);
224  }
225 
226 
227 
228  std::vector<std::map<std::string,edm::Handle<edm::ValueMap<double> > > > pfIsoMaps;
229  std::vector<std::map<std::string,std::vector<double> > > pfIsoMapVals;
230 
231  if(fillPFIsolation_){
232  for(unsigned int j=0;j<pfIsoMapNames.size();++j) {
233  std::map<std::string,std::vector<double> > mapVals;
234  std::map<std::string,edm::Handle<edm::ValueMap<double> > > maps;
235  for(std::map<std::string,edm::InputTag>::const_iterator map = pfIsoMapNames.at(j).begin(); map != pfIsoMapNames.at(j).end(); ++map) {
237  event.getByLabel(map->second,handleTmp);
238  maps[map->first]=handleTmp;
239  mapVals[map->first].resize(nMuons);
240  }
241  pfIsoMapVals.push_back(mapVals);
242  pfIsoMaps.push_back(maps);
243 
244  }
245  }
246 
247 
248 
249  std::vector<edm::Handle<edm::ValueMap<bool> > > selectorMaps(fillSelectors_ ? theSelectorMapNames.size() : 0);
250  std::vector<std::vector<bool> > selectorMapResults(fillSelectors_ ? theSelectorMapNames.size() : 0);
251  if(fillSelectors_){
252  unsigned int s=0;
253  for(InputTags::const_iterator tag = theSelectorMapNames.begin(); tag != theSelectorMapNames.end(); ++tag, ++s){
254  event.getByLabel(*tag,selectorMaps[s]);
255  selectorMapResults[s].resize(nMuons);
256  }
257  }
258 
259  edm::Handle<reco::MuonShowerMap> showerInfoMap;
260  if(fillShoweringInfo_) event.getByLabel(theShowerMapName,showerInfoMap);
261 
262  std::vector<reco::MuonShower> showerInfoColl(nMuons);
263 
265  if(fillCosmicsIdMap_) event.getByLabel(theCosmicCompMapName,cosmicIdMap);
266  std::vector<unsigned int> cosmicIdColl(fillCosmicsIdMap_ ? nMuons : 0);
267 
269  if(fillCosmicsIdMap_) event.getByLabel(theCosmicCompMapName,cosmicCompMap);
270  std::vector<reco::MuonCosmicCompatibility> cosmicCompColl(fillCosmicsIdMap_ ? nMuons : 0);
271 
272 
273  std::vector<reco::MuonRef> muonRefColl(nMuons);
274 
275 
276 
277  if(inputMuons->empty()) {
278  edm::OrphanHandle<reco::MuonCollection> muonHandle = event.put(outputMuons);
279 
280  if(fillTimingInfo_){
281  fillMuonMap<reco::MuonTimeExtra>(event, muonHandle, combinedTimeColl,"combined");
282  fillMuonMap<reco::MuonTimeExtra>(event, muonHandle, dtTimeColl,"dt");
283  fillMuonMap<reco::MuonTimeExtra>(event, muonHandle, cscTimeColl,"csc");
284  }
285 
287  fillMuonMap<reco::IsoDeposit>(event, muonHandle, trackDepColl, labelOrInstance(theTrackDepositName));
288  fillMuonMap<reco::IsoDeposit>(event, muonHandle, jetDepColl, labelOrInstance(theJetDepositName));
289  fillMuonMap<reco::IsoDeposit>(event, muonHandle, ecalDepColl, theEcalDepositName.instance());
290  fillMuonMap<reco::IsoDeposit>(event, muonHandle, hcalDepColl, theHcalDepositName.instance());
291  fillMuonMap<reco::IsoDeposit>(event, muonHandle, hoDepColl, theHoDepositName.instance());
292  }
293 
294  if(fillSelectors_){
295  unsigned int s = 0;
296  for(InputTags::const_iterator tag = theSelectorMapNames.begin();
297  tag != theSelectorMapNames.end(); ++tag, ++s){
298  fillMuonMap<bool>(event, muonHandle, selectorMapResults[s], labelOrInstance(*tag));
299  }
300  }
301 
302  if(fillShoweringInfo_) fillMuonMap<reco::MuonShower>(event, muonHandle, showerInfoColl, labelOrInstance(theShowerMapName));
303 
304  if(fillCosmicsIdMap_){
305  fillMuonMap<unsigned int>(event, muonHandle, cosmicIdColl, labelOrInstance(theCosmicCompMapName));
306  fillMuonMap<reco::MuonCosmicCompatibility>(event, muonHandle, cosmicCompColl, labelOrInstance(theCosmicCompMapName));
307  }
308 
309  fillMuonMap<reco::MuonRef>(event,inputMuonsOH, muonRefColl, theMuToMuMapName);
310 
311  if(fillPFIsolation_){
312  for(unsigned int j=0;j<pfIsoMapNames.size();++j)
313  for(std::map<std::string,edm::InputTag>::const_iterator map = pfIsoMapNames.at(j).begin(); map != pfIsoMapNames.at(j).end(); ++map) {
314  fillMuonMap<double>(event, muonHandle, pfIsoMapVals.at(j)[map->first], labelOrInstance(map->second));
315  }
316  }
317  return;
318  }
319 
320  // FIXME: add the option to swith off the Muon-PF "info association".
321 
322 
323  MuToPFMap muToPFMap;
324 
325  if(fillPFMomentum_){
326  dout << "Number of PFCandidates: " << pfCandidates->size() << endl;
327  for(unsigned int i=0;i< pfCandidates->size();++i)
328  if(abs(pfCandidates->at(i).pdgId()) == 13){
329  muToPFMap[pfCandidates->at(i).muonRef()] = i;
330  dout << "MuonRef: " << pfCandidates->at(i).muonRef().id() << " " << pfCandidates->at(i).muonRef().key() << " PF p4: " << pfCandidates->at(i).p4() << endl;
331  }
332  dout << "Number of PFMuons: " << muToPFMap.size() << endl;
333  dout << "Number of Muons in the original collection: " << inputMuons->size() << endl;
334  }
335 
336  reco::MuonRef::key_type muIndex = 0;
337  unsigned int i = 0;
338  foreach(const reco::Muon &inMuon, *inputMuons){
339 
340  reco::MuonRef muRef(inputMuons, muIndex);
341  muonRefColl[i] = reco::MuonRef(outputMuonsRefProd, muIndex++);
342 
343  // Copy the muon
344  reco::Muon outMuon = inMuon;
345 
346  if(fillPFMomentum_){
347  // search for the corresponding pf candidate
348  MuToPFMap::iterator iter = muToPFMap.find(muRef);
349  if(iter != muToPFMap.end()){
350  outMuon.setPFP4(pfCandidates->at(iter->second).p4());
351  outMuon.setP4(pfCandidates->at(iter->second).p4());//PF is the default
352  outMuon.setBestTrack(pfCandidates->at(iter->second).bestMuonTrackType());
353  muToPFMap.erase(iter);
354  dout << "MuonRef: " << muRef.id() << " " << muRef.key()
355  << " Is it PF? " << outMuon.isPFMuon()
356  << " PF p4: " << outMuon.pfP4() << endl;
357  }
358 
359 
360  dout << "MuonRef: " << muRef.id() << " " << muRef.key()
361  << " Is it PF? " << outMuon.isPFMuon() << endl;
362 
363  dout << "GLB " << outMuon.isGlobalMuon()
364  << " TM " << outMuon.isTrackerMuon()
365  << " STA " << outMuon.isStandAloneMuon()
366  << " p4 " << outMuon.p4() << endl;
367  }
368 
369  // Add PF isolation info
370  if(fillPFIsolation_){
371  thePFIsoHelper->embedPFIsolation(outMuon,muRef);
372 
373  for(unsigned int j=0;j<pfIsoMapNames.size();++j) {
374  for(std::map<std::string,edm::InputTag>::const_iterator map = pfIsoMapNames[j].begin(); map != pfIsoMapNames[j].end(); ++map){
375  (pfIsoMapVals[j])[map->first][i] = (*pfIsoMaps[j][map->first])[muRef];
376  }
377  }
378  }
379 
380  // Fill timing information
381  if(fillTimingInfo_){
382  combinedTimeColl[i] = (*timeMapCmb)[muRef];
383  dtTimeColl[i] = (*timeMapDT)[muRef];
384  cscTimeColl[i] = (*timeMapCSC)[muRef];
385  }
386 
388  trackDepColl[i] = (*trackIsoDepMap)[muRef];
389  ecalDepColl[i] = (*ecalIsoDepMap)[muRef];
390  hcalDepColl[i] = (*hcalIsoDepMap)[muRef];
391  hoDepColl[i] = (*hoIsoDepMap)[muRef];
392  jetDepColl[i] = (*jetIsoDepMap)[muRef];;
393  }
394 
395  if(fillSelectors_){
396  unsigned int s = 0;
397  for(InputTags::const_iterator tag = theSelectorMapNames.begin();
398  tag != theSelectorMapNames.end(); ++tag, ++s)
399  selectorMapResults[s][i] = (*selectorMaps[s])[muRef];
400  }
401 
402  // Fill the Showering Info
403  if(fillShoweringInfo_) showerInfoColl[i] = (*showerInfoMap)[muRef];
404 
405  if(fillCosmicsIdMap_){
406  cosmicIdColl[i] = (*cosmicIdMap)[muRef];
407  cosmicCompColl[i] = (*cosmicCompMap)[muRef];
408  }
409 
410  outputMuons->push_back(outMuon);
411  ++i;
412  }
413 
414  dout << "Number of Muons in the new muon collection: " << outputMuons->size() << endl;
415  edm::OrphanHandle<reco::MuonCollection> muonHandle = event.put(outputMuons);
416 
417  if(fillTimingInfo_){
418  fillMuonMap<reco::MuonTimeExtra>(event, muonHandle, combinedTimeColl,"combined");
419  fillMuonMap<reco::MuonTimeExtra>(event, muonHandle, dtTimeColl,"dt");
420  fillMuonMap<reco::MuonTimeExtra>(event, muonHandle, cscTimeColl,"csc");
421  }
422 
424  fillMuonMap<reco::IsoDeposit>(event, muonHandle, trackDepColl, labelOrInstance(theTrackDepositName));
425  fillMuonMap<reco::IsoDeposit>(event, muonHandle, jetDepColl, labelOrInstance(theJetDepositName));
426  fillMuonMap<reco::IsoDeposit>(event, muonHandle, ecalDepColl, theEcalDepositName.instance());
427  fillMuonMap<reco::IsoDeposit>(event, muonHandle, hcalDepColl, theHcalDepositName.instance());
428  fillMuonMap<reco::IsoDeposit>(event, muonHandle, hoDepColl, theHoDepositName.instance());
429  }
430 
431  if(fillPFIsolation_){
432 
433  for(unsigned int j=0;j<pfIsoMapNames.size();++j) {
434  for(std::map<std::string,edm::InputTag>::const_iterator map = pfIsoMapNames[j].begin(); map != pfIsoMapNames[j].end(); ++map)
435  fillMuonMap<double>(event, muonHandle, pfIsoMapVals[j][map->first], labelOrInstance(map->second));
436  }
437  }
438 
439  if(fillSelectors_){
440  unsigned int s = 0;
441  for(InputTags::const_iterator tag = theSelectorMapNames.begin();
442  tag != theSelectorMapNames.end(); ++tag, ++s)
443  fillMuonMap<bool>(event, muonHandle, selectorMapResults[s], labelOrInstance(*tag));
444  }
445 
446  if(fillShoweringInfo_) fillMuonMap<reco::MuonShower>(event, muonHandle, showerInfoColl, labelOrInstance(theShowerMapName));
447 
448  if(fillCosmicsIdMap_){
449  fillMuonMap<unsigned int>(event, muonHandle, cosmicIdColl, labelOrInstance(theCosmicCompMapName));
450  fillMuonMap<reco::MuonCosmicCompatibility>(event, muonHandle, cosmicCompColl, labelOrInstance(theCosmicCompMapName));
451  }
452 
453  fillMuonMap<reco::MuonRef>(event,inputMuonsOH, muonRefColl, theMuToMuMapName);
454 
455 
456 }
int i
Definition: DBlmapReader.cc:9
edm::InputTag theTrackDepositName
Definition: MuonProducer.h:79
virtual const LorentzVector & p4() const GCC11_FINAL
four-momentum Lorentz vector
const std::string metname
bool isTrackerMuon() const
Definition: Muon.h:220
bool fillSelectors_
Definition: MuonProducer.h:71
#define dout
Definition: MuonProducer.cc:36
#define abs(x)
Definition: mlp_lapack.h:159
bool isGlobalMuon() const
Definition: Muon.h:219
edm::InputTag theEcalDepositName
Definition: MuonProducer.h:80
bool isStandAloneMuon() const
Definition: Muon.h:221
reco::Candidate::LorentzVector pfP4() const
Definition: Muon.h:103
std::map< reco::MuonRef, unsigned int > MuToPFMap
Definition: MuonProducer.cc:41
std::vector< Muon > MuonCollection
collection of Muon objects
Definition: MuonFwd.h:9
bool fillCosmicsIdMap_
Definition: MuonProducer.h:72
dictionary map
Definition: Association.py:205
ProductID id() const
std::vector< PFCandidatePtr > pfCandidates(const PFJet &jet, int particleId, bool sort=true)
edm::InputTag thePFCandLabel
Definition: MuonProducer.h:67
std::vector< std::map< std::string, edm::InputTag > > pfIsoMapNames
Definition: MuonProducer.h:94
bool fillDetectorBasedIsolation_
Definition: MuonProducer.h:75
edm::InputTag theMuonsCollectionLabel
Definition: MuonProducer.h:66
int j
Definition: DBlmapReader.cc:9
std::string labelOrInstance(const edm::InputTag &) const
edm::Ref< MuonCollection > MuonRef
presistent reference to a Muon
Definition: MuonFwd.h:13
edm::InputTag theShowerMapName
Definition: MuonProducer.h:87
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::InputTag theHoDepositName
Definition: MuonProducer.h:82
bool fillTimingInfo_
Definition: MuonProducer.h:77
bool fillPFIsolation_
Definition: MuonProducer.h:74
InputTags theSelectorMapNames
Definition: MuonProducer.h:85
std::string theMuToMuMapName
Definition: MuonProducer.h:90
bool fillShoweringInfo_
Definition: MuonProducer.h:76
int embedPFIsolation(reco::Muon &, reco::MuonRef &)
std::string const & label() const
Definition: InputTag.h:42
MuPFIsoHelper * thePFIsoHelper
Definition: MuonProducer.h:92
void beginEvent(const edm::Event &iEvent)
virtual void setBestTrack(MuonTrackType muonType)
Definition: Muon.h:92
#define begin
Definition: vmac.h:31
virtual void setP4(const LorentzVector &p4) GCC11_FINAL
set 4-momentum
edm::InputTag theCosmicCompMapName
Definition: MuonProducer.h:88
bool isPFMuon() const
Definition: Muon.h:223
edm::InputTag theHcalDepositName
Definition: MuonProducer.h:81
virtual void setPFP4(const reco::Candidate::LorentzVector &p4_)
Definition: Muon.cc:837
bool fillPFMomentum_
Definition: MuonProducer.h:73
boost::remove_cv< typename boost::remove_reference< argument_type >::type >::type key_type
Definition: Ref.h:170
std::string const & instance() const
Definition: InputTag.h:43
edm::InputTag theJetDepositName
Definition: MuonProducer.h:83
void MuonProducer::setAlias ( std::string  alias)
inlineprivate

Definition at line 55 of file MuonProducer.h.

References theAlias.

Referenced by MuonProducer().

55  {
56  alias.erase( alias.size() - 1, alias.size() );
57  theAlias=alias;
58  }
std::string theAlias
Definition: MuonProducer.h:53

Member Data Documentation

bool MuonProducer::debug_
private

Definition at line 63 of file MuonProducer.h.

bool MuonProducer::fastLabelling_
private

Definition at line 64 of file MuonProducer.h.

Referenced by labelOrInstance(), and MuonProducer().

bool MuonProducer::fillCosmicsIdMap_
private

Definition at line 72 of file MuonProducer.h.

Referenced by MuonProducer(), and produce().

bool MuonProducer::fillDetectorBasedIsolation_
private

Definition at line 75 of file MuonProducer.h.

Referenced by MuonProducer(), and produce().

bool MuonProducer::fillIsolation_
private

Definition at line 69 of file MuonProducer.h.

bool MuonProducer::fillPFIsolation_
private

Definition at line 74 of file MuonProducer.h.

Referenced by MuonProducer(), produce(), and ~MuonProducer().

bool MuonProducer::fillPFMomentum_
private

Definition at line 73 of file MuonProducer.h.

Referenced by MuonProducer(), and produce().

bool MuonProducer::fillSelectors_
private

Definition at line 71 of file MuonProducer.h.

Referenced by MuonProducer(), and produce().

bool MuonProducer::fillShoweringInfo_
private

Definition at line 76 of file MuonProducer.h.

Referenced by MuonProducer(), and produce().

bool MuonProducer::fillTimingInfo_
private

Definition at line 77 of file MuonProducer.h.

Referenced by MuonProducer(), and produce().

std::vector<std::map<std::string,edm::InputTag> > MuonProducer::pfIsoMapNames
private

Definition at line 94 of file MuonProducer.h.

Referenced by MuonProducer(), and produce().

std::string MuonProducer::theAlias
private

Definition at line 53 of file MuonProducer.h.

Referenced by MuonProducer(), and setAlias().

edm::InputTag MuonProducer::theCosmicCompMapName
private

Definition at line 88 of file MuonProducer.h.

Referenced by MuonProducer(), and produce().

edm::InputTag MuonProducer::theEcalDepositName
private

Definition at line 80 of file MuonProducer.h.

Referenced by MuonProducer(), and produce().

edm::InputTag MuonProducer::theHcalDepositName
private

Definition at line 81 of file MuonProducer.h.

Referenced by MuonProducer(), and produce().

edm::InputTag MuonProducer::theHoDepositName
private

Definition at line 82 of file MuonProducer.h.

Referenced by MuonProducer(), and produce().

edm::InputTag MuonProducer::theJetDepositName
private

Definition at line 83 of file MuonProducer.h.

Referenced by MuonProducer(), and produce().

edm::InputTag MuonProducer::theMuonsCollectionLabel
private

Definition at line 66 of file MuonProducer.h.

Referenced by labelOrInstance(), MuonProducer(), and produce().

std::string MuonProducer::theMuToMuMapName
private

Definition at line 90 of file MuonProducer.h.

Referenced by MuonProducer(), and produce().

edm::InputTag MuonProducer::thePFCandLabel
private

Definition at line 67 of file MuonProducer.h.

Referenced by MuonProducer(), and produce().

MuPFIsoHelper* MuonProducer::thePFIsoHelper
private

Definition at line 92 of file MuonProducer.h.

Referenced by MuonProducer(), produce(), and ~MuonProducer().

InputTags MuonProducer::theSelectorMapNames
private

Definition at line 85 of file MuonProducer.h.

Referenced by MuonProducer(), and produce().

edm::InputTag MuonProducer::theShowerMapName
private

Definition at line 87 of file MuonProducer.h.

Referenced by MuonProducer(), and produce().

edm::InputTag MuonProducer::theTrackDepositName
private

Definition at line 79 of file MuonProducer.h.

Referenced by MuonProducer(), and produce().

bool MuonProducer::writeIsoDeposits_
private

Definition at line 70 of file MuonProducer.h.