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 84858 2014-10-21 16:08:22Z 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" >> 38 #include "G4MoleculeTable.hh" 36 39 37 using namespace std; 40 using namespace std; 38 41 39 //____________________________________________ << 42 // ###################################################################### >> 43 // ### MolecularDecayChannel ### >> 44 // ###################################################################### >> 45 >> 46 struct CompMoleculePointer >> 47 { >> 48 bool operator()(const G4Molecule* mol1, const G4Molecule* mol2) const >> 49 { >> 50 return (*mol1) < (*mol2); >> 51 } >> 52 }; >> 53 >> 54 G4MolecularDissociationChannel::G4MolecularDissociationChannel(G4String aName) : >> 55 fName(aName) >> 56 { >> 57 //pointer >> 58 fProductsVector = 0; >> 59 //double >> 60 fDecayTime = 0; >> 61 fProbability = 0; >> 62 fReleasedEnergy = 0; >> 63 fRMSMotherMoleculeDisplacement = 0; >> 64 fDisplacementType = 0; // meaning no displacement cf G4VMolecularDisplacer >> 65 } 40 66 41 G4MolecularDissociationChannel::G4MolecularDis << 67 G4MolecularDissociationChannel::G4MolecularDissociationChannel() 42 : G4MolecularDissociationChannel() << 43 { 68 { 44 fName = aName; << 69 // pointer >> 70 fProductsVector = 0; >> 71 // double >> 72 fReleasedEnergy = 0; >> 73 fDecayTime = 0; >> 74 fProbability = 0; >> 75 fRMSMotherMoleculeDisplacement = 0; >> 76 fDisplacementType = 0; // meaning no displacement cf G4VMolecularDisplacer 45 } 77 } 46 78 47 //____________________________________________ << 79 G4MolecularDissociationChannel::~G4MolecularDissociationChannel() >> 80 { >> 81 if (fProductsVector) >> 82 { >> 83 fProductsVector->clear(); >> 84 delete fProductsVector; >> 85 } >> 86 } 48 87 49 G4MolecularDissociationChannel::G4MolecularDis << 88 G4MolecularDissociationChannel::G4MolecularDissociationChannel(const G4MolecularDissociationChannel& right) 50 : fDisplacementType(G4VMolecularDissociati << 51 , fReleasedEnergy(0.) << 52 , fProbability(0.) << 53 , fDecayTime(0.) << 54 , fRMSMotherMoleculeDisplacement(0.) << 55 { 89 { >> 90 *this = right; 56 } 91 } 57 92 58 //____________________________________________ << 93 G4MolecularDissociationChannel& G4MolecularDissociationChannel::operator=(const G4MolecularDissociationChannel& right) >> 94 { >> 95 if (&right == this) return *this; 59 96 60 void G4MolecularDissociationChannel::AddProduc << 97 // string >> 98 fName = right.fName; >> 99 //displacement type >> 100 fDisplacementType = right.fDisplacementType; >> 101 // pointer >> 102 if (right.fProductsVector) >> 103 { >> 104 // fProductsVector = new vector<G4MoleculeHandle>(*(right.fProductsVector)); >> 105 fProductsVector = new vector<const G4Molecule*>(*(right.fProductsVector)); >> 106 } >> 107 else fProductsVector = 0; >> 108 >> 109 // double >> 110 fReleasedEnergy = right.fReleasedEnergy; >> 111 fDecayTime = right.fDecayTime; >> 112 fProbability = right.fProbability; >> 113 // vector >> 114 fRMSMotherMoleculeDisplacement = right.fRMSMotherMoleculeDisplacement; >> 115 fRMSProductsDisplacementVector = right.fRMSProductsDisplacementVector; >> 116 return *this; >> 117 >> 118 } >> 119 >> 120 void G4MolecularDissociationChannel::AddProduct(const G4Molecule* molecule, 61 121 G4double displacement) 62 { 122 { 63 fProductsVector.push_back(pProduct); << 123 // if(!fProductsVector) fProductsVector = new vector<G4MoleculeHandle> ; 64 fRMSProductsDisplacementVector.push_back(d << 124 if (!fProductsVector) fProductsVector = new vector<const G4Molecule*>; >> 125 >> 126 // G4MoleculeHandle molHandle(G4MoleculeHandleManager::Instance()->GetMoleculeHandle(molecule)); >> 127 // fProductsVector->push_back(molHandle); >> 128 >> 129 fProductsVector->push_back(molecule); >> 130 fRMSProductsDisplacementVector.push_back(displacement); 65 } 131 } 66 132 67 //____________________________________________ << 133 void G4MolecularDissociationChannel::AddProduct(const G4String& molecule, >> 134 G4double displacement) >> 135 { >> 136 // if(!fProductsVector) fProductsVector = new vector<G4MoleculeHandle> ; >> 137 if (!fProductsVector) fProductsVector = new vector<const G4Molecule*>; >> 138 >> 139 fProductsVector->push_back( >> 140 G4MoleculeTable::Instance()->GetMoleculeModel(molecule)); >> 141 fRMSProductsDisplacementVector.push_back(displacement); >> 142 } 68 143 69 G4int G4MolecularDissociationChannel::GetNbPro 144 G4int G4MolecularDissociationChannel::GetNbProducts() const 70 { 145 { 71 return (G4int)fProductsVector.size(); << 146 if (fProductsVector) return fProductsVector->size(); >> 147 return 0; 72 } 148 } 73 149 74 //____________________________________________ << 150 const G4Molecule* G4MolecularDissociationChannel::GetProduct(int index) const 75 << 76 G4MolecularDissociationChannel::Product* G4Mol << 77 { 151 { 78 return fProductsVector[index]; << 152 if (fProductsVector) 79 } << 153 // return ((*fProductsVector)[index]).get(); >> 154 return ((*fProductsVector)[index]); 80 155 81 //____________________________________________ << 156 return 0; >> 157 } 82 158 83 G4double << 159 G4double G4MolecularDissociationChannel::GetRMSRadialDisplacementOfProduct(const G4Molecule* product) 84 G4MolecularDissociationChannel::GetRMSRadialDi << 85 { 160 { 86 if (fProductsVector.empty()) << 161 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 162 96 if (it == fProductsVector.end()) << 163 G4int sz = fProductsVector->size(); >> 164 G4double value = DBL_MAX; >> 165 for (G4int i = 0; i < sz; i++) >> 166 { >> 167 // if(*product != *((*fProductsVector)[i]).get()) >> 168 if (*product != *((*fProductsVector)[i])) 97 { 169 { 98 return -1.; << 170 value = fRMSProductsDisplacementVector[i]; 99 } 171 } 100 auto index = std::distance(fProductsVector << 172 } 101 return fRMSProductsDisplacementVector[inde << 173 return value; 102 } 174 } 103 175 104 176