G4ProjectileDiffractiveChannel.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 // $Id$
00028 //
00029 
00030 // Author : Gunter Folger Nov 2007
00031 // Class Description
00032 // Final state production model for theoretical models of hadron inelastic
00033 // projectile diffractive scattering in geant4;
00034 // Class Description - End
00035 //
00036 // Modified:
00037 
00038 #include "G4ProjectileDiffractiveChannel.hh"
00039 
00040 #include "G4HadTmpUtil.hh"              //lrint
00041 #include "G4QHadronVector.hh"
00042 #include "G4ParticleTable.hh"
00043 #include "G4IonTable.hh"
00044 #include "G4Lambda.hh"
00045 
00046 //#define debug_getFraction 1
00047 //#define debug_scatter 1
00048 
00049 G4ProjectileDiffractiveChannel::G4ProjectileDiffractiveChannel()
00050 {
00051         theQDiffraction=G4QDiffractionRatio::GetPointer();
00052 }
00053 
00054 G4ProjectileDiffractiveChannel::~G4ProjectileDiffractiveChannel()
00055 {}
00056 
00057 G4double G4ProjectileDiffractiveChannel::GetFraction(G4Nucleus &theNucleus,
00058                                 const G4DynamicParticle & thePrimary)
00059 {
00060         G4double ratio;
00061         ratio=theQDiffraction->GetRatio(thePrimary.GetTotalMomentum(),
00062                         thePrimary.GetDefinition()->GetPDGEncoding(),
00063                         theNucleus.GetZ_asInt(), theNucleus.GetN_asInt() );
00064            #ifdef debug_getFraction                     
00065               G4cout << "G4ProjectileDiffractiveChannel::ratio " << ratio << G4endl;
00066            #endif
00067                
00068         return ratio;                   
00069 }
00070 
00071 G4KineticTrackVector * G4ProjectileDiffractiveChannel::Scatter(G4Nucleus &theNucleus,
00072                                         const G4DynamicParticle & thePrimary)
00073 {
00074         
00075         
00076         G4int A=theNucleus.GetA_asInt();
00077         G4int Z=theNucleus.GetZ_asInt();
00078 
00079         G4ParticleDefinition * pDef=thePrimary.GetDefinition();
00080            #ifdef debug_scatter
00081              G4cout << " ProjectileDiffractive: A, Z,  proj-pdg" <<" "<< A <<" "<<Z 
00082                         << " "<<" " << pDef->GetParticleName()<< G4endl;
00083            #endif
00084         
00085         G4QHadronVector * result(0);
00086         G4KineticTrackVector * ktv(0);
00087         G4bool tryAgain;
00088         
00089         do {
00090            tryAgain = false;
00091            result=theQDiffraction->ProjFragment(pDef->GetPDGEncoding(),
00092                                 thePrimary.Get4Momentum(),Z, A-Z);
00093                                 
00094            if ( result && result->size() > 0 )
00095            {
00096                ktv=new G4KineticTrackVector();
00097                std::vector<G4QHadron *>::iterator i;
00098                  #ifdef debug_scatter
00099                     G4int count(0);
00100                  #endif
00101                for (i=result->begin(); i!=result->end(); i++)
00102                {
00103                   G4int pdgCode=(*i)->GetPDGCode();
00104                   G4ParticleDefinition * secDef(0);
00105                   if ( pdgCode < 80000000) {     // check if ion; should be 90Million, but 89Million is possible
00106                       secDef= G4ParticleTable::GetParticleTable()->FindParticle(pdgCode);
00107                   }else {
00108                       G4int qN = pdgCode % 1000;
00109                       G4int qZ = (pdgCode/1000) %1000;
00110                       if ( qZ < 500 && qN < 500){   // protect for delta being coded as/in nucleus 
00111                          secDef = G4ParticleTable::GetParticleTable()->GetIon(qZ,qN+qZ, 0);
00112                          if ( ! secDef ) 
00113                          {  // exceptions to the rule!
00114                             if ( pdgCode == 90000001 ) secDef= G4Neutron::Neutron();
00115                             if ( pdgCode == 91000000 ) secDef= G4Lambda::Lambda();
00116                          }
00117                       }   
00118                   }
00119                   
00120                   if  ( secDef ){
00121 
00122                       G4ThreeVector pos=(*i)->GetPosition();  //GetPosition returns const &
00123                       G4LorentzVector mom=(*i)->Get4Momentum();
00124 
00125                       G4KineticTrack * sPrim=new G4KineticTrack(secDef,
00126                                       (*i)->GetFormationTime(), pos, mom);
00127                       ktv->push_back(sPrim);
00128 
00129                         #ifdef debug_scatter
00130                           G4cout << "G4ProjectileDiffractive sec # "  << ++count << ", "
00131                             << "ChipsPDGCode=" << pdgCode << ", "
00132                             << secDef->GetParticleName() 
00133                             << ", time(ns) " << (*i)->GetFormationTime()/ns
00134                             << ", pos " << pos
00135                             << ", 4mom " << (*i)->Get4Momentum()
00136                             << G4endl;
00137                         #endif
00138                    } else {
00139                        #ifdef debug_scatter
00140                          G4cout << "G4ProjectileDiffractiveChannel: Particle with PDG code "<< pdgCode <<" does not converted!!!"<<G4endl;
00141                        #endif 
00142                        tryAgain=true;
00143                    }
00144                }   
00145                std::for_each(result->begin(), result->end(), DeleteQHadron());
00146                delete result;
00147                result=0;
00148            }
00149             
00150            if ( result ) delete result;
00151            if ( tryAgain ) {     // QDiffraction returned a "difficult" particle in nucleus
00152                std::for_each(ktv->begin(), ktv->end(), DeleteKineticTrack());
00153                delete ktv;
00154                ktv=0;
00155            }
00156         } while ( ! ktv);          
00157 
00158         return ktv;                            
00159 }

Generated on Mon May 27 17:49:26 2013 for Geant4 by  doxygen 1.4.7