SLIC
6.1.1
Simulation for the Linear Collider (SLIC) - Geant4 simulation application
src
LHEReader.cc
Go to the documentation of this file.
1
#include "
LHEReader.hh
"
2
3
// STL
4
#include <iostream>
5
#include <stdexcept>
6
7
namespace
slic
{
8
9
LHEReader::LHEReader
(
const
std::string& filename) {
10
std::cout <<
"Opening LHE file "
<< filename <<
std::endl
;
11
ifs_
.open(filename.c_str(), std::ifstream::in);
12
}
13
14
LHEReader::~LHEReader
() {
15
ifs_
.close();
16
}
17
18
LHEEvent
*
LHEReader::readNextEvent
() {
19
20
std::string line;
21
bool
foundEventElement =
false
;
22
while
(getline(
ifs_
, line)) {
23
if
(line ==
"<event>"
) {
24
foundEventElement =
true
;
25
break
;
26
}
27
}
28
29
if
(!foundEventElement) {
30
std::cerr <<
"WARNING: No next <event> element was found by the LHE reader."
<<
std::endl
;
31
return
NULL;
32
}
33
34
getline(
ifs_
, line);
35
36
LHEEvent
* nextEvent =
new
LHEEvent
(line);
37
38
while
(getline(
ifs_
, line)) {
39
40
if
(line ==
"</event>"
) {
41
break
;
42
}
43
44
LHEParticle
* particle =
new
LHEParticle
(line);
45
nextEvent->
addParticle
(particle);
46
}
47
48
const
std::vector<LHEParticle*>& particles = nextEvent->
getParticles
();
49
int
particleIndex = 0;
50
for
(std::vector<LHEParticle*>::const_iterator it = particles.begin(); it != particles.end(); it++) {
51
LHEParticle
* particle = (*it);
52
if
(particle->
getMOTHUP
(0) != 0) {
53
int
mother1 = particle->
getMOTHUP
(0);
54
int
mother2 = particle->
getMOTHUP
(1);
55
if
(mother1 > 0) {
56
particle->
setMother
(0, particles[mother1 - 1]);
57
}
58
if
(mother2 > 0) {
59
particle->
setMother
(1, particles[mother2 - 1]);
60
}
61
}
62
++particleIndex;
63
}
64
65
return
nextEvent;
66
}
67
68
}
LHEReader.hh
slic::LHEEvent
LHE event with a list of particles and information from the header block.
Definition:
LHEEvent.hh:26
slic::LHEEvent::addParticle
void addParticle(LHEParticle *particle)
Definition:
LHEEvent.cc:70
slic::LHEEvent::getParticles
const std::vector< LHEParticle * > & getParticles()
Definition:
LHEEvent.cc:74
slic::LHEParticle
Single particle record in an LHE event.
Definition:
LHEParticle.hh:20
slic::LHEParticle::getMOTHUP
int getMOTHUP(int) const
Definition:
LHEParticle.cc:59
slic::LHEParticle::setMother
void setMother(int i, LHEParticle *particle)
Definition:
LHEParticle.cc:79
slic::LHEReader::ifs_
std::ifstream ifs_
Definition:
LHEReader.hh:48
slic::LHEReader::~LHEReader
virtual ~LHEReader()
Definition:
LHEReader.cc:14
slic::LHEReader::readNextEvent
LHEEvent * readNextEvent()
Definition:
LHEReader.cc:18
slic::LHEReader::LHEReader
LHEReader(const std::string &fileName)
Definition:
LHEReader.cc:9
LOG::endl
@ endl
Definition:
LogStream.hh:26
slic
Definition:
CommandLineOption.hh:9
Generated by
1.9.1