Fork me on GitHub

Ignore:
Timestamp:
Mar 1, 2009, 3:56:11 PM (16 years ago)
Author:
Xavier Rouby
Message:

new Hector version

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Utilities/Hector/src/H_BeamParticle.cc

    r240 r281  
    1 /*
    2 ---- Hector the simulator ----
    3    A fast simulator of particles through generic beamlines.
    4    J. de Favereau, X. Rouby ~~~ hector_devel@cp3.phys.ucl.ac.be
    5 
    6         http://www.fynu.ucl.ac.be/hector.html
    7 
    8    Centre de Physique des Particules et de Phénoménologie (CP3)
    9    Université Catholique de Louvain (UCL)
    10 */
     1  /* * * * * * * * * * * * * * * * * * * * * * * * * * * *
     2 *                                                         *
     3*                   --<--<--  A fast simulator --<--<--     *
     4*                 / --<--<--     of particle   --<--<--     *
     5*  ----HECTOR----<                                          *
     6*                 \ -->-->-- transport through -->-->--     *
     7*                   -->-->-- generic beamlines -->-->--     *
     8*                                                           *
     9* JINST 2:P09005 (2007)                                     *
     10*      X Rouby, J de Favereau, K Piotrzkowski (CP3)         *
     11*       http://www.fynu.ucl.ac.be/hector.html               *
     12*                                                           *
     13* Center for Cosmology, Particle Physics and Phenomenology  *
     14*              Universite catholique de Louvain             *
     15*                 Louvain-la-Neuve, Belgium                 *
     16 *                                                         *
     17   * * * * * * * * * * * * * * * * * * * * * * * * * * * */
    1118
    1219/// \file H_BeamParticle.cc
     
    3946using namespace std;
    4047
    41 void H_BeamParticle::init() {
     48void H_BeamParticle::init() { // for more efficiency, put the objects away from init!
    4249        mp = MP;
    4350        qp = QP;
     
    5764}
    5865
    59 H_BeamParticle::H_BeamParticle() {
     66H_BeamParticle::H_BeamParticle() { 
    6067        init();
    6168}
    6269
    63 H_BeamParticle::H_BeamParticle(const H_BeamParticle& p) {
    64         mp = p.mp;
    65         qp = p.qp;
    66         fx = p.fx;
    67         fy = p.fy;
    68         thx = p.thx;
    69         thy = p.thy;
    70         fs = p.fs;
    71         energy = p.energy;
    72         hasstopped = p.hasstopped;
    73         hasemitted = p.hasemitted;
    74         isphysical = p.isphysical;
    75         stop_position = new TVectorD(*(p.stop_position));
     70H_BeamParticle::H_BeamParticle(const H_BeamParticle& p):
     71        mp(p.mp), qp(p.qp), fs(p.fs), fx(p.fx), fy(p.fy), thx(p.thx), thy(p.thy),
     72        energy(p.energy), hasstopped(p.hasstopped), hasemitted(p.hasemitted),
     73        isphysical(p.isphysical), stop_position(new TVectorD(*(p.stop_position))),
     74        stop_element(0), positions(p.positions) {
    7675        if(p.hasstopped) stop_element = new H_OpticalElement(*(p.stop_element));
    77         positions = p.positions;
    7876}
    7977
     
    10098        stop_position = new TVectorD(*(p.stop_position));
    10199        if(p.hasstopped) stop_element = new H_OpticalElement(*(p.stop_element));
     100        else stop_element = 0;
    102101        positions = p.positions;
    103102        return *this;
    104103}
    105104
    106 bool H_BeamParticle::stopped(const H_AbstractBeamLine * beamline) {
     105const bool H_BeamParticle::stopped(const H_AbstractBeamLine * beamline) {
    107106        vector<TVectorD>::const_iterator position_i;
    108107        for(position_i = positions.begin(); position_i < positions.end()-1; position_i++) {
     
    159158}
    160159
    161 void H_BeamParticle::smearPos(const double dx,const double dy) {
     160
     161
     162void H_BeamParticle::smearPos(const double dx,const double dy, TRandom* r) {
    162163  // the beam is centered on (fx,fy) at IP
    163         fx = gRandom->Gaus(fx,dx);
    164         fy = gRandom->Gaus(fy,dy);
     164        fx = r->Gaus(fx,dx);
     165        fy = r->Gaus(fy,dy);
     166        positions.clear();
     167        addPosition(fx,thx,fy,thy,fs);
     168        return;
     169}
     170
     171void H_BeamParticle::smearAng(const double tx, const double ty, TRandom* r) {
     172  // the beam transverse direction is centered on (thx,thy) at IP
     173        thx = r->Gaus(thx,tx);
     174        thy = r->Gaus(thy,ty);
    165175        positions.clear();
    166176        addPosition(fx,thx,fy,thy,fs);
     
    168178}
    169179
    170 void H_BeamParticle::smearPos() {
    171   // the beam is centered on (fx,fy) at IP
    172         fx = gRandom->Gaus(fx,SX);
    173         fy = gRandom->Gaus(fy,SY);
    174         positions.clear();
    175         addPosition(fx,thx,fy,thy,fs);
    176         return;
    177 }
    178 
    179 void H_BeamParticle::smearAng(const double tx, const double ty) {
    180   // the beam transverse direction is centered on (thx,thy) at IP
    181         thx = gRandom->Gaus(thx,tx);
    182         thy = gRandom->Gaus(thy,ty);
    183         positions.clear();
    184         addPosition(fx,thx,fy,thy,fs);
    185         return;
    186 }
    187 
    188 void H_BeamParticle::smearAng() {
    189    // the beam transverse direction is centered on (thx,thy) at IP
    190         thx = gRandom->Gaus(thx,STX);
    191         thy = gRandom->Gaus(thy,STY);
    192         positions.clear();
    193         addPosition(fx,thx,fy,thy,fs);
    194         return;
    195 }
    196 
    197 void H_BeamParticle::smearE(const double erre) {
    198         energy = gRandom->Gaus(energy,erre);
    199         return;
    200 }
    201 
    202 void H_BeamParticle::smearE() {
    203         energy = gRandom->Gaus(energy,SBE);
    204         return;
    205 }
    206 
    207 void H_BeamParticle::smearS(const double errs) {
    208         fs= gRandom->Gaus(fs,errs);
     180void H_BeamParticle::smearE(const double erre, TRandom* r) {
     181        energy = r->Gaus(energy,erre);
     182        return;
     183}
     184
     185void H_BeamParticle::smearS(const double errs, TRandom* r) {
     186        fs= r->Gaus(fs,errs);
    209187        positions.clear();
    210188        addPosition(fx,thx,fy,thy,fs);
     
    212190}
    213191
    214 void H_BeamParticle::smearS() {
    215         fs = gRandom->Gaus(fs,SS);
    216         positions.clear();
    217         addPosition(fx,thx,fy,thy,fs);
    218         return;
    219 }
    220192
    221193void H_BeamParticle::set4Momentum(const double px, const double py, const double pz, const double ene) {
     
    267239        if(hasstopped) return stop_element;
    268240        else { H_OpticalElement * dummy_el = new H_Drift("",0,0); return dummy_el;}
    269 }
    270 
    271 void H_BeamParticle::emitGamma(const double gee, const double gq2) {
    272         emitGamma(gee,gq2,0,2*pi);
    273         return;
    274241}
    275242
     
    362329}
    363330
    364 void H_BeamParticle::printProperties() const {
    365         cout << " M   = " << getM()  << "GeV ";
    366         cout << " Q   = " << getQ()  << "e";
    367         cout << " fx  = " << getX()  << "m   ";
    368         cout << " fy  = " << getY()  << "m   ";
    369         cout << " thx = " << getTX() << "rad ";
    370         cout << " thy = " << getTY() << "rad ";
    371         cout << endl;
    372         return;
     331std::ostream& operator<< (std::ostream& os, const H_BeamParticle& p) {
     332        os << " M   = " << p.getM()  << "GeV ";
     333        os << " Q   = " << p.getQ()  << "e";
     334        os << " fx  = " << p.getX()  << "m   ";
     335        os << " fy  = " << p.getY()  << "m   ";
     336        os << " thx = " << p.getTX() << "rad ";
     337        os << " thy = " << p.getTY() << "rad ";
     338        os << endl;
     339   return os;
    373340}
    374341
     
    491458        delete [] graph;
    492459        return ppath;
    493 }
    494 
    495 void H_BeamParticle::computePath(const H_AbstractBeamLine * beam) {
    496         computePath(beam,true);
    497460}
    498461
Note: See TracChangeset for help on using the changeset viewer.