#include YanjunAnalyzer::YanjunAnalyzer(const edm::ParameterSet& iConfig) { //now do what ever initialization is needed nEvents = 0; nFourM = 0; } YanjunAnalyzer::~YanjunAnalyzer() { // do anything here that needs to be done at desctruction time // (e.g. close files, deallocate resources etc.) } // // member functions // // ------------ method called to for each event ------------ void YanjunAnalyzer::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) { using namespace edm; nEvents++; // using reco::TrackCollection; bool keepEvent = false; int nMuon = 0; bool isFourM = false; // get gen particle candidates edm::Handle genCandidates; iEvent.getByLabel("genParticles", genCandidates); float eta = 0.; for ( GenParticleCollection::const_iterator mcIter=genCandidates->begin(); mcIter!=genCandidates->end(); ++mcIter ) { // Muons: if ( mcIter->pdgId() == 13 || mcIter->pdgId() == -13) { // Mother is a Z if ( mcIter->mother()->pdgId() == 23 ) { // In fiducial volume: if ( mcIter->eta() > -2.4 && mcIter->eta() < 2.4 ) nMuon++; } } } if (nMuon > 3) { isFourM = true; nFourM++; } // #ifdef THIS_IS_AN_EVENT_EXAMPLE // Handle pIn; // iEvent.getByLabel("example",pIn); // #endif // #ifdef THIS_IS_AN_EVENTSETUP_EXAMPLE // ESHandle pSetup; // iSetup.get().get(pSetup); // #endif } // ------------ method called once each job just before starting event loop ------------ void YanjunAnalyzer::beginJob(const edm::EventSetup&) { } // ------------ method called once each job just after ending the event loop ------------ void YanjunAnalyzer::endJob() { std::cout << "Number of events read " << nEvents << std::endl; std::cout << "Four muons: " << " = " << nFourM << std::endl; } //define this as a plug-in DEFINE_FWK_MODULE(YanjunAnalyzer);