CMS 3D CMS Logo

CosmicsMuonIdProducer.cc
Go to the documentation of this file.
1 #include <string>
2 #include <vector>
3 
9 
16 
18 
20 public:
22  : inputMuonCollection_(iConfig.getParameter<edm::InputTag>("muonCollection")),
23  inputTrackCollections_(iConfig.getParameter<std::vector<edm::InputTag>>("trackCollections")) {
24  edm::ConsumesCollector iC = consumesCollector();
26  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  }
37  delete compatibilityFiller_;
38  }
39 
40 private:
41  void produce(edm::Event&, const edm::EventSetup&) override;
43  std::vector<edm::InputTag> inputTrackCollections_;
45  std::vector<edm::EDGetTokenT<reco::TrackCollection>> trackTokens_;
46 
48 };
49 
52  iEvent.getByToken(muonToken_, muons);
53  // reserve some space
54  std::vector<unsigned int> values;
55  values.reserve(muons->size());
56 
57  std::vector<reco::MuonCosmicCompatibility> compValues;
58  compValues.reserve(muons->size());
59 
60  for (reco::MuonCollection::const_iterator muon = muons->begin(); muon != muons->end(); ++muon) {
61  unsigned int foundPartner(0);
62  if (muon->innerTrack().isNonnull()) {
63  for (unsigned int i = 0; i < inputTrackCollections_.size(); ++i) {
65  iEvent.getByToken(trackTokens_.at(i), tracks);
66  if (muonid::findOppositeTrack(tracks, *muon->innerTrack()).isNonnull()) {
67  foundPartner = i + 1;
68  break;
69  }
70  }
71  }
72  values.push_back(foundPartner);
73 
74  compValues.push_back(compatibilityFiller_->fillCompatibility(*muon, iEvent, iSetup));
75  }
76 
77  // create and fill value map
78  auto out = std::make_unique<edm::ValueMap<unsigned int>>();
80  filler.insert(muons, values.begin(), values.end());
81  filler.fill();
82 
83  auto outC = std::make_unique<edm::ValueMap<reco::MuonCosmicCompatibility>>();
85  fillerC.insert(muons, compValues.begin(), compValues.end());
86  fillerC.fill();
87 
88  // put value map into event
89  iEvent.put(std::move(out));
90  iEvent.put(std::move(outC));
91 }
PDWG_BPHSkim_cff.muons
muons
Definition: PDWG_BPHSkim_cff.py:47
mps_fire.i
i
Definition: mps_fire.py:428
Muon.h
CosmicsMuonIdProducer::compatibilityFiller_
MuonCosmicCompatibilityFiller * compatibilityFiller_
Definition: CosmicsMuonIdProducer.cc:47
muon
Definition: MuonCocktails.h:17
CosmicsMuonIdProducer::~CosmicsMuonIdProducer
~CosmicsMuonIdProducer() override
Definition: CosmicsMuonIdProducer.cc:35
edm::EDGetTokenT< reco::MuonCollection >
edm
HLT enums.
Definition: AlignableModifier.h:19
CosmicsMuonIdProducer::CosmicsMuonIdProducer
CosmicsMuonIdProducer(const edm::ParameterSet &iConfig)
Definition: CosmicsMuonIdProducer.cc:21
MuonCosmicCompatibilityFiller.h
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89285
EDProducer.h
edm::Handle< reco::MuonCollection >
MakerMacros.h
Track.h
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
CosmicsMuonIdProducer::produce
void produce(edm::Event &, const edm::EventSetup &) override
Definition: CosmicsMuonIdProducer.cc:50
MuonCosmicCompatibilityFiller::fillCompatibility
reco::MuonCosmicCompatibility fillCompatibility(const reco::Muon &muon, edm::Event &, const edm::EventSetup &)
fill cosmic compatibility variables
Definition: MuonCosmicCompatibilityFiller.cc:100
HLT_FULL_cff.muon
muon
Definition: HLT_FULL_cff.py:11710
contentValuesCheck.values
values
Definition: contentValuesCheck.py:38
MuonFwd.h
MuonCosmicCompatibilityFiller
Definition: MuonCosmicCompatibilityFiller.h:43
CosmicsMuonIdProducer::inputMuonCollection_
edm::InputTag inputMuonCollection_
Definition: CosmicsMuonIdProducer.cc:42
edm::ParameterSet
Definition: ParameterSet.h:47
Event.h
tracks
const uint32_t *__restrict__ const HitContainer *__restrict__ TkSoA *__restrict__ tracks
Definition: CAHitNtupletGeneratorKernelsImpl.h:159
trigObjTnPSource_cfi.filler
filler
Definition: trigObjTnPSource_cfi.py:21
iEvent
int iEvent
Definition: GenABIO.cc:224
trackerHitRTTI::vector
Definition: trackerHitRTTI.h:21
edm::stream::EDProducer
Definition: EDProducer.h:38
edm::EventSetup
Definition: EventSetup.h:58
CosmicsMuonIdProducer::trackTokens_
std::vector< edm::EDGetTokenT< reco::TrackCollection > > trackTokens_
Definition: CosmicsMuonIdProducer.cc:45
ValueMap.h
eostools.move
def move(src, dest)
Definition: eostools.py:511
std
Definition: JetResolutionObject.h:76
CosmicsMuonIdProducer
Definition: CosmicsMuonIdProducer.cc:19
CosmicsMuonIdProducer::muonToken_
edm::EDGetTokenT< reco::MuonCollection > muonToken_
Definition: CosmicsMuonIdProducer.cc:44
Frameworkfwd.h
EventSetup.h
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
CosmicsMuonIdProducer::inputTrackCollections_
std::vector< edm::InputTag > inputTrackCollections_
Definition: CosmicsMuonIdProducer.cc:43
MillePedeFileConverter_cfg.out
out
Definition: MillePedeFileConverter_cfg.py:31
edm::helper::Filler
Definition: ValueMap.h:22
ParameterSet.h
muonid::findOppositeTrack
reco::TrackRef findOppositeTrack(const edm::Handle< reco::TrackCollection > &collection, const reco::Track &muon, double angleMatch=0.01, double momentumMatch=0.05)
Definition: MuonCosmicsId.cc:28
edm::Event
Definition: Event.h:73
edm::InputTag
Definition: InputTag.h:15
edm::ConsumesCollector
Definition: ConsumesCollector.h:45
MuonCosmicsId.h