Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:30:42

0001 #ifndef L1Trigger_TrackFindingTMTT_TP_h
0002 #define L1Trigger_TrackFindingTMTT_TP_h
0003 
0004 #include "DataFormats/Math/interface/deltaPhi.h"
0005 #include "SimDataFormats/TrackingAnalysis/interface/TrackingParticle.h"
0006 #include "DataFormats/Common/interface/Ptr.h"
0007 
0008 #include "L1Trigger/TrackFindingTMTT/interface/Settings.h"
0009 #include "L1Trigger/TrackFindingTMTT/interface/Utility.h"
0010 
0011 #include "DataFormats/JetReco/interface/GenJetCollection.h"
0012 #include "DataFormats/JetReco/interface/GenJet.h"
0013 
0014 #include <vector>
0015 #include <list>
0016 
0017 namespace tmtt {
0018 
0019   class Stub;
0020 
0021   typedef edm::Ptr<TrackingParticle> TrackingParticlePtr;
0022 
0023   class TP {
0024   public:
0025     // Fill useful info about tracking particle.
0026     TP(const TrackingParticlePtr& tpPtr, unsigned int index_in_vTPs, const Settings* settings);
0027 
0028     // Return pointer to original tracking particle.
0029     const TrackingParticlePtr& trackingParticlePtr() const { return trackingParticlePtr_; }
0030 
0031     bool operator==(const TP& tpOther) const { return (this->index() == tpOther.index()); }
0032 
0033     // Fill truth info with association from tracking particle to stubs.
0034     void fillTruth(const std::list<Stub>& vStubs);
0035 
0036     // == Functions for returning info about tracking particles ===
0037 
0038     // Location in InputData::vTPs_
0039     unsigned int index() const { return index_in_vTPs_; }
0040     // Basic TP properties
0041     int pdgId() const { return pdgId_; }
0042     // Did TP come from in-time or out-of-time bunch crossing?
0043     bool inTimeBx() const { return inTimeBx_; }
0044     // Did it come from the main physics collision or from pileup?
0045     bool physicsCollision() const { return physicsCollision_; }
0046     int charge() const { return charge_; }
0047     float mass() const { return mass_; }
0048     float pt() const { return pt_; }
0049     // Protect against pt=0;
0050     float qOverPt() const {
0051       constexpr float big = 9.9e9;
0052       return (pt_ > 0) ? charge_ / pt_ : big;
0053     }
0054     float eta() const { return eta_; }
0055     float theta() const { return theta_; }
0056     float tanLambda() const { return tanLambda_; }
0057     float phi0() const { return phi0_; }
0058     // TP production vertex (x,y,z) coordinates.
0059     float vx() const { return vx_; }
0060     float vy() const { return vy_; }
0061     float vz() const { return vz_; }
0062     // d0 and z0 impact parameters with respect to (x,y) = (0,0).
0063     float d0() const { return d0_; }
0064     float z0() const { return z0_; }
0065     // Estimate track bend angle at a given radius, ignoring scattering.
0066     float dphi(float rad) const { return asin(settings_->invPtToDphi() * rad * charge_ / pt_); }
0067     // Estimated phi angle at which TP trajectory crosses a given radius rad, ignoring scattering.
0068     float trkPhiAtR(float rad) const { return reco::deltaPhi(phi0_ - this->dphi(rad) - d0_ / rad, 0.); }
0069     // Estimated z coord at which TP trajectory crosses a given radius rad, ignoring scattering.
0070     float trkZAtR(float rad) const { return (vz_ + rad * tanLambda_); }
0071     // Estimated phi angle at which TP trajectory crosses the module containing the given stub.
0072     float trkPhiAtStub(const Stub* stub) const;
0073     // Estimated r coord at which TP trajectory crosses the module containing the given stub.
0074     float trkRAtStub(const Stub* stub) const;
0075     // Estimated z coord at which TP trajectory crosses the module containing the given stub.
0076     float trkZAtStub(const Stub* stub) const;
0077 
0078     // == Functions returning stubs produced by tracking particle.
0079     const std::vector<const Stub*>& assocStubs() const {
0080       return assocStubs_;
0081     }  // associated stubs. (Includes those failing tightened front-end electronics cuts supplied by user). (Which stubs are returned is affected by "StubMatchStrict" config param.)
0082     unsigned int numAssocStubs() const { return assocStubs_.size(); }
0083     unsigned int numLayers() const { return nLayersWithStubs_; }
0084     // TP is worth keeping (e.g. for fake rate measurement)
0085     bool use() const { return use_; }
0086     // TP can be used for efficiency measurement (good kinematics, in-time Bx, optionally specified PDG ID).
0087     bool useForEff() const { return useForEff_; }
0088     // TP can be used for algorithmic efficiency measurement (also requires stubs in enough layers).
0089     bool useForAlgEff() const { return useForAlgEff_; }
0090 
0091     void fillNearestJetInfo(const reco::GenJetCollection* genJets);  // Store info (deltaR, pt) with nearest jet
0092 
0093     // Check if TP is in a jet (for performance studies in jets)
0094     float tpInJet(float genJetPtCut = 30.) const { return (tpInJet_ && nearestJetPt_ > genJetPtCut); }
0095     float nearestJetPt() const { return nearestJetPt_; }  // -ve if no nearest jet.
0096 
0097   private:
0098     void fillUse();           // Fill the use_ flag.
0099     void fillUseForEff();     // Fill the useForEff_ flag.
0100     void fillUseForAlgEff();  // Fill the useforAlgEff_ flag.
0101 
0102     // Calculate how many tracker layers this TP has stubs in.
0103     void calcNumLayers() { nLayersWithStubs_ = Utility::countLayers(settings_, assocStubs_, false); }
0104 
0105   private:
0106     TrackingParticlePtr trackingParticlePtr_;  // Pointer to original TrackingParticle.
0107 
0108     unsigned int index_in_vTPs_;  // location of this TP in InputData::vTPs
0109 
0110     const Settings* settings_;  // Configuration parameters
0111 
0112     int pdgId_;
0113     bool inTimeBx_;          // TP came from in-time bunch crossing.
0114     bool physicsCollision_;  // True if TP from physics collision rather than pileup.
0115     int charge_;
0116     float mass_;
0117     float pt_;  // TP kinematics
0118     float eta_;
0119     float theta_;
0120     float tanLambda_;
0121     float phi0_;
0122     float vx_;  // TP production point.
0123     float vy_;
0124     float vz_;
0125     float d0_;  // d0 impact parameter with respect to (x,y) = (0,0)
0126     float z0_;  // z0 impact parameter with respect to (x,y) = (0,0)
0127 
0128     std::vector<const Stub*> assocStubs_;
0129     unsigned int nLayersWithStubs_;  // Number of tracker layers with stubs from this TP.
0130 
0131     bool use_;           // TP is worth keeping (e.g. for fake rate measurement)
0132     bool useForEff_;     // TP can be used for tracking efficiency measurement.
0133     bool useForAlgEff_;  // TP can be used for tracking algorithmic efficiency measurement.
0134 
0135     bool tpInJet_;
0136     float nearestJetPt_;
0137   };
0138 
0139 }  // namespace tmtt
0140 
0141 #endif