ATLAS Offline Software
ZRObject.h
Go to the documentation of this file.
1 // emacs: this is -*- c++ -*-
2 
3 /*
4  Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
5 */
6 
7 /**************************************************************************
8  **
9  ** File: ZRObject.h
10  **
11  ** Description: Object with rmin, rmax, zmin, zmax coordinates
12  ** with access methods and a test to see whether an
13  ** RoI lies within it, completely or partially.
14  **
15  ** Author: M.Sutton
16  **
17  ** Created: Wed Apr 4 17:43:46 BST 2007
18  ** Modified:
19  **
20  **
21  **
22  **************************************************************************/
23 
24 
25 #ifndef REGSELLUT_ZROBJECT_H
26 #define REGSELLUT_ZROBJECT_H
27 
28 #include "RegSelLUT/RegSelRoI.h"
29 
30 #include <iostream>
31 
32 
33 inline double calceta(double r, double z) {
34  if ( z==0 ) return 0;
35  double theta = std::atan(r/z);
36  if ( theta<0 ) theta += M_PI;
37  return -std::log( std::tan(theta*0.5) );
38 }
39 
40 
41 class ZRObject {
42 
43 public:
44 
45  ZRObject() : m_rMin(0), m_rMax(0),
46  m_zMin(0), m_zMax(0),
47  m_z2Min(0), m_z2Max(0), m_enabled(false)
48  { }
49 
50  ZRObject(double rmin, double rmax, double zmin, double zmax) :
51  m_rMin(rmin<rmax?rmin:rmax), m_rMax(rmax>rmin?rmax:rmin),
54  m_enabled(true)
55  { }
56 
57  ZRObject(double rmin, double rmax,
58  double zmin, double zmax,
59  double z2min, double z2max) :
60  m_rMin(rmin<rmax?rmin:rmax), m_rMax(rmax>rmin?rmax:rmin),
62  m_z2Min(z2min<z2max?z2min:z2max), m_z2Max(z2max>z2min?z2max:z2min),
63  m_enabled(true)
64  { }
65 
66  virtual ~ZRObject() = default;
67 
68  // check to see if the RoI and the object overlap
69  // ok really check if the object is completely outside,
70  // otherwise it must overlap
71  virtual bool inRoI(const RegSelRoI& roi) const {
72  if ( !enabled() ) return false;
73  if ( (roi.getzMax(rMin())<zMin() && roi.getzMax(rMax())<z2Min()) ||
74  (roi.getzMin(rMin())>zMax() && roi.getzMin(rMax())>z2Max()) ) {
75  return false;
76  }
77  return true;
78  }
79 
80  double rMin() const { return m_rMin; }
81  double rMax() const { return m_rMax; }
82 
83  double zMin() const { return m_zMin; }
84  double zMax() const { return m_zMax; }
85 
86  double z2Min() const { return m_z2Min; }
87  double z2Max() const { return m_z2Max; }
88 
89  double rMin(double rmin) { m_rMin = rmin; return m_rMin; }
90  double rMax(double rmax) { m_rMax = rmax; return m_rMax; }
91 
92  double zMin(double zmin) { m_zMin = zmin; return m_zMin; }
93  double zMax(double zmax) { m_zMax = zmax; return m_zMax; }
94 
95  double z2Min(double zmin) { m_z2Min = zmin; return m_z2Min; }
96  double z2Max(double zmax) { m_z2Max = zmax; return m_z2Max; }
97 
98  bool enabled() const { return m_enabled; }
99  bool enable() { return m_enabled=true; }
100  bool disable() { return m_enabled=false; }
101 
102  double _etaMin(double z=0) const {
103  double eta1 = calceta( rMin(), zMin()-z);
104  double eta2 = calceta( rMax(), z2Min()-z);
105  if ( eta1<eta2 ) return eta1;
106  else return eta2;
107  }
108 
109  double _etaMax(double z=0) const {
110  double eta1 = calceta( rMin(), zMax()-z);
111  double eta2 = calceta( rMax(), z2Max()-z);
112  if ( eta1>eta2 ) return eta1;
113  else return eta2;
114  }
115 
116 protected:
117 
118  double m_rMin, m_rMax;
119  double m_zMin, m_zMax;
120  double m_z2Min, m_z2Max;
121 
122  bool m_enabled;
123 
124 };
125 
126 
127 inline std::ostream& operator<<(std::ostream& s, const ZRObject& zr) {
128  s << "[ r=" << zr.rMin() << " - " << zr.rMax()
129  << " z=" << zr.zMin() << " - " << zr.zMax();
130  if ( zr.zMin()!=zr.z2Min() || zr.zMax()!=zr.z2Max() ) s << " z2=" << zr.z2Min() << " - " << zr.z2Max();
131  s << " ]";
132  return s;
133 }
134 
135 
136 
137 #endif /* REGSELLUT_ZROBJECT_H */
beamspotman.r
def r
Definition: beamspotman.py:676
ZRObject::z2Min
double z2Min() const
Definition: ZRObject.h:86
ZRObject::ZRObject
ZRObject(double rmin, double rmax, double zmin, double zmax, double z2min, double z2max)
Definition: ZRObject.h:57
python.SystemOfUnits.s
int s
Definition: SystemOfUnits.py:131
ParticleGun_SamplingFraction.eta2
eta2
Definition: ParticleGun_SamplingFraction.py:96
ZRObject::z2Max
double z2Max(double zmax)
Definition: ZRObject.h:96
ZRObject::ZRObject
ZRObject()
Definition: ZRObject.h:45
ZRObject::rMin
double rMin(double rmin)
Definition: ZRObject.h:89
PixelAthClusterMonAlgCfg.zmin
zmin
Definition: PixelAthClusterMonAlgCfg.py:169
ZRObject::m_zMax
double m_zMax
Definition: ZRObject.h:119
ZRObject::m_z2Max
double m_z2Max
Definition: ZRObject.h:120
theta
Scalar theta() const
theta method
Definition: AmgMatrixBasePlugin.h:75
ZRObject::m_enabled
bool m_enabled
Definition: ZRObject.h:122
M_PI
#define M_PI
Definition: ActiveFraction.h:11
ZRObject::ZRObject
ZRObject(double rmin, double rmax, double zmin, double zmax)
Definition: ZRObject.h:50
xAOD::eta1
setEt setPhi setE277 setWeta2 eta1
Definition: TrigEMCluster_v1.cxx:41
ZRObject::rMin
double rMin() const
Definition: ZRObject.h:80
calceta
double calceta(double r, double z)
Definition: ZRObject.h:33
ZRObject::rMax
double rMax() const
Definition: ZRObject.h:81
ZRObject::m_rMax
double m_rMax
Definition: ZRObject.h:118
drawFromPickle.atan
atan
Definition: drawFromPickle.py:36
ZRObject::zMin
double zMin() const
Definition: ZRObject.h:83
ZRObject::_etaMin
double _etaMin(double z=0) const
Definition: ZRObject.h:102
z
#define z
PixelAthClusterMonAlgCfg.zmax
zmax
Definition: PixelAthClusterMonAlgCfg.py:169
RegSelRoI::getzMax
double getzMax() const
Definition: RegSelRoI.h:60
drawFromPickle.tan
tan
Definition: drawFromPickle.py:36
ZRObject::m_z2Min
double m_z2Min
Definition: ZRObject.h:120
RegSelRoI
Definition: RegSelRoI.h:32
operator<<
std::ostream & operator<<(std::ostream &s, const ZRObject &zr)
Definition: ZRObject.h:127
ZRObject::zMax
double zMax(double zmax)
Definition: ZRObject.h:93
RegSelRoI::getzMin
double getzMin() const
Definition: RegSelRoI.h:59
ZRObject::z2Max
double z2Max() const
Definition: ZRObject.h:87
ZRObject::zMax
double zMax() const
Definition: ZRObject.h:84
ZRObject::enable
bool enable()
Definition: ZRObject.h:99
ZRObject::m_zMin
double m_zMin
Definition: ZRObject.h:119
ZRObject::z2Min
double z2Min(double zmin)
Definition: ZRObject.h:95
ZRObject::m_rMin
double m_rMin
Definition: ZRObject.h:118
ZRObject::zMin
double zMin(double zmin)
Definition: ZRObject.h:92
python.CaloCondTools.log
log
Definition: CaloCondTools.py:20
ZRObject::disable
bool disable()
Definition: ZRObject.h:100
ZRObject
Definition: ZRObject.h:41
ZRObject::rMax
double rMax(double rmax)
Definition: ZRObject.h:90
ZRObject::enabled
bool enabled() const
Definition: ZRObject.h:98
ZRObject::inRoI
virtual bool inRoI(const RegSelRoI &roi) const
Definition: ZRObject.h:71
RegSelRoI.h
ZRObject::~ZRObject
virtual ~ZRObject()=default
ZRObject::_etaMax
double _etaMax(double z=0) const
Definition: ZRObject.h:109