source: trunk/source/persistency/mctruth/src/G4MCTEvent.cc@ 1193

Last change on this file since 1193 was 818, checked in by garnier, 17 years ago

import all except CVS

File size: 4.1 KB
Line 
1//
2// ********************************************************************
3// * License and Disclaimer *
4// * *
5// * The Geant4 software is copyright of the Copyright Holders of *
6// * the Geant4 Collaboration. It is provided under the terms and *
7// * conditions of the Geant4 Software License, included in the file *
8// * LICENSE and available at http://cern.ch/geant4/license . These *
9// * include a list of copyright holders. *
10// * *
11// * Neither the authors of this software system, nor their employing *
12// * institutes,nor the agencies providing financial support for this *
13// * work make any representation or warranty, express or implied, *
14// * regarding this software system or assume any liability for its *
15// * use. Please see the license in the file LICENSE and URL above *
16// * for the full disclaimer and the limitation of liability. *
17// * *
18// * This code implementation is the result of the scientific and *
19// * technical work of the GEANT4 collaboration. *
20// * By using, copying, modifying or distributing the software (or *
21// * any work based on the software) you agree to acknowledge its *
22// * use in resulting scientific publications, and indicate your *
23// * acceptance of all terms of the Geant4 Software license. *
24// ********************************************************************
25//
26// G4MCTEvent.cc
27//
28// ====================================================================
29
30#ifndef WIN32
31#ifdef G4LIB_USE_HEPMC
32
33#include "G4ios.hh"
34#include "G4MCTEvent.hh"
35#include "G4MCTGenEvent.hh"
36#include "G4MCTSimEvent.hh"
37#include "G4MCTSimParticle.hh"
38
39// ====================================================================
40//
41// class description
42//
43// ====================================================================
44
45////////////////////
46G4MCTEvent::G4MCTEvent()
47 : eventNumber(0)
48////////////////////
49{
50 genEvent= new G4MCTGenEvent(); // will be reused.
51 simEvent= new G4MCTSimEvent();
52}
53
54/////////////////////
55G4MCTEvent::~G4MCTEvent()
56/////////////////////
57{
58 delete genEvent;
59 delete simEvent;
60}
61
62/////////////////////////////////////////////////////
63G4MCTSimParticle* G4MCTEvent::GetSimParticle
64 (const G4MCTGenParticle& genpart) const
65/////////////////////////////////////////////////////
66{
67 MCTGen2SimParticleMap::const_iterator pos= gen2simParticleMap.find(genpart);
68 if(pos != gen2simParticleMap.end()) {
69 return pos-> second;
70 } else {
71 return 0;
72 }
73}
74
75////////////////////////////////////////////////////
76G4MCTGenParticle G4MCTEvent::GetGenParticle
77 (const G4MCTSimParticle* simpart) const
78////////////////////////////////////////////////////
79{
80 MCTSim2GenParticleMap::const_iterator
81 pos= sim2genParticleMap.find(const_cast<G4MCTSimParticle*>(simpart));
82 if(pos != sim2genParticleMap.end()) {
83 return pos-> second;
84 } else {
85 return G4MCTGenParticle(0,0);
86 }
87}
88
89////////////////////////////////////////////////////////
90int G4MCTEvent::AddPrimaryPair(const G4MCTGenParticle& genp,
91 const G4MCTSimParticle* simp)
92////////////////////////////////////////////////////////
93{
94 gen2simParticleMap.insert(std::make_pair(const_cast<G4MCTGenParticle&>(genp),
95 const_cast<G4MCTSimParticle*>(simp)));
96 sim2genParticleMap.insert(std::make_pair(const_cast<G4MCTSimParticle*>(simp),
97 const_cast<G4MCTGenParticle&>(genp)));
98
99 return gen2simParticleMap.size();
100}
101
102///////////////////////////
103void G4MCTEvent::ClearEvent()
104///////////////////////////
105{
106 gen2simParticleMap.clear();
107 sim2genParticleMap.clear();
108
109 genEvent-> ClearEvent();
110 simEvent-> ClearEvent();
111}
112
113
114//////////////////////////////////////////////
115void G4MCTEvent::Print(std::ostream& ostr) const
116//////////////////////////////////////////////
117{
118 ostr << "Event#:" << eventNumber << G4endl;
119 genEvent-> Print(ostr);
120 simEvent-> Print(ostr);
121}
122
123#endif
124#endif
Note: See TracBrowser for help on using the repository browser.