ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4HIJING_Model.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file G4HIJING_Model.cc
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 //
28 // MODULE: G4HIJING_Model.hh
29 //
30 // Version: 1.B
31 // Date: 10/09/2013
32 // Authors: Khaled Abdel-Waged
33 // Institute: Umm Al-Qura University
34 // Country: Saudi Arabia
35 // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
36 //
37 #include "G4HIJING_Model.hh"
38 #ifdef G4_USE_HIJING
39 #include "G4HIJING_Interface.hh"
40 //-------------------------------
41 #include "globals.hh"
42 #include "G4DynamicParticle.hh"
43 #include "G4IonTable.hh"
44 #include "G4CollisionOutput.hh"
45 #include "G4V3DNucleus.hh"
46 #include "G4Track.hh"
47 #include "G4Nucleus.hh"
48 #include "G4LorentzRotation.hh"
49 
50 #include "G4ParticleDefinition.hh"
51 #include "G4ParticleTable.hh"
52 
53 //AND->
54 #include "G4Version.hh"
55 //AND<-
56 //----------------new_anti
57 #include "G4AntiHe3.hh"
58 #include "G4AntiDeuteron.hh"
59 #include "G4AntiTriton.hh"
60 #include "G4AntiAlpha.hh"
61 //---------------------------
62 #include <fstream>
63 #include <string>
64 #include "HistoManager.hh" //newkhaled
65 #include "G4SystemOfUnits.hh"
67 
68 //
69 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
71  :G4VIntraNuclearTransportModel(nam), verbose(0)
72 {
73 
74 
75  if (verbose > 3) {
76  G4cout << " >>> G4HIJING_Model default constructor" << G4endl;
77  }
78 
79 #ifdef G4ANALYSIS_USE
80 fHistoManager = HistoManager::GetPointer(); //new_khaled
81 #endif
82 
83 //
84 // Set the minimum and maximum range for the HIJING model
85 
86  SetMinEnergy(4.0*GeV);
87 // SetMaxEnergy(2000.0*TeV);
88 
89 
90 
91 //
92 
93 //
94  WelcomeMessage();
95 //
96  CurrentEvent=0;
97 
98 //
99 
100 InitialiseDataTables();
101 
102 
103 //
104 }
106 //
107 // Destructor
108 //
109 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
112 
114  G4V3DNucleus* ) {
115  return 0;
116 }
117 
119 //
120 // ApplyYourself
121 //
122 // Member function to process an event, and get information about the products.
123 
124 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
126  const G4HadProjectile &theTrack, G4Nucleus &theTarget)
127 {
128  G4cout<<"HERE I AM"<<G4endl;
129 //anti_new
130 // ------------------define anti_light_nucleus
131 const G4ParticleDefinition* anti_deu =
133 
134 const G4ParticleDefinition* anti_he3=
136 
137 const G4ParticleDefinition* anti_tri=
139 
140 const G4ParticleDefinition* anti_alp=
142 
143 //---------------------------------------------------
144 //
145 // The secondaries will be returned in G4HadFinalState &theResult -
146 // initialise this. The original track will always be discontinued and
147 // secondaries followed.
148 //
149  theResult.Clear();
151 
152  G4DynamicParticle* cascadeParticle=0;
153 //
154 //
155 // Get relevant information about the projectile and target (A, Z, energy/nuc,
156 // momentum, etc).
157 //
158 
159 
160  const G4ParticleDefinition *definitionP = theTrack.GetDefinition();
161  const G4double AP = definitionP->GetBaryonNumber();
162  const G4double ZP = definitionP->GetPDGCharge();
163  G4int AT = theTarget.GetN_asInt();
164  G4int ZT = theTarget.GetZ_asInt();
165 // -----------------------------------------------
166  G4int id=definitionP->GetPDGEncoding(); //get particle encoding
167 
168 // G4cout<<"particle id========= "<<id<<G4endl;
169 // ------------------------------------------------
170  G4int AP1 = G4lrint(AP);
171  G4int ZP1 = G4lrint(ZP);
172  G4int AT1 = AT;
173  G4int ZT1 = ZT;
174 
175 
176 // ****************************************************************************
177 // The following is the parameters necessary to initiate HIJSET() and HIJING()
178 // ----------------------------------------------------------------------------
179 // hiparnt_.ihpr2[3]=0; //switch off(=0) / on(=1) jet quenching
180 // hiparnt_.ihpr2[2]=1; //switch on triggered Jet production
181 // ---------------------------------------------------------------------------
182 // hiparnt_.ihnt2[0]=AP1; //Projectile
183 hiparnt_.ihnt2[1]=ZP1;
184 hiparnt_.ihnt2[2]=AT1; //Target
185 hiparnt_.ihnt2[3]=ZT1;
186 hiparnt_.ihnt2[5]=0; //Special Target
187 
188 
189  if (AP1>1 ||definitionP==anti_deu ||definitionP==anti_he3
190  ||definitionP==anti_tri ||definitionP==anti_alp)
191 
192  {
193 
194  hiparnt_.ihnt2[0]=AP1;
195  hiparnt_.ihnt2[4]=0; //Special Projectile
196 
197  }else if (id==2212) {
198 
199  hiparnt_.ihnt2[0]=1;
200  hiparnt_.ihnt2[4]=2212;
201 
202 
203  } else if(id==-2212){
204 
205  hiparnt_.ihnt2[0]=1;
206  hiparnt_.ihnt2[4]=-2212;
207 
208  } else if(id==2112){
209 
210  hiparnt_.ihnt2[0]=1;
211  hiparnt_.ihnt2[4]=2112;
212 
213  } else if(id==-2112){
214 
215  hiparnt_.ihnt2[0]=1;
216  hiparnt_.ihnt2[4]=-2112;
217 
218 
219  } else if(id==211) {
220  hiparnt_.ihnt2[0]=1; //needed by HIJING
221  hiparnt_.ihnt2[4]=211;
222 
223 
224  } else if(id==-211) {
225 
226  hiparnt_.ihnt2[0]=1; //needed by HIJING
227  hiparnt_.ihnt2[4]=-211;
228 
229  } else if(id==321) {
230 
231  hiparnt_.ihnt2[0]=1; //needed by HIJING
232  hiparnt_.ihnt2[4]=321;
233 
234 
235  } else if(id==-321) {
236 
237  hiparnt_.ihnt2[0]=1; //needed by HIJING
238  hiparnt_.ihnt2[4]=-321;
239 
240  } else {
241 
242  G4cout << " Sorry, No definition for PROJECTLE for HIJING::"
243  <<id<< "found" << G4endl;
244 
245  //AND->
246 #if G4VERSION_NUMBER>=950
247  //New signature (9.5) for G4Exception
248  //Using G4HadronicException
249  throw G4HadronicException(__FILE__,__LINE__,
250  "Sorry, no definition for PROJECTILE for HIJING");
251 #else
252  G4Exception(" ");
253 #endif
254  //AND<-
255  } //end if id
256 
257 //-------------------------------------------------------
258 // -------------identify mass -------------------------
259 
260  G4int id_n=2112;
261  G4int id_p=2212;
262 
263  hiparnt_.hint1[7]=std::max(ulmass_ (&id_n),ulmass_ (&id_p));
264 
265 
267 
268 
269  if (hiparnt_.ihnt2[4]!=0)
270  hiparnt_.hint1[7]=ulmass_ (&hiparnt_.ihnt2[4]);
271  //rest mass of the projectile HIJING
272 
273 //----------------------------------------------------
274 // identify Energy
275 //
276 
277 
278 G4double m= hiparnt_.hint1[7]; //mass in GeV
279 
280 G4ThreeVector P3= theTrack.Get4Momentum().vect()/GeV;
281 // momentum in GeV
282 
283 G4double Pbeam=P3.z();
284 //momentum in z-direction
285 
286 G4double Ebeam=Eplab(m, Pbeam);
287 //calculate Energy of beam
288 
289 //G4cout<<"mass= "<<m<<" P3= "<<P3<<endl;
290 
291 //---------------------------Beam ---------------------------------------
292 
293 //Lab frame: beam moves in negative z-direction
294 
295 G4LorentzVector lab= G4LorentzVector(0.0,0.0,-1.0*Pbeam,Ebeam+m);
296 
297 G4double TotalPbefore=-1.0*lab.z();
298 //Calculate z-Momentum before collision
299 //
300 G4double TotalEbefore = lab.e();
301 //Calculate Energy before collision
302 
303 
304 // --------------------------------------------------------
305 // Turn to CM frame:
306 // ---------------------------------------------------------
307 
308 G4LorentzVector cms = G4LorentzVector(0.0,0.0,0.0,lab.mag());
309 
310 // ----------------------Get relative speed between frames---------
311 // ----------------------------------------------------------------
312 G4LorentzVector Psum=(lab+cms); //4-Momentum sum
313 G4double beta_rel=Psum.beta();
314 
315 //---------------------Transform to equal frame--------------------
316 //-----------------------------------------------------------------
317 
318 Psum.boost(0.0,0.0,-1.0*beta_rel);
319 
320 //-----------------Get equal speed velocity between frames--------
321 G4double betann=Psum.beta();
322 //G4double gama= Psum.gamma();
323 
324 // ----------Colliding CM Energy per nucleon-nucleon for HIJING-
325 // ----------------------------------------------------
326 
327 G4double Ecms=lab.mag(); //CM energy for HIJING
328 efrm=Ecms; //units are in GeV for HIJING
329 
331 
332 if (CurrentEvent==0)
333 {
334 
335 
336 G4cout << "\n initialise HIJING, wait-------"<<G4endl;
337 
338 G4cout << "\n"<<G4endl;
339 
340 
341 //hijset_ (&efrm,&AP1,&ZP1,&AT1,&ZT1);
342 
343 hijset_ (&efrm);
344 
345 G4cout << "\n end initialize "<<G4endl;
346 
347 CurrentEvent=1;
348 }
350 //------------------------------------------------------------
351 // identify impact parameter
352  bmin=0.0;
353 // bmax=0.5;
354 
356 
357 //----------------------------------------------
358 
359  do
360  {
361 
362  G4cout <<"HIJING_Model running-------------" <<G4endl;
363 
364  hijing_ (&bmin,&bmax);
365 
366  Nproduce=himain1_.natt; //no of produced particles
367 
368 
369  if (Nproduce<2)
370  {
371 
372 
373 
374 G4cout <<"===============Warning====================================="<<G4endl;
375 G4cout <<"-----------------------------------------------------------"<<G4endl;
376 G4cout <<"Number of produced particles is very low: " <<himain1_.natt<<G4endl;
377 G4cout <<"------------------------------------------------------------"<<G4endl;
378 G4cout <<"============================================================"<<G4endl;
379  }
380  }
381  while (Nproduce<2);
382 // =============================================================================
383 
384  G4double BB=hiparnt_.hint1[18]; //impact parameter HINT1(19)
385 // cout<<"HIJING=====impact parameter= "<<BB<<endl;
386 
387  for (G4int i=0; i<Nproduce; i++)
388  {
389 
390 
391 
392  G4int pid=himain2_.katt[0][i];
393 
394 // Particle is a final state secondary and not a nucleus.
395 // Determine what this secondary particle is, and if valid, load dynamic
396 // parameters.
397 //
398 // G4cout<<"pid================"<<pid<<G4endl;
399 
403 // exclude beam nucleons as produced particles
404 // cout<<" himain2_.katt[1][i]== "<<himain2_.katt[1][i]<<endl;
405 // if(himain2_.katt[1][i]==0 || himain2_.katt[1][i]==10) continue;
406 // -----------------------------------------------------------
407 // --------------reject neutral particles by calling luchge <new>
408 // G4int chg_HIJ=luchge_ (&pid);
409 // if (chg_HIJ==0) continue;
410 
411  if (pd)
412  {
413 
414 //units are in MeV/c for G4
415 
416  G4double px = himain2_.patt[0][i]*GeV;
417  G4double py = himain2_.patt[1][i]*GeV;
418  G4double pz = himain2_.patt[2][i]*GeV;
419  G4double et = himain2_.patt[3][i]*GeV;
420 
421 
422 // ------------------------------Use "Lorentz vector"----------
423 G4LorentzVector lorenzCM = G4LorentzVector(px,py,pz,et);
424 // Move to the lab frame
425 lorenzCM.boost(0.0,0.0,-1.0*betann);
426 G4LorentzVector lorenzLab = G4LorentzVector(lorenzCM.px(),lorenzCM.py(),
427  -1.0*lorenzCM.pz(),lorenzCM.e());
428 //-------------------------------------------------------------------
429 cascadeParticle = new G4DynamicParticle(pd, lorenzLab);
430 
431 theResult.AddSecondary(cascadeParticle);
432 
433 } //if pd
434 
435 } //for
436 
437 #ifdef G4ANALYSIS_USE //khaled new
438 fHistoManager->StoreSecondaries(BB, theResult);
439 #endif
440 //} //if warning
441 
442 //
443 
444 
445 //=======================================================================
446 if (verbose >= 3) {
447 
448 //
449  G4double TotalEafter = 0.0;
450  G4ThreeVector TotalPafter;
451  G4double charge = 0.0;
452  G4int baryon = 0;
453  G4int nSecondaries = theResult.GetNumberOfSecondaries();
454 
455  for (G4int j=0; j<nSecondaries; j++) {
456  TotalEafter += theResult.GetSecondary(j)->
457  GetParticle()->GetTotalEnergy()/GeV;
458 
459  TotalPafter += theResult.GetSecondary(j)->
460  GetParticle()->GetMomentum()/GeV;
461 
463  GetParticle()->GetDefinition();
464 
465  charge += pd->GetPDGCharge();
466  baryon += pd->GetBaryonNumber();
467 
468  } //for secondaries
469 
470  G4cout <<"----------------------------------------"
471  <<"----------------------------------------"
472  <<G4endl;
473  G4cout <<"Total energy before collision = " <<TotalEbefore
474  <<" GeV" <<G4endl;
475  G4cout <<"Total energy after collision = " <<TotalEafter/nSecondaries
476  //GeV
477  <<" GeV" <<G4endl;
478 
479  G4cout <<"----------------------------------------"<<G4endl;
480 
481  G4cout <<"Total momentum before collision = " <<TotalPbefore
482  //GeV
483 <<" GeV/c" <<G4endl;
484  G4cout <<"Total momentum after collision = " <<TotalPafter.z()/nSecondaries
485  //GeV
486  <<" GeV/c" <<G4endl;
487  G4cout <<"----------------------------------------"<<G4endl;
488 
489  if (verbose >= 4) {
490  G4cout <<"Total charge before collision = " <<(ZP+ZT) //
491  <<G4endl;
492  G4cout <<"Total charge after collision = " <<charge
493  <<G4endl;
494 
495  G4cout <<"----------------------------------------"<<G4endl;
496 
497  G4cout <<"Total baryon number before collision = "<<AP+AT
498  <<G4endl;
499  G4cout <<"Total baryon number after collision = "<<baryon
500  <<G4endl;
501  G4cout <<"----------------------------------------"<<G4endl;
502 
503  } //if verbose4
504 
505  G4cout <<"----------------------------------------"
506  <<"----------------------------------------"
507  <<G4endl;
508 
509  } //if verbose3
510 
511 
512 return &theResult;
513 } //G4hadfinal
514 
515 
516 //---------------------------------------------------------------------
517 
518 //---------------------------------------------------------------------
519 //
520 // WelcomeMessage
521 //
522 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
523 void G4HIJING_Model::WelcomeMessage () const
524 {
525 G4cout <<G4endl;
526 G4cout <<" *****************************************************************"
527 <<G4endl;
528 G4cout <<" Interface to G4HIJING_Model activated"
529 <<G4endl;
530 G4cout <<" Version number : 01.00.0B File date : 10/09/2013" <<G4endl;
531 G4cout <<" Interface written by Khaled Abdel-Waged "
532 <<G4endl;
533 G4cout <<" Umm Al-Qura University "
534 <<G4endl;
535 G4cout <<" SAUDI ARABIA "
536 <<G4endl;
537 G4cout <<G4endl;
538 G4cout <<" *****************************************************************"
539 <<G4endl;
540 G4cout << G4endl;
541  return;
542 }
543 
544 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
546 {
547 //
548 //
549 // The next line is to make sure the block data statements are
550 // executed.
551 //
552 
554 
555 }
556 
558 {
559 G4double Eb= std::sqrt(P*P+m*m);
560 return Eb;
561 }
562 #endif
563