00001 // 00002 // ******************************************************************** 00003 // * License and Disclaimer * 00004 // * * 00005 // * The Geant4 software is copyright of the Copyright Holders of * 00006 // * the Geant4 Collaboration. It is provided under the terms and * 00007 // * conditions of the Geant4 Software License, included in the file * 00008 // * LICENSE and available at http://cern.ch/geant4/license . These * 00009 // * include a list of copyright holders. * 00010 // * * 00011 // * Neither the authors of this software system, nor their employing * 00012 // * institutes,nor the agencies providing financial support for this * 00013 // * work make any representation or warranty, express or implied, * 00014 // * regarding this software system or assume any liability for its * 00015 // * use. Please see the license in the file LICENSE and URL above * 00016 // * for the full disclaimer and the limitation of liability. * 00017 // * * 00018 // * This code implementation is the result of the scientific and * 00019 // * technical work of the GEANT4 collaboration. * 00020 // * By using, copying, modifying or distributing the software (or * 00021 // * any work based on the software) you agree to acknowledge its * 00022 // * use in resulting scientific publications, and indicate your * 00023 // * acceptance of all terms of the Geant4 Software license. * 00024 // ******************************************************************** 00025 // 00026 // G4MCTEvent.cc 00027 // 00028 // ==================================================================== 00029 00030 #include "G4ios.hh" 00031 #include "G4MCTEvent.hh" 00032 #include "G4MCTGenEvent.hh" 00033 #include "G4MCTSimEvent.hh" 00034 #include "G4MCTSimParticle.hh" 00035 00036 // ==================================================================== 00037 // 00038 // class description 00039 // 00040 // ==================================================================== 00041 00043 G4MCTEvent::G4MCTEvent() 00044 : eventNumber(0) 00046 { 00047 genEvent= new G4MCTGenEvent(); // will be reused. 00048 simEvent= new G4MCTSimEvent(); 00049 } 00050 00052 G4MCTEvent::~G4MCTEvent() 00054 { 00055 delete genEvent; 00056 delete simEvent; 00057 } 00058 00060 G4MCTSimParticle* G4MCTEvent::GetSimParticle 00061 (const G4MCTGenParticle& genpart) const 00063 { 00064 MCTGen2SimParticleMap::const_iterator pos= gen2simParticleMap.find(genpart); 00065 if(pos != gen2simParticleMap.end()) { 00066 return pos-> second; 00067 } else { 00068 return 0; 00069 } 00070 } 00071 00073 G4MCTGenParticle G4MCTEvent::GetGenParticle 00074 (const G4MCTSimParticle* simpart) const 00076 { 00077 MCTSim2GenParticleMap::const_iterator 00078 pos= sim2genParticleMap.find(const_cast<G4MCTSimParticle*>(simpart)); 00079 if(pos != sim2genParticleMap.end()) { 00080 return pos-> second; 00081 } else { 00082 return G4MCTGenParticle((void*)0,(void*)0); 00083 } 00084 } 00085 00087 int G4MCTEvent::AddPrimaryPair(const G4MCTGenParticle& genp, 00088 const G4MCTSimParticle* simp) 00090 { 00091 gen2simParticleMap.insert(std::make_pair(const_cast<G4MCTGenParticle&>(genp), 00092 const_cast<G4MCTSimParticle*>(simp))); 00093 sim2genParticleMap.insert(std::make_pair(const_cast<G4MCTSimParticle*>(simp), 00094 const_cast<G4MCTGenParticle&>(genp))); 00095 00096 return gen2simParticleMap.size(); 00097 } 00098 00100 void G4MCTEvent::ClearEvent() 00102 { 00103 gen2simParticleMap.clear(); 00104 sim2genParticleMap.clear(); 00105 00106 genEvent-> ClearEvent(); 00107 simEvent-> ClearEvent(); 00108 } 00109 00111 void G4MCTEvent::Print(std::ostream& ostr) const 00113 { 00114 ostr << "Event#:" << eventNumber << G4endl; 00115 simEvent-> Print(ostr); 00116 }