CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes
IntegralOverPhiFunction Class Reference

#include <PhysicsTools/IsolationUtils/src/IntegralOverPhiFunction.cc>

Inheritance diagram for IntegralOverPhiFunction:

Public Member Functions

virtual ROOT::Math::IGenFunction * Clone () const
 
 IntegralOverPhiFunction ()
 
void SetParameterAlpha (double alpha)
 
void SetParameterPhi0 (double phi0)
 
void SetParameterTheta0 (double theta0)
 
 ~IntegralOverPhiFunction ()
 

Private Member Functions

double DoDerivative (double x) const
 
double DoEval (double x) const
 
virtual double DoEvalPar (double x, const double *param) const
 
virtual double DoParameterDerivative (double, const double *, unsigned int) const
 
void DoParameterGradient (double x, double *paramGradient) const
 
void SetParameters (double *param)
 

Private Attributes

double alpha_
 
unsigned int numSolutionMax1_
 
unsigned int numSolutionMax2_
 
unsigned int numSolutionMax3_
 
unsigned int numSolutionMax4_
 
unsigned int numSolutionMin1_
 
unsigned int numSolutionMin2_
 
unsigned int numSolutionMin3_
 
unsigned int numSolutionMin4_
 
double phi0_
 
double theta0_
 

Static Private Attributes

static const unsigned int debugLevel_ = 0
 

Detailed Description

Description: auxialiary class for fixed area isolation cone computation (this class performs the integration over the azimuthal angle)

Implementation: imported into CMSSW on 05/18/2007

Definition at line 31 of file IntegralOverPhiFunction.h.

Constructor & Destructor Documentation

IntegralOverPhiFunction::IntegralOverPhiFunction ( )

Definition at line 46 of file IntegralOverPhiFunction.cc.

References alpha_, numSolutionMax1_, numSolutionMax2_, numSolutionMax3_, numSolutionMax4_, numSolutionMin1_, numSolutionMin2_, numSolutionMin3_, numSolutionMin4_, phi0_, and theta0_.

Referenced by Clone().

47  : ROOT::Math::ParamFunction<ROOT::Math::IParametricGradFunctionOneDim>(3)
48 {
49  theta0_ = 0.;
50  phi0_ = 0.;
51  alpha_ = 0.;
52 
53 // !!! ONLY FOR TESTING
54  numSolutionMin1_ = 0;
55  numSolutionMax1_ = 0;
56  numSolutionMin2_ = 0;
57  numSolutionMax2_ = 0;
58  numSolutionMin3_ = 0;
59  numSolutionMax3_ = 0;
60  numSolutionMin4_ = 0;
61  numSolutionMax4_ = 0;
62 // FOR TESTING ONLY !!!
63 }
IntegralOverPhiFunction::~IntegralOverPhiFunction ( )

Definition at line 65 of file IntegralOverPhiFunction.cc.

References debugLevel_, numSolutionMax1_, numSolutionMax2_, numSolutionMax3_, numSolutionMax4_, numSolutionMin1_, numSolutionMin2_, numSolutionMin3_, and numSolutionMin4_.

66 {
67 // !!! ONLY FOR TESTING
68  if ( debugLevel_ > 0 ) {
69  edm::LogVerbatim("") << "<IntegralOverPhiFunction::~IntegralOverPhiFunction>:" << std::endl
70  << " numSolutionMin1 = " << numSolutionMin1_ << std::endl
71  << " numSolutionMax1 = " << numSolutionMax1_ << std::endl
72  << " numSolutionMin2 = " << numSolutionMin2_ << std::endl
73  << " numSolutionMax2 = " << numSolutionMax2_ << std::endl
74  << " numSolutionMin3 = " << numSolutionMin3_ << std::endl
75  << " numSolutionMax3 = " << numSolutionMax3_ << std::endl
76  << " numSolutionMin4 = " << numSolutionMin4_ << std::endl
77  << " numSolutionMax4 = " << numSolutionMax4_ << std::endl;
78  }
79 // FOR TESTING ONLY !!!
80 }
static const unsigned int debugLevel_

