ATLAS Offline Software
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 
14 namespace Trig {
15 
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;
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
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
Trig::BunchCrossingToolBase
Base class for all BunchCrossingTool implementations.
Definition: BunchCrossingToolBase.h:41
Trig::xAODBunchCrossingTool::beginEvent
virtual StatusCode beginEvent()
Function called at the beginning of each event.
Definition: xAODBunchCrossingTool.cxx:86
DataModel_detail::const_iterator
Const iterator class for DataVector/DataList.
Definition: DVLIterator.h:82
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
Trig::xAODBunchCrossingTool::xAODBunchCrossingTool
xAODBunchCrossingTool(const std::string &name="xAODBunchCrossingTool")
Create a proper constructor for Athena.
Definition: xAODBunchCrossingTool.cxx:16
Trig
The common trigger namespace for trigger analysis tools.
Definition: CaloTowerVecMon.h:44
AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
asg::AsgMetadataTool::inputMetaStore
MetaStorePtr_t inputMetaStore() const
Accessor for the input metadata store.
Definition: AsgMetadataTool.cxx:88
mergePhysValFiles.end
end
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:93
xAODBunchCrossingTool.h
Trig::xAODBunchCrossingTool::beginInputFile
virtual StatusCode beginInputFile()
Function called at the beginning of each input file.
Definition: xAODBunchCrossingTool.cxx:35
AthCommonDataStore< AthCommonMsg< AlgTool > >::evtStore
ServiceHandle< StoreGateSvc > & evtStore()
The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:85
python.ConfigurableDb.conf
def conf
Definition: ConfigurableDb.py:282
Trig::xAODBunchCrossingTool::m_metaKey
std::string m_metaKey
Key of the metadata container.
Definition: xAODBunchCrossingTool.h:62
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
DataVector
Derived DataVector<T>.
Definition: DataVector.h:581
Trig::xAODBunchCrossingTool::m_cache
Cache_t m_cache
Cached configurations.
Definition: xAODBunchCrossingTool.h:71
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:192
Trig::xAODBunchCrossingTool::m_eventKey
std::string m_eventKey
Key of the event data object.
Definition: xAODBunchCrossingTool.h:64
Trig::BunchCrossingToolBase::loadUnpairedBunches
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.
Definition: BunchCrossingToolBase.cxx:1118
DataVector::end
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
Trig::BunchCrossingToolBase::loadSingleBunches
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.
Definition: BunchCrossingToolBase.cxx:871
Trig::xAODBunchCrossingTool::m_currentID
unsigned int m_currentID
The currently loaded configuration ID.
Definition: xAODBunchCrossingTool.h:74
BunchConfContainer.h
BunchConfKey.h
Trig::xAODBunchCrossingTool::initialize
virtual StatusCode initialize()
Function initialising the tool.
Definition: xAODBunchCrossingTool.cxx:24
Trig::BunchCrossingToolBase::loadBunchTrains
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.
Definition: BunchCrossingToolBase.cxx:987
DataVector::begin
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
xAOD::BunchConfKey_v1
Class identifying the bunch configuration of a given event.
Definition: BunchConfKey_v1.h:29
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37
Trig::BunchConfig
Structure describing a bunch configuration.
Definition: BunchConfig.h:28