Changeset 281 in svn for trunk/Utilities/Hector/src/H_BeamParticle.cc
- Timestamp:
- Mar 1, 2009, 3:56:11 PM (16 years ago)
- 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 * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 11 18 12 19 /// \file H_BeamParticle.cc … … 39 46 using namespace std; 40 47 41 void H_BeamParticle::init() { 48 void H_BeamParticle::init() { // for more efficiency, put the objects away from init! 42 49 mp = MP; 43 50 qp = QP; … … 57 64 } 58 65 59 H_BeamParticle::H_BeamParticle() { 66 H_BeamParticle::H_BeamParticle() { 60 67 init(); 61 68 } 62 69 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)); 70 H_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) { 76 75 if(p.hasstopped) stop_element = new H_OpticalElement(*(p.stop_element)); 77 positions = p.positions;78 76 } 79 77 … … 100 98 stop_position = new TVectorD(*(p.stop_position)); 101 99 if(p.hasstopped) stop_element = new H_OpticalElement(*(p.stop_element)); 100 else stop_element = 0; 102 101 positions = p.positions; 103 102 return *this; 104 103 } 105 104 106 bool H_BeamParticle::stopped(const H_AbstractBeamLine * beamline) {105 const bool H_BeamParticle::stopped(const H_AbstractBeamLine * beamline) { 107 106 vector<TVectorD>::const_iterator position_i; 108 107 for(position_i = positions.begin(); position_i < positions.end()-1; position_i++) { … … 159 158 } 160 159 161 void H_BeamParticle::smearPos(const double dx,const double dy) { 160 161 162 void H_BeamParticle::smearPos(const double dx,const double dy, TRandom* r) { 162 163 // 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 171 void 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); 165 175 positions.clear(); 166 176 addPosition(fx,thx,fy,thy,fs); … … 168 178 } 169 179 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); 180 void H_BeamParticle::smearE(const double erre, TRandom* r) { 181 energy = r->Gaus(energy,erre); 182 return; 183 } 184 185 void H_BeamParticle::smearS(const double errs, TRandom* r) { 186 fs= r->Gaus(fs,errs); 209 187 positions.clear(); 210 188 addPosition(fx,thx,fy,thy,fs); … … 212 190 } 213 191 214 void H_BeamParticle::smearS() {215 fs = gRandom->Gaus(fs,SS);216 positions.clear();217 addPosition(fx,thx,fy,thy,fs);218 return;219 }220 192 221 193 void H_BeamParticle::set4Momentum(const double px, const double py, const double pz, const double ene) { … … 267 239 if(hasstopped) return stop_element; 268 240 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;274 241 } 275 242 … … 362 329 } 363 330 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;331 std::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; 373 340 } 374 341 … … 491 458 delete [] graph; 492 459 return ppath; 493 }494 495 void H_BeamParticle::computePath(const H_AbstractBeamLine * beam) {496 computePath(beam,true);497 460 } 498 461
Note:
See TracChangeset
for help on using the changeset viewer.