Member Function Documentation

virtual ROOT::Math::IGenFunction* IntegralOverPhiFunction::Clone ( ) const
inlinevirtual

Definition at line 41 of file IntegralOverPhiFunction.h.

References IntegralOverPhiFunction().

41 { return new IntegralOverPhiFunction(*this); }
double IntegralOverPhiFunction::DoDerivative ( double  x) const
private

Definition at line 223 of file IntegralOverPhiFunction.cc.

224 {
225 //--- virtual function inherited from ROOT::Math::ParamFunction base class;
226 // not implemented, because not neccessary, but needs to be defined to make code compile...
227  edm::LogWarning("") << "Function not implemented yet !" << std::endl;
228 
229  return 0.;
230 }
double IntegralOverPhiFunction::DoEval ( double  x) const
private

Definition at line 119 of file IntegralOverPhiFunction.cc.

References alpha_, dtNoiseDBValidation_cfg::cerr, checkSolutions(), debugLevel_, epsilon, i, j, siStripFEDMonitor_P5_cff::Max, siStripFEDMonitor_P5_cff::Min, normalizedPhi(), numSolutionMax1_, numSolutionMax2_, numSolutionMax3_, numSolutionMax4_, numSolutionMin1_, numSolutionMin2_, numSolutionMin3_, numSolutionMin4_, phi, phi0_, jptDQMConfig_cff::phiMax, jptDQMConfig_cff::phiMin, Pi, alignCSCRings::r, alignCSCRings::s, lumiQTWidget::t, and theta0_.

