CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Public Attributes | Private Attributes
CMSCGEN Class Reference

#include <CMSCGEN.h>

Public Member Functions

 CMSCGEN ()
 
double cos_theta ()
 
double dNdEmudEnu (double Enu, double Emu, double theta)
 
double flux ()
 
int generate ()
 
int generateNuMu ()
 
int initialize (double, double, double, double, CLHEP::HepRandomEngine *, bool, bool)
 
int initialize (double, double, double, double, int, bool, bool)
 
int initializeNuMu (double, double, double, double, double, double, double, double, double, CLHEP::HepRandomEngine *)
 
int initializeNuMu (double, double, double, double, double, double, double, double, double, int)
 
double momentum_times_charge ()
 
 ~CMSCGEN ()
 

Public Attributes

double AR
 
double dNdEmudEnuMax
 
double negabs
 
double negfrac
 
double ProdAlt
 
double Rnunubar
 
double sigma
 

Private Attributes

double b0
 
double b0c [3]
 
double b1
 
double b1c [3]
 
double b2
 
double b2c [3]
 
double c
 
double c1
 
double c2
 
double cemax
 
double cmax
 
double cmax_in
 
double cmax_max
 
double cmax_min
 
double cmin
 
double cmin_in
 
double corr [101]
 
bool delRanGen
 
double enumax
 
double enumin
 
int initialization
 
double integrated_flux
 
double Lfac
 
double Lmax
 
double Lmin
 
double pe [9]
 
double pmax
 
double pmin
 
double pmin_max
 
double pmin_min
 
double pq
 
CLHEP::HepRandomEngine * RanGen2
 
bool TIFOnly_const
 
bool TIFOnly_lin
 
double xemax
 
double xemin
 

Detailed Description

Definition at line 30 of file CMSCGEN.h.

Constructor & Destructor Documentation

CMSCGEN::CMSCGEN ( )

Definition at line 13 of file CMSCGEN.cc.

13  : initialization(0), RanGen2(0), delRanGen(false)
14 {
15 }
CLHEP::HepRandomEngine * RanGen2
Definition: CMSCGEN.h:78
int initialization
Definition: CMSCGEN.h:37
bool delRanGen
Definition: CMSCGEN.h:79
CMSCGEN::~CMSCGEN ( )

Definition at line 17 of file CMSCGEN.cc.

References delRanGen, and RanGen2.

18 {
19  if (delRanGen)
20  delete RanGen2;
21 }
CLHEP::HepRandomEngine * RanGen2
Definition: CMSCGEN.h:78
bool delRanGen
Definition: CMSCGEN.h:79

Member Function Documentation

double CMSCGEN::cos_theta ( )

Definition at line 462 of file CMSCGEN.cc.

References c, gather_cfg::cout, and initialization.

Referenced by CosmicMuonGenerator::nextEvent().

463 {
464 
465  if(initialization==1)
466  {
467  // here convert between coordinate systems:
468  return -c;
469  }
470  else
471  {
472  std::cout << " >>> CMSCGEN <<< warning: not initialized" << std::endl;
473  return -0.9999;
474  }
475 
476 }
int initialization
Definition: CMSCGEN.h:37
tuple cout
Definition: gather_cfg.py:121
double c
Definition: CMSCGEN.h:47
double CMSCGEN::dNdEmudEnu ( double  Enu,
double  Emu,
double  theta 
)

Definition at line 577 of file CMSCGEN.cc.

References alpha, AR, funct::cos(), epsilon, N_A, funct::pow(), ProdAlt, Rearth, sigma, funct::sin(), and SurfaceOfEarth.

Referenced by generateNuMu(), and initializeNuMu().

577  {
578  double cthetaNu = 1. + ctheta; //swap cos(theta) from down to up range
579  double thetas = asin(sin(acos(cthetaNu))*(Rearth-SurfaceOfEarth)/(Rearth+ProdAlt));
580  double costhetas = cos(thetas);
581  double dNdEnudW = 0.0286*pow(Enu,-2.7)*(1./(1.+(6.*Enu*costhetas)/115.)+0.213/(1.+(1.44*Enu*costhetas)/850.)); //cm^2*s*sr*GeV
582  double dNdEmudEnu = N_A*sigma/alpha*dNdEnudW*1./(1.+Emu/epsilon)*
583  (Enu-Emu+AR/3*(Enu*Enu*Enu-Emu*Emu*Emu)/(Enu*Enu));
584  return dNdEmudEnu;
585 }
float alpha
Definition: AMPTWrapper.h:95
double sigma
Definition: CMSCGEN.h:119
double AR
Definition: CMSCGEN.h:120
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
double ProdAlt
Definition: CMSCGEN.h:118
const double N_A
const double SurfaceOfEarth
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
double dNdEmudEnu(double Enu, double Emu, double theta)
Definition: CMSCGEN.cc:577
const double epsilon
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
const double Rearth
double CMSCGEN::flux ( )

Definition at line 478 of file CMSCGEN.cc.

