ATLAS Offline Software
Loading...
Searching...
No Matches
ActiveFraction.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2024 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
13namespace 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 const std::vector<std::pair<float,float>>& getEtaBins( ) const;
23 const 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.;
85 return m_activeFracTable[etaBin][phiBin];
86 }
87 inline void ActiveFraction::setActiveFraction( unsigned int etaBin, unsigned int phiBin, float value) {
88
89 m_activeFracTable[etaBin][phiBin] = value;
90 }
91
92 inline const std::vector<std::pair<float,float>>& ActiveFraction::getEtaBins( ) const {
93 return m_etaBins;
94 }
95
96 inline const std::vector<std::pair<float,float>>& ActiveFraction::getPhiBins( ) const {
97 return m_phiBins;
98 }
99
100}
101
103CONDCONT_DEF(TRTCond::ActiveFraction,85974973);
104#endif
#define M_PI
Scalar eta() const
pseudorapidity method
Scalar deltaPhi(const MatrixBase< Derived > &vec) const
Scalar phi() const
phi method
Hold mappings of ranges to condition objects.
#define CONDCONT_DEF(...)
Definition CondCont.h:1413
macros to associate a CLID to a type
#define CLASS_DEF(NAME, CID, VERSION)
associate a clid and a version to a type eg
std::vector< std::pair< float, float > > m_phiBins
float getActiveFraction(float eta, float phi) const
int findEtaBin(float eta) const
const std::vector< std::pair< float, float > > & getEtaBins() const
std::vector< std::vector< float > > m_activeFracTable
int findPhiBin(float phi) const
std::vector< std::pair< float, float > > m_etaBins
void setActiveFraction(unsigned int etaBin, unsigned int phiBin, float value)
const std::vector< std::pair< float, float > > & getPhiBins() const