source: trunk/source/processes/hadronic/models/chiral_inv_phase_space/interface/src/G4ChiralInvariantPhaseSpace.cc @ 1340

Last change on this file since 1340 was 1340, checked in by garnier, 14 years ago

update ti head

File size: 9.8 KB
Line 
1//
2// ********************************************************************
3// * License and Disclaimer                                           *
4// *                                                                  *
5// * The  Geant4 software  is  copyright of the Copyright Holders  of *
6// * the Geant4 Collaboration.  It is provided  under  the terms  and *
7// * conditions of the Geant4 Software License,  included in the file *
8// * LICENSE and available at  http://cern.ch/geant4/license .  These *
9// * include a list of copyright holders.                             *
10// *                                                                  *
11// * Neither the authors of this software system, nor their employing *
12// * institutes,nor the agencies providing financial support for this *
13// * work  make  any representation or  warranty, express or implied, *
14// * regarding  this  software system or assume any liability for its *
15// * use.  Please see the license in the file  LICENSE  and URL above *
16// * for the full disclaimer and the limitation of liability.         *
17// *                                                                  *
18// * This  code  implementation is the result of  the  scientific and *
19// * technical work of the GEANT4 collaboration.                      *
20// * By using,  copying,  modifying or  distributing the software (or *
21// * any work based  on the software)  you  agree  to acknowledge its *
22// * use  in  resulting  scientific  publications,  and indicate your *
23// * acceptance of all terms of the Geant4 Software license.          *
24// ********************************************************************
25//
26
27// Modified:
28// 24.08.10 A. Dotti (andrea.dotti@cern.ch) handle exceptions
29//          thrown by Q4QEnvironment::Fragment retying interaction
30// 17.06.10 A. Dotti (andrea.dotti@cern.ch) handle case in which
31//          Q4QEnvironment returns a 90000000 fragment (see code comments)
32
33// Created:
34// 16.01.08 V.Ivanchenko use initialization similar to other CHIPS models
35//
36
37#include "G4ChiralInvariantPhaseSpace.hh"
38#include "G4ParticleTable.hh"
39#include "G4LorentzVector.hh"
40#include "G4DynamicParticle.hh"
41#include "G4IonTable.hh"
42#include "G4Neutron.hh"
43#include "G4Gamma.hh"
44
45G4ChiralInvariantPhaseSpace::G4ChiralInvariantPhaseSpace()
46{}
47
48G4ChiralInvariantPhaseSpace::~G4ChiralInvariantPhaseSpace()
49{}
50
51G4HadFinalState * G4ChiralInvariantPhaseSpace::ApplyYourself(
52           const G4HadProjectile& aTrack, 
53           G4Nucleus& aTargetNucleus, 
54           G4HadFinalState * aChange)
55{
56  G4HadFinalState * aResult;
57  if(aChange != 0)
58  {
59    aResult = aChange;
60  }
61  else
62  {
63    aResult = & theResult;
64    aResult->Clear();
65    aResult->SetStatusChange(stopAndKill);
66  }
67  //projectile properties needed in constructor of quasmon
68  G4LorentzVector proj4Mom;
69  proj4Mom = aTrack.Get4Momentum();
70  G4int projectilePDGCode = aTrack.GetDefinition()
71                                  ->GetPDGEncoding();
72 
73  //target properties needed in constructor of quasmon
74  G4int targetZ = G4int(aTargetNucleus.GetZ()+0.5);
75  G4int targetA = G4int(aTargetNucleus.GetN()+0.5);
76  G4int targetPDGCode = 90000000 + 1000*targetZ + (targetA-targetZ);
77  // NOT NECESSARY ______________
78  G4double targetMass = G4ParticleTable::GetParticleTable()->GetIonTable()
79                                                           ->GetIonMass(targetZ, targetA);
80  G4LorentzVector targ4Mom(0.,0.,0.,targetMass); 
81  // END OF NOT NECESSARY^^^^^^^^
82
83  // V.Ivanchenko set the same value as for other CHIPS models
84  G4int nop = 152; 
85  //G4int nop = 164; // nuclear clusters up to A=21
86  G4double fractionOfSingleQuasiFreeNucleons = 0.4;
87  G4double fractionOfPairedQuasiFreeNucleons = 0.0;
88  if(targetA>27) fractionOfPairedQuasiFreeNucleons = 0.04;
89  G4double clusteringCoefficient = 4.;
90  G4double temperature = 180.;
91  G4double halfTheStrangenessOfSee = 0.1; // = s/d = s/u
92  G4double etaToEtaPrime = 0.3;
93 
94  // construct and fragment the quasmon
95  //G4QCHIPSWorld aWorld(nop);              // Create CHIPS World of nop particles
96  G4QCHIPSWorld::Get()->GetParticles(nop);  // Create CHIPS World of nop particles
97  G4QNucleus::SetParameters(fractionOfSingleQuasiFreeNucleons,
98                            fractionOfPairedQuasiFreeNucleons,
99                            clusteringCoefficient);
100  G4Quasmon::SetParameters(temperature,
101                           halfTheStrangenessOfSee,
102                           etaToEtaPrime);
103  //  G4QEnvironment::SetParameters(solidAngle);
104//  G4cout << "Input info "<< projectilePDGCode << " "
105//         << targetPDGCode <<" "
106//       << 1./MeV*proj4Mom<<" "
107//       << 1./MeV*targ4Mom << " "
108//       << nop << G4endl;
109  G4QHadronVector projHV;
110  G4QHadron* iH = new G4QHadron(projectilePDGCode, 1./MeV*proj4Mom);
111  projHV.push_back(iH);
112
113  //AND
114  //A. Dotti 24 Aug. : Trying to handle situation when G4QEnvironment::Fragment throws an exception
115  //                   Seen by ATLAS for gamma+Nuclear interaction for Gamma@2.4GeV on Al
116  //                   The poor-man solution here is to re-try interaction if a G4QException is catched
117  //                   Warning: G4QExcpetion does NOT inherit from base class G4HadException
118  G4QHadronVector* output=0;
119
120  bool retry=true;
121  int retryes=0;
122  int maxretries=10;
123
124  while ( retry && retryes < maxretries ) 
125    {
126      G4QEnvironment* pan= new G4QEnvironment(projHV, targetPDGCode);
127
128      try
129        {
130          ++retryes;
131          output = pan->Fragment();
132          retry=false;//If here, Fragment did not throw! (AND)
133        }
134      catch( ... )
135        {
136          G4cerr << "***WARNING*** Exception thrown passing through G4ChiralInvariantPhaseSpace "<<G4endl;
137          G4cerr << " targetPDGCode = "<< targetPDGCode <<G4endl;
138          G4cerr << " Dumping the information in the pojectile list"<<G4endl;
139          for(size_t i=0; i< projHV.size(); i++)
140            {
141              G4cerr <<"  Incoming 4-momentum and PDG code of "<<i<<"'th hadron: "
142                     <<" "<< projHV[i]->Get4Momentum()<<" "<<projHV[i]->GetPDGCode()<<G4endl;
143            }
144          G4cerr << "Retrying interaction "<<G4endl; //AND
145          //throw; //AND
146        }
147      delete pan;
148    } //AND
149  if ( retryes >= maxretries ) //AND
150    {
151      G4cerr << "***ERROR*** Maximum number of retries ("<<maxretries<<") reached for G4QEnvironment::Fragment(), exception is being thrown" << G4endl;
152      throw G4HadronicException(__FILE__,__LINE__,"G4ChiralInvariantPhaseSpace::ApplyYourself(...) - Maximum number of re-tries reached, abandon interaction");
153    }
154 
155  // Fill the particle change.
156  G4DynamicParticle * theSec;
157#ifdef CHIPSdebug
158  G4cout << "G4ChiralInvariantPhaseSpace: NEW EVENT #ofHadrons="
159         <<output->size()<<G4endl;
160#endif
161
162
163  unsigned int particle;
164  for( particle = 0; particle < output->size(); particle++)
165  {
166    if(output->operator[](particle)->GetNFragments() != 0) 
167    {
168      delete output->operator[](particle);
169      continue;
170    }
171    theSec = new G4DynamicParticle; 
172    G4int pdgCode = output->operator[](particle)->GetPDGCode();
173#ifdef CHIPSdebug
174    G4cout << "G4ChiralInvariantPhaseSpace: h#"<<particle
175           <<", PDG="<<pdgCode<<G4endl;
176#endif
177    G4ParticleDefinition * theDefinition;
178    // Note that I still have to take care of strange nuclei
179    // For this I need the mass calculation, and a changed interface
180    // for ion-tablel ==> work for Hisaya @@@@@@@
181    // Then I can sort out the pdgCode. I also need a decau process
182    // for strange nuclei; may be another chips interface
183    if(pdgCode>90000000) 
184    {
185      G4int aZ = (pdgCode-90000000)/1000;
186      G4int anN = pdgCode-90000000-1000*aZ;
187      theDefinition = G4ParticleTable::GetParticleTable()->FindIon(aZ,anN+aZ,0,aZ);
188      if(aZ == 0 && anN == 1) theDefinition = G4Neutron::Neutron();
189    }
190    //AND
191    else if ( pdgCode == 90000000 && output->operator[](particle)->Get4Momentum().m()<1*MeV )
192      {
193        //A. Dotti:
194        //We cure the case the model returns a (A,Z)=0,0 G4QHadron with a very small mass
195        //We convert this to a gamma. According to the author of the model this is the
196        //correct thing to do and it is done also in other parts of the CHIPS package
197        theDefinition = G4Gamma::Gamma();
198      }
199    //AND
200    else
201    {
202      theDefinition = G4ParticleTable::GetParticleTable()
203        ->FindParticle(output->operator[](particle)->GetPDGCode());
204    }
205
206    //AND
207    //A. Dotti: Handle problematic cases in which one of the products has not been recognized
208    //          This should never happen but we want to add an extra-protection
209    if ( theDefinition == NULL )
210      {
211        //If we arrived here something bad really happened. We do not know how to handle the products of the interaction, we give up, resetting the
212        //result and keeping the primary alive.
213        G4cerr<<"**WARNING*** G4ChiralInvariantPhaseSpace::ApplyYourself(...) : G4QEnvironment::Fragment() returns an invalid fragment\n with fourMom(MeV)=";
214        G4cerr<<output->operator[](particle)->Get4Momentum()<<" and mass(MeV)="<<output->operator[](particle)->Get4Momentum().m();
215        G4cerr<<". Offending PDG is:"<<pdgCode<<" abandon interaction. \n Taget PDG was:"<<targetPDGCode<<" \n Dumping the information in the projectile list:\n";
216        for(size_t i=0; i< projHV.size(); i++)
217          {
218            G4cerr <<" Incoming 4-momentum and PDG code of "<<i<<"'th hadron: "
219                 <<" "<< projHV[i]->Get4Momentum()<<" "<<projHV[i]->GetPDGCode()<<"\n";
220          }
221        G4cerr<<"\n Please report as bug \n***END OF MESSAGE***"<<G4endl;
222
223        for ( unsigned int cparticle=0 ; cparticle<output->size();++cparticle)
224          delete output->operator[](cparticle);
225        delete output;
226        std::for_each(projHV.begin(), projHV.end(), DeleteQHadron());
227        projHV.clear();
228
229        aResult->Clear();
230        aResult->SetStatusChange(isAlive);
231        aResult->SetEnergyChange(aTrack.GetKineticEnergy());
232        aResult->SetMomentumChange(aTrack.Get4Momentum().vect().unit());
233        return aResult;
234      }
235    //AND
236
237
238    theSec->SetDefinition(theDefinition);
239    theSec->SetMomentum(output->operator[](particle)->Get4Momentum().vect());
240    aResult->AddSecondary(theSec); 
241    delete output->operator[](particle);
242  }
243  delete output;
244  std::for_each(projHV.begin(), projHV.end(), DeleteQHadron());
245  projHV.clear();
246  return aResult;
247}
248
Note: See TracBrowser for help on using the repository browser.