120 {
121 //--- return zero if theta either close to zero or close to Pi
122 // (phi not well-defined in that case;
123 // numerical expressions might become "NaN"s)
124  const double epsilon = 1.e-3;
125  if ( x < epsilon || x > (TMath::Pi() - epsilon) ) return 0.;
126 
127 //--- calculate trigonometric expressions
128 // (dependend on angle theta0;
129 // polar angle of cone axis);
130 // avoid theta0 exactly zero or exactly Pi
131 // (numerical expressions become "NaN"s)
132  double theta0 = theta0_;
133  if ( theta0 < epsilon ) theta0 = epsilon;
134  if ( theta0 > (TMath::Pi() - epsilon)) theta0 = (TMath::Pi() - epsilon);
135  double cosTheta0 = TMath::Cos(theta0);
136  double cos2Theta0 = TMath::Cos(2*theta0);
137  double sinTheta0 = TMath::Sin(theta0);
138  double cotTheta0 = 1./TMath::Tan(theta0);
139  double cscTheta0 = 1./TMath::Sin(theta0);
140 // (dependend on angle phi0;
141 // azimuth angle of cone axis)
142  double cosPhi0 = TMath::Cos(phi0_);
143  double tanPhi0 = TMath::Tan(phi0_);
144 // (dependend on angle theta;
145 // polar angle of point within cone)
146  double cosTheta = TMath::Cos(x);
147  double cos2Theta = TMath::Cos(2*x);
148  double sinTheta = TMath::Sin(x);
149  double cotTheta = 1./TMath::Tan(x);
150  double cscTheta = 1./TMath::Sin(x);
151 // (dependent on angle alpha;
152 // opening angle of cone, measured from cone axis)
153  double cosAlpha = TMath::Cos(alpha_);
154 
155  double s = -cosPhi0*cosPhi0*(2*cosAlpha*cosAlpha + cos2Theta - 4*cosAlpha*cosTheta*cosTheta0 + cos2Theta0)*sinTheta*sinTheta*sinTheta0*sinTheta0;
156 
157 //--- return either zero or 2 Pi
158 // in case argument of square-root is zero or negative
159 // (negative values solely arise from rounding errors);
160 // check whether to return zero or 2 Pi:
161 // o return zero
162 // if |theta- theta0| > alpha,
163 // (theta outside cone of opening angle alpha, so vanishing integral over phi)
164 // o return 2 Pi
165 // if |theta- theta0| < alpha
166 // (theta within cone of opening angle alpha;
167 // actually theta0 < alpha in forward/backward direction,
168 // so that integral includes all phi values, hence yielding 2 Pi)
169  if ( s <= 0 ) {
170  if ( TMath::Abs(x - theta0) > alpha_ ) return 0;
171  if ( TMath::Abs(x - theta0) <= alpha_ ) return 2*TMath::Pi();
172  std::cerr << "Error in <IntegralOverPhiFunction::operator()>: failed to compute return value !" << std::endl;
173  }
174 
175  double r = (1./TMath::Sqrt(2.))*(cscTheta*cscTheta*cscTheta0*cscTheta0*TMath::Sqrt(s)*tanPhi0);
176  double t = cosPhi0*(-cotTheta*cotTheta0 + cosAlpha*cscTheta*cscTheta0);
177 
178  double phi[4];
179  phi[0] = -TMath::ACos(t - r);
180  phi[1] = TMath::ACos(t - r);
181  phi[2] = -TMath::ACos(t + r);
182  phi[3] = TMath::ACos(t + r);
183 
184  if ( debugLevel_ > 0 ) {
185  edm::LogVerbatim("") << "phi0 = " << phi0_ << std::endl
186  << "phi[0] = " << phi[0] << " (phi[0] - phi0 = " << (phi[0] - phi0_)*180/TMath::Pi() << ")" << std::endl
187  << "phi[1] = " << phi[1] << " (phi[1] - phi0 = " << (phi[1] - phi0_)*180/TMath::Pi() << ")" << std::endl
188  << "phi[2] = " << phi[2] << " (phi[2] - phi0 = " << (phi[2] - phi0_)*180/TMath::Pi() << ")" << std::endl
189  << "phi[3] = " << phi[3] << " (phi[3] - phi0 = " << (phi[3] - phi0_)*180/TMath::Pi() << ")" << std::endl;
190  }
191 
192  double phiMin = 0.;
193  double phiMax = 0.;
194  for ( unsigned int i = 0; i < 4; ++i ) {
195  for ( unsigned int j = (i + 1); j < 4; ++j ) {
196 //--- search for the two solutions for phi
197 // that have an equal distance to phi0
198 // and are on either side
199  double dPhi_i = phi[i] - phi0_;
200  double dPhi_j = phi0_ - phi[j];
201  if ( TMath::Abs(normalizedPhi(dPhi_i - dPhi_j)) < epsilon ) { // map difference in azimuth angle into interval [-pi,+pi] and require it to be negligible
202  //if ( TMath::Abs((phi[i] - phi0_) - (phi0_ - phi[j])) < epsilon ) { // map difference in azimuth angle into interval [-pi,+pi] and require it to be negligible
203  phiMin = TMath::Min(phi[i], phi[j]);
204  phiMax = TMath::Max(phi[i], phi[j]);
205 
206 // !!! ONLY FOR TESTING
211 // FOR TESTING ONLY !!!
212  }
213  }
214  }
215 
216  if ( phiMin == 0 && phiMax == 0 ) {
217  edm::LogError("") << "failed to compute Return Value !" << std::endl;
218  }
219 
220  return TMath::Abs(normalizedPhi(phi0_ - phiMin)) + TMath::Abs(normalizedPhi(phiMax - phi0_));
221 }
const double Pi
int i
Definition: DBlmapReader.cc:9
void checkSolutions(unsigned int i, unsigned int &numSolution1, unsigned int &numSolution2, unsigned int &numSolution3, unsigned int &numSolution4)
int j
Definition: DBlmapReader.cc:9
static const unsigned int debugLevel_
const double epsilon
Definition: DDAxes.h:10
double normalizedPhi(double phi)
Definition: normalizedPhi.cc:5
Definition: DDAxes.h:10
double IntegralOverPhiFunction::DoEvalPar ( double  x,
const double *  param 
) const
privatevirtual

