ATLAS Offline Software
CscRegUtils.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #ifndef TRIGL2MUONSA_CSCREGUTILS_H
6 #define TRIGL2MUONSA_CSCREGUTILS_H
7 
9 #include "GaudiKernel/Service.h"
10 #include "GaudiKernel/ToolHandle.h"
11 
13 
14 
15 #include <iostream>
16 #include <vector>
17 
18 
19 
20 namespace TrigL2MuonSA {
21 
22 class ReturnCode;
23 
24 
25 class UtilTools{
26 
27 public:
29 
30  double calc_theta(double eta) const{ return 2*std::atan(std::exp((-1)*eta)); }
31  double calc_theta(double x, double y, double z) const{ return std::acos(z/std::sqrt(x*x+y*y+z*z)); } // for position not for direction theta in [0,pi]
32  double calc_eta(double x, double y, double z) const {return (-1)*std::log(std::tan(calc_theta(x,y,z)/2.));}
33  double calc_phi( double x, double y) const;
34  double calc_dphi(double phi1, double phi2) const;
35  double calc_sumsq(double x, double y) const { return std::sqrt(x*x+y*y); }
36  double calc_sumsq(double x, double y, double z) const { return std::sqrt(x*x+y*y+z*z);}
37  double cotan(double theta) const { return std::tan(M_PI-theta); }
38  double relative_error(double measured, double reference) const {return (measured-reference)/reference; }
39  double average_phi(double phi1, double phi2) const;
40 
41 };
42 
43 
44 class CscRegDict: public AthAlgTool{
45 
46  public:
47 
48  // typedef TrigL2MuonSA::ReturnCode ReturnCode;
49 
50  typedef struct {
51  double etaMin;
52  double etaMax;
53  double phiMin;
54  double phiMax;
55  double phiCen;
56  double phiMod; //actual phi coordinates of center for data
57  double Displacement;
58  double idealAtanNormal; // surface on which segments will be defined
59  double actualAtanNormal;//surface of first wirelayer is defined by: n*x=a, where n=(cos(phiCen)sin(AtanNormal),sin(phiCen)sin(AtanNormal),cos(AtanNormal)); a=Displacement
62  } CscRegion;
63 
64  CscRegDict(const std::string &type, const std::string &name, const IInterface *parent);
65 
66  virtual StatusCode initialize() override;
67 
68  double phiCen(int module){ return m_reg_dict[module].phiCen; }
69  double phiMod(int module) const { return m_reg_dict[module].phiMod; }
70 
71  int get_hash(int stationname, int stationeta, int stationphi) const; //return a module context hashId.
72  Amg::Vector3D nomalVector(int module) const;
73  double displacement(int module) const;
74  double posCorrectionR(int module, int charge);
75  double posCorrectionZ(int module, int charge);
76  double idealAtanNormal(int module) const { return m_reg_dict[module].idealAtanNormal; }
77  double actualAtanNormal(int module) const { return m_reg_dict[module].actualAtanNormal; }
78  int stationName(int hash) const;
79  int stationEta(int hash) const;
80  int stationPhi(int hash) const;
81 
82  private:
83  Gaudi::Property< bool > m_isMC { this, "MCFlag", true, "" };
84  CscRegion m_reg_dict[32]{};//dictionary of CSC regions
85  int m_module_hashes[2][2][8]{};//dictionary of hashIds
86 
87 
91 
92  double PhiConv(double phi); //convert phi [0,2*pi)=>[-pi,pi)
93 
95 
96 };
97 
98 
99 inline double CscRegDict::displacement(int module) const
100 {
101  return (0<=module && module <32) ? m_reg_dict[module].Displacement : 0.;
102 }
103 
104 inline int CscRegDict::stationName(int hash) const
105 {
106  if(hash<0 || hash>31) return 999;
107  else return (hash<16) ? 50 : 51;
108 }
109 
110 inline int CscRegDict::stationEta(int hash) const
111 {
112  if(hash<0 || hash>31) return 999;
113  else{
114  int secteta=(hash - hash%8)/8;// secteta: 0(Small Cside),1(Small Aside), 2(Large Cside), 3(Large Aside)
115  return (secteta%2) ? 1 : -1;
116  }
117 }
118 
119 inline int CscRegDict::stationPhi(int hash) const
120 {
121  if(hash<0 || hash>31) return 999;
122  else return hash%8+1;
123 }
124 
125 
127 
128 public:
129  ReturnCode()=delete; //Forbid uninitialisation
130  ReturnCode(unsigned int retcode){m_retcode=retcode;}
131 
132  enum{
134  SUCCESS=1
135  };
136 
137  bool isSuccess(){return (m_retcode==SUCCESS);}
138 
139  void operator= (unsigned int retcode){m_retcode=retcode;}
140  bool operator== ( unsigned int code){return (m_retcode==code);}
141  bool operator!= ( unsigned int code){return (m_retcode!=code);}
142 
143 private:
144  unsigned int m_retcode;
145 
146 };
147 
148 
149 }//namespace TrigL2MuonSA
150 
151 #endif /* TRIGL2MUONSA_CSCREGUTILS_H */
TrigL2MuonSA::CscRegDict::m_module_hashes
int m_module_hashes[2][2][8]
Definition: CscRegUtils.h:85
TrigL2MuonSA::CscRegDict::phiCen
double phiCen(int module)
Definition: CscRegUtils.h:68
TrigL2MuonSA::CscRegDict::PhiConv
double PhiConv(double phi)
Definition: CscRegUtils.cxx:147
TrigL2MuonSA::CscRegDict::idealAtanNormal
double idealAtanNormal(int module) const
Definition: CscRegUtils.h:76
TrigL2MuonSA::CscRegDict::posCorrectionZ
double posCorrectionZ(int module, int charge)
Definition: CscRegUtils.cxx:194
TrigL2MuonSA::CscRegDict::displacement
double displacement(int module) const
Definition: CscRegUtils.h:99
TrigL2MuonSA::UtilTools::calc_eta
double calc_eta(double x, double y, double z) const
Definition: CscRegUtils.h:32
TrigL2MuonSA::ReturnCode::operator==
bool operator==(unsigned int code)
Definition: CscRegUtils.h:140
TrigL2MuonSA::CscRegDict::phiMod
double phiMod(int module) const
Definition: CscRegUtils.h:69
TrigL2MuonSA::UtilTools::relative_error
double relative_error(double measured, double reference) const
Definition: CscRegUtils.h:38
TrigL2MuonSA::ReturnCode::ReturnCode
ReturnCode(unsigned int retcode)
Definition: CscRegUtils.h:130
M_PI
#define M_PI
Definition: ActiveFraction.h:11
TrigL2MuonSA::CscRegDict::initializePosCorrectionParameters
ReturnCode initializePosCorrectionParameters()
Definition: CscRegUtils.cxx:274
TrigL2MuonSA::CscRegDict::m_isMC
Gaudi::Property< bool > m_isMC
Definition: CscRegUtils.h:83
TrigL2MuonSA::ReturnCode::m_retcode
unsigned int m_retcode
Definition: CscRegUtils.h:144
TrigL2MuonSA::CscRegDict::CscRegion::posCorrectionPlusR
double posCorrectionPlusR
Definition: CscRegUtils.h:60
TrigL2MuonSA::CscRegDict::CscRegion::phiCen
double phiCen
Definition: CscRegUtils.h:55
TrigL2MuonSA::UtilTools::calc_theta
double calc_theta(double x, double y, double z) const
Definition: CscRegUtils.h:31
reference
Definition: hcg.cxx:437
TrigL2MuonSA::CscRegDict::initializeDictionaryForData
ReturnCode initializeDictionaryForData()
Definition: CscRegUtils.cxx:267
drawFromPickle.exp
exp
Definition: drawFromPickle.py:36
TrigL2MuonSA::CscRegDict::initializeHashDictionary
ReturnCode initializeHashDictionary()
Definition: CscRegUtils.cxx:157
x
#define x
TrigL2MuonSA::ReturnCode::operator=
void operator=(unsigned int retcode)
Definition: CscRegUtils.h:139
TrigL2MuonSA::CscRegDict::CscRegion::etaMin
double etaMin
Definition: CscRegUtils.h:51
drawFromPickle.atan
atan
Definition: drawFromPickle.py:36
TrigL2MuonSA::CscRegDict::CscRegion::actualAtanNormal
double actualAtanNormal
Definition: CscRegUtils.h:59
TrigL2MuonSA::CscRegDict::stationName
int stationName(int hash) const
Definition: CscRegUtils.h:104
TrigL2MuonSA::UtilTools
Definition: CscRegUtils.h:25
TrigL2MuonSA::CscRegDict::initialize
virtual StatusCode initialize() override
Definition: CscRegUtils.cxx:23
TrigL2MuonSA::CscRegDict::CscRegion::Displacement
double Displacement
Definition: CscRegUtils.h:57
python.PyAthena.module
module
Definition: PyAthena.py:131
GeoPrimitives.h
TrigL2MuonSA::UtilTools::calc_dphi
double calc_dphi(double phi1, double phi2) const
Definition: CscRegUtils.cxx:229
histSizes.code
code
Definition: histSizes.py:129
TrigL2MuonSA::ReturnCode::isSuccess
bool isSuccess()
Definition: CscRegUtils.h:137
TrigL2MuonSA::UtilTools::calc_theta
double calc_theta(double eta) const
Definition: CscRegUtils.h:30
z
#define z
TrigL2MuonSA::CscRegDict::CscRegDict
CscRegDict(const std::string &type, const std::string &name, const IInterface *parent)
Definition: CscRegUtils.cxx:16
TrigL2MuonSA::ReturnCode::FAILURE
@ FAILURE
Definition: CscRegUtils.h:133
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
AthAlgTool.h
test_pyathena.parent
parent
Definition: test_pyathena.py:15
TrigL2MuonSA::UtilTools::calc_sumsq
double calc_sumsq(double x, double y) const
Definition: CscRegUtils.h:35
drawFromPickle.tan
tan
Definition: drawFromPickle.py:36
TrigL2MuonSA::CscRegDict::CscRegion::phiMod
double phiMod
Definition: CscRegUtils.h:56
TrigL2MuonSA::UtilTools::calc_phi
double calc_phi(double x, double y) const
Definition: CscRegUtils.cxx:207
TrigL2MuonSA::ReturnCode::operator!=
bool operator!=(unsigned int code)
Definition: CscRegUtils.h:141
TrigL2MuonSA::UtilTools::cotan
double cotan(double theta) const
Definition: CscRegUtils.h:37
TrigL2MuonSA::UtilTools::calc_sumsq
double calc_sumsq(double x, double y, double z) const
Definition: CscRegUtils.h:36
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
charge
double charge(const T &p)
Definition: AtlasPID.h:756
TrigL2MuonSA::CscRegDict::get_hash
int get_hash(int stationname, int stationeta, int stationphi) const
Definition: CscRegUtils.cxx:125
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
TrigL2MuonSA::CscRegDict::CscRegion::phiMin
double phiMin
Definition: CscRegUtils.h:53
TrigL2MuonSA::UtilTools::average_phi
double average_phi(double phi1, double phi2) const
Definition: CscRegUtils.cxx:243
TrigL2MuonSA::CscRegDict::CscRegion::phiMax
double phiMax
Definition: CscRegUtils.h:54
TrigL2MuonSA::CscRegDict::CscRegion
Definition: CscRegUtils.h:50
TrigL2MuonSA::CscRegDict::actualAtanNormal
double actualAtanNormal(int module) const
Definition: CscRegUtils.h:77
TrigL2MuonSA::ReturnCode
Definition: CscRegUtils.h:126
TrigL2MuonSA::ReturnCode::ReturnCode
ReturnCode()=delete
y
#define y
TrigL2MuonSA::CscRegDict::stationPhi
int stationPhi(int hash) const
Definition: CscRegUtils.h:119
CaloCondBlobAlgs_fillNoiseFromASCII.hash
dictionary hash
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:109
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
TrigL2MuonSA::UtilTools::UtilTools
UtilTools()
Definition: CscRegUtils.h:28
dq_make_web_display.reference
reference
Definition: dq_make_web_display.py:44
TrigL2MuonSA::CscRegDict::CscRegion::etaMax
double etaMax
Definition: CscRegUtils.h:52
python.CaloCondTools.log
log
Definition: CaloCondTools.py:20
TrigL2MuonSA::CscRegDict::stationEta
int stationEta(int hash) const
Definition: CscRegUtils.h:110
AthAlgTool
Definition: AthAlgTool.h:26
TrigL2MuonSA::CscRegDict::m_util
TrigL2MuonSA::UtilTools m_util
Definition: CscRegUtils.h:94
TrigL2MuonSA::CscRegDict::m_reg_dict
CscRegion m_reg_dict[32]
Definition: CscRegUtils.h:84
TrigL2MuonSA::ReturnCode::SUCCESS
@ SUCCESS
Definition: CscRegUtils.h:134
TrigL2MuonSA::CscRegDict::posCorrectionR
double posCorrectionR(int module, int charge)
Definition: CscRegUtils.cxx:185
TrigL2MuonSA::CscRegDict::nomalVector
Amg::Vector3D nomalVector(int module) const
Definition: CscRegUtils.cxx:174
TrigL2MuonSA::CscRegDict::CscRegion::idealAtanNormal
double idealAtanNormal
Definition: CscRegUtils.h:58
TrigL2MuonSA
Definition: AlignmentBarrelLUT.h:13
TrigL2MuonSA::CscRegDict::CscRegion::posCorrectionMinusR
double posCorrectionMinusR
Definition: CscRegUtils.h:61
TrigL2MuonSA::CscRegDict
Definition: CscRegUtils.h:44