CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros 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  * $Date: 2012/08/12 16:13:28 $
9  * $Revision: 1.1 $
10  *
11  */
12 #include <iostream>
13 
14 // framework & common header files
19 
24 
25 //DQM services
29 
31 //#include "DataFormats/HepMCCandidate/interface/GenParticle.h"
32 
34 #include "TLorentzVector.h"
35 
37 
39  public:
40  explicit HiggsValidation(const edm::ParameterSet&);
41  virtual ~HiggsValidation();
42  virtual void beginJob();
43  virtual void endJob();
44  virtual void analyze(const edm::Event&, const edm::EventSetup&);
45  virtual void beginRun(const edm::Run&, const edm::EventSetup&);
46  virtual void endRun(const edm::Run&, const edm::EventSetup&);
47 
48  private:
49 
50 
52  public:
53 
55  fillMap();
56  std::vector<std::string> input = iConfig.getParameter<std::vector<std::string> >("monitorDecays");
57  for(std::vector<std::string>::const_iterator i = input.begin(); i!= input.end(); ++i){
58  fill(*i);
59  }
60  }
61 
63 
64  size_t position(int pid1,int pid2){
65  if(abs(pid1) == 14 || abs(pid1) == 16) pid1 = 12;
66  if(abs(pid2) == 14 || abs(pid2) == 16) pid2 = 12;
67  for(size_t i = 0; i < channels.size(); ++i){
68  if((channels[i].first == abs(pid1) && channels[i].second == abs(pid2)) ||
69  (channels[i].first == abs(pid2) && channels[i].second == abs(pid1))) return i+1;
70  }
71  return channels.size()+1;
72  }
73 
74  size_t size(){return channels.size() + 2;}
75  size_t undetermined(){return 0;}
76  size_t stable(){return size();}
77  std::string channel(size_t i){
78  if(i == 0) return "?";
79  if(i == channels.size()+1) return "Stable";
80  return convert(channels[i-1].first)+convert(channels[i-1].second);
81  }
82 
83  int convert(std::string s){
84  if( namePidMap.count(s)){
85  return namePidMap[s];
86  }
87  return 0;
88  }
89 
90  std::string convert(int pid){
91  pid = abs(pid);
92  if(pid == 14 || pid == 16) pid = 12;
93  for(std::map<std::string,int>::const_iterator i = namePidMap.begin(); i!= namePidMap.end(); ++i) {
94  if(i->second == pid) return i->first;
95  }
96  return "not found";
97  }
98 
99  unsigned int NDecayParticles(){return nparticles_;}
100 
102  int idx=0;
103  for(std::map<std::string,int>::const_iterator i = namePidMap.begin(); i!= namePidMap.end(); ++i) {
104  if(i->second == pid) return idx;
105  idx++;
106  }
107  return -1;
108  }
109 
110  std::string ConvertIndex(int index){
111  int idx=0;
112  for(std::map<std::string,int>::const_iterator i = namePidMap.begin(); i!= namePidMap.end(); ++i) {
113  if(idx==index) return i->first;
114  idx++;
115  }
116  return "unknown";
117  }
118 
119  private:
120  void fill(std::string s){
121  size_t pos = s.find("+");
122  std::string particle1 = s.substr(0,pos);
123  std::string particle2 = s.substr(pos+1,s.length()-pos);
124  std::pair<int,int> decay;
125  decay.first = convert(particle1);
126  decay.second = convert(particle2);
127  channels.push_back(decay);
128  }
129 
130  void fillMap(){
131  namePidMap["d"] = 1;
132  namePidMap["u"] = 2;
133  namePidMap["s"] = 3;
134  namePidMap["c"] = 4;
135  namePidMap["b"] = 5;
136  namePidMap["t"] = 6;
137  namePidMap["e"] = 11;
138  namePidMap["nu"] = 12;
139  namePidMap["mu"] = 13;
140  namePidMap["tau"] = 15;
141  namePidMap["gamma"] = 22;
142  namePidMap["Z"] = 23;
143  namePidMap["W"] = 24;
144  nparticles_=0;
145  for(std::map<std::string,int>::const_iterator i = namePidMap.begin(); i!= namePidMap.end(); ++i){
146  nparticles_++;
147  }
148  }
149 
150  std::map<std::string,int> namePidMap;
151 
152  std::vector<std::pair<int,int> > channels;
153  unsigned int nparticles_;
154 
155  };
156 
157  int findHiggsDecayChannel(const HepMC::GenParticle*,std::vector<HepMC::GenParticle*> &decayprod);
158  std::string convert(int);
159 
161 
163 
165  std::string particle_name;
166 
168 
171 
174 
177 
181 
182  std::vector<MonitorElement*> HiggsDecayProd_pt;
183  std::vector<MonitorElement*> HiggsDecayProd_eta;
184 
185 };
186 
187 #endif
edm::ESHandle< HepPDT::ParticleDataTable > fPDGTable
PDT table.
T getParameter(std::string const &) const
virtual void analyze(const edm::Event &, const edm::EventSetup &)
int i
Definition: DBlmapReader.cc:9
MonitorElement * Higgs_eta
virtual void endRun(const edm::Run &, const edm::EventSetup &)
WeightManager _wmanager
virtual void beginRun(const edm::Run &, const edm::EventSetup &)
#define abs(x)
Definition: mlp_lapack.h:159
MonitorElement * nEvt
std::vector< MonitorElement * > HiggsDecayProd_pt
size_t position(int pid1, int pid2)
MonitoredDecays * monitoredDecays
virtual ~HiggsValidation()
HiggsValidation(const edm::ParameterSet &)
U second(std::pair< T, U > const &p)
std::vector< std::pair< int, int > > channels
MonitoredDecays(const edm::ParameterSet &iConfig)
int findHiggsDecayChannel(const HepMC::GenParticle *, std::vector< HepMC::GenParticle * > &decayprod)
std::vector< MonitorElement * > HiggsDecayProd_eta
std::map< std::string, int > namePidMap
MonitorElement * Higgs_pt
bool first
Definition: L1TdeRCT.cc:79
MonitorElement * HiggsDecayChannels
std::string convert(int)
tuple input
Definition: collect_tpl.py:10
edm::InputTag hepmcCollection_
DQMStore * dbe
ME&#39;s &quot;container&quot;.
virtual void beginJob()
std::string ConvertIndex(int index)
std::string channel(size_t i)
virtual void endJob()
string s
Definition: asciidump.py:422
std::string particle_name
Definition: Run.h:31
MonitorElement * Higgs_mass