ATLAS Offline Software
Loading...
Searching...
No Matches
PolygonBase.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
3*/
4
5#include <iostream>
6#include <cstdlib>
8#include "GeoModelKernel/throwExcept.h"
9using namespace MuonCalib;
10
11PolygonBase::PolygonBase(const std::vector<double> & x) {
12
13 // CHECK FOR CORRECT FILLING
14 for (unsigned int k=0; k<x.size()-1; k++) {
15 if (x[k]>=x[k+1]) {
16 THROW_EXCEPTION("PolygonBase::init - Abscissae not in increasing order!");
17 }
18 }
19 // TRANSFER THE INPUT DATA //
20 m_x = x;
21}
22double PolygonBase::value(const int k, const double x) const {
23
24 // CHECK THE BASE FUNCTION INDEX //
25 if (k<0 || k>static_cast<int>(m_x.size()-1)) {
26 THROW_EXCEPTION("PolygonBase::value - Illegal function index "<<k<<"! Should be >0 and "<<m_x.size());
27 }
28
29 // outside the domain of the polygon //
30 if (x<m_x[0] || x>m_x[m_x.size()-1]) {
31 return 0.0;
32 }
33 // inside the domain of the polygon //
34 if (k==0 && x<m_x[0]) {
35 return 0.0;
36 }
37 if (k==0 && x<=m_x[1]) {
38 return (m_x[1]-x)/(m_x[1]-m_x[0]);
39 }
40 if (k==0 && x>m_x[1]) {
41 return 0.0;
42 }
43 if (static_cast<unsigned int>(k)==m_x.size()-1 &&
44 x<=m_x[m_x.size()-2]) {
45 return 0.0;
46 }
47 if (static_cast<unsigned int>(k)==m_x.size()-1 &&
48 x<=m_x[m_x.size()-1]) {
49 return (x-m_x[k-1])/(m_x[k]-m_x[k-1]);
50 }
51 if (static_cast<unsigned int>(k)==m_x.size()-1 &&
52 x>m_x[m_x.size()-1]) {
53 return 0.0;
54 }
55 if (x<m_x[k-1] || x>m_x[k+1]) {
56 return 0.0;
57 }
58
59 if (x<m_x[k]) {
60 return (x-m_x[k-1])/(m_x[k]-m_x[k-1]);
61 }
62 return (m_x[k+1]-x)/(m_x[k+1]-m_x[k]);
63}
#define x
double value(const int k, const double x) const
get the value of the k-th base function at x
std::vector< double > m_x
Definition PolygonBase.h:54
PolygonBase(const std::vector< double > &x)
Constructor: the vector x contains the abscissae of the base points of the polygon.
CscCalcPed - algorithm that finds the Cathode Strip Chamber pedestals from an RDO.
#define THROW_EXCEPTION(MESSAGE)
Definition throwExcept.h:10