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 // $Id: G4MolecularDecayChannel.cc 65022 2012-11-12 16:43:12Z gcosmo $ 00027 // 00028 // ---------------------------------------------------------------------- 00029 // GEANT 4 class implementation file 00030 // 00031 // History: first implementation by Alfonso Mantero 4 Mar 2009 00032 // 00033 // ********************************************************************** 00034 00035 #include "G4MolecularDecayChannel.hh" 00036 #include "G4Molecule.hh" 00037 #include "G4MoleculeHandleManager.hh" 00038 00039 using namespace std; 00040 00041 // ###################################################################### 00042 // ### MolecularDecayChannel ### 00043 // ###################################################################### 00044 00045 struct CompMoleculePointer 00046 { 00047 bool operator()(const G4Molecule* mol1, const G4Molecule* mol2) const 00048 { 00049 return (*mol1) < (*mol2); 00050 } 00051 }; 00052 00053 G4MolecularDecayChannel::G4MolecularDecayChannel(G4String aName) : fName(aName) 00054 { 00055 //pointer 00056 fProductsVector = 0; 00057 //double 00058 fDecayTime = 0; 00059 fProbability = 0; 00060 fReleasedEnergy = 0; 00061 fRMSMotherMoleculeDisplacement = 0; 00062 fDisplacementType = 0; // meaning no displacement cf G4VMolecularDisplacer 00063 } 00064 00065 G4MolecularDecayChannel::G4MolecularDecayChannel() 00066 { 00067 // pointer 00068 fProductsVector = 0; 00069 // double 00070 fReleasedEnergy = 0; 00071 fDecayTime = 0; 00072 fProbability = 0; 00073 fRMSMotherMoleculeDisplacement = 0; 00074 fDisplacementType = 0; // meaning no displacement cf G4VMolecularDisplacer 00075 } 00076 00077 G4MolecularDecayChannel::~G4MolecularDecayChannel() 00078 { 00079 if(fProductsVector) 00080 { 00081 fProductsVector->clear(); 00082 delete fProductsVector; 00083 } 00084 } 00085 00086 G4MolecularDecayChannel::G4MolecularDecayChannel(const G4MolecularDecayChannel& right) 00087 { 00088 *this = right; 00089 } 00090 00091 G4MolecularDecayChannel& G4MolecularDecayChannel::operator= 00092 (const G4MolecularDecayChannel& right) 00093 { 00094 if (&right==this) return *this; 00095 00096 // string 00097 fName = right.fName; 00098 //displacement type 00099 fDisplacementType = right.fDisplacementType; 00100 // pointer 00101 if(right.fProductsVector) 00102 { 00103 fProductsVector = new vector<G4MoleculeHandle>(*(right.fProductsVector)); 00104 } 00105 else fProductsVector = 0; 00106 00107 // double 00108 fReleasedEnergy = right.fReleasedEnergy; 00109 fDecayTime = right.fDecayTime; 00110 fProbability = right.fProbability; 00111 // vector 00112 fRMSMotherMoleculeDisplacement = right.fRMSMotherMoleculeDisplacement; 00113 fRMSProductsDisplacementVector = right.fRMSProductsDisplacementVector; 00114 return *this; 00115 00116 } 00117 00118 void G4MolecularDecayChannel::AddProduct(const G4Molecule* molecule, G4double displacement) 00119 { 00120 if(!fProductsVector) fProductsVector = new vector<G4MoleculeHandle> ; 00121 00122 G4MoleculeHandle molHandle(G4MoleculeHandleManager::Instance()->GetMoleculeHandle(molecule)); 00123 fProductsVector->push_back(molHandle); 00124 fRMSProductsDisplacementVector.push_back(displacement); 00125 } 00126 00127 G4int G4MolecularDecayChannel::GetNbProducts() const 00128 { 00129 if(fProductsVector) 00130 return fProductsVector->size(); 00131 return 0; 00132 } 00133 00134 const G4Molecule* G4MolecularDecayChannel::GetProduct(int index) const 00135 { 00136 if(fProductsVector) 00137 return ((*fProductsVector)[index]).get(); 00138 00139 return 0; 00140 } 00141 00142 G4double G4MolecularDecayChannel::GetRMSRadialDisplacementOfProduct(const G4Molecule* product) 00143 { 00144 if(!fProductsVector) return -1.; 00145 00146 G4int sz = fProductsVector->size(); 00147 G4double value = DBL_MAX; 00148 for (G4int i=0; i<sz ; i++) 00149 { 00150 if(*product != *((*fProductsVector)[i]).get()) 00151 { 00152 value = fRMSProductsDisplacementVector[i]; 00153 } 00154 } 00155 return value; 00156 } 00157