CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes

CosmicsMuonIdProducer Class Reference

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

List of all members.

Public Member Functions

 CosmicsMuonIdProducer (const edm::ParameterSet &iConfig)
virtual ~CosmicsMuonIdProducer ()

Private Member Functions

virtual void produce (edm::Event &, const edm::EventSetup &)

Private Attributes

MuonCosmicCompatibilityFiller compatibilityFiller_
edm::InputTag inputMuonCollection_
std::vector< edm::InputTaginputTrackCollections_

Detailed Description

Definition at line 19 of file CosmicsMuonIdProducer.cc.


Constructor & Destructor Documentation

CosmicsMuonIdProducer::CosmicsMuonIdProducer ( const edm::ParameterSet iConfig) [inline]

Definition at line 21 of file CosmicsMuonIdProducer.cc.

                                                        :
    inputMuonCollection_(iConfig.getParameter<edm::InputTag>("muonCollection")),
    inputTrackCollections_(iConfig.getParameter<std::vector<edm::InputTag> >("trackCollections")),
    compatibilityFiller_(iConfig.getParameter<edm::ParameterSet>("CosmicCompFillerParameters"))
  {
    produces<edm::ValueMap<unsigned int> >().setBranchAlias("cosmicsVeto");
    produces<edm::ValueMap<reco::MuonCosmicCompatibility> >().setBranchAlias("cosmicCompatibility");
  }
virtual CosmicsMuonIdProducer::~CosmicsMuonIdProducer ( ) [inline, virtual]

Definition at line 29 of file CosmicsMuonIdProducer.cc.

{}

Member Function Documentation

void CosmicsMuonIdProducer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
) [private, virtual]

Implements edm::EDProducer.

Definition at line 39 of file CosmicsMuonIdProducer.cc.

References compatibilityFiller_, edm::helper::Filler< Map >::fill(), MuonCosmicCompatibilityFiller::fillCompatibility(), muonid::findOppositeTrack(), edm::Event::getByLabel(), i, inputMuonCollection_, inputTrackCollections_, edm::helper::Filler< Map >::insert(), metsig::muon, patZpeak::muons, dbtoconf::out, edm::Event::put(), testEve_cfg::tracks, and makeHLTPrescaleTable::values.

{
  edm::Handle<reco::MuonCollection> muons;
  iEvent.getByLabel(inputMuonCollection_, muons);
  // reserve some space
  std::vector<unsigned int> values;
  values.reserve(muons->size());

  std::vector<reco::MuonCosmicCompatibility> compValues;
  compValues.reserve(muons->size());
  
  for(reco::MuonCollection::const_iterator muon = muons->begin(); 
      muon != muons->end(); ++muon)
    {
      unsigned int foundPartner(0);
      if ( muon->innerTrack().isNonnull() ){
        for ( unsigned int i=0; i<inputTrackCollections_.size(); ++i )
          {
            edm::Handle<reco::TrackCollection> tracks;
            iEvent.getByLabel(inputTrackCollections_.at(i), tracks);
            if ( muonid::findOppositeTrack(tracks,*muon->innerTrack()).isNonnull() ){
              foundPartner = i+1;
              break;
            }
          }
      }
      values.push_back(foundPartner);

      compValues.push_back(compatibilityFiller_.fillCompatibility(*muon, iEvent, iSetup));
    }

  // create and fill value map
  std::auto_ptr<edm::ValueMap<unsigned int> > out(new edm::ValueMap<unsigned int>());
  edm::ValueMap<unsigned int>::Filler filler(*out);
  filler.insert(muons, values.begin(), values.end());
  filler.fill();


  std::auto_ptr<edm::ValueMap<reco::MuonCosmicCompatibility> > outC(new edm::ValueMap<reco::MuonCosmicCompatibility>());
  edm::ValueMap<reco::MuonCosmicCompatibility>::Filler fillerC(*outC);
  fillerC.insert(muons, compValues.begin(), compValues.end());
  fillerC.fill();

  // put value map into event
  iEvent.put(out);
  iEvent.put(outC);
}

Member Data Documentation

Definition at line 35 of file CosmicsMuonIdProducer.cc.

Referenced by produce().

Definition at line 33 of file CosmicsMuonIdProducer.cc.

Referenced by produce().

Definition at line 34 of file CosmicsMuonIdProducer.cc.

Referenced by produce().