ATLAS Offline Software
Loading...
Searching...
No Matches
PhiRange.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
3*/
4/***************************************************************************
5 PhiRange.cxx - description
6 -------------------
7 begin : 26/02/2002
8 email : e.moyse@qmul.ac.uk
9***************************************************************************/
10
11
13
14#include <iostream>
15#include "math.h"
16
17namespace LVL1 {
18
20 : m_min( 0.0 ), m_max( 0.0 ) {
21
22 }
23
24 PhiRange::PhiRange( double min, double max )
25 : m_min( min ), m_max( max ) {
26
28 }
29
30 double PhiRange::min() const {
31 return m_min;
32 }
33
34 double PhiRange::max() const {
35 return m_max;
36 }
37
39 void PhiRange::setRange( double min, double max ) {
40 m_min = min;
41 m_max = max;
43 }
44
45
50 bool PhiRange::contains( double number ) const {
51
52 double diff = fabs( m_min - m_max );
53 if ( diff > M_PI ) {
54 // range must overlap 2PI
55 return ( ( m_min <= number && number <= ( 2 * M_PI ) )
56 || ( ( 0 <= number && number <= m_max ) ) );
57 }
58 // diff must be <=M_PI
59 return ( ( m_min <= number ) && ( number <= m_max ) );
60 }
61
64 // should really check for more extreme values.
65
66// double & tmpMin = m_min;
67// double& tmpMax = m_max;
68
69 if ( m_min < 0.0 ) m_min = ( 2.0 * M_PI ) + m_min;
70 if ( m_max > ( 2.0 * M_PI ) ) m_max -= ( 2.0 * M_PI );
71
72 if ( fabs(m_min-m_max) > M_PI) {
73 // RoI range must span 2PI wraparound. In which case m_min should have higher value, m_max lower
74 if (m_min < m_max) {
75 // swap them
76 double temp = m_max;
77 m_max = m_min;
78 m_min = temp;
79 }
80 }
81 else if ( m_min >= m_max ) {
82 // swap them
83 double temp = m_max;
84 m_max = m_min;
85 m_min = temp;
86 }
87 // }
88 return;
89 }
90
93 double LVL1::PhiRange::centre() const {
94 double diff = fabs( m_min - m_max );
95 if ( diff > M_PI ) {
96 // range must overlap 2PI
97 double cent = ( m_min + ( m_max - m_min + 2 * M_PI ) / 2 );
98 if ( cent < 0.0 ) return ( 2.0 * M_PI ) + cent;
99 if ( cent > ( 2.0 * M_PI ) ) return cent -( 2.0 * M_PI );
100 return cent;
101 }
102 // diff must be <=M_PI
103 return ( m_min + ( ( m_max - m_min ) / 2 ) );
104
105 }
106
107} // namespace LVL1
#define M_PI
void diff(const Jet &rJet1, const Jet &rJet2, std::map< std::string, double > varDiff)
Difference between jets - Non-Class function required by trigger.
Definition Jet.cxx:631
double m_max
Definition PhiRange.h:40
double min() const
Definition PhiRange.cxx:30
void checkValues()
This function makes sure m_min really is less than m_max.
Definition PhiRange.cxx:63
bool contains(double number) const
returns true if the range contains the number (i.e.
Definition PhiRange.cxx:50
void setRange(double min, double max)
sets range
Definition PhiRange.cxx:39
double max() const
Definition PhiRange.cxx:34
double m_min
Definition PhiRange.h:39
double centre() const
returns the centre of the two ranges.
Definition PhiRange.cxx:93
eFexTowerBuilder creates xAOD::eFexTowerContainer from supercells (LATOME) and triggerTowers (TREX) i...
std::string number(const double &d, const std::string &s)
Definition utils.cxx:186