Go to the documentation of this file.00001
00002
00003
00004
00005
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include <memory>
00023
00024
00025 #include "FWCore/Framework/interface/Frameworkfwd.h"
00026 #include "FWCore/Framework/interface/EDProducer.h"
00027
00028 #include "FWCore/Framework/interface/Event.h"
00029 #include "FWCore/Framework/interface/MakerMacros.h"
00030
00031 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00032
00033 #include "DataFormats/PatCandidates/interface/CompositeCandidate.h"
00034 #include "DataFormats/RecoCandidate/interface/RecoChargedCandidate.h"
00035 #include "DataFormats/PatCandidates/interface/Muon.h"
00036 #include "DataFormats/TrackReco/interface/Track.h"
00037 #include "DataFormats/TrackReco/interface/TrackFwd.h"
00038 #include "PhysicsTools/CandUtils/interface/AddFourMomenta.h"
00039 #include "DataFormats/Math/interface/deltaR.h"
00040
00041
00042 #include <TLorentzVector.h>
00043
00044
00045 #include <vector>
00046
00047
00048
00049
00050
00051 class PatJPsiProducer : public edm::EDProducer {
00052 public:
00053 explicit PatJPsiProducer(const edm::ParameterSet&);
00054 ~PatJPsiProducer();
00055
00056 private:
00057 virtual void beginJob() ;
00058 virtual void produce(edm::Event&, const edm::EventSetup&);
00059 virtual void endJob() ;
00060
00061
00062
00063 edm::InputTag muonSrc_;
00064 };
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078 PatJPsiProducer::PatJPsiProducer(const edm::ParameterSet& iConfig) :
00079 muonSrc_ ( iConfig.getParameter<edm::InputTag>("muonSrc") )
00080 {
00081 produces<std::vector<pat::CompositeCandidate> > ();
00082
00083 }
00084
00085
00086 PatJPsiProducer::~PatJPsiProducer()
00087 {
00088
00089 }
00090
00091
00092
00093
00094
00095
00096
00097 void
00098 PatJPsiProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup)
00099 {
00100
00101 std::auto_ptr<std::vector<pat::CompositeCandidate> > jpsiCands( new std::vector<pat::CompositeCandidate> );
00102 edm::Handle<edm::View<pat::Muon> > h_muons;
00103 iEvent.getByLabel( muonSrc_, h_muons );
00104 std::cout<<"valid?"<< h_muons.isValid()<<" size?"<< h_muons->size();
00105 if ( h_muons.isValid() && h_muons->size() > 1 ) {
00106
00107 for ( edm::View<pat::Muon>::const_iterator muonsBegin = h_muons->begin(),
00108 muonsEnd = h_muons->end(), imuon = muonsBegin;
00109 imuon != muonsEnd - 1; ++imuon ) {
00110
00111 for ( edm::View<pat::Muon>::const_iterator jmuon = imuon + 1;
00112 jmuon != muonsEnd; ++jmuon ) {
00113 if ( imuon->charge() * jmuon->charge() < 0 ) {
00114
00115
00116 pat::CompositeCandidate jpsi;
00117 jpsi.addDaughter( *imuon, "mu1");
00118 jpsi.addDaughter( *jmuon, "mu2");
00119
00120 AddFourMomenta addp4;
00121 addp4.set( jpsi );
00122
00123 double dR = reco::deltaR<pat::Muon,pat::Muon>( *imuon, *jmuon );
00124
00125
00126 jpsi.addUserFloat("dR", dR );
00127
00128 jpsiCands->push_back( jpsi );
00129
00130 }
00131 }
00132 }
00133 }
00134 iEvent.put( jpsiCands );
00135
00136 }
00137
00138
00139 void
00140 PatJPsiProducer::beginJob()
00141 {
00142 }
00143
00144
00145 void
00146 PatJPsiProducer::endJob() {
00147 }
00148
00149
00150 DEFINE_FWK_MODULE(PatJPsiProducer);