Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:32:10

0001 ///////////////////////////////////////
0002 //
0003 // class Validation: Class to fill dqm monitor elements from existing EDM file
0004 //
0005 ///////////////////////////////////////
0006 
0007 #include "Validation/EventGenerator/interface/BPhysicsSpectrum.h"
0008 
0009 #include "FWCore/Framework/interface/MakerMacros.h"
0010 
0011 using namespace edm;
0012 
0013 BPhysicsSpectrum::BPhysicsSpectrum(const edm::ParameterSet& iPSet)
0014     : genparticleCollection_(iPSet.getParameter<edm::InputTag>("genparticleCollection")),
0015       // do not include weights right now to allow for running on aod
0016       name(iPSet.getParameter<std::string>("name")),
0017       mass_min(iPSet.getParameter<double>("massmin")),
0018       mass_max(iPSet.getParameter<double>("massmax")) {
0019   genparticleCollectionToken_ = consumes<reco::GenParticleCollection>(genparticleCollection_);
0020   Particles = iPSet.getParameter<std::vector<int> >("pdgids");
0021 }
0022 
0023 BPhysicsSpectrum::~BPhysicsSpectrum() {}
0024 
0025 void BPhysicsSpectrum::bookHistograms(DQMStore::IBooker& i, edm::Run const&, edm::EventSetup const&) {
0026   DQMHelper dqm(&i);
0027   i.setCurrentFolder("Generator/BPhysics");
0028   Nobj = dqm.book1dHisto("NSpectrum" + name, "NSpectrum" + name, 1, 0., 1, "bin", "Number of " + name);
0029   mass = dqm.book1dHisto(name + "Mass", "Mass Spectrum", 100, mass_min, mass_max, "Mass (GeV)", "Number of Events");
0030 }
0031 
0032 void BPhysicsSpectrum::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) {
0033   edm::Handle<reco::GenParticleCollection> genParticles;
0034   iEvent.getByToken(genparticleCollectionToken_, genParticles);
0035   for (reco::GenParticleCollection::const_iterator iter = genParticles->begin(); iter != genParticles->end(); ++iter) {
0036     for (unsigned int i = 0; i < Particles.size(); i++) {
0037       if (abs(iter->pdgId()) == abs(Particles[i])) {
0038         Nobj->Fill(0.5, 1.0);
0039         mass->Fill(iter->mass(), 1.0);
0040       }
0041     }
0042   }
0043 }