]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TMEVSIM/TMevSim.cxx
Coding violations corrected
[u/mrichter/AliRoot.git] / TMEVSIM / TMevSim.cxx
CommitLineData
1a2762e8 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
15
88cb7938 16/* $Id$ */
1a2762e8 17
18////////////////////////////////////////////////////////////////////////////
19//
20// TMevSim
21//
22// TMevSim is an interface class between the event generator MEVSIM and
23// the ROOT system. The current implementation is based on the 6.11.2000
24// version provided by Lanny Ray on /afs/cern.ch/user/y/yiota/ray/mult_gen.
25//
26// Authors of MEVSIM:
27// For The STAR Collaboration
28//
29// Lanny Ray
30// Dept. of Physics
31// The University of Texas at Austin
32// Austin, Texas 78712
33// (512) 471-6107
34// ray@physics.utexas.edu
35//
36// Ron Longacre email:
37//
38//
39////////////////////////////////////////////////////////////////////////////
40//
41// I. OVERVIEW
42//
43// This code is intended to provide a quick means of producing
44// uncorrelated simulated events for event-by-event studies,
45// detector acceptance and efficiency studies, etc. The
46// user selects the number of events, the one-particle distribution
47// model, the Geant particles to include, the ranges in transverse
48// momentum, pseudorapidity and azimuthal angle, the mean
49// multiplicity for each particle type for the event run, the
50// mean temperature, Rapidity width, etc., and the standard deviations
51// for the event-to-event variation in the model parameters.
52// Note that these events are produced in the c.m. frame only.
53//
54// Anisotropic flow may also be simulated by introducing explicit
55// phi-dependence (azimuthal angle) in the particle distributions.
56// The assumed model is taken from Poskanzer and Voloshin, Phys. Rev.
57// C58, 1671 (1998), Eq.(1), where we use,
58//
59// E d^3N/dp^3 = (1/2*pi*pt)*[d^2N/dpt*dy]
60// * [1 + SUM(n=1,nflowterms){2*Vn*cos[n(phi-PSIr)]}]
61//
62// with up to 'nflowterms' (currently set to 6, see file
63// Parameter_values.inc) Fourier components allowed. Vn are
64// coefficients and PSIr is the reaction plane angle.
65// The algebraic signs of the Vn terms for n=odd are reversed
66// from their input values for particles with rapidity (y) < 0
67// as suggested in Poskanzer and Voloshin.
68// The flow parameters can depend on pt and rapidity (y) according
69// to the model suggested by Art Poskanzer (Feb. 2000) and as
70// defined in the Function Vn_pt_y.
71//
72// The user may select either to have the same multiplicity per
73// particle type for each event or to let the multiplicity vary
74// randomly according to a Poisson distribution. In addition, an
75// overall multiplicative scale factor can be applied to each
76// particle ID's multiplicity (same factor applied to each PID).
77// This scaling can vary randomly according to a Gaussian from
78// event-to-event. This is to simulate trigger acceptance
79// fluctuations. Similarly the
80// parameters of the one-particle distribution models may either
81// be fixed to the same value for each event or allowed to randomly
82// vary about a specified mean with a specified standard deviation
83// and assuming a Gaussian distribution.
84//
85// With respect to the reaction plane and anisotropic flow simulation,
86// the user may select among four options:
87// (1) ignore reaction plane and anisotropic flow effects; all
88// distributions will be azimuthally invariant, on average.
89// (2) assume a fixed reaction plane angle, PSIr, for all events
90// in the run.
91// (3) assume a Gaussian distribution with specified mean and
92// standard deviation for the reaction plane angles for the
93// events in the run. PSIr is randomly determined for each
94// event.
95// (4) assume uniformly distributed, random values for the reaction
96// plane angles from 0 to 360 deg., for each event in the run.
97//
98// The user may also select the anisotropic flow parameters, Vn,
99// to either be fixed for each event, or to randomly vary from event
100// to event according to a Gaussian distribution where the user must
101// specify the mean and std. dev. For both cases the input file must
102// list the 'nflowterms' (e.g. 6) values of the mean and Std.dev. for
103// the Vn parameters for all particle ID types included in the run.
104//
105// The available list of particles has been increased to permit a
106// number of meson and baryon resonances. For those with broad widths
107// the code samples the mass distribution for the resonance and outputs
108// the resonance mass for each instance in a special kinematic file
109// (see file unit=9, filename = 'mult_gen.kin'). The resonance shapes
110// are approximately Breit-Wigner and are specific for each resonance
111// case. The additional particle/resonances include: rho(+,-,0),
112// omega(0), eta', phi, J/Psi, Delta(-,0,+,++) and K*(+,-,0). Masses
113// are sampled for the rho, omega, phi, Deltas and D*s.
114// Refer to SUBR: Particle_prop and Particle_mass for the explicit
115// parameters, resonance shape models, and sampling ranges.
116//
117// The input is from a file, named 'mult_gen.in'. The output is
118// loaded into a file named 'mult_gen.out' which includes run
119// header information, event header information and the EVENT: and
120// TRACK: formats as in the new STAR TEXT Format for event generator
121// input to GSTAR. A log file, 'mult_gen.log' is also written which
122// may contain error messages. Normally this file should be empty
123// after a successful run. These filenames can easily be changed
124// to more suitable names by the script that runs the program or
125// by hand.
126//
127//
128// II. ALGORITHM
129//
130//
131//
132// The method for generating random multiplicities and model parameter
133// values involves the following steps:
134// (1) The Poisson or Gaussian distributions are computed and
135// loaded into function f().
136// (2) The distribution f(x') is integrated from xmin to x
137// and saved from x = xmin to x = xmax. The range and mesh
138// spaces are specified by the user.
139// (3) The integral of f is normalized to unity where
140// integral[f(x')](at x = xmin) = 0.0
141// integral[f(x')](at x = xmax) = 1.0
142// (4) A random number generator is called which delivers values
143// between 0.0 and 1.0.
144// (5) We consider the coordinate x (from xmin to xmax) to be
145// dependent on the integral[f]. Using the random number
146// for the selected value of integral[f] the value of x
147// is obtained by interpolation.
148//
149// An interpolation subroutine from Rubin Landau, Oregon State Univ.,
150// is used to do this interpolation; it involves uneven mesh point
151// spacing.
152//
153// The method for generating the particle momenta uses the
154// standard random elimination method and involves the following
155// steps:
156//
157// For model_type = 1,2,3,4 which are functions of pt,y (see following):
158// (1) The y range is computed using the pseudorapidity (eta)
159// range and includes ample cushioning around the sides
160// along the eta acceptance edges.
161// (2) The transverse momentum (pt) and rapidity (y) are
162// randomly chosen within the specified ranges.
163// (3) The pseudorapidity is computed for this (pt,y) value
164// (and the mass for each pid) and checked against the
165// pseudorapidity acceptance range.
166// (4) If the pseudorapidity is within range then the one-particle
167// model distribution is calculated at this point and its ratio
168// to the maximum value throughout (pt,eta) acceptance region
169// is calculated.
170// (5) Another random number is called and if less than the ratio
171// from step#4 the particle momentum is used; if not, then
172// another trial value of (pt,y) is obtained.
173// (6) This continues until the required multiplicity for the
174// specific event and particle type has been satisfied.
175// (7) This process is repeated for the requested number of particle
176// types and events.
177//
178// For model_type = 5,6 (see following) which are input bin-by-bin
179// in pt,eta:
180// (1) The transverse momentum (pt) and pseudorapidity (eta) are
181// randomly chosen within the specified ranges.
182// (2) The one-particle model distribution is calculated at this
183// point and its ratio to the maximum value throughout the
184// (pt,eta) region is calculated.
185// (3) Another random number is called and if less than the ratio
186// from step(2) the particle momentum is used; if not then
187// another trial value of (pt,eta) is obtained.
188// (4) This continues until the required multiplicity for the
189// specific event and particle type has been satisfied.
190// (5) This process is repeated for the requested number of particle
191// types and events.
192//
193// Problematic parameter values are tested, bad input values are checked
194// and in some cases may be changed so that the program will not crash.
195// In some cases the code execution is stopped.
196// Some distributions and/or unusual model parameter values may cause the
197// code to hang up due to the poor performance of the "elimination"
198// method for very strongly peaked distributions. These are tested for
199// certain problematic values and if necessary these events are aborted.
200// A message, "*** Event No. 2903 ABORTED:" for example is printed
201// in the 'mult_gen.out' file. Temperatures .le. 0.01 GeV and rapidity
202// width parameters .le. 0.01 will cause the event to abort.
203//
204//
205//
206// III. DESCRIPTION OF THE INPUT:
207//
208//
209// The input is described below in the 'read' statements and also in
210// the sample input file. Some additional comments are as follows:
211//
212// (1) n_events - Selected number of events in run. Can be anything
213// .ge. 1.
214// (2) n_pid_type - Number of particle ID types to include in the
215// particle list. e.g. pi(+) and pi(-) are counted
216// separately. The limit is set by parameter npid
217// in the accompanying include file 'Parameter_values.inc'
218// and is presently set at 20.
219// (3) model_type - equals 1,2,3,4,5 or 6 so far. See comments in
220// Function dNdpty to see what is calculated.
221// The models included are:
222// = 1, Factorized mt exponential, Gaussian rapidity model
223// = 2, Pratt non-expanding, spherical thermal source model
224// = 3, Bertsch non-expanding spherical thermal source model
225// = 4, Pratt spherically expanding, thermally equilibrated
226// source model.
227// = 5, Factorized pt and eta distributions input bin-by-bin.
228// = 6, Fully 2D pt,eta distributions input bin-by-bin.
229// NOTE: model_type = 1-4 are functions of (pt,y)
230// model_type = 5,6 are functions of (pt,eta)
231// (4) reac_plane_cntrl - Can be either 1,2,3 or 4 where:
232// = 1 to ignore reaction plane and anisotropic flow,
233// all distributions will be azimuthally symm.
234// = 2 to use a fixed reaction plane angle for all
235// events in the run.
236// = 3 to assume a randomly varying reaction plane
237// angle for each event as determined by a
238// Gaussian distribution.
239// = 4 to assume a randomly varying reaction plane
240// for each event in the run as determined by
241// a uniform distribution from 0 to 360 deg.
242// (5) PSIr_mean, PSIr_stdev - Reaction plane angle mean and Gaussian
243// std.dev. (both are in degrees) for cases
244// with reac_plane_cntrl = 2 (use mean value)
245// and 3. Note: these are read in regardless
246// of the value of reac_plane_cntrl.
247// (6) MultFac_mean, MultFac_stdev - Overall multiplicity scaling factor
248// for all PID types; mean and std.dev.;
249// for trigger fluctuations event-to-evt.
250// (7) pt_cut_min,pt_cut_max - Range of transverse momentum in GeV/c.
251// (8) eta_cut_min,eta_cut_max - Pseudorapidity range
252// (9) phi_cut_min,phi_cut_max - Azimuthal angular range in degrees.
253// (10) n_stdev_mult - Number of standard deviations about the mean value
254// of multiplicity to include in the random event-to-
255// event selection process. The maximum number of
256// steps that can be covered is determined by
257// parameter n_mult_max_steps in the accompanying
258// include file 'Parameter_values.inc' which is
259// presently set at 1000, but the true upper limit for
260// this is n_mult_max_steps - 1 = 999.
261// (11) n_stdev_temp - Same, except for the "Temperature" parameter.
262// (12) n_stdev_sigma- Same, except for the rapidity width parameter.
263// (13) n_stdev_expvel - Same, except for the expansion velocity parameter.
264// (14) n_stdev_PSIr - Same, except for the reaction plane angle
265// (15) n_stdev_Vn - Same, except for the anisotropy coefficients, Vn.
266// (16) n_stdev_MultFac - Same, except for the multiplicity scaling factor.
267// (17) n_integ_pts - Number of mesh points to use in the random model
268// parameter selection process. The upper limit is
269// set by parameter nmax_integ in the accompanying
270// include file 'Parameter_values.inc' which is presently
271// set at 100, but the true upper limit for n_integ_pts
272// is nmax_integ - 1 = 99.
273// (18) n_scan_pts - Number of mesh points to use to scan the (pt,y)
274// dependence of the model distributions looking for
275// the maximum value. The 2-D grid has
276// n_scan_pts * n_scan_pts points; no limit to size of
277// n_scan_pts.
278// (19) irand - Starting random number seed.
279//
280//**************************************************************************
281// FOR MODEL_TYPE = 1,2,3 or 4:
282// Input the following 7 lines for each particle type; repeat these
283// set of lines n_pid_type times:
284//
285// (a) gpid - Geant Particle ID code number
286// (b) mult_mean,mult_variance_control - Mean multiplicity and
287// variance control where:
288// mult_variance_control = 0 for no variance in multiplicity
289// mult_variance_control = 1 to allow Poisson distribution for
290// particle multiplicities for all events.
291// Note that a hard limit exists for the maximum possible
292// multiplicity for a given particle type per event. This is
293// determined by parameter factorial_max in accompanying include
294// file 'common_facfac.inc' and is presently set at 10000.
295// (c) Temp_mean, Temp_stdev - Temperature parameter mean (in GeV)
296// and standard deviation (Gaussian distribution assumed).
297// (d) sigma_mean, sigma_stdev - Rapidity distribution width (sigma)
298// parameter mean and standard deviation (Gaussian distribution
299// assumed).
300// (e) expvel_mean, expvel_stdev - S. Pratt expansion velocity
301// (in units of c) mean and standard deviation (Gaussian
302// distribution assumed).
303// (f) Vn_mean(k); k=1,4 - Anisotropic flow parameters, mean values
304// for Fourier component n=1.
305// (g) Vn_stdev(k); k=1,4 - Anisotropic flow parameters, std.dev.
306// values for Fourier component n=1.
307//
308// Repeat the last two lines of input for remaining Fourier
309// components n=2,3...6. Include all 6 sets of parameters
310// even if these are not used by the model for Vn(pt,y) (set
311// unused parameter means and std.dev. to 0.0). List 4 values
312// on every line, even though for n=even the 4th quantity is
313// not used.
314//
315//**************************************************************************
316// FOR MODEL_TYPE = 5 input the following set of lines for each particle
317// type; repeat these n_pid_type times.
318//
319// (a) gpid - Geant Particle ID code number
320// (b) mult_mean,mult_variance_control - Mean multiplicity and
321// variance control where:
322// mult_variance_control = 0 for no variance in multiplicity
323// mult_variance_control = 1 to allow Poisson distribution for
324// particle multiplicities for all events.
325// (c) pt_start, eta_start - minimum starting values for pt, eta
326// input for the bin-by-bin distributions.
327// (d) n_pt_bins, n_eta_bins - # input pt and eta bins.
328// (e) delta_pt, pt_bin - pt bin size and function value, repeat for
329// each pt bin.
330// (f) delta_eta, eta_bin - eta bin size and function value, repeat
331// for each eta bin.
332// (g) Vn_mean(k); k=1,4 - Anisotropic flow parameters, mean values
333// for Fourier component n=1.
334// (h) Vn_stdev(k); k=1,4 - Anisotropic flow parameters, std.dev.
335// values for Fourier component n=1.
336//
337// Repeat the last two lines of input for remaining Fourier
338// components n=2,3...6. Include all 6 sets of parameters
339// even if these are not used by the model for Vn(pt,y) (set
340// unused parameter means and std.dev. to 0.0). List 4 values
341// on every line, even though for n=even the 4th quantity is
342// not used.
343//
344// NOTE: The pt, eta ranges must fully include the requested ranges
345// in input #4 and 5 above; else the code execution will stop.
346//
347// Also, variable bin sizes are permitted for the input distributions.
348//
349// Also, this input distribution is used for all events in the run;
350// no fluctuations in this "parent" distribution are allowed from
351// event-to-event.
352//
353//**************************************************************************
354// FOR MODEL_TYPE = 6 input the following set of lines for each particle
355// type; repeat these n_pid_type times.
356//
357// (a) gpid - Geant Particle ID code number
358// (b) mult_mean,mult_variance_control - Mean multiplicity and
359// variance control where:
360// mult_variance_control = 0 for no variance in multiplicity
361// mult_variance_control = 1 to allow Poisson distribution for
362// particle multiplicities for all events.
363// (c) pt_start, eta_start - minimum starting values for pt, eta
364// input for the bin-by-bin distributions.
365// (d) n_pt_bins, n_eta_bins - # input pt and eta bins.
366// (e) delta_pt - pt bin size, repeat for each pt bin.
367// (f) delta_eta - eta bin size, repeat for each eta bin.
368// (g) i,j,pt_eta_bin(i,j) - read pt (index = i) and eta (index = j)
369// bin numbers and bin value for full 2D space
370// (h) Vn_mean(k); k=1,4 - Anisotropic flow parameters, mean values
371// for Fourier component n=1.
372// (i) Vn_stdev(k); k=1,4 - Anisotropic flow parameters, std.dev.
373// values for Fourier component n=1.
374//
375// Repeat the last two lines of input for remaining Fourier
376// components n=2,3...6. Include all 6 sets of parameters
377// even if these are not used by the model for Vn(pt,y) (set
378// unused parameter means and std.dev. to 0.0). List 4 values
379// on every line, even though for n=even the 4th quantity is
380// not used.
381//
382// NOTE: The pt, eta ranges must fully include the requested ranges
383// in input #4 and 5 above; else the code execution will stop.
384//
385// Also, variable bin sizes are permitted for the input distributions.
386//
387// Also, this input distribution is used for all events in the run;
388// no fluctuations in this "parent" distribution are allowed from
389// event-to-event.
390//
391///////////////////////////////////////////////////////////////////////////////
392
393
eae0fe66 394#include <Riostream.h>
1a2762e8 395
31d87da2 396#include "TMevSim.h"
397#include"TMevSimPartTypeParams.h"
1a2762e8 398#include "TParticle.h"
1a2762e8 399
400#ifndef WIN32
401# define multgen multgen_
402# define type_of_call
403#else
404# define multgen MULTGEN
405# define type_of_call _stdcall
406#endif
407
408
409ClassImp(TMevSim)
410
411
412extern "C" void type_of_call multgen();
413
414//______________________________________________________________________________
415TMevSim::TMevSim(Int_t nEvents, Int_t modelType, Int_t reacPlaneCntrl,
416 Float_t psiRMean, Float_t psiRStDev, Float_t multFacMean, Float_t multFacStDev,
417 Float_t ptCutMin, Float_t ptCutMax, Float_t etaCutMin, Float_t etaCutMax,
418 Float_t phiCutMin, Float_t phiCutMax, Int_t irand) : TGenerator("MevSim", "MevSim")
419{
420// TMevSim constructor: initializes all the event-wide variables of MevSim with
421// user supplied values, or with the default ones (declared in the header file).
422// It also allocates space for the array which will store parameters specific to
423// each particle species.
424// Caution: Setting nEvents > 1 will have no effect, since only the last generated
425// event will be stored in POUT COMMON, and therefore only one event can be
426// accessible at a time.
427
428 fNEvents = nEvents;
429 fModelType = modelType;
430 fReacPlaneCntrl = reacPlaneCntrl;
431 fPsiRMean = psiRMean;
432 fPsiRStDev = psiRStDev;
433 fMultFacMean = multFacMean;
434 fMultFacStDev = multFacStDev;
435 fPtCutMin = ptCutMin;
436 fPtCutMax = ptCutMax;
437 fEtaCutMin = etaCutMin;
438 fEtaCutMax = etaCutMax;
439 fPhiCutMin = phiCutMin;
440 fPhiCutMax = phiCutMax;
441 fNStDevMult = fNStDevTemp = fNStDevSigma = fNStDevExpVel = fNStdDevPSIr = fNStDevVn = fNStDevMultFac = 3.0;
442 fNIntegPts = 100;
443 fNScanPts = 100;
444 firand = irand;
445 fParticleTypeParameters = new TClonesArray("TMevSimPartTypeParams",10);
4319640b 446 fNPDGCodes = 0;
1a2762e8 447 DefineParticles();
448}
449//______________________________________________________________________________
450TMevSim::~TMevSim()
451{
452// TMevSim destructor: destroys the object and all the particle information stored
453// in the list.
454
455 if (fParticleTypeParameters) {
456 fParticleTypeParameters->Clear();
457 delete fParticleTypeParameters;
458 fParticleTypeParameters = 0;
459 }
460}
461//______________________________________________________________________________
96df9573 462TMevSim::TMevSim(TMevSim& mevsim) : TGenerator(mevsim) {
1a2762e8 463// The copy constructor
464
465 *this = mevsim;
466}
467//______________________________________________________________________________
31d87da2 468
469TMevSim& TMevSim::operator=(const TMevSim& mevsim) {
1a2762e8 470// An assignment operator: initializes all the event-wide variables of MevSim with
471// the ones from a copied object. It also copies the parameters specific to
472// each particle species.
473
474 fNEvents = mevsim.GetNEvents();
475 fModelType = mevsim.GetModelType();
476 fReacPlaneCntrl = mevsim.GetReacPlaneCntrl();
477 fPsiRMean = mevsim.GetPsiRMean();
478 fPsiRStDev = mevsim.GetPsiRStDev();
479 fMultFacMean = mevsim.GetMultFacMean();
480 fMultFacStDev = mevsim.GetMultFacStDev();
481 fPtCutMin = mevsim.GetPtCutMin();
482 fPtCutMax = mevsim.GetPtCutMax();
483 fEtaCutMin = mevsim.GetEtaCutMin();
484 fEtaCutMax = mevsim.GetEtaCutMax();
485 fPhiCutMin = mevsim.GetPhiCutMin();
486 fPhiCutMax = mevsim.GetPhiCutMax();
487 fNStDevMult = mevsim.GetNStDevMult();
488 fNStDevTemp = mevsim.GetNStDevTemp();
489 fNStDevSigma =GetNStDevSigma();
490 fNStDevExpVel = mevsim.GetNStDevExpVel();
491 fNStdDevPSIr = mevsim.GetNStDevPSIr();
492 fNStDevVn = mevsim.GetNStDevVn();
493 fNStDevMultFac = mevsim.GetNStDevMultFac();
494 fNIntegPts = mevsim.GetNintegPts();
495 fNScanPts = mevsim.GetNScanPts();
496 firand = mevsim.firand;
497 fParticleTypeParameters = new TClonesArray("TMevSimPartTypeParams",mevsim.GetNPidTypes());
498 for (int i=0; i< mevsim.GetNPidTypes(); i++)
499 {
500 TMevSimPartTypeParams *temp = 0;
501 mevsim.GetPartTypeParamsByIndex(i,temp);
502 fParticleTypeParameters->AddLast(temp);
503 }
504 DefineParticles();
505 return (*this);
506}
507//______________________________________________________________________________
508void TMevSim::Initialize() {
509// TMevSim initialization: creates an input file for the FORTRAN
510// program MevSim. Converts all the event-wide information and particle
511// specific information to the format readable by MevSim and writes it
512// to disk in current directory.
513// Caution: At least one TMevSimPartTypeParams object must be created and
514// added to the collection before event generation can start.
515
516 TMevSimPartTypeParams * params = 0;
517
518
519 ofstream *file = new ofstream("mult_gen.in",ios::out | ios::trunc);
520 // Write out the parameters to the pramameter file
521 *file << " " << fNEvents << " ! Number of Events \n";
522 *file << " " << GetNPidTypes() << " \n";
523 *file << " " << fModelType << " \n";
524 *file << " " << fReacPlaneCntrl << " \n";
525 file->setf(ios::showpoint);
526 *file << " " << fPsiRMean << " " << fPsiRStDev << " \n";
527 *file << " " << fMultFacMean << " " << fMultFacStDev << " \n";
528 *file << " " << fPtCutMin << " " << fPtCutMax << " \n";
529 *file << " " << fEtaCutMin << " " << fEtaCutMax << " \n";
530 *file << " " << fPhiCutMin << " " << fPhiCutMax << " \n";
531 *file << " " << fNStDevMult << " \n";
532 *file << " " << fNStDevTemp << " \n";
533 *file << " " << fNStDevSigma << " \n";
534 *file << " " << fNStDevExpVel << " \n";
535 *file << " " << fNStdDevPSIr << " \n";
536 *file << " " << fNStDevVn << " \n";
537 *file << " " << fNStDevMultFac << " \n";
538 *file << " " << fNIntegPts << " \n";
539 *file << " " << fNScanPts << " \n";
540 *file << " " << firand << " \n";
541 // Write out particle specific information
542 for (Int_t i=0; i< (fParticleTypeParameters->GetLast() + 1); i++) {
543
544 params = (TMevSimPartTypeParams *) ((*fParticleTypeParameters)[i]);
545
546 *file << " " << params->GetGPid() << " ! Particle GEANT Pid \n";
547 *file << " " << params->GetMultMean() << " " << params->GetMultVarianceControl() << " \n";
548 *file << " " << params->GetTempMean() << " " << params->GetTempStDev() << " \n";
549 *file << " " << params->GetSigmaMean() << " " << params->GetSigmaStDev() << " \n";
550 *file << " " << params->GetExpVelMean() << " " << params->GetExpVelStDev() << " \n";
551
552 for (Int_t cnt1 = 0; cnt1 < NFLOWTERMS; cnt1++) {
553 *file << " ";
04504820 554 Int_t cnt2;
555 for (cnt2 = 0; cnt2 < 4; cnt2++) *file << params->GetVnMeanComponent(cnt1, cnt2) << " ";
1a2762e8 556 *file << " \n ";
04504820 557 for (cnt2 = 0; cnt2 < 4; cnt2++) *file << params->GetVnStDevComponent(cnt1, cnt2) << " ";
1a2762e8 558 *file << " \n";
559 }
560 }
561 file->close();
562
563}
564//______________________________________________________________________________
31d87da2 565void TMevSim::GenerateEvent() {
1a2762e8 566// Generates one MevSim event. TMevSim::Initialize() must be called prior
567// to calling this function.
568
31d87da2 569 Info("GenerateEvent","Calling FORTRAN multgen()");
1a2762e8 570 multgen();
571}
572
573//______________________________________________________________________________
96df9573 574Int_t TMevSim::ImportParticles(TClonesArray *particles, Option_t */*option*/)
1a2762e8 575{
576// Read in particles created by MevSim into the TClonesArray(). The Initialize()
577// and GenrateEvent() functions must be called prior to calling this funtion.
578// The particles are read from the COMMON POUT. Right now the only provided
579// information is Geant PID, 3 momentum components and the energy of the particle.
580
581 if (particles == 0) return 0;
31d87da2 582 TClonesArray &aParticles = *particles;
583 aParticles.Clear();
1a2762e8 584
585 Int_t totpart = 0;
586 for (Int_t nrpidtype=0; nrpidtype < (fParticleTypeParameters->GetLast() + 1); nrpidtype++) {
587 Int_t nrpart = 0;
588 Int_t pidcode = ((TMevSimPartTypeParams *) (*fParticleTypeParameters)[nrpidtype])->GetGPid();
589 while ((TRACK.pout[(4*nrpart+3)*NPID+nrpidtype] > 0.0) || (TRACK.pout[(4*nrpart)*NPID+nrpidtype] != 0.0)) {
590 int poffset = 4*nrpart*NPID+nrpidtype;
591 Float_t px = TRACK.pout[poffset];
592 poffset += NPID;
593 Float_t py = TRACK.pout[poffset];
594 poffset += NPID;
595 Float_t pz = TRACK.pout[poffset];
596 poffset += NPID;
597 Float_t mass = TRACK.pout[poffset];
31d87da2 598 new(aParticles[totpart+nrpart]) TParticle(
1a2762e8 599 PDGFromId(pidcode), // Get the PDG ID from GEANT ID
600 0,
601 0,
602 0,
603 0,
604 0,
605 px,
606 py,
607 pz,
608 sqrt(mass*mass+px*px+py*py+pz*pz),
609 0,
610 0,
611 0,
612 0);
613 nrpart++;
614 }
615 totpart += nrpart;
616 }
617 return totpart;
618}
619//______________________________________________________________________________
620void TMevSim::SetNEvents(Int_t nEvents ) {
621// Sets the number of events to be generated by MevSim.
622// Caution: Setting nEvents > 1 will have no effect, since only the last generated
623// event will be stored in POUT COMMON, and therefore only one event can be
624// accessible at a time.
625
626 fNEvents = nEvents;
627}
628//______________________________________________________________________________
629Int_t TMevSim::GetNEvents() const {
630 return fNEvents;
631}
632//______________________________________________________________________________
633Int_t TMevSim::GetNPidTypes() const {
634 return fParticleTypeParameters->GetLast()+1;
635}
636//______________________________________________________________________________
637void TMevSim::SetModelType(Int_t modelType) {
638 fModelType = modelType;
639}
640//______________________________________________________________________________
641Int_t TMevSim::GetModelType() const {
642 return fModelType;
643}
644//______________________________________________________________________________
645void TMevSim::SetReacPlaneCntrl(Int_t reacPlaneCntrl) {
646 fReacPlaneCntrl = reacPlaneCntrl;
647}
648//______________________________________________________________________________
649Int_t TMevSim::GetReacPlaneCntrl() const {
650 return fReacPlaneCntrl;
651}
652//______________________________________________________________________________
653void TMevSim::SetPsiRParams(Float_t psiRMean, Float_t psiRStDev) {
654 fPsiRMean = psiRMean;
655 fPsiRStDev = psiRStDev;
656}
657//______________________________________________________________________________
658Float_t TMevSim::GetPsiRMean() const {
659 return fPsiRMean;
660}
661//______________________________________________________________________________
662Float_t TMevSim::GetPsiRStDev() const {
663 return fPsiRStDev;
664}
665//______________________________________________________________________________
666void TMevSim::SetMultFacParams(Float_t multFacMean, Float_t multFacStDev) {
667 fMultFacMean = multFacMean;
668 fMultFacStDev = multFacStDev;
669}
670//______________________________________________________________________________
671Float_t TMevSim::GetMultFacMean() const {
672 return fMultFacMean;
673}
674//______________________________________________________________________________
675Float_t TMevSim::GetMultFacStDev() const {
676 return fMultFacStDev;
677}
678//______________________________________________________________________________
679void TMevSim::SetPtCutRange(Float_t ptCutMin, Float_t ptCutMax) {
680 fPtCutMin = ptCutMin;
681 fPtCutMax = ptCutMax;
682}
683//______________________________________________________________________________
684Float_t TMevSim::GetPtCutMin() const {
685 return fPtCutMin;
686}
687//______________________________________________________________________________
688Float_t TMevSim::GetPtCutMax() const {
689 return fPtCutMax;
690}
691//______________________________________________________________________________
692void TMevSim::SetEtaCutRange(Float_t etaCutMin, Float_t etaCutMax) { fEtaCutMin = etaCutMin;
693 fEtaCutMax = etaCutMax;
694}
695
696//______________________________________________________________________________
697 Float_t TMevSim::GetEtaCutMin() const {
698 return fEtaCutMin;
699}
700//______________________________________________________________________________
701 Float_t TMevSim::GetEtaCutMax() const {
702 return fEtaCutMax;
703}
704//______________________________________________________________________________
705void TMevSim::SetPhiCutRange(Float_t phiCutMin, Float_t phiCutMax) {
706 fPhiCutMin = phiCutMin;
707 fPhiCutMax = phiCutMax;
708}
709//______________________________________________________________________________
710Float_t TMevSim::GetPhiCutMin() const {
711 return fPhiCutMin;
712}
713//______________________________________________________________________________
714Float_t TMevSim::GetPhiCutMax() const {
715 return fPhiCutMax;
716}
717//______________________________________________________________________________
718void TMevSim::SetNStDevMult(Float_t nStDevMult) {
719 fNStDevMult = nStDevMult;
720}
721//______________________________________________________________________________
722Float_t TMevSim::GetNStDevMult() const {
723 return fNStDevMult;
724}
725//______________________________________________________________________________
726void TMevSim::SetNStDevTemp(Float_t nStDevTemp) {
727 fNStDevTemp = nStDevTemp;
728}
729//______________________________________________________________________________
730Float_t TMevSim::GetNStDevTemp() const {
731 return fNStDevTemp;
732}
733//______________________________________________________________________________
734void TMevSim::SetNStDevSigma(Float_t nStDevSigma) {
735 fNStDevSigma = nStDevSigma;
736}
737//______________________________________________________________________________
738Float_t TMevSim::GetNStDevSigma() const {
739 return fNStDevSigma;
740}
741//______________________________________________________________________________
742void TMevSim::SetNStDevExpVel(Float_t nStDevExpVel) {
743 fNStDevExpVel = nStDevExpVel;
744}
745//______________________________________________________________________________
746Float_t TMevSim::GetNStDevExpVel() const {
747 return fNStDevExpVel;
748}
749//______________________________________________________________________________
750void TMevSim::SetNStDevPSIr(Float_t nStDevPSIr) {
751 fNStdDevPSIr = nStDevPSIr;
752}
753//______________________________________________________________________________
754Float_t TMevSim::GetNStDevPSIr() const {
755 return fNStdDevPSIr;
756}
757//______________________________________________________________________________
758void TMevSim::SetNStDevVn(Float_t nStDevVn) {
759 fNStDevVn = nStDevVn;
760}
761//______________________________________________________________________________
762Float_t TMevSim::GetNStDevVn() const {
763 return fNStDevVn;
764}
765//______________________________________________________________________________
766void TMevSim::SetNStDevMultFac(Float_t nStDevMultFac) {
767 fNStDevMultFac = nStDevMultFac;
768}
769//______________________________________________________________________________
770Float_t TMevSim::GetNStDevMultFac() const {
771 return fNStDevMultFac;
772}
773//______________________________________________________________________________
774void TMevSim::SetNIntegPts(Int_t nIntegPts) {
775 fNIntegPts = nIntegPts;
776}
777//______________________________________________________________________________
778Int_t TMevSim::GetNintegPts() const {
779 return fNIntegPts;
780}
781//______________________________________________________________________________
782void TMevSim::SetNScanPts(Int_t nScanPts) {
783 fNScanPts = nScanPts;
784}
785//______________________________________________________________________________
786Int_t TMevSim::GetNScanPts() const {
787 return fNScanPts;
788}
789//______________________________________________________________________________
790void TMevSim::AddPartTypeParams(TMevSimPartTypeParams *params) {
791// Add the particle specied parameters and the end of the list.
792
793 //cout << params << " " << fParticleTypeParameters << endl;
794
795 //fParticleTypeParameters->Dump();
796 params->Dump();
797
798 Int_t last = fParticleTypeParameters->GetLast();
799 new ((*fParticleTypeParameters)[last+1]) TMevSimPartTypeParams(*params);
800}
801//______________________________________________________________________________
802void TMevSim::SetPartTypeParams(Int_t index, TMevSimPartTypeParams *params)
803{
804// Create the new copy particle species parameters provided by params, and store
805// them in the position designated by index.
806
807 *((TMevSimPartTypeParams *) ((*fParticleTypeParameters)[index])) = *params;
808}
809//______________________________________________________________________________
31d87da2 810void TMevSim::GetPartTypeParamsByIndex(Int_t index, TMevSimPartTypeParams *params) const
1a2762e8 811{
812// Return the particle parameters stored in the list at the postion index.
813// Returns NULL if index is out of bounds.
814
815 if ((index < fParticleTypeParameters->GetLast()) && (index >= 0))
816 params = (TMevSimPartTypeParams *) (*fParticleTypeParameters)[index];
817 else
818 params = NULL;
819}
820//______________________________________________________________________________
31d87da2 821void TMevSim::GetPartTypeParamsByGPid(Int_t gpid, TMevSimPartTypeParams *params) const
1a2762e8 822{
823// Return the particle parameters for the particle with Geant PID gpid.
824// Returns NULL if the parameters for such particle do not exist in the list.
825
826 Int_t i = -1;
827
828 while (++i <= fParticleTypeParameters->GetLast())
829 {
830 if (((TMevSimPartTypeParams *) (*fParticleTypeParameters)[i])->GetGPid() == gpid)
831 {
832 params = (TMevSimPartTypeParams *) (*fParticleTypeParameters)[i];
833 return;
834 }
835 }
836 params = NULL;
837 return;
838}
839//_____________________________________________________________________________
840Int_t TMevSim::PDGFromId(Int_t id) const
841{
842 //
843 // Return PDG code and pseudo ENDF code from Geant3 code
844 //
845 if(id>0 && id<fNPDGCodes) return fPDGCode[id];
846 else return -1;
847}
848//_____________________________________________________________________________
849void TMevSim::DefineParticles()
850{
851 //
852 // Load standard numbers for GEANT particles and PDG conversion
853 fPDGCode[fNPDGCodes++]=-99; // 0 = unused location
854 fPDGCode[fNPDGCodes++]=22; // 1 = photon
855 fPDGCode[fNPDGCodes++]=-11; // 2 = positron
856 fPDGCode[fNPDGCodes++]=11; // 3 = electron
857 fPDGCode[fNPDGCodes++]=12; // 4 = neutrino e
858 fPDGCode[fNPDGCodes++]=-13; // 5 = muon +
859 fPDGCode[fNPDGCodes++]=13; // 6 = muon -
860 fPDGCode[fNPDGCodes++]=111; // 7 = pi0
861 fPDGCode[fNPDGCodes++]=211; // 8 = pi+
862 fPDGCode[fNPDGCodes++]=-211; // 9 = pi-
863 fPDGCode[fNPDGCodes++]=130; // 10 = Kaon Long
864 fPDGCode[fNPDGCodes++]=321; // 11 = Kaon +
865 fPDGCode[fNPDGCodes++]=-321; // 12 = Kaon -
866 fPDGCode[fNPDGCodes++]=2112; // 13 = Neutron
867 fPDGCode[fNPDGCodes++]=2212; // 14 = Proton
868 fPDGCode[fNPDGCodes++]=-2212; // 15 = Anti Proton
869 fPDGCode[fNPDGCodes++]=310; // 16 = Kaon Short
870 fPDGCode[fNPDGCodes++]=221; // 17 = Eta
871 fPDGCode[fNPDGCodes++]=3122; // 18 = Lambda
872 fPDGCode[fNPDGCodes++]=3222; // 19 = Sigma +
873 fPDGCode[fNPDGCodes++]=3212; // 20 = Sigma 0
874 fPDGCode[fNPDGCodes++]=3112; // 21 = Sigma -
875 fPDGCode[fNPDGCodes++]=3322; // 22 = Xi0
876 fPDGCode[fNPDGCodes++]=3312; // 23 = Xi-
877 fPDGCode[fNPDGCodes++]=3334; // 24 = Omega-
878 fPDGCode[fNPDGCodes++]=-2112; // 25 = Anti Proton
879 fPDGCode[fNPDGCodes++]=-3122; // 26 = Anti Proton
880 fPDGCode[fNPDGCodes++]=-3222; // 27 = Anti Sigma -
881 fPDGCode[fNPDGCodes++]=-3212; // 28 = Anti Sigma 0
882 fPDGCode[fNPDGCodes++]=-3112; // 29 = Anti Sigma 0
883 fPDGCode[fNPDGCodes++]=-3322; // 30 = Anti Xi 0
884 fPDGCode[fNPDGCodes++]=-3312; // 31 = Anti Xi +
885 fPDGCode[fNPDGCodes++]=-3334; // 32 = Anti Omega +
886}
887