ATLAS Offline Software
Loading...
Searching...
No Matches
xAODBunchCrossingTool.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3*/
4
5// $Id: xAODBunchCrossingTool.cxx 620838 2014-10-09 11:38:00Z krasznaa $
6
7// EDM include(s):
10
11// Local include(s):
13
14namespace Trig {
15
17 : BunchCrossingToolBase( name ),
18 m_cache(), m_currentID( -1 ) {
19
20 declareProperty( "MetaDataKey", m_metaKey = "BunchConfiguration" );
21 declareProperty( "EventDataKey", m_eventKey = "BunchConfKey" );
22 }
23
25
26 // Greet the user:
27 ATH_MSG_INFO( "Initialising..." );
28 ATH_MSG_DEBUG( "MetaDataKey = " << m_metaKey );
29 ATH_MSG_DEBUG( "EventDataKey = " << m_eventKey );
30
31 // Return gracefully:
32 return StatusCode::SUCCESS;
33 }
34
36
37 // Get the configuration object from the file:
38 const xAOD::BunchConfContainer* metaCont = 0;
39 ATH_CHECK( inputMetaStore()->retrieve( metaCont, m_metaKey ) );
40
41 // Copy the information from the container into the tool's internal
42 // cache:
45 for( ; itr != end; ++itr ) {
46 // Create/access the configuration object:
47 BunchConfig& conf = m_cache[ ( *itr )->configID() ];
48 // Fill it with information:
49 conf.filledBCIDs = ( *itr )->collidingBCIDs();
50 if( ( *itr )->intensitiesBeam1Available() ) {
51 conf.filledIntBeam1 = ( *itr )->intensitiesBeam1();
52 } else {
53 conf.filledIntBeam1.clear();
54 }
55 if( ( *itr )->intensitiesBeam2Available() ) {
56 conf.filledIntBeam2 = ( *itr )->intensitiesBeam2();
57 } else {
58 conf.filledIntBeam2.clear();
59 }
60 if( ( *itr )->unpairedBCIDsBeam1Available() ) {
61 conf.unpairedBCIDsBeam1 = ( *itr )->unpairedBCIDsBeam1();
62 } else {
63 conf.unpairedBCIDsBeam1.clear();
64 }
65 if( ( *itr )->unpairedBCIDsBeam2Available() ) {
66 conf.unpairedBCIDsBeam2 = ( *itr )->unpairedBCIDsBeam2();
67 } else {
68 conf.unpairedBCIDsBeam2.clear();
69 }
70 if( ( *itr )->unpairedIntensitiesBeam1Available() ) {
71 conf.unpairedIntBeam1 = ( *itr )->unpairedIntensisitesBeam1();
72 } else {
73 conf.unpairedIntBeam1.clear();
74 }
75 if( ( *itr )->unpairedIntensitiesBeam2Available() ) {
76 conf.unpairedIntBeam2 = ( *itr )->unpairedIntensisitesBeam2();
77 } else {
78 conf.unpairedIntBeam2.clear();
79 }
80 }
81
82 // Return gracefully:
83 return StatusCode::SUCCESS;
84 }
85
87
88 // Get the event object:
89 const xAOD::BunchConfKey* key = 0;
90 ATH_CHECK( evtStore()->retrieve( key, m_eventKey ) );
91
92 // If this is the currently loaded ID, we're done already:
93 if( key->id() == m_currentID ) {
94 return StatusCode::SUCCESS;
95 }
96
97 // If not, check if we know the configuration for this ID:
98 Cache_t::const_iterator config_itr = m_cache.find( key->id() );
99 if( config_itr == m_cache.end() ) {
100 // Whoops, we don't know this configuration...
101 ATH_MSG_ERROR( "No configuration available for ID "
102 << key->id() );
103 return StatusCode::FAILURE;
104 }
105
106 // Load the new configuration:
107 ATH_CHECK( loadSingleBunches( config_itr->second.filledBCIDs,
108 config_itr->second.filledIntBeam1,
109 config_itr->second.filledIntBeam2 ) );
110 ATH_CHECK( loadBunchTrains( config_itr->second.filledBCIDs,
111 config_itr->second.filledIntBeam1,
112 config_itr->second.filledIntBeam2 ) );
113 ATH_CHECK( loadUnpairedBunches( config_itr->second.unpairedBCIDsBeam1,
114 config_itr->second.unpairedBCIDsBeam2,
115 config_itr->second.unpairedIntBeam1,
116 config_itr->second.unpairedIntBeam2 ) );
117
118 // Remember that this is the new configuration:
119 m_currentID = key->id();
120
121 // Return gracefully:
122 return StatusCode::SUCCESS;
123 }
124
125} // namespace Trig
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_DEBUG(x)
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
ServiceHandle< StoreGateSvc > & evtStore()
DataModel_detail::const_iterator< DataVector > const_iterator
Definition DataVector.h:838
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
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.
BunchCrossingToolBase(const std::string &name="BunchCrossingToolBase")
Default constructor.
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.
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.
virtual StatusCode beginInputFile()
Function called at the beginning of each input file.
Cache_t m_cache
Cached configurations.
xAODBunchCrossingTool(const std::string &name="xAODBunchCrossingTool")
Create a proper constructor for Athena.
std::string m_eventKey
Key of the event data object.
unsigned int m_currentID
The currently loaded configuration ID.
std::string m_metaKey
Key of the metadata container.
virtual StatusCode initialize()
Function initialising the tool.
virtual StatusCode beginEvent()
Function called at the beginning of each event.
MetaStorePtr_t inputMetaStore() const
Accessor for the input metadata store.
The common trigger namespace for trigger analysis tools.
BunchConfContainer_v1 BunchConfContainer
Define the latest version of the bunch configuration container class.
BunchConfKey_v1 BunchConfKey
Declare the current version of the bunch configuration key type.
Structure describing a bunch configuration.
Definition BunchConfig.h:28