ATLAS Offline Software
ActiveFraction.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #ifndef ACTIVEFRACTION_H
6 #define ACTIVEFRACTION_H
7 #include <vector>
10 #ifndef M_PI
11 #define M_PI 3.141592653589793238462643383279502884197
12 #endif
13 namespace TRTCond{
14  // eta,phi binned map of the active straw fraction
16  public:
18  virtual ~ActiveFraction(){};
19  int findEtaBin( float eta ) const;
20  int findPhiBin( float phi ) const;
21  float getActiveFraction( float eta, float phi ) const;
22  std::vector<std::pair<float,float>> getEtaBins( ) const;
23  std::vector<std::pair<float,float>> getPhiBins( ) const;
24  void setActiveFraction( unsigned int etaBin, unsigned int phiBin, float value);
25 
26  private:
28  std::vector<std::pair<float,float> > m_etaBins;
29  std::vector<std::pair<float,float> > m_phiBins;
30  std::vector<std::vector<float> > m_activeFracTable; // [etaBin,phiBin]
31  };
33  m_nBinsPhi=96;
34  m_etaBins.push_back( std::make_pair(-2.1,-1.75) );
35  m_etaBins.push_back( std::make_pair(-1.75,-1.3) );
36  m_etaBins.push_back( std::make_pair(-1.3,-1.07) );
37  m_etaBins.push_back( std::make_pair(-1.07,-0.65) );
38  m_etaBins.push_back( std::make_pair(-0.65,-0.1) );
39  m_etaBins.push_back( std::make_pair(-0.1,0.) );
40  m_etaBins.push_back( std::make_pair(0.,0.1) );
41  m_etaBins.push_back( std::make_pair(0.1,0.65) );
42  m_etaBins.push_back( std::make_pair(0.65,1.07) );
43  m_etaBins.push_back( std::make_pair(1.07,1.3) );
44  m_etaBins.push_back( std::make_pair(1.3,1.75) );
45  m_etaBins.push_back( std::make_pair(1.75,2.1) );
46  float phiEdgeLow = -1. * M_PI;
47  float deltaPhi = 2. * M_PI / (1. * m_nBinsPhi) ;
48  for ( int i = 0; i < m_nBinsPhi; ++i ) {
49  m_phiBins.push_back( std::make_pair( phiEdgeLow + i*deltaPhi, phiEdgeLow + (i+1)*deltaPhi ) );
50  }
51  // Initialize the table with 1.'s
52  std::vector<float> dummyPhiVec( m_phiBins.size(), 1. );
53  std::vector<std::vector<float> > dummyTable( m_etaBins.size(), dummyPhiVec );
54  m_activeFracTable = dummyTable;
55  }
56 
57  inline int ActiveFraction::findEtaBin( float eta) const {
58  int etaBin = 0;
59  for ( ; etaBin < (int)m_etaBins.size(); ++etaBin ) {
60  std::pair<float,float> theBin = m_etaBins.at(etaBin);
61  if ( eta > theBin.first && eta <= theBin.second ) break;
62  }
63  if ( etaBin == (int)m_etaBins.size() ) return -1;
64 
65  return etaBin;
66  }
67 
68  inline int ActiveFraction::findPhiBin( float phi) const {
69  int phiBin = 0;
70  for ( ; phiBin < (int)m_phiBins.size(); ++phiBin ) {
71  std::pair<float,float> theBin = m_phiBins.at(phiBin);
72  if ( phi > theBin.first && phi <= theBin.second ) break;
73  }
74  if ( phiBin == (int)m_phiBins.size() ) return-1;
75  return phiBin;
76  }
77 
78  inline float ActiveFraction::getActiveFraction( float eta, float phi ) const {
79 
80 
81  int etaBin = findEtaBin(eta);
82  if ( etaBin < 0 ) return 1.;
83  int phiBin = findPhiBin(phi);
84  if ( phiBin < 0 ) return 1.;
86  }
87  inline void ActiveFraction::setActiveFraction( unsigned int etaBin, unsigned int phiBin, float value) {
88 
90  }
91 
92  inline std::vector<std::pair<float,float>> ActiveFraction::getEtaBins( ) const {
93  return m_etaBins;
94  }
95 
96  inline std::vector<std::pair<float,float>> ActiveFraction::getPhiBins( ) const {
97  return m_phiBins;
98  }
99 
100 }
101 
103 CONDCONT_DEF(TRTCond::ActiveFraction,85974973);
104 #endif
TRTCond::ActiveFraction::getPhiBins
std::vector< std::pair< float, float > > getPhiBins() const
Definition: ActiveFraction.h:96
TRTCond::ActiveFraction::findPhiBin
int findPhiBin(float phi) const
Definition: ActiveFraction.h:68
CondCont.h
Hold mappings of ranges to condition objects.
phi
Scalar phi() const
phi method
Definition: AmgMatrixBasePlugin.h:64
eta
Scalar eta() const
pseudorapidity method
Definition: AmgMatrixBasePlugin.h:79
xAOD::deltaPhi
setSAddress setEtaMS setDirPhiMS setDirZMS setBarrelRadius setEndcapAlpha setEndcapRadius setInterceptInner setEtaMap setEtaBin setIsTgcFailure setDeltaPt deltaPhi
Definition: L2StandAloneMuon_v1.cxx:160
M_PI
#define M_PI
Definition: ActiveFraction.h:11
athena.value
value
Definition: athena.py:122
CONDCONT_DEF
CONDCONT_DEF(TRTCond::ActiveFraction, 85974973)
TRTCond::ActiveFraction::setActiveFraction
void setActiveFraction(unsigned int etaBin, unsigned int phiBin, float value)
Definition: ActiveFraction.h:87
TRTCond::ActiveFraction::m_etaBins
std::vector< std::pair< float, float > > m_etaBins
Definition: ActiveFraction.h:28
TRTCond::ActiveFraction::getEtaBins
std::vector< std::pair< float, float > > getEtaBins() const
Definition: ActiveFraction.h:92
xAOD::etaBin
setSAddress setEtaMS setDirPhiMS setDirZMS setBarrelRadius setEndcapAlpha setEndcapRadius setInterceptInner setEtaMap etaBin
Definition: L2StandAloneMuon_v1.cxx:148
lumiFormat.i
int i
Definition: lumiFormat.py:92
TRTCond::ActiveFraction::m_phiBins
std::vector< std::pair< float, float > > m_phiBins
Definition: ActiveFraction.h:29
TRTCond::ActiveFraction::ActiveFraction
ActiveFraction()
Definition: ActiveFraction.h:32
xAOD::phiBin
setSAddress setEtaMS setDirPhiMS setDirZMS setBarrelRadius setEndcapAlpha setEndcapRadius setPhiMap phiBin
Definition: L2StandAloneMuon_v2.cxx:144
TRTCond::ActiveFraction::m_nBinsPhi
int m_nBinsPhi
Definition: ActiveFraction.h:27
TRTCond::ActiveFraction::m_activeFracTable
std::vector< std::vector< float > > m_activeFracTable
Definition: ActiveFraction.h:30
TRTCond::ActiveFraction::getActiveFraction
float getActiveFraction(float eta, float phi) const
Definition: ActiveFraction.h:78
TRTCond
Definition: BasicRtRelation.cxx:8
readCCLHist.int
int
Definition: readCCLHist.py:84
TRTCond::ActiveFraction::findEtaBin
int findEtaBin(float eta) const
Definition: ActiveFraction.h:57
CLASS_DEF
#define CLASS_DEF(NAME, CID, VERSION)
associate a clid and a version to a type eg
Definition: Control/AthenaKernel/AthenaKernel/CLASS_DEF.h:64
CLASS_DEF.h
macros to associate a CLID to a type
TRTCond::ActiveFraction
Definition: ActiveFraction.h:15
TRTCond::ActiveFraction::~ActiveFraction
virtual ~ActiveFraction()
Definition: ActiveFraction.h:18