ATLAS Offline Software
Loading...
Searching...
No Matches
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)
15 : TBEventStreamerTool(type,name,parent)
16 , m_patternUnitKey("TBTrigPat")
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
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
#define endmsg
#define ATH_CHECK
Evaluate an expression and check for errors.
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
ServiceHandle< StoreGateSvc > & evtStore()
TBEventStreamerTool(const std::string &name, const std::string &type, const IInterface *parent)
std::map< std::string, bit_mask > bit_mask_store
TBPatternUnitStreamerToolH8(const std::string &type, const std::string &name, const IInterface *parent)
std::string decodeBinary(bit_mask &theTrigger)
StatusCode findPattern(const pattern_store &thePatterns, const bit_mask_store &theBitMasks, bit_mask &theMask)
virtual StatusCode accept() override
virtual StatusCode initializeTool() override
unsigned int getTriggerWord() const