ATLAS Offline Software
TBPatternUnitStreamerToolH8.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3 */
4 
7 #include <string>
8 #include <ios>
9 
10 
12  const std::string& type,
13  const std::string& name,
14  const IInterface* parent)
16  , m_patternUnitKey("TBTrigPat")
17  , m_acceptPattern()
18  , m_rejectPattern()
19 {
20  declareProperty("PatternUnitName",m_patternUnitKey);
21  declareProperty("AcceptPattern", m_acceptPatternNames);
22  declareProperty("RejectPattern", m_rejectPatternNames);
23  // pre-settings (to be moved to helper!)
24  m_triggerBitMap["Physics"] = 0x00000001; // Physics accept
25  m_triggerBitMap["Calibration"] = 0x00000002; // Calib accept
26  m_triggerBitMap["LED"] = 0x00000002; // LED (same as calib) accept
27  m_triggerBitMap["Random"] = 0x00000004; // Random accept
28  m_triggerBitMap["MonoCIS"] = 0x00000008; // MonoCIS accept
29 }
30 
32 { }
33 
35 // Initialize //
37 
39 {
40  // messages
41  MsgStream report(msgSvc(),name());
42 
43  // form accept trigger pattern
44  m_acceptPattern = 0x00000000;
47  m_acceptPattern)).isFailure())
48  {
49  report << MSG::ERROR
50  << "cannot build accept pattern mask."
51  << endmsg;
52  return StatusCode::FAILURE;
53  }
54 
55  // form reject trigger pattern
56  m_rejectPattern = 0x00000000;
59  m_rejectPattern)).isFailure() )
60  {
61  report << MSG::ERROR
62  << "cannot build reject pattern mask."
63  << endmsg;
64  return StatusCode::FAILURE;
65  }
66 
67  // print pattern matrices
68  report << MSG::INFO << " " << endmsg;
69  report << MSG::INFO << " ###################" << endmsg;
70  report << MSG::INFO << " # TriggerPatterns #" << endmsg;
71  report << MSG::INFO << " ###################" << endmsg;
72  report << MSG::INFO << " " << endmsg;
73  report << MSG::INFO << " +-+-+-+-+-+-+" << endmsg;
74  report << MSG::INFO << " | | C | |" << endmsg;
75  report << MSG::INFO << " | | a | |" << endmsg;
76  report << MSG::INFO << " | | l | |" << endmsg;
77  report << MSG::INFO << " | | i | |" << endmsg;
78  report << MSG::INFO << " | P | b | |" << endmsg;
79  report << MSG::INFO << " | h | r | R |" << endmsg;
80  report << MSG::INFO << " | y | a | a |" << endmsg;
81  report << MSG::INFO << " | s | t | n |" << endmsg;
82  report << MSG::INFO << " | i | i | d |" << endmsg;
83  report << MSG::INFO << " | c | o | o |" << endmsg;
84  report << MSG::INFO << " | s | n | m |" << endmsg;
85  report << MSG::INFO << "+--------+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+" << endmsg;
86  std::string decoded = this->decodeBinary(m_acceptPattern);
87  report << MSG::INFO << "| accept | " ;
88  for ( unsigned int i=0; i<std::min(decoded.length(),m_triggerBitMap.size());
89  i++ )
90  {
91  report << MSG::INFO << decoded.substr(i,1) << " | ";
92  }
93 // report << MSG::INFO
94 // << " (0x" << std::setw(8) << std::setfill('0')
95 // << std::setiosflags(std::ios_base::hex) << m_acceptPattern << ")"
96 // << std::setiosflags(std::ios_base::dec)
97 // << endmsg;
98  report << MSG::INFO << "+--------+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+" << endmsg;
99  report << MSG::INFO << "| reject | ";
100  decoded = this->decodeBinary(m_rejectPattern);
101  for ( unsigned int i=0; i<std::min(decoded.length(),m_triggerBitMap.size());
102  i++ )
103  {
104  report << MSG::INFO << decoded.substr(i,1) << " | ";
105  }
106 // report << MSG::INFO
107 // << " (0x" << std::setw(8) << std::setfill('0')
108 // << std::setiosflags(std::ios_base::hex) << m_rejectPattern << ")"
109 // << std::setiosflags(std::ios_base::dec)
110 // << endmsg;
111  report << MSG::INFO << "+--------+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+" << endmsg;
112  report << MSG::INFO << "| ignore | ";
113  bit_mask ignorePattern = ~( m_rejectPattern ^ m_acceptPattern );
114  decoded = this->decodeBinary(ignorePattern);
115  for ( unsigned int i=0; i<std::min(decoded.length(),m_triggerBitMap.size());
116  i++ )
117  {
118  report << MSG::INFO << decoded.substr(i,1) << " | ";
119  }
120 // report << MSG::INFO
121 // << " (0x" << std::setw(8) << std::setfill('0')
122 // << std::setiosflags(std::ios_base::hex) << ignorePattern << ")"
123 // << std::setiosflags(std::ios_base::dec)
124 // << endmsg;
125  report << MSG::INFO << "+--------+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+" << endmsg;
126 
127  return StatusCode::SUCCESS;
128 }
129 
131 // Accept/Reject //
133 
135 {
136  // messaging
137  MsgStream report(msgSvc(),name());
138 
139  // retrieve pattern unit
140  const TBTriggerPatternUnit* theTrigger;
141  ATH_CHECK( evtStore()->retrieve(theTrigger,m_patternUnitKey) );
142 
143  //
144  bit_mask thePattern = theTrigger->getTriggerWord() & 0x00ffffff;
145 
146  // check acceptance (AND requirement)
147  bool globalAccept = m_acceptPattern != 0x00000000
149  ? ( thePattern & m_acceptPattern ) != 0x00000000
150  : true;
151 
152  // check rejection (OR requirement)
153  globalAccept = m_rejectPattern != 0x0000
154  ? globalAccept & ( ( thePattern & m_rejectPattern ) == 0x0000 )
155  : globalAccept;
156 
157  return globalAccept
158  ? StatusCode::SUCCESS
159  : StatusCode::FAILURE;
160 }
161 
163 // Helper //
165 
167 {
168  unsigned int nBits = sizeof(theTriggerWord) ;
169  std::string thePattern;
170  bit_mask testPattern = 0x00000001;
171 
172  for ( unsigned int i=0; i<nBits; i++ )
173  {
174  if ( ( theTriggerWord & testPattern ) == testPattern )
175  {
176  thePattern = thePattern + "X";
177  }
178  else
179  {
180  thePattern = thePattern + "O";
181  }
182  testPattern *= 2;
183  }
184  return thePattern;
185 }
186 
188  listOfPatterns,
189  const bit_mask_store&
190  definedPattern,
191  bit_mask& theMask)
192 {
193  // messaging
194  MsgStream report(msgSvc(),name());
195 
196  // build pattern
197  for (const pattern& pat : listOfPatterns)
198  {
199  bit_mask_store::const_iterator findIter =
200  definedPattern.find(pat);
201  if ( findIter != definedPattern.end() )
202  {
203  theMask = theMask | (*findIter).second;
204  }
205  else
206  {
207  report << MSG::WARNING
208  << "requested pattern <"
209  << pat
210  << "> unknown, ignore..."
211  << endmsg;
212  }
213  }
214  return StatusCode::SUCCESS;
215 }
216 
217 
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
TBPatternUnitStreamerToolH8::~TBPatternUnitStreamerToolH8
virtual ~TBPatternUnitStreamerToolH8()
Definition: TBPatternUnitStreamerToolH8.cxx:31
TBPatternUnitStreamerToolH8.h
TBPatternUnitStreamerToolH8::findPattern
StatusCode findPattern(const pattern_store &thePatterns, const bit_mask_store &theBitMasks, bit_mask &theMask)
Definition: TBPatternUnitStreamerToolH8.cxx:187
AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
min
constexpr double min()
Definition: ap_fixedTest.cxx:26
checkTP.report
report
Definition: checkTP.py:127
TBPatternUnitStreamerToolH8::pattern_store
std::vector< pattern > pattern_store
Definition: TBPatternUnitStreamerToolH8.h:40
TBTriggerPatternUnit::getTriggerWord
unsigned int getTriggerWord() const
Definition: TBTriggerPatternUnit.h:50
TBTriggerPatternUnit.h
TBPatternUnitStreamerToolH8::pattern
std::string pattern
Definition: TBPatternUnitStreamerToolH8.h:39
TBPatternUnitStreamerToolH8::accept
virtual StatusCode accept() override
Definition: TBPatternUnitStreamerToolH8.cxx:134
AthCommonDataStore< AthCommonMsg< AlgTool > >::evtStore
ServiceHandle< StoreGateSvc > & evtStore()
The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:85
StdJOSetup.msgSvc
msgSvc
Provide convenience handles for various services.
Definition: StdJOSetup.py:36
TBPatternUnitStreamerToolH8::m_patternUnitKey
std::string m_patternUnitKey
Definition: TBPatternUnitStreamerToolH8.h:57
lumiFormat.i
int i
Definition: lumiFormat.py:85
TBPatternUnitStreamerToolH8::m_rejectPattern
bit_mask m_rejectPattern
Definition: TBPatternUnitStreamerToolH8.h:66
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
TBPatternUnitStreamerToolH8::bit_mask
unsigned int bit_mask
Definition: TBPatternUnitStreamerToolH8.h:37
test_pyathena.parent
parent
Definition: test_pyathena.py:15
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
TBPatternUnitStreamerToolH8::m_rejectPatternNames
pattern_store m_rejectPatternNames
Definition: TBPatternUnitStreamerToolH8.h:59
dso-stats.pat
pat
Definition: dso-stats.py:39
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
TBPatternUnitStreamerToolH8::m_acceptPattern
bit_mask m_acceptPattern
Definition: TBPatternUnitStreamerToolH8.h:65
TBPatternUnitStreamerToolH8::initializeTool
virtual StatusCode initializeTool() override
Definition: TBPatternUnitStreamerToolH8.cxx:38
TBPatternUnitStreamerToolH8::m_acceptPatternNames
pattern_store m_acceptPatternNames
Definition: TBPatternUnitStreamerToolH8.h:58
TBPatternUnitStreamerToolH8::bit_mask_store
std::map< std::string, bit_mask > bit_mask_store
Definition: TBPatternUnitStreamerToolH8.h:38
TBEventStreamerTool
Definition: TBEventStreamerTool.h:15
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
TBPatternUnitStreamerToolH8::decodeBinary
std::string decodeBinary(bit_mask &theTrigger)
Definition: TBPatternUnitStreamerToolH8.cxx:166
TBPatternUnitStreamerToolH8::TBPatternUnitStreamerToolH8
TBPatternUnitStreamerToolH8(const std::string &type, const std::string &name, const IInterface *parent)
Definition: TBPatternUnitStreamerToolH8.cxx:11
TBTriggerPatternUnit
Definition: TBTriggerPatternUnit.h:27
TBPatternUnitStreamerToolH8::m_triggerBitMap
bit_mask_store m_triggerBitMap
Definition: TBPatternUnitStreamerToolH8.h:67