StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StarLightGen.cxx
1 #include "StarLightGen.h"
2 ClassImp(StarLightGen);
3 
4 #include "randomgenerator.h"
5 #include "TDatabasePDG.h"
6 #include "TParticlePDG.h"
7 
8 #include "StarGenerator/UTIL/StarRandom.h"
9 #include "StarGenerator/EVENT/StarGenAAEvent.h"
10 #include "StarGenerator/EVENT/StarGenPPEvent.h"
11 #include "StarGenerator/EVENT/StarGenParticle.h"
12 
13 #include "inputParameters.h"
14 #include "TString.h"
15 
16 // ----------------------------------------------------------------------------
17 // Remap STARlight's random number generator to Star Random
18 extern "C" {
19  Double_t rndm_( Int_t *idummy ){
20  return StarRandom::Instance().flat();
21  };
22 };
23 // ----------------------------------------------------------------------------
24 // ----------------------------------------------------------------------------
25 // ----------------------------------------------------------------------------
26 StarLightGen::StarLightGen(const Char_t *name) : StarGenerator(name),
27  ParametersDouble(),
28  ParametersInt(),
29  _parameters(0),
30  mSTARlight(0)
31 {
32 
33 
34  mSTARlight = new starlight();
35 
37  ParametersInt["BEAM_1_Z"] = 79; // Z of projectile //Can be set from mBlue
38  ParametersInt["BEAM_1_A"] = 197; // A of projectile //Can be set from mBlue
39  ParametersInt["BEAM_2_Z"] = 79; // Z of target //Can be set from mYell
40  ParametersInt["BEAM_2_A"] = 197; // A of target //Can be set from mYell
41  ParametersDouble["BEAM_GAMMA"] = 106; // Gamma of the colliding ions
42  ParametersDouble["W_MAX"] = 4.0; // Max value of w
43  ParametersDouble["W_MIN"] = 0.0; // Min value of w
44  ParametersInt["W_N_BINS"] = 40; // Bins i w
45  ParametersDouble["RAP_MAX"] = 4.; // max y
46  ParametersInt["RAP_N_BINS"] = 80; // Bins i y
47  ParametersInt["CUT_PT"] = 0; // Cut in pT? 0 (no, 1 yes)
48  ParametersDouble["PT_MIN"] = 1.0; // Minimum pT in GeV
49  ParametersDouble["PT_MAX"] = 3.0; // Maximum pT in GeV
50  ParametersInt["CUT_ETA"] = 0; // Cut in pseudorapidity? (0 no, 1 yes)
51  ParametersInt["ETA_MIN"] = -10; // Minimum pseudorapidity
52  ParametersInt["ETA_MAX"] = 10; // Maximum pseudorapidity
53  ParametersInt["PROD_MODE"] = 2; // gg or gP switch (1 2-photon, 2 vector meson (narrow), 3 vector meson (wide) )
54  ParametersInt["PROD_PID"] = 444; // Channel of interest
55  ParametersInt["BREAKUP_MODE"] = 5; // Controls the nuclear breakup
56  ParametersInt["INTERFERENCE"] = 0; // Interference (0 off, 1 on)
57  ParametersDouble["IF_STRENGTH"] = 1.; // % of intefernce (0.0 - 0.1)
58  ParametersInt["COHERENT"] = 1; // Coherent1,Incoherent0
59  ParametersDouble["INCO_FACTOR"] = 1.; // percentage of incoherence
60  ParametersDouble["BFORD"] = 9.5; // I honestly don't know what this does
61  ParametersDouble["INT_PT_MAX"] = 0.24; // Maxvoid imum pt considered, when interference is turned on
62  ParametersInt["INT_PT_N_BINS"] = 120; // Number of pt bins when interference is turned on
63  ParametersInt["RND_SEED"] = 12345; // This isn't actually used, but starlight looks for it
64  ParametersInt["OUTPUT_FORMAT"] = 0; // Again, I don't think this is used, but starlight looks for it
65  // JFN 9/11/12 5:24pm : check if there is an object in the StarGenerator class which stores pt or eta cuts. If there is, reset the cut parameters right here accordingly.
66 
67 }
68 // ----------------------------------------------------------------------------
69 // ----------------------------------------------------------------------------
70 // ----------------------------------------------------------------------------
72 {
73  // Proton mass:
74  Double_t ProtonMass = 0.938272046;
75  // Neutron mass:
76  Double_t NeutronMass = 0.939565378;
77 
78  // Map typical species run at RHIC
79  map<TString,Int_t> A, Z;
80  A["p"] = 1; Z["p"] = 1;
81  A["n"] = 1; Z["n"] = 0;
82  A["d"] = 2; Z["d"] = 1;
83  A["He3"] = 3; Z["He3"] = 2;
84  A["Au"] = 197; Z["Au"] = 79;
85  A["Cu"] = 64; Z["Cu"] = 29;
86  A["U"] = 238; Z["U"] = 92;
87 
88 
89  A["proton"] =1; Z["proton"] =1;
90  A["neutron"] =1; Z["neutron"] =0;
91  A["deuteron"] =2; Z["deuteron"] =1;
92  A["e-"] =0; Z["e-"] =0;
93  A["electron"] =0; Z["electron"] =0;
94  A["e+"] =0; Z["e+"] =0;
95  A["positron"] =0; Z["positron"] =0;
96 
97 
98  TString myBlue = mBlue;
99  TString myYell = mYell;
100 
101 
102  //
103  // Initialize STARlight based on the frame and registerd beam momenta
104  //
105 
106  ParametersInt["BEAM_1_A"] = A[myBlue];
107  ParametersInt["BEAM_1_Z"] = Z[myBlue];
108  ParametersInt["BEAM_2_A"] = A[myYell];
109  ParametersInt["BEAM_2_Z"] = Z[myYell];
110 
111  // Here we set the BEAM_GAMMA value. Gamma = E/M = mRootS/(massBlue+massYell).
112  if( mFrame == "CMS" )
113  {
114  // if mFrame == "CMS" then we get mRootS to work with
115  ParametersDouble["BEAM_GAMMA"] = mRootS/(((Z[myBlue]+Z[myYell])*ProtonMass)+((A[myBlue]-Z[myBlue]+A[myYell]-Z[myYell])*NeutronMass));
116  }
117  if( (mFrame == "3MOM") || (mFrame == "4MOM") || (mFrame == "5MOM") )
118  {
119  // if mFrame == "#MOM" then we get momentum vectors to work with
120  // 4MOM = ( px, py, pz, E/c = sqrt( m**2*c**2 + |p|**2) )
121  // JFN 9/28/12 9:15am - I'm a little fuzy on my relativistic mechaincs, so this next should be double checked:
122  // Also, the units need to be checked. c=1?
123  mRootS = ( sqrt(pow(((Z[myBlue]*ProtonMass)+((A[myBlue]-Z[myBlue])*NeutronMass)),2) + sqrt( pow(mBlueMomentum.Px(),2) + pow(mBlueMomentum.Py(),2) + pow(mBlueMomentum.Pz(),2))) + sqrt(pow(((Z[myYell]*ProtonMass)+((A[myYell]-Z[myYell])*NeutronMass)),2) + sqrt( pow(mYellMomentum.Px(),2) + pow(mYellMomentum.Py(),2) + pow(mYellMomentum.Pz(),2))));
124  ParametersDouble["BEAM_GAMMA"] = mRootS/(((Z[myBlue]+Z[myYell])*ProtonMass)+((A[myBlue]-Z[myBlue]+A[myYell]-Z[myYell])*NeutronMass));
125  }
126 
127  // TDatabasePDG &pdg = (*TDatabasePDG::Instance());
128  // TParticlePDG *blue = pdg.GetParticle(myBlue); assert(blue);
129  // TParticlePDG *yell = pdg.GetParticle(myYell); assert(yell);
130 
131  //
132  // Setup event record based upon the beam species
133  //
134 
135  if ( (mBlue == "Au") || (mBlue == "Cu") || (mBlue == "U") ) mEvent = new StarGenAAEvent();
136  else if ( (mBlue == "proton") && (mYell == "proton") ) mEvent = new StarGenPPEvent();
137  else assert(0); // figure this out
138 
139 
140  //
141  // Initialize STARlight with the parameters specifed
142  //
143  ProcessParameters();
144 
145  //
146  return StMaker::Init();
147  //
148 }
149 // ----------------------------------------------------------------------------
151 {
152 
153  //
154  // Generate the event.
155  //
156  upcEvent event = mSTARlight -> produceEvent();
157 
158  // JFN 9/12/12 10:10am: go figure out what this does and why it should be here
159  // Rset hepevt
160  //mSTARlight ->pushTrackReset();
161 
162  if ( (mBlue == "Au") || (mBlue == "Cu") || (mBlue == "U") ) FillAA( mEvent );
163  if ( (mBlue == "proton") && (mYell == "proton") ) FillPP( mEvent );
164  else /* ever make it onto this branch, assert in init FillPP( mEvent ); */ assert(0);
165 
166  //
167  // Get number of particles
168  //
169  const std::vector<starlightParticle> &particles = *(event.getParticles());
170 
171  // Loop over all particles in the event
172  for ( UInt_t i=0;i<particles.size();i++ )
173  {
174  Int_t q = particles[i].getCharge();
175  Int_t id = particles[i].getPdgCode();
176  Int_t stat = StarGenParticle::kFinal; // JFN 9/12/12 3:47pm: I don't think STARlight assigns particle status codes, but I'm also hedging my bet that it only gives final state particles. This may be a problem.
177  Int_t mother1 = ParametersInt["PROD_PID"];
178  Int_t mother2 = ParametersInt["PROD_PID"];
179  Int_t daughter1 = 0; // I don't think that there are any decays
180  Int_t daughter2 = 0;
181  Double_t px = particles[i].GetPx();
182  Double_t py = particles[i].GetPy();
183  Double_t pz = particles[i].GetPz();
184  Double_t energy = particles[i].GetE();
185  Double_t mass = particles[i].M();
186  Double_t vx = 0; // As far as I can deduce, there is no vertex information provided
187  Double_t vy = 0;
188  Double_t vz = 0;
189  Double_t vt = 0;
190 
191  //
192  // STARlight does not follow the PDG naming convention. They drop the sign of antiparticles.
193  //
194  assert( id > 0 );// If this fails, starlight group has changed something
195  id *= q / abs(q);
196 
197  mEvent -> AddParticle( stat, id, mother1, mother2, daughter1, daughter2, px, py, pz, energy, mass, vx, vy, vz, vt );
198 
199  }
200 
201  return kStOK;
202 }
203 
204 // ----------------------------------------------------------------------------
205 // ----------------------------------------------------------------------------
206 // ----------------------------------------------------------------------------
208 {
209  //
210  // Fill event-wise information
211  //
212  // JFN 9/12/12 3:48pm: At the moment I am including this mostly for completeness, and I am padding out the values with nulls. Some of these parameters are meaningless for STARlight, and others will be filled in at a later time
213  // JFN 9/12/12 3:52pm: At the later moment in time when I come back to fix this, these "Fill??()" functions may need to also to a pointed to the upcEvent which has just been generated. I don't know how else they will get the event data.
214  StarGenAAEvent *event = (StarGenAAEvent *)myevent;
215 
216  event -> idBlue = 1;
217  event -> idYell = 1;
218  event -> process = ParametersInt["PROD_PID"];
219  event -> subprocess = 0;
220 
221  event -> idParton1 = 0;
222  event -> idParton2 = 0;
223  event -> xParton1 = 0;
224  event -> xParton2 = 0;
225  event -> xPdf1 = 0;
226  event -> xPdf2 = 0;
227  event -> Q2fac = 0;
228  event -> Q2ren = 0;
229  event -> valence1 = 0;
230  event -> valence2 = 0;
231 
232  event -> sHat = 0;
233  event -> tHat = 0;
234  event -> uHat = 0;
235  event -> ptHat = 0;
236  event -> thetaHat = 0;
237  event -> phiHat = 0;
238 
239  event -> weight = 0;
240 
241 }
242 // ----------------------------------------------------------------------------
243 // ----------------------------------------------------------------------------
244 // ----------------------------------------------------------------------------
246 {
247  //
248  // Fill event-wise information
249  //
250  // JFN 9/12/12 3:48pm: At the moment I am including this mostly for completeness, and I am padding out the values with nulls. Some of these parameters are meaningless for STARlight, and others will be filled in at a later time
251  // JFN 9/12/12 3:52pm: At the later moment in time when I come back to fix this, these "Fill??()" functions may need to also to a poointed to the upcEvent which has just been generated. I don't know how else they will get the event data.
252  StarGenPPEvent *event = (StarGenPPEvent *)myevent;
253 
254  event -> idBlue = 1;
255  event -> idYell = 1;
256  event -> process = ParametersInt["PROD_PID"];
257  event -> subprocess = 0;
258 
259  event -> idParton1 = 0;
260  event -> idParton2 = 0;
261  event -> xParton1 = 0;
262  event -> xParton2 = 0;
263  event -> xPdf1 = 0;
264  event -> xPdf2 = 0;
265  event -> Q2fac = 0;
266  event -> Q2ren = 0;
267  event -> valence1 = 0;
268  event -> valence2 = 0;
269 
270  event -> sHat = 0;
271  event -> tHat = 0;
272  event -> uHat = 0;
273  event -> ptHat = 0;
274  event -> thetaHat = 0;
275  event -> phiHat = 0;
276 
277  event -> weight = 0;
278 
279 }
280 // ----------------------------------------------------------------------------
281 void StarLightGen::ProcessParameters()
282 {
283  // First we print all of the parameters to a file
284  std::ofstream params_out;
285  params_out.open( "starlight.in" );
286  for(map<TString,Double_t>::iterator i = ParametersDouble.begin(); i != ParametersDouble.end(); i++)
287  {
288  params_out << i->first << " = " << i->second << endl;
289  }
290  for(map<TString,Int_t>::iterator i = ParametersInt.begin(); i != ParametersInt.end(); i++)
291  {
292  params_out << i->first << " = " << i->second << endl;
293  }
294  params_out.close();
295 
296  // Then we tell STARlight to read it in
297  _parameters = new inputParameters();
298  _parameters -> init( "starlight.in" );
299  mSTARlight -> setInputParameters( _parameters );
300  //_parameters->interactionType() = "PHOTONPHOTON";
301  mSTARlight -> init();
302 }
303 // ----------------------------------------------------------------------------
304 void StarLightGen::SetEtaCut( Double_t low, Double_t high )
305 {
306  ParametersDouble["ETA_MIN"] = low;
307  ParametersDouble["ETA_MAX"] = high;
308  ParametersInt["CUT_ETA"] = 1; // Turn the cut on
309 }
310 // ----------------------------------------------------------------------------
311 void StarLightGen::SetPtCut( Double_t low, Double_t high )
312 {
313  ParametersDouble["PT_MIN"] = low;
314  ParametersDouble["PT_MAX"] = high;
315  ParametersInt["CUT_PT"] = 1; // Turn the cut on
316 }
317 // ----------------------------------------------------------------------------
318 void StarLightGen::SetRapidityValues( Double_t high, Int_t bins )
319 {
320  ParametersDouble["RAP_MAX"] = high;
321  ParametersInt["RAP_N_BINS"] = bins;
322 }
323 // ----------------------------------------------------------------------------
324 void StarLightGen::SetWValues( Double_t low, Double_t high, Int_t bins )
325 {
326  ParametersDouble["W_MIN"] = low;
327  ParametersDouble["W_MAX"] = high;
328  ParametersInt["W_N_BINS"] = bins;
329 }
330 // ----------------------------------------------------------------------------
331 void StarLightGen::SetProductionMode( Int_t mode )
332 {
333  ParametersInt["PROD_MODE"] = mode;
334 }
335 // ----------------------------------------------------------------------------
336 void StarLightGen::SetProductionPID( Int_t pid )
337 {
338  ParametersInt["PROD_PID"] = pid;
339 }
340 // ----------------------------------------------------------------------------
341 void StarLightGen::SetBreakupMode( Int_t mode )
342 {
343  ParametersInt["BREAKUP_MODE"] = mode;
344 }
345 // ----------------------------------------------------------------------------
346 void StarLightGen::SetInterference( Double_t percent )
347 {
348  if( (percent > 1) || (percent<0) )
349  {
350  cout << "starSTARlight::SetInterference( Double_t percent ) : percent must be a value between 0 and 1." << endl;
351  assert( (percent > 1) || (percent<0) );
352  }
353 
354  ParametersDouble["IF_STRENGTH"] = percent;
355  ParametersInt["INTERFERENCE"] = 1;
356 }
357 // ----------------------------------------------------------------------------
358 void StarLightGen::SetIncoherence( Double_t percent )
359 {
360  if( (percent > 1) || (percent<0) )
361  {
362  cout << "starSTARlight::SetIncoherence( Double_t percent ) : percent must be a value between 0 and 1." << endl;
363  assert( (percent > 1) || (percent<0) );
364  }
365 
366  ParametersDouble["INCO_FACTOR"] = percent;
367  ParametersInt["COHERENT"] = 0;
368 }
369 // ----------------------------------------------------------------------------
370 void StarLightGen::SetBFORD( Double_t value )
371 {
372  ParametersDouble["BFORD"] = value;
373 }
374 // ----------------------------------------------------------------------------
375 void StarLightGen::SetInterferencePtValues( Double_t high, Int_t bins )
376 {
377  ParametersDouble["INT_PT_MAX"] = high;
378  ParametersInt["INT_PT_N_BINS"] = bins;
379 }
void FillAA(StarGenEvent *event)
(Optional) Method to fill a AA event
StarLightGen(const Char_t *name="STARlight")
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)
Event record tailored to heavy ion collisions.
Event record class tailored to PP kinematics.
TLorentzVector mYellMomentum
4-Momentum of the yellow beam
ABC for defining event generator interfaces.
Definition: StarGenerator.h:34
StarGenEvent * mEvent
Generated event.
void FillPP(StarGenEvent *event)
(Optional) Method to fill a PP event
TLorentzVector mBlueMomentum
4-Momentum of the blue beam
Interface to the StarLightGen (c++ version) event generator.
Definition: StarLightGen.h:19
Double_t flat() const
Return a random number uniformly distributed between 0 and 1.
Definition: StarRandom.cxx:68
Base class for event records.
Definition: StarGenEvent.h:81
Definition: Stypes.h:40
TString mFrame
Frame of the collision, i.e. CMS, FIXT, 3MOM, 4MOM, 5MOM.
TString mBlue
Name of the blue beam particle (+z)
Int_t Generate()