CMS 3D CMS Logo

BPhysicsSpectrum.cc
Go to the documentation of this file.
1 //
3 // class Validation: Class to fill dqm monitor elements from existing EDM file
4 //
6 
8 
10 
11 using namespace edm;
12 
14  : genparticleCollection_(iPSet.getParameter<edm::InputTag>("genparticleCollection")),
15  // do not include weights right now to allow for running on aod
16  name(iPSet.getParameter<std::string>("name")),
17  mass_min(iPSet.getParameter<double>("massmin")),
18  mass_max(iPSet.getParameter<double>("massmax")) {
19  genparticleCollectionToken_ = consumes<reco::GenParticleCollection>(genparticleCollection_);
20  Particles = iPSet.getParameter<std::vector<int> >("pdgids");
21 }
22 
24 
26 
28  DQMHelper dqm(&i);
29  i.setCurrentFolder("Generator/BPhysics");
30  Nobj = dqm.book1dHisto("NSpectrum" + name, "NSpectrum" + name, 1, 0., 1, "bin", "Number of " + name);
31  mass = dqm.book1dHisto(name + "Mass", "Mass Spectrum", 100, mass_min, mass_max, "Mass (GeV)", "Number of Events");
32 }
33 
36  iEvent.getByToken(genparticleCollectionToken_, genParticles);
37  for (reco::GenParticleCollection::const_iterator iter = genParticles->begin(); iter != genParticles->end(); ++iter) {
38  for (unsigned int i = 0; i < Particles.size(); i++) {
39  if (abs(iter->pdgId()) == abs(Particles[i])) {
40  Nobj->Fill(0.5, 1.0);
41  mass->Fill(iter->mass(), 1.0);
42  }
43  }
44  }
45 }
T getParameter(std::string const &) const
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:525
void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:418
MonitorElement * Nobj
MonitorElement * mass
void dqmBeginRun(const edm::Run &r, const edm::EventSetup &c) override
void bookHistograms(DQMStore::IBooker &i, edm::Run const &, edm::EventSetup const &) override
void Fill(long long x)
int iEvent
Definition: GenABIO.cc:224
MonitorElement * book1dHisto(std::string name, std::string title, int n, double xmin, double xmax, std::string xaxis, std::string yaxis)
Definition: DQMHelper.cc:7
edm::EDGetTokenT< reco::GenParticleCollection > genparticleCollectionToken_
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
BPhysicsSpectrum(const edm::ParameterSet &)
edm::InputTag genparticleCollection_
~BPhysicsSpectrum() override
HLT enums.
std::vector< int > Particles
void analyze(edm::Event const &, edm::EventSetup const &) override
Definition: Run.h:45