References gather_cfg::cout, initialization, and integrated_flux.

479 {
480 
481  if(initialization==1)
482  {
483  return integrated_flux;
484  }
485  else
486  {
487  std::cout << " >>> CMSCGEN <<< warning: not initialized" << std::endl;
488  return -0.9999;
489  }
490 
491 }
int initialization
Definition: CMSCGEN.h:37
double integrated_flux
Definition: CMSCGEN.h:69
tuple cout
Definition: gather_cfg.py:121
int CMSCGEN::generate ( )

Definition at line 256 of file CMSCGEN.cc.

References b0, b0c, b1, b1c, b2, b2c, c, cemax, cmax, cmin, corr, gather_cfg::cout, alignCSCRings::e, initialization, gen::k, dttmaxenums::L, Lfac, Lmin, siStripFEDMonitor_P5_cff::Max, siStripFEDMonitor_P5_cff::Min, pe, pq, mix_2012_Summer_inTimeOnly_cff::prob, diffTwoXMLs::r1, diffTwoXMLs::r2, RanGen2, mathSSE::sqrt(), TIFOnly_const, TIFOnly_lin, xemax, xemin, and detailsBasic3DVector::z.

Referenced by CosmicMuonGenerator::nextEvent().

257 {
258 
259  if(initialization==0)
260  {
261  std::cout << " >>> CMSCGEN <<< warning: not initialized" << std::endl;
262  return -1;
263  }
264 
265  // note: use historical notation (fortran version l3cgen.f)
266 
267  //
268  // +++ determine x = 1/e**2
269  //
270  // explanation: the energy distribution
271  // dn/d(1/e**2) = dn/de * e**3 = dn/dlog10(e) * e**2
272  // is parametrized by a polynomial. accordingly xe = 1/e**2 is sampled
273  // and e calculated
274  //
275  // need precise random variable with high precison since for
276  // emin = 3 GeV energies around 3000 GeV are very rare!
277  //
278 
279  double r1, r2, r3;
280  double xe, e, ce, L, L2;
281  int k;
282  double prob;
283 
284  double c_max;
285  double z, z_max;
286 
287  while (1)
288  {
289  prob = RanGen2->flat();
290  r1 = double(prob);
291  prob = RanGen2->flat();
292  r2 = double(prob);
293 
294  xe = xemin+r1*(xemax-xemin);
295 
296  if( (1./sqrt(xe)<3) && TIFOnly_const == true) { //generate constant energy dependence for E<2GeV, only used for TIF
297  //compute constant to match to CMSCGEN spectrum
298  e=3.;
299  L = log10(e);
300  L2 = L*L;
301 
302  ce = (((((((pe[8]*L
303  +pe[7])*L
304  +pe[6])*L
305  +pe[5])*L
306  +pe[4])*L
307  +pe[3])*L
308  +pe[2])*L
309  +pe[1])*L
310  +pe[0];
311 
312  k = int ((L-Lmin)*Lfac+1.);
313  k = TMath::Max(1,TMath::Min(k,100));
314  ce = ce * corr[k];
315 
316  e = 1./sqrt(xe);
317  if(r2 < ( e*e*e*ce/(cemax*3.*3.*3.) )) break;
318 
319  }else if( (1./sqrt(xe)<3) && TIFOnly_lin == true) { //generate linear energy dependence for E<2GeV, only used for TIF
320  //compute constant to match to CMSCGEN spectrum
321  e=3.;
322  L = log10(e);
323  L2 = L*L;
324 
325  ce = (((((((pe[8]*L
326  +pe[7])*L
327  +pe[6])*L
328  +pe[5])*L
329  +pe[4])*L
330  +pe[3])*L
331  +pe[2])*L
332  +pe[1])*L
333  +pe[0];
334 
335  k = int ((L-Lmin)*Lfac+1.);
336  k = TMath::Max(1,TMath::Min(k,100));
337  ce = ce * corr[k];
338 
339  e = 1./sqrt(xe);
340  if(r2 < ( e*e*e*e*ce/(cemax*3.*3.*3.*3.) )) break;
341 
342  }else{ //this is real CMSCGEN energy-dependence
343 
344  e = 1./sqrt(xe);
345  L = log10(e);
346  L2 = L*L;
347 
348  ce = (((((((pe[8]*L
349  +pe[7])*L
350  +pe[6])*L
351  +pe[5])*L
352  +pe[4])*L
353  +pe[3])*L
354  +pe[2])*L
355  +pe[1])*L
356  +pe[0];
357 
358  k = int ((L-Lmin)*Lfac+1.);
359  k = TMath::Max(1,TMath::Min(k,100));
360  ce = ce * corr[k];
361 
362  if(cemax*r2 < ce) break;
363 
364  } //end of CMSCGEN energy-dependence
365  } //end of while
366 
367  pq = e;
368 
369  //
370  // +++ charge ratio 1.280
371  //
372  prob = RanGen2->flat();
373  r3 = double(prob);
374 
375  double charg = 1.;
376  if(r3 < 0.439) charg=-1.;
377 
378  pq = pq*charg;
379 
380  //
381  // +++ determine cos(angle)
382  //
383  // simple trial and rejection method
384  //
385 
386  // first calculate energy dependent coefficients b_i
387 
388  if(TIFOnly_const == true && e<3.){ //forTIF (when E<2GeV use angles of 2GeV cosmic)
389  L = log10(3.);
390  L2 = L*L;
391  }
392  if(TIFOnly_lin == true && e<3.){ //forTIF (when E<2GeV use angles of 2GeV cosmic)
393  L = log10(3.);
394  L2 = L*L;
395  }
396 
397  b0 = b0c[0] + b0c[1] * L + b0c[2]* L2;
398  b1 = b1c[0] + b1c[1] * L + b1c[2]* L2;
399  b2 = b2c[0] + b2c[1] * L + b2c[2]* L2;
400 
401  //
402  // need to know the maximum of z(c)
403  //
404  // first calculate c for which c distribution z(c) = maximum
405  //
406  // (note: maximum of curve is NOT always at c = -1, but never at c = -0.1)
407  //
408 
409  // try extremal value (from z'(c) = 0), but only if z''(c) < 0
410  //
411  // z'(c) = b1 + b2 * c => at c_max = - b1 / (2 b_2) is z'(c) = 0
412  //
413  // z''(c) = b2
414 
415  c_max = -1.;
416 
417  if(b2<0.) {
418  c_max = - 0.5 * b1/b2;
419  if(c_max < -1.) c_max = -1.;
420  if(c_max > -0.1) c_max = -0.1;
421  }
422 
423  z_max = b0 + b1 * c_max + b2 * c_max * c_max;
424 
425  // again cut out explicitly regions of zero flux
426  double c_cut = -0.42 + L*0.35;
427  if (c_cut > cmax) c_cut = cmax;
428 
429  // now we throw dice:
430 
431  while (1)
432  {
433  prob = RanGen2->flat();
434  r1 = double(prob);
435  prob = RanGen2->flat();
436  r2 = double(prob);
437  c = cmin + (c_cut-cmin)*r1;
438  z = b0 + b1 * c + b2 * c*c;
439  if (z > z_max*r2) break;
440  }
441 
442  return 0;
443 
444 }
double b1c[3]
Definition: CMSCGEN.h:74
CLHEP::HepRandomEngine * RanGen2
Definition: CMSCGEN.h:78
int initialization
Definition: CMSCGEN.h:37
double corr[101]
Definition: CMSCGEN.h:75
double b0
Definition: CMSCGEN.h:65
float float float z
double cmax
Definition: CMSCGEN.h:42
bool TIFOnly_const
Definition: CMSCGEN.h:81
double xemin
Definition: CMSCGEN.h:49
double Lfac
Definition: CMSCGEN.h:60
T sqrt(T t)
Definition: SSEVec.h:48
double b0c[3]
Definition: CMSCGEN.h:74
double b2
Definition: CMSCGEN.h:67
int k[5][pyjets_maxn]
bool TIFOnly_lin
Definition: CMSCGEN.h:82
double cmin
Definition: CMSCGEN.h:41
double pe[9]
Definition: CMSCGEN.h:73
double b1
Definition: CMSCGEN.h:66
double b2c[3]
Definition: CMSCGEN.h:74
tuple cout
Definition: gather_cfg.py:121
double xemax
Definition: CMSCGEN.h:50
double pq
Definition: CMSCGEN.h:46
double cemax
Definition: CMSCGEN.h:71
double c
Definition: CMSCGEN.h:47
double Lmin
Definition: CMSCGEN.h:58
int CMSCGEN::generateNuMu ( )

