Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:26:39

0001 #include "FastSimulation/Event/interface/FSimTrack.h"
0002 
0003 //C++ Headers
0004 #include <iomanip>
0005 #include <string>
0006 
0007 //using namespace HepPDT;
0008 
0009 FSimTrack::FSimTrack()
0010     : SimTrack(),
0011       mom_(nullptr),
0012       id_(-1),
0013       charge_(-999),
0014       endv_(-1),
0015       layer1(0),
0016       layer2(0),
0017       ecal(0),
0018       hcal(0),
0019       vfcal(0),
0020       hcalexit(0),
0021       hoentr(0),
0022       prop(false),
0023       closestDaughterId_(-1),
0024       info_(nullptr),
0025       properDecayTime(1E99) {
0026   ;
0027 }
0028 
0029 FSimTrack::FSimTrack(const RawParticle* p, int iv, int ig, int id, FBaseSimEvent* mom, double dt)
0030     :  //  SimTrack(p->pid(),*p,iv,ig),   // to uncomment once Mathcore is installed
0031       SimTrack(p->pid(), p->momentum(), iv, ig),
0032       mom_(mom),
0033       id_(id),
0034       charge_(-999),
0035       endv_(-1),
0036       layer1(0),
0037       layer2(0),
0038       ecal(0),
0039       hcal(0),
0040       vfcal(0),
0041       hcalexit(0),
0042       hoentr(0),
0043       prop(false),
0044       closestDaughterId_(-1),
0045       momentum_(p->momentum()),
0046       properDecayTime(dt) {
0047   setTrackId(id);
0048   info_ = mom_->theTable()->particle(HepPDT::ParticleID(type()));
0049 }
0050 
0051 //! Hack to interface "old" calorimetry with "new" propagation in tracker (need to construct FSimTracks)
0052 FSimTrack::FSimTrack(int ipart,
0053                      const math::XYZTLorentzVector& p,
0054                      int iv,
0055                      int ig,
0056                      int id,
0057                      double charge,
0058                      const math::XYZTLorentzVector& tkp,
0059                      const math::XYZTLorentzVector& tkm,
0060                      const SimVertex& tkv)
0061     : SimTrack(ipart, p, iv, ig, math::XYZVectorD(tkp.X(), tkp.Y(), tkp.Z()), tkm),
0062       vertex_(tkv),
0063       mom_(nullptr),
0064       id_(id),
0065       charge_(charge),
0066       endv_(-1),
0067       layer1(0),
0068       layer2(0),
0069       ecal(0),
0070       hcal(0),
0071       vfcal(0),
0072       hcalexit(0),
0073       hoentr(0),
0074       prop(false),
0075       closestDaughterId_(-1),
0076       info_(nullptr),
0077       momentum_(p),
0078       properDecayTime(-1),
0079       isGlobal_(false) {
0080   setTrackId(id);
0081 }
0082 
0083 FSimTrack::~FSimTrack() { ; }
0084 
0085 bool FSimTrack::notYetToEndVertex(const XYZTLorentzVector& pos) const {
0086   // If there is no end vertex, nothing to compare to
0087   if (noEndVertex())
0088     return true;
0089   // If the particle immediately decays, no need to propagate
0090   if ((endVertex().position() - vertex().position()).Vect().Mag2() < 1e-4)
0091     return false;
0092   // If the end vertex has a larger radius, not yet there
0093   if (endVertex().position().Perp2() > pos.Perp2() + 1e-10)
0094     return true;
0095   // If the end vertex has a larger z, not yet there
0096   if (fabs(endVertex().position().Z()) > fabs(pos.Z()) + 1e-5)
0097     return true;
0098   // Otherwise, the end vertex is overtaken already
0099   return false;
0100 }
0101 
0102 /// Set the variable at the beginning of the propagation
0103 void FSimTrack::setPropagate() { prop = true; }
0104 
0105 /// Set the preshower layer1 variables
0106 void FSimTrack::setLayer1(const RawParticle& pp, int success) {
0107   Layer1_Entrance = pp;
0108   layer1 = success;
0109 }
0110 
0111 /// Set the preshower layer2 variables
0112 void FSimTrack::setLayer2(const RawParticle& pp, int success) {
0113   Layer2_Entrance = pp;
0114   layer2 = success;
0115 }
0116 
0117 /// Set the ecal variables
0118 void FSimTrack::setEcal(const RawParticle& pp, int success) {
0119   ECAL_Entrance = pp;
0120   ecal = success;
0121 }
0122 
0123 /// Set the hcal variables
0124 void FSimTrack::setHcal(const RawParticle& pp, int success) {
0125   HCAL_Entrance = pp;
0126   hcal = success;
0127 }
0128 
0129 /// Set the vcal variables
0130 void FSimTrack::setVFcal(const RawParticle& pp, int success) {
0131   VFCAL_Entrance = pp;
0132   vfcal = success;
0133 }
0134 
0135 /// Set the hcal variables
0136 void FSimTrack::setHcalExit(const RawParticle& pp, int success) {
0137   HCAL_Exit = pp;
0138   hcalexit = success;
0139 }
0140 
0141 void FSimTrack::setHO(const RawParticle& pp, int success) {
0142   HO_Entrance = pp;
0143   hoentr = success;
0144 }
0145 
0146 std::ostream& operator<<(std::ostream& o, const FSimTrack& t) {
0147   std::string name = t.particleInfo() ? t.particleInfo()->name() : "Unknown";
0148   const XYZTLorentzVector& momentum1 = t.momentum();
0149   XYZVector vertex1 = t.vertex().position().Vect();
0150   int vertexId1 = t.vertex().id();
0151 
0152   o.setf(std::ios::fixed, std::ios::floatfield);
0153   o.setf(std::ios::right, std::ios::adjustfield);
0154 
0155   o << std::setw(4) << t.id() << "; " << std::setw(4) << t.genpartIndex() << "; " << name << "\n\t\t";
0156 
0157   //for(unsigned int k=0;k<11-name.length() && k<12; k++) o << "; ";
0158 
0159   o << "Position: " << std::setw(6) << std::setprecision(2) << momentum1.eta() << "; " << std::setw(6)
0160     << std::setprecision(2) << momentum1.phi() << "; " << std::setw(6) << std::setprecision(2) << momentum1.pt() << "; "
0161     << std::setw(6) << std::setprecision(2) << momentum1.e() << "; " << std::setw(4) << vertexId1 << "; "
0162     << std::setw(6) << std::setprecision(1) << vertex1.x() << "; " << std::setw(6) << std::setprecision(1)
0163     << vertex1.y() << "; " << std::setw(6) << std::setprecision(1) << vertex1.z() << "; " << std::setw(4)
0164     << (t.particleInfo() ? (t.noMother() ? -1 : t.mother().id()) : -1) << "; "
0165     << "\n\t\t";
0166 
0167   if (!t.noEndVertex()) {
0168     XYZTLorentzVector vertex2 = t.endVertex().position();
0169     int vertexId2 = t.endVertex().id();
0170 
0171     o << "Decayed particle: " << std::setw(4) << vertexId2 << "; " << std::setw(6) << std::setprecision(2)
0172       << vertex2.eta() << "; " << std::setw(6) << std::setprecision(2) << vertex2.phi() << "; " << std::setw(5)
0173       << std::setprecision(1) << vertex2.pt() << "; " << std::setw(6) << std::setprecision(1) << vertex2.z() << "; ";
0174     for (int i = 0; i < t.nDaughters(); ++i)
0175       o << std::setw(4) << t.daughter(i).id() << "; "
0176         << "\n\t\t";
0177 
0178   } else {
0179     if (t.onLayer1()) {
0180       XYZTLorentzVector vertex2 = t.layer1Entrance().vertex();
0181 
0182       o << "Layer 1: " << std::setw(4) << -t.onLayer1() << "; " << std::setw(6) << std::setprecision(2) << vertex2.eta()
0183         << "; " << std::setw(6) << std::setprecision(2) << vertex2.phi() << "; " << std::setw(5) << std::setprecision(1)
0184         << vertex2.pt() << "; " << std::setw(6) << std::setprecision(1) << vertex2.z() << "; " << std::setw(6)
0185         << std::setprecision(2) << t.layer1Entrance().pt() << "; " << std::setw(6) << std::setprecision(2)
0186         << t.layer1Entrance().e() << "; "
0187         << "\n\t\t";
0188     }
0189     if (t.onLayer2()) {
0190       XYZTLorentzVector vertex2 = t.layer2Entrance().vertex();
0191 
0192       o << "Layer 2: " << std::setw(4) << -t.onLayer2() << "; " << std::setw(6) << std::setprecision(2) << vertex2.eta()
0193         << "; " << std::setw(6) << std::setprecision(2) << vertex2.phi() << "; " << std::setw(5) << std::setprecision(1)
0194         << vertex2.pt() << "; " << std::setw(6) << std::setprecision(1) << vertex2.z() << "; " << std::setw(6)
0195         << std::setprecision(2) << t.layer2Entrance().pt() << "; " << std::setw(6) << std::setprecision(2)
0196         << t.layer2Entrance().e() << "; "
0197         << "\n\t\t";
0198     }
0199     //if ( t.onEcal() ) {
0200 
0201     XYZTLorentzVector vertex2 = t.ecalEntrance().vertex();
0202 
0203     o << "ECAL: " << std::setw(4) << -t.onEcal() << "; " << std::setw(6) << std::setprecision(2) << vertex2.eta()
0204       << "; " << std::setw(6) << std::setprecision(2) << vertex2.phi() << "; " << std::setw(5) << std::setprecision(1)
0205       << vertex2.pt() << "; " << std::setw(6) << std::setprecision(1) << vertex2.z() << "; " << std::setw(6)
0206       << std::setprecision(2) << t.ecalEntrance().pt() << "; " << std::setw(6) << std::setprecision(2)
0207       << t.ecalEntrance().e() << "; "
0208       << "\n\t\t";
0209     //}
0210     //if ( t.onHcal() ) {
0211 
0212     vertex2 = t.hcalEntrance().vertex();
0213 
0214     o << "HCAL: " << std::setw(4) << -t.onHcal() << "; " << std::setw(6) << std::setprecision(2) << vertex2.eta()
0215       << "; " << std::setw(6) << std::setprecision(2) << vertex2.phi() << "; " << std::setw(5) << std::setprecision(1)
0216       << vertex2.pt() << "; " << std::setw(6) << std::setprecision(1) << vertex2.z() << "; " << std::setw(6)
0217       << std::setprecision(2) << t.hcalEntrance().pt() << "; " << std::setw(6) << std::setprecision(2)
0218       << t.hcalEntrance().e() << "; "
0219       << "\n\t\t";
0220     //}
0221     //if ( t.onVFcal() ) {
0222 
0223     vertex2 = t.vfcalEntrance().vertex();
0224 
0225     o << "VFCAL: " << std::setw(4) << -t.onVFcal() << "; " << std::setw(6) << std::setprecision(2) << vertex2.eta()
0226       << "; " << std::setw(6) << std::setprecision(2) << vertex2.phi() << "; " << std::setw(5) << std::setprecision(1)
0227       << vertex2.pt() << "; " << std::setw(6) << std::setprecision(1) << vertex2.z() << "; " << std::setw(6)
0228       << std::setprecision(2) << t.vfcalEntrance().pt() << "; " << std::setw(6) << std::setprecision(2)
0229       << t.vfcalEntrance().e() << "; "
0230       << "\n\t\t";
0231     //}
0232   }
0233   return o;
0234 }