Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
// $Id: Geant4Hits.cpp 513 2013-04-05 14:31:53Z gaede $
//====================================================================
// AIDA Detector description implementation for LCD
//--------------------------------------------------------------------
//
// Author : M.Frank
//
//====================================================================
// Framework include files
#include "DD4hep/Primitives.h"
#include "DD4hep/InstanceCount.h"
#include "DDG4/Geant4Primary.h"
// C/C++ include files
#include <stdexcept>
#include <cstdio>
using namespace DD4hep;
using namespace DD4hep::Simulation;
/// Default destructor
PrimaryExtension::~PrimaryExtension() {
}
/// Default destructor
Geant4PrimaryMap::~Geant4PrimaryMap() {
releaseObjects(primaryMap)();
}
/// Default constructor
Geant4PrimaryInteraction::Geant4PrimaryInteraction()
: mask(0), next_particle_identifier(-1)
{
}
/// Copy constructor
Geant4PrimaryInteraction::Geant4PrimaryInteraction(const Geant4PrimaryInteraction&)
: mask(0), next_particle_identifier(-1)
{
}
/// Assignment operator
Geant4PrimaryInteraction& Geant4PrimaryInteraction::operator=(const Geant4PrimaryInteraction& c) {
if ( &c == this ) {}
return *this;
}
/// Default destructor
Geant4PrimaryInteraction::~Geant4PrimaryInteraction() {
releaseObjects(vertices)();
releaseObjects(particles)();
}
/// Access a new particle identifier within the interaction
int Geant4PrimaryInteraction::nextPID() {
return ++next_particle_identifier;
}
/// Access a new particle identifier within the interaction
void Geant4PrimaryInteraction::setNextPID(int new_value) {
next_particle_identifier = new_value-1;
}
/// Default constructor
Geant4PrimaryEvent::Geant4PrimaryEvent()
{
}
/// Copy constructor
Geant4PrimaryEvent::Geant4PrimaryEvent(const Geant4PrimaryEvent&)
{
}
/// Assignment operator
Geant4PrimaryEvent& Geant4PrimaryEvent::operator=(const Geant4PrimaryEvent& c) {
if ( &c == this ) {}
return *this;
}
/// Default destructor
Geant4PrimaryEvent::~Geant4PrimaryEvent() {
destroyObjects(m_interactions)();
}
/// Add a new interaction object to the event
void Geant4PrimaryEvent::add(int id, Geant4PrimaryInteraction* interaction) {
if ( interaction ) {
Interactions::iterator i = m_interactions.find(id);
if ( i == m_interactions.end() ) {
interaction->mask = id;
m_interactions.insert(std::make_pair(id,interaction));
return;
}
char text[132];
::snprintf(text,sizeof(text),"Geant4PrimaryEvent: Interaction with ID '%d' "
"exists and cannot be added twice!",id);
throw std::runtime_error(text);
}
throw std::runtime_error("Geant4PrimaryEvent: CANNOT add invalid Interaction!");
}
/// Retrieve an interaction by it's ID
Geant4PrimaryEvent::Interaction* Geant4PrimaryEvent::get(int mask) const {
Interactions::const_iterator i = m_interactions.find(mask);
if ( i != m_interactions.end() ) {
return (*i).second;
}
return 0;
}
/// Retrieve all intractions
std::vector<Geant4PrimaryEvent::Interaction*> Geant4PrimaryEvent::interactions() const {
std::vector<Interaction*> v;
for(Interactions::const_iterator i=m_interactions.begin(); i!=m_interactions.end(); ++i)
v.push_back((*i).second);
return v;
}