CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_1/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 
00112 
00113   
00114   if(fillPFIsolation_){
00115     
00116     edm::ParameterSet pfIsoPSet = pSet.getParameter<edm::ParameterSet >("PFIsolation");
00117 
00118     //Define a map between the isolation and the PSet for the PFHelper
00119     std::map<std::string,edm::ParameterSet> psetMap;
00120 
00121     //First declare what isolation you are going to read
00122     std::vector<std::string> isolationLabels;
00123     isolationLabels.push_back("pfIsolationR03");
00124     isolationLabels.push_back("pfIsoMeanDRProfileR03");
00125     isolationLabels.push_back("pfIsoSumDRProfileR03");
00126     isolationLabels.push_back("pfIsolationR04");
00127     isolationLabels.push_back("pfIsoMeanDRProfileR04");
00128     isolationLabels.push_back("pfIsoSumDRProfileR04");
00129 
00130     //Fill the label,pet map and initialize MuPFIsoHelper
00131     for( std::vector<std::string>::const_iterator label = isolationLabels.begin();label != isolationLabels.end();++label)
00132       psetMap[*label] =pfIsoPSet.getParameter<edm::ParameterSet >(*label); 
00133     thePFIsoHelper = new MuPFIsoHelper(psetMap);
00134 
00135     //Now loop on the mass read for each PSet the parameters and save them to the mapNames for later
00136 
00137     for(std::map<std::string,edm::ParameterSet>::const_iterator map = psetMap.begin();map!= psetMap.end();++map) {
00138       std::map<std::string,edm::InputTag> isoMap;
00139       isoMap["chargedParticle"]              = map->second.getParameter<edm::InputTag>("chargedParticle");
00140       isoMap["chargedHadron"]                = map->second.getParameter<edm::InputTag>("chargedHadron");
00141       isoMap["neutralHadron"]                = map->second.getParameter<edm::InputTag>("neutralHadron");
00142       isoMap["neutralHadronHighThreshold"]   = map->second.getParameter<edm::InputTag>("neutralHadronHighThreshold");
00143       isoMap["photon"]                       = map->second.getParameter<edm::InputTag>("photon");
00144       isoMap["photonHighThreshold"]          = map->second.getParameter<edm::InputTag>("photonHighThreshold");
00145       isoMap["pu"]                           = map->second.getParameter<edm::InputTag>("pu");
00146       pfIsoMapNames.push_back(isoMap);
00147     }
00148 
00149 
00150     for(unsigned int j=0;j<pfIsoMapNames.size();++j) {
00151       for(std::map<std::string,edm::InputTag>::const_iterator map = pfIsoMapNames.at(j).begin(); map != pfIsoMapNames.at(j).end(); ++map)
00152         produces<edm::ValueMap<double> >(labelOrInstance(map->second));
00153 
00154     }
00155     
00156   }
00157 }
00158 
00160 MuonProducer::~MuonProducer(){ 
00161   if (thePFIsoHelper && fillPFIsolation_) delete thePFIsoHelper;
00162 }
00163 
00164 
00166 void MuonProducer::produce(edm::Event& event, const edm::EventSetup& eventSetup){
00167 
00168    const std::string metname = "Muon|RecoMuon|MuonIdentification|MuonProducer";
00169 
00170    // the muon collection, it will be loaded in the event
00171    std::auto_ptr<reco::MuonCollection> outputMuons(new reco::MuonCollection());
00172    reco::MuonRefProd outputMuonsRefProd = event.getRefBeforePut<reco::MuonCollection>();
00173 
00174    edm::Handle<reco::MuonCollection> inputMuons; 
00175    event.getByLabel(theMuonsCollectionLabel, inputMuons);
00176    edm::OrphanHandle<reco::MuonCollection> inputMuonsOH(inputMuons.product(), inputMuons.id());
00177    
00178    edm::Handle<reco::PFCandidateCollection> pfCandidates; 
00179    event.getByLabel(thePFCandLabel, pfCandidates);
00180 
00181 
00182    // fetch collections for PFIso
00183    if(fillPFIsolation_) thePFIsoHelper->beginEvent(event);
00184 
00185    
00186    // Fill timing information
00187    edm::Handle<reco::MuonTimeExtraMap> timeMapCmb;
00188    edm::Handle<reco::MuonTimeExtraMap> timeMapDT;
00189    edm::Handle<reco::MuonTimeExtraMap> timeMapCSC;
00190    
00191    int nMuons=inputMuons->size();
00192 
00193    std::vector<reco::MuonTimeExtra> dtTimeColl(nMuons);
00194    std::vector<reco::MuonTimeExtra> cscTimeColl(nMuons);
00195    std::vector<reco::MuonTimeExtra> combinedTimeColl(nMuons);
00196 
00197    if(fillTimingInfo_){
00198      event.getByLabel(theMuonsCollectionLabel.label(),"combined",timeMapCmb);
00199      event.getByLabel(theMuonsCollectionLabel.label(),"dt",timeMapDT);
00200      event.getByLabel(theMuonsCollectionLabel.label(),"csc",timeMapCSC);
00201    }
00202 
00203    std::vector<reco::IsoDeposit> trackDepColl(nMuons);
00204    std::vector<reco::IsoDeposit> ecalDepColl(nMuons);
00205    std::vector<reco::IsoDeposit> hcalDepColl(nMuons);
00206    std::vector<reco::IsoDeposit> hoDepColl(nMuons);
00207    std::vector<reco::IsoDeposit> jetDepColl(nMuons);
00208 
00209 
00210    edm::Handle<reco::IsoDepositMap> trackIsoDepMap;
00211    edm::Handle<reco::IsoDepositMap> ecalIsoDepMap;
00212    edm::Handle<reco::IsoDepositMap> hcalIsoDepMap;
00213    edm::Handle<reco::IsoDepositMap> hoIsoDepMap;
00214    edm::Handle<reco::IsoDepositMap> jetIsoDepMap;
00215 
00216 
00217    if(fillDetectorBasedIsolation_){
00218      event.getByLabel(theTrackDepositName,trackIsoDepMap);
00219      event.getByLabel(theEcalDepositName,ecalIsoDepMap);
00220      event.getByLabel(theHcalDepositName,hcalIsoDepMap);
00221      event.getByLabel(theHoDepositName,hoIsoDepMap);
00222      event.getByLabel(theJetDepositName,jetIsoDepMap);
00223    }
00224 
00225    
00226 
00227    std::vector<std::map<std::string,edm::Handle<edm::ValueMap<double> > > > pfIsoMaps;
00228    std::vector<std::map<std::string,std::vector<double> > > pfIsoMapVals;
00229 
00230    if(fillPFIsolation_){
00231     for(unsigned int j=0;j<pfIsoMapNames.size();++j) {
00232         std::map<std::string,std::vector<double> > mapVals;
00233         std::map<std::string,edm::Handle<edm::ValueMap<double> > > maps;
00234         for(std::map<std::string,edm::InputTag>::const_iterator map = pfIsoMapNames.at(j).begin(); map != pfIsoMapNames.at(j).end(); ++map) {
00235           edm::Handle<edm::ValueMap<double> > handleTmp;
00236           event.getByLabel(map->second,handleTmp);
00237           maps[map->first]=handleTmp;
00238           mapVals[map->first].resize(nMuons);
00239         }
00240         pfIsoMapVals.push_back(mapVals);
00241         pfIsoMaps.push_back(maps);
00242 
00243     }
00244    }
00245 
00246 
00247    
00248    std::vector<edm::Handle<edm::ValueMap<bool> > >  selectorMaps(fillSelectors_ ? theSelectorMapNames.size() : 0); 
00249    std::vector<std::vector<bool> > selectorMapResults(fillSelectors_ ? theSelectorMapNames.size() : 0);
00250    if(fillSelectors_){
00251      unsigned int s=0;
00252      for(InputTags::const_iterator tag = theSelectorMapNames.begin(); tag != theSelectorMapNames.end(); ++tag, ++s){
00253        event.getByLabel(*tag,selectorMaps[s]);
00254        selectorMapResults[s].resize(nMuons);
00255      }
00256    }
00257 
00258    edm::Handle<reco::MuonShowerMap> showerInfoMap;
00259    if(fillShoweringInfo_) event.getByLabel(theShowerMapName,showerInfoMap);
00260 
00261    std::vector<reco::MuonShower> showerInfoColl(nMuons);
00262 
00263    edm::Handle<edm::ValueMap<unsigned int> > cosmicIdMap;
00264    if(fillCosmicsIdMap_) event.getByLabel(theCosmicCompMapName,cosmicIdMap);
00265    std::vector<unsigned int> cosmicIdColl(fillCosmicsIdMap_ ? nMuons : 0);
00266    
00267    edm::Handle<edm::ValueMap<reco::MuonCosmicCompatibility> > cosmicCompMap;
00268    if(fillCosmicsIdMap_) event.getByLabel(theCosmicCompMapName,cosmicCompMap);
00269    std::vector<reco::MuonCosmicCompatibility> cosmicCompColl(fillCosmicsIdMap_ ? nMuons : 0);
00270 
00271 
00272    std::vector<reco::MuonRef> muonRefColl(nMuons);
00273 
00274 
00275 
00276    if(inputMuons->empty()) {
00277      edm::OrphanHandle<reco::MuonCollection> muonHandle = event.put(outputMuons);
00278      
00279      if(fillTimingInfo_){
00280        fillMuonMap<reco::MuonTimeExtra>(event, muonHandle, combinedTimeColl,"combined");
00281        fillMuonMap<reco::MuonTimeExtra>(event, muonHandle, dtTimeColl,"dt");
00282        fillMuonMap<reco::MuonTimeExtra>(event, muonHandle, cscTimeColl,"csc");
00283      }
00284      
00285      if(fillDetectorBasedIsolation_){
00286        fillMuonMap<reco::IsoDeposit>(event, muonHandle, trackDepColl, labelOrInstance(theTrackDepositName));
00287        fillMuonMap<reco::IsoDeposit>(event, muonHandle, jetDepColl,   labelOrInstance(theJetDepositName));
00288        fillMuonMap<reco::IsoDeposit>(event, muonHandle, ecalDepColl,  theEcalDepositName.instance());
00289        fillMuonMap<reco::IsoDeposit>(event, muonHandle, hcalDepColl,  theHcalDepositName.instance());
00290        fillMuonMap<reco::IsoDeposit>(event, muonHandle, hoDepColl,    theHoDepositName.instance());
00291      }
00292 
00293      if(fillSelectors_){
00294        unsigned int s = 0;
00295        for(InputTags::const_iterator tag = theSelectorMapNames.begin(); 
00296            tag != theSelectorMapNames.end(); ++tag, ++s){
00297          fillMuonMap<bool>(event, muonHandle, selectorMapResults[s], labelOrInstance(*tag));
00298        }
00299      }
00300 
00301      if(fillShoweringInfo_) fillMuonMap<reco::MuonShower>(event, muonHandle, showerInfoColl, labelOrInstance(theShowerMapName));
00302 
00303      if(fillCosmicsIdMap_){
00304        fillMuonMap<unsigned int>(event, muonHandle, cosmicIdColl, labelOrInstance(theCosmicCompMapName));
00305        fillMuonMap<reco::MuonCosmicCompatibility>(event, muonHandle, cosmicCompColl, labelOrInstance(theCosmicCompMapName));
00306      }
00307 
00308      fillMuonMap<reco::MuonRef>(event,inputMuonsOH, muonRefColl, theMuToMuMapName);
00309 
00310      if(fillPFIsolation_){
00311        for(unsigned int j=0;j<pfIsoMapNames.size();++j) 
00312          for(std::map<std::string,edm::InputTag>::const_iterator map = pfIsoMapNames.at(j).begin(); map != pfIsoMapNames.at(j).end(); ++map) {
00313            fillMuonMap<double>(event, muonHandle, pfIsoMapVals.at(j)[map->first], labelOrInstance(map->second));
00314         }
00315      }
00316      return;
00317    }
00318    
00319    // FIXME: add the option to swith off the Muon-PF "info association".
00320    
00321 
00322    MuToPFMap muToPFMap;
00323 
00324    if(fillPFMomentum_){
00325      dout << "Number of PFCandidates: " << pfCandidates->size() << endl;
00326      foreach(const reco::PFCandidate &pfCand, *pfCandidates)
00327        if(abs(pfCand.pdgId()) == 13){
00328          muToPFMap[pfCand.muonRef()] = pfCand.p4();     
00329          dout << "MuonRef: " << pfCand.muonRef().id() << " " << pfCand.muonRef().key() << " PF p4: " << pfCand.p4() << endl;
00330        }
00331      dout << "Number of PFMuons: " << muToPFMap.size() << endl;
00332      dout << "Number of Muons in the original collection: " << inputMuons->size() << endl;
00333    }
00334 
00335    reco::MuonRef::key_type muIndex = 0;
00336    unsigned int i = 0;
00337    foreach(const reco::Muon &inMuon, *inputMuons){
00338      
00339      reco::MuonRef muRef(inputMuons, muIndex);
00340      muonRefColl[i] = reco::MuonRef(outputMuonsRefProd, muIndex++);
00341 
00342      // Copy the muon 
00343      reco::Muon outMuon = inMuon;
00344     
00345      if(fillPFMomentum_){ 
00346      // search for the corresponding pf candidate
00347        MuToPFMap::iterator iter =  muToPFMap.find(muRef);
00348        if(iter != muToPFMap.end()){
00349          outMuon.setPFP4(iter->second);
00350          muToPFMap.erase(iter);
00351          dout << "MuonRef: " << muRef.id() << " " << muRef.key() 
00352               << " Is it PF? " << outMuon.isPFMuon() 
00353               << " PF p4: " << outMuon.pfP4() << endl;
00354        }
00355        
00356        
00357        dout << "MuonRef: " << muRef.id() << " " << muRef.key() 
00358             << " Is it PF? " << outMuon.isPFMuon() << endl;
00359        
00360        dout << "GLB "  << outMuon.isGlobalMuon()
00361             << " TM "  << outMuon.isTrackerMuon()
00362             << " STA " << outMuon.isStandAloneMuon() 
00363             << " p4 "  << outMuon.p4() << endl;
00364      }
00365 
00366      // Add PF isolation info
00367      if(fillPFIsolation_){
00368        thePFIsoHelper->embedPFIsolation(outMuon,muRef);
00369 
00370        for(unsigned int j=0;j<pfIsoMapNames.size();++j) {
00371          for(std::map<std::string,edm::InputTag>::const_iterator map = pfIsoMapNames[j].begin(); map != pfIsoMapNames[j].end(); ++map){
00372            (pfIsoMapVals[j])[map->first][i] = (*pfIsoMaps[j][map->first])[muRef];
00373          }
00374        }
00375      }
00376      
00377      // Fill timing information   
00378      if(fillTimingInfo_){
00379        combinedTimeColl[i] = (*timeMapCmb)[muRef];
00380        dtTimeColl[i] = (*timeMapDT)[muRef];
00381        cscTimeColl[i] = (*timeMapCSC)[muRef];
00382      }
00383      
00384      if(fillDetectorBasedIsolation_){
00385        trackDepColl[i] = (*trackIsoDepMap)[muRef];
00386        ecalDepColl[i]  = (*ecalIsoDepMap)[muRef];
00387        hcalDepColl[i]  = (*hcalIsoDepMap)[muRef];
00388        hoDepColl[i]    = (*hoIsoDepMap)[muRef];
00389        jetDepColl[i]   = (*jetIsoDepMap)[muRef];;
00390      }
00391      
00392      if(fillSelectors_){
00393        unsigned int s = 0;
00394        for(InputTags::const_iterator tag = theSelectorMapNames.begin(); 
00395            tag != theSelectorMapNames.end(); ++tag, ++s)
00396          selectorMapResults[s][i] = (*selectorMaps[s])[muRef];
00397      }
00398 
00399      // Fill the Showering Info
00400      if(fillShoweringInfo_) showerInfoColl[i] = (*showerInfoMap)[muRef];
00401 
00402      if(fillCosmicsIdMap_){
00403        cosmicIdColl[i] = (*cosmicIdMap)[muRef];
00404        cosmicCompColl[i] = (*cosmicCompMap)[muRef];
00405      }
00406 
00407      outputMuons->push_back(outMuon); 
00408      ++i;
00409    }
00410    
00411    dout << "Number of Muons in the new muon collection: " << outputMuons->size() << endl;
00412    edm::OrphanHandle<reco::MuonCollection> muonHandle = event.put(outputMuons);
00413 
00414    if(fillTimingInfo_){
00415      fillMuonMap<reco::MuonTimeExtra>(event, muonHandle, combinedTimeColl,"combined");
00416      fillMuonMap<reco::MuonTimeExtra>(event, muonHandle, dtTimeColl,"dt");
00417      fillMuonMap<reco::MuonTimeExtra>(event, muonHandle, cscTimeColl,"csc");
00418    }
00419 
00420    if(fillDetectorBasedIsolation_){
00421      fillMuonMap<reco::IsoDeposit>(event, muonHandle, trackDepColl, labelOrInstance(theTrackDepositName));
00422      fillMuonMap<reco::IsoDeposit>(event, muonHandle, jetDepColl,   labelOrInstance(theJetDepositName));
00423      fillMuonMap<reco::IsoDeposit>(event, muonHandle, ecalDepColl,  theEcalDepositName.instance());
00424      fillMuonMap<reco::IsoDeposit>(event, muonHandle, hcalDepColl,  theHcalDepositName.instance());
00425      fillMuonMap<reco::IsoDeposit>(event, muonHandle, hoDepColl,    theHoDepositName.instance());
00426    }
00427    
00428    if(fillPFIsolation_){
00429 
00430      for(unsigned int j=0;j<pfIsoMapNames.size();++j) {
00431        for(std::map<std::string,edm::InputTag>::const_iterator map = pfIsoMapNames[j].begin(); map != pfIsoMapNames[j].end(); ++map) 
00432          fillMuonMap<double>(event, muonHandle, pfIsoMapVals[j][map->first], labelOrInstance(map->second));
00433      }
00434    }   
00435 
00436    if(fillSelectors_){
00437      unsigned int s = 0;
00438      for(InputTags::const_iterator tag = theSelectorMapNames.begin(); 
00439          tag != theSelectorMapNames.end(); ++tag, ++s)
00440        fillMuonMap<bool>(event, muonHandle, selectorMapResults[s], labelOrInstance(*tag));
00441    }
00442 
00443    if(fillShoweringInfo_) fillMuonMap<reco::MuonShower>(event, muonHandle, showerInfoColl, labelOrInstance(theShowerMapName));
00444 
00445    if(fillCosmicsIdMap_){
00446      fillMuonMap<unsigned int>(event, muonHandle, cosmicIdColl, labelOrInstance(theCosmicCompMapName));
00447      fillMuonMap<reco::MuonCosmicCompatibility>(event, muonHandle, cosmicCompColl, labelOrInstance(theCosmicCompMapName));
00448    }
00449 
00450    fillMuonMap<reco::MuonRef>(event,inputMuonsOH, muonRefColl, theMuToMuMapName);
00451    
00452  
00453 }
00454 
00455 
00456 
00457 template<typename TYPE>
00458 void MuonProducer::fillMuonMap(edm::Event& event,
00459                                const edm::OrphanHandle<reco::MuonCollection>& muonHandle,
00460                                const std::vector<TYPE>& muonExtra,
00461                                const std::string& label){
00462  
00463   typedef typename edm::ValueMap<TYPE>::Filler FILLER; 
00464 
00465   std::auto_ptr<edm::ValueMap<TYPE> > muonMap(new edm::ValueMap<TYPE>());
00466   if(!muonExtra.empty()){
00467     FILLER filler(*muonMap);
00468     filler.insert(muonHandle, muonExtra.begin(), muonExtra.end());
00469     filler.fill();
00470   }
00471   event.put(muonMap,label);
00472 }
00473 
00474 
00475 std::string MuonProducer::labelOrInstance(const edm::InputTag &input) const{
00476   if(fastLabelling_) return input.label();
00477 
00478   return input.label() != theMuonsCollectionLabel.label() ? input.label() : input.instance();
00479 }