ATLAS Offline Software
Loading...
Searching...
No Matches
LVL1TGCTrigger::TGCNSWCoincidenceMap Class Reference

#include <TGCNSWCoincidenceMap.h>

Inheritance diagram for LVL1TGCTrigger::TGCNSWCoincidenceMap:
Collaboration diagram for LVL1TGCTrigger::TGCNSWCoincidenceMap:

Public Member Functions

 TGCNSWCoincidenceMap (TGCArguments *tgcargs, const std::string &version, int side, int oct, int mod)
 ~TGCNSWCoincidenceMap ()=default
bool isForward (int module)
int TGCNSW_pTcalcu_EtaPhi (const LVL1TGC::NSWTrigOut *nswOut, int RoI) const
int TGCNSW_pTcalcu_EtaDtheta (const LVL1TGC::NSWTrigOut *nswOut, int RoI) const
const std::string & getVersion () const
int getSideId () const
int getOctantId () const
 TGCNSWCoincidenceMap (const TGCNSWCoincidenceMap &right)
bool readMap (const std::string &moduleName, ReadCW_Type cw_type)
bool readShift ()
TGCArgumentstgcArgs ()
const TGCArgumentstgcArgs () const
bool msgLvl (const MSG::Level lvl) const
 Test the output level.
MsgStream & msg () const
 The standard message stream.
MsgStream & msg (const MSG::Level lvl) const
 The standard message stream.
void setLevel (MSG::Level lvl)
 Change the current logging level.

Private Types

enum  { N_dEta =64 , N_dPhi =16 , N_Dtheta =32 , N_PT_THRESH =15 }
enum  ReadCW_Type { EtaPhi_CW =0 , EtaDtheta_CW }

Private Member Functions

 TGCNSWCoincidenceMap ()=delete
void initMessaging () const
 Initialize our message level and MessageSvc.

Private Attributes

std::map< TGCRegionType, int > m_NumberOfEtaRaw = {{TGCRegionType::ENDCAP,37}, {TGCRegionType::FORWARD,16}}
std::map< TGCRegionType, int > m_NumberOfRoI = {{TGCRegionType::ENDCAP, LVL1TGC::kNumberOfEndcapRoI}, {TGCRegionType::FORWARD,64}}
std::vector< short int > m_EtaPhi_CW [N_dEta][N_dPhi]
std::vector< short int > m_EtaDtheta_CW [N_dEta][N_Dtheta]
std::vector< short int > m_Offset_Eta
std::vector< short int > m_Offset_Phi
std::string m_verName
int m_side {}
int m_octant {}
int m_module {}
int m_sector {}
TGCRegionType m_region {TGCRegionType::FORWARD}
TGCArgumentsm_tgcArgs {}
std::string m_nm
 Message source name.
boost::thread_specific_ptr< MsgStream > m_msg_tls
 MsgStream instance (a std::cout like with print-out levels)
std::atomic< IMessageSvc * > m_imsg { nullptr }
 MessageSvc pointer.
std::atomic< MSG::Level > m_lvl { MSG::NIL }
 Current logging level.
std::atomic_flag m_initialized ATLAS_THREAD_SAFE = ATOMIC_FLAG_INIT
 Messaging initialized (initMessaging)

Detailed Description

Definition at line 24 of file TGCNSWCoincidenceMap.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
private
Enumerator
N_dEta 
N_dPhi 
N_Dtheta 
N_PT_THRESH 

Definition at line 28 of file TGCNSWCoincidenceMap.h.

◆ ReadCW_Type

Constructor & Destructor Documentation

◆ TGCNSWCoincidenceMap() [1/3]

LVL1TGCTrigger::TGCNSWCoincidenceMap::TGCNSWCoincidenceMap ( )
privatedelete

◆ TGCNSWCoincidenceMap() [2/3]

LVL1TGCTrigger::TGCNSWCoincidenceMap::TGCNSWCoincidenceMap ( TGCArguments * tgcargs,
const std::string & version,
int side,
int oct,
int mod )