Definition at line 588 of file CMSCGEN.cc.

References c, cmax, cmin, gather_cfg::cout, dNdEmudEnu(), dNdEmudEnuMax, enumax, enumin, initialization, pmax, pmin, pq, RanGen2, RPCpg::rate(), and Rnunubar.

Referenced by CosmicMuonGenerator::nextEvent().

588  {
589  if(initialization==0)
590  {
591  std::cout << " >>> CMSCGEN <<< warning: not initialized" << std::endl;
592  return -1;
593  }
594 
595  double ctheta, Emu;
596  while (1) {
597  ctheta = cmin + (cmax-cmin)*RanGen2->flat();
598  Emu = pmin + (pmax-pmin)*RanGen2->flat();
599  double Enu = enumin + (enumax-enumin)*RanGen2->flat();
600  double rate = dNdEmudEnu(Enu, Emu, ctheta);
601  if (rate > dNdEmudEnuMax*RanGen2->flat()) break;
602  }
603 
604  c = -ctheta; //historical sign convention
605 
606  pq = Emu;
607  //
608  // +++ nu/nubar ratio (~1.2)
609  //
610  double charg = 1.; //nubar -> mu+
611  if (RanGen2->flat() > Rnunubar/(1.+Rnunubar))
612  charg = -1.; //neutrino -> mu-
613 
614  pq = pq*charg;
615 
616 
617  //int flux += this event rate
618 
619  return 1;
620 }
double enumax
Definition: CMSCGEN.h:87
double pmax
Definition: CMSCGEN.h:40
CLHEP::HepRandomEngine * RanGen2
Definition: CMSCGEN.h:78
int initialization
Definition: CMSCGEN.h:37
double cmax
Definition: CMSCGEN.h:42
double cmin
Definition: CMSCGEN.h:41
double pmin
Definition: CMSCGEN.h:39
double rate(double x)
Definition: Constants.cc:3
double dNdEmudEnu(double Enu, double Emu, double theta)
Definition: CMSCGEN.cc:577
tuple cout
Definition: gather_cfg.py:121
double pq
Definition: CMSCGEN.h:46
double c
Definition: CMSCGEN.h:47
double enumin
Definition: CMSCGEN.h:86
double dNdEmudEnuMax
Definition: CMSCGEN.h:122
double Rnunubar
Definition: CMSCGEN.h:117
int CMSCGEN::initialize ( double  pmin_in,
double  pmax_in,
double  thetamin_in,
double  thetamax_in,
CLHEP::HepRandomEngine *  rnd,
bool  TIFOnly_constant,
bool  TIFOnly_linear 
)

