G4GIDI_Misc.cc

Go to the documentation of this file.
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 /*
00027 # <<BEGIN-copyright>>
00028 # Copyright (c) 2010, Lawrence Livermore National Security, LLC. 
00029 # Produced at the Lawrence Livermore National Laboratory 
00030 # Written by Bret R. Beck, beck6@llnl.gov. 
00031 # CODE-461393
00032 # All rights reserved. 
00033 #  
00034 # This file is part of GIDI. For details, see nuclear.llnl.gov. 
00035 # Please also read the "Additional BSD Notice" at nuclear.llnl.gov. 
00036 # 
00037 # Redistribution and use in source and binary forms, with or without modification, 
00038 # are permitted provided that the following conditions are met: 
00039 #
00040 #      1) Redistributions of source code must retain the above copyright notice, 
00041 #         this list of conditions and the disclaimer below.
00042 #      2) Redistributions in binary form must reproduce the above copyright notice, 
00043 #         this list of conditions and the disclaimer (as noted below) in the 
00044 #          documentation and/or other materials provided with the distribution.
00045 #      3) Neither the name of the LLNS/LLNL nor the names of its contributors may be 
00046 #         used to endorse or promote products derived from this software without 
00047 #         specific prior written permission. 
00048 #
00049 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY 
00050 # EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 
00051 # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT 
00052 # SHALL LAWRENCE LIVERMORE NATIONAL SECURITY, LLC, THE U.S. DEPARTMENT OF ENERGY OR 
00053 # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
00054 # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
00055 # OR SERVICES;  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 
00056 # AND ON  ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
00057 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 
00058 # EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
00059 # <<END-copyright>>
00060 */
00061 #include <iostream>
00062 #include <string>
00063 #include <vector>
00064 #include <xData.h>
00065 #include <tpia_target.h>
00066 #include <tpia_misc.h>
00067 #include <string.h>
00068 #include "G4GIDI_Misc.hh"
00069 
00070 using namespace std;
00071 using namespace GIDI;
00072 
00073 /*
00074 ***************************************************************
00075 */
00076 char *G4GIDI_Misc_Z_A_m_ToName( int iZ, int iA, int im ) {
00077 
00078     const char *Z = tpia_misc_ZToSymbol( iZ );
00079     char S[128], mS[32], *name;
00080 
00081     if( Z == NULL ) return( NULL );
00082     if( iA == 0 ) {
00083         if( im != 0 ) return( NULL );
00084         sprintf( S, "%s_natural", Z ); }
00085     else {
00086         sprintf( S, "%s_%d", Z, iA );
00087         if( im != 0 ) {
00088             sprintf( mS, "_m%d", im );
00089             strcat( S, mS );
00090         }
00091     }
00092     name = (char *) xData_malloc2( NULL, strlen( S ) + 1, 0, "name" );
00093     if( name != NULL ) strcpy( name, S );
00094     return( name );
00095 }
00096 /*
00097 ***************************************************************
00098 */
00099 char *G4GIDI_Misc_channelCompound( char *particle1, char *particle2 ) {
00100 
00101     int Z1, A1, m1, Z2, A2, m2;
00102 
00103     if( tpia_miscNameToZAm( NULL, particle1, &Z1, &A1, &m1 ) ) return( NULL );
00104     if( tpia_miscNameToZAm( NULL, particle2, &Z2, &A2, &m2 ) ) return( NULL );
00105     if( A1 == 0 ) A2 = 0;
00106     if( A2 == 0 ) A1 = 0;
00107     return( G4GIDI_Misc_Z_A_m_ToName( Z1 + Z2, A1 + A2, 0 ) );
00108 }
00109 /*
00110 ***************************************************************
00111 */
00112 int G4GIDI_Misc_channelProductsCompare( tpia_channel *channel, int nProducts, char **productNames ) {
00113 
00114     int i;
00115     tpia_product *product;
00116 
00117     if( channel->decayChannel.numberOfProducts != nProducts ) return( 0 );
00118     for( product = tpia_channel_getFirstProduct( channel ), i = 0; product != NULL; product = tpia_decayChannel_getNextProduct( product ), i++ ) {
00119         if( strcmp( product->productID->name, productNames[i] ) ) return( 0 );
00120     }
00121     return( 1 );
00122 }
00123 /*
00124 ***************************************************************
00125 */
00126 //int getNamesOfAvailableTargets_walker( tpia_mapEntry *entry, int level, void *userData ) {
00127 int getNamesOfAvailableTargets_walker( tpia_mapEntry *entry, int , void *userData ) {
00128 
00129     vector<string> *listOfTargets = (vector<string> *) userData;
00130     vector<string>::iterator iter;
00131 
00132     if( entry->type != tpia_mapEntry_type_target ) return( 0 );
00133     for( iter = listOfTargets->begin( ); iter != listOfTargets->end( ); iter++ ) {
00134         if( entry->targetName == iter->c_str( ) ) return( 0 );
00135     }
00136     listOfTargets->push_back( entry->targetName );
00137     return( 0 );
00138 }

Generated on Mon May 27 17:48:23 2013 for Geant4 by  doxygen 1.4.7