Definition at line 22 of file TGCNSWCoincidenceMap.cxx.

23 :AthMessaging("TGCNSWCoincidenceMap"),
24 m_verName(version),
25 m_side(side),
26 m_octant(oct),
27 m_module(mod),
28 m_tgcArgs(tgcargs)
29 {
30
31 setLevel(tgcArgs()->MSGLEVEL());
32
33 if(!tgcArgs()->USE_NSW()){return;}
34
35 std::string moduleName = std::to_string(mod);
36 if( isForward(mod)){
38 m_sector = m_module/3;
39 m_sector += 3*m_octant;
40 }
41 else{
43 m_sector = m_module%3 + 2*(m_module/3);
44 m_sector += 6*m_octant;
45 }
46
47
50
51 for(int dr=0;dr!=N_dEta;dr++){
52 for(int dphi=0;dphi!=N_dPhi;dphi++){
53 m_EtaPhi_CW[dr][dphi].resize(m_NumberOfRoI[m_region]);
54 std::fill(m_EtaPhi_CW[dr][dphi].begin(), m_EtaPhi_CW[dr][dphi].end(),0);
55 }
56 for(int dTheta=0;dTheta!=N_Dtheta;dTheta++){
58 std::fill(m_EtaDtheta_CW[dr][dTheta].begin(), m_EtaDtheta_CW[dr][dTheta].end(),0);
59 }
60 }
61
62 if( ( oct%2==0 && mod==5 ) || (oct%2==1 && (mod==2 || mod==8)) ){moduleName+="b";}
63 else{moduleName+="a";}
64
65
66 //---------Read out CW data---------
67 if(!this->readMap( moduleName, ReadCW_Type::EtaPhi_CW) ||
68 !this->readMap( moduleName, ReadCW_Type::EtaDtheta_CW)
69 ){
70 // NSW trigger flag is set to false when the map reading failed.
71 tgcArgs()->set_USE_NSW(false);
72 }
73
74 //---------Fill Shift data---------
75 if(!this->readShift()){
76 // NSW trigger flag is set to false when the map reading failed.
77 tgcArgs()->set_USE_NSW(false);
78 }
79
80 }
void setLevel(MSG::Level lvl)
Change the current logging level.
AthMessaging()
Default constructor:
std::vector< short int > m_EtaDtheta_CW[N_dEta][N_Dtheta]
std::map< TGCRegionType, int > m_NumberOfRoI
bool readMap(const std::string &moduleName, ReadCW_Type cw_type)
std::vector< short int > m_EtaPhi_CW[N_dEta][N_dPhi]

◆ ~TGCNSWCoincidenceMap()

LVL1TGCTrigger::TGCNSWCoincidenceMap::~TGCNSWCoincidenceMap ( )
default

◆ TGCNSWCoincidenceMap() [3/3]

LVL1TGCTrigger::TGCNSWCoincidenceMap::TGCNSWCoincidenceMap ( const TGCNSWCoincidenceMap & right)

Member Function Documentation

◆ getOctantId()

int LVL1TGCTrigger::TGCNSWCoincidenceMap::getOctantId ( ) const

◆ getSideId()

int LVL1TGCTrigger::TGCNSWCoincidenceMap::getSideId ( ) const

◆ getVersion()

const std::string & LVL1TGCTrigger::TGCNSWCoincidenceMap::getVersion ( ) const

◆ initMessaging()

void AthMessaging::initMessaging ( ) const
privateinherited

Initialize our message level and MessageSvc.

This method should only be called once.

Definition at line 39 of file AthMessaging.cxx.

40{
42 // If user did not set an explicit level, set a default
43 if (m_lvl == MSG::NIL) {
44 m_lvl = m_imsg ?
45 static_cast<MSG::Level>( m_imsg.load()->outputLevel(m_nm) ) :
46 MSG::INFO;
47 }
48}
std::string m_nm
Message source name.
std::atomic< IMessageSvc * > m_imsg
MessageSvc pointer.
std::atomic< MSG::Level > m_lvl
Current logging level.
IMessageSvc * getMessageSvc(bool quiet=false)