Definition at line 23 of file CMSCGEN.cc.

References b0, b0c, b1, b1c, b2, b2c, c1, c2, cemax, cmax, cmax_in, cmax_max, cmax_min, cmin, cmin_in, corr, gather_cfg::cout, delRanGen, initialization, integrated_flux, gen::k, dttmaxenums::L, Lfac, Lmax, Lmin, AlCaHLTBitMon_ParallelJobs::p, p1, p2, pe, pmax, pmin, pmin_max, pmin_min, funct::pow(), RanGen2, alignCSCRings::s, TIFOnly_const, TIFOnly_lin, xemax, and xemin.

Referenced by initialize(), and CosmicMuonGenerator::initialize().

24 {
25  if (delRanGen)
26  delete RanGen2;
27  RanGen2 = rnd;
28  delRanGen = false;
29 
30  //set bools for TIFOnly options (E<2GeV with unphysical energy dependence)
31  TIFOnly_const = TIFOnly_constant;
32  TIFOnly_lin = TIFOnly_linear;
33 
34 
35  // units: GeV
36 
37  // WARNING: coordinate system:
38  // - to outside world define z axis downwards, i.e.
39  // muon coming from above, vertically: cos = 1
40  // (used for backward compatibility)
41  // - internally use frame with z axis upwards, i.e.
42  // muon coming from above, vertically: cos = -1
43  // (corresponds to CMS note definition)
44 
45  //set cmin and cmax, here convert between coordinate systems:
46  cmin_in = - TMath::Cos(thetamin_in);//input angle already converted from Deg to Rad!
47  cmax_in = - TMath::Cos(thetamax_in);//input angle already converted from Deg to Rad!
48 
49 
50  //allowed energy range
51  pmin_min = 3.;
52  //pmin_max = 100.;
53  pmin_max = 3000.;
54  pmax = 3000.;
55  //allowed angular range
56  //cmax_max = -0.1,
57  cmax_max = -0.01,
58  cmax_min = -0.9999;
59 
60  if(TIFOnly_const == true || TIFOnly_lin == true) pmin_min = 0.; //forTIF
61 
62  // set pmin
63  if(pmin_in < pmin_min || pmin_in > pmin_max){
64  std::cout << " >>> CMSCGEN.initialize <<< warning: illegal pmin_in =" << pmin_in;
65  return(-1);
66  } else if(pmax_in > pmax ){
67  std::cout << " >>> CMSCGEN.initialize <<< warning: illegal pmax_in =" << pmax_in;
68  return(-1);
69  }else{
70  pmin = pmin_in;
71  pmax = pmax_in;
72  xemax = 1./(pmin*pmin);
73  xemin = 1./(pmax*pmax);
74  }
75 
76 
77  // set cmax and cmin
78  if(cmax_in < cmax_min || cmax_in > cmax_max)
79  {
80  std::cout << " >>> CMSCGEN.initialize <<< warning: illegal cmax_in =" << cmax_in;
81  return(-1);
82  }
83  else
84  {
85  cmax = cmax_in;
86  cmin = cmin_in;
87  }
88 
89 
90  initialization = 1;
91 
92  if(TIFOnly_const == true || TIFOnly_lin == true) pmin_min = 3.; //forTIF
93 
94  // Lmin = log10(pmin_min);
95  Lmin = log10(pmin);
96  Lmax = log10(pmax);
97  Lfac = 100./(Lmax-Lmin);
98 
99  //
100  // +++ coefficients for energy spectrum
101  //
102 
103  pe[0] = -1.;
104  pe[1] = 6.22176;
105  pe[2] = -13.9404;
106  pe[3] = 18.1643;
107  pe[4] = -9.22784;
108  pe[5] = 1.99234;
109  pe[6] = -0.156434;
110  pe[7] = 0.;
111  pe[8] = 0.;
112 
113  //
114  // +++ coefficients for cos theta distribution
115  //
116 
117  b0c[0] = 0.6639;
118  b0c[1] = -0.9587;
119  b0c[2] = 0.2772;
120 
121  b1c[0] = 5.820;
122  b1c[1] = -6.864;
123  b1c[2] = 1.367;
124 
125  b2c[0] = 10.39;
126  b2c[1] = -8.593;
127  b2c[2] = 1.547;
128 
129  //
130  // +++ calculate correction table for different cos theta dependence!
131  // reference range: c1 to c2
132  //
133  // explanation: the parametrization of the energy spectrum as used above
134  // is the integral over the c = cos(zenith angle) range -1...-0.1
135  // since the c distribution depends on energy, the integrated energy
136  // spectrum depends on this range. Here a correction factor is determined,
137  // based on the linear c dependence of the c distribution.
138  // The correction is calculated for 100 bins in L = log10(energy).
139  //
140  // +++ in same loop calculate integrated flux
141  // (integrated over angles and momentum)
142 
143  c1 = -1.;
144  c2 = -0.1;
145 
146  double cemax0 = 1.0;
147  double L, L2;
148  double s;
149  double p, p1, p2;
150  double integral_here, integral_ref;
151  double c_cut;
152 
153  integrated_flux = 0.;
154 
155  for(int k=1; k<=100; k++)
156  {
157  L = Lmin + (k-0.5)/Lfac;
158  L2 = L*L;
159  p = pow(10,L);
160  p1 = pow(10,L-0.5/Lfac);
161  p2 = pow(10,L+0.5/Lfac);
162 
163  b0 = b0c[0] + b0c[1] * L + b0c[2]* L2;
164  b1 = b1c[0] + b1c[1] * L + b1c[2]* L2;
165  b2 = b2c[0] + b2c[1] * L + b2c[2]* L2;
166 
167  // cut out explicitly regions of zero flux
168  // (for low momentum and near horizontal showers)
169  // since parametrization for z distribution doesn't work here
170  // (can become negative)
171 
172  c_cut = -0.42 + L*0.35;
173 
174  if (c_cut > c2) c_cut = c2;
175 
176  integral_ref = b0 * (c_cut - c1)
177  + b1/2. * (c_cut*c_cut - c1*c1)
178  + b2/3. * (c_cut*c_cut*c_cut - c1*c1*c1);
179 
180  if (c_cut > cmax) c_cut = cmax;
181 
182  integral_here = b0 * (c_cut - cmin)
183  + b1/2. * (c_cut*c_cut - cmin*cmin)
184  + b2/3. * (c_cut*c_cut*c_cut - cmin*cmin*cmin);
185 
186  corr[k] = integral_here/integral_ref;
187 
188  s = (((((((pe[8]*L
189  +pe[7])*L
190  +pe[6])*L
191  +pe[5])*L
192  +pe[4])*L
193  +pe[3])*L
194  +pe[2])*L
195  +pe[1])*L
196  +pe[0];
197 
198  integrated_flux += 1./pow(p,3) * s * corr[k] * (p2-p1);
199 
200  /*
201  std::cout << k << " "
202  << corr[k] << " "
203  << p << " "
204  << s << " "
205  << p1 << " "
206  << p2 << " "
207  << integrated_flux << " "
208  << std::endl;
209  */
210 
211  // std::cout << k << " " << corr[k] << " " << std::endl;
212  }
213 
214  integrated_flux *= 1.27E3;
215  std::cout << " >>> CMSCGEN.initialize <<< " <<
216  " Integrated flux = " << integrated_flux << " /m**2/s " << std::endl;
217 
218  // find approximate peak value, for Monte Carlo sampling
219  // peak is near L = 2
220 
221  double ce;
222 
223  ce = (((((((pe[8]*2.
224  +pe[7])*2.
225  +pe[6])*2.
226  +pe[5])*2.
227  +pe[4])*2.
228  +pe[3])*2.
229  +pe[2])*2.
230  +pe[1])*2.
231  +pe[0];
232 
233  // normalize to 0.5 (not 1) to have some margin if peak is not at L=2
234  //
235  ce = 0.5/ce;
236 
237  for (int k=0; k<9; k++)
238  {
239  pe[k] = pe[k]*ce;
240  }
241 
242  cemax = cemax0*corr[50];
243 
244  return initialization;
245 }
double b1c[3]
Definition: CMSCGEN.h:74
double c2
Definition: CMSCGEN.h:63
double pmax
Definition: CMSCGEN.h:40
CLHEP::HepRandomEngine * RanGen2
Definition: CMSCGEN.h:78
double c1
Definition: CMSCGEN.h:62
int initialization
Definition: CMSCGEN.h:37
double corr[101]
Definition: CMSCGEN.h:75
double b0
Definition: CMSCGEN.h:65
double cmax_min
Definition: CMSCGEN.h:55
double cmin_in
Definition: CMSCGEN.h:43
double cmax
Definition: CMSCGEN.h:42
bool TIFOnly_const
Definition: CMSCGEN.h:81
double xemin
Definition: CMSCGEN.h:49
double cmax_max
Definition: CMSCGEN.h:56
double Lfac
Definition: CMSCGEN.h:60
bool delRanGen
Definition: CMSCGEN.h:79
double b0c[3]
Definition: CMSCGEN.h:74
double b2
Definition: CMSCGEN.h:67
double Lmax
Definition: CMSCGEN.h:59
double p2[4]
Definition: TauolaWrapper.h:90
double integrated_flux
Definition: CMSCGEN.h:69
int k[5][pyjets_maxn]
bool TIFOnly_lin
Definition: CMSCGEN.h:82
double pmin_min
Definition: CMSCGEN.h:52
double cmin
Definition: CMSCGEN.h:41
double pmin
Definition: CMSCGEN.h:39
double pe[9]
Definition: CMSCGEN.h:73
double pmin_max
Definition: CMSCGEN.h:53
double b1
Definition: CMSCGEN.h:66
double p1[4]
Definition: TauolaWrapper.h:89
double b2c[3]
Definition: CMSCGEN.h:74
tuple cout
Definition: gather_cfg.py:121
double xemax
Definition: CMSCGEN.h:50
double cemax
Definition: CMSCGEN.h:71
double cmax_in
Definition: CMSCGEN.h:44
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
double Lmin
Definition: CMSCGEN.h:58
int CMSCGEN::initialize ( double  pmin_in,
double  pmax_in,
double  thetamin_in,
double  thetamax_in,
int  RanSeed,
bool  TIFOnly_constant,
bool  TIFOnly_linear 
)

