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 
20 // system include files
21 #include <memory>
22 
23 // user include files
26 
29 
31 
39 
40 
41 #include <TLorentzVector.h>
42 
43 
44 #include <vector>
45 
46 //
47 // class decleration
48 //
49 
51  public:
52  explicit PatJPsiProducer(const edm::ParameterSet&);
54 
55  private:
56  virtual void beginJob() override ;
57  virtual void produce(edm::Event&, const edm::EventSetup&) override;
58  virtual void endJob() override ;
59 
60  // ----------member data ---------------------------
61 
63 };
64 
65 //
66 // constants, enums and typedefs
67 //
68 
69 
70 //
71 // static data member definitions
72 //
73 
74 //
75 // constructors and destructor
76 //
78  muonSrcToken_ ( consumes<edm::View<pat::Muon> >( iConfig.getParameter<edm::InputTag>("muonSrc") ) )
79 {
80  produces<std::vector<pat::CompositeCandidate> > ();
81 
82 }
83 
84 
86 {
87 
88 }
89 
90 
91 //
92 // member functions
93 //
94 
95 // ------------ method called to produce the data ------------
96 void
98 {
99 
100  auto jpsiCands = std::make_unique<std::vector<pat::CompositeCandidate>>();
102  iEvent.getByToken( muonSrcToken_, h_muons );
103 
104  // const double MUON_MASS = 0.106;
105  const double JPSI_MASS = 3.097;
106 
107 
108  if ( h_muons.isValid() && h_muons->size() > 1 ) {
109 
110  for ( edm::View<pat::Muon>::const_iterator muonsBegin = h_muons->begin(),
111  muonsEnd = h_muons->end(), imuon = muonsBegin;
112  imuon != muonsEnd - 1; ++imuon ) {
113  if ( imuon->pt() > 1.0 ) {
114 
115 
116  for ( edm::View<pat::Muon>::const_iterator jmuon = imuon + 1;
117  jmuon != muonsEnd; ++jmuon ) {
118  if ( imuon->charge() * jmuon->charge() < 0 ) {
119 
121  jpsi.addDaughter( *imuon, "mu1");
122  jpsi.addDaughter( *jmuon, "mu2");
123 
124  AddFourMomenta addp4;
125  addp4.set( jpsi );
126 
127  double dR = reco::deltaR<pat::Muon,pat::Muon>( *imuon, *jmuon );
128 
129  jpsi.addUserFloat("dR", dR );
130 
131  if ( fabs( jpsi.mass() - JPSI_MASS ) < 1.0 ) {
132  jpsiCands->push_back( jpsi );
133  }
134  }
135  }
136  }
137  }
138  }
139 
140  iEvent.put(std::move(jpsiCands));
141 
142 }
143 
144 // ------------ method called once each job just before starting event loop ------------
145 void
147 {
148 }
149 
150 // ------------ method called once each job just after ending the event loop ------------
151 void
153 }
154 
155 //define this as a plug-in
Analysis-level particle class.
virtual void produce(edm::Event &, const edm::EventSetup &) override
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:122
virtual double mass() const final
mass
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:460
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
void addUserFloat(const std::string &label, float data, const bool overwrite=false)
Set user-defined float.
Definition: PATObject.h:813
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
Definition: HeavyIon.h:7
virtual void endJob() override
int iEvent
Definition: GenABIO.cc:230
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
virtual void beginJob() override
#define jpsi
HLT enums.
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
def move(src, dest)
Definition: eostools.py:510