Geant4 Cross Reference

Cross-Referencing   Geant4
Geant4/processes/hadronic/models/parton_string/hadronization/src/G4ExcitedStringDecay.cc

Version: [ ReleaseNotes ] [ 1.0 ] [ 1.1 ] [ 2.0 ] [ 3.0 ] [ 3.1 ] [ 3.2 ] [ 4.0 ] [ 4.0.p1 ] [ 4.0.p2 ] [ 4.1 ] [ 4.1.p1 ] [ 5.0 ] [ 5.0.p1 ] [ 5.1 ] [ 5.1.p1 ] [ 5.2 ] [ 5.2.p1 ] [ 5.2.p2 ] [ 6.0 ] [ 6.0.p1 ] [ 6.1 ] [ 6.2 ] [ 6.2.p1 ] [ 6.2.p2 ] [ 7.0 ] [ 7.0.p1 ] [ 7.1 ] [ 7.1.p1 ] [ 8.0 ] [ 8.0.p1 ] [ 8.1 ] [ 8.1.p1 ] [ 8.1.p2 ] [ 8.2 ] [ 8.2.p1 ] [ 8.3 ] [ 8.3.p1 ] [ 8.3.p2 ] [ 9.0 ] [ 9.0.p1 ] [ 9.0.p2 ] [ 9.1 ] [ 9.1.p1 ] [ 9.1.p2 ] [ 9.1.p3 ] [ 9.2 ] [ 9.2.p1 ] [ 9.2.p2 ] [ 9.2.p3 ] [ 9.2.p4 ] [ 9.3 ] [ 9.3.p1 ] [ 9.3.p2 ] [ 9.4 ] [ 9.4.p1 ] [ 9.4.p2 ] [ 9.4.p3 ] [ 9.4.p4 ] [ 9.5 ] [ 9.5.p1 ] [ 9.5.p2 ] [ 9.6 ] [ 9.6.p1 ] [ 9.6.p2 ] [ 9.6.p3 ] [ 9.6.p4 ] [ 10.0 ] [ 10.0.p1 ] [ 10.0.p2 ] [ 10.0.p3 ] [ 10.0.p4 ] [ 10.1 ] [ 10.1.p1 ] [ 10.1.p2 ] [ 10.1.p3 ] [ 10.2 ] [ 10.2.p1 ] [ 10.2.p2 ] [ 10.2.p3 ] [ 10.3 ] [ 10.3.p1 ] [ 10.3.p2 ] [ 10.3.p3 ] [ 10.4 ] [ 10.4.p1 ] [ 10.4.p2 ] [ 10.4.p3 ] [ 10.5 ] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

Diff markup

