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
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 163 of file AthMessaging.h.

164{
165 MsgStream* ms = m_msg_tls.get();
166 if (!ms) {
167 if (!m_initialized.test_and_set()) initMessaging();
168 ms = new MsgStream(m_imsg,m_nm);
169 m_msg_tls.reset( ms );
170 }
171
172 ms->setLevel (m_lvl);
173 return *ms;
174}
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 178 of file AthMessaging.h.

179{ 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 (m_lvl <= lvl) {
154 msg() << lvl;
155 return true;
156 } else {
157 return false;
158 }
159}

◆ 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 m_EtaPhi_CW[posR][posPHI][roi]=pT;
171 }
172 }
173 //-----Read EtaDtheta CW-----
174 if(cw_type==ReadCW_Type::EtaDtheta_CW){
175 for(size_t posDTHETA=0; posDTHETA<N_Dtheta; posDTHETA++){
176 cont >> word;
177 std::istringstream(word) >> std::hex >> pT;
178 auto & roiIndexedVector = m_EtaDtheta_CW[posR][posDTHETA];
179 if ((roi<0) or (static_cast<size_t>(roi)>=roiIndexedVector.size())){
180 throw std::out_of_range("roi outside of vector limits in TGCNSWCoincidenceMap::readMap");
181 }
182 roiIndexedVector[roi]=pT;
183 }
184 }
185 }
186
187 }
188 data.close();
189
190
191 return true;
192 }
#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 195 of file TGCNSWCoincidenceMap.cxx.

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

◆ 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 63 of file TGCNSWCoincidenceMap.h.

◆ 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
private

Definition at line 66 of file TGCNSWCoincidenceMap.h.

◆ m_sector

int LVL1TGCTrigger::TGCNSWCoincidenceMap::m_sector
private

Definition at line 65 of file TGCNSWCoincidenceMap.h.

◆ m_side

int LVL1TGCTrigger::TGCNSWCoincidenceMap::m_side
private

Definition at line 62 of file TGCNSWCoincidenceMap.h.

◆ m_tgcArgs

TGCArguments* LVL1TGCTrigger::TGCNSWCoincidenceMap::m_tgcArgs
private

Definition at line 68 of file TGCNSWCoincidenceMap.h.

◆ m_verName

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

Definition at line 61 of file TGCNSWCoincidenceMap.h.


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