Definition at line 247 of file CMSCGEN.cc.

References delRanGen, and initialize().

248 {
249  CLHEP::HepRandomEngine *rnd = new CLHEP::HepJamesRandom;
250  //set seed for Random Generator (seed can be controled by config-file), P.Biallass 2006
251  rnd->setSeed(RanSeed, 0);
252  delRanGen = true;
253  return initialize(pmin_in, pmax_in, thetamin_in, thetamax_in, rnd, TIFOnly_constant, TIFOnly_linear);
254 }
int initialize(double, double, double, double, CLHEP::HepRandomEngine *, bool, bool)
Definition: CMSCGEN.cc:23
bool delRanGen
Definition: CMSCGEN.h:79
int CMSCGEN::initializeNuMu ( double  pmin_in,
double  pmax_in,
double  thetamin_in,
double  thetamax_in,
double  Enumin_in,
double  Enumax_in,
double  Phimin_in,
double  Phimax_in,
double  ProdAlt_in,
CLHEP::HepRandomEngine *  rnd 
)

Definition at line 495 of file CMSCGEN.cc.

References AR, cmax, cmin, gather_cfg::cout, delRanGen, dNdEmudEnu(), dNdEmudEnuMax, alignCSCRings::e, enumax, enumin, i, initialization, integrated_flux, negabs, negfrac, pmax, pmin, ProdAlt, RanGen2, RPCpg::rate(), Rnunubar, and sigma.

