Skip to content
Snippets Groups Projects
Commit cb63b230 authored by Vakhtang Tsulaia's avatar Vakhtang Tsulaia
Browse files

Merge branch 'sweep_iov_channel_number_fix_to_master' into 'master'

Sweep IOV channel number fix to master

See merge request atlas/athena!39434
parents 01ccc26b ccf02e12
No related branches found
No related tags found
No related merge requests found
...@@ -114,6 +114,8 @@ public: ...@@ -114,6 +114,8 @@ public:
/// channel number for index: (index = 0 to size-1) /// channel number for index: (index = 0 to size-1)
ChanNum chanNum(unsigned int index) const; ChanNum chanNum(unsigned int index) const;
bool fixChanNum(ChanNum oldChan, ChanNum newChan);
/// attribute list for a given channel number /// attribute list for a given channel number
const AttributeList& attributeList(ChanNum chanNum) const; const AttributeList& attributeList(ChanNum chanNum) const;
...@@ -674,6 +676,26 @@ CondAttrListCollection::isSameButMinRange ( const CondAttrListCollection& rhs, ...@@ -674,6 +676,26 @@ CondAttrListCollection::isSameButMinRange ( const CondAttrListCollection& rhs,
} }
inline bool
CondAttrListCollection::fixChanNum(const ChanNum oldChan,
const ChanNum newChan) {
auto attrRet = m_attrMap.emplace(newChan, m_attrMap[oldChan]);
// if a new element was inserted, erase the old one
if (attrRet.second) m_attrMap.erase(oldChan);
auto iovRet = m_iovMap.emplace(newChan, m_iovMap[oldChan]);
// if a new element was inserted, erase the old one
if (iovRet.second) m_iovMap.erase(oldChan);
auto nameRet = m_nameMap.emplace(newChan, m_nameMap[oldChan]);
// if a new element was inserted, erase the old one
if (nameRet.second) m_nameMap.erase(oldChan);
return attrRet.first->first == newChan
&& iovRet.first->first == newChan
&& nameRet.first->first == newChan;
}
#endif // DBDATAOBJECTS_CONDATTRLISTCOLLECTION_H #endif // DBDATAOBJECTS_CONDATTRLISTCOLLECTION_H
...@@ -12,11 +12,11 @@ atlas_add_library( EvgenProdToolsLib ...@@ -12,11 +12,11 @@ atlas_add_library( EvgenProdToolsLib
PUBLIC_HEADERS EvgenProdTools PUBLIC_HEADERS EvgenProdTools
INCLUDE_DIRS ${ROOT_INCLUDE_DIRS} INCLUDE_DIRS ${ROOT_INCLUDE_DIRS}
LINK_LIBRARIES ${ROOT_LIBRARIES} AtlasHepMCLib AtlasHepMCsearchLib AthenaBaseComps TruthHelper GeneratorModulesLib GenInterfacesLib LINK_LIBRARIES ${ROOT_LIBRARIES} AtlasHepMCLib AtlasHepMCsearchLib AthenaBaseComps TruthHelper GeneratorModulesLib GenInterfacesLib
PRIVATE_LINK_LIBRARIES AthenaKernel EventInfo GaudiKernel TruthUtils ) PRIVATE_LINK_LIBRARIES AthenaKernel EventInfo GaudiKernel TruthUtils IOVDbDataModel AthenaPoolUtilities )
atlas_add_component( EvgenProdTools atlas_add_component( EvgenProdTools
src/components/*.cxx src/components/*.cxx
LINK_LIBRARIES EvgenProdToolsLib ) LINK_LIBRARIES EvgenProdToolsLib IOVDbDataModel AthenaPoolUtilities )
# Install files from the package: # Install files from the package:
atlas_install_python_modules( python/*.py POST_BUILD_CMD ${ATLAS_FLAKE8} ) atlas_install_python_modules( python/*.py POST_BUILD_CMD ${ATLAS_FLAKE8} )
......
...@@ -28,6 +28,8 @@ public: ...@@ -28,6 +28,8 @@ public:
private: private:
ServiceHandle< StoreGateSvc > m_metaDataStore{
"StoreGateSvc/MetaDataStore", name()};
int m_nPass; int m_nPass;
int m_nCount; int m_nCount;
......
...@@ -15,6 +15,9 @@ ...@@ -15,6 +15,9 @@
#include "EventInfo/EventInfo.h" #include "EventInfo/EventInfo.h"
#include "EventInfo/EventID.h" #include "EventInfo/EventID.h"
#include "EventInfo/EventType.h" #include "EventInfo/EventType.h"
#include "IOVDbDataModel/IOVMetaDataContainer.h"
#include "IOVDbDataModel/IOVPayloadContainer.h"
#include "AthenaPoolUtilities/CondAttrListCollection.h"
#include <cmath> #include <cmath>
#include <cassert> #include <cassert>
...@@ -100,10 +103,12 @@ else{ ...@@ -100,10 +103,12 @@ else{
// Change the EventID in the eventinfo header // Change the EventID in the eventinfo header
const EventInfo* pInputEvt(0); const EventInfo* pInputEvt(0);
ATH_MSG_INFO("Set new run number called !!" << m_newRunNumber); ATH_MSG_INFO("Set new run number called !!" << m_newRunNumber);
unsigned int oldRunNumber = 0;
if (evtStore()->retrieve(pInputEvt).isSuccess()) { if (evtStore()->retrieve(pInputEvt).isSuccess()) {
assert(pInputEvt); assert(pInputEvt);
EventID* eventID = const_cast<EventID*>(pInputEvt->event_ID()); EventID* eventID = const_cast<EventID*>(pInputEvt->event_ID());
ATH_MSG_INFO("git eventid !! " ); ATH_MSG_INFO("git eventid !! " );
oldRunNumber = eventID->run_number();
eventID->set_run_number(m_newRunNumber); eventID->set_run_number(m_newRunNumber);
ATH_MSG_INFO("Set new run number" << m_newRunNumber); ATH_MSG_INFO("Set new run number" << m_newRunNumber);
ATH_MSG_DEBUG("Set new run number in event_ID"); ATH_MSG_DEBUG("Set new run number in event_ID");
...@@ -118,6 +123,65 @@ else{ ...@@ -118,6 +123,65 @@ else{
ATH_MSG_ERROR("No EventInfo object found"); ATH_MSG_ERROR("No EventInfo object found");
return StatusCode::SUCCESS; return StatusCode::SUCCESS;
} }
{
// change the channel number where /Generation/Parameters are found
auto newChannelNumber =
static_cast< const CondAttrListCollection::ChanNum >(m_newRunNumber);
auto oldChannelNumber =
static_cast< const CondAttrListCollection::ChanNum >(oldRunNumber);
const char* key = "/Generation/Parameters";
const IOVMetaDataContainer * iovContainer = nullptr;
if (m_metaDataStore->retrieve(iovContainer, key).isSuccess()
&& iovContainer) {
// get a hold of the payload
const IOVPayloadContainer * payloadContainer =
iovContainer->payloadContainer();
// Grab the attribute list
for (CondAttrListCollection* collection : *payloadContainer) {
for(unsigned int index = 0; index < collection->size(); ++index) {
if (collection->chanNum(index) != oldChannelNumber) {
ATH_MSG_INFO("Not updating \"" << key << "\" on channel number "
<< collection->chanNum(index));
continue;
}
if (collection->fixChanNum(oldChannelNumber, newChannelNumber))
ATH_MSG_INFO("Updated \"" << key << "\" channel number from "
<< oldChannelNumber << " to " << newChannelNumber);
else
ATH_MSG_ERROR("Channel number update from " << oldChannelNumber
<< " to " << newChannelNumber << " on \"" << key
<< "\" FAILED");
}
}
{
// Update the MC channel number in the "/TagInfo"
const char* key = "/TagInfo";
const IOVMetaDataContainer * iovContainer = nullptr;
if (m_metaDataStore->retrieve(iovContainer, key).isSuccess()
&& iovContainer) {
// get a hold of the payload
const IOVPayloadContainer * payloadContainer =
iovContainer->payloadContainer();
// Grab the attribute list
for (CondAttrListCollection* collection : *payloadContainer) {
for (auto pair : *collection) {
// pair is a pair of Channel number and AttributeList
if (pair.second.exists("mc_channel_number"))
pair.second["mc_channel_number"].setValue(m_newRunNumber);
}
}
}
}
} else {
ATH_MSG_INFO("Could not retrieve \"" << key << "\" from MetaDataStore");
}
}
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment