ATLAS Offline Software
Loading...
Searching...
No Matches
TBPatternUnitStreamerTool.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3*/
4
6
9
10#include <string>
11#include <ios>
12
14 const std::string& name,
15 const IInterface* parent)
16 : TBEventStreamerTool(type,name,parent)
17 , m_patternUnitKey("TBTrigPat")
20{
21 declareInterface<TBEventStreamerTool>(this);
22 declareProperty("PatternUnitName",m_patternUnitKey);
23 declareProperty("AcceptPattern", m_acceptPatternNames);
24 declareProperty("RejectPattern", m_rejectPatternNames);
25 // pre-settings (to be moved to helper!)
26 m_triggerBitMap["S1"] = 0x00000001; // S1 accept
27 m_triggerBitMap["S2"] = 0x00000002; // S2 accept
28 m_triggerBitMap["S3"] = 0x00000004; // S3 accept
29 m_triggerBitMap["B2"] = 0x00000008; // B2 accept
30 m_triggerBitMap["VetoLeft"] = 0x00000010; // VetoLeft
31 m_triggerBitMap["VetoRight"] = 0x00000020; // VetoRight
32 m_triggerBitMap["VetoDown"] = 0x00000040; // VetoUp
33 m_triggerBitMap["VetoUp"] = 0x00000080; // VetoDown
34 m_triggerBitMap["Mu1Left"] = 0x00000100; // Mu 1 Left
35 m_triggerBitMap["Mu1Right"] = 0x00000200; // Mu 1 Right
36 m_triggerBitMap["Mu2Left"] = 0x00000400; // Mu 2 Left
37 m_triggerBitMap["EarlyPU"] = 0x00000800; // Early PileUp
38 m_triggerBitMap["LatePU"] = 0x00001000; // Late PileUp
39 m_triggerBitMap["InSpill"] = 0x00002000; // In Spill Tag
40 m_triggerBitMap["OffSpill"] = 0x00004000; // Off Spill Tag
41 m_triggerBitMap["Cedar6of8"] = 0x00008000; // Cedar 7 of 8 segments
42 m_triggerBitMap["Mu2Right"] = 0x00010000; // Mu 2 Right
43 m_triggerBitMap["HoleVeto"] = 0x00020000; // Hole Counter
44 m_triggerBitMap["W1*W2"] = 0x00040000; // W1*W2 coincidence
45 m_triggerBitMap["B1"] = 0x00080000; // B2 accept
46 m_triggerBitMap["ScalerReset"] = 0x00100000; // Scaler Reset Tag
47 m_triggerBitMap["Cedar7of8"] = 0x08000000; // Cedar 7 of 8 segments
48 m_triggerBitMap["Cedar8of8"] = 0x10000000; // Cedar 8 of 8 segments
49}
50
53
55// Initialize //
57
59{
60 // messages
61 MsgStream report(msgSvc(),name());
62
63 // form accept trigger pattern
64 m_acceptPattern = 0x00000000;
67 m_acceptPattern)).isFailure())
68 {
69 report << MSG::ERROR
70 << "cannot build accept pattern mask."
71 << endmsg;
72 return StatusCode::FAILURE;
73 }
74
75 // form reject trigger pattern
76 m_rejectPattern = 0x00000000;
79 m_rejectPattern)).isFailure() )
80 {
81 report << MSG::ERROR
82 << "cannot build reject pattern mask."
83 << endmsg;
84 return StatusCode::FAILURE;
85 }
86
87 // print pattern matrices
88 report << MSG::INFO << " " << endmsg;
89 report << MSG::INFO << " ###################" << endmsg;
90 report << MSG::INFO << " # TriggerPatterns #" << endmsg;
91 report << MSG::INFO << " ###################" << endmsg;
92 report << MSG::INFO << " " << endmsg;
93 report << MSG::INFO << " +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+" << endmsg;
94 report << MSG::INFO << " | | | | | | | | | | | | | | | | | | | | |S| |" << endmsg;
95 report << MSG::INFO << " | | | | | | | | | | | | | | | | | | | | |c| |" << endmsg;
96 report << MSG::INFO << " | | | | | |V| | | | | | | | | |C| | | | |a|C|" << endmsg;
97 report << MSG::INFO << " | | | | |V|e| |V| |M| | | | |O|e|M|H| | |l|e|" << endmsg;
98 report << MSG::INFO << " | | | | |e|t| |e|M|u|M|E| |I|f|d|u|o| | |e|d|" << endmsg;
99 report << MSG::INFO << " | | | | |t|o|V|t|u|1|u|a|L|n|f|a|2|l| | |r|a|" << endmsg;
100 report << MSG::INFO << " | | | | |o|R|e|o|1|R|2|r|a|S|S|r|R|e|W| |R|r|" << endmsg;
101 report << MSG::INFO << " | | | | |L|i|t|D|L|i|L|l|t|p|p|7|i|V|1| |e|8|" << endmsg;
102 report << MSG::INFO << " | | | | |e|g|o|o|e|g|e|y|e|i|i|o|g|e|*| |s|o|" << endmsg;
103 report << MSG::INFO << " |S|S|S|B|f|h|U|w|f|h|f|P|P|l|l|f|h|t|W|B|e|f|" << endmsg;
104 report << MSG::INFO << " |1|2|3|2|t|t|p|n|t|t|t|U|U|l|l|8|t|o|2|1|t|8|" << endmsg;
105 report << MSG::INFO << "+--------+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+" << endmsg;
106 report << MSG::INFO << "| accept |";
107 std::string decoded = this->decodeBinary(m_acceptPattern);
108 for ( unsigned int i=0; i<std::min(decoded.length(),m_triggerBitMap.size());
109 i++ )
110 {
111 report << MSG::INFO << decoded.substr(i,1) << "|";
112 }
113// report << MSG::INFO
114// << " (0x" << std::setw(8) << std::setfill('0')
115// << std::setiosflags(std::ios_base::hex) << m_acceptPattern << ")"
116// << std::setiosflags(std::ios_base::dec)
117// << endmsg;
118 report << MSG::INFO << "+--------+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+" << endmsg;
119 report << MSG::INFO << "| reject |";
120 decoded = this->decodeBinary(m_rejectPattern);
121 for ( unsigned int i=0; i<std::min(decoded.length(),m_triggerBitMap.size());
122 i++ )
123 {
124 report << MSG::INFO << decoded.substr(i,1) << "|";
125 }
126// report << MSG::INFO
127// << " (0x" << std::setw(8) << std::setfill('0')
128// << std::setiosflags(std::ios_base::hex) << m_rejectPattern << ")"
129// << std::setiosflags(std::ios_base::dec)
130// << endmsg;
131 report << MSG::INFO << "+--------+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+" << endmsg;
132 report << MSG::INFO << "| ignore |";
133 bit_mask ignorePattern = ~( m_rejectPattern ^ m_acceptPattern );
134 decoded = this->decodeBinary(ignorePattern);
135 for ( unsigned int i=0; i<std::min(decoded.length(),m_triggerBitMap.size());
136 i++ )
137 {
138 report << MSG::INFO << decoded.substr(i,1) << "|";
139 }
140// report << MSG::INFO
141// << " (0x" << std::setw(8) << std::setfill('0')
142// << std::setiosflags(std::ios_base::hex) << ignorePattern << ")"
143// << std::setiosflags(std::ios_base::dec)
144// << endmsg;
145 report << MSG::INFO << "+--------+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+" << endmsg;
146
147 return StatusCode::SUCCESS;
148}
149
151// Accept/Reject //
153
155{
156 // messaging
157 MsgStream report(msgSvc(),name());
158
159 // Always accept non-physics events
160 const TBEventInfo* theEventInfo;
161 ATH_CHECK( evtStore()->retrieve(theEventInfo,"TBEventInfo") );
162
163 unsigned short evType = theEventInfo->getEventType();
164 report << MSG::DEBUG << "Event Type found " << evType << endmsg;
165 if (evType != 1) return StatusCode::SUCCESS;
166
167 // retrieve pattern unit
168 const TBTriggerPatternUnit* theTrigger;
169 ATH_CHECK( evtStore()->retrieve(theTrigger,m_patternUnitKey) );
170
171 //
172 bit_mask thePattern = theTrigger->getTriggerWord() & 0x00ffffff;
173
174 // check acceptance (AND requirement)
175 bool globalAccept = m_acceptPattern != 0x00000000
176 ? ( thePattern & m_acceptPattern ) == m_acceptPattern
177 : true;
178
179 // check rejection (OR requirement)
180 globalAccept = m_rejectPattern != 0x0000
181 ? globalAccept & ( ( thePattern & m_rejectPattern ) == 0x0000 )
182 : globalAccept;
183
184 return globalAccept
185 ? StatusCode::SUCCESS
186 : StatusCode::FAILURE;
187}
188
190// Helper //
192
194{
195 unsigned int nBits = sizeof(theTriggerWord) * 8;
196 std::string thePattern;
197 bit_mask testPattern = 0x00000001;
198 for ( unsigned int i=0; i<nBits; i++ )
199 {
200 if ( ( theTriggerWord & testPattern ) == testPattern )
201 {
202 thePattern = thePattern + "X";
203 }
204 else
205 {
206 thePattern = thePattern + "O";
207 }
208 testPattern *= 2;
209 }
210 return thePattern;
211}
212
214 listOfPatterns,
215 const bit_mask_store&
216 definedPattern,
217 bit_mask& theMask)
218{
219 // messaging
220 MsgStream report(msgSvc(),name());
221
222 // build pattern
223 for (const pattern& pat : listOfPatterns)
224 {
225 bit_mask_store::const_iterator findIter =
226 definedPattern.find(pat);
227 if ( findIter != definedPattern.end() )
228 {
229 theMask = theMask | (*findIter).second;
230 }
231 else
232 {
233 report << MSG::WARNING
234 << "requested pattern <"
235 << pat
236 << "> unknown, ignore..."
237 << endmsg;
238 }
239 }
240 return StatusCode::SUCCESS;
241}
242
243
#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()
int getEventType() const
Definition TBEventInfo.h:71
TBEventStreamerTool(const std::string &name, const std::string &type, const IInterface *parent)
StatusCode findPattern(const pattern_store &thePatterns, const bit_mask_store &theBitMasks, bit_mask &theMask)
virtual StatusCode accept() override
std::map< std::string, bit_mask > bit_mask_store
std::vector< pattern > pattern_store
virtual StatusCode initializeTool() override
std::string decodeBinary(bit_mask &theTrigger)
TBPatternUnitStreamerTool(const std::string &type, const std::string &name, const IInterface *parent)
unsigned int getTriggerWord() const