CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_10_patch1/src/RecoMuon/MuonIdentification/plugins/MuonProducer.cc

Go to the documentation of this file.
00001 
00009 #include "RecoMuon/MuonIdentification/plugins/MuonProducer.h"
00010 
00011 #include "RecoMuon/MuonIsolation/interface/MuPFIsoHelper.h"
00012 
00013 #include "FWCore/Framework/interface/Event.h"
00014 #include "FWCore/Framework/interface/EventSetup.h"
00015 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00016 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00017 
00018 #include "DataFormats/MuonReco/interface/Muon.h"
00019 #include "DataFormats/MuonReco/interface/MuonTrackLinks.h"
00020 #include "DataFormats/MuonReco/interface/MuonTimeExtraMap.h"
00021 #include "DataFormats/MuonReco/interface/MuonShower.h"
00022 #include "DataFormats/MuonReco/interface/MuonCosmicCompatibility.h"
00023 #include "DataFormats/MuonReco/interface/MuonToMuonMap.h"
00024 
00025 #include "DataFormats/ParticleFlowCandidate/interface/PFCandidate.h"
00026 #include "DataFormats/ParticleFlowCandidate/interface/PFCandidateFwd.h"
00027 
00028 #include "DataFormats/Common/interface/ValueMap.h"
00029 #include "DataFormats/RecoCandidate/interface/IsoDepositFwd.h"
00030 #include "DataFormats/RecoCandidate/interface/IsoDeposit.h"
00031 
00032 #include <boost/foreach.hpp>
00033 #define foreach BOOST_FOREACH
00034 
00035 #ifndef dout
00036 #define dout if(debug_) std::cout
00037 #endif
00038 
00039 using std::endl;
00040 
00041 typedef std::map<reco::MuonRef, reco::Candidate::LorentzVector> MuToPFMap;
00042 
00043 namespace reco {
00044   typedef edm::ValueMap<reco::MuonShower> MuonShowerMap;
00045 }
00046 
00047 
00049 MuonProducer::MuonProducer(const edm::ParameterSet& pSet):debug_(pSet.getUntrackedParameter<bool>("ActivateDebug",false)){
00050   
00051   setAlias(pSet.getParameter<std::string>("@module_label"));
00052   
00053   fastLabelling_ = pSet.getUntrackedParameter<bool>("FastLabelling",true);
00054 
00055   
00056   theMuonsCollectionLabel = pSet.getParameter<edm::InputTag>("InputMuons");
00057   thePFCandLabel = pSet.getParameter<edm::InputTag>("PFCandidates");
00058   
00059   
00060   // Variables to switch on-off the differnt parts
00061   fillSelectors_              = pSet.getParameter<bool>("FillSelectorMaps");
00062   fillCosmicsIdMap_           = pSet.getParameter<bool>("FillCosmicsIdMap");
00063   fillPFMomentum_             = pSet.getParameter<bool>("FillPFMomentumAndAssociation");
00064   fillPFIsolation_            = pSet.getParameter<bool>("FillPFIsolation");
00065   fillDetectorBasedIsolation_ = pSet.getParameter<bool>("FillDetectorBasedIsolation"); 
00066   fillShoweringInfo_          = pSet.getParameter<bool>("FillShoweringInfo");
00067   fillTimingInfo_             = pSet.getParameter<bool>("FillTimingInfo");
00068 
00069   produces<reco::MuonCollection>();
00070 
00071   if(fillTimingInfo_){
00072     produces<reco::MuonTimeExtraMap>("combined");
00073     produces<reco::MuonTimeExtraMap>("dt");
00074     produces<reco::MuonTimeExtraMap>("csc");
00075   }
00076   
00077   if (fillDetectorBasedIsolation_){
00078     theTrackDepositName = pSet.getParameter<edm::InputTag>("TrackIsoDeposits");
00079     produces<reco::IsoDepositMap>(labelOrInstance(theTrackDepositName));
00080     theJetDepositName = pSet.getParameter<edm::InputTag>("JetIsoDeposits");
00081     produces<reco::IsoDepositMap>(labelOrInstance(theJetDepositName));
00082     theEcalDepositName = pSet.getParameter<edm::InputTag>("EcalIsoDeposits");
00083     produces<reco::IsoDepositMap>(theEcalDepositName.instance());
00084     theHcalDepositName = pSet.getParameter<edm::InputTag>("HcalIsoDeposits");
00085     produces<reco::IsoDepositMap>(theHcalDepositName.instance());
00086     theHoDepositName = pSet.getParameter<edm::InputTag>("HoIsoDeposits");
00087     produces<reco::IsoDepositMap>(theHoDepositName.instance());
00088   }
00089   
00090   if(fillSelectors_){
00091     theSelectorMapNames = pSet.getParameter<InputTags>("SelectorMaps");
00092     
00093     for(InputTags::const_iterator tag = theSelectorMapNames.begin(); tag != theSelectorMapNames.end(); ++tag)
00094       produces<edm::ValueMap<bool> >(labelOrInstance(*tag));
00095   }
00096   
00097   if(fillShoweringInfo_){
00098     theShowerMapName = pSet.getParameter<edm::InputTag>("ShowerInfoMap");
00099     produces<edm::ValueMap<reco::MuonShower> >(labelOrInstance(theShowerMapName));
00100   }
00101   
00102   if(fillCosmicsIdMap_){
00103     theCosmicCompMapName = pSet.getParameter<edm::InputTag>("CosmicIdMap");
00104     produces<edm::ValueMap<reco::MuonCosmicCompatibility> >(labelOrInstance(theCosmicCompMapName));
00105     produces<edm::ValueMap<unsigned int> >(labelOrInstance(theCosmicCompMapName));
00106   }
00107   
00108   theMuToMuMapName = theMuonsCollectionLabel.label()+"2"+theAlias+"sMap";
00109   produces<edm::ValueMap<reco::MuonRef> >(theMuToMuMapName);
00110   
00111   if(fillPFIsolation_){
00112     edm::ParameterSet pfIsoPSet = pSet.getParameter<edm::ParameterSet>("PFIsolation");
00113     thePFIsoHelper = new MuPFIsoHelper(pfIsoPSet);
00114     edm::ParameterSet isoCfg03 = pfIsoPSet.getParameter<edm::ParameterSet>("isolationR03");
00115     edm::ParameterSet isoCfg04 = pfIsoPSet.getParameter<edm::ParameterSet>("isolationR04");
00116 
00117     theIsoPF03MapNames["chargedParticle"] = isoCfg03.getParameter<edm::InputTag>("chargedParticle");
00118     theIsoPF03MapNames["chargedHadron"]   = isoCfg03.getParameter<edm::InputTag>("chargedHadron");
00119     theIsoPF03MapNames["neutralHadron"]   = isoCfg03.getParameter<edm::InputTag>("neutralHadron");
00120     theIsoPF03MapNames["photon"]          = isoCfg03.getParameter<edm::InputTag>("photon");
00121     theIsoPF03MapNames["pu"]              = isoCfg03.getParameter<edm::InputTag>("pu");
00122 
00123     theIsoPF04MapNames["chargedParticle"] = isoCfg04.getParameter<edm::InputTag>("chargedParticle");
00124     theIsoPF04MapNames["chargedHadron"]   = isoCfg04.getParameter<edm::InputTag>("chargedHadron");
00125     theIsoPF04MapNames["neutralHadron"]   = isoCfg04.getParameter<edm::InputTag>("neutralHadron");
00126     theIsoPF04MapNames["photon"]          = isoCfg04.getParameter<edm::InputTag>("photon");
00127     theIsoPF04MapNames["pu"]              = isoCfg04.getParameter<edm::InputTag>("pu");
00128     
00129     for(std::map<std::string,edm::InputTag>::const_iterator map = theIsoPF03MapNames.begin(); map != theIsoPF03MapNames.end(); ++map)
00130       produces<edm::ValueMap<double> >(labelOrInstance(map->second));
00131     
00132     for(std::map<std::string,edm::InputTag>::const_iterator map = theIsoPF04MapNames.begin(); map != theIsoPF04MapNames.end(); ++map)
00133       produces<edm::ValueMap<double> >(labelOrInstance(map->second));
00134   }
00135 }
00136 
00138 MuonProducer::~MuonProducer(){ 
00139   if (thePFIsoHelper && fillPFIsolation_) delete thePFIsoHelper;
00140 }
00141 
00142 
00144 void MuonProducer::produce(edm::Event& event, const edm::EventSetup& eventSetup){
00145 
00146    const std::string metname = "Muon|RecoMuon|MuonIdentification|MuonProducer";
00147 
00148    // the muon collection, it will be loaded in the event
00149    std::auto_ptr<reco::MuonCollection> outputMuons(new reco::MuonCollection());
00150    reco::MuonRefProd outputMuonsRefProd = event.getRefBeforePut<reco::MuonCollection>();
00151 
00152    edm::Handle<reco::MuonCollection> inputMuons; 
00153    event.getByLabel(theMuonsCollectionLabel, inputMuons);
00154    edm::OrphanHandle<reco::MuonCollection> inputMuonsOH(inputMuons.product(), inputMuons.id());
00155    
00156    edm::Handle<reco::PFCandidateCollection> pfCandidates; 
00157    event.getByLabel(thePFCandLabel, pfCandidates);
00158 
00159 
00160    // fetch collections for PFIso
00161    if(fillPFIsolation_) thePFIsoHelper->beginEvent(event);
00162 
00163    
00164    // Fill timing information
00165    edm::Handle<reco::MuonTimeExtraMap> timeMapCmb;
00166    edm::Handle<reco::MuonTimeExtraMap> timeMapDT;
00167    edm::Handle<reco::MuonTimeExtraMap> timeMapCSC;
00168    
00169    int nMuons=inputMuons->size();
00170 
00171    std::vector<reco::MuonTimeExtra> dtTimeColl(nMuons);
00172    std::vector<reco::MuonTimeExtra> cscTimeColl(nMuons);
00173    std::vector<reco::MuonTimeExtra> combinedTimeColl(nMuons);
00174 
00175    if(fillTimingInfo_){
00176      event.getByLabel(theMuonsCollectionLabel.label(),"combined",timeMapCmb);
00177      event.getByLabel(theMuonsCollectionLabel.label(),"dt",timeMapDT);
00178      event.getByLabel(theMuonsCollectionLabel.label(),"csc",timeMapCSC);
00179    }
00180 
00181    std::vector<reco::IsoDeposit> trackDepColl(nMuons);
00182    std::vector<reco::IsoDeposit> ecalDepColl(nMuons);
00183    std::vector<reco::IsoDeposit> hcalDepColl(nMuons);
00184    std::vector<reco::IsoDeposit> hoDepColl(nMuons);
00185    std::vector<reco::IsoDeposit> jetDepColl(nMuons);
00186 
00187 
00188    edm::Handle<reco::IsoDepositMap> trackIsoDepMap;
00189    edm::Handle<reco::IsoDepositMap> ecalIsoDepMap;
00190    edm::Handle<reco::IsoDepositMap> hcalIsoDepMap;
00191    edm::Handle<reco::IsoDepositMap> hoIsoDepMap;
00192    edm::Handle<reco::IsoDepositMap> jetIsoDepMap;
00193 
00194 
00195    if(fillDetectorBasedIsolation_){
00196      event.getByLabel(theTrackDepositName,trackIsoDepMap);
00197      event.getByLabel(theEcalDepositName,ecalIsoDepMap);
00198      event.getByLabel(theHcalDepositName,hcalIsoDepMap);
00199      event.getByLabel(theHoDepositName,hoIsoDepMap);
00200      event.getByLabel(theJetDepositName,jetIsoDepMap);
00201    }
00202 
00203    std::map<std::string,edm::Handle<edm::ValueMap<double> > >  pfIso03Maps; 
00204    std::map<std::string,std::vector<double> > pfIso03MapVals;
00205    std::map<std::string,edm::Handle<edm::ValueMap<double> > >  pfIso04Maps; 
00206    std::map<std::string,std::vector<double> > pfIso04MapVals;
00207 
00208    if(fillPFIsolation_){
00209      for(std::map<std::string,edm::InputTag>::const_iterator map = theIsoPF03MapNames.begin(); map != theIsoPF03MapNames.end(); ++map){
00210        event.getByLabel(map->second,pfIso03Maps[map->first]);
00211        pfIso03MapVals[map->first].resize(nMuons);
00212      }
00213      for(std::map<std::string,edm::InputTag>::const_iterator map = theIsoPF04MapNames.begin(); map != theIsoPF04MapNames.end(); ++map){
00214        event.getByLabel(map->second,pfIso04Maps[map->first]);
00215        pfIso04MapVals[map->first].resize(nMuons);
00216      }
00217    }
00218    
00219    std::vector<edm::Handle<edm::ValueMap<bool> > >  selectorMaps(fillSelectors_ ? theSelectorMapNames.size() : 0); 
00220    std::vector<std::vector<bool> > selectorMapResults(fillSelectors_ ? theSelectorMapNames.size() : 0);
00221    if(fillSelectors_){
00222      unsigned int s=0;
00223      for(InputTags::const_iterator tag = theSelectorMapNames.begin(); tag != theSelectorMapNames.end(); ++tag, ++s){
00224        event.getByLabel(*tag,selectorMaps[s]);
00225        selectorMapResults[s].resize(nMuons);
00226      }
00227    }
00228 
00229    edm::Handle<reco::MuonShowerMap> showerInfoMap;
00230    if(fillShoweringInfo_) event.getByLabel(theShowerMapName,showerInfoMap);
00231 
00232    std::vector<reco::MuonShower> showerInfoColl(nMuons);
00233 
00234    edm::Handle<edm::ValueMap<unsigned int> > cosmicIdMap;
00235    if(fillCosmicsIdMap_) event.getByLabel(theCosmicCompMapName,cosmicIdMap);
00236    std::vector<unsigned int> cosmicIdColl(fillCosmicsIdMap_ ? nMuons : 0);
00237    
00238    edm::Handle<edm::ValueMap<reco::MuonCosmicCompatibility> > cosmicCompMap;
00239    if(fillCosmicsIdMap_) event.getByLabel(theCosmicCompMapName,cosmicCompMap);
00240    std::vector<reco::MuonCosmicCompatibility> cosmicCompColl(fillCosmicsIdMap_ ? nMuons : 0);
00241 
00242 
00243    std::vector<reco::MuonRef> muonRefColl(nMuons);
00244 
00245 
00246 
00247    if(inputMuons->empty()) {
00248      edm::OrphanHandle<reco::MuonCollection> muonHandle = event.put(outputMuons);
00249      
00250      if(fillTimingInfo_){
00251        fillMuonMap<reco::MuonTimeExtra>(event, muonHandle, combinedTimeColl,"combined");
00252        fillMuonMap<reco::MuonTimeExtra>(event, muonHandle, dtTimeColl,"dt");
00253        fillMuonMap<reco::MuonTimeExtra>(event, muonHandle, cscTimeColl,"csc");
00254      }
00255      
00256      if(fillDetectorBasedIsolation_){
00257        fillMuonMap<reco::IsoDeposit>(event, muonHandle, trackDepColl, labelOrInstance(theTrackDepositName));
00258        fillMuonMap<reco::IsoDeposit>(event, muonHandle, jetDepColl,   labelOrInstance(theJetDepositName));
00259        fillMuonMap<reco::IsoDeposit>(event, muonHandle, ecalDepColl,  theEcalDepositName.instance());
00260        fillMuonMap<reco::IsoDeposit>(event, muonHandle, hcalDepColl,  theHcalDepositName.instance());
00261        fillMuonMap<reco::IsoDeposit>(event, muonHandle, hoDepColl,    theHoDepositName.instance());
00262      }
00263 
00264      if(fillSelectors_){
00265        unsigned int s = 0;
00266        for(InputTags::const_iterator tag = theSelectorMapNames.begin(); 
00267            tag != theSelectorMapNames.end(); ++tag, ++s){
00268          fillMuonMap<bool>(event, muonHandle, selectorMapResults[s], labelOrInstance(*tag));
00269        }
00270      }
00271 
00272      if(fillShoweringInfo_) fillMuonMap<reco::MuonShower>(event, muonHandle, showerInfoColl, labelOrInstance(theShowerMapName));
00273 
00274      if(fillCosmicsIdMap_){
00275        fillMuonMap<unsigned int>(event, muonHandle, cosmicIdColl, labelOrInstance(theCosmicCompMapName));
00276        fillMuonMap<reco::MuonCosmicCompatibility>(event, muonHandle, cosmicCompColl, labelOrInstance(theCosmicCompMapName));
00277      }
00278 
00279      fillMuonMap<reco::MuonRef>(event,inputMuonsOH, muonRefColl, theMuToMuMapName);
00280 
00281      if(fillPFIsolation_){
00282        for(std::map<std::string,edm::InputTag>::const_iterator map = theIsoPF03MapNames.begin(); map != theIsoPF03MapNames.end(); ++map)
00283          fillMuonMap<double>(event, muonHandle, pfIso03MapVals[map->first], labelOrInstance(map->second));
00284        for(std::map<std::string,edm::InputTag>::const_iterator map = theIsoPF04MapNames.begin(); map != theIsoPF04MapNames.end(); ++map)
00285          fillMuonMap<double>(event, muonHandle, pfIso04MapVals[map->first], labelOrInstance(map->second));
00286      }
00287 
00288      return;
00289    }
00290    
00291    // FIXME: add the option to swith off the Muon-PF "info association".
00292    
00293 
00294    MuToPFMap muToPFMap;
00295 
00296    if(fillPFMomentum_){
00297      dout << "Number of PFCandidates: " << pfCandidates->size() << endl;
00298      foreach(const reco::PFCandidate &pfCand, *pfCandidates)
00299        if(abs(pfCand.pdgId()) == 13){
00300          muToPFMap[pfCand.muonRef()] = pfCand.p4();     
00301          dout << "MuonRef: " << pfCand.muonRef().id() << " " << pfCand.muonRef().key() << " PF p4: " << pfCand.p4() << endl;
00302        }
00303      dout << "Number of PFMuons: " << muToPFMap.size() << endl;
00304      dout << "Number of Muons in the original collection: " << inputMuons->size() << endl;
00305    }
00306 
00307    reco::MuonRef::key_type muIndex = 0;
00308    unsigned int i = 0;
00309    foreach(const reco::Muon &inMuon, *inputMuons){
00310      
00311      reco::MuonRef muRef(inputMuons, muIndex);
00312      muonRefColl[i] = reco::MuonRef(outputMuonsRefProd, muIndex++);
00313 
00314      // Copy the muon 
00315      reco::Muon outMuon = inMuon;
00316     
00317      if(fillPFMomentum_){ 
00318      // search for the corresponding pf candidate
00319        MuToPFMap::iterator iter =  muToPFMap.find(muRef);
00320        if(iter != muToPFMap.end()){
00321          outMuon.setPFP4(iter->second);
00322          muToPFMap.erase(iter);
00323          dout << "MuonRef: " << muRef.id() << " " << muRef.key() 
00324               << " Is it PF? " << outMuon.isPFMuon() 
00325               << " PF p4: " << outMuon.pfP4() << endl;
00326        }
00327        
00328        
00329        dout << "MuonRef: " << muRef.id() << " " << muRef.key() 
00330             << " Is it PF? " << outMuon.isPFMuon() << endl;
00331        
00332        dout << "GLB "  << outMuon.isGlobalMuon()
00333             << " TM "  << outMuon.isTrackerMuon()
00334             << " STA " << outMuon.isStandAloneMuon() 
00335             << " p4 "  << outMuon.p4() << endl;
00336      }
00337 
00338      // Add PF isolation info
00339      if(fillPFIsolation_){
00340        thePFIsoHelper->embedPFIsolation(outMuon,muRef);
00341        for(std::map<std::string,edm::InputTag>::const_iterator map = theIsoPF03MapNames.begin(); map != theIsoPF03MapNames.end(); ++map)
00342          pfIso03MapVals[map->first][i] = (*pfIso03Maps[map->first])[muRef];
00343        for(std::map<std::string,edm::InputTag>::const_iterator map = theIsoPF04MapNames.begin(); map != theIsoPF04MapNames.end(); ++map)
00344          pfIso04MapVals[map->first][i] = (*pfIso04Maps[map->first])[muRef];
00345      }
00346 
00347      
00348      // Fill timing information   
00349      if(fillTimingInfo_){
00350        combinedTimeColl[i] = (*timeMapCmb)[muRef];
00351        dtTimeColl[i] = (*timeMapDT)[muRef];
00352        cscTimeColl[i] = (*timeMapCSC)[muRef];
00353      }
00354      
00355      if(fillDetectorBasedIsolation_){
00356        trackDepColl[i] = (*trackIsoDepMap)[muRef];
00357        ecalDepColl[i]  = (*ecalIsoDepMap)[muRef];
00358        hcalDepColl[i]  = (*hcalIsoDepMap)[muRef];
00359        hoDepColl[i]    = (*hoIsoDepMap)[muRef];
00360        jetDepColl[i]   = (*jetIsoDepMap)[muRef];;
00361      }
00362      
00363      if(fillSelectors_){
00364        unsigned int s = 0;
00365        for(InputTags::const_iterator tag = theSelectorMapNames.begin(); 
00366            tag != theSelectorMapNames.end(); ++tag, ++s)
00367          selectorMapResults[s][i] = (*selectorMaps[s])[muRef];
00368      }
00369 
00370      // Fill the Showering Info
00371      if(fillShoweringInfo_) showerInfoColl[i] = (*showerInfoMap)[muRef];
00372 
00373      if(fillCosmicsIdMap_){
00374        cosmicIdColl[i] = (*cosmicIdMap)[muRef];
00375        cosmicCompColl[i] = (*cosmicCompMap)[muRef];
00376      }
00377 
00378      outputMuons->push_back(outMuon); 
00379      ++i;
00380    }
00381 
00382    dout << "Number of Muons in the new muon collection: " << outputMuons->size() << endl;
00383    edm::OrphanHandle<reco::MuonCollection> muonHandle = event.put(outputMuons);
00384 
00385    if(fillTimingInfo_){
00386      fillMuonMap<reco::MuonTimeExtra>(event, muonHandle, combinedTimeColl,"combined");
00387      fillMuonMap<reco::MuonTimeExtra>(event, muonHandle, dtTimeColl,"dt");
00388      fillMuonMap<reco::MuonTimeExtra>(event, muonHandle, cscTimeColl,"csc");
00389    }
00390 
00391    if(fillDetectorBasedIsolation_){
00392      fillMuonMap<reco::IsoDeposit>(event, muonHandle, trackDepColl, labelOrInstance(theTrackDepositName));
00393      fillMuonMap<reco::IsoDeposit>(event, muonHandle, jetDepColl,   labelOrInstance(theJetDepositName));
00394      fillMuonMap<reco::IsoDeposit>(event, muonHandle, ecalDepColl,  theEcalDepositName.instance());
00395      fillMuonMap<reco::IsoDeposit>(event, muonHandle, hcalDepColl,  theHcalDepositName.instance());
00396      fillMuonMap<reco::IsoDeposit>(event, muonHandle, hoDepColl,    theHoDepositName.instance());
00397    }
00398    
00399    if(fillPFIsolation_){
00400      for(std::map<std::string,edm::InputTag>::const_iterator map = theIsoPF03MapNames.begin(); map != theIsoPF03MapNames.end(); ++map)
00401        fillMuonMap<double>(event, muonHandle, pfIso03MapVals[map->first], labelOrInstance(map->second));
00402      for(std::map<std::string,edm::InputTag>::const_iterator map = theIsoPF04MapNames.begin(); map != theIsoPF04MapNames.end(); ++map)
00403        fillMuonMap<double>(event, muonHandle, pfIso04MapVals[map->first], labelOrInstance(map->second));
00404    }   
00405 
00406    if(fillSelectors_){
00407      unsigned int s = 0;
00408      for(InputTags::const_iterator tag = theSelectorMapNames.begin(); 
00409          tag != theSelectorMapNames.end(); ++tag, ++s)
00410        fillMuonMap<bool>(event, muonHandle, selectorMapResults[s], labelOrInstance(*tag));
00411    }
00412 
00413    if(fillShoweringInfo_) fillMuonMap<reco::MuonShower>(event, muonHandle, showerInfoColl, labelOrInstance(theShowerMapName));
00414 
00415    if(fillCosmicsIdMap_){
00416      fillMuonMap<unsigned int>(event, muonHandle, cosmicIdColl, labelOrInstance(theCosmicCompMapName));
00417      fillMuonMap<reco::MuonCosmicCompatibility>(event, muonHandle, cosmicCompColl, labelOrInstance(theCosmicCompMapName));
00418    }
00419 
00420    fillMuonMap<reco::MuonRef>(event,inputMuonsOH, muonRefColl, theMuToMuMapName);
00421    
00422 
00423 
00424 }
00425 
00426 template<typename TYPE>
00427 void MuonProducer::fillMuonMap(edm::Event& event,
00428                                const edm::OrphanHandle<reco::MuonCollection>& muonHandle,
00429                                const std::vector<TYPE>& muonExtra,
00430                                const std::string& label){
00431  
00432   typedef typename edm::ValueMap<TYPE>::Filler FILLER; 
00433 
00434   std::auto_ptr<edm::ValueMap<TYPE> > muonMap(new edm::ValueMap<TYPE>());
00435   if(!muonExtra.empty()){
00436     FILLER filler(*muonMap);
00437     filler.insert(muonHandle, muonExtra.begin(), muonExtra.end());
00438     filler.fill();
00439   }
00440   event.put(muonMap,label);
00441 }
00442 
00443 
00444 std::string MuonProducer::labelOrInstance(const edm::InputTag &input) const{
00445   if(fastLabelling_) return input.label();
00446 
00447   return input.label() != theMuonsCollectionLabel.label() ? input.label() : input.instance();
00448 }