CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
PatJPsiProducer.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: PatJPsiProducer
4 // Class: PatJPsiProducer
5 //
13 //
14 // Original Author: "Salvatore Rappoccio"
15 // Created: Mon Sep 28 12:53:57 CDT 2009
16 //
17 //
18 
19 // system include files
20 #include <memory>
21 
22 // user include files
25 
28 
30 
38 
39 #include <TLorentzVector.h>
40 
41 #include <vector>
42 
43 //
44 // class decleration
45 //
46 
48 public:
49  explicit PatJPsiProducer(const edm::ParameterSet&);
50  ~PatJPsiProducer() override;
51 
52 private:
53  void beginJob() override;
54  void produce(edm::Event&, const edm::EventSetup&) override;
55  void endJob() override;
56 
57  // ----------member data ---------------------------
58 
60 };
61 
62 //
63 // constants, enums and typedefs
64 //
65 
66 //
67 // static data member definitions
68 //
69 
70 //
71 // constructors and destructor
72 //
74  : muonSrcToken_(consumes<edm::View<pat::Muon>>(iConfig.getParameter<edm::InputTag>("muonSrc"))) {
75  produces<std::vector<pat::CompositeCandidate>>();
76 }
77 
79 
80 //
81 // member functions
82 //
83 
84 // ------------ method called to produce the data ------------
86  auto jpsiCands = std::make_unique<std::vector<pat::CompositeCandidate>>();
88  iEvent.getByToken(muonSrcToken_, h_muons);
89 
90  // const double MUON_MASS = 0.106;
91  const double JPSI_MASS = 3.097;
92 
93  if (h_muons.isValid() && h_muons->size() > 1) {
94  for (edm::View<pat::Muon>::const_iterator muonsBegin = h_muons->begin(),
95  muonsEnd = h_muons->end(),
96  imuon = muonsBegin;
97  imuon != muonsEnd - 1;
98  ++imuon) {
99  if (imuon->pt() > 1.0) {
100  for (edm::View<pat::Muon>::const_iterator jmuon = imuon + 1; jmuon != muonsEnd; ++jmuon) {
101  if (imuon->charge() * jmuon->charge() < 0) {
103  jpsi.addDaughter(*imuon, "mu1");
104  jpsi.addDaughter(*jmuon, "mu2");
105 
106  AddFourMomenta addp4;
107  addp4.set(jpsi);
108 
109  double dR = reco::deltaR<pat::Muon, pat::Muon>(*imuon, *jmuon);
110 
111  jpsi.addUserFloat("dR", dR);
112 
113  if (fabs(jpsi.mass() - JPSI_MASS) < 1.0) {
114  jpsiCands->push_back(jpsi);
115  }
116  }
117  }
118  }
119  }
120  }
121 
122  iEvent.put(std::move(jpsiCands));
123 }
124 
125 // ------------ method called once each job just before starting event loop ------------
127 
128 // ------------ method called once each job just after ending the event loop ------------
130 
131 //define this as a plug-in
Analysis-level particle class.
void produce(edm::Event &, const edm::EventSetup &) override
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:539
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
void addUserFloat(const std::string &label, float data, const bool overwrite=false)
Set user-defined float.
Definition: PATObject.h:892
void endJob() override
int iEvent
Definition: GenABIO.cc:224
edm::EDGetTokenT< edm::View< pat::Muon > > muonSrcToken_
def move
Definition: eostools.py:511
void addDaughter(const Candidate &, const std::string &s="")
add a clone of the passed candidate as daughter
void beginJob() override
#define jpsi
double mass() const final
mass
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:86
PatJPsiProducer(const edm::ParameterSet &)
void set(reco::Candidate &c) const
set up a candidate
~PatJPsiProducer() override