Definition at line 108 of file IntegralOverPhiFunction.cc.

References x.

109 {
110  theta0_ = param[0];
111  phi0_ = param[1];
112  alpha_ = param[2];
113 
114  return DoEval(x);
115 }
double DoEval(double x) const
Definition: DDAxes.h:10
double IntegralOverPhiFunction::DoParameterDerivative ( double  ,
const double *  ,
unsigned  int 
) const
privatevirtual

Definition at line 232 of file IntegralOverPhiFunction.cc.

233 {
234 //--- virtual function inherited from ROOT::Math::ParamFunction base class;
235 // not implemented, because not neccessary, but needs to be defined to make code compile...
236  edm::LogWarning("") << "Function not implemented yet !" << std::endl;
237 
238  return 0.;
239 }
void IntegralOverPhiFunction::DoParameterGradient ( double  x,
double *  paramGradient 
) const
private

Definition at line 241 of file IntegralOverPhiFunction.cc.

242 {
243 //--- virtual function inherited from ROOT::Math::ParamFunction base class;
244 // not implemented, because not neccessary, but needs to be defined to make code compile...
245  edm::LogWarning("") << "Function not implemented yet !" << std::endl;
246 }
void IntegralOverPhiFunction::SetParameterAlpha ( double  alpha)

Definition at line 96 of file IntegralOverPhiFunction.cc.

References alpha, and alpha_.

Referenced by IntegrandThetaFunction::DoEval().

97 {
98  alpha_ = alpha;
99 }
float alpha
Definition: AMPTWrapper.h:95
void IntegralOverPhiFunction::SetParameterPhi0 ( double  phi0)

Definition at line 91 of file IntegralOverPhiFunction.cc.

References normalizedPhi(), and phi0_.

Referenced by IntegrandThetaFunction::DoEval().

92 {
93  phi0_ = normalizedPhi(phi0); // map azimuth angle into interval [-pi,+pi]
94 }
double normalizedPhi(double phi)
Definition: normalizedPhi.cc:5
void IntegralOverPhiFunction::SetParameters ( double *  param)
private

Definition at line 101 of file IntegralOverPhiFunction.cc.

References alpha_, phi0_, and theta0_.

102 {
103  theta0_ = param[0];
104  phi0_ = param[1];
105  alpha_ = param[2];
106 }
void IntegralOverPhiFunction::SetParameterTheta0 ( double  theta0)

Definition at line 86 of file IntegralOverPhiFunction.cc.

References theta0_.

Referenced by IntegrandThetaFunction::DoEval().

87 {
88  theta0_ = theta0;
89 }

Member Data Documentation

double IntegralOverPhiFunction::alpha_
mutableprivate
const unsigned int IntegralOverPhiFunction::debugLevel_ = 0
staticprivate

Definition at line 67 of file IntegralOverPhiFunction.h.

Referenced by DoEval(), and ~IntegralOverPhiFunction().

unsigned int IntegralOverPhiFunction::numSolutionMax1_
mutableprivate
unsigned int IntegralOverPhiFunction::numSolutionMax2_
mutableprivate
unsigned int IntegralOverPhiFunction::numSolutionMax3_
mutableprivate
unsigned int IntegralOverPhiFunction::numSolutionMax4_
mutableprivate
unsigned int IntegralOverPhiFunction::numSolutionMin1_
mutableprivate
unsigned int IntegralOverPhiFunction::numSolutionMin2_
mutableprivate
unsigned int IntegralOverPhiFunction::numSolutionMin3_
mutableprivate
unsigned int IntegralOverPhiFunction::numSolutionMin4_
mutableprivate
double IntegralOverPhiFunction::phi0_
mutableprivate
double IntegralOverPhiFunction::theta0_
mutableprivate