CMS 3D CMS Logo

MuonSelectionTypeValueMapProducer.h
Go to the documentation of this file.
1 #ifndef MuonIdentification_MuonSelectionTypeValueMapProducer_h
2 #define MuonIdentification_MuonSelectionTypeValueMapProducer_h
3 
4 #include <string>
5 #include <vector>
6 
10 
17 
19  public:
21  inputMuonCollection_(iConfig.getParameter<edm::InputTag>("inputMuonCollection")),
22  selectionTypeLabel_(iConfig.getParameter<std::string>("selectionType"))
23  {
25  produces<edm::ValueMap<bool> >().setBranchAlias("muid"+selectionTypeLabel_);
26  muonToken_ = consumes<reco::MuonCollection>(inputMuonCollection_);
27  }
29 
30  private:
31  void produce(edm::Event&, const edm::EventSetup&) override;
32 
35 
38 };
39 
40 void
42 {
43  // input muon collection
45  iEvent.getByToken(muonToken_, muonsH);
46 
47  // reserve some space
48  std::vector<bool> values;
49  values.reserve(muonsH->size());
50 
51  // isGoodMuon
52  for(reco::MuonCollection::const_iterator it = muonsH->begin(); it != muonsH->end(); ++it)
53  values.push_back(muon::isGoodMuon(*it, selectionType_));
54 
55  // create and fill value map
56  auto out = std::make_unique<edm::ValueMap<bool>>();
58  filler.insert(muonsH, values.begin(), values.end());
59  filler.fill();
60 
61  // put value map into event
62  iEvent.put(std::move(out));
63 }
64 
65 #endif
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:125
MuonSelectionTypeValueMapProducer(const edm::ParameterSet &iConfig)
edm::EDGetTokenT< reco::MuonCollection > muonToken_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:517
SelectionType
Selector type.
Definition: MuonSelectors.h:17
int iEvent
Definition: GenABIO.cc:224
void produce(edm::Event &, const edm::EventSetup &) override
bool isGoodMuon(const reco::Muon &muon, SelectionType type, reco::Muon::ArbitrationType arbitrationType=reco::Muon::SegmentAndTrackArbitration)
main GoodMuon wrapper call
SelectionType selectionTypeFromString(const std::string &label)
Definition: MuonSelectors.cc:9
HLT enums.
def move(src, dest)
Definition: eostools.py:511