Skip to content
Snippets Groups Projects
Commit deed5486 authored by cranshaw's avatar cranshaw
Browse files

Updates to attribute list building in AthenaPoolOutputStream

- remove multiple adds of EventInfoTagBuilder Algorithm
- support both EventInfo and xAOD::EventInfo


Former-commit-id: dcd6dcd7
parent 38b01c48
No related branches found
No related tags found
No related merge requests found
......@@ -18,7 +18,7 @@ def createOutputStream( streamName, fileName = "", asAlg = False, noTag = False
outputStream = AthenaOutputStream(
streamName,
WritingTool = writingTool,
ItemList = [ "EventInfo#*" ]
ItemList = [ "EventInfo#*, xAOD::EventInfo#*, AthenaAttributeList#SimpleTag" ]
)
outputStream.MetadataStore = svcMgr.MetaDataStore
outputStream.MetadataItemList = [ "EventStreamInfo#" + streamName, "IOVMetaDataContainer#*" ]
......@@ -27,13 +27,17 @@ def createOutputStream( streamName, fileName = "", asAlg = False, noTag = False
topSequence = AlgSequence()
if not noTag:
key = "SimpleTag"
# Tell tool to pick it up
outputStream.WritingTool.AttributeListKey=key
# build eventinfo attribute list
from OutputStreamAthenaPoolConf import EventInfoAttListTool
svcMgr.ToolSvc += EventInfoAttListTool()
from OutputStreamAthenaPoolConf import EventInfoTagBuilder
EventInfoTagBuilder = EventInfoTagBuilder(AttributeList="SimpleTag")
topSequence += EventInfoTagBuilder
EventInfoTagBuilder = EventInfoTagBuilder(AttributeList=key)
if ('EventInfoTagBuilder/EventInfoTagBuilder' not in topSequence.getProperties()['Members']):
topSequence += EventInfoTagBuilder
# decide where to put outputstream in sequencing
if asAlg:
......
......@@ -6,7 +6,7 @@
Name : EventInfoAttListTool.cxx
Author : Jack Cranshaw
Created : January 2017
Purpose : create a EventInfoTag - The Tag information associated to the event
Purpose : create a EventInfoAttList - The Tag information associated to the event
is built here
*****************************************************************************/
......@@ -17,14 +17,19 @@ Purpose : create a EventInfoTag - The Tag information associated to the event
#include "GaudiKernel/Property.h"
#include "xAODEventInfo/EventInfo.h"
#include "EventInfo/EventInfo.h"
#include "EventInfo/EventID.h"
#include "EventInfo/EventType.h"
#include "CoralBase/AttributeListSpecification.h"
#include <sstream>
//using xAOD::EventInfo;
/** the constructor */
EventInfoAttListTool::EventInfoAttListTool (const std::string& type,
const std::string& name,
const IInterface* parent) :
EventInfoAttListTool::EventInfoAttListTool (const std::string& type, const
std::string& name, const IInterface* parent) :
AthAlgTool( type, name, parent )
{
declareInterface<EventInfoAttListTool>( this );
......@@ -51,9 +56,25 @@ StatusCode EventInfoAttListTool::initialize() {
}
/** execute - called on every event */
const AthenaAttributeList
EventInfoAttListTool::getAttributeList(const xAOD::EventInfo& eventInfo) {
/* Build attribute list from EventInfo object */
const AthenaAttributeList EventInfoAttListTool::getAttributeList(const xAOD::EventInfo& eventInfo) {
// Create attributeList with appropriate attributes
AthenaAttributeList eventTag( *m_attribListSpec );
StatusCode sc = this->eventTag (eventTag, eventInfo);
if (sc.isFailure()) {
ATH_MSG_WARNING("Unable to build Tag Fragments for the Event");
}
ATH_MSG_DEBUG("EventInfoAttListTool - getAttributeList() return success");
return eventTag;
}
/* Build attribute list from EventInfo object */
const AthenaAttributeList EventInfoAttListTool::getAttributeList(const EventInfo& eventInfo) {
// Create attributeList with appropriate attributes
AthenaAttributeList eventTag( *m_attribListSpec );
......@@ -69,9 +90,8 @@ EventInfoAttListTool::getAttributeList(const xAOD::EventInfo& eventInfo) {
}
/** build the tag associate to the event information */
StatusCode
EventInfoAttListTool::eventTag(AthenaAttributeList& eventTag,
const xAOD::EventInfo& eventInfo)
StatusCode EventInfoAttListTool::eventTag(AthenaAttributeList& eventTag,
const xAOD::EventInfo& eventInfo)
{
/** Event Type */
......@@ -110,6 +130,47 @@ EventInfoAttListTool::eventTag(AthenaAttributeList& eventTag,
}
/** build the tag associate to the event information */
StatusCode EventInfoAttListTool::eventTag(AthenaAttributeList& eventTag,
const EventInfo& eventInfo)
{
/** Event Type */
bool isSimulation = eventInfo.event_type()->test(EventType::IS_SIMULATION);
bool isTestBeam = eventInfo.event_type()->test(EventType::IS_TESTBEAM);
bool isCalibration = eventInfo.event_type()->test(EventType::IS_CALIBRATION);
eventTag["IsSimulation"] .data<bool>() = isSimulation;
eventTag["IsCalibration"].data<bool>() = isCalibration;
eventTag["IsTestBeam"] .data<bool>() = isTestBeam;
// run number and Event number
unsigned int runNumber = eventInfo.event_ID()->run_number();
unsigned int condRunNumber = runNumber;
unsigned long long eventNumber = eventInfo.event_ID()->event_number();
unsigned int lumiBlock = eventInfo.event_ID()->lumi_block();
if (isSimulation) runNumber = eventInfo.event_type()->mc_channel_number();
eventTag["RunNumber"] .data<unsigned int>() = runNumber;
eventTag["EventNumber"] .data<unsigned long long>() = eventNumber;
eventTag["LumiBlockN"] .data<unsigned int>() = lumiBlock;
eventTag["ConditionsRun"].data<unsigned int>() = condRunNumber;
unsigned long timeStamp = eventInfo.event_ID()->time_stamp();
unsigned long timeStampNS = eventInfo.event_ID()->time_stamp_ns_offset();
unsigned long bunchId = eventInfo.event_ID()->bunch_crossing_id();
eventTag["EventTime"] .data<unsigned int>() = timeStamp;
eventTag["EventTimeNanoSec"].data<unsigned int>() = timeStampNS;
eventTag["BunchId"] .data<unsigned int>() = bunchId;
// event weight
// used for event weighting in monte carlo or just an event count in data
float evweight = 1;
if (isSimulation) evweight = eventInfo.event_type()->mc_event_weight();
eventTag["EventWeight"].data<float>() = evweight;
return StatusCode::SUCCESS;
}
/** finialize - called once at the end */
StatusCode EventInfoAttListTool::finalize() {
ATH_MSG_DEBUG("in finalize()");
......
......@@ -14,6 +14,7 @@ Purpose : Tool to buid the Global Event Tags
#include "CoralBase/AttributeListSpecification.h"
#include "PersistentDataModel/AthenaAttributeList.h"
#include "xAODEventInfo/EventInfo.h"
#include "EventInfo/EventInfo.h"
#include <string>
......@@ -26,8 +27,8 @@ public:
/** Standard Constructor */
EventInfoAttListTool(const std::string& type,
const std::string& name,
const IInterface* parent);
const std::string& name,
const IInterface* parent);
/** AlgTool and IAlgTool interface methods */
static const InterfaceID& interfaceID( ) { return IID_EventInfoAttListTool; };
......@@ -40,6 +41,7 @@ public:
bool isValid();
const coral::AttributeListSpecification& getAttributeSpecification();
const AthenaAttributeList getAttributeList(const xAOD::EventInfo& einfo);
const AthenaAttributeList getAttributeList(const EventInfo& einfo);
protected:
......@@ -47,8 +49,10 @@ protected:
virtual ~EventInfoAttListTool( );
/** the various components to build their own fragments of tag */
StatusCode eventTag (AthenaAttributeList& eventTagCol,
const xAOD::EventInfo& eventInfo);
StatusCode eventTag (AthenaAttributeList& eventTagCol,
const xAOD::EventInfo& eventInfo);
StatusCode eventTag (AthenaAttributeList& eventTagCol,
const EventInfo& eventInfo);
coral::AttributeListSpecification* m_attribListSpec;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment