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 @example_myparticle #include "DataFormats/MuonReco/interface/Muon.h"
00034 @example_myparticle #include "DataFormats/EgammaCandidates/interface/PixelMatchGsfElectron.h"
00035 @example_myparticle #include "DataFormats/Candidate/interface/Particle.h"
00036 @example_myparticle #include "FWCore/MessageLogger/interface/MessageLogger.h"
00037 @example_myparticle #include "FWCore/Utilities/interface/InputTag.h"
00038
00039
00040
00041
00042
00043 class prodname : public edm::EDProducer {
00044 public:
00045 explicit prodname(const edm::ParameterSet&);
00046 ~prodname();
00047
00048 static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
00049
00050 private:
00051 virtual void beginJob() ;
00052 virtual void produce(edm::Event&, const edm::EventSetup&);
00053 virtual void endJob() ;
00054
00055 virtual void beginRun(edm::Run&, edm::EventSetup const&);
00056 virtual void endRun(edm::Run&, edm::EventSetup const&);
00057 virtual void beginLuminosityBlock(edm::LuminosityBlock&, edm::EventSetup const&);
00058 virtual void endLuminosityBlock(edm::LuminosityBlock&, edm::EventSetup const&);
00059
00060
00061 @example_myparticle edm::InputTag muonTags_;
00062 @example_myparticle edm::InputTag electronTags_;
00063 };
00064
00065
00066
00067
00068
00069 @example_myparticle
00070 @example_myparticle typedef std::vector<reco::Particle> MyParticleCollection;
00071
00072
00073
00074
00075
00076
00077
00078
00079 prodname::prodname(const edm::ParameterSet& iConfig)
00080 @example_myparticle :
00081 @example_myparticle muonTags_( iConfig.getParameter<edm::InputTag>( "muons" )),
00082 @example_myparticle electronTags_( iConfig.getParameter<edm::InputTag>( "electrons" ))
00083 {
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094 @example_myparticle produces<MyParticleCollection>( "particles" );
00095
00096
00097 }
00098
00099
00100 prodname::~prodname()
00101 {
00102
00103
00104
00105
00106 }
00107
00108
00109
00110
00111
00112
00113
00114 void
00115 prodname::produce(edm::Event& iEvent, const edm::EventSetup& iSetup)
00116 {
00117 using namespace edm;
00118 @example_myparticle using namespace reco;
00119 @example_myparticle using namespace std;
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137 @example_myparticle Handle<MuonCollection> muons;
00138 @example_myparticle iEvent.getByLabel( muonTags_, muons );
00139 @example_myparticle
00140 @example_myparticle Handle<PixelMatchGsfElectronCollection> electrons;
00141 @example_myparticle iEvent.getByLabel( electronTags_, electrons );
00142 @example_myparticle
00143 @example_myparticle
00144 @example_myparticle auto_ptr<MyParticleCollection> newParticles( new MyParticleCollection );
00145 @example_myparticle
00146 @example_myparticle
00147 @example_myparticle if( muons->size() == 4 || electrons->size() == 4 || ( muons->size() == 2 && electrons->size() == 2 ) ) {
00148 @example_myparticle
00149 @example_myparticle
00150 @example_myparticle Particle::LorentzVector totalP4( 0, 0, 0, 0 );
00151 @example_myparticle Particle::Charge charge( 0 );
00152 @example_myparticle
00153 @example_myparticle
00154 @example_myparticle for( MuonCollection::const_iterator muon = muons->begin(); muon != muons->end(); ++muon ) {
00155 @example_myparticle totalP4 += muon->p4();
00156 @example_myparticle charge += muon->charge();
00157 @example_myparticle }
00158 @example_myparticle
00159 @example_myparticle for( PixelMatchGsfElectronCollection::const_iterator electron = electrons->begin(); electron != electrons->end(); ++electron ) {
00160 @example_myparticle totalP4 += electron->p4();
00161 @example_myparticle charge += electron->charge();
00162 @example_myparticle }
00163 @example_myparticle
00164 @example_myparticle
00165 @example_myparticle Particle h;
00166 @example_myparticle h.setP4(totalP4);
00167 @example_myparticle h.setCharge(charge);
00168 @example_myparticle
00169 @example_myparticle
00170 @example_myparticle newParticles->push_back( h );
00171 @example_myparticle }
00172 @example_myparticle
00173 @example_myparticle
00174 @example_myparticle iEvent.put( newParticles, "particles" );
00175 }
00176
00177
00178 void
00179 prodname::beginJob()
00180 {
00181 }
00182
00183
00184 void
00185 prodname::endJob() {
00186 }
00187
00188
00189 void
00190 prodname::beginRun(edm::Run&, edm::EventSetup const&)
00191 {
00192 }
00193
00194
00195 void
00196 prodname::endRun(edm::Run&, edm::EventSetup const&)
00197 {
00198 }
00199
00200
00201 void
00202 prodname::beginLuminosityBlock(edm::LuminosityBlock&, edm::EventSetup const&)
00203 {
00204 }
00205
00206
00207 void
00208 prodname::endLuminosityBlock(edm::LuminosityBlock&, edm::EventSetup const&)
00209 {
00210 }
00211
00212
00213 void
00214 prodname::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
00215
00216
00217 edm::ParameterSetDescription desc;
00218 desc.setUnknown();
00219 descriptions.addDefault(desc);
00220 @example_myparticle
00221 @example_myparticle
00222 @example_myparticle
00223 @example_myparticle
00224 @example_myparticle
00225 @example_myparticle
00226 @example_myparticle
00227 }
00228
00229
00230 DEFINE_FWK_MODULE(prodname);