HepMC3 event record library
test
testDelete.cc
1
// -*- C++ -*-
2
//
3
// This file is part of HepMC
4
// Copyright (C) 2014-2019 The HepMC collaboration (see AUTHORS for details)
5
//
6
#include "
HepMC3/GenEvent.h
"
7
#include "
HepMC3/GenParticle.h
"
8
#include "
HepMC3/GenVertex.h
"
9
#include "
HepMC3/ReaderAscii.h
"
10
#include "
HepMC3/WriterAscii.h
"
11
#include "
HepMC3/ReaderAsciiHepMC2.h
"
12
#include "
HepMC3/WriterAsciiHepMC2.h
"
13
#include "HepMC3TestUtils.h"
14
using namespace
HepMC3
;
15
int
main
()
16
{
17
ReaderAsciiHepMC2
inputA(
"inputDelete.hepmc"
);
18
if
(inputA.failed())
return
1;
19
std::vector<GenEvent> evts;
20
while
( !inputA.failed() )
21
{
22
GenEvent
evt=
GenEvent
(Units::GEV,Units::MM);
23
inputA.read_event(evt);
24
if
( inputA.failed() ) {
25
printf(
"End of file reached. Exit.\n"
);
26
break
;
27
}
28
evts.push_back(evt);
29
}
30
inputA.close();
31
//No alien particles should be detached from vertices or removed from events
32
int
i=0;
33
int
j=0;
34
while
(i==j)
35
{
36
i=rand()% evts.size();
37
j=rand()% evts.size();
38
}
39
evts[i].remove_particles(evts[j].particles());
40
41
for
(GenParticlePtr p: evts.at(i).particles())
42
evts[j].remove_particle(p);
43
44
for
(GenParticlePtr p: evts.at(i).particles()) {
45
for
(GenVertexPtr v: evts.at(j).vertices()) {
46
(v)->remove_particle_in(p);
47
(v)->remove_particle_out(p);
48
}
49
}
50
51
WriterAscii
outputA(
"frominputDelete.hepmc"
);
52
if
(outputA.failed())
return
2;
53
for
(
size_t
i=0; i<evts.size(); i++) outputA.write_event(evts[i]);
54
evts.clear();
55
outputA.close();
56
57
58
ReaderAscii
inputB(
"frominputDelete.hepmc"
);
59
if
(inputB.failed())
return
3;
60
WriterAsciiHepMC2
outputB(
"fromfrominputDelete.hepmc"
);
61
if
(outputB.failed())
return
4;
62
while
( !inputB.failed() )
63
{
64
GenEvent
evt(Units::GEV,Units::MM);
65
inputB.read_event(evt);
66
if
( inputB.failed() ) {
67
printf(
"End of file reached. Exit.\n"
);
68
break
;
69
}
70
outputB.write_event(evt);
71
evt.
clear
();
72
}
73
inputB.close();
74
outputB.close();
75
return
COMPARE_ASCII_FILES(
"fromfrominputDelete.hepmc"
,
"inputDelete.hepmc"
);
76
}
GenEvent.h
Definition of class GenEvent.
HepMC3::WriterAscii
GenEvent I/O serialization for structured text files.
Definition:
WriterAscii.h:25
HepMC3::GenEvent
Stores event-related information.
Definition:
GenEvent.h:41
HepMC3::WriterAsciiHepMC2
GenEvent I/O serialization for structured text files.
Definition:
WriterAsciiHepMC2.h:27
GenVertex.h
Definition of class GenVertex.
HepMC3
HepMC3 main namespace.
Definition:
AnalysisExample.h:19
HepMC3::GenEvent::clear
void clear()
Remove contents of this event.
Definition:
GenEvent.cc:608
GenParticle.h
Definition of class GenParticle.
HepMC3::ReaderAscii
GenEvent I/O parsing for structured text files.
Definition:
ReaderAscii.h:29
ReaderAsciiHepMC2.h
Definition of class ReaderAsciiHepMC2.
WriterAscii.h
Definition of class WriterAscii.
WriterAsciiHepMC2.h
Definition of class WriterAsciiHepMC2.
HepMC3::ReaderAsciiHepMC2
Parser for HepMC2 I/O files.
Definition:
ReaderAsciiHepMC2.h:30
ReaderAscii.h
Definition of class ReaderAscii.
main
int main(int argc, char **argv)
Definition:
rootIOTree_example_read.cc:23
Generated on Sat Apr 25 2020 15:27:49 for HepMC3 event record library by
1.8.18