StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StarHijing.cxx
1 
2 #include "StarHijing.h"
3 ClassImp(StarHijing);
4 
5 #include "StarCallf77.h"
6 #include "StarGenerator/EVENT/StarGenAAEvent.h"
7 #include "StarGenerator/EVENT/StarGenParticle.h"
8 
9 #include "StarGenerator/UTIL/StarRandom.h"
10 #include "TString.h"
11 
12 #include <map>
13 #include <iostream>
14 using namespace std;
15 
16 #include "TGenericTable.h"
17 
18 StMaker *_maker = 0;
19 
20 TGenericTable *regtable( const Char_t *type, const Char_t *name, void *address )
21 {
22  TGenericTable *table = new TGenericTable(type,name);
23  table->Adopt( 1, address );
24  _maker -> AddData( table, ".const" );
25  return table;
26 };
27 
28 // ----------------------------------------------------------------------------
29 // Remap hijing's random number generator to StarRandom
30 extern "C" {
31  float rlustar_( Int_t *idummy ){ return StarRandom::Instance().flat(); };
32  float rndmstar_( Int_t *idummy ){ return StarRandom::Instance().flat(); };
33 };
34 Double_t rndm(){ return StarRandom::Instance().flat(); }
35 // ----------------------------------------------------------------------------
36 // ----------------------------------------------------------------------------
37 // ----------------------------------------------------------------------------
38 StarHijing::StarHijing( const Char_t *name ) : StarGenerator(name)
39 {
40 
41  _maker = this;
42 
43  // Register configuration commons
44  regtable("HiParnt_t", "hiparnt", (void *)address_of_hiparnt() );
45  regtable("HiMain1_t", "himain1", (void *)address_of_himain1() );
46  //regtable("HiMain2_t", "himain2", (void *)address_of_himain2() ); // Probably too big to be useful
47  regtable("Ludat3_t", "ludat3", (void *)address_of_hiparnt() );
48 
49  // Setup a map between HIJING status codes and HepMC status codes
50  // katt(i,4)... all other codes should map to kUnknown
51  mStatusCode[1] = StarGenParticle::kFinal;
52  mStatusCode[11] = StarGenParticle::kDecayed;
53 
54 
55  // Mapping between jetset particle IDs and PDG particle IDs
56  mParticleCode[ 10551 ] = 551;
57  mParticleCode[ 20443 ] = 10443;
58  mParticleCode[ 30443 ] = 20443;
59  mParticleCode[ 30553 ] = 20553;
60  mParticleCode[ 4232 ] = 4332;
61  mParticleCode[ 4332 ] = 4232;
62 
63 }
64 
65 Int_t StarHijing::pdgid( const Int_t &jetid )
66 {
67  // Unknown particles
68  if ( jetid == 551 ) return 0;
69  if ( jetid == 10443 ) return 0;
70 
71  // K0/K0bar = 0.5 K0 short + 0.5 K0 long
72  if ( jetid==311 || jetid==-311 )
73  {
74  if ( rndm() > 0.5 ) return 130; // K0 long
75  else return 310; // K0 short
76  }
77 
78  int id = mParticleCode[jetid];
79 
80 
81 
82  // Return ID if it was found in the table
83  if ( id )
84  return id;
85 
86  // If the particle isn't in the table, it corresponds to the PDG code
87  return jetid;
88 }
89 
90 
91 
92 Int_t StarHijing::LuComp( Int_t jetsetid )
93 {
94  return Lucomp( jetsetid );
95 };
96 
97 
99 {
100 
101  mEvent = new StarGenAAEvent();
102 
103  // Number of spectators
104  // Initialized per event
105  for ( Int_t i=0; i<2; i++ ){
106  mNumberOfSpectatorProtons[i]=0;
107  mNumberOfSpectatorNeutrons[i]=0;
108  }
109 
115 #define STABLE(x) ludat3().mdcy( Lucomp( x ), 1 ) = 0
116  STABLE( 111 );
117  STABLE( 221 );
118  STABLE( 3122 );
119  STABLE( 3212 );
120  STABLE( 3112 );
121  STABLE( 3222 );
122  STABLE( 3312 );
123  STABLE( 3322 );
124  STABLE( 3334 );
125 #undef STABLE
126 
127 
128 
129 
130 
131  /*
132  ludat3().mdcy(102,1)=0; // PI0 111
133  ludat3().mdcy(109,1)=0; // ETA 221
134  ludat3().mdcy(164,1)=0; // LAMBDA0 3122
135  ludat3().mdcy(167,1)=0; // SIGMA0 3212
136  ludat3().mdcy(162,1)=0; // SIGMA- 3112
137  ludat3().mdcy(169,1)=0; // SIGMA+ 3222
138  ludat3().mdcy(172,1)=0; // Xi- 3312
139  ludat3().mdcy(174,1)=0; // Xi0 3322
140  ludat3().mdcy(176,1)=0; // OMEGA- 3334
141  */
142  // Double check indexing here
143  /*
144  ludat3().mdcy(106,1)=0; // PI+ 211 (not decayed anyhow)
145  ludat3().mdcy(112,1)=1; // K_SHORT 310 ... decay these ...
146  ludat3().mdcy(105,1)=1; // K_LONG 130
147  ludat3().mdcy(116,1)=0; // K+ 321
148  */
149 
150 
151  //
152  // Check the frame. Only CMS is supported at this time
153  //
154  if (!( mFrame == "CMS" || mFrame =="FIXT"))
155  {
156  cout << "StarHijing: Only CMS / FIXT frame supported for now. Kill me now." << endl;
157  }
158 
160  // Initialize the hijing
162 
163  // Map typical species run at RHIC
164  map<TString,Int_t> A, Z; map<TString,string> type;
165  A["p"] =1; Z["p"] =1; type["p"] ="P ";
166  A["n"] =1; Z["n"] =0; type["n"] ="N ";
167  A["d"] =2; Z["d"] =1; type["d"] ="A ";
168  A["He3"]=3; Z["He3"]=2; type["He3"]="A ";
169 
170 
171  A["Au"]=197; Z["Au"]=79; type["Au"]="A ";
172  A["Cu"]=63; Z["Cu"]=29; type["Cu"]="A ";
173  A["U"] =238; Z["U"]=92; type["U"] ="A ";
174  A["Al"]=27; Z["Al"]=13; type["Al"]="A ";
175 
176  A["proton"] =1; Z["proton"] =1; type["proton"] ="P "; // important to map size of type onto character*8
177  A["neutron"] =1; Z["neutron"] =0; type["neutron"] ="N ";
178  A["deuteron"] =2; Z["deuteron"] =1; type["deuteron"] ="A ";
179 
180  A["Zr96"]= 96; Z["Zr96"]=40; type["Zr96"]="A ";
181  A["Ru96"]= 96; Z["Ru96"]=44; type["Ru96"]="A ";
182 
183  hiparnt().ihpr2(12) = 1; // 0=particle decays on 1=off
184 
185  string frame = mFrame.Data();
186  if(frame =="FIXT") frame="LAB";
187 
188  float roots = TMath::Abs( mRootS );
189  Hijset( roots, frame, type[mBlue], type[mYell], A[mBlue], Z[mBlue], A[mYell], Z[mYell] );
190 
191  mNumberOfBeamProtons[0]=Z[mBlue];
192  mNumberOfBeamProtons[1]=Z[mYell];
193  mNumberOfBeamNeutrons[0]=A[mBlue]-mNumberOfBeamProtons[0];
194  mNumberOfBeamNeutrons[1]=A[mYell]-mNumberOfBeamProtons[1];
195 
196  //
197  // PDG id for heavy ions
198  //
199  //if ( mBlue != "p" && mBlue != "n" ) mBlueId = 10 * A[mBlue] + 10000 * Z[mBlue] + 1000000000;
200  //if ( mYell != "p" && mYell != "n" ) mBlueId = 10 * A[mYell] + 10000 * Z[mYell] + 1000000000;
201 
202  //
203  // Keep all information for all particles, even those which decay
204  //
205  hiparnt().ihpr2(21)=1;
206  hiparnt().ihpr2(10)=1; // show error msgs
207 
208  return StMaker::Init();
209 
210 }
211 // ----------------------------------------------------------------------------
212 // ----------------------------------------------------------------------------
213 // ----------------------------------------------------------------------------
214 extern "C" {
215  void hijing_( const char *frame, float &bmin, float &bmax, int sframe );
216 }
217 
219 {
220 
221  Hijset();
222 
223  float bmax = hiparnt().hipr1(34)+hiparnt().hipr1(35);
224  if ( mImpactMax < 0 )
225  mImpactMax = bmax;
226  else if ( mImpactMax > bmax )
227  mImpactMax = bmax;
228 
229  cout << "-----------------> Generate() <--------------------" << endl;
230 
231  // Generate one hijing event
232  {
233  // string frame = mframe;
234 
235  string frame = "CMS ";
236 
237  if(mFrame == "FIXT")
238  frame="LAB ";
239 
240  cout << mFrame.Data() << " " << frame.data() << endl;
241 
242  Float_t bmin = mImpactMin;
243  Float_t bmax = mImpactMax;
244  // Hijing( frame, bmin, bmax );
245  hijing_( frame.c_str(), bmin, bmax, frame.size() );
246  }
247 
248 
249  // Number of spectators
250  // Initialized per event
251  //
252  for ( Int_t i=0; i<2; i++ ){
253  mNumberOfSpectatorProtons[i]=0;
254  mNumberOfSpectatorNeutrons[i]=0;
255  }
256 
257  //
258  // Loop over all particles in the event
259  //
260  mNumberOfParticles = himain1().natt;
261  StarGenParticle *particles[ mNumberOfParticles + 1]; // temporary list of particles [1<=idx<=mNumber]
262  StarGenParticle *current = 0;
263  for ( Int_t idx=1; idx<=mNumberOfParticles; idx++ )
264  {
265 
266  Int_t jsid = himain2().katt(idx, 1); // this is jetset 7.2 id
267  Int_t id = ( pdgid(jsid) );
268 
269  Int_t stat = himain2().katt(idx, 4);
270  if ( !stat ) {
272  }
273  Int_t m1 = himain2().katt(idx, 3);
274  Int_t m2 = -1;
275  Int_t d1 = -1; // daughters will be set below
276  Int_t d2 = -1; //
277  Double_t px = himain2().patt(idx, 1);
278  Double_t py = himain2().patt(idx, 2);
279  Double_t pz = himain2().patt(idx, 3); pz *= mDirect;
280  Double_t E = himain2().patt(idx, 4);
281  Double_t M = Ulmass(jsid); // Need to lookup mass here... from hijing library ... ulmass in hipyset
282  Double_t vx = himain2().vatt(idx, 1);
283  Double_t vy = himain2().vatt(idx, 2);
284  Double_t vz = himain2().vatt(idx, 3);
285  Double_t vt = himain2().vatt(idx, 4);
286 
287  particles[idx] = mEvent -> AddParticle( stat, id, m1, m2, d1, d2, px, py, pz, E, M, vx, vy, vz, vt );
288  if ( m1 > 0 ) { //
289  current = particles[m1];
290  assert(current);
291  // Set first daughter if it hasn't been set
292  if ( -1 == current->GetFirstDaughter() ) current->SetFirstDaughter(idx);
293  // Set last daughter if it's larger than the current idx
294  if ( idx > current->GetLastDaughter() ) current->SetLastDaughter(idx);
295  }
296 
297 
298  // count spectators
299  Int_t code = himain2().katt(idx, 2 );
300 
301  if ( code == 0 || code == 1 ) // blue beam spectator
302  {
303  if ( id == 2212 ) mNumberOfSpectatorProtons[0]++;
304  if ( id == 2112 ) mNumberOfSpectatorNeutrons[0]++;
305  }
306 
307  if ( code == 10 || code == 11 ) // yellow beam spectator
308  {
309  if ( id == 2212 ) mNumberOfSpectatorProtons[1]++;
310  if ( id == 2112 ) mNumberOfSpectatorNeutrons[1]++;
311  }
312 
313  }
314 
315 
316 
317  FillAA(mEvent);
318 
319  return kStOK;
320 
321 }
322 // ----------------------------------------------------------------------------
323 // ----------------------------------------------------------------------------
324 // ----------------------------------------------------------------------------
326 {
327 
328  StarGenAAEvent *event = (StarGenAAEvent *)_event;
329 
330  event -> process = -999;
331  event -> subprocess = -999;
332  event -> idParton1 = hiparnt().ihnt2(9);
333  event -> idParton2 = hiparnt().ihnt2(10);
334  event -> xParton1 = -999;
335  event -> xParton2 = -999;
336  event -> xPdf1 = -999;
337  event -> xPdf2 = -999;
338  event -> Q2fac = -999;
339  event -> Q2ren = -999;
340  event -> valence1 = 0;
341  event -> valence2 = 0;
342  event -> sHat = -999;
343  event -> tHat = -999;
344  event -> uHat = -999;
345  event -> ptHat = -999;
346  event -> thetaHat = -999;
347  event -> phiHat = -999;
348 
349  event -> impactParameter = hiparnt().hint1(19); // in fm
350  event -> reactionPlane = hiparnt().hint1(20); // in rad
351 
352  // Number of particpant protons is Z - n spectators
353  // Number of particpant neutrons is ( A - Z ) - nspectators
354 
355  event -> numberOfBinary = himain1().n0;
356  event -> numberOfParticipantNeutrons[0] = mNumberOfBeamNeutrons[0] - mNumberOfSpectatorNeutrons[0];
357  event -> numberOfParticipantNeutrons[1] = mNumberOfBeamNeutrons[1] - mNumberOfSpectatorNeutrons[1];
358  event -> numberOfParticipantProtons[0] = mNumberOfBeamProtons[0] - mNumberOfSpectatorProtons[0];
359  event -> numberOfParticipantProtons[1] = mNumberOfBeamProtons[1] - mNumberOfSpectatorProtons[1];
360  event -> numberRejected = -999;
361  event -> numberWounded[0] = himain1().nwounded_blue;
362  event -> numberWounded[1] = himain1().nwounded_yell;
363  event -> numberOfJets = himain1().jatt;
364 
365  event -> weight = 1.0;
366 
367 }
Double_t mRootS
CMS energy or incident beam momentum for fixed target collisions.
static StarRandom & Instance()
Obtain the single instance of the random number generator.
Definition: StarRandom.cxx:87
TString mYell
Name of the yellow beam particle (-z)
void FillAA(StarGenEvent *event)
(Optional) Method to fill a AA event
Definition: StarHijing.cxx:325
Event record tailored to heavy ion collisions.
Yet another particle class.
ABC for defining event generator interfaces.
Definition: StarGenerator.h:34
StarGenEvent * mEvent
Generated event.
Double_t mImpactMin
Minimum impact parameter in a HI collision.
Int_t LuComp(Int_t jetsetid)
Definition: StarHijing.cxx:92
HiMain2_t & himain2()
Returns a refernece to the hijing main2 block.
Definition: StarHijing.h:66
Int_t Generate()
Definition: StarHijing.cxx:218
Double_t mImpactMax
Maximum impact parameter in a HI collision.
Double_t mDirect
Direction (+1 = W, -1 = E) of the beam in fixted target mode.
int & ihpr2(int i)
Definition: Hijing.h:94
Double_t flat() const
Return a random number uniformly distributed between 0 and 1.
Definition: StarRandom.cxx:68
HiParnt_t & hiparnt()
Returns a reference to the hijing parameters.
Definition: StarHijing.h:58
HiMain1_t & himain1()
Returns a reference to the hijing main1 block.
Definition: StarHijing.h:62
float & hipr1(int i)
Definition: Hijing.h:90
Interface to the HIJING event generator.
Definition: StarHijing.h:48
Base class for event records.
Definition: StarGenEvent.h:81
void SetLastDaughter(Int_t last)
Set the last daughter particle in the array of particles.
Int_t GetLastDaughter()
Get the last daughter particle.
Definition: Stypes.h:40
void SetFirstDaughter(Int_t first)
Set the first daughter particle in the array of particles.
float & hint1(int i)
Definition: Hijing.h:98
int & ihnt2(int i)
Definition: Hijing.h:102
int & katt(int i, int j)
Definition: Hijing.h:62
Int_t pdgid(const Int_t &code)
Definition: StarHijing.cxx:65
TString mFrame
Frame of the collision, i.e. CMS, FIXT, 3MOM, 4MOM, 5MOM.
TString mBlue
Name of the blue beam particle (+z)
Int_t GetFirstDaughter()
Get the first daughter particle.
Int_t Init()
Definition: StarHijing.cxx:98
virtual void Adopt(Int_t n, void *array)
Definition: TTable.cxx:1107
float & vatt(int i, int j)
Definition: Hijing.h:70
float & patt(int i, int j)
Definition: Hijing.h:66