ATLAS Offline Software
TGCTriggerBWCWReader.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 
9 
11  TGCTriggerLUTReader(lutType)
12 {
13 }
14 
15 
16 
18  const CondAttrListCollection* readCdo) {
19 
20  MsgStream log(m_msgSvc, "TGCTriggerBWCWReader::loadParameters");
21  if(m_svcLocator->service("MessageSvc", m_msgSvc) == StatusCode::FAILURE){
22  return false;
23  }
24 
27 
28  for(; itr!=itr_e; ++itr) {
29  const unsigned int channel = (*itr).first;
30  const coral::AttributeList& atr = (*itr).second;
31 
32  log << MSG::DEBUG<<"channel: " << channel<<endmsg;
33  std::string file = *(static_cast<const std::string*>((atr["file"]).addressOfData()));
34  std::string data = *(static_cast<const std::string*>((atr["data"]).addressOfData()));
35  std::string version = *(static_cast<const std::string*>((atr["version"]).addressOfData()));
36  std::string type = *(static_cast<const std::string*>((atr["type"]).addressOfData()));
37 
38  writeCdo->m_datamap[m_lutType][file] = data;
39  writeCdo->m_data[m_lutType].push_back(data);
40  writeCdo->m_file[m_lutType].push_back(file);
41  writeCdo->m_version[m_lutType].push_back(version);
42  writeCdo->m_type[m_lutType].push_back(type);
43 
44  log << MSG::INFO<<"file: " <<file<<endmsg;
45  log << MSG::DEBUG<<"data: " << data<<endmsg;
46 
47  }
48  return true;
49 }
50 
51 
52 
53 
54 
55 
56 
57 
59 
60  MsgStream log(m_msgSvc, "TGCTriggerBWCWReader::readLUT");
61  if(m_svcLocator->service("MessageSvc", m_msgSvc) == StatusCode::FAILURE){
62  return false;
63  }
64 
65  const int numberOfCoincidenceType = 4;
66 
67  const int moduleNumber[TGCTriggerLUTs::N_MODULETYPE] =
68  { 0, 1, 2, 2, 3, 4, 5, 5, 6, 7, 8, 8 };
69  const std::string moduleName[TGCTriggerLUTs::N_MODULETYPE]=
70  {"0a","1a","2a","2b","3a","4a","5a","5b","6a","7a","8a","8b"};
71  const std::string sideName[TGCTriggerLUTs::N_SIDE] = {"a","c"};
72  const std::string octantName[TGCTriggerLUTs::N_OCTANT] =
73  { "0", "1", "2", "3", "4", "5", "6", "7"};
74  const std::string coincidenceTypeName[numberOfCoincidenceType] = {"HH","HL","LH","LL"};
75 
76 
77  // initialize
78  bool fullCW = (writeCdo->getType(TGCTriggerLUTs::CW_BW) == "full" );
79  // loop over all files...
80  for(int iSide = 0; iSide<TGCTriggerLUTs::N_SIDE; iSide++){
81  for(int iOctant = 0; iOctant < TGCTriggerLUTs::N_OCTANT; iOctant++) {
82 
85 
86  for(int iModule=0; iModule<TGCTriggerLUTs::N_MODULETYPE; iModule+=1) {
87 
88  uint32_t phimod2 = moduleName[iModule].find('b') != std::string::npos ? 1 : 0;
89  uint32_t modaddr = ((moduleNumber[iModule] & TGCTriggerLUTs::MODULE_MASK)<<TGCTriggerLUTs::MODULE_SHIFT) +
91 
92  for(int iCoinType=0; iCoinType!=numberOfCoincidenceType; iCoinType++){
93 
94  std::string fn;
95  if (fullCW) {
96  fn = "RPhiCoincidenceMapRun3_" + sideName[iSide] + octantName[iOctant]
97  + moduleName[iModule] + coincidenceTypeName[iCoinType] + ".db";
98  } else{
99  fn = "RPhiCoincidenceMapRun3_" + moduleName[iModule] + coincidenceTypeName[iCoinType] + ".db";
100  }
101 
102  bool Forward_type1=(moduleName[iModule]=="2b"||moduleName[iModule]=="5a"||moduleName[iModule]=="8b");
103  bool Forward_type2=(moduleName[iModule]=="2a"||moduleName[iModule]=="5b"||moduleName[iModule]=="8a");
104 
105  if(iOctant%2==0 && Forward_type1){continue;}
106  if(iOctant%2==1 && Forward_type2){continue;}
107  int type = -1;
108  int lDR, hDR, lDPhi, hDPhi;
109 
110  std::string data = writeCdo->getData(TGCTriggerLUTs::CW_BW, fn);
111  std::istringstream stream(data);
112 
113  std::string buf,tag;
114  char delimiter = '\n';
115  int roi;
116 
117  while(getline(stream,buf,delimiter)){
118  std::istringstream header(buf);
119  header>>tag;
120  if(tag=="#") { // read header part.
121  header >> roi >> lDR >> hDR >> lDPhi >> hDPhi;
122  type = getType( lDR, hDR, lDPhi, hDPhi );
123  if( type<0 ) {
124  break;
125  }
126 
129 
130  for(uint8_t ir=lDR+TGCTriggerLUTs::DR_HIGH_RANGE; ir <= hDR+TGCTriggerLUTs::DR_HIGH_RANGE; ir++) { // 0...31 or 7...23
132 
133  // get window data
134  getline(stream, buf, delimiter);
135 
136  for(uint8_t iphi=lDPhi+TGCTriggerLUTs::DPHI_HIGH_RANGE; iphi <= hDPhi+TGCTriggerLUTs::DPHI_HIGH_RANGE; iphi++) {
137  uint32_t theaddr = octaddr + modaddr + cwaddr + draddr + iphi;
138  char pt = buf[iphi-lDPhi-TGCTriggerLUTs::DPHI_HIGH_RANGE];
139  if (pt == 'X') continue; // not opened
140  writeCdo->m_ptmap_bw[theaddr] = pt;
141  }
142  }
143 
144  }
145  }
146 
147  }// coincidence type
148  }// module
149  }// octant
150  }// side
151 
152  return true;
153 }
154 
155 
156 
157 
158 int TGCTriggerBWCWReader::getType(int lDR, int hDR, int lDPhi, int hDPhi ) const {
159  int type = -1;
160  if ( (lDR==-15) && (hDR==15) && (lDPhi==-7) && (hDPhi==7)) type = TGCTriggerBWCWReader::TMap_HH;
161  else if ( (lDR==-15) && (hDR==15) && (lDPhi==-3) && (hDPhi==3)) type = TGCTriggerBWCWReader::TMap_HL;
162  else if ( (lDR==-7) && (hDR==7) && (lDPhi==-7) && (hDPhi==7)) type = TGCTriggerBWCWReader::TMap_LH;
163  else if ( (lDR==-7) && (hDR==7) && (lDPhi==-3) && (hDPhi==3)) type = TGCTriggerBWCWReader::TMap_LL;
164  return type;
165 }
166 
167 int TGCTriggerBWCWReader::subSectorAdd(int ssid, int modid, int phimod2, int type) const {
168  return (ssid+(modid<<8)+(phimod2<<12) + (type<<16) );
169 }
170 
TGCTriggerLUTs::PHIMOD2_MASK
static constexpr uint8_t PHIMOD2_MASK
Mask for extracting the phi(F or B) from the GLOBALADDR.
Definition: TGCTriggerLUTs.h:36
data
char data[hepevt_bytes_allocation_ATLAS]
Definition: HepEvt.cxx:11
CondAttrListCollection::end
const_iterator end() const
Definition: CondAttrListCollection.h:315
TGCTriggerLUTs::m_file
std::vector< std::string > m_file[LUT_NUM]
Definition: TGCTriggerLUTs.h:86
header
Definition: hcg.cxx:526
plotting.yearwise_efficiency.channel
channel
Definition: yearwise_efficiency.py:28
CondAttrListCollection.h
This file defines the class for a collection of AttributeLists where each one is associated with a ch...
xAOD::uint8_t
uint8_t
Definition: Muon_v1.cxx:575
TGCTriggerBWCWReader::TMap_HH
@ TMap_HH
Definition: TGCTriggerBWCWReader.h:23
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
TGCTriggerBWCWReader::TGCTriggerBWCWReader
TGCTriggerBWCWReader(int lutType)
Definition: TGCTriggerBWCWReader.cxx:10
TGCTriggerLUTs::m_ptmap_bw
std::unordered_map< uint32_t, int8_t > m_ptmap_bw
Definition: TGCTriggerLUTs.h:90
test_pyathena.pt
pt
Definition: test_pyathena.py:11
TGCTriggerLUTs.h
CondAttrListCollection::begin
const_iterator begin() const
Access to Chan/AttributeList pairs via iterators.
Definition: CondAttrListCollection.h:309
python.PyKernel.AttributeList
AttributeList
Definition: PyKernel.py:36
TGCTriggerLUTs::getData
std::string getData(int cwtype, std::string file) const
Definition: TGCTriggerLUTs.cxx:18
CondAttrListCollection
This class is a collection of AttributeLists where each one is associated with a channel number....
Definition: CondAttrListCollection.h:52
TGCTriggerLUTReader::m_lutType
const int m_lutType
Definition: TGCTriggerLUTReader.h:28
TGCTriggerLUTs::ROI_SHIFT
static constexpr uint8_t ROI_SHIFT
Bit position of the module number bits in the GLOBALADDR.
Definition: TGCTriggerLUTs.h:46
AthenaPoolTestWrite.stream
string stream
Definition: AthenaPoolTestWrite.py:12
TGCTriggerLUTs::TYPE_SHIFT
static constexpr uint8_t TYPE_SHIFT
Bit position of the octant bits in the GLOBALADDR.
Definition: TGCTriggerLUTs.h:34
TGCTriggerLUTs::getType
std::string getType(int cwtype, int channel=0) const
Definition: TGCTriggerLUTs.cxx:41
TGCTriggerBWCWReader::TMap_LH
@ TMap_LH
Definition: TGCTriggerBWCWReader.h:23
TGCTriggerBWCWReader::subSectorAdd
int subSectorAdd(int ssid, int modid, int phimod2, int type) const
Definition: TGCTriggerBWCWReader.cxx:167
TGCTriggerBWCWReader::getType
int getType(int lDR, int hDR, int lDPhi, int hDPhi) const
Definition: TGCTriggerBWCWReader.cxx:158
TGCTriggerLUTs::DR_MASK
static constexpr uint8_t DR_MASK
Mask for extracting the deltaR from the GLOBALADDR.
Definition: TGCTriggerLUTs.h:48
TGCTriggerLUTReader::m_svcLocator
ISvcLocator * m_svcLocator
Definition: TGCTriggerLUTReader.h:30
TGCTriggerBWCWReader::TMap_HL
@ TMap_HL
Definition: TGCTriggerBWCWReader.h:23
TGCTriggerLUTs::N_MODULETYPE
@ N_MODULETYPE
Definition: TGCTriggerLUTs.h:70
python.AthDsoLogger.delimiter
delimiter
Definition: AthDsoLogger.py:71
TGCTriggerLUTs::DPHI_HIGH_RANGE
static constexpr uint8_t DPHI_HIGH_RANGE
Range of DPhi in the BW coincidence window for 3-station.
Definition: TGCTriggerLUTs.h:61
python.getCurrentFolderTag.fn
fn
Definition: getCurrentFolderTag.py:65
TGCTriggerLUTs
Definition: TGCTriggerLUTs.h:16
TGCTriggerLUTs::OCTANT_MASK
static constexpr uint8_t OCTANT_MASK
Mask for extracting the octant from the GLOBALADDR.
Definition: TGCTriggerLUTs.h:28
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
TGCTriggerLUTReader::m_msgSvc
IMessageSvc * m_msgSvc
Definition: TGCTriggerLUTReader.h:29
file
TFile * file
Definition: tile_monitor.h:29
TGCTriggerLUTs::DR_HIGH_RANGE
static constexpr uint8_t DR_HIGH_RANGE
Range of DR in the BW coincidence window for 3-station.
Definition: TGCTriggerLUTs.h:57
TGCTriggerBWCWReader.h
TGCTriggerLUTs::m_type
std::vector< std::string > m_type[LUT_NUM]
Definition: TGCTriggerLUTs.h:88
TGCTriggerLUTs::m_data
std::vector< std::string > m_data[LUT_NUM]
Definition: TGCTriggerLUTs.h:85
TGCTriggerLUTs::DR_SHIFT
static constexpr uint8_t DR_SHIFT
Bit position of the deltaR bits in the GLOBALADDR.
Definition: TGCTriggerLUTs.h:50
TGCTriggerLUTs::OCTANT_SHIFT
static constexpr uint8_t OCTANT_SHIFT
Bit position of the octant bits in the GLOBALADDR.
Definition: TGCTriggerLUTs.h:30
TGCTriggerLUTs::m_version
std::vector< std::string > m_version[LUT_NUM]
Definition: TGCTriggerLUTs.h:87
TGCTriggerLUTs::MODULE_MASK
static constexpr uint8_t MODULE_MASK
Mask for extracting the module number from the GLOBALADDR.
Definition: TGCTriggerLUTs.h:40
TGCTriggerLUTs::SIDE_SHIFT
static constexpr uint8_t SIDE_SHIFT
Bit position of the side bit in the GLOBALADDR.
Definition: TGCTriggerLUTs.h:26
TGCTriggerBWCWReader::loadParameters
bool loadParameters(TGCTriggerLUTs *writeCdo, const CondAttrListCollection *readKey) override
Definition: TGCTriggerBWCWReader.cxx:17
TGCTriggerLUTReader
Definition: TGCTriggerLUTReader.h:17
ir
int ir
counter of the current depth
Definition: fastadd.cxx:49
get_generator_info.version
version
Definition: get_generator_info.py:33
TGCTriggerLUTs::N_OCTANT
@ N_OCTANT
Definition: TGCTriggerLUTs.h:69
TGCTriggerBWCWReader::TMap_LL
@ TMap_LL
Definition: TGCTriggerBWCWReader.h:23
CondAttrListCollection::const_iterator
ChanAttrListMap::const_iterator const_iterator
Definition: CondAttrListCollection.h:63
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
DEBUG
#define DEBUG
Definition: page_access.h:11
TGCTriggerLUTs::TYPE_MASK
static constexpr uint8_t TYPE_MASK
Mask for extracting the octant from the GLOBALADDR.
Definition: TGCTriggerLUTs.h:32
python.CaloCondTools.log
log
Definition: CaloCondTools.py:20
TGCTriggerLUTs::SIDE_MASK
static constexpr uint8_t SIDE_MASK
Mask for extracting the side from the GLOBALADDR.
Definition: TGCTriggerLUTs.h:24
TGCTriggerLUTs::N_SIDE
@ N_SIDE
Definition: TGCTriggerLUTs.h:68
CaloCondBlobAlgs_fillNoiseFromASCII.tag
string tag
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:24
makeTOC.header
header
Definition: makeTOC.py:28
TGCTriggerBWCWReader::readLUT
bool readLUT(TGCTriggerLUTs *writeCdo) override
Definition: TGCTriggerBWCWReader.cxx:58
TGCTriggerLUTs::MODULE_SHIFT
static constexpr uint8_t MODULE_SHIFT
Bit position of the module number bits in the GLOBALADDR.
Definition: TGCTriggerLUTs.h:42
TGCTriggerLUTs::CW_BW
@ CW_BW
Definition: TGCTriggerLUTs.h:66
TGCTriggerLUTs::m_datamap
std::map< std::string, std::string > m_datamap[LUT_NUM]
Definition: TGCTriggerLUTs.h:84
TGCTriggerLUTs::ROI_MASK
static constexpr uint8_t ROI_MASK
Mask for extracting the module number from the GLOBALADDR.
Definition: TGCTriggerLUTs.h:44
TGCTriggerLUTs::PHIMOD2_SHIFT
static constexpr uint8_t PHIMOD2_SHIFT
Bit position of the module number bits in the GLOBALADDR.
Definition: TGCTriggerLUTs.h:38