CMS 3D CMS Logo

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 
51 private:
52  void produce(edm::StreamID, edm::Event&, const edm::EventSetup&) const override;
53 
54  // ----------member data ---------------------------
55 
57 };
58 
59 //
60 // constants, enums and typedefs
61 //
62 
63 //
64 // static data member definitions
65 //
66 
67 //
68 // constructors and destructor
69 //
71  : muonSrcToken_(consumes<edm::View<pat::Muon>>(iConfig.getParameter<edm::InputTag>("muonSrc"))) {
72  produces<std::vector<pat::CompositeCandidate>>();
73 }
74 
75 //
76 // member functions
77 //
78 
79 // ------------ method called to produce the data ------------
81  auto jpsiCands = std::make_unique<std::vector<pat::CompositeCandidate>>();
83  iEvent.getByToken(muonSrcToken_, h_muons);
84 
85  // const double MUON_MASS = 0.106;
86  const double JPSI_MASS = 3.097;
87 
88  if (h_muons.isValid() && h_muons->size() > 1) {
89  for (edm::View<pat::Muon>::const_iterator muonsBegin = h_muons->begin(),
90  muonsEnd = h_muons->end(),
91  imuon = muonsBegin;
92  imuon != muonsEnd - 1;
93  ++imuon) {
94  if (imuon->pt() > 1.0) {
95  for (edm::View<pat::Muon>::const_iterator jmuon = imuon + 1; jmuon != muonsEnd; ++jmuon) {
96  if (imuon->charge() * jmuon->charge() < 0) {
98  jpsi.addDaughter(*imuon, "mu1");
99  jpsi.addDaughter(*jmuon, "mu2");
100 
101  AddFourMomenta addp4;
102  addp4.set(jpsi);
103 
104  double dR = reco::deltaR<pat::Muon, pat::Muon>(*imuon, *jmuon);
105 
106  jpsi.addUserFloat("dR", dR);
107 
108  if (fabs(jpsi.mass() - JPSI_MASS) < 1.0) {
109  jpsiCands->push_back(jpsi);
110  }
111  }
112  }
113  }
114  }
115  }
116 
117  iEvent.put(std::move(jpsiCands));
118 }
119 
120 //define this as a plug-in
Analysis-level particle class.
void set(reco::Candidate &c) const
set up a candidate
#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
Definition: HeavyIon.h:7
int iEvent
Definition: GenABIO.cc:224
Definition: Muon.py:1
edm::EDGetTokenT< edm::View< pat::Muon > > muonSrcToken_
void addDaughter(const Candidate &, const std::string &s="")
add a clone of the passed candidate as daughter
HLT enums.
double mass() const final
mass
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:86
PatJPsiProducer(const edm::ParameterSet &)
void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override
def move(src, dest)
Definition: eostools.py:511