ATLAS Offline Software
CTPUtil.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 
6 // this class heasder file
7 #include "./CTPUtil.h"
8 
9 // standard include(s):
10 #include <cmath>
11 #include <iostream>
12 
13 // STL include(s):
14 #include <sstream>
15 #include <iomanip>
16 
17 // LVL1 includes
18 #include "TrigT1Result/CTPRoI.h"
19 
20 namespace LVL1CTP {
21 
22  int CTPUtil::getMuonMult( unsigned int word, int threshold ) {
23 
24  return static_cast<int>( ( word >> ( 3 * threshold ) ) & 0x7 );
25 
26  }
27 
28  int CTPUtil::getEMTMult( unsigned int word, int threshold ) {
29 
30  return static_cast<int>( ( word >> ( 3 * threshold + 1 ) ) & 0x7 );
31 
32  }
33 
34  int CTPUtil::getJetMult( unsigned int word, int threshold ) {
35 
36  return CTPUtil::getEMTMult( word, threshold );
37 
38  }
39 
40  int CTPUtil::getFJetMult( unsigned int word, int threshold ) {
41 
42  return static_cast<int>( ( word >> ( 2 * threshold + 1 ) ) & 0x3 );
43 
44  }
45 
46  int CTPUtil::getJetEMult( unsigned int word, int threshold ) {
47 
48  return static_cast<int>( ( word >> ( 25 + threshold ) ) & 0x1 );
49 
50  }
51 
52  int CTPUtil::getETMult( unsigned int word, int threshold ) {
53 
54  return static_cast<int>( ( word >> ( 9 + threshold ) ) & 0x1 );
55 
56  }
57 
58  int CTPUtil::getTMMult( unsigned int word, int threshold ) {
59 
60  return static_cast<int>( ( word >> ( 1 + threshold ) ) & 0x1 );
61 
62  }
63 
64  int CTPUtil::getMult( uint64_t word, unsigned int startbit, unsigned int endbit ) {
65 
66  return static_cast<int>( ( word >> startbit ) & static_cast<unsigned int>( pow( 2, endbit - startbit + 1 ) - 1 ) );
67 
68  }
69 
70  int CTPUtil::getMuonMult( const std::vector<unsigned int>& words, unsigned int startbit, unsigned int endbit ) {
71  std::bitset<256> bits = convertToBitset(words);
72  std::bitset<256> mask = pow( 2, endbit - startbit + 1 ) - 1;
73  bits >>= startbit;
74  return static_cast<int>((bits&mask).to_ulong());
75  }
76 
77  int CTPUtil::getOptMult( std::bitset<128> bits, unsigned int startbit, unsigned int endbit ) {
78  std::bitset<128> mask = pow( 2, endbit - startbit + 1 ) - 1;
79  bits >>= startbit;
80  return static_cast<int>((bits&mask).to_ulong());
81  }
82 
83  unsigned int CTPUtil::getMultTopo( uint64_t word, unsigned int cableStart, unsigned int cableEnd, unsigned int clock ) {
84 
85  unsigned int mult = 0;
86 
87  for(int cb = (int)cableEnd; cb >= (int)cableStart; --cb) { // must be signed int
88  unsigned int b = 2 * cb + clock;
89  mult <<= 1;
90  mult += (word & ( 1UL << b )) ? 1 : 0 ;
91  }
92 
93  return mult;
94  }
95 
96 
97  std::bitset<256> CTPUtil::convertToBitset(const std::vector<uint32_t>& words) {
98  std::bitset<256> bitset;
99  for (size_t i(0); i < words.size(); ++i) {
100  std::bitset<256> bs = words[i];
101  bs <<= (i * 32);
102  bitset |= bs;
103  }
104  return bitset;
105  }
106 
107 
108  std::bitset<512> CTPUtil::convertToLargeBitset(const std::vector<ROIB::CTPRoI>& words) {
109  std::bitset<512> bitset;
110  for (size_t i(0); i < words.size(); ++i) {
111  std::bitset<512> bs = words[i].roIWord();
112  bs <<= (i * 32);
113  bitset |= bs;
114  }
115  return bitset;
116  }
117 
118  std::bitset<512> CTPUtil::convertToLargeBitset(const std::vector<uint32_t>& words) {
119  std::bitset<512> bitset;
120  for (size_t i(0); i < words.size(); ++i) {
121  std::bitset<512> bs = words[i];
122  bs <<= (i * 32);
123  bitset |= bs;
124  }
125  return bitset;
126  }
127 
128  std::bitset<256> CTPUtil::convertToBitset(const std::vector<ROIB::CTPRoI>& words) {
129  std::bitset<256> bitset;
130  for (size_t i(0); i < words.size(); ++i) {
131  std::bitset<256> bs = words[i].roIWord();
132  bs <<= (i * 32);
133  bitset |= bs;
134  }
135  return bitset;
136  }
137 
138  unsigned int CTPUtil::alignBits( int value, int startbit, int endbit ) {
139 
140  int ostart = std::min( startbit, endbit );
141  int oend = std::max( startbit, endbit );
142  int start = std::max( ostart, 0 );
143  int end = std::min( oend, 32 );
144 
145  unsigned int result = value;
146  if( ostart < 0 ) result >>= static_cast< int >( std::abs( static_cast< double >( ostart ) ) );
147  else result <<= ostart;
148  result &= createMask( start, end );
149 
150  return result;
151 
152  }
153 
154  unsigned int CTPUtil::createMask( int startbit, int endbit ) {
155 
156  int start = std::min( std::max( startbit, 0 ), std::max( endbit, 0 ) );
157  int end = std::max( std::min( startbit, 32 ), std::min( endbit, 32 ) );
158 
159  unsigned int result = 0;
160  for( int i = 0; i <= ( end - start ); ++i ) {
161  result <<= 1;
162  result |= 1;
163  }
164  result <<= start;
165 
166  return result;
167 
168  }
169 
170  std::string CTPUtil::printHex(const std::vector<uint32_t>& rhs, const std::string& delimiter)
171  {
172  std::ostringstream s;
173 
174  // switch to hex format
175  s << std::hex << std::setfill( '0' );
176 
177  if (rhs.size() > 0)
178  s << " 0x" << std::setw(8) << rhs[0];
179  for (size_t i(1); i < rhs.size(); ++i) {
180  s << delimiter << " 0x" << std::setw(8) << rhs[i];
181  }
182 
183  // switch back to normal format
184  s << std::dec << std::setfill(' ');
185 
186  return s.str();
187  }
188 
189 
190 } // namespace LVL1CTP
python.SystemOfUnits.s
int s
Definition: SystemOfUnits.py:131
get_generator_info.result
result
Definition: get_generator_info.py:21
LVL1CTP::CTPUtil::createMask
static unsigned int createMask(int startbit, int endbit)
create mask
Definition: CTPUtil.cxx:154
max
#define max(a, b)
Definition: cfImp.cxx:41
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
LVL1CTP::CTPUtil::getJetMult
static int getJetMult(unsigned int word, int threshold)
get Jet multiplicty in legacy mode
Definition: CTPUtil.cxx:34
LVL1CTP::CTPUtil::getFJetMult
static int getFJetMult(unsigned int word, int threshold)
get Forward Jet multiplicty in legacy mode
Definition: CTPUtil.cxx:40
mergePhysValFiles.start
start
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:14
conifer::pow
constexpr int pow(int x)
Definition: conifer.h:20
LVL1CTP::CTPUtil::getTMMult
static int getTMMult(unsigned int word, int threshold)
get missing Et multiplicty in legacy mode
Definition: CTPUtil.cxx:58
CTPUtil.h
athena.value
value
Definition: athena.py:122
python.utils.AtlRunQueryLookup.mask
string mask
Definition: AtlRunQueryLookup.py:460
mergePhysValFiles.end
end
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:93
LVL1CTP::CTPUtil::getMult
static int getMult(uint64_t word, unsigned int startbit, unsigned int endbit)
extract multiplicities using new trigger configuration interface
Definition: CTPUtil.cxx:64
python.AthDsoLogger.delimiter
delimiter
Definition: AthDsoLogger.py:71
lumiFormat.i
int i
Definition: lumiFormat.py:92
xAOD::uint64_t
uint64_t
Definition: EventInfo_v1.cxx:123
LVL1CTP::CTPUtil::printHex
static std::string printHex(const std::vector< uint32_t > &rhs, const std::string &delimiter=",")
print vector in hex format
Definition: CTPUtil.cxx:170
LVL1CTP::CTPUtil::convertToBitset
static std::bitset< 256 > convertToBitset(const std::vector< uint32_t > &words)
convert list of words into bitset
Definition: CTPUtil.cxx:97
LVL1CTP::CTPUtil::getEMTMult
static int getEMTMult(unsigned int word, int threshold)
get EmTau multiplicty in legacy mode
Definition: CTPUtil.cxx:28
min
#define min(a, b)
Definition: cfImp.cxx:40
LVL1CTP::CTPUtil::getOptMult
static int getOptMult(std::bitset< 128 > bits, unsigned int startbit, unsigned int endbit)
Definition: CTPUtil.cxx:77
LVL1CTP::CTPUtil::getJetEMult
static int getJetEMult(unsigned int word, int threshold)
get Jet Energy multiplicty in legacy mode
Definition: CTPUtil.cxx:46
plotBeamSpotMon.b
b
Definition: plotBeamSpotMon.py:77
threshold
Definition: chainparser.cxx:74
LVL1CTP::CTPUtil::getMuonMult
static int getMuonMult(unsigned int word, int threshold)
get Muon multiplicty in legacy mode
Definition: CTPUtil.cxx:22
CTPRoI.h
LVL1CTP::CTPUtil::convertToLargeBitset
static std::bitset< 512 > convertToLargeBitset(const std::vector< uint32_t > &words)
convert list of words into bitset
Definition: CTPUtil.cxx:118
LVL1CTP::CTPUtil::getETMult
static int getETMult(unsigned int word, int threshold)
get transverse energy multiplicty in legacy mode
Definition: CTPUtil.cxx:52
LVL1CTP::CTPUtil::getMultTopo
static unsigned int getMultTopo(uint64_t word, unsigned int startbit, unsigned int endbit, unsigned int clock)
extract multiplicities from Topo words, were the encoding is different
Definition: CTPUtil.cxx:83
LVL1CTP::CTPUtil::alignBits
static unsigned int alignBits(int value, int startbit, int endbit)
align bits
Definition: CTPUtil.cxx:138
LVL1CTP
Definition: Lvl1ResultAccessTool.h:20
checkFileSG.words
words
Definition: checkFileSG.py:76
dumpTgcDigiThreshold.threshold
list threshold
Definition: dumpTgcDigiThreshold.py:34