Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-01-10 06:14:22

0001 #ifndef ChargeSignificanceTrajectoryFilter_H
0002 #define ChargeSignificanceTrajectoryFilter_H
0003 
0004 #include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
0005 #include "TrackingTools/TrajectoryFiltering/interface/TrajectoryFilter.h"
0006 #include "TrackingTools/PatternTools/interface/Trajectory.h"
0007 #include "TrackingTools/PatternTools/interface/TempTrajectory.h"
0008 
0009 /** A TrajectoryFilter that stops reconstruction if P_t drops
0010  *  below some value at some confidence level.
0011  *  The CkfTrajectoryBuilder uses this class to
0012  *  implement the minimal P_t cut.
0013  */
0014 
0015 class ChargeSignificanceTrajectoryFilter final : public TrajectoryFilter {
0016 public:
0017   explicit ChargeSignificanceTrajectoryFilter(float qsig) : theChargeSignificance(qsig) {}
0018 
0019   explicit ChargeSignificanceTrajectoryFilter(const edm::ParameterSet& pset, edm::ConsumesCollector& iC)
0020       : theChargeSignificance(pset.getParameter<double>("chargeSignificance")) {}
0021 
0022   static void fillPSetDescription(edm::ParameterSetDescription& iDesc) { iDesc.add<double>("chargeSignificance", -1.); }
0023 
0024   bool qualityFilter(const Trajectory& traj) const override { return traj.isValid(); }
0025   bool qualityFilter(const TempTrajectory& traj) const override { return traj.isValid(); }
0026 
0027   bool toBeContinued(Trajectory& traj) const override { return TBC<Trajectory>(traj); }
0028   bool toBeContinued(TempTrajectory& traj) const override { return TBC<TempTrajectory>(traj); }
0029 
0030   std::string name() const override { return "ChargeSignificanceTrajectoryFilter"; }
0031 
0032 protected:
0033   template <class T>
0034   bool TBC(T& traj) const {
0035     const typename T::DataContainer& tms = traj.measurements();
0036     // Check flip in q-significance. The loop over all TMs could be
0037     // avoided by storing the current significant q in the trajectory
0038 
0039     if (theChargeSignificance > 0.) {
0040       float qSig = 0;
0041 
0042       // skip first two hits (don't rely on significance of q/p)
0043       for (typename T::DataContainer::size_type itm = 2; itm < tms.size(); ++itm) {
0044         TrajectoryStateOnSurface const& tsos = tms[itm].updatedState();
0045         if (!tsos.isValid())
0046           continue;
0047 
0048         auto significance = tsos.localParameters().vector()(0) / std::sqrt(float(tsos.localError().matrix()(0, 0)));
0049 
0050         // don't deal with measurements compatible with 0
0051         if (std::abs(significance) < theChargeSignificance)
0052           continue;
0053 
0054         //
0055         // if charge not yet defined: store first significant Q
0056         //
0057         if (qSig == 0)
0058           qSig = significance;
0059 
0060         //
0061         //  invalidate and terminate in case of a change of sign
0062         //
0063         if (significance * qSig < 0) {
0064           traj.invalidate();
0065           traj.setStopReason(StopReason::CHARGE_SIGNIFICANCE);
0066           return false;
0067         }
0068       }
0069     }
0070     return true;
0071   }
0072 
0073   float theChargeSignificance;
0074 };
0075 
0076 #endif