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
10#include <cmath>
11#include <vector>
12
13#ifndef M_PI
14#define M_PI 3.141592653589793238462643383279502884197
15#endif
16namespace TRTCond{
17 // eta,phi binned map of the active straw fraction
19 public:
21 virtual ~ActiveFraction(){};
22 int findEtaBin( float eta ) const;
23 int findPhiBin( float phi ) const;
24 float getActiveFraction( float eta, float phi ) const;
25 const std::vector<std::pair<float,float>>& getEtaBins( ) const;
26 const std::vector<std::pair<float,float>>& getPhiBins( ) const;
27 void setActiveFraction( unsigned int etaBin, unsigned int phiBin, float value);
28
29 private:
31 std::vector<std::pair<float,float> > m_etaBins;
32 std::vector<std::pair<float,float> > m_phiBins;
33 std::vector<std::vector<float> > m_activeFracTable; // [etaBin,phiBin]
34 };
36 m_nBinsPhi=96;
37 m_etaBins.emplace_back( -2.1,-1.75);
38 m_etaBins.emplace_back( -1.75,-1.3 );
39 m_etaBins.emplace_back( -1.3,-1.07 );
40 m_etaBins.emplace_back( -1.07,-0.65 );
41 m_etaBins.emplace_back( -0.65,-0.1 );
42 m_etaBins.emplace_back( -0.1,0. );
43 m_etaBins.emplace_back( 0.,0.1 );
44 m_etaBins.emplace_back( 0.1,0.65 );
45 m_etaBins.emplace_back( 0.65,1.07 );
46 m_etaBins.emplace_back( 1.07,1.3 );
47 m_etaBins.emplace_back( 1.3,1.75 );
48 m_etaBins.emplace_back( 1.75,2.1 );
49 float phiEdgeLow = -1. * M_PI;
50 float deltaPhi = 2. * M_PI / (1. * m_nBinsPhi) ;
51 for ( int i = 0; i < m_nBinsPhi; ++i ) {
52 m_phiBins.push_back( std::make_pair( phiEdgeLow + i*deltaPhi, phiEdgeLow + (i+1)*deltaPhi ) );
53 }
54 // Initialize the table with 1.'s
55 std::vector<float> dummyPhiVec( m_phiBins.size(), 1. );
56 std::vector<std::vector<float> > dummyTable( m_etaBins.size(), dummyPhiVec );
57 m_activeFracTable = std::move(dummyTable);
58 }
59
60 inline int ActiveFraction::findEtaBin( float eta) const {
61 int etaBin = 0;
62 for ( ; etaBin < (int)m_etaBins.size(); ++etaBin ) {
63 std::pair<float,float> theBin = m_etaBins.at(etaBin);
64 if ( eta > theBin.first && eta <= theBin.second ) break;
65 }
66 if ( etaBin == (int)m_etaBins.size() ) return -1;
67
68 return etaBin;
69 }
70
71 inline int ActiveFraction::findPhiBin( float phi) const {
72 int phiBin = 0;
73 for ( ; phiBin < (int)m_phiBins.size(); ++phiBin ) {
74 std::pair<float,float> theBin = m_phiBins.at(phiBin);
75 if ( phi > theBin.first && phi <= theBin.second ) break;
76 }
77 if ( phiBin == (int)m_phiBins.size() ) return-1;
78 return phiBin;
79 }
80
81 inline float ActiveFraction::getActiveFraction( float eta, float phi ) const {
82
83
84 int etaBin = findEtaBin(eta);
85 if ( etaBin < 0 ) return 1.;
86 int phiBin = findPhiBin(phi);
87 if ( phiBin < 0 ) return 1.;
88 return m_activeFracTable[etaBin][phiBin];
89 }
90 inline void ActiveFraction::setActiveFraction( unsigned int etaBin, unsigned int phiBin, float value) {
91
92 m_activeFracTable[etaBin][phiBin] = value;
93 }
94
95 inline const std::vector<std::pair<float,float>>& ActiveFraction::getEtaBins( ) const {
96 return m_etaBins;
97 }
98
99 inline const std::vector<std::pair<float,float>>& ActiveFraction::getPhiBins( ) const {
100 return m_phiBins;
101 }
102
103}
104
106CONDCONT_DEF(TRTCond::ActiveFraction,85974973);
107#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