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 ()
 
void setRandomEngine (CLHEP::HepRandomEngine *v)
 
 ~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 469 of file CMSCGEN.cc.

References c, gather_cfg::cout, and initialization.

Referenced by CosmicMuonGenerator::nextEvent().

470 {
471 
472  if(initialization==1)
473  {
474  // here convert between coordinate systems:
475  return -c;
476  }
477  else
478  {
479  std::cout << " >>> CMSCGEN <<< warning: not initialized" << std::endl;
480  return -0.9999;
481  }
482 
483 }
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 584 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().

584  {
585  double cthetaNu = 1. + ctheta; //swap cos(theta) from down to up range
586  double thetas = asin(sin(acos(cthetaNu))*(Rearth-SurfaceOfEarth)/(Rearth+ProdAlt));
587  double costhetas = cos(thetas);
588  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
589  double dNdEmudEnu = N_A*sigma/alpha*dNdEnudW*1./(1.+Emu/epsilon)*
590  (Enu-Emu+AR/3*(Enu*Enu*Enu-Emu*Emu*Emu)/(Enu*Enu));
591  return dNdEmudEnu;
592 }
float alpha
Definition: AMPTWrapper.h:95
double sigma
Definition: CMSCGEN.h:121
double AR
Definition: CMSCGEN.h:122
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
double ProdAlt
Definition: CMSCGEN.h:120
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:584
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 485 of file CMSCGEN.cc.

References gather_cfg::cout, initialization, and integrated_flux.

486 {
487 
488  if(initialization==1)
489  {
490  return integrated_flux;
491  }
492  else
493  {
494  std::cout << " >>> CMSCGEN <<< warning: not initialized" << std::endl;
495  return -0.9999;
496  }
497 
498 }
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 263 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().

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

595  {
596  if(initialization==0)
597  {
598  std::cout << " >>> CMSCGEN <<< warning: not initialized" << std::endl;
599  return -1;
600  }
601 
602  double ctheta, Emu;
603  while (1) {
604  ctheta = cmin + (cmax-cmin)*RanGen2->flat();
605  Emu = pmin + (pmax-pmin)*RanGen2->flat();
606  double Enu = enumin + (enumax-enumin)*RanGen2->flat();
607  double rate = dNdEmudEnu(Enu, Emu, ctheta);
608  if (rate > dNdEmudEnuMax*RanGen2->flat()) break;
609  }
610 
611  c = -ctheta; //historical sign convention
612 
613  pq = Emu;
614  //
615  // +++ nu/nubar ratio (~1.2)
616  //
617  double charg = 1.; //nubar -> mu+
618  if (RanGen2->flat() > Rnunubar/(1.+Rnunubar))
619  charg = -1.; //neutrino -> mu-
620 
621  pq = pq*charg;
622 
623 
624  //int flux += this event rate
625 
626  return 1;
627 }
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:584
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:124
double Rnunubar
Definition: CMSCGEN.h:119
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 30 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().

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

References delRanGen, and initialize().

255 {
256  CLHEP::HepRandomEngine *rnd = new CLHEP::HepJamesRandom;
257  //set seed for Random Generator (seed can be controled by config-file), P.Biallass 2006
258  rnd->setSeed(RanSeed, 0);
259  delRanGen = true;
260  return initialize(pmin_in, pmax_in, thetamin_in, thetamax_in, rnd, TIFOnly_constant, TIFOnly_linear);
261 }
int initialize(double, double, double, double, CLHEP::HepRandomEngine *, bool, bool)
Definition: CMSCGEN.cc:30
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 502 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().

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

References delRanGen, and initializeNuMu().

575 {
576  CLHEP::HepRandomEngine *rnd = new CLHEP::HepJamesRandom;
577  //set seed for Random Generator (seed can be controled by config-file), P.Biallass 2006
578  rnd->setSeed(RanSeed, 0);
579  delRanGen = true;
580  return initializeNuMu(pmin_in, pmax_in, thetamin_in, thetamax_in, Enumin_in, Enumax_in, Phimin_in, Phimax_in, ProdAlt_in, rnd);
581 }
bool delRanGen
Definition: CMSCGEN.h:79
int initializeNuMu(double, double, double, double, double, double, double, double, double, CLHEP::HepRandomEngine *)
Definition: CMSCGEN.cc:502
double CMSCGEN::momentum_times_charge ( )

Definition at line 454 of file CMSCGEN.cc.

References gather_cfg::cout, initialization, and pq.

Referenced by CosmicMuonGenerator::nextEvent().

455 {
456 
457  if(initialization==1)
458  {
459  return pq;
460  }
461  else
462  {
463  std::cout << " >>> CMSCGEN <<< warning: not initialized" << std::endl;
464  return -9999.;
465  }
466 
467 }
int initialization
Definition: CMSCGEN.h:37
tuple cout
Definition: gather_cfg.py:121
double pq
Definition: CMSCGEN.h:46
void CMSCGEN::setRandomEngine ( CLHEP::HepRandomEngine *  v)

Definition at line 23 of file CMSCGEN.cc.

References delRanGen, RanGen2, and findQualityFiles::v.

Referenced by CosmicMuonGenerator::setRandomEngine().

23  {
24  if (delRanGen)
25  delete RanGen2;
26  RanGen2 = v;
27  delRanGen = false;
28 }
CLHEP::HepRandomEngine * RanGen2
Definition: CMSCGEN.h:78
bool delRanGen
Definition: CMSCGEN.h:79

Member Data Documentation

double CMSCGEN::AR

Definition at line 122 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(), setRandomEngine(), and ~CMSCGEN().

double CMSCGEN::dNdEmudEnuMax

Definition at line 124 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 125 of file CMSCGEN.h.

Referenced by initializeNuMu().

double CMSCGEN::negfrac

Definition at line 125 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 120 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(), setRandomEngine(), and ~CMSCGEN().

double CMSCGEN::Rnunubar

Definition at line 119 of file CMSCGEN.h.

Referenced by generateNuMu(), and initializeNuMu().

double CMSCGEN::sigma

Definition at line 121 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().