Main Page
Namespaces
Classes
Package Documentation
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Pages
src
TauAnalysis
MCEmbeddingTools
plugins
CheckHepMCEvent.cc
Go to the documentation of this file.
1
/*
2
#include "TauAnalysis/MCEmbeddingTools/plugins/CheckHepMCEvent.h"
3
4
CheckHepMCEvent::CheckHepMCEvent(const edm::ParameterSet& pset)
5
{
6
HepMCSource_= pset.getUntrackedParameter<string>("HepMCSource","newSource");
7
}
8
9
CheckHepMCEvent::~CheckHepMCEvent()
10
{
11
12
}
13
void CheckHepMCEvent::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup)
14
{
15
using namespace HepMC;
16
17
Handle<edm::HepMCProduct> HepMCHandle;
18
if (!iEvent.getByLabel(HepMCSource_,HepMCHandle))
19
{
20
LogError("CheckHepMCEvent") << "[EEE] \t Could not read event!\n";
21
return;
22
}
23
24
HepMC::GenEvent * evt = new HepMC::GenEvent(*(HepMCHandle->GetEvent()));
25
26
// evt->print(std::cout);
27
28
int total_cnt_vertices = evt->vertices_size();
29
int total_cnt_particles = evt->particles_size();
30
31
LogInfo("CheckHepMCEvent") << "[III] Event contains...\n";
32
LogInfo("CheckHepMCEvent") << "[III] \t"<< total_cnt_particles << " particles\n";
33
LogInfo("CheckHepMCEvent") << "[III] \t"<< total_cnt_vertices << " vertices\n";
34
35
for ( GenEvent::vertex_iterator vert = evt->vertices_begin(); vert != evt->vertices_end(); vert++ )
36
{
37
// std::cout << "[III] Vertex...\n";
38
// (*vert)->print(std::cout);
39
if ((*vert)->particles_in_size() <= 0)
40
LogError("CheckHepMCEvent") << "[EEE] \t vertex has no incoming particles\n";
41
42
if ((*vert)->particles_out_size() <= 0)
43
LogError("CheckHepMCEvent") << "[EEE] \t vertex has no outgoing particles\n";
44
45
if (!(*vert)->check_momentum_conservation())
46
LogWarning("CheckHepMCEvent") << "[WWW] \t particles in vertex do not obey momentum conservation\n";
47
48
for (GenVertex::particles_in_const_iterator it = (*vert)->particles_in_const_begin(); it!=(*vert)->particles_in_const_end(); it++)
49
checkParticle(*it);
50
51
for (GenVertex::particles_out_const_iterator it = (*vert)->particles_out_const_begin(); it!=(*vert)->particles_out_const_end(); it++)
52
{
53
checkParticle(*it);
54
if ((*it)->production_vertex() && (*it)->production_vertex()!=(*vert))
55
LogError("CheckHepMCEvent") << "[EEE] \t production vertex of outgoing particles is not identical to this vertex\n";
56
}
57
}
58
59
delete evt;
60
}
61
62
void CheckHepMCEvent::checkParticle(HepMC::GenParticle * part)
63
{
64
// std::cout << "[III] Particle... " << part->pdg_id() << " " << part->status()<< "\n";
65
if (!part->parent_event())
66
LogError("CheckHepMCEvent") << "[EEE] \t particle without parent event\n";
67
68
if (!part->production_vertex())
69
LogWarning("CheckHepMCEvent") << "[WWW] \t particle without production vertexz\n";
70
71
if (part->status()<=0)
72
LogError("CheckHepMCEvent") << "[EEE] \t invalidstatus\n";
73
74
if (part->status()==1 && (abs(part->pdg_id())<=9 || abs(part->pdg_id())==21))
75
{
76
LogError("CheckHepMCEvent") << "[EEE] \t gluon or quark in final state\n";
77
78
}
79
if (part->status()!=1 && !part->end_vertex())
80
{
81
LogError("CheckHepMCEvent") << "[EEE] \t decaying particle without end_vertex\n";
82
}
83
}
84
85
void CheckHepMCEvent::beginJob(const edm::EventSetup& )
86
{
87
88
}
89
90
void CheckHepMCEvent::endJob()
91
{
92
93
}
94
*/
Generated for CMSSW Reference Manual by
1.8.5