◆ isForward()

bool LVL1TGCTrigger::TGCNSWCoincidenceMap::isForward ( int module)

Definition at line 83 of file TGCNSWCoincidenceMap.cxx.

83 {
84 return ( mod==2 || mod==5 || mod==8 );
85 }

◆ msg() [1/2]

MsgStream & AthMessaging::msg ( ) const
inlineinherited

The standard message stream.

Returns a reference to the default message stream May not be invoked before sysInitialize() has been invoked.

Definition at line 167 of file AthMessaging.h.

168{
169 MsgStream* ms = m_msg_tls.get();
170 if (!ms) {
171 if (!m_initialized.test_and_set()) initMessaging();
172 ms = new MsgStream(m_imsg,m_nm);
173 m_msg_tls.reset( ms );
174 }
175
176 ms->setLevel (m_lvl);
177 return *ms;
178}
boost::thread_specific_ptr< MsgStream > m_msg_tls
MsgStream instance (a std::cout like with print-out levels)
void initMessaging() const
Initialize our message level and MessageSvc.

◆ msg() [2/2]

MsgStream & AthMessaging::msg ( const MSG::Level lvl) const
inlineinherited

The standard message stream.

Returns a reference to the default message stream May not be invoked before sysInitialize() has been invoked.

Definition at line 182 of file AthMessaging.h.

183{ return msg() << lvl; }
MsgStream & msg() const
The standard message stream.

◆ msgLvl()

bool AthMessaging::msgLvl ( const MSG::Level lvl) const
inlineinherited

Test the output level.

Parameters
lvlThe message level to test against
Returns
boolean Indicating if messages at given level will be printed
Return values
trueMessages at level "lvl" will be printed

Definition at line 151 of file AthMessaging.h.

152{
153 // If user did not set explicit message level we have to initialize
154 // the messaging and retrieve the default via the MessageSvc.
155 if (m_lvl==MSG::NIL && !m_initialized.test_and_set()) initMessaging();
156
157 if (m_lvl <= lvl) {
158 msg() << lvl;
159 return true;
160 } else {
161 return false;
162 }
163}

◆ readMap()

bool LVL1TGCTrigger::TGCNSWCoincidenceMap::readMap ( const std::string & moduleName,
ReadCW_Type cw_type )

Definition at line 129 of file TGCNSWCoincidenceMap.cxx.

