CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_4_5_patch3/src/FastSimulation/Event/src/FSimTrack.cc

Go to the documentation of this file.
00001 #include "FastSimulation/Event/interface/FSimTrack.h"
00002 
00003 //C++ Headers
00004 #include <iomanip>
00005 #include <string>
00006 
00007 //using namespace HepPDT;
00008 
00009 FSimTrack:: FSimTrack() : 
00010   SimTrack(), mom_(0), id_(-1), endv_(-1),
00011   layer1(0), layer2(0), ecal(0), hcal(0), vfcal(0), 
00012   prop(false), closestDaughterId_(-1), info_(0),
00013   properDecayTime(1E99) {;}
00014   
00015 FSimTrack::FSimTrack(const RawParticle* p, 
00016                      int iv, int ig, int id, 
00017                      FBaseSimEvent* mom,
00018                      double dt) :
00019   //  SimTrack(p->pid(),*p,iv,ig),   // to uncomment once Mathcore is installed 
00020   SimTrack(p->pid(),p->momentum(),iv,ig), 
00021   mom_(mom), id_(id), endv_(-1),
00022   layer1(0), layer2(0), ecal(0), hcal(0), vfcal(0), prop(false),
00023   closestDaughterId_(-1), momentum_(p->momentum()),
00024   properDecayTime(dt)
00025 { 
00026   setTrackId(id);
00027   info_ = mom_->theTable()->particle(HepPDT::ParticleID(type()));
00028 }
00029 
00030 FSimTrack::~FSimTrack() {;}
00031 
00032 bool 
00033 FSimTrack::notYetToEndVertex(const XYZTLorentzVector& pos) const {
00034   // If there is no end vertex, nothing to compare to
00035   if ( noEndVertex() ) return true;
00036   // If the particle immediately decays, no need to propagate
00037   if ( (endVertex().position()-vertex().position()).Vect().Mag2() < 1e-4 )
00038     return false;
00039   // If the end vertex has a larger radius, not yet there
00040   if ( endVertex().position().Perp2() > pos.Perp2()+1e-10 ) return true;
00041   // If the end vertex has a larger z, not yet there
00042   if ( fabs(endVertex().position().Z()) > fabs(pos.Z())+1e-5 ) return true;
00043   // Otherwise, the end vertex is overtaken already
00044   return false;
00045 }
00046 
00048 void 
00049 FSimTrack::setPropagate() { 
00050   prop=true; 
00051 }
00052 
00054 void 
00055 FSimTrack::setLayer1(const RawParticle& pp, int success) { 
00056   Layer1_Entrance=pp; 
00057   layer1=success; 
00058 }
00059 
00061 void 
00062 FSimTrack::setLayer2(const RawParticle& pp, int success) { 
00063   Layer2_Entrance=pp; 
00064   layer2=success; 
00065 }
00066 
00068 void 
00069 FSimTrack::setEcal(const RawParticle& pp, int success) { 
00070   ECAL_Entrance=pp; 
00071   ecal=success; 
00072 }
00073 
00075 void 
00076 FSimTrack::setHcal(const RawParticle& pp, int success) { 
00077   HCAL_Entrance=pp; 
00078   hcal=success; 
00079 }
00080 
00082 void 
00083 FSimTrack::setVFcal(const RawParticle& pp, int success) { 
00084   VFCAL_Entrance=pp; 
00085   vfcal=success; 
00086 }
00087 
00088 std::ostream& operator <<(std::ostream& o , const FSimTrack& t) {
00089 
00090   std::string name = t.particleInfo() ? t.particleInfo()->name() : "Unknown";
00091   XYZTLorentzVector momentum1 = t.momentum();
00092   XYZVector vertex1 = t.vertex().position().Vect();
00093   int vertexId1 = t.vertex().id();
00094 
00095   o.setf(std::ios::fixed, std::ios::floatfield);
00096   o.setf(std::ios::right, std::ios::adjustfield);
00097 
00098   o << std::setw(4) << t.id() << " " 
00099     << std::setw(4) << t.genpartIndex() << " " 
00100     << name;
00101 
00102   for(unsigned int k=0;k<11-name.length() && k<12; k++) o << " ";  
00103 
00104   o << std::setw(6) << std::setprecision(2) << momentum1.eta() << " " 
00105     << std::setw(6) << std::setprecision(2) << momentum1.phi() << " " 
00106     << std::setw(6) << std::setprecision(2) << momentum1.pt() << " " 
00107     << std::setw(6) << std::setprecision(2) << momentum1.e() << " " 
00108     << std::setw(4) << vertexId1 << " " 
00109     << std::setw(6) << std::setprecision(1) << vertex1.x() << " " 
00110     << std::setw(6) << std::setprecision(1) << vertex1.y() << " " 
00111     << std::setw(6) << std::setprecision(1) << vertex1.z() << " "
00112     << std::setw(4) << t.mother().id() << " ";
00113   
00114   if ( !t.noEndVertex() ) {
00115     XYZTLorentzVector vertex2 = t.endVertex().position();
00116     int vertexId2 = t.endVertex().id();
00117     
00118     o << std::setw(4) << vertexId2 << " "
00119       << std::setw(6) << std::setprecision(2) << vertex2.eta() << " " 
00120       << std::setw(6) << std::setprecision(2) << vertex2.phi() << " " 
00121       << std::setw(5) << std::setprecision(1) << vertex2.pt() << " " 
00122       << std::setw(6) << std::setprecision(1) << vertex2.z() << " ";
00123     for (int i=0; i<t.nDaughters(); ++i)
00124       o << std::setw(4) << t.daughter(i).id() << " ";
00125 
00126   } else {
00127 
00128     if ( t.onLayer1() ) {
00129 
00130       XYZTLorentzVector vertex2 = t.layer1Entrance().vertex();
00131       
00132       o << std::setw(4) << -t.onLayer1() << " " 
00133         << std::setw(6) << std::setprecision(2) << vertex2.eta() << " " 
00134         << std::setw(6) << std::setprecision(2) << vertex2.phi() << " " 
00135         << std::setw(5) << std::setprecision(1) << vertex2.pt() << " " 
00136         << std::setw(6) << std::setprecision(1) << vertex2.z() << " "
00137         << std::setw(6) << std::setprecision(2) << t.layer1Entrance().pt() << " " 
00138         << std::setw(6) << std::setprecision(2) << t.layer1Entrance().e() << " ";
00139       
00140     } else if ( t.onEcal() ) { 
00141 
00142       XYZTLorentzVector vertex2 = t.ecalEntrance().vertex();
00143       
00144       o << std::setw(4) << -t.onEcal() << " " 
00145         << std::setw(6) << std::setprecision(2) << vertex2.eta() << " " 
00146         << std::setw(6) << std::setprecision(2) << vertex2.phi() << " " 
00147         << std::setw(5) << std::setprecision(1) << vertex2.pt() << " " 
00148         << std::setw(6) << std::setprecision(1) << vertex2.z() << " "
00149         << std::setw(6) << std::setprecision(2) << t.ecalEntrance().pt() << " " 
00150         << std::setw(6) << std::setprecision(2) << t.ecalEntrance().e() << " ";
00151     }
00152   }
00153   return o;
00154 }