CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
CosmicsMuonIdProducer Class Reference
Inheritance diagram for CosmicsMuonIdProducer:
edm::stream::EDProducer<>

Public Member Functions

 CosmicsMuonIdProducer (const edm::ParameterSet &iConfig)
 
 ~CosmicsMuonIdProducer () override
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
bool hasAbilityToProduceInLumis () const final
 
bool hasAbilityToProduceInRuns () const final
 

Private Member Functions

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

Private Attributes

MuonCosmicCompatibilityFillercompatibilityFiller_
 
edm::InputTag inputMuonCollection_
 
std::vector< edm::InputTaginputTrackCollections_
 
edm::EDGetTokenT< reco::MuonCollectionmuonToken_
 
std::vector< edm::EDGetTokenT< reco::TrackCollection > > trackTokens_
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
typedef CacheContexts< T... > CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T... > HasAbility
 
typedef CacheTypes::LuminosityBlockCache LuminosityBlockCache
 
typedef LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCacheLuminosityBlockContext
 
typedef CacheTypes::LuminosityBlockSummaryCache LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache, GlobalCacheRunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 

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.

References compatibilityFiller_, edm::ParameterSet::getParameter(), mps_fire::i, inputMuonCollection_, inputTrackCollections_, muonToken_, and trackTokens_.

21  :
22  inputMuonCollection_(iConfig.getParameter<edm::InputTag>("muonCollection")),
23  inputTrackCollections_(iConfig.getParameter<std::vector<edm::InputTag> >("trackCollections"))
24  {
25  edm::ConsumesCollector iC = consumesCollector();
26  compatibilityFiller_ = new MuonCosmicCompatibilityFiller(iConfig.getParameter<edm::ParameterSet>("CosmicCompFillerParameters"),iC);
27 
28  produces<edm::ValueMap<unsigned int> >().setBranchAlias("cosmicsVeto");
29  produces<edm::ValueMap<reco::MuonCosmicCompatibility> >().setBranchAlias("cosmicCompatibility");
30 
31  muonToken_ = consumes<reco::MuonCollection>(inputMuonCollection_);
32  for(unsigned int i=0;i<inputTrackCollections_.size();++i)
33  trackTokens_.push_back(consumes<reco::TrackCollection>(inputTrackCollections_.at(i)));
34 
35  }
T getParameter(std::string const &) const
std::vector< edm::EDGetTokenT< reco::TrackCollection > > trackTokens_
std::vector< edm::InputTag > inputTrackCollections_
MuonCosmicCompatibilityFiller * compatibilityFiller_
edm::EDGetTokenT< reco::MuonCollection > muonToken_
CosmicsMuonIdProducer::~CosmicsMuonIdProducer ( )
inlineoverride

Definition at line 36 of file CosmicsMuonIdProducer.cc.

References compatibilityFiller_, and produce().

36  {
38  delete compatibilityFiller_;
39  }
MuonCosmicCompatibilityFiller * compatibilityFiller_

Member Function Documentation

void CosmicsMuonIdProducer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivate

Definition at line 53 of file CosmicsMuonIdProducer.cc.

References compatibilityFiller_, DEFINE_FWK_MODULE, MuonCosmicCompatibilityFiller::fillCompatibility(), objects.autophobj::filler, muonid::findOppositeTrack(), edm::Event::getByToken(), mps_fire::i, inputTrackCollections_, eostools::move(), metsig::muon, extraflags_cff::muons, muonToken_, MillePedeFileConverter_cfg::out, edm::Event::put(), l1t::tracks, trackTokens_, and MuonErrorMatrixValues_cff::values.

Referenced by ~CosmicsMuonIdProducer().

54 {
56  iEvent.getByToken(muonToken_, muons);
57  // reserve some space
58  std::vector<unsigned int> values;
59  values.reserve(muons->size());
60 
61  std::vector<reco::MuonCosmicCompatibility> compValues;
62  compValues.reserve(muons->size());
63 
64  for(reco::MuonCollection::const_iterator muon = muons->begin();
65  muon != muons->end(); ++muon)
66  {
67  unsigned int foundPartner(0);
68  if ( muon->innerTrack().isNonnull() ){
69  for ( unsigned int i=0; i<inputTrackCollections_.size(); ++i )
70  {
72  iEvent.getByToken(trackTokens_.at(i), tracks);
73  if ( muonid::findOppositeTrack(tracks,*muon->innerTrack()).isNonnull() ){
74  foundPartner = i+1;
75  break;
76  }
77  }
78  }
79  values.push_back(foundPartner);
80 
81  compValues.push_back(compatibilityFiller_->fillCompatibility(*muon, iEvent, iSetup));
82  }
83 
84  // create and fill value map
85  auto out = std::make_unique<edm::ValueMap<unsigned int>>();
87  filler.insert(muons, values.begin(), values.end());
88  filler.fill();
89 
90 
91  auto outC = std::make_unique<edm::ValueMap<reco::MuonCosmicCompatibility>>();
93  fillerC.insert(muons, compValues.begin(), compValues.end());
94  fillerC.fill();
95 
96  // put value map into event
97  iEvent.put(std::move(out));
98  iEvent.put(std::move(outC));
99 }
std::vector< edm::EDGetTokenT< reco::TrackCollection > > trackTokens_
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:125
reco::TrackRef findOppositeTrack(const edm::Handle< reco::TrackCollection > &collection, const reco::Track &muon, double angleMatch=0.01, double momentumMatch=0.05)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:517
std::vector< edm::InputTag > inputTrackCollections_
MuonCosmicCompatibilityFiller * compatibilityFiller_
reco::MuonCosmicCompatibility fillCompatibility(const reco::Muon &muon, edm::Event &, const edm::EventSetup &)
fill cosmic compatibility variables
edm::EDGetTokenT< reco::MuonCollection > muonToken_
def move(src, dest)
Definition: eostools.py:511

Member Data Documentation

MuonCosmicCompatibilityFiller* CosmicsMuonIdProducer::compatibilityFiller_
private

Definition at line 49 of file CosmicsMuonIdProducer.cc.

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

edm::InputTag CosmicsMuonIdProducer::inputMuonCollection_
private

Definition at line 43 of file CosmicsMuonIdProducer.cc.

Referenced by CosmicsMuonIdProducer().

std::vector<edm::InputTag> CosmicsMuonIdProducer::inputTrackCollections_
private

Definition at line 44 of file CosmicsMuonIdProducer.cc.

Referenced by CosmicsMuonIdProducer(), and produce().

edm::EDGetTokenT<reco::MuonCollection> CosmicsMuonIdProducer::muonToken_
private

Definition at line 45 of file CosmicsMuonIdProducer.cc.

Referenced by CosmicsMuonIdProducer(), and produce().

std::vector<edm::EDGetTokenT<reco::TrackCollection> > CosmicsMuonIdProducer::trackTokens_
private

Definition at line 46 of file CosmicsMuonIdProducer.cc.

Referenced by CosmicsMuonIdProducer(), and produce().