ATLAS Offline Software
Loading...
Searching...
No Matches
TrigConfBunchCrossingTool.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
5
6// STL include(s):
7#include <algorithm>
8#include <vector>
9
10// Gaudi include(s):
11#ifndef XAOD_STANDALONE
12# include "GaudiKernel/IIncidentSvc.h"
13#endif // not XAOD_STANDALONE
14
15// Trigger config include(s):
18
19// Local include(s):
21
22namespace {
23
24 template< typename T >
25 MsgStream& operator<< ( MsgStream& out, const std::vector< T >& vec ) {
26
27 out << "[";
28 for( size_t i = 0; i < vec.size(); ++i ) {
29 out << vec[ i ];
30 if( i < vec.size() - 1 ) {
31 out << ", ";
32 }
33 }
34 out << "]";
35
36 // Return the stream:
37 return out;
38 }
39
40} // private namespace
41
42namespace Trig {
43
44 TrigConfBunchCrossingTool::
45 TrigConfBunchCrossingTool( const std::string& name )
47 {
48 }
49
51
52 // Reset he bunch group ID, so at the next update we definitely
53 // load a new configuration:
54 m_bgId = -1;
55
56 // Report about the initialization:
57 ATH_MSG_INFO( "Initializing TrigConfBunchCrossingTool" );
58 ATH_MSG_INFO( " Maximal bunch spacing: " << m_maxBunchSpacing << " ns" );
59 ATH_MSG_INFO( " Length of train front: " << m_frontLength << " ns" );
60 ATH_MSG_INFO( " Length of train tail : " << m_tailLength << " ns" );
61#ifndef XAOD_STANDALONE
62 ATH_MSG_DEBUG( " LVL1 config service : " << m_configSvc );
63#endif // XAOD_STANDALONE
64 ATH_MSG_DEBUG( " Trig config tool : " << m_configTool );
65
66 // Retrieve the trigger configuration service/tool:
67#ifndef XAOD_STANDALONE
68 if (!m_configTool.empty()) {
69 ATH_MSG_DEBUG( " xAODConfigTool is set - will read from xAOD metadata" );
70 ATH_CHECK( m_configTool.retrieve() );
71 } else {
72 ATH_MSG_DEBUG( " xAODConfigTool is not set - will read from xAODConfigSvc" );
73 ATH_CHECK( m_configSvc.retrieve() );
74 }
75#else
76 ATH_CHECK( m_configTool.retrieve() );
77#endif // not XAOD_STANDALONE
78
79 // Return gracefully:
80 return StatusCode::SUCCESS;
81 }
82
84
85 // Simply call the function doing the heavy lifting:
87
88 // Return gracefully:
89 return StatusCode::SUCCESS;
90 }
91
98
99 return static_cast< configid_type >( m_bgId );
100 }
101
111 std::vector< float >
113
114 return std::vector< float >();
115 }
116
126 std::vector< float >
128
129 return std::vector< float >();
130 }
131
141 std::vector< float >
143
144 return std::vector< float >();
145 }
146
156 std::vector< float >
158
159 return std::vector< float >();
160 }
161
176
177 // Decide where to take the configuration from:
178 TrigConf::IILVL1ConfigSvc* configSvc = 0;
179#ifndef XAOD_STANDALONE
180 if (m_configTool.isSet()) {
181 configSvc = m_configTool.operator->();
182 } else {
183 configSvc = m_configSvc.operator->();
184 }
185#else
186 configSvc = m_configTool.operator->();
187#endif // not XAOD_STANDALONE
188
189 // Check if the needed info is even there:
190 if( ! configSvc->bunchGroupSet() ) {
191 ATH_MSG_FATAL( "Trigger configuration service doesn't provide "
192 "BunchGroupSet information" );
193 return StatusCode::FAILURE;
194 }
195
196 // Check if we already have the correct configuration:
197 if( configSvc->bunchGroupSet()->id() == m_bgId ) {
198 return StatusCode::SUCCESS;
199 }
200
201 // Report to the user what we're doing:
202 ATH_MSG_INFO( "Updating tool configuration to BGKey #"
203 << configSvc->bunchGroupSet()->id() );
204
205 // Print the configuration for debugging purposes, and remember which one
206 // we're processing:
207 m_bgId = configSvc->bunchGroupSet()->id();
208 printBunchGroups( configSvc );
209
210 //
211 // Select the collision bunch group:
212 //
213 const std::vector< TrigConf::BunchGroup >& bgs =
214 configSvc->bunchGroupSet()->bunchGroups();
215 std::vector< TrigConf::BunchGroup >::const_iterator filled_bg =
216 bgs.begin();
217 ++filled_bg;
218 ATH_MSG_INFO( "Taking the second bunch group as the colliding bunch "
219 "group" );
220
221 //
222 // Now interpret the information:
223 //
224 ATH_CHECK( loadSingleBunches( filled_bg->bunches() ) );
225 ATH_CHECK( loadBunchTrains( filled_bg->bunches() ) );
226
227 //
228 // Select the unpaired bunches. The overlaps are taken care of by the
229 // base tool.
230 //
231 std::vector< int > unpaired;
232 // These are the "unpaired isolated" bunches:
233 if( bgs.size() > 4 ) {
234 unpaired.insert( unpaired.end(), bgs[ 4 ].bunches().begin(),
235 bgs[ 4 ].bunches().end() );
236 }
237 // These are the "unpaired non-isolated" bunches:
238 if( bgs.size() > 5 ) {
239 unpaired.insert( unpaired.end(), bgs[ 5 ].bunches().begin(),
240 bgs[ 5 ].bunches().end() );
241 }
242
243 //
244 // Now interpret the information:
245 //
246 ATH_CHECK( loadUnpairedBunches( unpaired, unpaired ) );
247
248 // Print the configuration to give some feedback to the user:
249 printConfig();
250
251#ifndef XAOD_STANDALONE
252 // Let everybody know that the configuration of the tool has changed:
253 ServiceHandle< IIncidentSvc > incidentSvc( "IncidentSvc", name() );
254 ATH_CHECK( incidentSvc.retrieve() );
255 incidentSvc->fireIncident( Incident( "BunchConfiguration update",
257#endif // not XAOD_STANDALONE
258
259 // Return gracefully:
260 return StatusCode::SUCCESS;
261 }
262
267 void TrigConfBunchCrossingTool::
268 printBunchGroups( const TrigConf::IILVL1ConfigSvc* svc ) const {
269
270 // Skip the rest if nothing will be printed anyway:
271 if( ! msgLvl( MSG::VERBOSE ) ) return;
272
273 // Print the information:
274 ATH_MSG_VERBOSE( "Printing BunchGroup configuration:" );
275 for( const auto& bg : svc->bunchGroupSet()->bunchGroups() ) {
276 ATH_MSG_VERBOSE( " BG \"" << bg.name() << "\": " << bg.bunches() );
277 }
278
279 // Return gracefully:
280 return;
281 }
282
283} // namespace Trig
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_FATAL(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_DEBUG(x)
std::vector< size_t > vec
std::ostream & operator<<(std::ostream &lhs, const TestGaudiProperty &rhs)
bool msgLvl(const MSG::Level lvl) const
const std::vector< BunchGroup > & bunchGroups() const
Interface for all services/tools that provide LVL1 menu configuration information.
virtual const BunchGroupSet * bunchGroupSet() const =0
Provides the LVL1 bunch group set.
unsigned int id() const
static const std::string BUNCH_CONFIG_INCIDENT_NAME
Type name for the incident that such tools should emit.
Base class for all BunchCrossingTool implementations.
StatusCode loadBunchTrains(const std::vector< int > &bunches, const std::vector< float > &bunch_int1=std::vector< float >(), const std::vector< float > &bunch_int2=std::vector< float >())
Interpret the configuration for bunch trains.
StatusCode loadSingleBunches(const std::vector< int > &bunches, const std::vector< float > &bunch_int1=std::vector< float >(), const std::vector< float > &bunch_int2=std::vector< float >())
Interpret the configuration for single bunches.
void printConfig() const
Function printing the configuration of the tool.
int m_maxBunchSpacing
The maximum bunch spacing that the tool should consider.
int m_frontLength
Length of the "front" of a bunch train.
StatusCode loadUnpairedBunches(const std::vector< int > &beam1, const std::vector< int > &beam2, const std::vector< float > &bunch_int1=std::vector< float >(), const std::vector< float > &bunch_int2=std::vector< float >())
Interpret the configuration for unpaired bunches.
int m_tailLength
Length of the "tail" of a bunch train.
unsigned int configid_type
Declare the interface that this class provides.
virtual std::vector< float > configuredUnpairedIntensitiesBeam1() const
Override the default implementation because this tool doesn't provide this info.
void printBunchGroups(const TrigConf::IILVL1ConfigSvc *svc) const
Print the "raw" configuration for debugging.
unsigned int m_bgId
DB ID of the BunchGroups settings which was loaded last.
ToolHandle< TrigConf::ITrigConfigTool > m_configTool
The config tool handle.
StatusCode loadConfig()
Make sure that the latest/correct configuration is loaded.
virtual std::vector< float > configuredIntensitiesBeam1() const
Override the default implementation because this tool doesn't provide this info.
virtual configid_type configID() const
Unique identifier for the current configuration.
virtual std::vector< float > configuredIntensitiesBeam2() const
Override the default implementation because this tool doesn't provide this info.
virtual StatusCode beginEvent()
Function called when a new event is loaded.
virtual std::vector< float > configuredUnpairedIntensitiesBeam2() const
Override the default implementation because this tool doesn't provide this info.
ServiceHandle< TrigConf::ILVL1ConfigSvc > m_configSvc
The config service handle.
virtual ASG_TOOL_CLASS2(TrigConfBunchCrossingTool, Trig::IBunchCrossingTool, Trig::IBunchCrossingConfProvider) public StatusCode initialize()
Create a proper constructor for Athena.
The common trigger namespace for trigger analysis tools.