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