Skip to content

Commit

Permalink
Merge pull request #45965 from iarspider/iarspider-patch-20240910-roo…
Browse files Browse the repository at this point in the history
…tmaster

Update classes inheriting from ROOT::Minuit2::FCNBase to account for changes in ROOTmaster
  • Loading branch information
cmsbuild authored Sep 13, 2024
2 parents 47b9972 + 4b5e99d commit 4e7c227
Show file tree
Hide file tree
Showing 7 changed files with 62 additions and 1 deletion.
8 changes: 8 additions & 0 deletions OnlineDB/CSCCondDB/interface/CSCThrTurnOnFcn.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@

#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 @@ -39,7 +43,11 @@ 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
6 changes: 5 additions & 1 deletion OnlineDB/CSCCondDB/src/CSCFitAFEBThr.cc
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,12 @@ 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), 1, 500, 0.1);
#else
FunctionMinimum fmin = theFitter->Minimize(*theOBJfun, parinit, erparinit, 1, 500, 0.1);

#endif
status = fmin.IsValid();

if (status) {
Expand Down
4 changes: 4 additions & 0 deletions OnlineDB/CSCCondDB/src/CSCThrTurnOnFcn.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@
#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: 15 additions & 0 deletions RecoVertex/BeamSpotProducer/interface/BSpdfsFcn.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ ________________________________________________________________**/

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

class BSpdfsFcn : public ROOT::Minuit2::FCNBase {
public:
Expand All @@ -26,14 +30,25 @@ 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: 6 additions & 0 deletions RecoVertex/BeamSpotProducer/interface/FcnBeamSpotFitPV.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
#include "Minuit2/FCNBase.h"

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

class FcnBeamSpotFitPV : public ROOT::Minuit2::FCNBase {
public:
Expand All @@ -29,7 +31,11 @@ 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, 32, 4)
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: 20 additions & 0 deletions RecoVertex/BeamSpotProducer/src/BSpdfsFcn.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,16 @@ ________________________________________________________________**/

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

//______________________________________________________________________
#if ROOT_VERSION_CODE >= ROOT_VERSION(6, 32, 4)
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 @@ -35,8 +42,12 @@ double BSpdfsFcn::PDFGauss_d(double z, double d, double sigmad, double phi, cons
}

//______________________________________________________________________
#if ROOT_VERSION_CODE >= ROOT_VERSION(6, 32, 4)
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 @@ -57,7 +68,12 @@ double BSpdfsFcn::PDFGauss_d_resolution(
}

//______________________________________________________________________
#if ROOT_VERSION_CODE >= ROOT_VERSION(6, 32, 4)
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 @@ -73,7 +89,11 @@ double BSpdfsFcn::PDFGauss_z(double z, double sigmaz, const std::vector<double>&
}

//______________________________________________________________________
#if ROOT_VERSION_CODE >= ROOT_VERSION(6, 32, 4)
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: 4 additions & 0 deletions RecoVertex/BeamSpotProducer/src/FcnBeamSpotFitPV.cc
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,11 @@ 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 4e7c227

Please sign in to comment.