ATLAS Offline Software
TGCTileMuCoincidenceLUT.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 
9 
10 #include <fstream>
11 
12 namespace LVL1TGC {
13 
15  const SG::ReadCondHandleKey<TGCTriggerData>& readCondKey,
16  const std::string& version)
17  : m_verName(version),
18  m_tgcArgs(tgcargs),
19  m_readCondKey(readCondKey)
20 {
21  if (!tgcArgs()->TILE_MU()) return;
22  if (tgcArgs()->USE_CONDDB()) return;
23 
24  MsgStream log(Athena::getMessageSvc(), "LVL1TGC::TGCTileMuCoincidenceLUT");
25 
26  // read Inner Coincidence Map
27  if (this->readMap()) {
28  log << MSG::INFO
29  << " TGC TileMu CW version of " << m_verName << " is selected " << endmsg;
30  } else {
31  log << MSG::INFO
32  << " NOT use TileMu " << endmsg;
33  m_flagpt.clear();
34  m_flagroi.clear();
35  m_trigbit.clear();
36  }
37 }
38 
39 
41 {
42 }
43 
45 {
46  MsgStream log(Athena::getMessageSvc(), "LVL1TGC::TGCTileMuCoincidenceLUT");
47 
48  // select right database according to a set of thresholds
49  std::string dbname="";
50  dbname = "TileMuCoincidenceMap." + m_verName + "._12.db";
51 
52  //-----
53 
54  std::string fullName;
55  fullName = PathResolver::FindCalibDirectory("dev")+"/TrigT1TGC/TILE/"+dbname;
56  bool isFound =( fullName.length() > 0 );
57  if( !isFound) {
58  log << MSG::WARNING
59  << " Could not found " << dbname << endmsg;
60  return false ;
61  }
62 
63  std::ifstream file(fullName.c_str(),std::ios::in);
64 
65  static constexpr unsigned int BufferSize = 256;
66  char buf[BufferSize];
67 
68  while (file.getline(buf, BufferSize)) {
69 
70  int16_t sideId = -1;
71  int16_t sectorId = -1;
72  int16_t sscId = -1;
73 
74  std::istringstream header(buf);
75  std::string tag;
76  header >> tag;
77  if(tag == "#") {
78  header >> sideId >> sectorId >> sscId;
79  }
80 
81  // check Id
82  if(sideId < 0 || sideId>=TGCTriggerData::N_SIDE ||
83  sectorId < 0 || sectorId>=TGCTriggerData::N_ENDCAP_SECTOR ||
84  sscId < 0 || sscId>=TGCTriggerData::N_ENDCAP_SSC ) {
85  log << MSG::WARNING
86  << " illegal parameter in database header : " << header.str()
87  << " in file " << dbname
88  << endmsg;
89  file.close();
90  return false;
91  }
92 
93  uint16_t addr = this->getAddr(sideId, sectorId, sscId);
94 
95  uint8_t flagpt = 0;
96  for (size_t pt = 0; pt < TGCTriggerData::N_PT_THRESH; pt++){
97  uint8_t use;
98  header >> use;
99  flagpt |= (use&0x1)<<pt;
100  }
101  m_flagpt[addr] = flagpt;
102 
103  uint8_t roi = 0;
104  for (size_t pos=0; pos< TGCTriggerData::N_ROI_IN_SSC; pos++){
105  uint8_t use;
106  header >> use;
107  roi |= (use&0x1)<<pos;
108  }
109  m_flagroi[addr] = roi;
110 
111  // get trigger word
112  file.getline(buf,BufferSize);
113  std::istringstream cont(buf);
114  uint16_t trigbit = 0x0;
115  for(size_t pos=0; pos < TGCTriggerData::N_TILE_INPUT; pos++){
116  uint16_t word;
117  cont >> word;
118  trigbit |= (word & 0xf)<<(pos*4);
119  }
120  m_trigbit[addr] = trigbit;
121 
122  }
123  file.close();
124 
125  return true;
126 }
127 
128 
130  const int16_t ssc,
131  const int16_t sec,
132  const int16_t side) const
133 {
134  if ((module<0)||(module>=TGCTriggerData::N_TILE_INPUT)) return TM_NA;
135 
136  uint16_t mask = 0x0;
137  if (tgcArgs()->USE_CONDDB()) {
139  const TGCTriggerData* readCdo{*readHandle};
140  mask = readCdo->getTrigMaskTile(ssc, sec, side);
141  } else {
142  uint16_t addr = this->getAddr(side, sec, ssc);
143  std::unordered_map<uint16_t, uint16_t>::const_iterator it = m_trigbit.find(addr);
144  if(it != m_trigbit.end()) mask = it->second;
145  }
146 
147  return mask>>(module*4) & 0x7;
148 }
149 
151  const int16_t ssc,
152  const int16_t sec,
153  const int16_t side) const
154 {
155  if ((pt<=0)||(pt>TGCTriggerData::N_PT_THRESH)) return -1;
156 
157  uint8_t ptmask = 0x0;
158  if (tgcArgs()->USE_CONDDB()) {
160  const TGCTriggerData* readCdo{*readHandle};
161  ptmask = readCdo->getFlagPtTile(ssc, sec, side);
162  } else {
163  uint16_t addr = this->getAddr(side, sec, ssc);
164  std::unordered_map<uint16_t, uint8_t>::const_iterator it = m_flagpt.find(addr);
165  if(it != m_flagpt.end()) ptmask = it->second;
166  }
167  return (ptmask>>(pt-1)) & 0x1; /* only 1st bit needed (0x1) */
168 }
169 
171  const int16_t ssc,
172  const int16_t sec,
173  const int16_t side) const
174 {
175  if ((roi<0)||(roi>=TGCTriggerData::N_ROI_IN_SSC)) return -1;
176 
177  uint8_t roimask = 0x0;
178  if (tgcArgs()->USE_CONDDB()) {
180  const TGCTriggerData* readCdo{*readHandle};
181  roimask = readCdo->getFlagRoiTile(ssc, sec, side);
182  } else {
183  uint16_t addr = this->getAddr(side, sec, ssc);
184  std::unordered_map<uint16_t, uint8_t>::const_iterator it = m_flagroi.find(addr);
185  if(it != m_flagroi.end()) roimask = it->second;
186  }
187  return (roimask >> roi) & 0x1; /* only 1st bit needed (0x1) */
188 }
189 
191 {
194  (ssc & TGCTriggerData::SSC_MASK);
195 }
196 
197 
198 } //end of namespace bracket
CaloNoise_fillDB.dbname
dbname
Definition: CaloNoise_fillDB.py:43
TGCTriggerData::SECTOR_MASK
static constexpr uint8_t SECTOR_MASK
Mask for trigger sector for the (EIFI/TILE) ADDR.
Definition: TGCTriggerData.h:150
TGCTriggerData::N_TILE_INPUT
@ N_TILE_INPUT
Definition: TGCTriggerData.h:171
StateLessPT_NewConfig.BufferSize
BufferSize
Definition: StateLessPT_NewConfig.py:370
header
Definition: hcg.cxx:526
LVL1TGC::TGCTileMuCoincidenceLUT::m_trigbit
std::unordered_map< uint16_t, uint16_t > m_trigbit
Definition: TGCTileMuCoincidenceLUT.h:97
TGCTriggerData::ADDR_SECTOR_SHIFT
static constexpr uint8_t ADDR_SECTOR_SHIFT
Bit position of the trigger sector bit in the (EIFI/TILE) ADDR.
Definition: TGCTriggerData.h:156
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
getMessageSvc.h
singleton-like access to IMessageSvc via open function and helper
xAOD::uint8_t
uint8_t
Definition: Muon_v1.cxx:557
LVL1TGC::TGCTileMuCoincidenceLUT::getTrigMask
int getTrigMask(const int module, const int16_t ssc, const int16_t sec, const int16_t side) const
Definition: TGCTileMuCoincidenceLUT.cxx:129
LVL1TGC::TGCTileMuCoincidenceLUT::tgcArgs
LVL1TGCTrigger::TGCArguments * tgcArgs()
Definition: TGCTileMuCoincidenceLUT.h:91
WriteCellNoiseToCool.fullName
fullName
Definition: WriteCellNoiseToCool.py:461
skel.it
it
Definition: skel.GENtoEVGEN.py:396
LVL1TGC::TGCTileMuCoincidenceLUT::m_verName
std::string m_verName
Definition: TGCTileMuCoincidenceLUT.h:99
test_pyathena.pt
pt
Definition: test_pyathena.py:11
LVL1TGC::TGCTileMuCoincidenceLUT::TGCTileMuCoincidenceLUT
TGCTileMuCoincidenceLUT(LVL1TGCTrigger::TGCArguments *, const SG::ReadCondHandleKey< TGCTriggerData > &readCondKey, const std::string &version="NA")
Definition: TGCTileMuCoincidenceLUT.cxx:14
TGCTriggerData::ADDR_SIDE_SHIFT
static constexpr uint8_t ADDR_SIDE_SHIFT
Bit position of the side bit in the (EIFI/TILE) ADDR.
Definition: TGCTriggerData.h:154
LVL1TGC::TGCTileMuCoincidenceLUT::getFlagPT
int getFlagPT(const int pt, const int16_t ssc, const int16_t sec, const int16_t side) const
Definition: TGCTileMuCoincidenceLUT.cxx:150
PathResolver::FindCalibDirectory
static std::string FindCalibDirectory(const std::string &logical_file_name)
Definition: PathResolver.h:109
xAOD::int16_t
setScaleOne setStatusOne setSaturated int16_t
Definition: gFexGlobalRoI_v1.cxx:55
Athena::getMessageSvc
IMessageSvc * getMessageSvc(bool quiet=false)
Definition: getMessageSvc.cxx:20
python.utils.AtlRunQueryLookup.mask
string mask
Definition: AtlRunQueryLookup.py:460
TRT::Hit::side
@ side
Definition: HitInfo.h:83
python.PyAthena.module
module
Definition: PyAthena.py:131
TGCTriggerData::N_SIDE
@ N_SIDE
Definition: TGCTriggerData.h:162
TGCTriggerData::SSC_MASK
static constexpr uint8_t SSC_MASK
Mask for SSC for the (EIFI/TILE) ADDR.
Definition: TGCTriggerData.h:152
LVL1TGC::TGCTileMuCoincidenceLUT::getAddr
uint16_t getAddr(int16_t side, int16_t sec, int16_t ssc) const
Definition: TGCTileMuCoincidenceLUT.cxx:190
xAOD::uint16_t
setWord1 uint16_t
Definition: eFexEMRoI_v1.cxx:93
LVL1TGC::TGCTileMuCoincidenceLUT::readMap
bool readMap()
Definition: TGCTileMuCoincidenceLUT.cxx:44
TGCTriggerData::getFlagRoiTile
uint8_t getFlagRoiTile(int ssc, int sectorId, int side) const
Definition: TGCTriggerData.cxx:97
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
LVL1TGC::TGCTileMuCoincidenceLUT::m_readCondKey
const SG::ReadCondHandleKey< TGCTriggerData > & m_readCondKey
Definition: TGCTileMuCoincidenceLUT.h:101
LVL1TGC
Definition: BigWheelCoincidenceLUT.cxx:20
LVL1TGC::TGCTileMuCoincidenceLUT::~TGCTileMuCoincidenceLUT
virtual ~TGCTileMuCoincidenceLUT()
Definition: TGCTileMuCoincidenceLUT.cxx:40
file
TFile * file
Definition: tile_monitor.h:29
LVL1TGC::TGCTileMuCoincidenceLUT::m_flagpt
std::unordered_map< uint16_t, uint8_t > m_flagpt
Definition: TGCTileMuCoincidenceLUT.h:95
PathResolver.h
TGCTriggerData::N_ENDCAP_SECTOR
@ N_ENDCAP_SECTOR
Definition: TGCTriggerData.h:165
TGCTriggerData::N_ROI_IN_SSC
@ N_ROI_IN_SSC
Definition: TGCTriggerData.h:166
TGCTriggerData::SIDE_MASK
static constexpr uint8_t SIDE_MASK
Mask for extracting the side from the GLOBALADDR.
Definition: TGCTriggerData.h:107
LVL1TGCTrigger::TGCArguments
Definition: TGCArguments.h:12
python.LumiBlobConversion.pos
pos
Definition: LumiBlobConversion.py:18
TGCTriggerData::N_PT_THRESH
@ N_PT_THRESH
Definition: TGCTriggerData.h:161
SG::ReadCondHandleKey< TGCTriggerData >
get_generator_info.version
version
Definition: get_generator_info.py:33
TGCTriggerData::N_ENDCAP_SSC
@ N_ENDCAP_SSC
Definition: TGCTriggerData.h:164
python.CaloCondTools.log
log
Definition: CaloCondTools.py:20
TGCTriggerData::getFlagPtTile
unsigned char getFlagPtTile(int ssc, int sectorId, int side) const
Definition: TGCTriggerData.cxx:87
TGCTriggerData
Definition: TGCTriggerData.h:102
TGCTileMuCoincidenceLUT.h
CaloCondBlobAlgs_fillNoiseFromASCII.tag
string tag
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:24
makeTOC.header
header
Definition: makeTOC.py:28
LVL1TGC::TGCTileMuCoincidenceLUT::TM_NA
@ TM_NA
Definition: TGCTileMuCoincidenceLUT.h:82
LVL1TGC::TGCTileMuCoincidenceLUT::getFlagROI
int getFlagROI(const int roi, const int16_t ssc, const int16_t sec, const int16_t side) const
Definition: TGCTileMuCoincidenceLUT.cxx:170
LVL1TGC::TGCTileMuCoincidenceLUT::m_flagroi
std::unordered_map< uint16_t, uint8_t > m_flagroi
Definition: TGCTileMuCoincidenceLUT.h:96