Differences between /processes/hadronic/models/parton_string/hadronization/src/G4ExcitedStringDecay.cc (Version 11.3.0) and /processes/hadronic/models/parton_string/hadronization/src/G4ExcitedStringDecay.cc (Version 10.0.p3)


  1 //                                                  1 //
  2 // *******************************************      2 // ********************************************************************
  3 // * License and Disclaimer                         3 // * License and Disclaimer                                           *
  4 // *                                                4 // *                                                                  *
  5 // * The  Geant4 software  is  copyright of th      5 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
  6 // * the Geant4 Collaboration.  It is provided      6 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
  7 // * conditions of the Geant4 Software License      7 // * conditions of the Geant4 Software License,  included in the file *
  8 // * LICENSE and available at  http://cern.ch/      8 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
  9 // * include a list of copyright holders.           9 // * include a list of copyright holders.                             *
 10 // *                                               10 // *                                                                  *
 11 // * Neither the authors of this software syst     11 // * Neither the authors of this software system, nor their employing *
 12 // * institutes,nor the agencies providing fin     12 // * institutes,nor the agencies providing financial support for this *
 13 // * work  make  any representation or  warran     13 // * work  make  any representation or  warranty, express or implied, *
 14 // * regarding  this  software system or assum     14 // * regarding  this  software system or assume any liability for its *
 15 // * use.  Please see the license in the file      15 // * use.  Please see the license in the file  LICENSE  and URL above *
 16 // * for the full disclaimer and the limitatio     16 // * for the full disclaimer and the limitation of liability.         *
 17 // *                                               17 // *                                                                  *
 18 // * This  code  implementation is the result      18 // * This  code  implementation is the result of  the  scientific and *
 19 // * technical work of the GEANT4 collaboratio     19 // * technical work of the GEANT4 collaboration.                      *
 20 // * By using,  copying,  modifying or  distri     20 // * By using,  copying,  modifying or  distributing the software (or *
 21 // * any work based  on the software)  you  ag     21 // * any work based  on the software)  you  agree  to acknowledge its *
 22 // * use  in  resulting  scientific  publicati     22 // * use  in  resulting  scientific  publications,  and indicate your *
 23 // * acceptance of all terms of the Geant4 Sof     23 // * acceptance of all terms of the Geant4 Software license.          *
 24 // *******************************************     24 // ********************************************************************
 25 //                                                 25 //
 26 // Historic fragment from M.Komogorov; clean-u     26 // Historic fragment from M.Komogorov; clean-up still necessary @@@
 27                                                    27 
 28 #include "G4ExcitedStringDecay.hh"                 28 #include "G4ExcitedStringDecay.hh"
 29 #include "G4SystemOfUnits.hh"                      29 #include "G4SystemOfUnits.hh"
 30 #include "G4KineticTrack.hh"                       30 #include "G4KineticTrack.hh"
 31 #include "G4LundStringFragmentation.hh"        << 
 32 #include "G4HadronicInteractionRegistry.hh"    << 
 33                                                    31 
 34 #include "G4SampleResonance.hh"                <<  32 G4ExcitedStringDecay::G4ExcitedStringDecay() : G4VStringFragmentation(),
                                                   >>  33   theStringDecay(0)
                                                   >>  34 {}
 35                                                    35 
 36 //#define debug_G4ExcitedStringDecay           <<  36 G4ExcitedStringDecay::G4ExcitedStringDecay(G4VLongitudinalStringDecay * aStringDecay)
 37 //#define debug_G4ExcitedStringCorr            <<  37 : G4VStringFragmentation(),
                                                   >>  38   theStringDecay(aStringDecay)
                                                   >>  39 {}
 38                                                    40 
 39 G4ExcitedStringDecay::G4ExcitedStringDecay(G4V <<  41 G4ExcitedStringDecay::G4ExcitedStringDecay(const G4ExcitedStringDecay &)
 40   : G4VStringFragmentation(), theStringDecay(p <<  42 : G4VStringFragmentation(),
                                                   >>  43   theStringDecay(0)
 41 {                                                  44 {
 42   if(!ptr) {                                   <<  45   throw G4HadronicException(__FILE__, __LINE__, "G4ExcitedStringDecay::copy ctor not accessible");
 43     G4HadronicInteraction* p =                 <<  46 } 
 44       G4HadronicInteractionRegistry::Instance( << 
 45     theStringDecay = static_cast<G4VLongitudin << 
 46     if(!theStringDecay) { theStringDecay = new << 
 47   }                                            << 
 48   SetModelName(theStringDecay->GetModelName()) << 
 49 }                                              << 
 50                                                    47 
 51 G4ExcitedStringDecay::~G4ExcitedStringDecay()      48 G4ExcitedStringDecay::~G4ExcitedStringDecay()
 52 {}                                             <<  49 {
                                                   >>  50 }
 53                                                    51 
 54 G4KineticTrackVector *G4ExcitedStringDecay::Fr <<  52 const G4ExcitedStringDecay & G4ExcitedStringDecay::operator=(const G4ExcitedStringDecay &)
 55 {                                                  53 {
 56   return theStringDecay->FragmentString(theStr <<  54   throw G4HadronicException(__FILE__, __LINE__, "G4ExcitedStringDecay::operator= meant to not be accessable");
                                                   >>  55   return *this;
 57 }                                                  56 }
 58                                                    57 
 59 G4KineticTrackVector *G4ExcitedStringDecay::Fr <<  58 int G4ExcitedStringDecay::operator==(const G4ExcitedStringDecay &) const
 60 {                                                  59 {
 61   G4LorentzVector KTsum(0.,0.,0.,0.);          <<  60   return 0;
                                                   >>  61 }
 62                                                    62 
 63   #ifdef debug_G4ExcitedStringDecay            <<  63 int G4ExcitedStringDecay::operator!=(const G4ExcitedStringDecay &) const
 64   G4cout<<G4endl;                              <<  64 {
 65   G4cout<<"--------------------------- G4Excit <<  65   return 1;
 66   G4cout<<"Hadronization of Excited Strings: t <<  66 }
 67   #endif                                       << 
 68                                                    67 
 69   for ( unsigned int astring=0; astring < theS <<  68 G4KineticTrackVector *G4ExcitedStringDecay::FragmentString
 70   // for ( unsigned int astring=0; astring < 1 <<  69         (const G4ExcitedString &theString)
 71   {                                            <<  70 {
 72     // G4cout<<"theStrings->operator[](astring <<  71   if ( theStringDecay == NULL ) 
 73     if ( theStrings->operator[](astring)->IsEx << 
 74          {KTsum+= theStrings->operator[](astri << 
 75     else {KTsum+=theStrings->operator[](astrin << 
 76   }                                            << 
 77                                                    72 
 78   G4LorentzRotation toCms( -1 * KTsum.boostVec <<  73       theStringDecay=new G4LundStringFragmentation();
 79   G4LorentzRotation toLab(toCms.inverse());    <<  74     
 80   G4LorentzVector Ptmp;                        <<  75   return theStringDecay->FragmentString(theString);
 81   KTsum=G4LorentzVector(0.,0.,0.,0.);          <<  76 }
                                                   >>  77   
                                                   >>  78 G4KineticTrackVector *G4ExcitedStringDecay::FragmentStrings
                                                   >>  79         (const G4ExcitedStringVector * theStrings)
                                                   >>  80 {
                                                   >>  81   G4LorentzVector KTsum(0.,0.,0.,0.);
 82                                                    82 
                                                   >>  83 //G4cout<<"theStrings->size() "<<theStrings->size()<<G4endl;
 83   for ( unsigned int astring=0; astring < theS     84   for ( unsigned int astring=0; astring < theStrings->size(); astring++)
 84   // for ( unsigned int astring=0; astring < 1 << 
 85   {                                                85   {
 86     if ( theStrings->operator[](astring)->IsEx <<  86   KTsum+= theStrings->operator[](astring)->Get4Momentum();
 87     {                                          << 
 88       Ptmp=toCms * theStrings->operator[](astr << 
 89       theStrings->operator[](astring)->GetLeft << 
 90                                                << 
 91       Ptmp=toCms * theStrings->operator[](astr << 
 92       theStrings->operator[](astring)->GetRigh << 
 93                                                << 
 94       KTsum+= theStrings->operator[](astring)- << 
 95     }                                          << 
 96     else                                       << 
 97     {                                          << 
 98       Ptmp=toCms * theStrings->operator[](astr << 
 99       theStrings->operator[](astring)->GetKine << 
100       KTsum+= theStrings->operator[](astring)- << 
101     }                                          << 
102   }                                                87   }
103                                                    88 
104   G4SampleResonance BrW;                       << 
105   const G4ParticleDefinition* TrackDefinition= << 
106                                                << 
107   G4KineticTrackVector * theResult = new G4Kin     89   G4KineticTrackVector * theResult = new G4KineticTrackVector;
108   G4int attempts(0);                               90   G4int attempts(0);
109   G4bool success=false;                            91   G4bool success=false;
110   G4bool NeedEnergyCorrector=false;                92   G4bool NeedEnergyCorrector=false;
111   do {                                             93   do {
112         #ifdef debug_G4ExcitedStringDecay      <<  94        //G4cout<<"Check of momentum at string fragmentations. New try."<<G4endl;
113         G4cout<<"New try No "<<attempts<<" to  << 
114         #endif                                 << 
115                                                << 
116   std::for_each(theResult->begin() , theResult     95   std::for_each(theResult->begin() , theResult->end() , DeleteKineticTrack());
117   theResult->clear();                              96   theResult->clear();
118                                                    97 
119   attempts++;                                      98   attempts++;
120                                                <<  99         //G4cout<<G4endl<<"attempts "<<attempts<<G4endl;
121   G4LorentzVector KTsecondaries(0.,0.,0.,0.);     100   G4LorentzVector KTsecondaries(0.,0.,0.,0.);
122   NeedEnergyCorrector=false;                      101   NeedEnergyCorrector=false;
123                                                   102 
124   for ( unsigned int astring=0; astring < theS    103   for ( unsigned int astring=0; astring < theStrings->size(); astring++)
125         // for ( unsigned int astring=0; astri << 
126         // for ( unsigned int astring=1; astri << 
127         // for ( unsigned int astring=0; astri << 
128   {                                               104   {
129           #ifdef debug_G4ExcitedStringDecay    << 105           //G4cout<<"String No "<<astring+1<<" "<<theStrings->operator[](astring)->Get4Momentum().mag2()<<" "<<theStrings->operator[](astring)->GetRightParton()->GetPDGcode()<<" "<<theStrings->operator[](astring)->GetLeftParton()->GetPDGcode()<<" "<<theStrings->operator[](astring)->Get4Momentum()<<G4endl;
130           G4cout<<"String No "<<astring+1<<" E << 106           //G4int Uzhi; G4cin >>Uzhi;
131                                                << 
132           G4cout<<"String No "<<astring+1<<" 4 << 
133           <<" "<<theStrings->operator[](astrin << 
134           #endif                               << 
135                                                << 
136           G4KineticTrackVector * generatedKine    107           G4KineticTrackVector * generatedKineticTracks = NULL;
137     if ( theStrings->operator[](astring)->IsEx    108     if ( theStrings->operator[](astring)->IsExcited() )
138     {                                             109     {
139              #ifdef debug_G4ExcitedStringDecay << 110            //G4cout<<"Fragment String"<<G4endl;
140              G4cout<<"Fragment String with par << 
141                    <<theStrings->operator[](as << 
142                    <<theStrings->operator[](as << 
143                    <<"Direction "<<theStrings- << 
144              #endif                            << 
145          generatedKineticTracks=FragmentString    111          generatedKineticTracks=FragmentString(*theStrings->operator[](astring));
146              #ifdef debug_G4ExcitedStringDecay << 
147              G4cout<<"(G4ExcitedStringDecay) N << 
148                    <<generatedKineticTracks->s << 
149              #endif                            << 
150     } else {                                      112     } else {
151              #ifdef debug_G4ExcitedStringDecay << 
152              G4cout<<"   GetTrack from the Str << 
153              #endif                            << 
154              G4LorentzVector Mom=theStrings->o << 
155              G4KineticTrack * aTrack= new G4Ki << 
156                             theStrings->operat << 
157                             theStrings->operat << 
158                             G4ThreeVector(0),  << 
159                                                << 
160              aTrack->SetPosition(theStrings->o << 
161                                                << 
162              #ifdef debug_G4ExcitedStringDecay << 
163              G4cout<<"   A particle stored in  << 
164              #endif                            << 
165                                                << 
166        generatedKineticTracks = new G4KineticT    113        generatedKineticTracks = new G4KineticTrackVector;
167        generatedKineticTracks->push_back(aTrac << 114        generatedKineticTracks->push_back(theStrings->operator[](astring)->GetKineticTrack());
168     }                                             115     }    
169                                                   116 
170     if (generatedKineticTracks == nullptr || g << 117     if (generatedKineticTracks == NULL) 
171     {                                             118     {
172              // G4cerr << "G4VPartonStringMode << 119        G4cerr << "G4VPartonStringModel:No KineticTracks produced" << G4endl;
173        delete generatedKineticTracks;          << 120        continue;
174        generatedKineticTracks = nullptr;       << 
175              continue;                         << 
176     }                                             121     }
177                                                   122 
178           G4LorentzVector KTsum1(0.,0.,0.,0.);    123           G4LorentzVector KTsum1(0.,0.,0.,0.);
179           for ( unsigned int aTrack=0; aTrack<    124           for ( unsigned int aTrack=0; aTrack<generatedKineticTracks->size();aTrack++)
180     {                                             125     {
181              #ifdef debug_G4ExcitedStringDecay << 126             //--debug-- G4cout<<"Prod part "<<(*generatedKineticTracks)[aTrack]->GetDefinition()->GetParticleName()<<" "<<(*generatedKineticTracks)[aTrack]->Get4Momentum()<<G4endl;
182              G4cout<<"Prod part No. "<<aTrack+ << 
183                    <<(*generatedKineticTracks) << 
184                    <<(*generatedKineticTracks) << 
185                    <<(*generatedKineticTracks) << 
186              #endif                            << 
187              // --------------- Sampling mass  << 
188              TrackDefinition = (*generatedKine << 
189                                                << 
190        if (TrackDefinition->IsShortLived())    << 
191              {                                 << 
192                G4double NewTrackMass =         << 
193                  BrW.SampleMass( TrackDefiniti << 
194                                  BrW.GetMinimu << 
195                                  TrackDefiniti << 
196                G4LorentzVector Tmp=G4LorentzVe << 
197                Tmp.setE(std::sqrt(sqr(NewTrack << 
198                                                << 
199                (*generatedKineticTracks)[aTrac << 
200                                                << 
201                #ifdef debug_G4ExcitedStringDec << 
202                G4cout<<"Resonance *** "<<aTrac << 
203                      <<(*generatedKineticTrack << 
204                      <<(*generatedKineticTrack << 
205                      <<(*generatedKineticTrack << 
206                #endif                          << 
207            }                                   << 
208              //------------------------------- << 
209                                                << 
210              theResult->push_back(generatedKin    127              theResult->push_back(generatedKineticTracks->operator[](aTrack));
211              KTsum1+= (*generatedKineticTracks    128              KTsum1+= (*generatedKineticTracks)[aTrack]->Get4Momentum();
212     }                                             129     }
213     KTsecondaries+=KTsum1;                        130     KTsecondaries+=KTsum1;
214                                                   131   
215           #ifdef debug_G4ExcitedStringDecay    << 132         //--debug--G4cout << "String secondaries(" <<generatedKineticTracks->size()<< ")  momentum: "
216           G4cout << "String secondaries(" <<ge << 133         //--debug--<< theStrings->operator[](astring)->Get4Momentum() << " " << KTsum1 << G4endl;
217                  <<"Init  string  momentum: "< << 134     if  ( KTsum1.e() > 0 && std::abs((KTsum1.e()-theStrings->operator[](astring)->Get4Momentum().e()) / KTsum1.e()) > perMillion )
218                  <<"Final hadrons momentum: "< << 
219           #endif                               << 
220                                                << 
221     if  ( KTsum1.e() > 0 &&                    << 
222                 std::abs((KTsum1.e()-theString << 
223     {                                             135     {
                                                   >> 136       //--debug--  G4cout << "String secondaries(" <<generatedKineticTracks->size()<< ")  momentum: "
                                                   >> 137       //--debug--    << theStrings->operator[](astring)->Get4Momentum() << " " << KTsum1 << G4endl;
224       NeedEnergyCorrector=true;                   138       NeedEnergyCorrector=true;
225     }                                             139     }
226                                                   140 
227           #ifdef debug_G4ExcitedStringDecay    << 141 //        clean up
228           G4cout<<"NeedEnergyCorrection yes/no << 
229           #endif                               << 
230                                                << 
231           // clean up                          << 
232     delete generatedKineticTracks;                142     delete generatedKineticTracks;
233     success=true;                              << 
234   }                                               143   }
                                                   >> 144        //--debug  G4cout << "Initial Strings / secondaries total  4 momentum " << KTsum << " " <<KTsecondaries << G4endl;
235                                                   145 
                                                   >> 146     success=true;
                                                   >> 147         //G4cout<<"success "<<success<<G4endl;
236   if ( NeedEnergyCorrector ) success=EnergyAnd    148   if ( NeedEnergyCorrector ) success=EnergyAndMomentumCorrector(theResult, KTsum);
237   } while (!success && (attempts < 100));  /*  << 149     //G4cout<<"success after Ecorr "<<success<<G4endl;
238                                                << 150   } while(!success && (attempts < 10));   // It was 100 !!! Uzhi
239   for ( unsigned int aTrack=0; aTrack<theResul << 151           //G4cout<<"End frag string"<<G4endl;
240   {                                            << 
241     Ptmp=(*theResult)[aTrack]->Get4Momentum(); << 
242     Ptmp.transform( toLab);                    << 
243     (*theResult)[aTrack]->Set4Momentum(Ptmp);  << 
244   }                                            << 
245                                                << 
246   #ifdef debug_G4ExcitedStringDecay            << 
247   G4cout<<"End of the strings fragmentation (G << 
248                                                << 
249   G4LorentzVector  KTsum1(0.,0.,0.,0.);        << 
250                                                   152 
                                                   >> 153 #ifdef debug_ExcitedStringDecay
                                                   >> 154   G4LorentzVector  KTsum1=0;
251   for ( unsigned int aTrack=0; aTrack<theResul    155   for ( unsigned int aTrack=0; aTrack<theResult->size();aTrack++)
252   {                                               156   {
253       G4cout << " corrected tracks .. " << (*t    157       G4cout << " corrected tracks .. " << (*theResult)[aTrack]->GetDefinition()->GetParticleName()
254       <<"  " << (*theResult)[aTrack]->Get4Mome << 158       <<"  " << (*theResult)[aTrack]->Get4Momentum() << G4endl;
255       <<"  " << (*theResult)[aTrack]->Get4Mome << 
256       KTsum1+= (*theResult)[aTrack]->Get4Momen    159       KTsum1+= (*theResult)[aTrack]->Get4Momentum();
257   }                                               160   }
258                                                   161 
259   G4cout << "Needcorrector/success " << NeedEn << 162   G4cout << "Needcorrector/success " << NeedEnergyCorrector << "/" << success << ", Corrected total  4 momentum " << KTsum1  << G4endl;
260          << ", Corrected total  4 momentum " < << 
261   if ( ! success ) G4cout << "failed to correc    163   if ( ! success ) G4cout << "failed to correct E/p" << G4endl;  
                                                   >> 164 #endif
262                                                   165 
263   G4cout<<"End of the Hadronization (G4Excited << 
264   #endif                                       << 
265                                                << 
266   if (!success)                                << 
267   {                                            << 
268     if (theResult->size() != 0)                << 
269     {                                          << 
270       std::for_each(theResult->begin() , theRe << 
271       theResult->clear();                      << 
272       delete theResult; theResult=0;           << 
273     }                                          << 
274     for ( unsigned int astring=0; astring < th << 
275     // for ( unsigned int astring=0; astring < << 
276     {                                          << 
277       if ( theStrings->operator[](astring)->Is << 
278       {                                        << 
279         Ptmp=theStrings->operator[](astring)-> << 
280         Ptmp.transform( toLab);                << 
281         theStrings->operator[](astring)->GetLe << 
282                                                << 
283         Ptmp=theStrings->operator[](astring)-> << 
284         Ptmp.transform( toLab);                << 
285         theStrings->operator[](astring)->GetRi << 
286       }                                        << 
287       else                                     << 
288       {                                        << 
289         Ptmp=theStrings->operator[](astring)-> << 
290         Ptmp.transform( toLab);                << 
291         theStrings->operator[](astring)->GetKi << 
292       }                                        << 
293     }                                          << 
294   }                                            << 
295   return theResult;                               166   return theResult;
296 }                                                 167 }
297                                                   168 
298                                                << 169 G4bool G4ExcitedStringDecay::EnergyAndMomentumCorrector
299 G4bool G4ExcitedStringDecay::                  << 170     (G4KineticTrackVector* Output, G4LorentzVector& TotalCollisionMom)   
300 EnergyAndMomentumCorrector(G4KineticTrackVecto << 171   {
301 {                                              << 
302     const int    nAttemptScale = 500;             172     const int    nAttemptScale = 500;
303     const double ErrLimit = 1.E-5;                173     const double ErrLimit = 1.E-5;
304     if (Output->empty()) return TRUE;          << 174     if (Output->empty())
                                                   >> 175        return TRUE;
305     G4LorentzVector SumMom;                       176     G4LorentzVector SumMom;
306     G4double        SumMass = 0;               << 177     G4double        SumMass = 0;     
307     G4double        TotalCollisionMass = Total    178     G4double        TotalCollisionMass = TotalCollisionMom.m();
308                                                   179 
309     std::vector<G4double> HadronMass; G4double << 180 //G4cout<<G4endl<<"EnergyAndMomentumCorrector "<<Output->size()<<G4endl;
310                                                << 
311     #ifdef debug_G4ExcitedStringCorr           << 
312     G4cout<<G4endl<<"EnergyAndMomentumCorrecto << 
313     #endif                                     << 
314     // Calculate sum hadron 4-momenta and summ    181     // Calculate sum hadron 4-momenta and summing hadron mass
315     unsigned int cHadron;                         182     unsigned int cHadron;
316     for (cHadron = 0; cHadron < Output->size() << 183     for(cHadron = 0; cHadron < Output->size(); cHadron++)
317     {                                             184     {
318         SumMom  += Output->operator[](cHadron)    185         SumMom  += Output->operator[](cHadron)->Get4Momentum();
319         HadronM=Output->operator[](cHadron)->G << 186         SumMass += Output->operator[](cHadron)->GetDefinition()->GetPDGMass();
320         SumMass += Output->operator[](cHadron) << 
321     }                                             187     }
322                                                   188 
323     #ifdef debug_G4ExcitedStringCorr           << 189 //G4cout<<"SumMass TotalCollisionMass "<<SumMass<<" "<<TotalCollisionMass<<G4endl;
324     G4cout<<"Sum part mom "<<SumMom<<" "<<SumM << 
325           <<"Sum str  mom "<<TotalCollisionMom << 
326     G4cout<<"SumMass TotalCollisionMass "<<Sum << 
327     #endif                                     << 
328                                                   190 
329     // Cannot correct a single particle           191     // Cannot correct a single particle
330     if (Output->size() < 2) return FALSE;         192     if (Output->size() < 2) return FALSE;
331                                                   193 
332     if (SumMass > TotalCollisionMass) return F    194     if (SumMass > TotalCollisionMass) return FALSE;
333     SumMass = SumMom.m2();                        195     SumMass = SumMom.m2();
334     if (SumMass < 0) return FALSE;                196     if (SumMass < 0) return FALSE;
335     SumMass = std::sqrt(SumMass);                 197     SumMass = std::sqrt(SumMass);
336                                                   198 
337     // Compute c.m.s. hadron velocity and boos << 199      // Compute c.m.s. hadron velocity and boost KTV to hadron c.m.s.
338     // G4ThreeVector Beta = -SumMom.boostVecto << 200     G4ThreeVector Beta = -SumMom.boostVector();
339     G4ThreeVector Beta = -TotalCollisionMom.bo << 
340     Output->Boost(Beta);                          201     Output->Boost(Beta);
341                                                   202 
342     // Scale total c.m.s. hadron energy (hadro    203     // Scale total c.m.s. hadron energy (hadron system mass).
343     // It should be equal interaction mass        204     // It should be equal interaction mass
344     G4double Scale = 1;                           205     G4double Scale = 1;
345     G4int cAttempt = 0;                           206     G4int cAttempt = 0;
346     G4double Sum = 0;                             207     G4double Sum = 0;
347     G4bool success = false;                       208     G4bool success = false;
348     for (cAttempt = 0; cAttempt < nAttemptScal << 209     for(cAttempt = 0; cAttempt < nAttemptScale; cAttempt++)
349     {                                             210     {
350       Sum = 0;                                    211       Sum = 0;
351       for (cHadron = 0; cHadron < Output->size << 212       for(cHadron = 0; cHadron < Output->size(); cHadron++)
352       {                                           213       {
353         HadronM = HadronMass.at(cHadron);      << 
354         G4LorentzVector HadronMom = Output->op    214         G4LorentzVector HadronMom = Output->operator[](cHadron)->Get4Momentum();
355         HadronMom.setVect(Scale*HadronMom.vect    215         HadronMom.setVect(Scale*HadronMom.vect());
356         G4double E = std::sqrt(HadronMom.vect( << 216         G4double E = std::sqrt(HadronMom.vect().mag2() + sqr(Output->operator[](cHadron)->GetDefinition()->GetPDGMass()));
357                                                << 
358         HadronMom.setE(E);                        217         HadronMom.setE(E);
359         Output->operator[](cHadron)->Set4Momen    218         Output->operator[](cHadron)->Set4Momentum(HadronMom);
360         Sum += E;                                 219         Sum += E;
361       }                                           220       } 
362       Scale = TotalCollisionMass/Sum;          << 221       Scale = TotalCollisionMass/Sum;    
363       #ifdef debug_G4ExcitedStringCorr         << 222 #ifdef debug_G4ExcitedStringDecay 
364       G4cout << "Scale-1=" << Scale -1            223       G4cout << "Scale-1=" << Scale -1 
365              << ",  TotalCollisionMass=" << To << 224                 << ",  TotalCollisionMass=" << TotalCollisionMass
366              << ",  Sum=" << Sum               << 225     << ",  Sum=" << Sum
367        << G4endl;                              << 226     << G4endl;
368       #endif                                   << 227 #endif     
369       if (std::fabs(Scale - 1) <= ErrLimit)       228       if (std::fabs(Scale - 1) <= ErrLimit) 
370       {                                           229       {
371         success = true;                           230         success = true;
372   break;                                          231   break;
373       }                                           232       }
374     }                                             233     }
375                                                << 234 #ifdef debug_G4ExcitedStringDecay     
376     #ifdef debug_G4ExcitedStringCorr           << 235     if(!success)
377     if (!success)                              << 
378     {                                             236     {
379       G4cout << "G4ExcitedStringDecay::EnergyA    237       G4cout << "G4ExcitedStringDecay::EnergyAndMomentumCorrector - Warning"<<G4endl;
380       G4cout << "   Scale not unity at end of     238       G4cout << "   Scale not unity at end of iteration loop: "<<TotalCollisionMass<<" "<<Sum<<" "<<Scale<<G4endl;
381       G4cout << "   Number of secondaries: " <    239       G4cout << "   Number of secondaries: " << Output->size() << G4endl;
382       G4cout << "   Wanted total energy: " <<     240       G4cout << "   Wanted total energy: " <<  TotalCollisionMom.e() << G4endl; 
383       G4cout << "   Increase number of attempt    241       G4cout << "   Increase number of attempts or increase ERRLIMIT"<<G4endl;
384       // throw G4HadronicException(__FILE__, _ << 242 //       throw G4HadronicException(__FILE__, __LINE__, "G4ExcitedStringDecay failed to correct...");
385     }                                             243     }
386     #endif                                     << 244 #endif     
387                                                << 
388     // Compute c.m.s. interaction velocity and    245     // Compute c.m.s. interaction velocity and KTV back boost   
389     Beta = TotalCollisionMom.boostVector();       246     Beta = TotalCollisionMom.boostVector();
390     Output->Boost(Beta);                          247     Output->Boost(Beta);
391                                                   248 
392     return success;                               249     return success;
393 }                                              << 250   }
394                                                << 
395                                                   251