Referenced by CosmicMuonGenerator::initialize(), and initializeNuMu().

496 {
497  if (delRanGen)
498  delete RanGen2;
499  RanGen2 = rnd;
500  delRanGen = false;
501 
502  ProdAlt = ProdAlt_in;
503 
504  Rnunubar = 1.2;
505 
506  sigma = (0.72*Rnunubar+0.09)/(1+Rnunubar)*1.e-38; //cm^2GeV^-1
507 
508  AR = (0.69+0.06*Rnunubar)/(0.09+0.72*Rnunubar);
509 
510 
511  //set smin and smax, here convert between coordinate systems:
512  pmin = pmin_in;
513  pmax = pmax_in;
514  cmin = TMath::Cos(thetamin_in);//input angle already converted from Deg to Rad!
515  cmax = TMath::Cos(thetamax_in);//input angle already converted from Deg to Rad!
516  enumin = (Enumin_in < 10.) ? 10. : Enumin_in; //no nu's below 10GeV
517  enumax = Enumax_in;
518 
519 
520  //do initial run of flux rate to determine Maximum
521  integrated_flux = 0.;
522  dNdEmudEnuMax = 0.;
523  negabs = 0.;
524  negfrac = 0.;
525  int trials = 100000;
526  for (int i=0; i<trials; ++i) {
527  double ctheta = cmin + (cmax-cmin)*RanGen2->flat();
528  double Emu = pmin + (pmax-pmin)*RanGen2->flat();
529  double Enu = enumin + (enumax-enumin)*RanGen2->flat();
530  double rate = dNdEmudEnu(Enu, Emu, ctheta);
531  //std::cout << "trial=" << i << " ctheta=" << ctheta << " Emu=" << Emu << " Enu=" << Enu
532  // << " rate=" << rate << std::endl;
533  //std::cout << "cmin=" << cmin << " cmax=" << cmax
534  // << " pmin=" << pmin << " pmax=" << pmax
535  // << " enumin=" << enumin << " enumax=" << enumax << std::endl;
536  if (rate > 0.) {
538  if (rate > dNdEmudEnuMax)
540  }
541  else negabs++;
542  }
543  negfrac = negabs/trials;
544  integrated_flux /= trials;
545 
546  std::cout << "CMSCGEN::initializeNuMu: After " << trials << " trials:" << std::endl;
547  std::cout << "dNdEmudEnuMax=" << dNdEmudEnuMax << std::endl;
548  std::cout << "negfrac=" << negfrac << std::endl;
549 
550  //multiply by phase space boundaries
552  integrated_flux *= (Phimax_in-Phimin_in);
555  //remove negative phase space areas which do not contribute anything
556  integrated_flux *= (1.-negfrac);
557  std::cout << " >>> CMSCGEN.initializeNuMu <<< " <<
558  " Integrated flux = " << integrated_flux << " units??? " << std::endl;
559 
560 
561  initialization = 1;
562 
563  return initialization;
564 
565 }
int i
Definition: DBlmapReader.cc:9
double enumax
Definition: CMSCGEN.h:87
double sigma
Definition: CMSCGEN.h:119
double AR
Definition: CMSCGEN.h:120
double pmax
Definition: CMSCGEN.h:40
CLHEP::HepRandomEngine * RanGen2
Definition: CMSCGEN.h:78
double ProdAlt
Definition: CMSCGEN.h:118
double negfrac
Definition: CMSCGEN.h:123
int initialization
Definition: CMSCGEN.h:37
double cmax
Definition: CMSCGEN.h:42
bool delRanGen
Definition: CMSCGEN.h:79
double negabs
Definition: CMSCGEN.h:123
double integrated_flux
Definition: CMSCGEN.h:69
double cmin
Definition: CMSCGEN.h:41
double pmin
Definition: CMSCGEN.h:39
double rate(double x)
Definition: Constants.cc:3
double dNdEmudEnu(double Enu, double Emu, double theta)
Definition: CMSCGEN.cc:577
tuple cout
Definition: gather_cfg.py:121
double enumin
Definition: CMSCGEN.h:86
double dNdEmudEnuMax
Definition: CMSCGEN.h:122
double Rnunubar
Definition: CMSCGEN.h:117
int CMSCGEN::initializeNuMu ( double  pmin_in,
double  pmax_in,
double  thetamin_in,
double  thetamax_in,
double  Enumin_in,
double  Enumax_in,
double  Phimin_in,
double  Phimax_in,
double  ProdAlt_in,
int  RanSeed 
)

