CMS 3D CMS Logo

HiggsValidation.cc
Go to the documentation of this file.
1 /*class HiggsValidation
2  *
3  * Class to fill dqm monitor elements from existing EDM file
4  *
5  */
6 
8 
10 
11 #include "CLHEP/Units/defs.h"
12 #include "CLHEP/Units/PhysicalConstants.h"
13 
15 
19 using namespace edm;
20 
22  : wmanager_(iPSet, consumesCollector()),
23  hepmcCollection_(iPSet.getParameter<edm::InputTag>("hepmcCollection")),
24  particle_id(iPSet.getParameter<int>("pdg_id")),
25  particle_name(iPSet.getParameter<std::string>("particleName")) {
26  monitoredDecays = new MonitoredDecays(iPSet);
27  hepmcCollectionToken_ = consumes<HepMCProduct>(hepmcCollection_);
28 }
29 
31 
33 
36  std::string dir = "Generator/";
37  dir += particle_name;
38  DQMHelper dqm(&i);
39  i.setCurrentFolder(dir);
40 
41  // Number of analyzed events
42  nEvt = dqm.book1dHisto("nEvt", "n analyzed Events", 1, 0., 1., "bin", "Number of Events");
43 
44  //decay type
45 
46  std::string channel = particle_name + "_DecayChannels";
47  HiggsDecayChannels = dqm.book1dHisto(channel,
48  particle_name + " decay channels",
50  0,
52  "Decay Channels",
53  "Number of Events");
54 
55  for (size_t j = 0; j < monitoredDecays->size(); ++j) {
57  }
58 
59  //Kinematics
60  Higgs_pt = dqm.book1dHisto((particle_name + "_pt"),
61  (particle_name + " p_{t}"),
62  50,
63  0,
64  250,
65  "P_{t}^{" + particle_name + "} (GeV)",
66  "Number of Events");
67  Higgs_eta = dqm.book1dHisto((particle_name + "_eta"),
68  (particle_name + " #eta"),
69  50,
70  -5,
71  5,
72  "#eta^{" + particle_name + "}",
73  "Number of Events");
74  Higgs_mass = dqm.book1dHisto(
75  (particle_name + "_m"), (particle_name + " M"), 500, 0, 500, "M^{" + particle_name + "}", "Number of Events");
76 
77  int idx = 0;
78  for (unsigned int j = 0; j < monitoredDecays->NDecayParticles(); j++) {
79  HiggsDecayProd_pt.push_back(dqm.book1dHisto((monitoredDecays->ConvertIndex(idx) + "_pt"),
80  (monitoredDecays->ConvertIndex(idx) + " p_{t}"),
81  50,
82  0,
83  250,
84  "P_{t}^{" + monitoredDecays->ConvertIndex(idx) + "} (GeV)",
85  "Number of Events"));
86  HiggsDecayProd_eta.push_back(dqm.book1dHisto((monitoredDecays->ConvertIndex(idx) + "_eta"),
87  (monitoredDecays->ConvertIndex(idx) + " #eta"),
88  50,
89  -5,
90  5,
91  "#eta^{" + monitoredDecays->ConvertIndex(idx) + "}",
92  "Number of Events"));
93  idx++;
94  }
95 
96  return;
97 }
98 
100  double weight = wmanager_.weight(iEvent);
101  nEvt->Fill(0.5, weight);
102 
103  //Gathering the HepMCProduct information
105  iEvent.getByToken(hepmcCollectionToken_, evt);
106 
107  //Get EVENT
108  HepMC::GenEvent* myGenEvent = new HepMC::GenEvent(*(evt->GetEvent()));
109 
110  // loop over all particles
111  bool filled = false;
112  for (HepMC::GenEvent::particle_const_iterator iter = myGenEvent->particles_begin();
113  iter != myGenEvent->particles_end() && !filled;
114  ++iter) {
115  if (particle_id == std::abs((*iter)->pdg_id())) {
116  std::vector<HepMC::GenParticle*> decayprod;
117  int channel = findHiggsDecayChannel(*iter, decayprod);
118  HiggsDecayChannels->Fill(channel, weight);
119  Higgs_pt->Fill((*iter)->momentum().perp(), weight);
120  Higgs_eta->Fill((*iter)->momentum().eta(), weight);
121  Higgs_mass->Fill((*iter)->momentum().m(), weight);
122  for (unsigned int i = 0; i < decayprod.size(); i++) {
123  int idx = monitoredDecays->isDecayParticle(decayprod.at(i)->pdg_id());
124  if (0 <= idx && idx <= (int)HiggsDecayProd_pt.size()) {
125  HiggsDecayProd_pt.at(idx)->Fill(decayprod.at(i)->momentum().perp(), weight);
126  HiggsDecayProd_eta.at(idx)->Fill(decayprod.at(i)->momentum().eta(), weight);
127  }
128  }
129  filled = true;
130  }
131  }
132 
133  delete myGenEvent;
134 
135 } //analyze
136 
138  std::vector<HepMC::GenParticle*>& decayprod) {
139  if (genParticle->status() == 1)
140  return monitoredDecays->stable();
141  std::vector<int> children;
142  if (genParticle->end_vertex()) {
143  HepMC::GenVertex::particle_iterator des;
144  for (des = genParticle->end_vertex()->particles_begin(HepMC::descendants);
145  des != genParticle->end_vertex()->particles_end(HepMC::descendants);
146  ++des) {
147  if ((*des)->pdg_id() == genParticle->pdg_id())
148  continue;
149 
150  HepMC::GenVertex::particle_iterator mother = (*des)->production_vertex()->particles_begin(HepMC::parents);
151  if ((*mother)->pdg_id() == genParticle->pdg_id()) {
152  children.push_back((*des)->pdg_id());
153  decayprod.push_back((*des));
154  }
155  }
156  }
157 
158  if (children.size() == 2 && children.at(0) != 0 && children.at(1) != 0) {
159  return monitoredDecays->position(children.at(0), children.at(1));
160  }
161  return monitoredDecays->undetermined();
162 }
PdtPdgMini.h
mps_fire.i
i
Definition: mps_fire.py:355
HiggsValidation::findHiggsDecayChannel
int findHiggsDecayChannel(const HepMC::GenParticle *, std::vector< HepMC::GenParticle * > &decayprod)
Definition: HiggsValidation.cc:137
HiggsValidation::bookHistograms
void bookHistograms(DQMStore::IBooker &i, edm::Run const &, edm::EventSetup const &) override
Definition: HiggsValidation.cc:34
HiggsValidation::monitoredDecays
MonitoredDecays * monitoredDecays
Definition: HiggsValidation.h:169
edm::Run
Definition: Run.h:45
HiggsValidation::MonitoredDecays::ConvertIndex
std::string ConvertIndex(int index)
Definition: HiggsValidation.h:114
edm
HLT enums.
Definition: AlignableModifier.h:19
class-composition.children
children
Definition: class-composition.py:88
mps_merge.weight
weight
Definition: mps_merge.py:88
HiggsValidation::hepmcCollectionToken_
edm::EDGetTokenT< edm::HepMCProduct > hepmcCollectionToken_
Definition: HiggsValidation.h:184
HiggsValidation::MonitoredDecays::isDecayParticle
int isDecayParticle(int pid)
Definition: HiggsValidation.h:104
HiggsValidation::MonitoredDecays::stable
size_t stable()
Definition: HiggsValidation.h:75
edm::Handle
Definition: AssociativeIterator.h:50
training_settings.idx
idx
Definition: training_settings.py:16
HiggsValidation::HiggsValidation
HiggsValidation(const edm::ParameterSet &)
Definition: HiggsValidation.cc:21
HepMC::GenEvent
Definition: hepmc_rootio.cc:9
HiggsValidation::wmanager_
WeightManager wmanager_
Definition: HiggsValidation.h:46
GenParticle.h
HiggsValidation::analyze
void analyze(edm::Event const &, edm::EventSetup const &) override
Definition: HiggsValidation.cc:99
DQMHelper.h
MakerMacros.h
HiggsValidation::HiggsDecayProd_eta
std::vector< MonitorElement * > HiggsDecayProd_eta
Definition: HiggsValidation.h:182
dqm::impl::MonitorElement::Fill
void Fill(long long x)
Definition: MonitorElement.h:290
HiggsValidation::MonitoredDecays::undetermined
size_t undetermined()
Definition: HiggsValidation.h:74
HiggsValidation::MonitoredDecays::size
size_t size()
Definition: HiggsValidation.h:73
HiggsValidation.h
HiggsValidation::fPDGTable
edm::ESHandle< HepPDT::ParticleDataTable > fPDGTable
PDT table.
Definition: HiggsValidation.h:172
HiggsValidation::~HiggsValidation
~HiggsValidation() override
Definition: HiggsValidation.cc:30
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::ParameterSet
Definition: ParameterSet.h:36
HiggsValidation::MonitoredDecays::channel
std::string channel(size_t i)
Definition: HiggsValidation.h:76
HiggsValidation::MonitoredDecays
Definition: HiggsValidation.h:48
HiggsValidation::Higgs_pt
MonitorElement * Higgs_pt
Definition: HiggsValidation.h:177
LorentzVector.h
createfilelist.int
int
Definition: createfilelist.py:10
iEvent
int iEvent
Definition: GenABIO.cc:224
dqm::impl::MonitorElement::setBinLabel
virtual void setBinLabel(int bin, const std::string &label, int axis=1)
set bin label for x, y or z axis (axis=1, 2, 3 respectively)
Definition: MonitorElement.cc:771
edm::EventSetup
Definition: EventSetup.h:57
edm::HepMCProduct::GetEvent
const HepMC::GenEvent * GetEvent() const
Definition: HepMCProduct.h:34
HltBtagPostValidation_cff.c
c
Definition: HltBtagPostValidation_cff.py:31
HiggsValidation::particle_name
std::string particle_name
Definition: HiggsValidation.h:167
WeightManager::weight
double weight(const edm::Event &)
Definition: WeightManager.cc:24
alignCSCRings.r
r
Definition: alignCSCRings.py:93
DQMHelper
Definition: DQMHelper.h:15
HiggsValidation::dqmBeginRun
void dqmBeginRun(const edm::Run &r, const edm::EventSetup &c) override
Definition: HiggsValidation.cc:32
HiggsValidation::nEvt
MonitorElement * nEvt
Definition: HiggsValidation.h:174
GenParticle.GenParticle
GenParticle
Definition: GenParticle.py:18
std
Definition: JetResolutionObject.h:76
HiggsValidation::Higgs_mass
MonitorElement * Higgs_mass
Definition: HiggsValidation.h:179
HiggsValidation::HiggsDecayChannels
MonitorElement * HiggsDecayChannels
Definition: HiggsValidation.h:175
HiggsValidation::HiggsDecayProd_pt
std::vector< MonitorElement * > HiggsDecayProd_pt
Definition: HiggsValidation.h:181
dqm::implementation::IBooker
Definition: DQMStore.h:43
HiggsValidation::Higgs_eta
MonitorElement * Higgs_eta
Definition: HiggsValidation.h:178
dqm
Definition: DQMStore.h:18
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
HiggsValidation::MonitoredDecays::NDecayParticles
unsigned int NDecayParticles()
Definition: HiggsValidation.h:102
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
parents
TPRegexp parents
Definition: eve_filter.cc:21
HiggsValidation::hepmcCollection_
edm::InputTag hepmcCollection_
Definition: HiggsValidation.h:164
edm::Event
Definition: Event.h:73
HiggsValidation::MonitoredDecays::position
size_t position(int pid1, int pid2)
Definition: HiggsValidation.h:60
edm::InputTag
Definition: InputTag.h:15
weight
Definition: weight.py:1
HiggsValidation::particle_id
int particle_id
Definition: HiggsValidation.h:166
DeadROC_duringRun.dir
dir
Definition: DeadROC_duringRun.py:23