File indexing completed on 2024-04-06 12:31:40
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
0010
0011
0012
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
0037
0038
0039 if (theChargeSignificance > 0.) {
0040 float qSig = 0;
0041
0042
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
0051 if (std::abs(significance) < theChargeSignificance)
0052 continue;
0053
0054
0055
0056
0057 if (qSig == 0)
0058 qSig = significance;
0059
0060
0061
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