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 // 26 // 27 // ------------------------------------------- 27 // ---------------------------------------------------------------------- 28 // GEANT 4 class implementation file 28 // GEANT 4 class implementation file 29 // 29 // 30 // History: first implementation by Alfon 30 // History: first implementation by Alfonso Mantero 4 Mar 2009 31 // 31 // 32 // ******************************************* 32 // ********************************************************************** 33 33 34 #include "G4MolecularDissociationChannel.hh" 34 #include "G4MolecularDissociationChannel.hh" 35 #include "G4VMolecularDissociationDisplacer.hh << 35 #include "G4Molecule.hh" >> 36 #include "G4MoleculeHandleManager.hh" >> 37 #include "G4MoleculeTable.hh" 36 38 37 using namespace std; 39 using namespace std; 38 40 >> 41 // ----------------------------------------------------------------------------- >> 42 // ### MolecularDecayChannel ### >> 43 // ----------------------------------------------------------------------------- >> 44 >> 45 //struct CompMoleculePointer >> 46 //{ >> 47 // bool operator()(const G4Molecule* mol1, const G4Molecule* mol2) const >> 48 // { >> 49 // return (*mol1) < (*mol2); >> 50 // } >> 51 //}; >> 52 39 //____________________________________________ 53 //______________________________________________________________________________ 40 54 41 G4MolecularDissociationChannel::G4MolecularDis << 55 G4MolecularDissociationChannel::G4MolecularDissociationChannel(G4String aName) : 42 : G4MolecularDissociationChannel() << 56 fName(aName) 43 { << 57 { 44 fName = aName; << 58 //pointer >> 59 fProductsVector = 0; >> 60 //double >> 61 fDecayTime = 0; >> 62 fProbability = 0; >> 63 fReleasedEnergy = 0; >> 64 fRMSMotherMoleculeDisplacement = 0; >> 65 fDisplacementType = 0; // meaning no displacement cf G4VMolecularDisplacer 45 } 66 } 46 67 47 //____________________________________________ 68 //______________________________________________________________________________ 48 69 49 G4MolecularDissociationChannel::G4MolecularDis 70 G4MolecularDissociationChannel::G4MolecularDissociationChannel() 50 : fDisplacementType(G4VMolecularDissociati << 51 , fReleasedEnergy(0.) << 52 , fProbability(0.) << 53 , fDecayTime(0.) << 54 , fRMSMotherMoleculeDisplacement(0.) << 55 { 71 { >> 72 // pointer >> 73 fProductsVector = 0; >> 74 // double >> 75 fReleasedEnergy = 0; >> 76 fDecayTime = 0; >> 77 fProbability = 0; >> 78 fRMSMotherMoleculeDisplacement = 0; >> 79 fDisplacementType = 0; // meaning no displacement cf G4VMolecularDisplacer >> 80 } >> 81 >> 82 //______________________________________________________________________________ >> 83 >> 84 G4MolecularDissociationChannel::~G4MolecularDissociationChannel() >> 85 { >> 86 if(fProductsVector) >> 87 { >> 88 fProductsVector->clear(); >> 89 delete fProductsVector; >> 90 } >> 91 } >> 92 >> 93 //______________________________________________________________________________ >> 94 >> 95 G4MolecularDissociationChannel:: >> 96 G4MolecularDissociationChannel(const G4MolecularDissociationChannel& right) >> 97 { >> 98 *this = right; >> 99 } >> 100 >> 101 //______________________________________________________________________________ >> 102 >> 103 G4MolecularDissociationChannel& >> 104 G4MolecularDissociationChannel::operator=(const G4MolecularDissociationChannel& right) >> 105 { >> 106 if(&right == this) return *this; >> 107 >> 108 // string >> 109 fName = right.fName; >> 110 //displacement type >> 111 fDisplacementType = right.fDisplacementType; >> 112 // pointer >> 113 if(right.fProductsVector) >> 114 { >> 115 // fProductsVector = new vector<const G4Molecule*>(*(right.fProductsVector)); >> 116 fProductsVector = new vector<G4MolecularConfiguration*>(*(right.fProductsVector)); >> 117 } >> 118 else fProductsVector = 0; >> 119 >> 120 // double >> 121 fReleasedEnergy = right.fReleasedEnergy; >> 122 fDecayTime = right.fDecayTime; >> 123 fProbability = right.fProbability; >> 124 // vector >> 125 fRMSMotherMoleculeDisplacement = right.fRMSMotherMoleculeDisplacement; >> 126 fRMSProductsDisplacementVector = right.fRMSProductsDisplacementVector; >> 127 return *this; >> 128 } >> 129 >> 130 //______________________________________________________________________________ >> 131 >> 132 void G4MolecularDissociationChannel::AddProduct(const G4Molecule* molecule, >> 133 G4double displacement) >> 134 { >> 135 if(!fProductsVector) fProductsVector = new vector<G4MolecularConfiguration*>; >> 136 >> 137 fProductsVector->push_back(molecule->GetMolecularConfiguration()); >> 138 fRMSProductsDisplacementVector.push_back(displacement); >> 139 } >> 140 >> 141 //______________________________________________________________________________ >> 142 >> 143 void >> 144 G4MolecularDissociationChannel::AddProduct(G4MolecularConfiguration* molecule, >> 145 G4double displacement) >> 146 { >> 147 if(!fProductsVector) fProductsVector = new vector<G4MolecularConfiguration*>; >> 148 >> 149 fProductsVector->push_back(molecule); >> 150 fRMSProductsDisplacementVector.push_back(displacement); 56 } 151 } 57 152 58 //____________________________________________ 153 //______________________________________________________________________________ 59 154 60 void G4MolecularDissociationChannel::AddProduc << 155 void G4MolecularDissociationChannel::AddProduct(const G4String& molecule, 61 156 G4double displacement) 62 { 157 { 63 fProductsVector.push_back(pProduct); << 158 // if(!fProductsVector) fProductsVector = new vector<const G4Molecule*>; 64 fRMSProductsDisplacementVector.push_back(d << 159 if(!fProductsVector) fProductsVector = new vector<G4MolecularConfiguration*>; >> 160 >> 161 fProductsVector->push_back( >> 162 G4MoleculeTable::Instance()->GetConfiguration(molecule)); >> 163 fRMSProductsDisplacementVector.push_back(displacement); 65 } 164 } 66 165 67 //____________________________________________ 166 //______________________________________________________________________________ 68 167 69 G4int G4MolecularDissociationChannel::GetNbPro 168 G4int G4MolecularDissociationChannel::GetNbProducts() const 70 { 169 { 71 return (G4int)fProductsVector.size(); << 170 if(fProductsVector) return fProductsVector->size(); >> 171 return 0; 72 } 172 } 73 173 74 //____________________________________________ 174 //______________________________________________________________________________ 75 175 76 G4MolecularDissociationChannel::Product* G4Mol << 176 G4MolecularConfiguration* G4MolecularDissociationChannel::GetProduct(int index) const 77 { 177 { 78 return fProductsVector[index]; << 178 if(fProductsVector) >> 179 return ((*fProductsVector)[index]); >> 180 >> 181 return 0; 79 } 182 } 80 183 81 //____________________________________________ 184 //______________________________________________________________________________ 82 185 83 G4double 186 G4double 84 G4MolecularDissociationChannel::GetRMSRadialDi << 187 G4MolecularDissociationChannel:: >> 188 GetRMSRadialDisplacementOfProduct(const G4Molecule* product) 85 { 189 { 86 if (fProductsVector.empty()) << 190 if(!fProductsVector) return -1.; 87 { << 88 return -1.; << 89 } << 90 << 91 auto it = std::find_if(fProductsVector.beg << 92 [pProduct](Product* << 93 return _pProduc << 94 }); << 95 191 96 if (it == fProductsVector.end()) << 192 G4int sz = fProductsVector->size(); >> 193 G4double value = DBL_MAX; >> 194 for(G4int i = 0; i < sz; i++) >> 195 { >> 196 if(product->GetMolecularConfiguration() != ((*fProductsVector)[i])) 97 { 197 { 98 return -1.; << 198 value = fRMSProductsDisplacementVector[i]; 99 } 199 } 100 auto index = std::distance(fProductsVector << 200 } 101 return fRMSProductsDisplacementVector[inde << 201 return value; 102 } 202 } 103 203 104 204