Definition at line 567 of file CMSCGEN.cc.

References delRanGen, and initializeNuMu().

568 {
569  CLHEP::HepRandomEngine *rnd = new CLHEP::HepJamesRandom;
570  //set seed for Random Generator (seed can be controled by config-file), P.Biallass 2006
571  rnd->setSeed(RanSeed, 0);
572  delRanGen = true;
573  return initializeNuMu(pmin_in, pmax_in, thetamin_in, thetamax_in, Enumin_in, Enumax_in, Phimin_in, Phimax_in, ProdAlt_in, rnd);
574 }
bool delRanGen
Definition: CMSCGEN.h:79
int initializeNuMu(double, double, double, double, double, double, double, double, double, CLHEP::HepRandomEngine *)
Definition: CMSCGEN.cc:495
double CMSCGEN::momentum_times_charge ( )

Definition at line 447 of file CMSCGEN.cc.

References gather_cfg::cout, initialization, and pq.

Referenced by CosmicMuonGenerator::nextEvent().

448 {
449 
450  if(initialization==1)
451  {
452  return pq;
453  }
454  else
455  {
456  std::cout << " >>> CMSCGEN <<< warning: not initialized" << std::endl;
457  return -9999.;
458  }
459 
460 }
int initialization
Definition: CMSCGEN.h:37
tuple cout
Definition: gather_cfg.py:121
double pq
Definition: CMSCGEN.h:46

Member Data Documentation

double CMSCGEN::AR

Definition at line 120 of file CMSCGEN.h.

Referenced by dNdEmudEnu(), and initializeNuMu().

double CMSCGEN::b0
private

Definition at line 65 of file CMSCGEN.h.

Referenced by generate(), and initialize().

double CMSCGEN::b0c[3]
private

Definition at line 74 of file CMSCGEN.h.

Referenced by generate(), and initialize().

double CMSCGEN::b1
private

Definition at line 66 of file CMSCGEN.h.

Referenced by generate(), and initialize().

double CMSCGEN::b1c[3]
private

Definition at line 74 of file CMSCGEN.h.

Referenced by generate(), and initialize().

double CMSCGEN::b2
private

Definition at line 67 of file CMSCGEN.h.

Referenced by generate(), and initialize().

double CMSCGEN::b2c[3]
private

Definition at line 74 of file CMSCGEN.h.

Referenced by generate(), and initialize().

