CMS 3D CMS Logo

ConeAreaFunction.cc
Go to the documentation of this file.
2 
3 // -*- C++ -*-
4 //
5 // Package: ConeAreaFunction
6 // Class: ConeAreaFunction
7 //
16 //
17 // Original Author: Christian Veelken, UC Davis
18 // Created: Thu Nov 2 13:47:40 CST 2006
19 //
20 //
21 
22 // C++ standard library include files
23 #include <iostream>
24 #include <iomanip>
25 #include <vector>
26 
27 // ROOT include files
28 #include <TMath.h>
29 
30 // CMSSW include files
32 
35 
36 //
37 // constructors and destructor
38 //
39 
40 ConeAreaFunction::ConeAreaFunction() : ROOT::Math::ParamFunction<ROOT::Math::IParametricGradFunctionOneDim>(2) {
41  theta0_ = 0.;
42  phi0_ = 0.;
43 
44  etaMax_ = -1;
45 
47  integrator_ = new ROOT::Math::Integrator(*fTheta_);
48 }
49 
51  : ROOT::Math::ParamFunction<ROOT::Math::IParametricGradFunctionOneDim>(bluePrint) {
52  theta0_ = bluePrint.theta0_;
53  phi0_ = bluePrint.phi0_;
54 
55  etaMax_ = bluePrint.etaMax_;
56 
57  fTheta_ = new IntegrandThetaFunction(*bluePrint.fTheta_);
58  integrator_ = new ROOT::Math::Integrator(*fTheta_);
59 }
60 
62  delete fTheta_; // function gets deleted automatically by Integrator ?
63  delete integrator_;
64 }
65 
66 //
67 // assignment operator
68 //
69 
71  theta0_ = bluePrint.theta0_;
72  phi0_ = bluePrint.phi0_;
73 
74  etaMax_ = bluePrint.etaMax_;
75 
76  (*fTheta_) = (*bluePrint.fTheta_);
77  integrator_->SetFunction(*fTheta_);
78 
79  return (*this);
80 }
81 
82 //
83 // member functions
84 //
85 
86 void ConeAreaFunction::SetParameterTheta0(double theta0) { theta0_ = theta0; }
87 
89  phi0_ = normalizedPhi(phi0); // map azimuth angle into interval [-pi,+pi]
90 }
91 
92 void ConeAreaFunction::SetParameters(const double* param) {
93  if (debugLevel_ > 0) {
94  edm::LogVerbatim("") << "<ConeAreaFunction::SetParameters>:" << std::endl
95  << " theta0 = " << param[0] << std::endl
96  << " phi0 = " << param[1] << std::endl;
97  }
98 
99  theta0_ = param[0];
100  phi0_ = param[1];
101 }
102 
104  //--- check that pseudo-rapidity given as function argument is positive
105  // (assume equal acceptance for positive and negative pseudo-rapidities)
106 
107  if (etaMax > 0) {
108  etaMax_ = etaMax;
109  } else {
110  edm::LogError("") << "etaMax cannot be negative !" << std::endl;
111  }
112 }
113 
114 double ConeAreaFunction::DoEvalPar(double x, const double* param) const {
115  //--- calculate area covered by cone of opening angle alpha
116  // (measured from cone axis);
117  // evaluate integral over angle theta
118  // (polar angle of point within cone)
119  // FIXME: the const above is actually not true as it is implemented now.
120 
121  theta0_ = param[0];
122  phi0_ = param[1];
123 
124  return DoEval(x);
125 }
126 
127 double ConeAreaFunction::DoEval(double x) const {
128  //--- calculate area covered by cone of opening angle alpha
129  // (measured from cone axis);
130  // evaluate integral over angle theta
131  // (polar angle of point within cone)
132 
136 
137  integrator_->SetFunction(*fTheta_); // set updated parameter values in Integrator
138 
139  double thetaMin = (etaMax_ > 0) ? 2 * TMath::ATan(TMath::Exp(-etaMax_)) : 0.;
140  double thetaMax = TMath::Pi() - thetaMin;
141 
142  double integralOverTheta = integrator_->Integral(thetaMin, thetaMax);
143 
144  return integralOverTheta;
145 }
146 
147 double ConeAreaFunction::DoDerivative(double x) const {
148  //--- virtual function inherited from ROOT::Math::ParamFunction base class;
149  // not implemented, because not neccessary, but needs to be defined to make code compile...
150  edm::LogWarning("") << "Function not implemented yet !" << std::endl;
151 
152  return 0.;
153 }
154 
155 double ConeAreaFunction::DoParameterDerivative(double, const double*, unsigned int) const {
156  //--- virtual function inherited from ROOT::Math::ParamFunction base class;
157  // not implemented, because not neccessary, but needs to be defined to make code compile...
158  edm::LogWarning("") << "Function not implemented yet !" << std::endl;
159 
160  return 0.;
161 }
162 
163 void ConeAreaFunction::DoParameterGradient(double x, double* paramGradient) const {
164  //--- virtual function inherited from ROOT::Math::ParamFunction base class;
165  // not implemented, because not neccessary, but needs to be defined to make code compile...
166  edm::LogWarning("") << "Function not implemented yet !" << std::endl;
167 }
MessageLogger.h
IntegrandThetaFunction::SetParameterAlpha
void SetParameterAlpha(double alpha)
Definition: IntegrandThetaFunction.cc:84
ConeAreaFunction::SetParameterTheta0
void SetParameterTheta0(double theta0)
Definition: ConeAreaFunction.cc:86
IntegrandThetaFunction::SetParameterTheta0
void SetParameterTheta0(double theta0)
Definition: IntegrandThetaFunction.cc:78
IntegrandThetaFunction::SetParameterPhi0
void SetParameterPhi0(double phi0)
Definition: IntegrandThetaFunction.cc:80
DDAxes::x
ConeAreaFunction::theta0_
double theta0_
Definition: ConeAreaFunction.h:57
IntegrandThetaFunction.h
edm::LogWarning
Log< level::Warning, false > LogWarning
Definition: MessageLogger.h:122
ConeAreaFunction::debugLevel_
static const unsigned int debugLevel_
Definition: ConeAreaFunction.h:74
ConeAreaFunction::DoDerivative
double DoDerivative(double x) const
Definition: ConeAreaFunction.cc:147
ConeAreaFunction
Definition: ConeAreaFunction.h:33
normalizedPhi
constexpr T normalizedPhi(T phi)
Definition: normalizedPhi.h:8
IntegrandThetaFunction
Definition: IntegrandThetaFunction.h:33
ConeAreaFunction::DoEval
double DoEval(double x) const override
Definition: ConeAreaFunction.cc:127
ConeAreaFunction::fTheta_
IntegrandThetaFunction * fTheta_
Definition: ConeAreaFunction.h:71
ConeAreaFunction::~ConeAreaFunction
~ConeAreaFunction() override
Definition: ConeAreaFunction.cc:61
muonRecoAnalyzer_cfi.thetaMin
thetaMin
Definition: muonRecoAnalyzer_cfi.py:22
ConeAreaFunction::DoParameterGradient
void DoParameterGradient(double x, double *paramGradient) const
Definition: ConeAreaFunction.cc:163
ConeAreaFunction::operator=
ConeAreaFunction & operator=(const ConeAreaFunction &bluePrint)
Definition: ConeAreaFunction.cc:70
ConeAreaFunction::ConeAreaFunction
ConeAreaFunction()
Definition: ConeAreaFunction.cc:40
normalizedPhi.h
ConeAreaFunction::SetParameterPhi0
void SetParameterPhi0(double phi0)
Definition: ConeAreaFunction.cc:88
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
ConeAreaFunction::phi0_
double phi0_
Definition: ConeAreaFunction.h:58
muonRecoAnalyzer_cfi.thetaMax
thetaMax
Definition: muonRecoAnalyzer_cfi.py:23
edm::LogVerbatim
Log< level::Info, true > LogVerbatim
Definition: MessageLogger.h:128
genVertex_cff.x
x
Definition: genVertex_cff.py:12
ConeAreaFunction::SetAcceptanceLimit
void SetAcceptanceLimit(double etaMax)
Definition: ConeAreaFunction.cc:103
ALCARECOTkAlBeamHalo_cff.etaMax
etaMax
Definition: ALCARECOTkAlBeamHalo_cff.py:33
Pi
const double Pi
Definition: CosmicMuonParameters.h:18
ConeAreaFunction::etaMax_
double etaMax_
Definition: ConeAreaFunction.h:61
ConeAreaFunction::DoParameterDerivative
double DoParameterDerivative(double, const double *, unsigned int) const override
Definition: ConeAreaFunction.cc:155
ConeAreaFunction::integrator_
ROOT::Math::Integrator * integrator_
Definition: ConeAreaFunction.h:72
ROOT
Definition: Transform3DPJ.h:35
ConeAreaFunction::SetParameters
void SetParameters(double const *param) override
Definition: ConeAreaFunction.cc:92
ConeAreaFunction.h
ConeAreaFunction::DoEvalPar
double DoEvalPar(double, const double *) const override
Definition: ConeAreaFunction.cc:114