CMS 3D CMS Logo

MuMuForEmbeddingSelector.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: TauAnalysis/EmbeddingProducer
4 // Class: MuMuForEmbeddingSelector
5 //
13 //
14 // Original Author: Artur Akhmetshin
15 // Created: Mon, 13 Jun 2016 11:05:32 GMT
16 //
17 //
18 
19 // system include files
20 #include <memory>
21 
22 // user include files
25 
28 
31 
34 
35 //
36 // class declaration
37 //
38 
40 public:
42  ~MuMuForEmbeddingSelector() override;
43 
44  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
45 
46 private:
47  void beginStream(edm::StreamID) override;
48  void produce(edm::Event&, const edm::EventSetup&) override;
49  void endStream() override;
50 
51  //virtual void beginRun(edm::Run const&, edm::EventSetup const&) override;
52  //virtual void endRun(edm::Run const&, edm::EventSetup const&) override;
53  //virtual void beginLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&) override;
54  //virtual void endLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&) override;
55 
56  // ----------member data ---------------------------
58  double ZMass = 91.0;
59 };
60 
61 //
62 // constants, enums and typedefs
63 //
64 
65 //
66 // static data member definitions
67 //
68 
69 //
70 // constructors and destructor
71 //
73  : ZmumuCandidates_(consumes<edm::View<reco::CompositeCandidate>>(
74  iConfig.getParameter<edm::InputTag>("ZmumuCandidatesCollection"))) {
75  //register your products
76  /* Examples
77  produces<ExampleData2>();
78 
79  //if do put with a label
80  produces<ExampleData2>("label");
81 
82  //if you want to put into the Run
83  produces<ExampleData2,InRun>();
84 */
85  produces<edm::RefVector<pat::MuonCollection>>();
86 
87  //now do what ever other initialization is needed
88 }
89 
91  // do anything here that needs to be done at destruction time
92  // (e.g. close files, deallocate resources etc.)
93 }
94 
95 //
96 // member functions
97 //
98 
99 // ------------ method called to produce the data ------------
101  using namespace edm;
103  iEvent.getByToken(ZmumuCandidates_, ZmumuCandidatesHandle);
104  edm::View<reco::CompositeCandidate> ZmumuCandidates = *ZmumuCandidatesHandle;
105 
106  const reco::CompositeCandidate* chosenZCand = nullptr;
107  double massDifference = -1.0;
109  iZCand != ZmumuCandidates.end();
110  ++iZCand) {
111  if (std::abs(ZMass - iZCand->mass()) < massDifference || massDifference < 0) {
112  massDifference = std::abs(ZMass - iZCand->mass());
113  chosenZCand = &(*iZCand);
114  }
115  }
116  std::unique_ptr<edm::RefVector<pat::MuonCollection>> prod(new edm::RefVector<pat::MuonCollection>());
117  prod->reserve(2);
118  prod->push_back(chosenZCand->daughter(0)->masterClone().castTo<pat::MuonRef>());
119  prod->push_back(chosenZCand->daughter(1)->masterClone().castTo<pat::MuonRef>());
120  iEvent.put(std::move(prod));
121 }
122 
123 // ------------ method called once each stream before processing any runs, lumis or events ------------
125 
126 // ------------ method called once each stream after processing all runs, lumis and events ------------
128 
129 // ------------ method called when starting to processes a run ------------
130 /*
131 void
132 MuMuForEmbeddingSelector::beginRun(edm::Run const&, edm::EventSetup const&)
133 {
134 }
135 */
136 
137 // ------------ method called when ending the processing of a run ------------
138 /*
139 void
140 MuMuForEmbeddingSelector::endRun(edm::Run const&, edm::EventSetup const&)
141 {
142 }
143 */
144 
145 // ------------ method called when starting to processes a luminosity block ------------
146 /*
147 void
148 MuMuForEmbeddingSelector::beginLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&)
149 {
150 }
151 */
152 
153 // ------------ method called when ending the processing of a luminosity block ------------
154 /*
155 void
156 MuMuForEmbeddingSelector::endLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&)
157 {
158 }
159 */
160 
161 // ------------ method fills 'descriptions' with the allowed parameters for the module ------------
163  //The following says we do not know what parameters are allowed so do no validation
164  // Please change this to state exactly what you do use, even if it is no parameters
166  desc.setUnknown();
167  descriptions.addDefault(desc);
168 }
169 
170 //define this as a plug-in
edm::StreamID
Definition: StreamID.h:30
SelectingProcedure_cff.ZmumuCandidates
ZmumuCandidates
Definition: SelectingProcedure_cff.py:57
CompositeCandidate.h
sistrip::View
View
Definition: ConstantsForView.h:26
edm::EDGetTokenT
Definition: EDGetToken.h:33
edm
HLT enums.
Definition: AlignableModifier.h:19
Muon.h
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
EDProducer.h
edm::RefVector
Definition: EDProductfwd.h:27
MuMuForEmbeddingSelector::beginStream
void beginStream(edm::StreamID) override
Definition: MuMuForEmbeddingSelector.cc:124
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:45
edm::Handle
Definition: AssociativeIterator.h:50
MuMuForEmbeddingSelector::ZmumuCandidates_
edm::EDGetTokenT< edm::View< reco::CompositeCandidate > > ZmumuCandidates_
Definition: MuMuForEmbeddingSelector.cc:57
edm::Ref< MuonCollection >
MuMuForEmbeddingSelector::ZMass
double ZMass
Definition: MuMuForEmbeddingSelector.cc:58
MakerMacros.h
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
MuMuForEmbeddingSelector::MuMuForEmbeddingSelector
MuMuForEmbeddingSelector(const edm::ParameterSet &)
Definition: MuMuForEmbeddingSelector.cc:72
MuMuForEmbeddingSelector::fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: MuMuForEmbeddingSelector.cc:162
dumpMFGeometry_cfg.prod
prod
Definition: dumpMFGeometry_cfg.py:24
MuMuForEmbeddingSelector::~MuMuForEmbeddingSelector
~MuMuForEmbeddingSelector() override
Definition: MuMuForEmbeddingSelector.cc:90
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
edm::View
Definition: CaloClusterFwd.h:14
MuMuForEmbeddingSelector
Definition: MuMuForEmbeddingSelector.cc:39
HLT_2018_cff.InputTag
InputTag
Definition: HLT_2018_cff.py:79016
edm::ParameterSet
Definition: ParameterSet.h:36
Event.h
iEvent
int iEvent
Definition: GenABIO.cc:224
edm::stream::EDProducer
Definition: EDProducer.h:38
edm::ParameterSetDescription::setUnknown
void setUnknown()
Definition: ParameterSetDescription.cc:39
edm::EventSetup
Definition: EventSetup.h:57
edm::RefToBase::castTo
REF castTo() const
Definition: RefToBase.h:257
eostools.move
def move(src, dest)
Definition: eostools.py:511
Frameworkfwd.h
MuMuForEmbeddingSelector::endStream
void endStream() override
Definition: MuMuForEmbeddingSelector.cc:127
reco::Candidate::masterClone
virtual const CandidateBaseRef & masterClone() const =0
edm::View::const_iterator
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:86
MuMuForEmbeddingSelector::produce
void produce(edm::Event &, const edm::EventSetup &) override
Definition: MuMuForEmbeddingSelector.cc:100
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
ParameterSet.h
edm::Event
Definition: Event.h:73
edm::ConfigurationDescriptions::addDefault
void addDefault(ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:99
reco::CompositeCandidate::daughter
const Candidate * daughter(size_type) const override
return daughter at a given position, i = 0, ... numberOfDaughters() - 1 (read only mode)
Definition: CompositeCandidate.cc:30
StreamID.h
reco::CompositeCandidate
Definition: CompositeCandidate.h:21