Changeset 354 in PSPA for Interface_Web/trunk/pspaWT/sources/controler/src/particleBeam.cc
- Timestamp:
- Mar 1, 2013, 3:38:12 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Interface_Web/trunk/pspaWT/sources/controler/src/particleBeam.cc
r342 r354 333 333 } 334 334 335 void particleBeam::donneesDessinEllipseXxp(vector<double>& xcor, vector<double>& ycor) { 335 // void particleBeam::donneesDessinEllipseXxp(vector<double>& xcor, vector<double>& ycor) { 336 // int k; 337 // double x,y; 338 339 // if ( !momentRepresentationOk_ ) return; 340 341 // xcor.clear(); 342 // ycor.clear(); 343 344 // double xm = ( rij_.getMatrix().at(0) ).at(0); 345 // double ym = ( rij_.getMatrix().at(1) ).at(1); 346 // double r = ( rij_.getMatrix().at(1) ).at(0); 347 348 // cout << " racs11= " << xm << " racs22= " << ym << " r12= " << r << endl; 349 350 351 // int nbintv = 50; 352 // if ( xm == 0.0 ) return; 353 // double pas = 2.0 * xm / nbintv; 354 355 // // cout << " r= " << r << endl; 356 // double rac = (1 - r*r); 357 // if ( rac > 0.0 ) 358 // { 359 // cout << " cas rac > " << endl; 360 // rac = sqrt(1 - r*r); 361 // double alpha = -r / rac; 362 // double beta = xm / ( ym * rac); 363 // // double gamma = ym / ( xm * rac ); 364 // double epsil = xm * ym * rac; 365 // double fac1 = -1.0 / ( beta * beta); 366 // double fac2 = epsil/beta; 367 // double fac3 = -alpha/beta; 368 // double aux; 369 // for ( k=0; k < nbintv; k++) 370 // { 371 // x = -xm + k*pas; 372 // aux = fac1 * x * x + fac2; 373 // // cout << " aux2= " << aux << endl; 374 // if ( aux <= 0.0 ) 375 // { 376 // aux = 0.0; 377 // } 378 // else aux = sqrt(aux); 379 380 // // y = fac3*x; 381 // y = fac3*x + aux; 382 // xcor.push_back(x); 383 // ycor.push_back(y); 384 // } 385 386 // for ( k=0; k <= nbintv; k++) 387 // { 388 // x = xm - k*pas; 389 // aux = fac1 * x * x + fac2; 390 // if ( aux <= 0.0 ) 391 // { 392 // aux = 0.0; 393 // } 394 // else aux = sqrt(aux); 395 // // y = fac3*x; 396 // y = fac3*x - aux; 397 // xcor.push_back(x); 398 // ycor.push_back(y); 399 // } 400 // } 401 // else 402 // // cas degenere 403 // { 404 // cout << " cas degenere " << endl; 405 // double fac = ym/xm; 406 // for ( k=0; k < nbintv; k++) 407 // { 408 // x = -xm + k*pas; 409 // y = fac*x; 410 // xcor.push_back(x); 411 // ycor.push_back(y); 412 // } 413 414 // } 415 // } 416 417 void particleBeam::particlesPhaseSpaceData(vector<double>& xcor, vector<double>& ycor, unsigned indexAbs, unsigned indexOrd) { 418 particlesPhaseSpaceComponent(xcor, indexAbs); 419 particlesPhaseSpaceComponent(ycor, indexOrd); 420 } 421 422 void particleBeam::particlesPhaseSpaceComponent(vector<double>& coord, unsigned index) { 423 if ( !particleRepresentationOk_ ) return; 424 coord.clear(); 425 coord.resize(goodPartic_.size(), 0.0 ); 426 cout << " particleBeam::particlesPhaseSpaceComponent index = " << index << endl; 427 if ( index <= 2 ) { 428 for (unsigned i = 0; i < goodPartic_.size(); ++i) { 429 coord.at(i) = goodPartic_.at(i).getPosition().getComponent(index); 430 } 431 return; 432 } 433 434 if ( index > 2 && index < 5 ) { 435 for (unsigned i = 0; i < goodPartic_.size(); ++i) { 436 double begamz = goodPartic_.at(i).getBetaGamma().getComponent(2); 437 if ( begamz != 0.0) { 438 coord.at(i) = 1000.*goodPartic_.at(i).getBetaGamma().getComponent(index - 3)/begamz; // mimmiradians 439 } else { 440 coord.at(i) = 0.0; 441 } 442 } 443 return; 444 } 445 446 if ( index == 5 ) { 447 double gamma0 = referenceParticle_.getGamma(); 448 cout << " gamma0 = " << gamma0 << endl; 449 if ( gamma0 == 0.0 ) return; 450 for (unsigned i = 0; i < goodPartic_.size(); ++i) { 451 coord.at(i) = 100.*(goodPartic_.at(i).getGamma() - gamma0)/gamma0; // en % 452 cout << " gamma0 = " << gamma0 << " gamma = " << goodPartic_.at(i).getGamma() << endl; 453 } 454 return; 455 } 456 } 457 458 void particleBeam::donneesDessinEllipse(vector<double>& xcor, vector<double>& ycor, unsigned indexAbs, unsigned indexOrd) { 336 459 int k; 337 460 double x,y; … … 339 462 if ( !momentRepresentationOk_ ) return; 340 463 464 if ( indexAbs > 5 || indexOrd > 5 ) return; 465 341 466 xcor.clear(); 342 467 ycor.clear(); 343 344 double xm = ( rij_.getMatrix().at(0) ).at(0); 345 double ym = ( rij_.getMatrix().at(1) ).at(1); 346 double r = ( rij_.getMatrix().at(1) ).at(0); 468 // les index sont dans l'ordre x,y,z,xp,yp, de/E 469 // on traduit en TRANSPORT 470 if ( indexAbs == 1 ) indexAbs = 2; // y 471 if ( indexAbs == 2 ) indexAbs = 4; // z -> l 472 if ( indexAbs == 3 ) indexAbs = 1; // xp 473 if ( indexAbs == 4 ) indexAbs = 3; // yp 474 475 if ( indexOrd == 1 ) indexOrd = 2; // y 476 if ( indexOrd == 2 ) indexOrd = 4; // z -> l 477 if ( indexOrd == 3 ) indexOrd = 1; // xp 478 if ( indexOrd == 4 ) indexOrd = 3; // yp 479 480 cout << " index x" << indexAbs << " index y " << indexOrd << endl; 481 482 double xm = ( rij_.getMatrix().at(indexAbs) ).at(indexAbs); 483 double ym = ( rij_.getMatrix().at(indexOrd) ).at(indexOrd); 484 double r; 485 if ( indexOrd > indexAbs ) { 486 r = ( rij_.getMatrix().at(indexOrd) ).at(indexAbs); 487 } else { 488 r = ( rij_.getMatrix().at(indexAbs) ).at(indexOrd); 489 } 347 490 348 491 cout << " racs11= " << xm << " racs22= " << ym << " r12= " << r << endl; … … 415 558 } 416 559 417 418 419 void particleBeam::donneesDessinEllipse(vector<double>& xcor, vector<double>& ycor, unsigned indexAbs, unsigned indexOrd) {420 int k;421 double x,y;422 423 if ( !momentRepresentationOk_ ) return;424 425 if ( indexAbs > 5 || indexOrd > 5 ) return;426 427 xcor.clear();428 ycor.clear();429 // les index sont dans l'ordre x,y,z,xp,yp, de/E430 // on traduit en TRANSPORT431 if ( indexAbs == 1 ) indexAbs = 2; // y432 if ( indexAbs == 2 ) indexAbs = 4; // z -> l433 if ( indexAbs == 3 ) indexAbs = 1; // xp434 if ( indexAbs == 4 ) indexAbs = 3; // yp435 436 if ( indexOrd == 1 ) indexOrd = 2; // y437 if ( indexOrd == 2 ) indexOrd = 4; // z -> l438 if ( indexOrd == 3 ) indexOrd = 1; // xp439 if ( indexOrd == 4 ) indexOrd = 3; // yp440 441 cout << " index x" << indexAbs << " index y " << indexOrd << endl;442 443 double xm = ( rij_.getMatrix().at(indexAbs) ).at(indexAbs);444 double ym = ( rij_.getMatrix().at(indexOrd) ).at(indexOrd);445 double r;446 if ( indexOrd > indexAbs ) {447 r = ( rij_.getMatrix().at(indexOrd) ).at(indexAbs);448 } else {449 r = ( rij_.getMatrix().at(indexAbs) ).at(indexOrd);450 }451 452 cout << " racs11= " << xm << " racs22= " << ym << " r12= " << r << endl;453 454 455 int nbintv = 50;456 if ( xm == 0.0 ) return;457 double pas = 2.0 * xm / nbintv;458 459 // cout << " r= " << r << endl;460 double rac = (1 - r*r);461 if ( rac > 0.0 )462 {463 cout << " cas rac > " << endl;464 rac = sqrt(1 - r*r);465 double alpha = -r / rac;466 double beta = xm / ( ym * rac);467 // double gamma = ym / ( xm * rac );468 double epsil = xm * ym * rac;469 double fac1 = -1.0 / ( beta * beta);470 double fac2 = epsil/beta;471 double fac3 = -alpha/beta;472 double aux;473 for ( k=0; k < nbintv; k++)474 {475 x = -xm + k*pas;476 aux = fac1 * x * x + fac2;477 // cout << " aux2= " << aux << endl;478 if ( aux <= 0.0 )479 {480 aux = 0.0;481 }482 else aux = sqrt(aux);483 484 // y = fac3*x;485 y = fac3*x + aux;486 xcor.push_back(x);487 ycor.push_back(y);488 }489 490 for ( k=0; k <= nbintv; k++)491 {492 x = xm - k*pas;493 aux = fac1 * x * x + fac2;494 if ( aux <= 0.0 )495 {496 aux = 0.0;497 }498 else aux = sqrt(aux);499 // y = fac3*x;500 y = fac3*x - aux;501 xcor.push_back(x);502 ycor.push_back(y);503 }504 }505 else506 // cas degenere507 {508 cout << " cas degenere " << endl;509 double fac = ym/xm;510 for ( k=0; k < nbintv; k++)511 {512 x = -xm + k*pas;513 y = fac*x;514 xcor.push_back(x);515 ycor.push_back(y);516 }517 518 }519 }520 521 560 void particleBeam::histogramme(vector<double>&xcor,vector<int>& hist,int& cnts,double out[3]) 522 561 {
Note: See TracChangeset
for help on using the changeset viewer.