CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
HiggsValidation.h
Go to the documentation of this file.
1 #ifndef HiggsValidation_H
2 #define HiggsValidation_H
3 
4 /*class HiggsValidation
5  *
6  * Class to fill Event Generator dqm monitor elements; works on HepMCProduct
7  *
8  *
9  */
10 #include <iostream>
11 
12 // framework & common header files
13 
17 
22 
23 //DQM services
27 
29 //#include "DataFormats/HepMCCandidate/interface/GenParticle.h"
30 
32 #include "TLorentzVector.h"
33 
35 
37 public:
38  explicit HiggsValidation(const edm::ParameterSet &);
39  ~HiggsValidation() override;
40 
41  void bookHistograms(DQMStore::IBooker &i, edm::Run const &, edm::EventSetup const &) override;
42  void dqmBeginRun(const edm::Run &r, const edm::EventSetup &c) override;
43  void analyze(edm::Event const &, edm::EventSetup const &) override;
44 
45 private:
47 
49  public:
51  fillMap();
52  std::vector<std::string> input = iConfig.getParameter<std::vector<std::string> >("monitorDecays");
53  for (std::vector<std::string>::const_iterator i = input.begin(); i != input.end(); ++i) {
54  fill(*i);
55  }
56  }
57 
59 
60  size_t position(int pid1, int pid2) {
61  if (abs(pid1) == 14 || abs(pid1) == 16)
62  pid1 = 12;
63  if (abs(pid2) == 14 || abs(pid2) == 16)
64  pid2 = 12;
65  for (size_t i = 0; i < channels.size(); ++i) {
66  if ((channels[i].first == abs(pid1) && channels[i].second == abs(pid2)) ||
67  (channels[i].first == abs(pid2) && channels[i].second == abs(pid1)))
68  return i + 1;
69  }
70  return undetermined(); //channels.size()+1;
71  }
72 
73  size_t size() { return channels.size() + 2; }
74  size_t undetermined() { return 0; }
75  size_t stable() { return size(); }
76  std::string channel(size_t i) {
77  if (i == 0)
78  return "?";
79  if (i == channels.size() + 1)
80  return "Stable";
81  return convert(channels[i - 1].first) + convert(channels[i - 1].second);
82  }
83 
85  if (namePidMap.count(s)) {
86  return namePidMap[s];
87  }
88  return 0;
89  }
90 
91  std::string convert(int pid) {
92  pid = abs(pid);
93  if (pid == 14 || pid == 16)
94  pid = 12;
95  for (std::map<std::string, int>::const_iterator i = namePidMap.begin(); i != namePidMap.end(); ++i) {
96  if (i->second == pid)
97  return i->first;
98  }
99  return "not found";
100  }
101 
102  unsigned int NDecayParticles() { return nparticles_; }
103 
104  int isDecayParticle(int pid) {
105  int idx = 0;
106  for (std::map<std::string, int>::const_iterator i = namePidMap.begin(); i != namePidMap.end(); ++i) {
107  if (i->second == pid)
108  return idx;
109  idx++;
110  }
111  return -1;
112  }
113 
115  int idx = 0;
116  for (std::map<std::string, int>::const_iterator i = namePidMap.begin(); i != namePidMap.end(); ++i) {
117  if (idx == index)
118  return i->first;
119  idx++;
120  }
121  return "unknown";
122  }
123 
124  private:
126  size_t pos = s.find('+');
127  std::string particle1 = s.substr(0, pos);
128  std::string particle2 = s.substr(pos + 1, s.length() - pos);
129  std::pair<int, int> decay;
130  decay.first = convert(particle1);
131  decay.second = convert(particle2);
132  channels.push_back(decay);
133  }
134 
135  void fillMap() {
136  namePidMap["d"] = 1;
137  namePidMap["u"] = 2;
138  namePidMap["s"] = 3;
139  namePidMap["c"] = 4;
140  namePidMap["b"] = 5;
141  namePidMap["t"] = 6;
142  namePidMap["e"] = 11;
143  namePidMap["nu"] = 12;
144  namePidMap["mu"] = 13;
145  namePidMap["tau"] = 15;
146  namePidMap["gamma"] = 22;
147  namePidMap["Z"] = 23;
148  namePidMap["W"] = 24;
149  nparticles_ = 0;
150  for (std::map<std::string, int>::const_iterator i = namePidMap.begin(); i != namePidMap.end(); ++i) {
151  nparticles_++;
152  }
153  }
154 
155  std::map<std::string, int> namePidMap;
156 
157  std::vector<std::pair<int, int> > channels;
158  unsigned int nparticles_;
159  };
160 
161  int findHiggsDecayChannel(const HepMC::GenParticle *, std::vector<HepMC::GenParticle *> &decayprod);
162  std::string convert(int);
163 
165 
168 
170 
174 
177 
181 
182  std::vector<MonitorElement *> HiggsDecayProd_pt;
183  std::vector<MonitorElement *> HiggsDecayProd_eta;
184 
186 };
187 
188 #endif
edm::ESHandle< HepPDT::ParticleDataTable > fPDGTable
PDT table.
std::vector< MonitorElement * > HiggsDecayProd_pt
const edm::EventSetup & c
MonitorElement * Higgs_eta
void dqmBeginRun(const edm::Run &r, const edm::EventSetup &c) override
std::vector< std::pair< int, int > > channels
std::vector< MonitorElement * > HiggsDecayProd_eta
MonitorElement * nEvt
size_t position(int pid1, int pid2)
MonitoredDecays * monitoredDecays
static std::string const input
Definition: EdmProvDump.cc:47
HiggsValidation(const edm::ParameterSet &)
U second(std::pair< T, U > const &p)
MonitoredDecays(const edm::ParameterSet &iConfig)
int findHiggsDecayChannel(const HepMC::GenParticle *, std::vector< HepMC::GenParticle * > &decayprod)
void bookHistograms(DQMStore::IBooker &i, edm::Run const &, edm::EventSetup const &) override
edm::EDGetTokenT< edm::HepMCProduct > hepmcCollectionToken_
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
MonitorElement * Higgs_pt
MonitorElement * HiggsDecayChannels
std::string convert(int)
edm::ESGetToken< HepPDT::ParticleDataTable, edm::DefaultRecord > fPDGTableToken
void analyze(edm::Event const &, edm::EventSetup const &) override
edm::InputTag hepmcCollection_
~HiggsValidation() override
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
std::string ConvertIndex(int index)
WeightManager wmanager_
std::string channel(size_t i)
std::string particle_name
Definition: Run.h:45
std::map< std::string, int > namePidMap
MonitorElement * Higgs_mass