#include "Tutorial/Exercise/interface/ParentProducer.h" ParentProducer::ParentProducer(const edm::ParameterSet& cfg) { // need to tell it what it produces // otherwise I get an "Illegal attempt to 'put' an unregistered product." // error produces >(); } ParentProducer::~ParentProducer() {} void ParentProducer::produce(edm::Event& event, const edm::EventSetup& setup) { std::cout << "!!!!!!!!!!!!!!!!!!!!!!!" << std::endl; // results go here std::auto_ptr > parentCollection(new std::vector); // get muons edm::Handle muon_handle; event.getByLabel("muons",muon_handle); // the filter has run before hand, so I have at least two muons // why does every experiment have a different way of access what is basically a bunch of fourvectors on speed ?! const float min_pt = 5.0; const float max_eta = 5.0; if ( muon_handle->size() < 2) {std::cout << "HELP: Wrong number of muons !!" << std::endl;} for (unsigned int i = 0; i < muon_handle->size(); ++i) { for (unsigned int ii = i+1; ii < muon_handle->size(); ++ii) { // sigh reco::MuonRef muon_1(muon_handle, i); reco::MuonRef muon_2(muon_handle, ii); if (muon_1->charge() * muon_2->charge() < 0) { // get ahead of myself and put in pt and eta cuts if (muon_1->pt() > min_pt && std::abs(muon_1->eta()) < max_eta) { if (muon_2->pt() > min_pt && std::abs(muon_2->eta()) < max_eta) { // LeafCandidate( Charge q, const LorentzVector & p4, const Point & vtx = Point( 0, 0, 0 ), [etc] std::cout << "Found parent candidate" << std::endl; parentCollection->push_back(reco::LeafCandidate(0, muon_1->p4()+muon_2->p4())); } // muon_2 } // muon_1 } // charge } // for ii } // for i std::cout << parentCollection->size() << std::endl; event.put(parentCollection); } DEFINE_FWK_MODULE(ParentProducer);