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 // $Id: G4MolecularDissociationChannel.cc 74551 2013-10-14 12:59:14Z gcosmo $ 26 // 27 // 27 // ------------------------------------------- 28 // ---------------------------------------------------------------------- 28 // GEANT 4 class implementation file 29 // GEANT 4 class implementation file 29 // 30 // 30 // History: first implementation by Alfon 31 // History: first implementation by Alfonso Mantero 4 Mar 2009 31 // 32 // 32 // ******************************************* 33 // ********************************************************************** 33 34 34 #include "G4MolecularDissociationChannel.hh" 35 #include "G4MolecularDissociationChannel.hh" 35 #include "G4VMolecularDissociationDisplacer.hh << 36 #include "G4Molecule.hh" >> 37 #include "G4MoleculeHandleManager.hh" 36 38 37 using namespace std; 39 using namespace std; 38 40 39 //____________________________________________ << 41 // ###################################################################### >> 42 // ### MolecularDecayChannel ### >> 43 // ###################################################################### 40 44 41 G4MolecularDissociationChannel::G4MolecularDis << 45 struct CompMoleculePointer 42 : G4MolecularDissociationChannel() << 43 { 46 { 44 fName = aName; << 47 bool operator()(const G4Molecule* mol1, const G4Molecule* mol2) const 45 } << 48 { 46 << 49 return (*mol1) < (*mol2); 47 //____________________________________________ << 50 } >> 51 }; 48 52 49 G4MolecularDissociationChannel::G4MolecularDis << 53 G4MolecularDecayChannel::G4MolecularDecayChannel(G4String aName) : fName(aName) 50 : fDisplacementType(G4VMolecularDissociati << 51 , fReleasedEnergy(0.) << 52 , fProbability(0.) << 53 , fDecayTime(0.) << 54 , fRMSMotherMoleculeDisplacement(0.) << 55 { 54 { >> 55 //pointer >> 56 fProductsVector = 0; >> 57 //double >> 58 fDecayTime = 0; >> 59 fProbability = 0; >> 60 fReleasedEnergy = 0; >> 61 fRMSMotherMoleculeDisplacement = 0; >> 62 fDisplacementType = 0; // meaning no displacement cf G4VMolecularDisplacer 56 } 63 } 57 64 58 //____________________________________________ << 65 G4MolecularDecayChannel::G4MolecularDecayChannel() 59 << 60 void G4MolecularDissociationChannel::AddProduc << 61 << 62 { 66 { 63 fProductsVector.push_back(pProduct); << 67 // pointer 64 fRMSProductsDisplacementVector.push_back(d << 68 fProductsVector = 0; >> 69 // double >> 70 fReleasedEnergy = 0; >> 71 fDecayTime = 0; >> 72 fProbability = 0; >> 73 fRMSMotherMoleculeDisplacement = 0; >> 74 fDisplacementType = 0; // meaning no displacement cf G4VMolecularDisplacer 65 } 75 } 66 76 67 //____________________________________________ << 77 G4MolecularDecayChannel::~G4MolecularDecayChannel() >> 78 { >> 79 if(fProductsVector) >> 80 { >> 81 fProductsVector->clear(); >> 82 delete fProductsVector; >> 83 } >> 84 } 68 85 69 G4int G4MolecularDissociationChannel::GetNbPro << 86 G4MolecularDecayChannel::G4MolecularDecayChannel(const G4MolecularDecayChannel& right) 70 { 87 { 71 return (G4int)fProductsVector.size(); << 88 *this = right; 72 } 89 } 73 90 74 //____________________________________________ << 91 G4MolecularDecayChannel& G4MolecularDecayChannel::operator= >> 92 (const G4MolecularDecayChannel& right) >> 93 { >> 94 if (&right==this) return *this; >> 95 >> 96 // string >> 97 fName = right.fName; >> 98 //displacement type >> 99 fDisplacementType = right.fDisplacementType; >> 100 // pointer >> 101 if(right.fProductsVector) >> 102 { >> 103 fProductsVector = new vector<G4MoleculeHandle>(*(right.fProductsVector)); >> 104 } >> 105 else fProductsVector = 0; >> 106 >> 107 // double >> 108 fReleasedEnergy = right.fReleasedEnergy; >> 109 fDecayTime = right.fDecayTime; >> 110 fProbability = right.fProbability; >> 111 // vector >> 112 fRMSMotherMoleculeDisplacement = right.fRMSMotherMoleculeDisplacement; >> 113 fRMSProductsDisplacementVector = right.fRMSProductsDisplacementVector; >> 114 return *this; >> 115 >> 116 } 75 117 76 G4MolecularDissociationChannel::Product* G4Mol << 118 void G4MolecularDecayChannel::AddProduct(const G4Molecule* molecule, G4double displacement) 77 { 119 { 78 return fProductsVector[index]; << 120 if(!fProductsVector) fProductsVector = new vector<G4MoleculeHandle> ; >> 121 >> 122 G4MoleculeHandle molHandle(G4MoleculeHandleManager::Instance()->GetMoleculeHandle(molecule)); >> 123 fProductsVector->push_back(molHandle); >> 124 fRMSProductsDisplacementVector.push_back(displacement); 79 } 125 } 80 126 81 //____________________________________________ << 127 G4int G4MolecularDecayChannel::GetNbProducts() const >> 128 { >> 129 if(fProductsVector) >> 130 return fProductsVector->size(); >> 131 return 0; >> 132 } 82 133 83 G4double << 134 const G4Molecule* G4MolecularDecayChannel::GetProduct(int index) const 84 G4MolecularDissociationChannel::GetRMSRadialDi << 85 { 135 { 86 if (fProductsVector.empty()) << 136 if(fProductsVector) 87 { << 137 return ((*fProductsVector)[index]).get(); 88 return -1.; << 89 } << 90 138 91 auto it = std::find_if(fProductsVector.beg << 139 return 0; 92 [pProduct](Product* << 140 } 93 return _pProduc << 141 94 }); << 142 G4double G4MolecularDecayChannel::GetRMSRadialDisplacementOfProduct(const G4Molecule* product) >> 143 { >> 144 if(!fProductsVector) return -1.; 95 145 96 if (it == fProductsVector.end()) << 146 G4int sz = fProductsVector->size(); >> 147 G4double value = DBL_MAX; >> 148 for (G4int i=0; i<sz ; i++) 97 { 149 { 98 return -1.; << 150 if(*product != *((*fProductsVector)[i]).get()) >> 151 { >> 152 value = fRMSProductsDisplacementVector[i]; >> 153 } 99 } 154 } 100 auto index = std::distance(fProductsVector << 155 return value; 101 return fRMSProductsDisplacementVector[inde << 102 } 156 } 103 157 104 158