CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros 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 // $Id: PatJPsiProducer.cc,v 1.3 2012/11/29 09:54:35 kuessel Exp $
17 //
18 //
19 
20 
21 // system include files
22 #include <memory>
23 
24 // user include files
27 
30 
32 
40 
41 
42 #include <TLorentzVector.h>
43 
44 
45 #include <vector>
46 
47 //
48 // class decleration
49 //
50 
52  public:
53  explicit PatJPsiProducer(const edm::ParameterSet&);
55 
56  private:
57  virtual void beginJob() ;
58  virtual void produce(edm::Event&, const edm::EventSetup&);
59  virtual void endJob() ;
60 
61  // ----------member data ---------------------------
62 
64 };
65 
66 //
67 // constants, enums and typedefs
68 //
69 
70 
71 //
72 // static data member definitions
73 //
74 
75 //
76 // constructors and destructor
77 //
79  muonSrc_ ( iConfig.getParameter<edm::InputTag>("muonSrc") )
80 {
81  produces<std::vector<pat::CompositeCandidate> > ();
82 
83 }
84 
85 
87 {
88 
89 }
90 
91 
92 //
93 // member functions
94 //
95 
96 // ------------ method called to produce the data ------------
97 void
99 {
100 
101  std::auto_ptr<std::vector<pat::CompositeCandidate> > jpsiCands( new std::vector<pat::CompositeCandidate> );
103  iEvent.getByLabel( muonSrc_, h_muons );
104  std::cout<<"valid?"<< h_muons.isValid()<<" size?"<< h_muons->size();
105  if ( h_muons.isValid() && h_muons->size() > 1 ) {
106 
107  for ( edm::View<pat::Muon>::const_iterator muonsBegin = h_muons->begin(),
108  muonsEnd = h_muons->end(), imuon = muonsBegin;
109  imuon != muonsEnd - 1; ++imuon ) {
110 
111  for ( edm::View<pat::Muon>::const_iterator jmuon = imuon + 1;
112  jmuon != muonsEnd; ++jmuon ) {
113  if ( imuon->charge() * jmuon->charge() < 0 ) {
114 
115  //A composite Candidate is very useful to build event hypothesis and cut on combined object information.
117  jpsi.addDaughter( *imuon, "mu1");
118  jpsi.addDaughter( *jmuon, "mu2");
119 
120  AddFourMomenta addp4;
121  addp4.set( jpsi );
122 
123  double dR = reco::deltaR<pat::Muon,pat::Muon>( *imuon, *jmuon );
124 
125  // Analogue to any other PAT object we can add our own information into the object via addUserFloat/Int/Data()
126  jpsi.addUserFloat("dR", dR );
127 
128  jpsiCands->push_back( jpsi );
129 
130  }
131  }
132  }
133  }
134  iEvent.put( jpsiCands );
135 
136 }
137 
138 // ------------ method called once each job just before starting event loop ------------
139 void
141 {
142 }
143 
144 // ------------ method called once each job just after ending the event loop ------------
145 void
147 }
148 
149 //define this as a plug-in
Analysis-level particle class.
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:81
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
virtual void beginJob()
virtual void endJob()
int iEvent
Definition: GenABIO.cc:243
edm::InputTag muonSrc_
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:85
void addUserFloat(const std::string &label, float data)
Set user-defined float.
Definition: PATObject.h:763
bool isValid() const
Definition: HandleBase.h:76
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
void addDaughter(const Candidate &, const std::string &s="")
add a clone of the passed candidate as daughter
virtual void produce(edm::Event &, const edm::EventSetup &)
#define jpsi
PatJPsiProducer(const edm::ParameterSet &)
tuple cout
Definition: gather_cfg.py:121
void set(reco::Candidate &c) const
set up a candidate