130 {
131 std::string kSide[2] = {"a", "c"};
132 std::string kCWtype[2] = {"EtaPhi","EtaDtheta"};
133
134 std::string dbname="";
135
136 dbname = "/NSW/cm_" + kSide[m_side] + moduleName +kCWtype[cw_type]+"_Octant_"+m_verName+".db";
137 std::string fullName = PathResolver::FindCalibDirectory("dev")+"/TrigT1TGC"+dbname;
138
139 std::ifstream data(fullName);
140 if(!data.is_open()){
141 ATH_MSG_WARNING("Cannot open file dev/TrigT1TGC" << dbname);
142 return false;
143 }
144 char delimiter = '\n';
145 std::string field;
146 std::string tag;
147
148 while (std::getline(data, field, delimiter)) {
149 int roi=-1;
150 unsigned int n_Etabit=0;
151 unsigned int n_Phibit=0;
152 std::istringstream header(field);
153 header >> tag;
154 if(tag=="#"){ // read header part.
155 header >> roi >> n_Etabit >> n_Phibit;
156 }
157 // get trigger word
158 std::string word;
159 unsigned int pT=0;
160
162 for(size_t posR=0; posR<N_dEta ; posR++){
163 std::getline(data, field, delimiter);
164 std::istringstream cont(field);
165 //----Read EtaPhi CW---------
166 if(cw_type==ReadCW_Type::EtaPhi_CW){
167 for(size_t posPHI=0; posPHI<N_dPhi; posPHI++){
168 cont >> word;
169 std::istringstream(word) >> std::hex >> pT;
170 //values should be checked against sensible limits; do minimal check here:
171 if (roi<0) continue;
172 //coverity[TAINTED_SCALAR]
173 m_EtaPhi_CW[posR][posPHI][roi]=pT;
174 }
175 }
176 //-----Read EtaDtheta CW-----
177 if(cw_type==ReadCW_Type::EtaDtheta_CW){
178 for(size_t posDTHETA=0; posDTHETA<N_Dtheta; posDTHETA++){
179 cont >> word;
180 std::istringstream(word) >> std::hex >> pT;
181 auto & roiIndexedVector = m_EtaDtheta_CW[posR][posDTHETA];
182 if ((roi<0) or (static_cast<size_t>(roi)>=roiIndexedVector.size())){
183 throw std::out_of_range("roi outside of vector limits in TGCNSWCoincidenceMap::readMap");
184 }
185 roiIndexedVector[roi]=pT;
186 }
187 }
188 }
189 }
190 data.close();
191
192
193 return true;
194 }
#define ATH_MSG_WARNING(x)
char data[hepevt_bytes_allocation_ATLAS]
Definition HepEvt.cxx:11
static std::string FindCalibDirectory(const std::string &logical_file_name)

◆ readShift()

bool LVL1TGCTrigger::TGCNSWCoincidenceMap::readShift ( )

Definition at line 197 of file TGCNSWCoincidenceMap.cxx.

197 {
198
199 char delimiter = '\n';
200 std::string field;
201 std::string tag;
202 int side;
203 int triggerSector;
204
205 //------- Read Endcap Shift
206 std::string dbname="/NSW/";
207
208 if(m_region==TGCRegionType::ENDCAP){dbname += "RoIpos_Endcap.db";}
209 if(m_region==TGCRegionType::FORWARD){dbname += "RoIpos_Forward.db";}
210 std::string fullName = PathResolver::FindCalibDirectory("dev")+"/TrigT1TGC"+dbname;
211
212 std::ifstream data(fullName);
213 if(!data.is_open()){return false;}
214 while (std::getline(data, field, delimiter)) {
215 std::istringstream header(field);
216 header >> tag;
217 if(tag=="#"){ // read header part.
218 header >> side >> triggerSector ;
219 }
220
221 // get trigger word
222 std::getline(data, field, delimiter);
223 std::istringstream cont(field);
224 std::string word;
225 int shift=0;
226 std::array<int, 4> phi_shift {};
227 std::array<int, 37> eta_shift {};
228
229 if(side!=m_side || triggerSector!=m_sector){ continue; }
230 for(int phiN=0; phiN!=4; phiN++){
231 cont >> word;
232 std::istringstream(word) >> shift;
233 phi_shift[phiN]=shift;
234 }
235 for(int etaN=0; etaN!=m_NumberOfEtaRaw[m_region]; etaN++){
236 cont >> word;
237 std::istringstream(word) >> shift;
238 eta_shift[etaN]=shift;
239 }
240 for(int roi=0;roi!=m_NumberOfRoI[m_region];roi++){
241 m_Offset_Eta[roi]=eta_shift[roi/4]+N_dEta/2;
242 m_Offset_Phi[roi]=phi_shift[roi%4]+N_dPhi/2;
243 }
244
245 break;
246 }
247 data.close();
248
249 return true;
250 }
std::map< TGCRegionType, int > m_NumberOfEtaRaw

◆ setLevel()

void AthMessaging::setLevel ( MSG::Level lvl)
inherited

Change the current logging level.

Use this rather than msg().setLevel() for proper operation with MT.

Definition at line 28 of file AthMessaging.cxx.

29{
30 m_lvl = lvl;
31}

◆ tgcArgs() [1/2]

