File indexing completed on 2023-03-17 11:21:42
0001
0002
0003
0004
0005
0006
0007 #ifndef RecoPPS_ProtonReconstruction_ProtonReconstructionAlgorithm_h
0008 #define RecoPPS_ProtonReconstruction_ProtonReconstructionAlgorithm_h
0009
0010 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0011
0012 #include "DataFormats/CTPPSReco/interface/CTPPSLocalTrackLiteFwd.h"
0013 #include "DataFormats/ProtonReco/interface/ForwardProtonFwd.h"
0014
0015 #include "CondFormats/RunInfo/interface/LHCInfo.h"
0016 #include "CondFormats/PPSObjects/interface/LHCInterpolatedOpticalFunctionsSet.h"
0017 #include "CondFormats/PPSObjects/interface/LHCInterpolatedOpticalFunctionsSetCollection.h"
0018
0019 #include "TSpline.h"
0020 #include "Fit/Fitter.h"
0021
0022 #include <unordered_map>
0023
0024
0025
0026 class ProtonReconstructionAlgorithm {
0027 public:
0028 ProtonReconstructionAlgorithm(bool fit_vtx_y,
0029 bool improved_estimate,
0030 const std::string &multiRPAlgorithm,
0031 unsigned int verbosity);
0032 ~ProtonReconstructionAlgorithm() = default;
0033
0034 void init(const LHCInterpolatedOpticalFunctionsSetCollection &opticalFunctions);
0035 void release();
0036
0037
0038 reco::ForwardProton reconstructFromSingleRP(const CTPPSLocalTrackLiteRef &track,
0039 const LHCInfo &lhcInfo,
0040 std::ostream &os) const;
0041
0042
0043 reco::ForwardProton reconstructFromMultiRP(const CTPPSLocalTrackLiteRefVector &tracks,
0044 const LHCInfo &lhcInfo,
0045 std::ostream &os) const;
0046
0047 private:
0048 unsigned int verbosity_;
0049 bool fitVtxY_;
0050 bool useImprovedInitialEstimate_;
0051 enum { mrpaUndefined, mrpaChi2, mrpaNewton, mrpaAnalIter } multi_rp_algorithm_;
0052 bool initialized_;
0053
0054
0055 struct RPOpticsData {
0056 const LHCInterpolatedOpticalFunctionsSet *optics;
0057 std::shared_ptr<const TSpline3> s_x_d_vs_xi, s_L_x_vs_xi, s_xi_vs_x_d, s_y_d_vs_xi, s_v_y_vs_xi, s_L_y_vs_xi;
0058 double x0;
0059 double y0;
0060 double ch0;
0061 double ch1;
0062 double la0;
0063 double la1;
0064 };
0065
0066
0067 std::map<unsigned int, RPOpticsData> m_rp_optics_;
0068
0069
0070 class ChiSquareCalculator {
0071 public:
0072 ChiSquareCalculator() = default;
0073
0074 double operator()(const double *parameters) const;
0075
0076 const CTPPSLocalTrackLiteRefVector *tracks;
0077 const std::map<unsigned int, RPOpticsData> *m_rp_optics;
0078 };
0079
0080
0081 std::unique_ptr<ROOT::Fit::Fitter> fitter_;
0082
0083
0084 std::unique_ptr<ChiSquareCalculator> chiSquareCalculator_;
0085
0086 static void doLinearFit(const std::vector<double> &vx, const std::vector<double> &vy, double &b, double &a);
0087
0088 static double newtonGoalFcn(double xi, double x_N, double x_F, const RPOpticsData &i_N, const RPOpticsData &i_F);
0089 };
0090
0091 #endif