Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #include "FastSimulation/Event/interface/FBaseSimEvent.h"
0002 #include "FastSimulation/Event/interface/FSimVertex.h"
0003 
0004 inline const FSimVertex FSimTrack::vertex() const {
0005   return (!mom_ ? FSimVertex(vertex_.position(), vertex_.parentIndex(), vertex_.vertexId(), nullptr)
0006                 : mom_->vertex(vertIndex()));
0007 }
0008 
0009 inline const FSimVertex& FSimTrack::endVertex() const {
0010   if (endv_ < 0)
0011     throw cms::Exception("FastSim")
0012         << "FSimTrack::endVertex() called for FSimTrack w/o end vertex, please contact FastSim developers" << std::endl;
0013   return mom_->vertex(endv_);
0014 }
0015 
0016 inline const FSimTrack& FSimTrack::mother() const {
0017   if (noMother()) {
0018     throw cms::Exception("FastSim")
0019         << "FSimTrack::mother() called for FSimTrack w/o mother, please contact FastSim developers" << std::endl;
0020   }
0021   return vertex().parent();
0022 }
0023 
0024 inline const FSimTrack& FSimTrack::daughter(int i) const {
0025   if (i < 0 || i >= nDaughters())
0026     throw cms::Exception("FastSim")
0027         << "FSimTrack::daughter(int index) index out of range, please contact FastSim developers" << std::endl;
0028   if (abs(type()) == 11 || abs(type()) == 13)
0029     return mom_->track(daugh_[i]);
0030   else
0031     return endVertex().daughter(i);
0032 }
0033 
0034 inline int FSimTrack::nDaughters() const {
0035   if (abs(type()) == 11 || abs(type()) == 13)
0036     return daugh_.size();
0037   else {
0038     if (noEndVertex())
0039       return 0;
0040     else
0041       return endVertex().nDaughters();
0042   }
0043 }
0044 
0045 inline const std::vector<int>& FSimTrack::daughters() const {
0046   if (abs(type()) == 11 || noEndVertex())
0047     return daugh_;
0048   else {
0049     //if(noEndVertex()){
0050     //throw cms::Exception("FastSim") << "FSimTrack::daughters() called for FSimTrack w/o end vertex, please contact FastSim developers" << std::endl;
0051     //}
0052     return endVertex().daughters();
0053   }
0054 }
0055 
0056 inline bool FSimTrack::noEndVertex() const {
0057   // The particle either has no end vertex index
0058   if (endv_ < 0)
0059     return true;
0060 
0061   // or it's an electron/muon that has just Brem'ed, but continues its way
0062   // ... but not those intermediate e/mu PYTHIA entries with prompt Brem
0063   bool bremOutOfPipe = true;
0064   if ((mom_->vertex(endv_)).position().Perp2() < 1.0)
0065     bremOutOfPipe = false;
0066   return ((abs(type()) == 11 || abs(type()) == 13) && bremOutOfPipe && endVertex().nDaughters() > 0 &&
0067           endVertex().daughter(endVertex().nDaughters() - 1).type() == 22);
0068 }
0069 
0070 inline bool FSimTrack::noMother() const { return noVertex() || vertex().noParent(); }
0071 
0072 inline bool FSimTrack::noDaughter() const { return noEndVertex() || !nDaughters(); }
0073 
0074 inline const HepMC::GenParticle* FSimTrack::genParticle() const { return mom_->embdGenpart(genpartIndex()); }