Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:49:54

0001 // -----------------------------------------------------------------------------
0002 //  Prototype for a particle class
0003 // -----------------------------------------------------------------------------
0004 //  $Date: 2007/09/07 16:46:22 $
0005 //  $Revision: 1.13 $
0006 // -----------------------------------------------------------------------------
0007 //  Author: Stephan Wynhoff - RWTH-Aachen (Email: Stephan.Wynhoff@cern.ch)
0008 // -----------------------------------------------------------------------------
0009 #include "CommonTools/BaseParticlePropagator/interface/RawParticle.h"
0010 
0011 #include <cmath>
0012 
0013 RawParticle::RawParticle(const XYZTLorentzVector& p) : myMomentum(p) {}
0014 
0015 RawParticle::RawParticle(const int id, const XYZTLorentzVector& p, double mass, double charge)
0016     : myMomentum(p), myCharge{charge}, myMass{mass}, myId{id} {}
0017 
0018 RawParticle::RawParticle(
0019     const int id, const XYZTLorentzVector& p, const XYZTLorentzVector& xStart, double mass, double charge)
0020     : myMomentum(p), myVertex{xStart}, myCharge{charge}, myMass{mass}, myId{id} {}
0021 
0022 RawParticle::RawParticle(const XYZTLorentzVector& p, const XYZTLorentzVector& xStart, double charge)
0023     : myMomentum(p), myVertex{xStart}, myCharge{charge} {}
0024 
0025 RawParticle::RawParticle(double px, double py, double pz, double e, double charge)
0026     : myMomentum(px, py, pz, e), myCharge{charge} {}
0027 
0028 void RawParticle::setStatus(int istat) { myStatus = istat; }
0029 
0030 void RawParticle::setMass(float m) { myMass = m; }
0031 
0032 void RawParticle::setCharge(float q) { myCharge = q; }
0033 
0034 void RawParticle::chargeConjugate() {
0035   myId = -myId;
0036   myCharge = -1 * myCharge;
0037 }
0038 
0039 void RawParticle::setT(const double t) { myVertex.SetE(t); }
0040 
0041 void RawParticle::rotate(double angle, const XYZVector& raxis) {
0042   Rotation r(raxis, angle);
0043   XYZVector v(r * myMomentum.Vect());
0044   setMomentum(v.X(), v.Y(), v.Z(), E());
0045 }
0046 
0047 void RawParticle::rotateX(double rphi) {
0048   RotationX r(rphi);
0049   XYZVector v(r * myMomentum.Vect());
0050   setMomentum(v.X(), v.Y(), v.Z(), E());
0051 }
0052 
0053 void RawParticle::rotateY(double rphi) {
0054   RotationY r(rphi);
0055   XYZVector v(r * myMomentum.Vect());
0056   setMomentum(v.X(), v.Y(), v.Z(), E());
0057 }
0058 
0059 void RawParticle::rotateZ(double rphi) {
0060   RotationZ r(rphi);
0061   XYZVector v(r * myMomentum.Vect());
0062   setMomentum(v.X(), v.Y(), v.Z(), E());
0063 }
0064 
0065 void RawParticle::boost(double betax, double betay, double betaz) {
0066   Boost b(betax, betay, betaz);
0067   XYZTLorentzVector p(b * momentum());
0068   setMomentum(p.X(), p.Y(), p.Z(), p.T());
0069 }
0070 
0071 std::ostream& operator<<(std::ostream& o, const RawParticle& p) {
0072   o.setf(std::ios::fixed, std::ios::floatfield);
0073   o.setf(std::ios::right, std::ios::adjustfield);
0074 
0075   o << std::setw(4) << std::setprecision(2) << p.pid() << " (";
0076   o << std::setw(2) << std::setprecision(2) << p.status() << "): ";
0077   o << std::setw(10) << std::setprecision(4) << p.momentum() << " ";
0078   o << std::setw(10) << std::setprecision(4) << p.vertex();
0079   return o;
0080 }
0081 
0082 double RawParticle::et() const {
0083   double mypp, tmpEt = -1.;
0084 
0085   mypp = std::sqrt(momentum().mag2());
0086   if (mypp != 0) {
0087     tmpEt = E() * pt() / mypp;
0088   }
0089   return tmpEt;
0090 }