TGCArguments * LVL1TGCTrigger::TGCNSWCoincidenceMap::tgcArgs ( )
inline

Definition at line 51 of file TGCNSWCoincidenceMap.h.

51{ return m_tgcArgs;}

◆ tgcArgs() [2/2]

const TGCArguments * LVL1TGCTrigger::TGCNSWCoincidenceMap::tgcArgs ( ) const
inline

Definition at line 52 of file TGCNSWCoincidenceMap.h.

52{ return m_tgcArgs;}

◆ TGCNSW_pTcalcu_EtaDtheta()

int LVL1TGCTrigger::TGCNSWCoincidenceMap::TGCNSW_pTcalcu_EtaDtheta ( const LVL1TGC::NSWTrigOut * nswOut,
int RoI ) const

just for now. before we finalize the strategy, we always return the lowest pT value if we can find the NSW hit

Definition at line 110 of file TGCNSWCoincidenceMap.cxx.

111 {
112 std::vector<uint8_t> nswEta_vec=nswOut->getNSWeta();
113 std::vector<uint8_t> nswDtheta_vec=nswOut->getNSWDtheta();
114 int highest_pT=0;
115
116 for(unsigned int nswTrk_id=0;nswTrk_id!=nswEta_vec.size();nswTrk_id++){
117 int eta_decode=m_Offset_Eta[roi]-nswEta_vec[nswTrk_id];
118 int dTheta_decode=nswDtheta_vec[nswTrk_id];
119 if(eta_decode<0 || eta_decode>=N_dEta){continue;}
120 if(highest_pT<m_EtaDtheta_CW[eta_decode][dTheta_decode][roi]){
121 highest_pT=m_EtaDtheta_CW[eta_decode][dTheta_decode][roi];
122 }
123 }
124
125 return 1;
126 }
const std::vector< uint8_t > & getNSWDtheta() const
Definition NSWTrigOut.h:68
const std::vector< uint8_t > & getNSWeta() const
Definition NSWTrigOut.h:66

◆ TGCNSW_pTcalcu_EtaPhi()

int LVL1TGCTrigger::TGCNSWCoincidenceMap::TGCNSW_pTcalcu_EtaPhi ( const LVL1TGC::NSWTrigOut * nswOut,
int RoI ) const

just for now. before we finalize the strategy, we always return the lowest pT value if we can find the NSW hit

Definition at line 88 of file TGCNSWCoincidenceMap.cxx.

89 {
90 std::vector<uint8_t> nswEta_vec=nswOut->getNSWeta();
91 std::vector<uint8_t> nswPhi_vec=nswOut->getNSWphi();
92 int highest_pT=0;
93
94 for(unsigned int nswTrk_id=0;nswTrk_id!=nswEta_vec.size();nswTrk_id++){
95 int eta_decode=m_Offset_Eta[roi]-nswEta_vec[nswTrk_id];
96 int phi_decode=m_Offset_Phi[roi]-nswPhi_vec[nswTrk_id];
97 if(eta_decode<0 || eta_decode>=N_dEta){continue;}
98 if(phi_decode<0 || phi_decode>=N_dPhi){continue;}
99
100 if(highest_pT<m_EtaPhi_CW[eta_decode][phi_decode][roi]){
101 highest_pT=m_EtaPhi_CW[eta_decode][phi_decode][roi];
102 }
103 }
104
105 return 1;
106 }
const std::vector< uint8_t > & getNSWphi() const
Definition NSWTrigOut.h:67

Member Data Documentation

◆ ATLAS_THREAD_SAFE

std::atomic_flag m_initialized AthMessaging::ATLAS_THREAD_SAFE = ATOMIC_FLAG_INIT
mutableprivateinherited

Messaging initialized (initMessaging)

Definition at line 141 of file AthMessaging.h.

◆ m_EtaDtheta_CW

std::vector<short int> LVL1TGCTrigger::TGCNSWCoincidenceMap::m_EtaDtheta_CW[N_dEta][N_Dtheta]
private

