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 {
20  genparticleCollectionToken_=consumes<reco::GenParticleCollection>(genparticleCollection_);
21  Particles = iPSet.getParameter<std::vector<int> >("pdgids");
22 }
23 
25 
27 
29  DQMHelper dqm(&i); 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 }
46 
T getParameter(std::string const &) const
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:460
MonitorElement * Nobj
MonitorElement * mass
virtual void dqmBeginRun(const edm::Run &r, const edm::EventSetup &c) override
virtual ~BPhysicsSpectrum()
MonitorElement * book1dHisto(std::string name, std::string title, int n, double xmin, double xmax, std::string xaxis, std::string yaxis)
Definition: DQMHelper.cc:12
virtual void bookHistograms(DQMStore::IBooker &i, edm::Run const &, edm::EventSetup const &) override
void Fill(long long x)
int iEvent
Definition: GenABIO.cc:230
edm::EDGetTokenT< reco::GenParticleCollection > genparticleCollectionToken_
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
BPhysicsSpectrum(const edm::ParameterSet &)
edm::InputTag genparticleCollection_
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:277
HLT enums.
std::vector< int > Particles
virtual void analyze(edm::Event const &, edm::EventSetup const &) override
Definition: Run.h:42