Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #ifndef FastSimulation_Event_FSimTrack_H
0002 #define FastSimulation_Event_FSimTrack_H
0003 
0004 // HepPDT Headers
0005 #include "SimGeneral/HepPDTRecord/interface/ParticleDataTable.h"
0006 
0007 // CMSSW Headers
0008 #include "SimDataFormats/Track/interface/SimTrack.h"
0009 #include "SimDataFormats/Vertex/interface/SimVertex.h"
0010 
0011 // FAMOS headers
0012 #include "CommonTools/BaseParticlePropagator/interface/RawParticle.h"
0013 
0014 #include <vector>
0015 
0016 class FSimVertex;
0017 class FBaseSimEvent;
0018 
0019 namespace HepMC {
0020   class GenParticle;
0021   class GenVertex;
0022 }  // namespace HepMC
0023 
0024 /** A class that mimics SimTrack, with enhanced features.
0025  *  Essentially an interface to SimTrack.
0026  * \author Patrick Janot, CERN 
0027  * $Date: 9-Dec-2003
0028  */
0029 
0030 class FSimTrack : public SimTrack {
0031 public:
0032   /// Default constructor
0033   FSimTrack();
0034 
0035   /// Constructor from the EmmbSimTrack index in the FBaseSimEvent
0036   FSimTrack(const RawParticle* p, int iv, int ig, int id, FBaseSimEvent* mom, double dt = -1.);
0037 
0038   //! Hack to interface "old" calorimetry with "new" propagation in tracker (need to construct FSimTracks)
0039   FSimTrack(int ipart,
0040             const math::XYZTLorentzVector& p,
0041             int iv,
0042             int ig,
0043             int id,
0044             double charge,
0045             const math::XYZTLorentzVector& tkp,
0046             const math::XYZTLorentzVector& tkm,
0047             const SimVertex& tkv);
0048 
0049   /// Destructor
0050   virtual ~FSimTrack();
0051 
0052   /// particle info...
0053   inline const HepPDT::ParticleData* particleInfo() const { return info_; }
0054 
0055   /// charge
0056   inline float charge() const {
0057     if (particleInfo() == nullptr)
0058       return charge_;
0059     return particleInfo()->charge();
0060   }
0061 
0062   /// Origin vertex
0063   inline const FSimVertex vertex() const;
0064 
0065   /// end vertex
0066   inline const FSimVertex& endVertex() const;
0067 
0068   /// mother
0069   inline const FSimTrack& mother() const;
0070 
0071   /// Ith daughter
0072   inline const FSimTrack& daughter(int i) const;
0073 
0074   /// Number of daughters
0075   inline int nDaughters() const;
0076 
0077   /// Vector of daughter indices
0078   inline const std::vector<int>& daughters() const;
0079 
0080   /// no end vertex
0081   inline bool noEndVertex() const;
0082 
0083   /// Compare the end vertex position with another position.
0084   bool notYetToEndVertex(const XYZTLorentzVector& pos) const;
0085 
0086   /// no mother particle
0087   inline bool noMother() const;
0088 
0089   /// no daughters
0090   inline bool noDaughter() const;
0091 
0092   /// The original GenParticle
0093   inline const HepMC::GenParticle* genParticle() const;
0094 
0095   /// the index in FBaseSimEvent and other vectors
0096   inline int id() const { return id_; }
0097 
0098   /// The particle was propagated to the Preshower Layer1
0099   /// 2 : on the EndCaps; (no Barrel Preshower); no propagation possible
0100   /// 0 : not yet propagated or no pe
0101   inline int onLayer1() const { return layer1; }
0102 
0103   /// The particle was propagated to the Preshower Layer2
0104   /// 2 : on the EndCaps; (no Barrel Preshower); 3 : No propagation possible
0105   /// 0 : not yet propagated
0106   inline int onLayer2() const { return layer2; }
0107 
0108   /// The particle was propagated to the ECAL front face
0109   /// 1 : on the barrel; 2 : on the EndCaps; 3 : no propagation possible
0110   /// 0 : not yet propagated
0111   inline int onEcal() const { return ecal; }
0112 
0113   /// The particle was propagated to the HCAL front face
0114   /// 1 : on the barrel; 2 : on the EndCaps; 3 : no propagation possible
0115   /// 0 : not yet propagated
0116   inline int onHcal() const { return hcal; }
0117 
0118   /// The particle was propagated to the VFCAL front face
0119   /// 2 : on the EndCaps (No VFCAL Barrel); 3 : no propagation possible
0120   /// 0 : not yet propagated
0121   inline int onVFcal() const { return vfcal; }
0122 
0123   /// The particle was propagated to the HCAL back face
0124   /// 1 : on the barrel; 2 : on the EndCaps; 3 : no propagation possible
0125   /// 0 : not yet propagated
0126   inline int outHcal() const { return hcalexit; }
0127 
0128   //The particle was propagated to the HO front face
0129   /// 1 : on the barrel; 2 : on the EndCaps; 3 : no propagation possible
0130   /// 0 : not yet propagated
0131   inline int onHO() const { return hoentr; }
0132 
0133   /// The particle was tentatively propagated to calorimeters
0134   inline bool propagated() const { return prop; }
0135 
0136   /// The particle at Preshower Layer 1
0137   inline const RawParticle& layer1Entrance() const { return Layer1_Entrance; }
0138 
0139   /// The particle at Preshower Layer 2
0140   inline const RawParticle& layer2Entrance() const { return Layer2_Entrance; }
0141 
0142   /// The particle at ECAL entrance
0143   inline const RawParticle& ecalEntrance() const { return ECAL_Entrance; }
0144 
0145   /// The particle at HCAL entrance
0146   inline const RawParticle& hcalEntrance() const { return HCAL_Entrance; }
0147 
0148   /// The particle at VFCAL entrance
0149   inline const RawParticle& vfcalEntrance() const { return VFCAL_Entrance; }
0150 
0151   /// The particle at HCAL exir
0152   inline const RawParticle& hcalExit() const { return HCAL_Exit; }
0153 
0154   /// The particle at HCAL exir
0155   inline const RawParticle& hoEntrance() const { return HO_Entrance; }
0156 
0157   /// particle did not decay before more detectors (useful for newProducer)
0158   inline bool isGlobal() const { return isGlobal_; }
0159 
0160   /// particle did not decay before more detectors (useful for newProducer)
0161   inline void setGlobal() { isGlobal_ = true; }
0162 
0163   /// Set origin vertex
0164   inline void setOriginVertex(const SimVertex& v) { vertex_ = v; }
0165 
0166   /// Set the end vertex
0167   inline void setEndVertex(int endv) { endv_ = endv; }
0168 
0169   /// The particle has been propgated through the tracker
0170   void setPropagate();
0171 
0172   /// Set the preshower layer1 variables
0173   void setLayer1(const RawParticle& pp, int success);
0174 
0175   /// Set the preshower layer2 variables
0176   void setLayer2(const RawParticle& pp, int success);
0177 
0178   /// Set the ecal variables
0179   void setEcal(const RawParticle& pp, int success);
0180 
0181   /// Set the hcal variables
0182   void setHcal(const RawParticle& pp, int success);
0183 
0184   /// Set the hcal variables
0185   void setVFcal(const RawParticle& pp, int success);
0186 
0187   /// Set the hcal exit variables
0188   void setHcalExit(const RawParticle& pp, int success);
0189 
0190   /// Set the ho variables
0191   void setHO(const RawParticle& pp, int success);
0192 
0193   /// Add a RecHit for a track on a layer
0194   //  void addRecHit(const FamosBasicRecHit* hit, unsigned layer);
0195 
0196   /// Add a RecHit for a track on a layer
0197   //  void addSimHit(const RawParticle& pp, unsigned layer);
0198 
0199   /// Update the vactors of daughter's id
0200   inline void addDaughter(int i) { daugh_.push_back(i); }
0201 
0202   /// Set the index of the closest charged daughter
0203   inline void setClosestDaughterId(int id) { closestDaughterId_ = id; }
0204 
0205   /// Get the index of the closest charged daughter
0206   inline int closestDaughterId() const { return closestDaughterId_; }
0207 
0208   /// Temporary (until move of SimTrack to Mathcore) - No! Actually very useful
0209   const XYZTLorentzVector& momentum() const { return momentum_; }
0210 
0211   /// Reset the momentum (to be used with care)
0212   inline void setMomentum(const math::XYZTLorentzVector& newMomentum) { momentum_ = newMomentum; }
0213 
0214   /// Simply returns the SimTrack
0215   inline const SimTrack& simTrack() const { return *this; }
0216 
0217   /// Return the pre-defined decay time
0218   inline double decayTime() const { return properDecayTime; }
0219 
0220 private:
0221   //  HepMC::GenParticle* me_;
0222   SimVertex vertex_;
0223 
0224   FBaseSimEvent* mom_;
0225   //  int embd_;   // The index in the SimTrack vector
0226   int id_;         // The index in the FSimTrackVector
0227   double charge_;  // Charge of the particle
0228 
0229   int endv_;  // The index of the end vertex in FSimVertex
0230 
0231   int layer1;    // 1 if the particle was propagated to preshower layer1
0232   int layer2;    // 1 if the particle was propagated to preshower layer2
0233   int ecal;      // 1 if the particle was propagated to ECAL/HCAL barrel
0234   int hcal;      // 2 if the particle was propagated to ECAL/HCAL endcap
0235   int vfcal;     // 1 if the particle was propagated to VFCAL
0236   int hcalexit;  // 2 if the particle was propagated to HCAL Exit point
0237   int hoentr;    // 1 if the particle was propagated to HO
0238 
0239   bool prop;  // true if the propagation to the calorimeters was done
0240 
0241   RawParticle Layer1_Entrance;  // the particle at preshower Layer1
0242   RawParticle Layer2_Entrance;  // the particle at preshower Layer2
0243   RawParticle ECAL_Entrance;    // the particle at ECAL entrance
0244   RawParticle HCAL_Entrance;    // the particle at HCAL entrance
0245   RawParticle VFCAL_Entrance;   // the particle at VFCAL entrance
0246   RawParticle HCAL_Exit;        // the particle at HCAL ezit point
0247   RawParticle HO_Entrance;      // the particle at HO entrance
0248 
0249   std::vector<int> daugh_;  // The indices of the daughters in FSimTrack
0250   int closestDaughterId_;   // The index of the closest daughter id
0251 
0252   const HepPDT::ParticleData* info_;  // The PDG info
0253 
0254   XYZTLorentzVector momentum_;
0255 
0256   double properDecayTime;  // The proper decay time  (default is -1)
0257 
0258   bool isGlobal_;  // needed for interfacing the new particle propagator with the old muon sim hit code
0259 };
0260 
0261 #include <iosfwd>
0262 std::ostream& operator<<(std::ostream& o, const FSimTrack& t);
0263 
0264 #include "FastSimulation/Event/interface/FSimTrack.icc"
0265 
0266 #endif  // FSimTrack_H