00001 #include "__subsys__/__plgname__/plugins/__class__Producer.h" 00002 00003 #include <iostream> 00004 00005 using namespace pat; 00006 using namespace std; 00007 00008 __class__Producer::__class__Producer(const edm::ParameterSet & iConfig) : 00009 public edm::EDProducer(iConfig) 00010 { 00011 00012 // Here we get the list of common includes 00013 muonSrc_ = iConfig.getParameter<edm::InputTag>( "muonSource" ); 00014 electronSrc_ = iConfig.getParameter<edm::InputTag>( "electronSource" ); 00015 tauSrc_ = iConfig.getParameter<edm::InputTag>( "tauSource" ); 00016 photonSrc_ = iConfig.getParameter<edm::InputTag>( "photonSource" ); 00017 jetSrc_ = iConfig.getParameter<edm::InputTag>( "jetSource" ); 00018 metSrc_ = iConfig.getParameter<edm::InputTag>( "metSource" ); 00019 00020 // Here we get the output tag name 00021 outputName_ = iConfig.getParameter<edm::OutputTag>("outputName"); 00022 00023 // This declares the output to the event stream 00024 string alias; 00025 produces<std::vector<__class__> >(alias = outputName_).setBranchAddress(alias); 00026 } 00027 00028 __class__Producer::~__class__Producer() 00029 { 00030 } 00031 00032 __class__Producer::produce(edm::Event & iEvent, const edm::EventSetup & iSetup ) 00033 { 00034 00035 // Here is the vector where you should put your hypotheses 00036 std::vector<__class__ hyps; 00037 00038 00039 // ------------------------------------------------------------------------ 00040 // Here is where you get the objects you need. The perl script will 00041 // uncomment any that you need by reading the event hypothesis text file 00042 // ------------------------------------------------------------------------ 00043 00044 edm::Handle<std::vector<pat::Muon> > muons; 00045 iEvent.getByLabel(muonSrc_, muons); 00046 00047 edm::Handle<std::vector<pat::Electron> > electrons; 00048 iEvent.getByLabel(electronSrc_, electrons); 00049 00050 edm::Handle<std::vector<pat::Tau> > taus; 00051 iEvent.getByLabel(tauSrc_, taus); 00052 00053 edm::Handle<std::vector<pat::Photon> > photons; 00054 iEvent.getByLabel(photonSrc_, photons); 00055 00056 edm::Handle<std::vector<pat::Jet> > jets; 00057 iEvent.getByLabel(jetSrc_, jets); 00058 00059 edm::Handle<std::vector<pat::Met> > mets; 00060 iEvent.getByLabel(metSrc_, mets); 00061 00062 00063 // ------------------------------------------------------------------------ 00064 // ****** Here is where you put your event hypothesis code ****** 00065 // ------------------------------------------------------------------------ 00066 // A: Define a combinatorics loop. 00067 // Replace for ( ...;...;...) with your appropriate loop over objects, such as 00068 // for ( vector<Muon>::iterator imuon = muons->begin(); imuon != muons->end(); imuon++ ) 00069 // for ( vector<Muon>::iterator jmuon = imuon + 1; jmuon != muons->end(); jmuon++ ) 00070 // 00071 for ( ...; ...; ... ) { 00072 __class__ hyp; 00073 00074 // B: Fill "hyp" with your hypothesis information and push it back to the 00075 // vector containing them. 00076 // For instance, 00077 // hyp.muon1() = *imuon; 00078 // hyp.muon2() = *jmuon; 00079 // hyp.jets() = *jets; 00080 00081 hyps.push_back( hyp ); 00082 } 00083 00084 00085 // Here is where we write the hypotheses to the event stream 00086 std::auto_ptr<std::vector<__class__> > ap_hyps( hyps ); 00087 iEvent.put( ap_hyps, outputName_); 00088 00089 }