Skip to content

Commit

Permalink
Merge pull request #46079 from guitargeek/minuit2_fix
Browse files Browse the repository at this point in the history
Follow up on recent Minuit 2 code changes
  • Loading branch information
cmsbuild authored Oct 10, 2024
2 parents ab58733 + 43574ba commit ea0fd48
Show file tree
Hide file tree
Showing 7 changed files with 3 additions and 63 deletions.
8 changes: 0 additions & 8 deletions OnlineDB/CSCCondDB/interface/CSCThrTurnOnFcn.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@

#include "Minuit2/FCNBase.h"
#include <vector>
#include <RVersion.h>
#if ROOT_VERSION_CODE >= ROOT_VERSION(6, 33, 1)
#include <span>
#endif

class CSCThrTurnOnFcn : public ROOT::Minuit2::FCNBase {
private:
Expand Down Expand Up @@ -43,11 +39,7 @@ class CSCThrTurnOnFcn : public ROOT::Minuit2::FCNBase {
void setNorm(float n) { norm = n; };

/// Provide the chi-squared function for the given data
#if ROOT_VERSION_CODE >= ROOT_VERSION(6, 33, 1)
double operator()(std::span<const double>) const override;
#else
double operator()(const std::vector<double>&) const override;
#endif

///@@ What?
double Up() const override { return 1.; }
Expand Down
9 changes: 3 additions & 6 deletions OnlineDB/CSCCondDB/src/CSCFitAFEBThr.cc
Original file line number Diff line number Diff line change
Expand Up @@ -130,12 +130,9 @@ bool CSCFitAFEBThr::ThresholdNoise(const std::vector<float>& inputx,
// <<" "<<ery[i]<<std::endl;

/// Fit as 1D, <=500 iterations, edm=10**-5 (->0.1)
#if ROOT_VERSION_CODE >= ROOT_VERSION(6, 33, 1)
FunctionMinimum fmin = theFitter->Minimize(
*theOBJfun, {std::span<double>(parinit), std::span<double>(erparinit)}, MnStrategy{1}, 500, 0.1);
#else
FunctionMinimum fmin = theFitter->Minimize(*theOBJfun, parinit, erparinit, 1, 500, 0.1);
#endif
FunctionMinimum fmin =
theFitter->Minimize(*theOBJfun, MnUserParameterState{parinit, erparinit}, MnStrategy{1}, 500, 0.1);

status = fmin.IsValid();

if (status) {
Expand Down
4 changes: 0 additions & 4 deletions OnlineDB/CSCCondDB/src/CSCThrTurnOnFcn.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,7 @@
#include <vector>
#include "TMath.h"

#if ROOT_VERSION_CODE >= ROOT_VERSION(6, 33, 1)
double CSCThrTurnOnFcn::operator()(std::span<const double> par) const {
#else
double CSCThrTurnOnFcn::operator()(const std::vector<double>& par) const {
#endif
double x, y, er, fn;
double N = norm;
double chi2 = 0.;
Expand Down
15 changes: 0 additions & 15 deletions RecoVertex/BeamSpotProducer/interface/BSpdfsFcn.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,6 @@ ________________________________________________________________**/

#include <iostream>
#include <string>
#include <RVersion.h>
#if ROOT_VERSION_CODE >= ROOT_VERSION(6, 33, 1)
#include <span>
#endif

class BSpdfsFcn : public ROOT::Minuit2::FCNBase {
public:
Expand All @@ -30,25 +26,14 @@ class BSpdfsFcn : public ROOT::Minuit2::FCNBase {
// define pdfs to use
void SetPDFs(std::string usepdfs) { fusepdfs = usepdfs; }

#if ROOT_VERSION_CODE >= ROOT_VERSION(6, 33, 1)
double operator()(std::span<const double>) const override;
#else
double operator()(const std::vector<double>&) const override;
#endif
double Up() const override { return 1.; }

private:
#if ROOT_VERSION_CODE >= ROOT_VERSION(6, 33, 1)
double PDFGauss_d(double z, double d, double sigmad, double phi, std::span<const double> parms) const;
double PDFGauss_d_resolution(double z, double d, double phi, double pt, std::span<const double> parms) const;

double PDFGauss_z(double z, double sigmaz, std::span<const double> parms) const;
#else
double PDFGauss_d(double z, double d, double sigmad, double phi, const std::vector<double>& parms) const;
double PDFGauss_d_resolution(double z, double d, double phi, double pt, const std::vector<double>& parms) const;

double PDFGauss_z(double z, double sigmaz, const std::vector<double>& parms) const;
#endif

std::string fusepdfs;
std::vector<BSTrkParameters> fBSvector;
Expand Down
6 changes: 0 additions & 6 deletions RecoVertex/BeamSpotProducer/interface/FcnBeamSpotFitPV.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
#include "Minuit2/FCNBase.h"

#include <vector>
#include <span>
#include <RVersion.h>

class FcnBeamSpotFitPV : public ROOT::Minuit2::FCNBase {
public:
Expand All @@ -31,11 +29,7 @@ class FcnBeamSpotFitPV : public ROOT::Minuit2::FCNBase {
// deltaFcn for definition of the uncertainty
double Up() const override { return errorDef_; }
// -2lnL value based on vector of parameters
#if ROOT_VERSION_CODE >= ROOT_VERSION(6, 33, 1)
double operator()(std::span<const double>) const override;
#else
double operator()(const std::vector<double>&) const override;
#endif
// vertex count used for the fit (after selection)
unsigned int nrOfVerticesUsed() const;

Expand Down
20 changes: 0 additions & 20 deletions RecoVertex/BeamSpotProducer/src/BSpdfsFcn.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,9 @@ ________________________________________________________________**/

#include <cmath>
#include <vector>
#if ROOT_VERSION_CODE >= ROOT_VERSION(6, 33, 1)
#include <span>
#endif

//______________________________________________________________________
#if ROOT_VERSION_CODE >= ROOT_VERSION(6, 33, 1)
double BSpdfsFcn::PDFGauss_d(double z, double d, double sigmad, double phi, std::span<const double> parms) const {
#else
double BSpdfsFcn::PDFGauss_d(double z, double d, double sigmad, double phi, const std::vector<double>& parms) const {
#endif
//---------------------------------------------------------------------------
// PDF for d0 distribution. This PDF is a simple gaussian in the
// beam reference frame.
Expand All @@ -42,12 +35,8 @@ double BSpdfsFcn::PDFGauss_d(double z, double d, double sigmad, double phi, cons
}

//______________________________________________________________________
#if ROOT_VERSION_CODE >= ROOT_VERSION(6, 33, 1)
double BSpdfsFcn::PDFGauss_d_resolution(double z, double d, double phi, double pt, std::span<const double> parms) const {
#else
double BSpdfsFcn::PDFGauss_d_resolution(
double z, double d, double phi, double pt, const std::vector<double>& parms) const {
#endif
//---------------------------------------------------------------------------
// PDF for d0 distribution. This PDF is a simple gaussian in the
// beam reference frame. The IP resolution is parametrize by a linear
Expand All @@ -68,12 +57,7 @@ double BSpdfsFcn::PDFGauss_d_resolution(
}

//______________________________________________________________________
#if ROOT_VERSION_CODE >= ROOT_VERSION(6, 33, 1)
double BSpdfsFcn::PDFGauss_z(double z, double sigmaz, std::span<const double> parms) const {
#else
double BSpdfsFcn::PDFGauss_z(double z, double sigmaz, const std::vector<double>& parms) const {
#endif

//---------------------------------------------------------------------------
// PDF for z-vertex distribution. This distribution
// is parametrized by a simple normalized gaussian distribution.
Expand All @@ -89,11 +73,7 @@ double BSpdfsFcn::PDFGauss_z(double z, double sigmaz, const std::vector<double>&
}

//______________________________________________________________________
#if ROOT_VERSION_CODE >= ROOT_VERSION(6, 33, 1)
double BSpdfsFcn::operator()(const std::span<const double> params) const {
#else
double BSpdfsFcn::operator()(const std::vector<double>& params) const {
#endif
double f = 0.0;

//std::cout << "fusepdfs=" << fusepdfs << " params.size="<<params.size() << std::endl;
Expand Down
4 changes: 0 additions & 4 deletions RecoVertex/BeamSpotProducer/src/FcnBeamSpotFitPV.cc
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,7 @@ unsigned int FcnBeamSpotFitPV::nrOfVerticesUsed() const {
return nVtx;
}

#if ROOT_VERSION_CODE >= ROOT_VERSION(6, 33, 1)
double FcnBeamSpotFitPV::operator()(std::span<const double> pars) const {
#else
double FcnBeamSpotFitPV::operator()(const std::vector<double>& pars) const {
#endif
//
// fit parameters
//
Expand Down

0 comments on commit ea0fd48

Please sign in to comment.