double CMSCGEN::c
private

Definition at line 47 of file CMSCGEN.h.

Referenced by cos_theta(), generate(), and generateNuMu().

double CMSCGEN::c1
private

Definition at line 62 of file CMSCGEN.h.

Referenced by initialize().

double CMSCGEN::c2
private

Definition at line 63 of file CMSCGEN.h.

Referenced by initialize().

double CMSCGEN::cemax
private

Definition at line 71 of file CMSCGEN.h.

Referenced by generate(), and initialize().

double CMSCGEN::cmax
private

Definition at line 42 of file CMSCGEN.h.

Referenced by generate(), generateNuMu(), initialize(), and initializeNuMu().

double CMSCGEN::cmax_in
private

Definition at line 44 of file CMSCGEN.h.

Referenced by initialize().

double CMSCGEN::cmax_max
private

Definition at line 56 of file CMSCGEN.h.

Referenced by initialize().

double CMSCGEN::cmax_min
private

Definition at line 55 of file CMSCGEN.h.

Referenced by initialize().

double CMSCGEN::cmin
private

Definition at line 41 of file CMSCGEN.h.

Referenced by generate(), generateNuMu(), initialize(), and initializeNuMu().

double CMSCGEN::cmin_in
private

Definition at line 43 of file CMSCGEN.h.

Referenced by initialize().

double CMSCGEN::corr[101]
private

Definition at line 75 of file CMSCGEN.h.

Referenced by generate(), and initialize().

bool CMSCGEN::delRanGen
private

Definition at line 79 of file CMSCGEN.h.

Referenced by initialize(), initializeNuMu(), and ~CMSCGEN().

double CMSCGEN::dNdEmudEnuMax

Definition at line 122 of file CMSCGEN.h.

Referenced by generateNuMu(), and initializeNuMu().

double CMSCGEN::enumax
private

Definition at line 87 of file CMSCGEN.h.

Referenced by generateNuMu(), and initializeNuMu().

double CMSCGEN::enumin
private

Definition at line 86 of file CMSCGEN.h.

Referenced by generateNuMu(), and initializeNuMu().

int CMSCGEN::initialization
private
double CMSCGEN::integrated_flux
private

Definition at line 69 of file CMSCGEN.h.

Referenced by flux(), initialize(), and initializeNuMu().

double CMSCGEN::Lfac
private

Definition at line 60 of file CMSCGEN.h.

Referenced by generate(), and initialize().

double CMSCGEN::Lmax
private

Definition at line 59 of file CMSCGEN.h.

Referenced by initialize().

double CMSCGEN::Lmin
private

Definition at line 58 of file CMSCGEN.h.

Referenced by generate(), and initialize().

double CMSCGEN::negabs

Definition at line 123 of file CMSCGEN.h.

Referenced by initializeNuMu().

double CMSCGEN::negfrac

Definition at line 123 of file CMSCGEN.h.

Referenced by initializeNuMu().

double CMSCGEN::pe[9]
private

Definition at line 73 of file CMSCGEN.h.

Referenced by generate(), and initialize().

double CMSCGEN::pmax
private

Definition at line 40 of file CMSCGEN.h.

Referenced by generateNuMu(), initialize(), and initializeNuMu().

double CMSCGEN::pmin
private

Definition at line 39 of file CMSCGEN.h.

Referenced by generateNuMu(), initialize(), and initializeNuMu().

double CMSCGEN::pmin_max
private

Definition at line 53 of file CMSCGEN.h.

Referenced by initialize().

double CMSCGEN::pmin_min
private

Definition at line 52 of file CMSCGEN.h.

Referenced by initialize().

double CMSCGEN::pq
private

Definition at line 46 of file CMSCGEN.h.

Referenced by generate(), generateNuMu(), and momentum_times_charge().

double CMSCGEN::ProdAlt

Definition at line 118 of file CMSCGEN.h.

Referenced by dNdEmudEnu(), and initializeNuMu().

CLHEP::HepRandomEngine* CMSCGEN::RanGen2
private

Definition at line 78 of file CMSCGEN.h.

Referenced by generate(), generateNuMu(), initialize(), initializeNuMu(), and ~CMSCGEN().

double CMSCGEN::Rnunubar

Definition at line 117 of file CMSCGEN.h.

Referenced by generateNuMu(), and initializeNuMu().

double CMSCGEN::sigma

Definition at line 119 of file CMSCGEN.h.

Referenced by dNdEmudEnu(), and initializeNuMu().

bool CMSCGEN::TIFOnly_const
private

Definition at line 81 of file CMSCGEN.h.

Referenced by generate(), and initialize().

bool CMSCGEN::TIFOnly_lin
private

Definition at line 82 of file CMSCGEN.h.

Referenced by generate(), and initialize().

double CMSCGEN::xemax
private

Definition at line 50 of file CMSCGEN.h.

Referenced by generate(), and initialize().

double CMSCGEN::xemin
private

Definition at line 49 of file CMSCGEN.h.

Referenced by generate(), and initialize().