CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_2_7_hltpatch1/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), hcalexit(0), hoentr(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), hcalexit(0), hoentr(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 
00089 void 
00090 FSimTrack::setHcalExit(const RawParticle& pp, int success) { 
00091   HCAL_Exit=pp; 
00092   hcalexit=success; 
00093 }
00094 
00095 void 
00096 FSimTrack::setHO(const RawParticle& pp, int success) { 
00097   HO_Entrance=pp; 
00098   hoentr=success; 
00099 }
00100 
00101 
00102 
00103 
00104 
00105 
00106 std::ostream& operator <<(std::ostream& o , const FSimTrack& t) {
00107 
00108   std::string name = t.particleInfo() ? t.particleInfo()->name() : "Unknown";
00109   XYZTLorentzVector momentum1 = t.momentum();
00110   XYZVector vertex1 = t.vertex().position().Vect();
00111   int vertexId1 = t.vertex().id();
00112 
00113   o.setf(std::ios::fixed, std::ios::floatfield);
00114   o.setf(std::ios::right, std::ios::adjustfield);
00115 
00116   o << std::setw(4) << t.id() << " " 
00117     << std::setw(4) << t.genpartIndex() << " " 
00118     << name;
00119 
00120   for(unsigned int k=0;k<11-name.length() && k<12; k++) o << " ";  
00121 
00122   o << std::setw(6) << std::setprecision(2) << momentum1.eta() << " " 
00123     << std::setw(6) << std::setprecision(2) << momentum1.phi() << " " 
00124     << std::setw(6) << std::setprecision(2) << momentum1.pt() << " " 
00125     << std::setw(6) << std::setprecision(2) << momentum1.e() << " " 
00126     << std::setw(4) << vertexId1 << " " 
00127     << std::setw(6) << std::setprecision(1) << vertex1.x() << " " 
00128     << std::setw(6) << std::setprecision(1) << vertex1.y() << " " 
00129     << std::setw(6) << std::setprecision(1) << vertex1.z() << " "
00130     << std::setw(4) << t.mother().id() << " ";
00131   
00132   if ( !t.noEndVertex() ) {
00133     XYZTLorentzVector vertex2 = t.endVertex().position();
00134     int vertexId2 = t.endVertex().id();
00135     
00136     o << std::setw(4) << vertexId2 << " "
00137       << std::setw(6) << std::setprecision(2) << vertex2.eta() << " " 
00138       << std::setw(6) << std::setprecision(2) << vertex2.phi() << " " 
00139       << std::setw(5) << std::setprecision(1) << vertex2.pt() << " " 
00140       << std::setw(6) << std::setprecision(1) << vertex2.z() << " ";
00141     for (int i=0; i<t.nDaughters(); ++i)
00142       o << std::setw(4) << t.daughter(i).id() << " ";
00143 
00144   } else {
00145 
00146     if ( t.onLayer1() ) {
00147 
00148       XYZTLorentzVector vertex2 = t.layer1Entrance().vertex();
00149       
00150       o << std::setw(4) << -t.onLayer1() << " " 
00151         << std::setw(6) << std::setprecision(2) << vertex2.eta() << " " 
00152         << std::setw(6) << std::setprecision(2) << vertex2.phi() << " " 
00153         << std::setw(5) << std::setprecision(1) << vertex2.pt() << " " 
00154         << std::setw(6) << std::setprecision(1) << vertex2.z() << " "
00155         << std::setw(6) << std::setprecision(2) << t.layer1Entrance().pt() << " " 
00156         << std::setw(6) << std::setprecision(2) << t.layer1Entrance().e() << " ";
00157       
00158     } else if ( t.onEcal() ) { 
00159 
00160       XYZTLorentzVector vertex2 = t.ecalEntrance().vertex();
00161       
00162       o << std::setw(4) << -t.onEcal() << " " 
00163         << std::setw(6) << std::setprecision(2) << vertex2.eta() << " " 
00164         << std::setw(6) << std::setprecision(2) << vertex2.phi() << " " 
00165         << std::setw(5) << std::setprecision(1) << vertex2.pt() << " " 
00166         << std::setw(6) << std::setprecision(1) << vertex2.z() << " "
00167         << std::setw(6) << std::setprecision(2) << t.ecalEntrance().pt() << " " 
00168         << std::setw(6) << std::setprecision(2) << t.ecalEntrance().e() << " ";
00169     }
00170   }
00171   return o;
00172 }