source: trunk/source/processes/hadronic/models/parton_string/diffraction/src/G4FTFModel.cc @ 962

Last change on this file since 962 was 962, checked in by garnier, 15 years ago

update processes

File size: 10.5 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// $Id: G4FTFModel.cc,v 1.13 2008/12/09 10:40:52 vuzhinsk Exp $
28// GEANT4 tag $Name: geant4-09-02-ref-02 $
29//
30
31// ------------------------------------------------------------
32//      GEANT 4 class implementation file
33//
34//      ---------------- G4FTFModel ----------------
35//             by Gunter Folger, May 1998.
36//       class implementing the excitation in the FTF Parton String Model
37// ------------------------------------------------------------
38
39#include "G4FTFModel.hh"
40#include "G4FTFParameters.hh"                            // Uzhi 29.03.08
41#include "G4FTFParticipants.hh"
42#include "G4InteractionContent.hh"
43#include "G4LorentzRotation.hh"
44#include "G4ParticleDefinition.hh"
45#include "G4ios.hh"
46#include <utility>                                        // Uzhi 29.03.08
47
48// Class G4FTFModel
49
50G4FTFModel::G4FTFModel():theExcitation(new G4DiffractiveExcitation()),
51                         theElastic(new G4ElasticHNScattering()) // Uzhi 29.03.08
52{
53        G4VPartonStringModel::SetThisPointer(this);
54        theParameters=0;                                         // Uzhi 9.12.08
55}
56
57/*
58G4FTFModel::G4FTFModel(G4double , G4double , G4double ):theExcitation(new // Uzhi 9.12.08 G4DiffractiveExcitation())
59{
60        G4VPartonStringModel::SetThisPointer(this);
61}
62
63G4FTFModel::G4FTFModel(G4DiffractiveExcitation * anExcitation)
64:
65theExcitation(anExcitation)
66{
67        G4VPartonStringModel::SetThisPointer(this);
68}
69*/
70
71
72G4FTFModel::~G4FTFModel()
73{
74   if( theParameters != 0 ) delete theParameters;             // Uzhi 5.12.08
75// Because FTF model can be called for various particles
76// theParameters must be erased at the end of each call.
77// Thus the delete is olso in G4FTFModel::GetStrings() method
78   if( theExcitation != 0 ) delete theExcitation;             // Uzhi 5.12.08
79   if( theElastic    != 0 ) delete theElastic;                // Uzhi 5.12.08
80}
81
82
83const G4FTFModel & G4FTFModel::operator=(const G4FTFModel &)
84{
85        throw G4HadronicException(__FILE__, __LINE__, "G4FTFModel::operator= is not meant to be accessed ");
86        return *this;
87}
88
89
90int G4FTFModel::operator==(const G4FTFModel &right) const
91{
92        return this==&right;
93}
94
95int G4FTFModel::operator!=(const G4FTFModel &right) const
96{
97        return this!=&right;
98}
99
100// ------------------------------------------------------------
101void G4FTFModel::Init(const G4Nucleus & aNucleus, const G4DynamicParticle & aProjectile)
102{
103        theProjectile = aProjectile; 
104//G4cout<<"G4FTFModel::Init "<<aNucleus.GetN()<<" "<<aNucleus.GetZ()<<G4endl;
105        theParticipants.Init(aNucleus.GetN(),aNucleus.GetZ()); 
106// Uzhi N-mass number Z-charge ------------------------- Uzhi 29.03.08
107
108// --- cms energy
109
110        G4double s = sqr( theProjectile.GetMass() ) +
111                     sqr( G4Proton::Proton()->GetPDGMass() ) +
112                     2*theProjectile.GetTotalEnergy()*G4Proton::Proton()->GetPDGMass();
113/*
114G4cout << " primary Total E (GeV): " << theProjectile.GetTotalEnergy()/GeV << G4endl;
115G4cout << " primary Mass    (GeV): " << theProjectile.GetMass() /GeV << G4endl;
116G4cout << "cms std::sqrt(s) (GeV) = " << std::sqrt(s) / GeV << G4endl;
117*/
118
119      if( theParameters != 0 ) delete theParameters;                    // Uzhi 9.12.08
120      theParameters = new G4FTFParameters(theProjectile.GetDefinition(),
121                                          aNucleus.GetN(),aNucleus.GetZ(),
122                                          s);// ------------------------- Uzhi 19.04.08
123//theParameters->SetProbabilityOfElasticScatt(0.); // To turn on/off (1/0) elastic scattering
124}
125
126// ------------------------------------------------------------
127G4ExcitedStringVector * G4FTFModel::GetStrings()
128{
129//G4cout<<"theParticipants.GetList"<<G4endl;
130        theParticipants.GetList(theProjectile,theParameters);
131//G4cout<<"ExciteParticipants()"<<G4endl;
132        if (! ExciteParticipants()) return NULL;;
133//G4cout<<"theStrings = BuildStrings()"<<G4endl;
134        G4ExcitedStringVector * theStrings = BuildStrings();
135//G4cout<<"Return to theStrings "<<G4endl;
136        if( theParameters != 0 )                              // Uzhi 9.12.08
137        {                                                     // Uzhi 9.12.08
138          delete theParameters;                               // Uzhi 9.12.08
139          theParameters=0;                                    // Uzhi 9.12.08
140        }                                                     // Uzhi 9.12.08
141        return theStrings;
142}
143
144// ------------------------------------------------------------
145struct DeleteVSplitableHadron { void operator()(G4VSplitableHadron * aH){delete aH;} };
146
147// ------------------------------------------------------------
148G4bool G4FTFModel::ExciteParticipants()
149{
150/*    // Uzhi 29.03.08                     For elastic Scatt.
151G4cout<<"  In ExciteParticipants() "<<theParticipants.theInteractions.size()<<G4endl;
152G4cout<<" test Params Tot "<<theParameters->GetTotalCrossSection()<<G4endl;
153G4cout<<" test Params Ela "<<theParameters->GetElasticCrossSection()<<G4endl;
154       
155G4int counter=0;
156*/   // Uzhi 29.03.08
157
158
159
160        while (theParticipants.Next())
161        {         
162           const G4InteractionContent & collision=theParticipants.GetInteraction();
163/*
164counter++;
165G4cout<<" Inter # "<<counter<<G4endl;
166*/
167           G4VSplitableHadron * projectile=collision.GetProjectile();
168           G4VSplitableHadron * target=collision.GetTarget();
169
170//   // Uzhi 29.03.08
171           G4bool Successfull;
172           if(G4UniformRand()< theParameters->GetProbabilityOfElasticScatt())
173           {
174//G4cout<<"Elastic"<<G4endl;
175            Successfull=theElastic->ElasticScattering(projectile, target, theParameters);
176           }
177           else
178           {
179//G4cout<<"Inelastic"<<G4endl;
180            Successfull=theExcitation->ExciteParticipants(projectile, target, theParameters);
181           }
182//           if(!Successfull)
183// // Uzhi 29.03.08
184
185//         if ( ! theExcitation->ExciteParticipants(projectile, target) )
186           if(!Successfull)
187           {
188//           give up, clean up
189                std::vector<G4VSplitableHadron *> primaries;
190                std::vector<G4VSplitableHadron *> targets;
191                theParticipants.StartLoop();    // restart a loop
192                while ( theParticipants.Next() ) 
193                {
194                    const G4InteractionContent & interaction=theParticipants.GetInteraction();
195                         //  do not allow for duplicates ...
196                    if ( primaries.end() == std::find(primaries.begin(), primaries.end(),
197                                                      interaction.GetProjectile()) )
198                        primaries.push_back(interaction.GetProjectile());
199
200                    if ( targets.end()   == std::find(targets.begin(), targets.end(),
201                                                      interaction.GetTarget()) ) 
202                        targets.push_back(interaction.GetTarget());
203                }
204                std::for_each(primaries.begin(), primaries.end(), DeleteVSplitableHadron());
205                primaries.clear();
206                std::for_each(targets.begin(), targets.end(), DeleteVSplitableHadron());
207                targets.clear();
208
209                return false;
210           }  // End of the loop Uzhi
211        }
212        return true;
213}
214// ------------------------------------------------------------
215G4ExcitedStringVector * G4FTFModel::BuildStrings()
216{       
217// Loop over all collisions; find all primaries, and all target ( targets may
218//  be duplicate in the List ( to unique G4VSplitableHadrons)
219
220        G4ExcitedStringVector * strings;
221        strings = new G4ExcitedStringVector();
222       
223        std::vector<G4VSplitableHadron *> primaries;
224        std::vector<G4VSplitableHadron *> targets;
225       
226        theParticipants.StartLoop();    // restart a loop
227        while ( theParticipants.Next() ) 
228        {
229            const G4InteractionContent & interaction=theParticipants.GetInteraction();
230                 //  do not allow for duplicates ...
231            if ( primaries.end() == std::find(primaries.begin(), primaries.end(),
232                                                interaction.GetProjectile()) )
233                primaries.push_back(interaction.GetProjectile());
234               
235            if ( targets.end()   == std::find(targets.begin(), targets.end(),
236                                                interaction.GetTarget()) ) 
237                targets.push_back(interaction.GetTarget());
238        }
239           
240       
241//      G4cout << "BuildStrings prim/targ " << primaries.size() << " , " <<
242//                                             targets.size() << G4endl;
243
244        unsigned int ahadron;
245// Only for hA-interactions Uzhi -------------------------------------
246        for ( ahadron=0; ahadron < primaries.size() ; ahadron++)
247        {
248//G4ThreeVector aPosition=primaries[ahadron]->GetPosition();
249//G4cout<<"Proj Build "<<aPosition<<" "<<primaries[ahadron]->GetTimeOfCreation()<<G4endl;
250            G4bool isProjectile=true;
251            strings->push_back(theExcitation->String(primaries[ahadron], isProjectile));
252        }
253
254        for ( ahadron=0; ahadron < targets.size() ; ahadron++)
255        {
256//G4ThreeVector aPosition=targets[ahadron]->GetPosition();
257//G4cout<<"Targ Build "<<aPosition<<" "<<targets[ahadron]->GetTimeOfCreation()<<G4endl;
258            G4bool isProjectile=false;
259            strings->push_back(theExcitation->String(targets[ahadron], isProjectile));
260        }
261
262        std::for_each(primaries.begin(), primaries.end(), DeleteVSplitableHadron());
263        primaries.clear();
264        std::for_each(targets.begin(), targets.end(), DeleteVSplitableHadron());
265        targets.clear();
266       
267        return strings;
268}
269// ------------------------------------------------------------
Note: See TracBrowser for help on using the repository browser.