| 113 |
Double_t tof = 0.; |
Double_t tof = 0.; |
| 114 |
|
|
| 115 |
// Energy (in GeV) |
// Energy (in GeV) |
| 116 |
|
//printf("generateprimary check fprimP0 = %f\n",fprim.fP0); |
| 117 |
Double_t kinEnergy = MomentumToKinE(fprim.fP0); |
Double_t kinEnergy = MomentumToKinE(fprim.fP0); |
| 118 |
Double_t e = fmass + kinEnergy; |
Double_t e = fmass + kinEnergy; |
| 119 |
|
|
| 172 |
if(PEmin==0.) PEmin=1.E-10; |
if(PEmin==0.) PEmin=1.E-10; |
| 173 |
fprim.fP0=Power((frandom->Uniform(0.,1.)*(Power(PEmax,alpha)-Power(PEmin,alpha))+Power(PEmin,alpha)),1./alpha); |
fprim.fP0=Power((frandom->Uniform(0.,1.)*(Power(PEmax,alpha)-Power(PEmin,alpha))+Power(PEmin,alpha)),1./alpha); |
| 174 |
} |
} |
| 175 |
|
cout<<"GenSpe fprim.fP0= "<<fprim.fP0<<endl; |
| 176 |
|
if(isEnergy) fprim.fP0=KinEToMomentum(fprim.fP0); |
| 177 |
|
|
| 178 |
|
} |
| 179 |
|
|
| 180 |
|
|
| 181 |
|
//Cecilia Pizzolotto: powerlaw spectrum 3 with the shape |
| 182 |
|
// J(E) = 0.5*(E + b * exp(-c * sqrt(E)))^-a |
| 183 |
|
// between PEmin and PEmax and with the input parameters a,b,c. |
| 184 |
|
// Valeria di Felice fits parameter values are: |
| 185 |
|
// protons: a,b,c= 2.70, 2.15, 0.21 |
| 186 |
|
// electrons: a,b,c= 0.0638, 1.248e-16, -38.248 |
| 187 |
|
void PamVMCPrimaryGenerator::GenSpe_3par(Double_t PEmin, Double_t PEmax, Double_t a, Double_t b, Double_t c) |
| 188 |
|
{ |
| 189 |
|
|
| 190 |
|
Bool_t found=0; |
| 191 |
|
Double_t funct_min, funct_max; |
| 192 |
|
funct_max = function3par(PEmin,a,b,c); |
| 193 |
|
funct_min = function3par(PEmax,a,b,c); |
| 194 |
|
// |
| 195 |
|
Double_t wurfP; |
| 196 |
|
Double_t wurfy ; |
| 197 |
|
//printf("in genspe3par^^^^%f ^^%f ^^^^^^^^%f ^^^^^%f^^^^^^^\n",PEmin,PEmax,funct_min,funct_max); |
| 198 |
|
//printf("in par^^ %f %f %f \n",a,b,c); |
| 199 |
|
while( found==0 ) |
| 200 |
|
{ |
| 201 |
|
wurfP = frandom->Uniform(PEmin,PEmax); |
| 202 |
|
wurfy = frandom->Uniform(funct_min,funct_max); |
| 203 |
|
if( wurfy<(function3par(wurfP,a,b,c) )) |
| 204 |
|
{ |
| 205 |
|
// this is ok! |
| 206 |
|
fprim.fP0=wurfP; |
| 207 |
|
found=1; |
| 208 |
|
} |
| 209 |
|
} |
| 210 |
|
//printf("exit+++++++++++++++++++ %f %f \n",wurfP,fprim.fP0); |
| 211 |
|
} |
| 212 |
|
|
| 213 |
|
|
| 214 |
|
|
| 215 |
|
// cecilia pizzolotto |
| 216 |
|
void PamVMCPrimaryGenerator::GenSpe_Flat(Double_t PEmin, Double_t PEmax, Double_t gamma, Bool_t isEnergy) |
| 217 |
|
{ |
| 218 |
|
// Generates a flat spectrum from PEmin to PElim. Then a power law |
| 219 |
|
Double_t PElim = 1.; |
| 220 |
|
//Double_t alpha = 1.+gamma; //integral spectral index |
| 221 |
|
|
| 222 |
|
Bool_t okflag=0.; |
| 223 |
|
Double_t throw_x =0.; |
| 224 |
|
Double_t throw_y =0.; |
| 225 |
|
|
| 226 |
|
while(okflag==0) |
| 227 |
|
{ |
| 228 |
|
throw_x=frandom->Uniform(PEmin,PEmax); |
| 229 |
|
// cout<<" x "<<throw_x<<endl; |
| 230 |
|
if(throw_x<=PElim) |
| 231 |
|
{ |
| 232 |
|
okflag=1.; |
| 233 |
|
} |
| 234 |
|
else |
| 235 |
|
{ |
| 236 |
|
throw_y=frandom->Uniform(0.,1.); |
| 237 |
|
if( throw_y<(1*pow(throw_x,gamma))) |
| 238 |
|
{ |
| 239 |
|
okflag=1.; |
| 240 |
|
} |
| 241 |
|
} |
| 242 |
|
} |
| 243 |
|
fprim.fP0=throw_x; |
| 244 |
|
//h->Fill(fprimf.P0); |
| 245 |
|
okflag=0.; // reset |
| 246 |
|
|
| 247 |
if(isEnergy) fprim.fP0=KinEToMomentum(fprim.fP0); |
if(isEnergy) fprim.fP0=KinEToMomentum(fprim.fP0); |
| 248 |
|
|
| 249 |
} |
} |
| 250 |
|
|
| 251 |
|
// Spherical distribution -- Test by Cecilia P july 2009 ---- |
| 252 |
|
// flusso isotropo su 2pi |
| 253 |
|
void PamVMCPrimaryGenerator::GenSphericalPhiThe() |
| 254 |
|
{ |
| 255 |
|
// Generate phi theta |
| 256 |
|
Double_t theta=0.; |
| 257 |
|
Double_t phi=0.; |
| 258 |
|
|
| 259 |
|
Double_t xcos = sqrt( frandom->Uniform(0.,1.) ); |
| 260 |
|
theta = acos(xcos); //RAD |
| 261 |
|
|
| 262 |
|
phi = frandom->Uniform(0.,2.*Pi()); |
| 263 |
|
|
| 264 |
|
SetDirection(theta, phi); |
| 265 |
|
return; |
| 266 |
|
} |
| 267 |
|
|
| 268 |
|
|
| 269 |
|
|
| 270 |
|
|
| 271 |
|
|
| 272 |
|
void PamVMCPrimaryGenerator::GenSphPhiThe(Double_t xmin, Double_t xmax, Double_t ymin, Double_t ymax, |
| 273 |
|
Double_t zmin, Double_t zmax) |
| 274 |
|
{ |
| 275 |
|
Bool_t trkGood = kFALSE; |
| 276 |
|
Double_t theta = 999.; |
| 277 |
|
Double_t phi = 0.; |
| 278 |
|
Double_t x2,y2,x3,y3; |
| 279 |
|
Double_t x0,y0,z0; |
| 280 |
|
|
| 281 |
|
//static const Double_t rad2deg = 57.2958; |
| 282 |
|
// S21 and S31 position/size taken as reference (z on top of det) |
| 283 |
|
// constraint: must pass throuth these planes |
| 284 |
|
static const Double_t s2_xmax=9.05, s2_ymax=7.55, s2_z=73.439; // z on top of det |
| 285 |
|
static const Double_t s3_xmax=9.05, s3_ymax=7.55, s3_z=26.093; // z on top of det |
| 286 |
|
|
| 287 |
|
//Double_t thetamax=3.14; |
| 288 |
|
//thetamax = atan((xmax+s3_xmax)/(zmax-s3_z)); |
| 289 |
|
//cout<<" Quanto รจ il theta max? "<<thetamax<<" in deg "<<thetamax*(90./Pi())<<endl; |
| 290 |
|
|
| 291 |
|
while (trkGood!=kTRUE) |
| 292 |
|
{ |
| 293 |
|
x0= frandom->Uniform(xmin,xmax); |
| 294 |
|
y0= frandom->Uniform(ymin,ymax); |
| 295 |
|
z0= frandom->Uniform(zmin,zmax); |
| 296 |
|
|
| 297 |
|
// Generate phi theta |
| 298 |
|
theta=999.; // init |
| 299 |
|
while (theta>=0.65) // take only theta smaller than 37deg=0.65rad |
| 300 |
|
{ |
| 301 |
|
Double_t xcos = sqrt( frandom->Uniform(0.,1.) ); |
| 302 |
|
theta = acos(xcos); //RAD |
| 303 |
|
} |
| 304 |
|
phi = frandom->Uniform(0.,2.*Pi()); |
| 305 |
|
|
| 306 |
|
// Calculate xy at the constraint |
| 307 |
|
Double_t fact2 = (s2_z-z0)/cos(theta); |
| 308 |
|
x2 = x0 + fabs(fact2) * sin(theta) * cos(phi); |
| 309 |
|
y2 = y0 + fabs(fact2) * sin(theta) * sin(phi); |
| 310 |
|
Double_t fact3 = (s3_z-z0)/cos(theta); |
| 311 |
|
x3 = x0 + fabs(fact3) * sin(theta) * cos(phi); |
| 312 |
|
y3 = y0 + fabs(fact3) * sin(theta) * sin(phi); |
| 313 |
|
|
| 314 |
|
//cout<<" x/y0= "<<x0<<" "<<y0<<" x/y2= "<<fact2*sin(theta)*cos(phi)<<" "<<x2<<" xy3= "<< |
| 315 |
|
// fact3*sin(theta)*cos(phi)<<" "<<x3<<" phi/the "<<phi*(90./Pi())<<" "<<theta*(90./Pi())<<endl; |
| 316 |
|
|
| 317 |
|
// Test condition on the direction |
| 318 |
|
if ( Abs(x2) <= Abs(s2_xmax) && Abs(y2) <= Abs(s2_ymax) && |
| 319 |
|
Abs(x3) <= Abs(s3_xmax) && Abs(y3) <= Abs(s3_ymax) ) { |
| 320 |
|
trkGood = kTRUE; |
| 321 |
|
//cout<<" x/y0= "<<x0<<" "<<y0<<" x/y2= "<<fact2*sin(theta)*cos(phi)<<" "<<x2<<" xy3= "<< |
| 322 |
|
// fact3*sin(theta)*cos(phi)<<" "<<x3<<endl; |
| 323 |
|
} |
| 324 |
|
} |
| 325 |
|
|
| 326 |
|
// Set direction and position: |
| 327 |
|
SetDirection(theta, phi); |
| 328 |
|
SetPosition(x0, y0, z0); |
| 329 |
|
|
| 330 |
|
return; |
| 331 |
|
} |