Definition at line 56 of file TGCNSWCoincidenceMap.h.

◆ m_EtaPhi_CW

std::vector<short int> LVL1TGCTrigger::TGCNSWCoincidenceMap::m_EtaPhi_CW[N_dEta][N_dPhi]
private

Definition at line 55 of file TGCNSWCoincidenceMap.h.

◆ m_imsg

std::atomic<IMessageSvc*> AthMessaging::m_imsg { nullptr }
mutableprivateinherited

MessageSvc pointer.

Definition at line 135 of file AthMessaging.h.

135{ nullptr };

◆ m_lvl

std::atomic<MSG::Level> AthMessaging::m_lvl { MSG::NIL }
mutableprivateinherited

Current logging level.

Definition at line 138 of file AthMessaging.h.

138{ MSG::NIL };

◆ m_module

int LVL1TGCTrigger::TGCNSWCoincidenceMap::m_module {}
private

Definition at line 63 of file TGCNSWCoincidenceMap.h.

63{};

◆ m_msg_tls

boost::thread_specific_ptr<MsgStream> AthMessaging::m_msg_tls
mutableprivateinherited

MsgStream instance (a std::cout like with print-out levels)

Definition at line 132 of file AthMessaging.h.

◆ m_nm

std::string AthMessaging::m_nm
privateinherited

Message source name.

Definition at line 129 of file AthMessaging.h.

◆ m_NumberOfEtaRaw

std::map<TGCRegionType,int> LVL1TGCTrigger::TGCNSWCoincidenceMap::m_NumberOfEtaRaw = {{TGCRegionType::ENDCAP,37}, {TGCRegionType::FORWARD,16}}
private

Definition at line 30 of file TGCNSWCoincidenceMap.h.

◆ m_NumberOfRoI

std::map<TGCRegionType,int> LVL1TGCTrigger::TGCNSWCoincidenceMap::m_NumberOfRoI = {{TGCRegionType::ENDCAP, LVL1TGC::kNumberOfEndcapRoI}, {TGCRegionType::FORWARD,64}}
private

Definition at line 31 of file TGCNSWCoincidenceMap.h.

static constexpr unsigned int kNumberOfEndcapRoI
The number of ROIs in a endcap trigger sector.

◆ m_octant

int LVL1TGCTrigger::TGCNSWCoincidenceMap::m_octant {}
private

Definition at line 62 of file TGCNSWCoincidenceMap.h.

62{};

◆ m_Offset_Eta

std::vector<short int> LVL1TGCTrigger::TGCNSWCoincidenceMap::m_Offset_Eta
private

Definition at line 57 of file TGCNSWCoincidenceMap.h.

◆ m_Offset_Phi

std::vector<short int> LVL1TGCTrigger::TGCNSWCoincidenceMap::m_Offset_Phi
private

Definition at line 58 of file TGCNSWCoincidenceMap.h.

◆ m_region

TGCRegionType LVL1TGCTrigger::TGCNSWCoincidenceMap::m_region {TGCRegionType::FORWARD}
private

Definition at line 65 of file TGCNSWCoincidenceMap.h.

◆ m_sector

int LVL1TGCTrigger::TGCNSWCoincidenceMap::m_sector {}
private

Definition at line 64 of file TGCNSWCoincidenceMap.h.

64{};

◆ m_side

int LVL1TGCTrigger::TGCNSWCoincidenceMap::m_side {}
private

Definition at line 61 of file TGCNSWCoincidenceMap.h.

61{};

◆ m_tgcArgs

TGCArguments* LVL1TGCTrigger::TGCNSWCoincidenceMap::m_tgcArgs {}
private

Definition at line 67 of file TGCNSWCoincidenceMap.h.

67{};

◆ m_verName

std::string LVL1TGCTrigger::TGCNSWCoincidenceMap::m_verName
private

Definition at line 60 of file TGCNSWCoincidenceMap.h.


The documentation for this class was generated from the following files: