ATLAS Offline Software
Loading...
Searching...
No Matches
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
20namespace TrigL2MuonSA {
21
22class ReturnCode;
23
24
26
27public:
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
44class 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
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
99inline double CscRegDict::displacement(int module) const
100{
101 return (0<=module && module <32) ? m_reg_dict[module].Displacement : 0.;
102}
103
104inline int CscRegDict::stationName(int hash) const
105{
106 if(hash<0 || hash>31) return 999;
107 else return (hash<16) ? 50 : 51;
108}
109
110inline 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
119inline 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
128public:
129 ReturnCode()=delete; //Forbid uninitialisation
130 ReturnCode(unsigned int retcode){m_retcode=retcode;}
131
132 enum{
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
143private:
144 unsigned int m_retcode;
145
146};
147
148
149}//namespace TrigL2MuonSA
150
151#endif /* TRIGL2MUONSA_CSCREGUTILS_H */
#define M_PI
Scalar eta() const
pseudorapidity method
Scalar phi() const
phi method
Scalar theta() const
theta method
double charge(const T &p)
Definition AtlasPID.h:997
#define y
#define x
#define z
AthAlgTool(const std::string &type, const std::string &name, const IInterface *parent)
Constructor with parameters:
int stationEta(int hash) const
Amg::Vector3D nomalVector(int module) const
ReturnCode initializeHashDictionary()
double idealAtanNormal(int module) const
Definition CscRegUtils.h:76
double PhiConv(double phi)
int get_hash(int stationname, int stationeta, int stationphi) const
TrigL2MuonSA::UtilTools m_util
Definition CscRegUtils.h:94
Gaudi::Property< bool > m_isMC
Definition CscRegUtils.h:83
CscRegDict(const std::string &type, const std::string &name, const IInterface *parent)
double phiCen(int module)
Definition CscRegUtils.h:68
double phiMod(int module) const
Definition CscRegUtils.h:69
int stationPhi(int hash) const
CscRegion m_reg_dict[32]
Definition CscRegUtils.h:84
double displacement(int module) const
Definition CscRegUtils.h:99
int m_module_hashes[2][2][8]
Definition CscRegUtils.h:85
double actualAtanNormal(int module) const
Definition CscRegUtils.h:77
int stationName(int hash) const
double posCorrectionR(int module, int charge)
ReturnCode initializePosCorrectionParameters()
ReturnCode initializeDictionaryForData()
double posCorrectionZ(int module, int charge)
virtual StatusCode initialize() override
bool operator!=(unsigned int code)
ReturnCode(unsigned int retcode)
void operator=(unsigned int retcode)
bool operator==(unsigned int code)
double calc_phi(double x, double y) const
double calc_sumsq(double x, double y, double z) const
Definition CscRegUtils.h:36
double relative_error(double measured, double reference) const
Definition CscRegUtils.h:38
double calc_theta(double x, double y, double z) const
Definition CscRegUtils.h:31
double average_phi(double phi1, double phi2) const
double calc_eta(double x, double y, double z) const
Definition CscRegUtils.h:32
double calc_theta(double eta) const
Definition CscRegUtils.h:30
double calc_dphi(double phi1, double phi2) const
double cotan(double theta) const
Definition CscRegUtils.h:37
double calc_sumsq(double x, double y) const
Definition CscRegUtils.h:35
Eigen::Matrix< double, 3, 1 > Vector3D