File indexing completed on 2023-03-17 11:27:16
0001 #ifndef BPhysicsValidation_H
0002 #define BPhysicsValidation_H
0003
0004
0005
0006
0007
0008
0009
0010 #include <iostream>
0011 #include "TMath.h"
0012
0013
0014 #include "FWCore/Framework/interface/Event.h"
0015 #include "FWCore/Framework/interface/EventSetup.h"
0016 #include "FWCore/Framework/interface/Run.h"
0017
0018 #include "DataFormats/Common/interface/Handle.h"
0019 #include "FWCore/Framework/interface/ESHandle.h"
0020 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0021 #include "FWCore/Utilities/interface/InputTag.h"
0022
0023
0024 #include "DQMServices/Core/interface/DQMStore.h"
0025 #include "FWCore/ServiceRegistry/interface/Service.h"
0026 #include "DQMServices/Core/interface/DQMEDAnalyzer.h"
0027
0028 #include "DataFormats/HepMCCandidate/interface/GenParticle.h"
0029 #include "DataFormats/HepMCCandidate/interface/GenParticle.h"
0030 #include "DataFormats/HepMCCandidate/interface/GenParticleFwd.h"
0031
0032 #include "Validation/EventGenerator/interface/DQMHelper.h"
0033
0034 class BPhysicsValidation : public DQMEDAnalyzer {
0035 public:
0036 explicit BPhysicsValidation(const edm::ParameterSet &);
0037 ~BPhysicsValidation() override;
0038
0039 void bookHistograms(DQMStore::IBooker &i, edm::Run const &, edm::EventSetup const &) override;
0040 void analyze(edm::Event const &, edm::EventSetup const &) override;
0041
0042 private:
0043 class ParticleMonitor {
0044 public:
0045 ParticleMonitor(std::string name_, const edm::ParameterSet &p_)
0046 : p(p_), name(name_), pdgid(p.getParameter<int>("pdgid")){};
0047 ~ParticleMonitor(){};
0048
0049 void Configure(DQMStore::IBooker &i) {
0050 std::string pname = p.getParameter<std::string>("pname");
0051 double mass_min = p.getParameter<double>("massmin");
0052 double mass_max = p.getParameter<double>("massmax");
0053 DQMHelper dqm(&i);
0054 i.setCurrentFolder("Generator/BPhysics");
0055
0056 pt = dqm.book1dHisto(name + "PT", "P_{t} of the " + pname + "s", 100, 0., 100, "P_{t} (GeV)", "Number of Events");
0057 eta = dqm.book1dHisto(name + "ETA", "#eta of the " + pname + "s", 100, -5., 5., "#eta", "Number of Events");
0058 phi = dqm.book1dHisto(
0059 name + "PHI", "#phi of the " + pname + "s", 100, 0, 2 * TMath::Pi(), "#phi", "Number of Events");
0060 mass = dqm.book1dHisto(
0061 name + "MASS", "Mass of the " + pname + "s", 100, mass_min, mass_max, "Mass (GeV)", "Number of Events");
0062 }
0063
0064 void Fill(const reco::GenParticle *p, double weight) {
0065 if (abs(p->pdgId()) == abs(pdgid)) {
0066 pt->Fill(p->pt(), weight);
0067 eta->Fill(p->eta(), weight);
0068 phi->Fill(p->phi(), weight);
0069 mass->Fill(p->mass(), weight);
0070 }
0071 }
0072 int PDGID() { return pdgid; }
0073
0074 private:
0075 const edm::ParameterSet p;
0076 std::string name;
0077 int pdgid;
0078 MonitorElement *pt, *eta, *phi, *mass;
0079 };
0080
0081 void FillDaughters(const reco::GenParticle *p);
0082 edm::InputTag genparticleCollection_;
0083 edm::EDGetTokenT<reco::GenParticleCollection> genparticleCollectionToken_;
0084 std::string name;
0085 ParticleMonitor particle;
0086 std::vector<ParticleMonitor> daughters;
0087 MonitorElement *Nobj;
0088 };
0089
0090 #endif